@entifix/next-shell 0.1.0-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 (271) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/dist/index.d.ts +21 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +19 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/back-office/account-menu.d.ts +29 -0
  8. package/dist/lib/back-office/account-menu.d.ts.map +1 -0
  9. package/dist/lib/back-office/account-menu.js +70 -0
  10. package/dist/lib/back-office/account-menu.js.map +1 -0
  11. package/dist/lib/back-office/back-office-shell.d.ts +50 -0
  12. package/dist/lib/back-office/back-office-shell.d.ts.map +1 -0
  13. package/dist/lib/back-office/back-office-shell.js +128 -0
  14. package/dist/lib/back-office/back-office-shell.js.map +1 -0
  15. package/dist/lib/back-office/breadcrumbs.d.ts +16 -0
  16. package/dist/lib/back-office/breadcrumbs.d.ts.map +1 -0
  17. package/dist/lib/back-office/breadcrumbs.js +53 -0
  18. package/dist/lib/back-office/breadcrumbs.js.map +1 -0
  19. package/dist/lib/back-office/group-by-screen-type.d.ts +21 -0
  20. package/dist/lib/back-office/group-by-screen-type.d.ts.map +1 -0
  21. package/dist/lib/back-office/group-by-screen-type.js +39 -0
  22. package/dist/lib/back-office/group-by-screen-type.js.map +1 -0
  23. package/dist/lib/back-office/index.d.ts +6 -0
  24. package/dist/lib/back-office/index.d.ts.map +1 -0
  25. package/dist/lib/back-office/index.js +7 -0
  26. package/dist/lib/back-office/index.js.map +1 -0
  27. package/dist/lib/back-office/nav.d.ts +39 -0
  28. package/dist/lib/back-office/nav.d.ts.map +1 -0
  29. package/dist/lib/back-office/nav.js +3 -0
  30. package/dist/lib/back-office/nav.js.map +1 -0
  31. package/dist/lib/back-office/sidebar-nav.d.ts +26 -0
  32. package/dist/lib/back-office/sidebar-nav.d.ts.map +1 -0
  33. package/dist/lib/back-office/sidebar-nav.js +181 -0
  34. package/dist/lib/back-office/sidebar-nav.js.map +1 -0
  35. package/dist/lib/command-palette/command-palette-host.d.ts +41 -0
  36. package/dist/lib/command-palette/command-palette-host.d.ts.map +1 -0
  37. package/dist/lib/command-palette/command-palette-host.js +196 -0
  38. package/dist/lib/command-palette/command-palette-host.js.map +1 -0
  39. package/dist/lib/command-palette/index.d.ts +9 -0
  40. package/dist/lib/command-palette/index.d.ts.map +1 -0
  41. package/dist/lib/command-palette/index.js +10 -0
  42. package/dist/lib/command-palette/index.js.map +1 -0
  43. package/dist/lib/command-palette/palette-command.d.ts +32 -0
  44. package/dist/lib/command-palette/palette-command.d.ts.map +1 -0
  45. package/dist/lib/command-palette/palette-command.js +19 -0
  46. package/dist/lib/command-palette/palette-command.js.map +1 -0
  47. package/dist/lib/command-palette/use-command-recency.d.ts +28 -0
  48. package/dist/lib/command-palette/use-command-recency.d.ts.map +1 -0
  49. package/dist/lib/command-palette/use-command-recency.js +67 -0
  50. package/dist/lib/command-palette/use-command-recency.js.map +1 -0
  51. package/dist/lib/command-palette/use-command-source.d.ts +17 -0
  52. package/dist/lib/command-palette/use-command-source.d.ts.map +1 -0
  53. package/dist/lib/command-palette/use-command-source.js +70 -0
  54. package/dist/lib/command-palette/use-command-source.js.map +1 -0
  55. package/dist/lib/command-palette/use-nav-source.d.ts +21 -0
  56. package/dist/lib/command-palette/use-nav-source.d.ts.map +1 -0
  57. package/dist/lib/command-palette/use-nav-source.js +78 -0
  58. package/dist/lib/command-palette/use-nav-source.js.map +1 -0
  59. package/dist/lib/command-palette/use-records-source.d.ts +23 -0
  60. package/dist/lib/command-palette/use-records-source.d.ts.map +1 -0
  61. package/dist/lib/command-palette/use-records-source.js +199 -0
  62. package/dist/lib/command-palette/use-records-source.js.map +1 -0
  63. package/dist/lib/command-palette/use-tabs-source.d.ts +20 -0
  64. package/dist/lib/command-palette/use-tabs-source.d.ts.map +1 -0
  65. package/dist/lib/command-palette/use-tabs-source.js +52 -0
  66. package/dist/lib/command-palette/use-tabs-source.js.map +1 -0
  67. package/dist/lib/command-palette/use-use-cases-source.d.ts +22 -0
  68. package/dist/lib/command-palette/use-use-cases-source.d.ts.map +1 -0
  69. package/dist/lib/command-palette/use-use-cases-source.js +93 -0
  70. package/dist/lib/command-palette/use-use-cases-source.js.map +1 -0
  71. package/dist/lib/config/config-route.d.ts +51 -0
  72. package/dist/lib/config/config-route.d.ts.map +1 -0
  73. package/dist/lib/config/config-route.js +65 -0
  74. package/dist/lib/config/config-route.js.map +1 -0
  75. package/dist/lib/config/service-proxy-route.d.ts +28 -0
  76. package/dist/lib/config/service-proxy-route.d.ts.map +1 -0
  77. package/dist/lib/config/service-proxy-route.js +125 -0
  78. package/dist/lib/config/service-proxy-route.js.map +1 -0
  79. package/dist/lib/config/service-token.d.ts +5 -0
  80. package/dist/lib/config/service-token.d.ts.map +1 -0
  81. package/dist/lib/config/service-token.js +18 -0
  82. package/dist/lib/config/service-token.js.map +1 -0
  83. package/dist/lib/crud/entity-crud-form.d.ts +49 -0
  84. package/dist/lib/crud/entity-crud-form.d.ts.map +1 -0
  85. package/dist/lib/crud/entity-crud-form.js +133 -0
  86. package/dist/lib/crud/entity-crud-form.js.map +1 -0
  87. package/dist/lib/crud/hand-off-write.d.ts +35 -0
  88. package/dist/lib/crud/hand-off-write.d.ts.map +1 -0
  89. package/dist/lib/crud/hand-off-write.js +27 -0
  90. package/dist/lib/crud/hand-off-write.js.map +1 -0
  91. package/dist/lib/crud/index.d.ts +9 -0
  92. package/dist/lib/crud/index.d.ts.map +1 -0
  93. package/dist/lib/crud/index.js +10 -0
  94. package/dist/lib/crud/index.js.map +1 -0
  95. package/dist/lib/crud/make-entity-crud.d.ts +28 -0
  96. package/dist/lib/crud/make-entity-crud.d.ts.map +1 -0
  97. package/dist/lib/crud/make-entity-crud.js +318 -0
  98. package/dist/lib/crud/make-entity-crud.js.map +1 -0
  99. package/dist/lib/crud/make-entity-crud.types.d.ts +237 -0
  100. package/dist/lib/crud/make-entity-crud.types.d.ts.map +1 -0
  101. package/dist/lib/crud/make-entity-crud.types.js +6 -0
  102. package/dist/lib/crud/make-entity-crud.types.js.map +1 -0
  103. package/dist/lib/crud/pending-notice.d.ts +31 -0
  104. package/dist/lib/crud/pending-notice.d.ts.map +1 -0
  105. package/dist/lib/crud/pending-notice.js +72 -0
  106. package/dist/lib/crud/pending-notice.js.map +1 -0
  107. package/dist/lib/crud/slug.d.ts +13 -0
  108. package/dist/lib/crud/slug.d.ts.map +1 -0
  109. package/dist/lib/crud/slug.js +13 -0
  110. package/dist/lib/crud/slug.js.map +1 -0
  111. package/dist/lib/crud/use-entity-affordances.d.ts +20 -0
  112. package/dist/lib/crud/use-entity-affordances.d.ts.map +1 -0
  113. package/dist/lib/crud/use-entity-affordances.js +22 -0
  114. package/dist/lib/crud/use-entity-affordances.js.map +1 -0
  115. package/dist/lib/crud/use-entity-bulk.d.ts +43 -0
  116. package/dist/lib/crud/use-entity-bulk.d.ts.map +1 -0
  117. package/dist/lib/crud/use-entity-bulk.js +106 -0
  118. package/dist/lib/crud/use-entity-bulk.js.map +1 -0
  119. package/dist/lib/crud/use-entity-link-sources.d.ts +25 -0
  120. package/dist/lib/crud/use-entity-link-sources.d.ts.map +1 -0
  121. package/dist/lib/crud/use-entity-link-sources.js +37 -0
  122. package/dist/lib/crud/use-entity-link-sources.js.map +1 -0
  123. package/dist/lib/health/health-routes.d.ts +37 -0
  124. package/dist/lib/health/health-routes.d.ts.map +1 -0
  125. package/dist/lib/health/health-routes.js +90 -0
  126. package/dist/lib/health/health-routes.js.map +1 -0
  127. package/dist/lib/i18n/catalog/en.d.ts +4 -0
  128. package/dist/lib/i18n/catalog/en.d.ts.map +1 -0
  129. package/dist/lib/i18n/catalog/en.js +347 -0
  130. package/dist/lib/i18n/catalog/en.js.map +1 -0
  131. package/dist/lib/i18n/catalog/es.d.ts +397 -0
  132. package/dist/lib/i18n/catalog/es.d.ts.map +1 -0
  133. package/dist/lib/i18n/catalog/es.js +407 -0
  134. package/dist/lib/i18n/catalog/es.js.map +1 -0
  135. package/dist/lib/i18n/catalog/index.d.ts +671 -0
  136. package/dist/lib/i18n/catalog/index.d.ts.map +1 -0
  137. package/dist/lib/i18n/catalog/index.js +28 -0
  138. package/dist/lib/i18n/catalog/index.js.map +1 -0
  139. package/dist/lib/i18n/index.d.ts +2 -0
  140. package/dist/lib/i18n/index.d.ts.map +1 -0
  141. package/dist/lib/i18n/index.js +3 -0
  142. package/dist/lib/i18n/index.js.map +1 -0
  143. package/dist/lib/i18n/locale-link.d.ts +23 -0
  144. package/dist/lib/i18n/locale-link.d.ts.map +1 -0
  145. package/dist/lib/i18n/locale-link.js +43 -0
  146. package/dist/lib/i18n/locale-link.js.map +1 -0
  147. package/dist/lib/i18n/spec-catalog.d.ts +2 -0
  148. package/dist/lib/i18n/spec-catalog.d.ts.map +1 -0
  149. package/dist/lib/i18n/spec-catalog.js +84 -0
  150. package/dist/lib/i18n/spec-catalog.js.map +1 -0
  151. package/dist/lib/search/record-search-route.d.ts +44 -0
  152. package/dist/lib/search/record-search-route.d.ts.map +1 -0
  153. package/dist/lib/search/record-search-route.js +158 -0
  154. package/dist/lib/search/record-search-route.js.map +1 -0
  155. package/dist/lib/search/record-search-source.d.ts +59 -0
  156. package/dist/lib/search/record-search-source.d.ts.map +1 -0
  157. package/dist/lib/search/record-search-source.js +118 -0
  158. package/dist/lib/search/record-search-source.js.map +1 -0
  159. package/dist/lib/search/record-search.types.d.ts +85 -0
  160. package/dist/lib/search/record-search.types.d.ts.map +1 -0
  161. package/dist/lib/search/record-search.types.js +29 -0
  162. package/dist/lib/search/record-search.types.js.map +1 -0
  163. package/dist/lib/search/search-records.d.ts +25 -0
  164. package/dist/lib/search/search-records.d.ts.map +1 -0
  165. package/dist/lib/search/search-records.js +36 -0
  166. package/dist/lib/search/search-records.js.map +1 -0
  167. package/dist/lib/session/account-links.d.ts +46 -0
  168. package/dist/lib/session/account-links.d.ts.map +1 -0
  169. package/dist/lib/session/account-links.js +41 -0
  170. package/dist/lib/session/account-links.js.map +1 -0
  171. package/dist/lib/session/bearer.d.ts +25 -0
  172. package/dist/lib/session/bearer.d.ts.map +1 -0
  173. package/dist/lib/session/bearer.js +31 -0
  174. package/dist/lib/session/bearer.js.map +1 -0
  175. package/dist/lib/session/cookies.d.ts +14 -0
  176. package/dist/lib/session/cookies.d.ts.map +1 -0
  177. package/dist/lib/session/cookies.js +33 -0
  178. package/dist/lib/session/cookies.js.map +1 -0
  179. package/dist/lib/session/device.d.ts +31 -0
  180. package/dist/lib/session/device.d.ts.map +1 -0
  181. package/dist/lib/session/device.js +80 -0
  182. package/dist/lib/session/device.js.map +1 -0
  183. package/dist/lib/session/index.d.ts +3 -0
  184. package/dist/lib/session/index.d.ts.map +1 -0
  185. package/dist/lib/session/index.js +12 -0
  186. package/dist/lib/session/index.js.map +1 -0
  187. package/dist/lib/session/refresh-route.d.ts +19 -0
  188. package/dist/lib/session/refresh-route.d.ts.map +1 -0
  189. package/dist/lib/session/refresh-route.js +85 -0
  190. package/dist/lib/session/refresh-route.js.map +1 -0
  191. package/dist/lib/session/session-keepalive.d.ts +52 -0
  192. package/dist/lib/session/session-keepalive.d.ts.map +1 -0
  193. package/dist/lib/session/session-keepalive.js +72 -0
  194. package/dist/lib/session/session-keepalive.js.map +1 -0
  195. package/dist/lib/session/use-session-refresh.d.ts +43 -0
  196. package/dist/lib/session/use-session-refresh.d.ts.map +1 -0
  197. package/dist/lib/session/use-session-refresh.js +120 -0
  198. package/dist/lib/session/use-session-refresh.js.map +1 -0
  199. package/dist/lib/wizard/index.d.ts +4 -0
  200. package/dist/lib/wizard/index.d.ts.map +1 -0
  201. package/dist/lib/wizard/index.js +5 -0
  202. package/dist/lib/wizard/index.js.map +1 -0
  203. package/dist/lib/wizard/use-wizard-draft.d.ts +22 -0
  204. package/dist/lib/wizard/use-wizard-draft.d.ts.map +1 -0
  205. package/dist/lib/wizard/use-wizard-draft.js +39 -0
  206. package/dist/lib/wizard/use-wizard-draft.js.map +1 -0
  207. package/dist/lib/wizard/use-wizard-step-param.d.ts +60 -0
  208. package/dist/lib/wizard/use-wizard-step-param.d.ts.map +1 -0
  209. package/dist/lib/wizard/use-wizard-step-param.js +94 -0
  210. package/dist/lib/wizard/use-wizard-step-param.js.map +1 -0
  211. package/dist/lib/wizard/wizard-tab-kind.d.ts +31 -0
  212. package/dist/lib/wizard/wizard-tab-kind.d.ts.map +1 -0
  213. package/dist/lib/wizard/wizard-tab-kind.js +33 -0
  214. package/dist/lib/wizard/wizard-tab-kind.js.map +1 -0
  215. package/dist/lib/workspace/drafts-state.d.ts +88 -0
  216. package/dist/lib/workspace/drafts-state.d.ts.map +1 -0
  217. package/dist/lib/workspace/drafts-state.js +128 -0
  218. package/dist/lib/workspace/drafts-state.js.map +1 -0
  219. package/dist/lib/workspace/entity-nav.d.ts +26 -0
  220. package/dist/lib/workspace/entity-nav.d.ts.map +1 -0
  221. package/dist/lib/workspace/entity-nav.js +56 -0
  222. package/dist/lib/workspace/entity-nav.js.map +1 -0
  223. package/dist/lib/workspace/entity-tab-kind.d.ts +51 -0
  224. package/dist/lib/workspace/entity-tab-kind.d.ts.map +1 -0
  225. package/dist/lib/workspace/entity-tab-kind.js +47 -0
  226. package/dist/lib/workspace/entity-tab-kind.js.map +1 -0
  227. package/dist/lib/workspace/idb-state-storage.d.ts +9 -0
  228. package/dist/lib/workspace/idb-state-storage.d.ts.map +1 -0
  229. package/dist/lib/workspace/idb-state-storage.js +32 -0
  230. package/dist/lib/workspace/idb-state-storage.js.map +1 -0
  231. package/dist/lib/workspace/index.d.ts +13 -0
  232. package/dist/lib/workspace/index.d.ts.map +1 -0
  233. package/dist/lib/workspace/index.js +14 -0
  234. package/dist/lib/workspace/index.js.map +1 -0
  235. package/dist/lib/workspace/pending-state.d.ts +84 -0
  236. package/dist/lib/workspace/pending-state.d.ts.map +1 -0
  237. package/dist/lib/workspace/pending-state.js +155 -0
  238. package/dist/lib/workspace/pending-state.js.map +1 -0
  239. package/dist/lib/workspace/pending-transactions.d.ts +44 -0
  240. package/dist/lib/workspace/pending-transactions.d.ts.map +1 -0
  241. package/dist/lib/workspace/pending-transactions.js +114 -0
  242. package/dist/lib/workspace/pending-transactions.js.map +1 -0
  243. package/dist/lib/workspace/tab-kind.d.ts +48 -0
  244. package/dist/lib/workspace/tab-kind.d.ts.map +1 -0
  245. package/dist/lib/workspace/tab-kind.js +47 -0
  246. package/dist/lib/workspace/tab-kind.js.map +1 -0
  247. package/dist/lib/workspace/tab-state.d.ts +36 -0
  248. package/dist/lib/workspace/tab-state.d.ts.map +1 -0
  249. package/dist/lib/workspace/tab-state.js +81 -0
  250. package/dist/lib/workspace/tab-state.js.map +1 -0
  251. package/dist/lib/workspace/tabs-state.d.ts +46 -0
  252. package/dist/lib/workspace/tabs-state.d.ts.map +1 -0
  253. package/dist/lib/workspace/tabs-state.js +56 -0
  254. package/dist/lib/workspace/tabs-state.js.map +1 -0
  255. package/dist/lib/workspace/use-entity-draft.d.ts +25 -0
  256. package/dist/lib/workspace/use-entity-draft.d.ts.map +1 -0
  257. package/dist/lib/workspace/use-entity-draft.js +38 -0
  258. package/dist/lib/workspace/use-entity-draft.js.map +1 -0
  259. package/dist/lib/workspace/workspace-scope.d.ts +51 -0
  260. package/dist/lib/workspace/workspace-scope.d.ts.map +1 -0
  261. package/dist/lib/workspace/workspace-scope.js +42 -0
  262. package/dist/lib/workspace/workspace-scope.js.map +1 -0
  263. package/dist/lib/workspace/workspace-shell.d.ts +33 -0
  264. package/dist/lib/workspace/workspace-shell.d.ts.map +1 -0
  265. package/dist/lib/workspace/workspace-shell.js +206 -0
  266. package/dist/lib/workspace/workspace-shell.js.map +1 -0
  267. package/dist/server.d.ts +13 -0
  268. package/dist/server.d.ts.map +1 -0
  269. package/dist/server.js +41 -0
  270. package/dist/server.js.map +1 -0
  271. package/package.json +95 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/crud/make-entity-crud.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ConfigurationRepositoryTag,\n deleteUCFactory,\n type EntityRepositoryTag,\n getUCFactory,\n loadUCFactory,\n saveUCFactory,\n} from '@entifix/business';\nimport {\n describeEntityColumns,\n EntifixBuildError,\n type EntifixError,\n EntifixLogicError,\n type Entity,\n type EntityConstructor,\n envelopeEntityName,\n extractMetaEntity,\n} from '@entifix/core';\nimport { EntityTable, useCasesForSurface } from '@entifix/react-controls';\nimport {\n entityQueryScope,\n useDataLoading,\n useEntityMutation,\n useEntityRecord,\n} from '@entifix/react-integration';\nimport type { TransactionSink } from '@entifix/transactions';\nimport { TransactionSinkTag } from '@entifix/transactions';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { Context } from 'effect';\nimport { useParams, useRouter } from 'next/navigation';\nimport { useState } from 'react';\n\nimport { useLocaleHref } from '../i18n/index.js';\nimport {\n pendingFor,\n pendingRecordsFor,\n usePendingTransactions,\n} from '../workspace/pending-transactions.js';\nimport { EntityCrudForm } from './entity-crud-form.js';\nimport { handOffWrite } from './hand-off-write.js';\nimport type {\n EntityCrud,\n EntityCrudLinkSource,\n EntityCrudOptions,\n EntityCrudSingleViewProps,\n} from './make-entity-crud.types.js';\nimport { PendingNotice } from './pending-notice.js';\nimport { CATALOG_NEW_SLUG, slugToEntityId } from './slug.js';\nimport { useEntityAffordances } from './use-entity-affordances.js';\nimport { useEntityBulk } from './use-entity-bulk.js';\n\n/** What a picker defaults to reading off its target. */\nconst TARGET_NAME_PROPERTY = 'name';\n\n/**\n * What the generated pages' use-cases run against.\n *\n * Exported because a hand-built screen needs the same three: a wizard reads\n * records, resolves pickers and writes through exactly these ports, and\n * rebuilding the union at each such call site is how one of them ends up\n * missing `TransactionSinkTag` and quietly losing its optimistic treatment.\n */\nexport type CrudContext =\n EntityRepositoryTag | ConfigurationRepositoryTag | TransactionSinkTag;\n\n/**\n * Merges the configuration adapter with one repository adapter into the context\n * the use-cases run against.\n *\n * The casts are the price of naming adapters by key: `AdapterKey` narrows which\n * names may be *offered*, but TypeScript will not carry that narrowing through\n * an index access on a generic record. The alternative is every call site\n * passing two `Context` values per entity — the duplication this factory exists\n * to remove.\n */\nexport function mergeCrudContext<TAdapters>(\n adapters: TAdapters,\n configuration: keyof TAdapters,\n repository: keyof TAdapters,\n sink: TransactionSink,\n): Context.Context<CrudContext> {\n return Context.add(\n Context.merge(\n adapters[configuration] as Context.Context<ConfigurationRepositoryTag>,\n adapters[repository] as Context.Context<EntityRepositoryTag>,\n ),\n TransactionSinkTag,\n sink,\n );\n}\n\n/**\n * Builds the list page and the single-record page for one entity.\n *\n * Every catalog entity used to cost ~10 files and ~300 lines whose only variable\n * was a class name: two organisms with a `.types.ts` each, two client pages, two\n * route files. The route files stay (Next needs a module per path); everything\n * between them is derived from the entity's own metadata, so a new reference\n * entity is this call plus a nav entry.\n *\n * Two things are checked here rather than at the call site, because both fail\n * silently otherwise. The catalog key must be the entity's own `@entity({ key })`\n * — they are the same string by convention, and a drifted one titles the form\n * after a different entity in a way only a reader of both catalogs would catch.\n * And a `links` entry must name a real member — a picker aimed at nothing renders\n * identically to a read-only field.\n *\n * **Serves compile-time `@entity()` classes only.** Operator reference data ships\n * with the code, so making this spec-driven would trade type safety for nothing;\n * a vendor-authored `EntitySpecification` renders through a separate path\n * (ADR 0014).\n */\n/**\n * A rejected verb, as something the form's error slot can render.\n *\n * `useErrorMessage` resolves `details.code` through the shared `errors`\n * catalog, so a shell that throws an `EntifixError` carrying one gets its\n * translated sentence; anything else — a network failure, a thrown string —\n * keeps its message rather than being relabelled with a code it never had.\n */\nfunction asEntifixError(failure: unknown): EntifixError {\n return failure instanceof EntifixLogicError ||\n failure instanceof EntifixBuildError\n ? failure\n : new EntifixLogicError(\n failure instanceof Error ? failure.message : String(failure),\n );\n}\n\nexport function makeEntityCrud<TEntity extends Entity, TAdapters>(\n entityConstructor: EntityConstructor<TEntity>,\n options: EntityCrudOptions<TAdapters, TEntity>,\n): EntityCrud<TEntity> {\n const {\n useAdapters,\n basePath,\n catalogKey,\n repository,\n configuration,\n hiddenFields = [],\n columns,\n toolbar,\n links = [],\n metadataSource,\n runBulkUseCase,\n runUseCase,\n } = options;\n\n const meta = extractMetaEntity(entityConstructor);\n if (meta.key !== catalogKey) {\n throw new EntifixBuildError(\n `${entityConstructor.name} declares key \"${String(meta.key)}\" but was given catalog key \"${catalogKey}\"`,\n );\n }\n // Read off `@entity()` rather than rebuilt from `catalogKey`. Both spellings\n // produce the same string today, and that is exactly the problem: a second\n // place that knows how an entity's catalog subtree is laid out is a second\n // place to fix when one moves. `MetaEntityOptions` makes them optional, so an\n // entity that never declared them fails here — where a screen is generated —\n // rather than on the render that first tries to title a tab with `undefined`.\n const { labelKey: entityLabelKey, pluralKey: entityPluralKey } = meta;\n if (entityLabelKey === undefined || entityPluralKey === undefined) {\n throw new EntifixBuildError(\n `${entityConstructor.name} must declare labelKey and pluralKey on @entity() to be generated`,\n );\n }\n\n // Computed once: a descriptor is a property of the class, so nothing about it\n // depends on the record being edited. `linkLabelProperty`/`linkSearchProperty`\n // are overridden here because a scalar foreign key's `@accessor()` cannot name\n // the target's members — it may not import the target at all.\n // The wire name, which is also what a pending entry records and what\n // `entityQueryScopeFor` keys on — one derivation, so a notice and an\n // invalidation can never disagree about which entity they mean.\n const entityName = envelopeEntityName(entityConstructor);\n const descriptors = describeEntityColumns(entityConstructor);\n const linkPlans = links.map(link => {\n const descriptor = descriptors.find(entry => entry.name === link.field);\n if (descriptor === undefined) {\n throw new EntifixBuildError(\n `${entityConstructor.name} has no member \"${link.field}\" for a link source`,\n );\n }\n return {\n ...link,\n descriptor: {\n ...descriptor,\n linkLabelProperty: link.labelProperty ?? TARGET_NAME_PROPERTY,\n linkSearchProperty: link.searchProperty ?? TARGET_NAME_PROPERTY,\n },\n };\n });\n\n function ListPage() {\n const adapters = useAdapters();\n // Outside a `PendingTransactionsProvider` this watches nothing, so a host\n // that has not mounted one behaves exactly as it did before.\n const pending = usePendingTransactions();\n // Every internal href carries the locale. An unprefixed one still resolves —\n // the middleware redirects it — but the visitor pays a round trip per click.\n const withLocale = useLocaleHref();\n\n const queryClient = useQueryClient();\n const scope = entityQueryScope(entityConstructor);\n const affordances = useEntityAffordances(entityConstructor, metadataSource);\n\n // Records this browser has created but the service has not finished\n // writing. Prepended below rather than patched into the cache, which a\n // refetch would undo.\n const optimistic = pendingRecordsFor<TEntity>(pending, entityName);\n\n const pager = useDataLoading<TEntity, CrudContext>({\n uc: loadUCFactory<TEntity>(),\n ctx: mergeCrudContext(adapters, configuration, repository, pending),\n // Scoped rather than left to the per-instance fallback, which is correct\n // but unshared: with the entity's own scope one invalidation refreshes\n // every page and filter of it, which is what a bulk run needs — and it is\n // the same prefix `useReactiveInvalidation`already targets, so a generated\n // list now also refreshes on a reactive change event.\n queryKey: scope,\n });\n\n // Only when this caller may actually run something over a selection.\n //\n // Measured live: an `admin` holds `catalog-reference:*:read` and no\n // `retire`, so the service filters the verb out of `$metadata` — but the\n // selection column still rendered, offering a set that no action could be\n // taken on. A checkbox that can lead nowhere is worse than no checkbox: it\n // reads as a permission the user does not have.\n //\n // Decided from the served document rather than from the runner, because\n // the runner is a property of the *shell* (it knows the route) and the\n // grant is a property of the *caller*. The column therefore appears when\n // the document lands, which is the asynchrony ADR 0026 already accepts for\n // every action surface.\n const canRunBulk =\n useCasesForSurface('bulk-bar', affordances.metadata?.useCases).length > 0;\n\n const bulk = useEntityBulk<TEntity>({\n run: canRunBulk ? runBulkUseCase : undefined,\n // A bulk write changed the rows underneath the listing, so the page is\n // re-read; the selection deliberately survives it (#121 — \"the selection\n // is still there afterwards\"), because the operator's next act is usually\n // to retry the failures or run a second verb on the same rows.\n onCompleted: () => {\n void queryClient.invalidateQueries({ queryKey: scope });\n },\n });\n\n // What a row's overflow menu runs, and the one place the list reports a\n // verb that failed.\n //\n // ⚠️ **A row verb and the form's are the same runner with different\n // arguments.** `EntityTable` hands back the whole record, because that is\n // what it has; `runUseCase` takes an id, because that is what a route needs\n // (#216). The list has no error slot of its own, so a failure lands in the\n // table's own error region — the same one a failed page read uses.\n const [useCaseError, setUseCaseError] = useState<EntifixError | undefined>(\n undefined,\n );\n // Called unconditionally and the *result* gated, the way the surfaces are\n // read in `EntityForm`: the name begins with `use`, so short-circuiting it\n // reads to `react-hooks/rules-of-hooks` as a conditional hook.\n const rowUseCases = useCasesForSurface(\n 'row-menu',\n affordances.metadata?.useCases,\n );\n const canRunRowUseCase = runUseCase !== undefined && rowUseCases.length > 0;\n\n const handleRowUseCase = canRunRowUseCase\n ? (key: string, item: TEntity) => {\n if (item.id == null) return;\n setUseCaseError(undefined);\n void runUseCase(key, item.id).then(\n () => queryClient.invalidateQueries({ queryKey: scope }),\n (failure: unknown) => setUseCaseError(asEntifixError(failure)),\n );\n }\n : undefined;\n\n return (\n <div className=\"flex flex-col gap-s\">\n {/* Above the table, because this is where `afterSave()` leaves the\n operator after a create — and a create is the only transactional\n write there is, so this is the surface the pending state has. */}\n <PendingNotice\n entries={pendingFor(pending, entityName)}\n onDismiss={pending.dismiss}\n />\n <EntityTable\n entityConstructor={entityConstructor}\n {...pager}\n items={[...optimistic, ...pager.items]}\n totalItems={pager.totalItems + optimistic.length}\n hrefFor={id => withLocale(`${basePath}/${String(id)}`)}\n newHref={withLocale(`${basePath}/${CATALOG_NEW_SLUG}`)}\n {...affordances}\n {...bulk.tableProps}\n onUseCase={handleRowUseCase}\n error={useCaseError ?? pager.error}\n >\n {columns}\n {toolbar}\n </EntityTable>\n </div>\n );\n }\n\n /**\n * Dual-host: as a route it reads its slug from the URL and returns to the list\n * on save; in a workspace tab it takes the slug and the post-save action as\n * props.\n */\n function SingleViewPage({\n slug,\n onSaved,\n onDeleted,\n draft,\n }: EntityCrudSingleViewProps = {}) {\n const adapters = useAdapters();\n const pending = usePendingTransactions();\n const router = useRouter();\n const withLocale = useLocaleHref();\n const params = useParams<{ slug: string }>();\n // A verb's failure is this page's, not the record fetch's or the mutation's,\n // so it needs a slot of its own to reach the form's error area.\n const [useCaseError, setUseCaseError] = useState<EntifixError | undefined>(\n undefined,\n );\n const id = slugToEntityId(slug ?? params.slug);\n\n const ctx = mergeCrudContext(adapters, configuration, repository, pending);\n\n const {\n entity,\n isLoading,\n error: loadError,\n reload,\n } = useEntityRecord<TEntity, CrudContext>({\n uc: getUCFactory<TEntity>(),\n ctx,\n id,\n });\n\n const {\n save,\n remove,\n isSaving,\n isDeleting,\n error: writeError,\n } = useEntityMutation<TEntity, CrudContext>({\n saveUc: saveUCFactory<TEntity>(),\n deleteUc: deleteUCFactory<TEntity>(),\n ctx,\n });\n\n // Rebuilt inline on every render on purpose: `useEntityLinkSource` holds\n // these in a ref and keeps them out of its query keys, precisely so a caller\n // does not have to memoise them.\n const linkSources: EntityCrudLinkSource[] = linkPlans.map(plan => ({\n field: plan.field,\n descriptor: plan.descriptor,\n config: {\n entityConstructor: plan.entityConstructor,\n loadUc: loadUCFactory(),\n getUc: getUCFactory(),\n ctx: mergeCrudContext(\n adapters,\n configuration,\n plan.repository,\n pending,\n ),\n },\n }));\n\n const afterSave = onSaved ?? (() => router.push(withLocale(basePath)));\n const afterDelete = onDeleted ?? (() => router.push(withLocale(basePath)));\n\n // The draft is spent once the write *commits*, and only here is that known:\n // `useEntityForm` neither fetches nor saves, so it cannot clear its own.\n // A failed mutation deliberately keeps the draft — the edit is still the\n // user's only copy of what they typed.\n const handleSave = async (next: TEntity) => {\n const saved = await save(next);\n if (saved === undefined) return;\n\n // ⚠️ Deliberately *not* a `setQueriesData` patch. The list refetches on\n // mount — precisely when the operator arrives, having just been navigated\n // here — and the server legitimately does not hold the record yet, so the\n // refetch would replace the patched page and the row would vanish a\n // moment after appearing. The pending set outlives refetches.\n handOffWrite({ id: String(saved.id), record: saved, pending, draft });\n afterSave();\n };\n\n const handleDelete = async () => {\n if (await remove(id)) {\n draft?.clear();\n afterDelete();\n }\n };\n\n /**\n * An `entity`-bound verb, on the record being shown.\n *\n * It **reloads** rather than patching what it has: the service decides the\n * resulting state — a `publish` may land on `published` from four different\n * places — and a client that assumed the new value would show the wrong one\n * the first time the rule changed. `id == null` means the create form,\n * where there is no record to act on and the form renders no verbs anyway.\n *\n * ⚠️ The rejection is **caught and shown**, never left to the promise.\n * `EntityForm`'s `onUseCase` returns `void`, so an uncaught rejection here\n * reaches the console and nothing else — measured on an offering refusing\n * `unpublish` from `draft`: the service answered `409` with a coded body,\n * the record correctly did not move, and the operator saw a button that\n * appeared to do nothing at all.\n */\n const handleUseCase =\n runUseCase === undefined || id == null\n ? undefined\n : (key: string) => {\n setUseCaseError(undefined);\n void runUseCase(key, id).then(\n () => reload(),\n (failure: unknown) => setUseCaseError(asEntifixError(failure)),\n );\n };\n\n return (\n <EntityCrudForm<TEntity>\n // Remounts (and reseeds the fields) once the record arrives.\n key={String(entity?.id ?? CATALOG_NEW_SLUG)}\n entityConstructor={entityConstructor}\n catalogKey={catalogKey}\n metadataSource={metadataSource}\n hiddenFields={hiddenFields}\n links={linkSources}\n entity={entity}\n isLoading={isLoading}\n isSaving={isSaving}\n isDeleting={isDeleting}\n error={loadError ?? writeError ?? useCaseError}\n onSave={handleSave}\n onDelete={id == null ? undefined : handleDelete}\n onUseCase={handleUseCase}\n backHref={withLocale(basePath)}\n draft={draft}\n />\n );\n }\n\n return {\n entityConstructor,\n entityKey: catalogKey,\n entityLabelKey,\n entityPluralKey,\n basePath,\n ListPage,\n SingleViewPage,\n };\n}\n"],"names":["deleteUCFactory","getUCFactory","loadUCFactory","saveUCFactory","describeEntityColumns","EntifixBuildError","EntifixLogicError","envelopeEntityName","extractMetaEntity","EntityTable","useCasesForSurface","entityQueryScope","useDataLoading","useEntityMutation","useEntityRecord","TransactionSinkTag","useQueryClient","Context","useParams","useRouter","useState","useLocaleHref","pendingFor","pendingRecordsFor","usePendingTransactions","EntityCrudForm","handOffWrite","PendingNotice","CATALOG_NEW_SLUG","slugToEntityId","useEntityAffordances","useEntityBulk","TARGET_NAME_PROPERTY","mergeCrudContext","adapters","configuration","repository","sink","add","merge","asEntifixError","failure","Error","message","String","makeEntityCrud","entityConstructor","options","useAdapters","basePath","catalogKey","hiddenFields","columns","toolbar","links","metadataSource","runBulkUseCase","runUseCase","meta","key","name","labelKey","entityLabelKey","pluralKey","entityPluralKey","undefined","entityName","descriptors","linkPlans","map","link","descriptor","find","entry","field","linkLabelProperty","labelProperty","linkSearchProperty","searchProperty","ListPage","affordances","pending","withLocale","queryClient","scope","optimistic","pager","uc","ctx","queryKey","canRunBulk","metadata","useCases","length","bulk","run","onCompleted","invalidateQueries","useCaseError","setUseCaseError","rowUseCases","canRunRowUseCase","handleRowUseCase","item","id","then","div","className","entries","onDismiss","dismiss","items","totalItems","hrefFor","newHref","tableProps","onUseCase","error","SingleViewPage","slug","onSaved","onDeleted","draft","loadError","router","params","entity","isLoading","reload","save","remove","isSaving","isDeleting","writeError","saveUc","deleteUc","linkSources","plan","config","loadUc","getUc","afterSave","push","afterDelete","handleSave","next","saved","record","handleDelete","clear","handleUseCase","onSave","onDelete","backHref","entityKey"],"mappings":"AAAA;;;AAEA,SAEEA,eAAe,EAEfC,YAAY,EACZC,aAAa,EACbC,aAAa,QACR,oBAAoB;AAC3B,SACEC,qBAAqB,EACrBC,iBAAiB,EAEjBC,iBAAiB,EAGjBC,kBAAkB,EAClBC,iBAAiB,QACZ,gBAAgB;AACvB,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,0BAA0B;AAC1E,SACEC,gBAAgB,EAChBC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,QACV,6BAA6B;AAEpC,SAASC,kBAAkB,QAAQ,wBAAwB;AAC3D,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,SAAS,EAAEC,SAAS,QAAQ,kBAAkB;AACvD,SAASC,QAAQ,QAAQ,QAAQ;AAEjC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SACEC,UAAU,EACVC,iBAAiB,EACjBC,sBAAsB,QACjB,uCAAuC;AAC9C,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,YA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AOkF;YACPV,QAAQA;YACRC,WAAWA;YACXI,UAAUA;YACVC,YAAYA;YACZf,KAAK,GAAEM,OAAAA,oBAAAA,YAAaU,sBAAbV,OAA2BzB;YAClCqD,QAAQP;YACRQ,UAAUhD,MAAM,OAAOvC,YAAYmF;YACnChC,WAAWkC;YACXG,UAAUvE,WAAWjC;YACrByE,OAAOA;WAfF9E,gBAAOkF,0BAAAA,OAAQtB,EAAE,oBAAI5E;IAkBhC;IAEA,OAAO;QACLkB;QACA4G,WAAWxG;QACXY;QACAE;QACAf;QACA8B;QACAuC;IACF;AACF"}
@@ -0,0 +1,237 @@
1
+ import type { ConfigurationRepositoryTag, EntityRepositoryTag } from '@entifix/business';
2
+ import type { BulkOutcome, Entity, EntityConstructor, EntityFieldDescriptor, EntityId, EntityMetadataSource, EntitySelection } from '@entifix/core';
3
+ import type { EntityDraftStore, EntityLinkSourceConfig } from '@entifix/react-integration';
4
+ import type { Context } from 'effect/Context';
5
+ import type { CustomTypeOptions } from 'i18next';
6
+ import type { ReactElement, ReactNode } from 'react';
7
+ /**
8
+ * The `entity` catalog keys that carry **both** form titles, a `label` and a
9
+ * `plural`.
10
+ *
11
+ * Derived from the Spanish catalog rather than written out, so the union is the
12
+ * catalog: an entity whose subtree has no `form.editTitle`/`form.newTitle`
13
+ * cannot be handed to {@link makeEntityCrud} at all, and adding a reference
14
+ * entity therefore starts by adding its copy to both locales. That is the whole
15
+ * i18n gate for this factory — `@r10c/i18n-check` scans only
16
+ * `packages/business/ts` for `@useCase()` decorators and never `.tsx`, so a
17
+ * runtime key here would be checked by nothing.
18
+ *
19
+ * `label`/`plural` joined the condition when {@link EntityCrud} began carrying
20
+ * them, so that a workspace tab and a nav entry derived from this descriptor
21
+ * name the entity in the catalog's own words. They are part of the **type**
22
+ * rather than a runtime assertion in the factory, because the catalog is
23
+ * statically known here: a missing `plural` should fail at the call site that
24
+ * generates the screens, not on the render that first tries to title a tab.
25
+ *
26
+ * Keeping the key typed is what lets the generated form call `useT('entity')`
27
+ * with a template literal and still fail the build on a typo, instead of
28
+ * reaching for the `useTranslateKey` escape hatch that authored copy must not
29
+ * use. `AccountLabelKey` in `../session/account-links.ts` is the same trick
30
+ * written out by hand; this one cannot drift because it is computed.
31
+ */
32
+ export type EntityCatalogKey<TEntityCatalog = EntityCatalogOf<TypeOptionsResources>> = [TEntityCatalog] extends [never] ? string : {
33
+ [K in keyof TEntityCatalog]: TEntityCatalog[K] extends {
34
+ form: {
35
+ editTitle: string;
36
+ newTitle: string;
37
+ };
38
+ label: string;
39
+ plural: string;
40
+ } ? K : never;
41
+ }[keyof TEntityCatalog] & string;
42
+ /**
43
+ * The host's `entity` namespace, read back out of its own `i18next`
44
+ * augmentation.
45
+ *
46
+ * ⚠️ **The `entity` catalog is the host's, not entifix's.** It names *their*
47
+ * entities — a parameter, an offering, a sales channel — so a framework that
48
+ * shipped one would be shipping an application's product copy. Reading it back
49
+ * through `CustomTypeOptions` keeps the key union computed rather than written
50
+ * out, which is what stops it drifting, while leaving the catalog where it
51
+ * belongs. A host that declares no augmentation gets `string`, and the factory
52
+ * still works with the gate relaxed.
53
+ */
54
+ type TypeOptionsResources = CustomTypeOptions extends {
55
+ resources: infer R;
56
+ } ? R : never;
57
+ type EntityCatalogOf<TResources> = TResources extends {
58
+ entity: infer E;
59
+ } ? E : never;
60
+ /**
61
+ * A relation the generated form edits with a picker.
62
+ *
63
+ * The target is named here rather than derived, because the common case is a
64
+ * **plain foreign key**: when the target lives in another slice's store a typed
65
+ * `EntityLink` is both an illegal import and a cross-store join, so the member
66
+ * is a bare `string` (`ProductSpecification.brandId` into `catalog-reference`)
67
+ * and its `@accessor()` has no vocabulary for "the target's name". Hence
68
+ * `labelProperty`/`searchProperty` are stated at the call site instead of being
69
+ * left to `describeEntityColumns`' `'name'` default, which happens to be right
70
+ * today and states nothing.
71
+ *
72
+ * `searchProperty` must be `filterable` on the **target** or the service answers
73
+ * `400`; `useEntityLinkSource` throws at render rather than letting that surface
74
+ * as an empty suggestion list.
75
+ */
76
+ export interface EntityCrudLink<TAdapters> {
77
+ /** The owning entity's accessor name, e.g. `'brandId'`. */
78
+ readonly field: string;
79
+ readonly entityConstructor: EntityConstructor<Entity>;
80
+ /**
81
+ * Which adapter holds the **target's** repository. Often a different service
82
+ * than the record's own: `catalog-reference` is another slice's store, so
83
+ * resolving an id goes through that domain's own read path.
84
+ */
85
+ readonly repository: AdapterKey<TAdapters, Context<EntityRepositoryTag>>;
86
+ /** Defaults to `'name'`. */
87
+ readonly labelProperty?: string;
88
+ /** Defaults to `'name'`. Must be `filterable` on the target. */
89
+ readonly searchProperty?: string;
90
+ }
91
+ /** The keys of `TAdapters` whose value is assignable to `TValue`. */
92
+ export type AdapterKey<TAdapters, TValue> = {
93
+ [K in keyof TAdapters]: TAdapters[K] extends TValue ? K : never;
94
+ }[keyof TAdapters];
95
+ export interface EntityCrudOptions<TAdapters, TEntity extends Entity> {
96
+ /** The domain shell's adapters hook, e.g. `useMarketplaceAdminAdapters`. */
97
+ readonly useAdapters: () => TAdapters;
98
+ /** Route prefix for both pages, e.g. `'/catalog/product-brand'`. */
99
+ readonly basePath: string;
100
+ /**
101
+ * The entity's `entity` catalog key. Asserted against `@entity({ key })` at
102
+ * factory time — the two are the same string by convention
103
+ * (`entity:product-brand.label` mirrors `key: 'product-brand'`), and letting
104
+ * them drift would title a form after a different entity.
105
+ */
106
+ readonly catalogKey: EntityCatalogKey;
107
+ /** Which adapter holds this entity's own repository. */
108
+ readonly repository: AdapterKey<TAdapters, Context<EntityRepositoryTag>>;
109
+ readonly configuration: AdapterKey<TAdapters, Context<ConfigurationRepositoryTag>>;
110
+ /**
111
+ * Members the form keeps but does not show — `id` always, plus anything a
112
+ * transaction assigns. A hidden member still round-trips: it is dropped from
113
+ * the rendered fields, not from the draft, so `reconstructEntity` carries it
114
+ * back out of the seeded values.
115
+ */
116
+ readonly hiddenFields?: readonly string[];
117
+ /** `<EntityColumn>` overrides for the list, for presentation metadata cannot express. */
118
+ readonly columns?: ReactNode;
119
+ /**
120
+ * Extra controls beside the table's own — an `<EntityTableToolbar>`.
121
+ *
122
+ * Its own option rather than more `columns`, though both end up as
123
+ * `EntityTable` children and the slots are sorted by component identity: a
124
+ * toolbar filed under a columns prop is a name that lies, and the first thing
125
+ * to go here is a link into a wizard, which is not a column by any reading
126
+ * ([ADR 0045](../../../../../../docs/adr/0045-the-wizard-a-step-graph-and-a-submit-that-hands-off.md)).
127
+ */
128
+ readonly toolbar?: ReactNode;
129
+ /** Frozen at factory time — see `use-entity-link-sources.ts`. */
130
+ readonly links?: readonly EntityCrudLink<TAdapters>[];
131
+ /**
132
+ * Where the entity's served affordances come from — `GET /api/<entity>/$metadata`.
133
+ *
134
+ * Supplying it is what turns on everything ADR 0026 and ADR 0035 describe:
135
+ * Save and Delete filtered against the caller's real grants, the declared
136
+ * verbs on the form, the row overflow menu, and the bulk bar. Omitting it
137
+ * keeps the pre-0026 behaviour exactly, which is what every generated catalog
138
+ * rendered before this option existed.
139
+ *
140
+ * A `EntityMetadataSource` rather than a URL because the two hosts reach
141
+ * their service differently — one through the config-driven REST adapters,
142
+ * one through a shell's own same-origin routes.
143
+ */
144
+ readonly metadataSource?: EntityMetadataSource;
145
+ /**
146
+ * Runs a `collection`-bound verb over a selection, and reports **per row**.
147
+ *
148
+ * Supplying it opts the list into the selection column and the bulk bar.
149
+ * It is separate from `metadataSource` because the two are independent: an
150
+ * entity can declare no collection verb and still want permission-filtered
151
+ * Save, and the endpoint a verb posts to is the shell's knowledge, not
152
+ * metadata's.
153
+ */
154
+ readonly runBulkUseCase?: (key: string, selection: EntitySelection<TEntity>) => Promise<readonly BulkOutcome[]>;
155
+ /**
156
+ * Runs an `entity`-bound verb on the record the single view is showing.
157
+ *
158
+ * The sibling of {@link runBulkUseCase}, and it had to exist for the same
159
+ * reason: `EntityForm` has rendered these buttons since ADR 0035, and
160
+ * `EntityCrudForm` has accepted an `onUseCase` for as long — but nothing ever
161
+ * passed one, so a generated screen showed a declared, granted, served verb
162
+ * that did nothing when clicked. Measured on `ProductOffering`'s `publish`,
163
+ * which passed every `@r10c/slices` invariant and appeared nowhere.
164
+ *
165
+ * Resolving means the record changed, and the page reloads it: a verb that
166
+ * moves a lifecycle leaves the form showing the old state otherwise, which
167
+ * reads as "the button did nothing". Rejecting surfaces through the form's
168
+ * own error slot, so a `409` from an illegal transition renders as the coded
169
+ * message the catalog holds rather than a thrown promise nobody catches.
170
+ */
171
+ readonly runUseCase?: (key: string, id: EntityId) => Promise<void>;
172
+ }
173
+ /**
174
+ * Props both hosts pass. A route host passes none — the slug comes from the URL
175
+ * and a save returns to the list; the workspace tab host passes all of them.
176
+ */
177
+ export interface EntityCrudSingleViewProps {
178
+ /** Defaults to the `[slug]` route param. */
179
+ readonly slug?: string;
180
+ /** Defaults to navigating back to the list. */
181
+ readonly onSaved?: () => void;
182
+ readonly onDeleted?: () => void;
183
+ /**
184
+ * Where to autosave the edit. Supplying it is the whole opt-in: the form
185
+ * seeds from the persisted draft, writes to it on every edit, and the page
186
+ * clears it once a save or delete commits.
187
+ *
188
+ * A route host omits it and stays ephemeral, which is the rule stated as a
189
+ * missing prop rather than as a flag — there is no value of "absent" that
190
+ * accidentally starts persisting.
191
+ */
192
+ readonly draft?: EntityDraftStore;
193
+ }
194
+ /**
195
+ * What the factory returns: a **named descriptor**, not four loose components.
196
+ *
197
+ * The identity fields are here so the workspace registry and the nav are derived
198
+ * from a list of these rather than from the hand-written const maps they replace
199
+ * (#141).
200
+ */
201
+ export interface EntityCrud<TEntity extends Entity> {
202
+ readonly entityConstructor: EntityConstructor<TEntity>;
203
+ /** `@entity({ key })`, which is also `catalogKey` and the tab address payload. */
204
+ readonly entityKey: EntityCatalogKey;
205
+ /**
206
+ * `@entity({ labelKey })` — how one record is named. A record tab's title.
207
+ *
208
+ * Read off the decorator rather than passed, so the tab strip, the nav and the
209
+ * search results all name the entity from the one place it names itself.
210
+ */
211
+ readonly entityLabelKey: string;
212
+ /** `@entity({ pluralKey })` — how the collection is named. A list tab's title. */
213
+ readonly entityPluralKey: string;
214
+ readonly basePath: string;
215
+ readonly ListPage: () => ReactElement;
216
+ readonly SingleViewPage: (props?: EntityCrudSingleViewProps) => ReactElement;
217
+ }
218
+ /**
219
+ * A picker's transport with its context tags erased.
220
+ *
221
+ * The factory cannot preserve one type parameter per link — the pages that
222
+ * build these know their adapters, the generated form only forwards them — and
223
+ * `EntityForm.linkSources` is already `Record<string, EntityLinkSource<any>>`
224
+ * for the same reason.
225
+ */
226
+ export type AnyEntityLinkSourceConfig = EntityLinkSourceConfig<Entity, any>;
227
+ /**
228
+ * One picker, resolved: the descriptor computed once at factory time, and the
229
+ * use-cases plus adapter context the page builds per render.
230
+ */
231
+ export interface EntityCrudLinkSource {
232
+ readonly field: string;
233
+ readonly descriptor: EntityFieldDescriptor;
234
+ readonly config: AnyEntityLinkSourceConfig;
235
+ }
236
+ export {};
237
+ //# sourceMappingURL=make-entity-crud.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-entity-crud.types.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/make-entity-crud.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,eAAe,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,gBAAgB,CAC1B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M,WAAW,yBAAyB;IACxC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC;;;;;;;;OAQG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,OAAO,SAAS,MAAM;IAChD,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACvD,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,kFAAkF;IAClF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE,yBAAyB,KAAK,YAAY,CAAC;CAC9E;AAED;;;;;;;GAOG;AAEH,MAAM,MAAM,yBAAyB,GAAG,sBAAsB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5E;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC;CAC5C"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * One picker, resolved: the descriptor computed once at factory time, and the
3
+ * use-cases plus adapter context the page builds per render.
4
+ */ export { };
5
+
6
+ //# sourceMappingURL=make-entity-crud.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/crud/make-entity-crud.types.ts"],"sourcesContent":["import type {\n ConfigurationRepositoryTag,\n EntityRepositoryTag,\n} from '@entifix/business';\nimport type {\n BulkOutcome,\n Entity,\n EntityConstructor,\n EntityFieldDescriptor,\n EntityId,\n EntityMetadataSource,\n EntitySelection,\n} from '@entifix/core';\nimport type {\n EntityDraftStore,\n EntityLinkSourceConfig,\n} from '@entifix/react-integration';\nimport type { Context } from 'effect/Context';\nimport type { CustomTypeOptions } from 'i18next';\nimport type { ReactElement, ReactNode } from 'react';\n\n/**\n * The `entity` catalog keys that carry **both** form titles, a `label` and a\n * `plural`.\n *\n * Derived from the Spanish catalog rather than written out, so the union is the\n * catalog: an entity whose subtree has no `form.editTitle`/`form.newTitle`\n * cannot be handed to {@link makeEntityCrud} at all, and adding a reference\n * entity therefore starts by adding its copy to both locales. That is the whole\n * i18n gate for this factory — `@r10c/i18n-check` scans only\n * `packages/business/ts` for `@useCase()` decorators and never `.tsx`, so a\n * runtime key here would be checked by nothing.\n *\n * `label`/`plural` joined the condition when {@link EntityCrud} began carrying\n * them, so that a workspace tab and a nav entry derived from this descriptor\n * name the entity in the catalog's own words. They are part of the **type**\n * rather than a runtime assertion in the factory, because the catalog is\n * statically known here: a missing `plural` should fail at the call site that\n * generates the screens, not on the render that first tries to title a tab.\n *\n * Keeping the key typed is what lets the generated form call `useT('entity')`\n * with a template literal and still fail the build on a typo, instead of\n * reaching for the `useTranslateKey` escape hatch that authored copy must not\n * use. `AccountLabelKey` in `../session/account-links.ts` is the same trick\n * written out by hand; this one cannot drift because it is computed.\n */\nexport type EntityCatalogKey<\n TEntityCatalog = EntityCatalogOf<TypeOptionsResources>,\n> = [TEntityCatalog] extends [never]\n ? // No host augmentation in this compilation — this package's own specs, or\n // an adopter who has not declared one. The factory still works; the key is\n // simply unchecked, which is the same trade `useTranslateKey` makes.\n string\n : {\n [K in keyof TEntityCatalog]: TEntityCatalog[K] extends {\n form: { editTitle: string; newTitle: string };\n label: string;\n plural: string;\n }\n ? K\n : never;\n }[keyof TEntityCatalog] &\n string;\n\n/**\n * The host's `entity` namespace, read back out of its own `i18next`\n * augmentation.\n *\n * ⚠️ **The `entity` catalog is the host's, not entifix's.** It names *their*\n * entities — a parameter, an offering, a sales channel — so a framework that\n * shipped one would be shipping an application's product copy. Reading it back\n * through `CustomTypeOptions` keeps the key union computed rather than written\n * out, which is what stops it drifting, while leaving the catalog where it\n * belongs. A host that declares no augmentation gets `string`, and the factory\n * still works with the gate relaxed.\n */\ntype TypeOptionsResources = CustomTypeOptions extends { resources: infer R }\n ? R\n : never;\n\ntype EntityCatalogOf<TResources> = TResources extends { entity: infer E }\n ? E\n : never;\n\n/**\n * A relation the generated form edits with a picker.\n *\n * The target is named here rather than derived, because the common case is a\n * **plain foreign key**: when the target lives in another slice's store a typed\n * `EntityLink` is both an illegal import and a cross-store join, so the member\n * is a bare `string` (`ProductSpecification.brandId` into `catalog-reference`)\n * and its `@accessor()` has no vocabulary for \"the target's name\". Hence\n * `labelProperty`/`searchProperty` are stated at the call site instead of being\n * left to `describeEntityColumns`' `'name'` default, which happens to be right\n * today and states nothing.\n *\n * `searchProperty` must be `filterable` on the **target** or the service answers\n * `400`; `useEntityLinkSource` throws at render rather than letting that surface\n * as an empty suggestion list.\n */\nexport interface EntityCrudLink<TAdapters> {\n /** The owning entity's accessor name, e.g. `'brandId'`. */\n readonly field: string;\n readonly entityConstructor: EntityConstructor<Entity>;\n /**\n * Which adapter holds the **target's** repository. Often a different service\n * than the record's own: `catalog-reference` is another slice's store, so\n * resolving an id goes through that domain's own read path.\n */\n readonly repository: AdapterKey<TAdapters, Context<EntityRepositoryTag>>;\n /** Defaults to `'name'`. */\n readonly labelProperty?: string;\n /** Defaults to `'name'`. Must be `filterable` on the target. */\n readonly searchProperty?: string;\n}\n\n/** The keys of `TAdapters` whose value is assignable to `TValue`. */\nexport type AdapterKey<TAdapters, TValue> = {\n [K in keyof TAdapters]: TAdapters[K] extends TValue ? K : never;\n}[keyof TAdapters];\n\nexport interface EntityCrudOptions<TAdapters, TEntity extends Entity> {\n /** The domain shell's adapters hook, e.g. `useMarketplaceAdminAdapters`. */\n readonly useAdapters: () => TAdapters;\n /** Route prefix for both pages, e.g. `'/catalog/product-brand'`. */\n readonly basePath: string;\n /**\n * The entity's `entity` catalog key. Asserted against `@entity({ key })` at\n * factory time — the two are the same string by convention\n * (`entity:product-brand.label` mirrors `key: 'product-brand'`), and letting\n * them drift would title a form after a different entity.\n */\n readonly catalogKey: EntityCatalogKey;\n /** Which adapter holds this entity's own repository. */\n readonly repository: AdapterKey<TAdapters, Context<EntityRepositoryTag>>;\n readonly configuration: AdapterKey<\n TAdapters,\n Context<ConfigurationRepositoryTag>\n >;\n /**\n * Members the form keeps but does not show — `id` always, plus anything a\n * transaction assigns. A hidden member still round-trips: it is dropped from\n * the rendered fields, not from the draft, so `reconstructEntity` carries it\n * back out of the seeded values.\n */\n readonly hiddenFields?: readonly string[];\n /** `<EntityColumn>` overrides for the list, for presentation metadata cannot express. */\n readonly columns?: ReactNode;\n /**\n * Extra controls beside the table's own — an `<EntityTableToolbar>`.\n *\n * Its own option rather than more `columns`, though both end up as\n * `EntityTable` children and the slots are sorted by component identity: a\n * toolbar filed under a columns prop is a name that lies, and the first thing\n * to go here is a link into a wizard, which is not a column by any reading\n * ([ADR 0045](../../../../../../docs/adr/0045-the-wizard-a-step-graph-and-a-submit-that-hands-off.md)).\n */\n readonly toolbar?: ReactNode;\n /** Frozen at factory time — see `use-entity-link-sources.ts`. */\n readonly links?: readonly EntityCrudLink<TAdapters>[];\n /**\n * Where the entity's served affordances come from — `GET /api/<entity>/$metadata`.\n *\n * Supplying it is what turns on everything ADR 0026 and ADR 0035 describe:\n * Save and Delete filtered against the caller's real grants, the declared\n * verbs on the form, the row overflow menu, and the bulk bar. Omitting it\n * keeps the pre-0026 behaviour exactly, which is what every generated catalog\n * rendered before this option existed.\n *\n * A `EntityMetadataSource` rather than a URL because the two hosts reach\n * their service differently — one through the config-driven REST adapters,\n * one through a shell's own same-origin routes.\n */\n readonly metadataSource?: EntityMetadataSource;\n /**\n * Runs a `collection`-bound verb over a selection, and reports **per row**.\n *\n * Supplying it opts the list into the selection column and the bulk bar.\n * It is separate from `metadataSource` because the two are independent: an\n * entity can declare no collection verb and still want permission-filtered\n * Save, and the endpoint a verb posts to is the shell's knowledge, not\n * metadata's.\n */\n readonly runBulkUseCase?: (\n key: string,\n selection: EntitySelection<TEntity>,\n ) => Promise<readonly BulkOutcome[]>;\n /**\n * Runs an `entity`-bound verb on the record the single view is showing.\n *\n * The sibling of {@link runBulkUseCase}, and it had to exist for the same\n * reason: `EntityForm` has rendered these buttons since ADR 0035, and\n * `EntityCrudForm` has accepted an `onUseCase` for as long — but nothing ever\n * passed one, so a generated screen showed a declared, granted, served verb\n * that did nothing when clicked. Measured on `ProductOffering`'s `publish`,\n * which passed every `@r10c/slices` invariant and appeared nowhere.\n *\n * Resolving means the record changed, and the page reloads it: a verb that\n * moves a lifecycle leaves the form showing the old state otherwise, which\n * reads as \"the button did nothing\". Rejecting surfaces through the form's\n * own error slot, so a `409` from an illegal transition renders as the coded\n * message the catalog holds rather than a thrown promise nobody catches.\n */\n readonly runUseCase?: (key: string, id: EntityId) => Promise<void>;\n}\n\n/**\n * Props both hosts pass. A route host passes none — the slug comes from the URL\n * and a save returns to the list; the workspace tab host passes all of them.\n */\nexport interface EntityCrudSingleViewProps {\n /** Defaults to the `[slug]` route param. */\n readonly slug?: string;\n /** Defaults to navigating back to the list. */\n readonly onSaved?: () => void;\n readonly onDeleted?: () => void;\n /**\n * Where to autosave the edit. Supplying it is the whole opt-in: the form\n * seeds from the persisted draft, writes to it on every edit, and the page\n * clears it once a save or delete commits.\n *\n * A route host omits it and stays ephemeral, which is the rule stated as a\n * missing prop rather than as a flag — there is no value of \"absent\" that\n * accidentally starts persisting.\n */\n readonly draft?: EntityDraftStore;\n}\n\n/**\n * What the factory returns: a **named descriptor**, not four loose components.\n *\n * The identity fields are here so the workspace registry and the nav are derived\n * from a list of these rather than from the hand-written const maps they replace\n * (#141).\n */\nexport interface EntityCrud<TEntity extends Entity> {\n readonly entityConstructor: EntityConstructor<TEntity>;\n /** `@entity({ key })`, which is also `catalogKey` and the tab address payload. */\n readonly entityKey: EntityCatalogKey;\n /**\n * `@entity({ labelKey })` — how one record is named. A record tab's title.\n *\n * Read off the decorator rather than passed, so the tab strip, the nav and the\n * search results all name the entity from the one place it names itself.\n */\n readonly entityLabelKey: string;\n /** `@entity({ pluralKey })` — how the collection is named. A list tab's title. */\n readonly entityPluralKey: string;\n readonly basePath: string;\n readonly ListPage: () => ReactElement;\n readonly SingleViewPage: (props?: EntityCrudSingleViewProps) => ReactElement;\n}\n\n/**\n * A picker's transport with its context tags erased.\n *\n * The factory cannot preserve one type parameter per link — the pages that\n * build these know their adapters, the generated form only forwards them — and\n * `EntityForm.linkSources` is already `Record<string, EntityLinkSource<any>>`\n * for the same reason.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyEntityLinkSourceConfig = EntityLinkSourceConfig<Entity, any>;\n\n/**\n * One picker, resolved: the descriptor computed once at factory time, and the\n * use-cases plus adapter context the page builds per render.\n */\nexport interface EntityCrudLinkSource {\n readonly field: string;\n readonly descriptor: EntityFieldDescriptor;\n readonly config: AnyEntityLinkSourceConfig;\n}\n"],"names":[],"mappings":"AAwQA;;;CAGC,GACD,WAIC"}
@@ -0,0 +1,31 @@
1
+ import type { PendingEntry } from '@entifix/transactions';
2
+ export interface PendingNoticeProps {
3
+ /** This entity's in-flight and failed writes, newest last. */
4
+ entries: readonly PendingEntry[];
5
+ /** Retires a failure the operator has read. */
6
+ onDismiss: (transactionId: string) => void;
7
+ className?: string;
8
+ }
9
+ /**
10
+ * What became of the writes this browser started but the server has not
11
+ * finished.
12
+ *
13
+ * ⚠️ **This is the list's surface because the tab strip cannot be.** Only
14
+ * creates are transactional (`create: 'command'` fires on `isCreate` alone), and
15
+ * a create has no workspace tab — `EntityEditorTab` takes a required id, so
16
+ * `master:<key>` is the list and there is no address for a record that does not
17
+ * exist yet. A badge keyed on a pending record id would therefore be unreachable
18
+ * by construction, which is exactly the "declared, styled, never produced"
19
+ * defect ADR 0043 was written about. It renders here instead, where
20
+ * `afterSave()` actually puts the operator.
21
+ *
22
+ * `role="status"`, not `role="alert"` — the `BulkResult` reasoning: an outcome
23
+ * to read, not an interruption.
24
+ *
25
+ * The failure headline is a catalog key and never `entry.reason`, which is free
26
+ * text from whatever threw, in whatever language that code was written in. The
27
+ * reason is kept as secondary, explicitly-unlocalized detail; a translatable
28
+ * failure needs an error *code* on the event, which is ADR 0043's residual.
29
+ */
30
+ export declare function PendingNotice({ entries, onDismiss, className, }: PendingNoticeProps): import("react").JSX.Element | null;
31
+ //# sourceMappingURL=pending-notice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-notice.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/pending-notice.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IACjC,+CAA+C;IAC/C,SAAS,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,SAAS,EACT,SAAS,GACV,EAAE,kBAAkB,sCA0DpB"}
@@ -0,0 +1,72 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Button, cn, useT } from '@entifix/react-controls/primitives';
4
+ /**
5
+ * What became of the writes this browser started but the server has not
6
+ * finished.
7
+ *
8
+ * ⚠️ **This is the list's surface because the tab strip cannot be.** Only
9
+ * creates are transactional (`create: 'command'` fires on `isCreate` alone), and
10
+ * a create has no workspace tab — `EntityEditorTab` takes a required id, so
11
+ * `master:<key>` is the list and there is no address for a record that does not
12
+ * exist yet. A badge keyed on a pending record id would therefore be unreachable
13
+ * by construction, which is exactly the "declared, styled, never produced"
14
+ * defect ADR 0043 was written about. It renders here instead, where
15
+ * `afterSave()` actually puts the operator.
16
+ *
17
+ * `role="status"`, not `role="alert"` — the `BulkResult` reasoning: an outcome
18
+ * to read, not an interruption.
19
+ *
20
+ * The failure headline is a catalog key and never `entry.reason`, which is free
21
+ * text from whatever threw, in whatever language that code was written in. The
22
+ * reason is kept as secondary, explicitly-unlocalized detail; a translatable
23
+ * failure needs an error *code* on the event, which is ADR 0043's residual.
24
+ */ export function PendingNotice({ entries, onDismiss, className }) {
25
+ // The `shell` namespace: this copy lives in `shell.ts`, and `useT()` with no
26
+ // argument reads `controls` — which resolves nothing and renders the key.
27
+ const t = useT('shell');
28
+ const saving = entries.filter((entry)=>entry.state === 'pending');
29
+ const failed = entries.filter((entry)=>entry.state === 'failed');
30
+ if (saving.length === 0 && failed.length === 0) return null;
31
+ return /*#__PURE__*/ _jsxs("div", {
32
+ role: "status",
33
+ "aria-label": t('workspace.pendingLabel'),
34
+ "data-testid": "pending-notice",
35
+ className: cn('flex flex-col gap-2xs rounded-lg border border-border bg-surface-elevated px-s py-2xs', className),
36
+ children: [
37
+ saving.length > 0 && /*#__PURE__*/ _jsx("span", {
38
+ className: "text-step-sm text-content-muted",
39
+ children: t('workspace.savePending', {
40
+ count: saving.length
41
+ })
42
+ }),
43
+ failed.map((entry)=>/*#__PURE__*/ _jsxs("div", {
44
+ className: "flex flex-wrap items-center gap-2xs",
45
+ children: [
46
+ /*#__PURE__*/ _jsx("span", {
47
+ className: "text-step-sm text-danger",
48
+ children: t('workspace.saveFailed')
49
+ }),
50
+ entry.reason !== undefined && // Untranslated on purpose, and marked as such: it is a server
51
+ // exception string, shown because a reason nobody can read is worse
52
+ // than one in the wrong language.
53
+ /*#__PURE__*/ _jsx("span", {
54
+ lang: "und",
55
+ className: "text-step-sm text-content-muted",
56
+ "data-testid": "pending-notice-reason",
57
+ children: entry.reason
58
+ }),
59
+ /*#__PURE__*/ _jsx(Button, {
60
+ type: "button",
61
+ variant: "ghost",
62
+ size: "sm",
63
+ onClick: ()=>onDismiss(entry.transactionId),
64
+ children: t('workspace.saveFailedDismiss')
65
+ })
66
+ ]
67
+ }, entry.transactionId))
68
+ ]
69
+ });
70
+ }
71
+
72
+ //# sourceMappingURL=pending-notice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/crud/pending-notice.tsx"],"sourcesContent":["'use client';\n\nimport { Button, cn, useT } from '@entifix/react-controls/primitives';\nimport type { PendingEntry } from '@entifix/transactions';\n\nexport interface PendingNoticeProps {\n /** This entity's in-flight and failed writes, newest last. */\n entries: readonly PendingEntry[];\n /** Retires a failure the operator has read. */\n onDismiss: (transactionId: string) => void;\n className?: string;\n}\n\n/**\n * What became of the writes this browser started but the server has not\n * finished.\n *\n * ⚠️ **This is the list's surface because the tab strip cannot be.** Only\n * creates are transactional (`create: 'command'` fires on `isCreate` alone), and\n * a create has no workspace tab — `EntityEditorTab` takes a required id, so\n * `master:<key>` is the list and there is no address for a record that does not\n * exist yet. A badge keyed on a pending record id would therefore be unreachable\n * by construction, which is exactly the \"declared, styled, never produced\"\n * defect ADR 0043 was written about. It renders here instead, where\n * `afterSave()` actually puts the operator.\n *\n * `role=\"status\"`, not `role=\"alert\"` — the `BulkResult` reasoning: an outcome\n * to read, not an interruption.\n *\n * The failure headline is a catalog key and never `entry.reason`, which is free\n * text from whatever threw, in whatever language that code was written in. The\n * reason is kept as secondary, explicitly-unlocalized detail; a translatable\n * failure needs an error *code* on the event, which is ADR 0043's residual.\n */\nexport function PendingNotice({\n entries,\n onDismiss,\n className,\n}: PendingNoticeProps) {\n // The `shell` namespace: this copy lives in `shell.ts`, and `useT()` with no\n // argument reads `controls` — which resolves nothing and renders the key.\n const t = useT('shell');\n\n const saving = entries.filter(entry => entry.state === 'pending');\n const failed = entries.filter(entry => entry.state === 'failed');\n\n if (saving.length === 0 && failed.length === 0) return null;\n\n return (\n <div\n role=\"status\"\n aria-label={t('workspace.pendingLabel')}\n data-testid=\"pending-notice\"\n className={cn(\n 'flex flex-col gap-2xs rounded-lg border border-border bg-surface-elevated px-s py-2xs',\n className,\n )}\n >\n {saving.length > 0 && (\n <span className=\"text-step-sm text-content-muted\">\n {t('workspace.savePending', { count: saving.length })}\n </span>\n )}\n\n {failed.map(entry => (\n <div\n key={entry.transactionId}\n className=\"flex flex-wrap items-center gap-2xs\"\n >\n <span className=\"text-step-sm text-danger\">\n {t('workspace.saveFailed')}\n </span>\n {entry.reason !== undefined && (\n // Untranslated on purpose, and marked as such: it is a server\n // exception string, shown because a reason nobody can read is worse\n // than one in the wrong language.\n <span\n lang=\"und\"\n className=\"text-step-sm text-content-muted\"\n data-testid=\"pending-notice-reason\"\n >\n {entry.reason}\n </span>\n )}\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => onDismiss(entry.transactionId)}\n >\n {t('workspace.saveFailedDismiss')}\n </Button>\n </div>\n ))}\n </div>\n );\n}\n"],"names":["Button","cn","useT","PendingNotice","entries","onDismiss","className","t","saving","filter","entry","state","failed","length","div","role","aria-label","data-testid","span","count","map","reason","undefined","lang","type","variant","size","onClick","transactionId"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,EAAE,EAAEC,IAAI,QAAQ,qCAAqC;AAWtE;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASC,cAAc,EAC5BC,OAAO,EACPC,SAAS,EACTC,SAAS,EACU;IACnB,6EAA6E;IAC7E,0EAA0E;IAC1E,MAAMC,IAAIL,KAAK;IAEf,MAAMM,SAASJ,QAAQK,MAAM,CAACC,CAAAA,QAASA,MAAMC,KAAK,KAAK;IACvD,MAAMC,SAASR,QAAQK,MAAM,CAACC,CAAAA,QAASA,MAAMC,KAAK,KAAK;IAEvD,IAAIH,OAAOK,MAAM,KAAK,KAAKD,OAAOC,MAAM,KAAK,GAAG,OAAO;IAEvD,qBACE,MAACC;QACCC,MAAK;QACLC,cAAYT,EAAE;QACdU,eAAY;QACZX,WAAWL,GACT,yFACAK;;YAGDE,OAAOK,MAAM,GAAG,mBACf,KAACK;gBAAKZ,WAAU;0BACbC,EAAE,yBAAyB;oBAAEY,OAAOX,OAAOK,MAAM;gBAAC;;YAItDD,OAAOQ,GAAG,CAACV,CAAAA,sBACV,MAACI;oBAECR,WAAU;;sCAEV,KAACY;4BAAKZ,WAAU;sCACbC,EAAE;;wBAEJG,MAAMW,MAAM,KAAKC,aAChB,8DAA8D;wBAC9D,oEAAoE;wBACpE,kCAAkC;sCAClC,KAACJ;4BACCK,MAAK;4BACLjB,WAAU;4BACVW,eAAY;sCAEXP,MAAMW,MAAM;;sCAGjB,KAACrB;4BACCwB,MAAK;4BACLC,SAAQ;4BACRC,MAAK;4BACLC,SAAS,IAAMtB,UAAUK,MAAMkB,aAAa;sCAE3CrB,EAAE;;;mBAxBAG,MAAMkB,aAAa;;;AA8BlC"}
@@ -0,0 +1,13 @@
1
+ import type { EntityId } from '@entifix/core';
2
+ /**
3
+ * The `[slug]` value that means "create" rather than an existing record, as in
4
+ * `/catalog/product/new`. Reserving this one literal is the cost of addressing
5
+ * the create form through the same dynamic segment as every record.
6
+ */
7
+ export declare const CATALOG_NEW_SLUG = "new";
8
+ /**
9
+ * Maps a route slug to the id of the record to load. `undefined` means there is
10
+ * nothing to load — the create case.
11
+ */
12
+ export declare function slugToEntityId(slug: string | undefined): EntityId;
13
+ //# sourceMappingURL=slug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/slug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAEjE"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The `[slug]` value that means "create" rather than an existing record, as in
3
+ * `/catalog/product/new`. Reserving this one literal is the cost of addressing
4
+ * the create form through the same dynamic segment as every record.
5
+ */ export const CATALOG_NEW_SLUG = 'new';
6
+ /**
7
+ * Maps a route slug to the id of the record to load. `undefined` means there is
8
+ * nothing to load — the create case.
9
+ */ export function slugToEntityId(slug) {
10
+ return slug == null || slug === CATALOG_NEW_SLUG ? undefined : slug;
11
+ }
12
+
13
+ //# sourceMappingURL=slug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/crud/slug.ts"],"sourcesContent":["import type { EntityId } from '@entifix/core';\n\n/**\n * The `[slug]` value that means \"create\" rather than an existing record, as in\n * `/catalog/product/new`. Reserving this one literal is the cost of addressing\n * the create form through the same dynamic segment as every record.\n */\nexport const CATALOG_NEW_SLUG = 'new';\n\n/**\n * Maps a route slug to the id of the record to load. `undefined` means there is\n * nothing to load — the create case.\n */\nexport function slugToEntityId(slug: string | undefined): EntityId {\n return slug == null || slug === CATALOG_NEW_SLUG ? undefined : slug;\n}\n"],"names":["CATALOG_NEW_SLUG","slugToEntityId","slug","undefined"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,mBAAmB,MAAM;AAEtC;;;CAGC,GACD,OAAO,SAASC,eAAeC,IAAwB;IACrD,OAAOA,QAAQ,QAAQA,SAASF,mBAAmBG,YAAYD;AACjE"}
@@ -0,0 +1,20 @@
1
+ import type { Entity, EntityConstructor, EntityMetadataDocument, EntityMetadataSource } from '@entifix/core';
2
+ /** What a surface needs to render an entity's served affordances. */
3
+ export interface EntityAffordances {
4
+ metadata?: EntityMetadataDocument;
5
+ isMetadataLoading: boolean;
6
+ }
7
+ /**
8
+ * Reads what this caller may do with an entity, in the shape a surface spreads.
9
+ *
10
+ * A thin rename over `useEntityUseCases` — `isLoading` becomes
11
+ * `isMetadataLoading` — so a page can spread the result straight into
12
+ * `EntityForm` or `EntityTable` beside its other props, rather than restating
13
+ * two lines at every call site. An absent source is the hook's own business.
14
+ *
15
+ * Absent metadata is **not** a security posture: it is the shape both surfaces
16
+ * read as "behave exactly as before ADR 0026". The route guard is the
17
+ * authorization boundary.
18
+ */
19
+ export declare function useEntityAffordances<TEntity extends Entity>(entityConstructor: EntityConstructor<TEntity>, source: EntityMetadataSource | undefined): EntityAffordances;
20
+ //# sourceMappingURL=use-entity-affordances.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-entity-affordances.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/use-entity-affordances.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAGvB,qEAAqE;AACrE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,MAAM,EACzD,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAC7C,MAAM,EAAE,oBAAoB,GAAG,SAAS,GACvC,iBAAiB,CAInB"}
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ import { useEntityUseCases } from '@entifix/react-integration';
3
+ /**
4
+ * Reads what this caller may do with an entity, in the shape a surface spreads.
5
+ *
6
+ * A thin rename over `useEntityUseCases` — `isLoading` becomes
7
+ * `isMetadataLoading` — so a page can spread the result straight into
8
+ * `EntityForm` or `EntityTable` beside its other props, rather than restating
9
+ * two lines at every call site. An absent source is the hook's own business.
10
+ *
11
+ * Absent metadata is **not** a security posture: it is the shape both surfaces
12
+ * read as "behave exactly as before ADR 0026". The route guard is the
13
+ * authorization boundary.
14
+ */ export function useEntityAffordances(entityConstructor, source) {
15
+ const { metadata, isLoading } = useEntityUseCases(entityConstructor, source);
16
+ return {
17
+ metadata,
18
+ isMetadataLoading: isLoading
19
+ };
20
+ }
21
+
22
+ //# sourceMappingURL=use-entity-affordances.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/crud/use-entity-affordances.ts"],"sourcesContent":["'use client';\n\nimport type {\n Entity,\n EntityConstructor,\n EntityMetadataDocument,\n EntityMetadataSource,\n} from '@entifix/core';\nimport { useEntityUseCases } from '@entifix/react-integration';\n\n/** What a surface needs to render an entity's served affordances. */\nexport interface EntityAffordances {\n metadata?: EntityMetadataDocument;\n isMetadataLoading: boolean;\n}\n\n/**\n * Reads what this caller may do with an entity, in the shape a surface spreads.\n *\n * A thin rename over `useEntityUseCases` — `isLoading` becomes\n * `isMetadataLoading` — so a page can spread the result straight into\n * `EntityForm` or `EntityTable` beside its other props, rather than restating\n * two lines at every call site. An absent source is the hook's own business.\n *\n * Absent metadata is **not** a security posture: it is the shape both surfaces\n * read as \"behave exactly as before ADR 0026\". The route guard is the\n * authorization boundary.\n */\nexport function useEntityAffordances<TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n source: EntityMetadataSource | undefined,\n): EntityAffordances {\n const { metadata, isLoading } = useEntityUseCases(entityConstructor, source);\n\n return { metadata, isMetadataLoading: isLoading };\n}\n"],"names":["useEntityUseCases","useEntityAffordances","entityConstructor","source","metadata","isLoading","isMetadataLoading"],"mappings":"AAAA;AAQA,SAASA,iBAAiB,QAAQ,6BAA6B;AAQ/D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,qBACdC,iBAA6C,EAC7CC,MAAwC;IAExC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGL,kBAAkBE,mBAAmBC;IAErE,OAAO;QAAEC;QAAUE,mBAAmBD;IAAU;AAClD"}
@@ -0,0 +1,43 @@
1
+ import { type BulkOutcome, type Entity, type EntityId, type EntitySelection } from '@entifix/core';
2
+ export interface UseEntityBulkOptions<TEntity extends Entity> {
3
+ /**
4
+ * Runs one `collection`-bound verb. Absent means this listing has no bulk
5
+ * actions, and no selection column is rendered at all.
6
+ */
7
+ readonly run?: (key: string, selection: EntitySelection<TEntity>) => Promise<readonly BulkOutcome[]>;
8
+ /** Called after a run, so the listing can re-read the rows it just changed. */
9
+ readonly onCompleted?: () => void;
10
+ /** The whole request failed — a transport error, not a per-row outcome. */
11
+ readonly onError?: (error: unknown) => void;
12
+ }
13
+ /** The props {@link useEntityBulk} contributes to `EntityTable`. */
14
+ export interface EntityBulkTableProps<TEntity extends Entity> {
15
+ selection?: EntitySelection<TEntity>;
16
+ onSelectionChange?: (selection: EntitySelection<TEntity>) => void;
17
+ onBulkUseCase?: (key: string, selection: EntitySelection<TEntity>) => void;
18
+ bulkOutcomes?: readonly BulkOutcome[];
19
+ onBulkDismiss?: () => void;
20
+ onBulkRetry?: (ids: EntityId[]) => void;
21
+ isBulkRunning?: boolean;
22
+ }
23
+ /**
24
+ * Owns a listing's selection and the result of the last bulk run.
25
+ *
26
+ * The selection lives here rather than inside `EntityTable` because it has to
27
+ * survive pagination, and the page owns the pager — a selection reset by the
28
+ * very navigation used to add to it would make "select rows across pages"
29
+ * impossible.
30
+ *
31
+ * Two behaviours worth not re-deriving. **The selection survives the action**
32
+ * (#121): after a run the rows stay ticked, because the operator's next act is
33
+ * usually to retry the failures or to run a second verb on the same rows, and
34
+ * re-selecting forty rows to do it is the whole cost the bulk bar exists to
35
+ * remove. And **a retry re-runs only the failures**, as an `ids` selection
36
+ * built from the outcomes — never the original selection, which would redo the
37
+ * successful rows and, for a `matching` selection, re-resolve a filter whose
38
+ * answer has just changed underneath it.
39
+ */
40
+ export declare function useEntityBulk<TEntity extends Entity>({ run, onCompleted, onError, }: UseEntityBulkOptions<TEntity>): {
41
+ tableProps: EntityBulkTableProps<TEntity>;
42
+ };
43
+ //# sourceMappingURL=use-entity-bulk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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