@entifix/next-shell 0.19.0 → 0.20.1

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 (86) hide show
  1. package/README.md +7 -5
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +2 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/back-office/account-menu.d.ts +10 -1
  7. package/dist/lib/back-office/account-menu.d.ts.map +1 -1
  8. package/dist/lib/back-office/account-menu.js +27 -3
  9. package/dist/lib/back-office/account-menu.js.map +1 -1
  10. package/dist/lib/back-office/back-office-shell.d.ts +0 -19
  11. package/dist/lib/back-office/back-office-shell.d.ts.map +1 -1
  12. package/dist/lib/back-office/back-office-shell.js +75 -59
  13. package/dist/lib/back-office/back-office-shell.js.map +1 -1
  14. package/dist/lib/back-office/breadcrumb-labels.d.ts +20 -0
  15. package/dist/lib/back-office/breadcrumb-labels.d.ts.map +1 -0
  16. package/dist/lib/back-office/breadcrumb-labels.js +52 -0
  17. package/dist/lib/back-office/breadcrumb-labels.js.map +1 -0
  18. package/dist/lib/back-office/breadcrumbs.d.ts.map +1 -1
  19. package/dist/lib/back-office/breadcrumbs.js +6 -1
  20. package/dist/lib/back-office/breadcrumbs.js.map +1 -1
  21. package/dist/lib/back-office/index.d.ts +1 -0
  22. package/dist/lib/back-office/index.d.ts.map +1 -1
  23. package/dist/lib/back-office/index.js +1 -0
  24. package/dist/lib/back-office/index.js.map +1 -1
  25. package/dist/lib/back-office/sidebar-nav.d.ts.map +1 -1
  26. package/dist/lib/back-office/sidebar-nav.js +31 -36
  27. package/dist/lib/back-office/sidebar-nav.js.map +1 -1
  28. package/dist/lib/command-palette/command-palette-host.d.ts.map +1 -1
  29. package/dist/lib/command-palette/command-palette-host.js +2 -9
  30. package/dist/lib/command-palette/command-palette-host.js.map +1 -1
  31. package/dist/lib/command-palette/use-use-cases-source.d.ts.map +1 -1
  32. package/dist/lib/command-palette/use-use-cases-source.js +3 -1
  33. package/dist/lib/command-palette/use-use-cases-source.js.map +1 -1
  34. package/dist/lib/confirm-action/confirm-action-state.d.ts +33 -0
  35. package/dist/lib/confirm-action/confirm-action-state.d.ts.map +1 -0
  36. package/dist/lib/confirm-action/confirm-action-state.js +33 -0
  37. package/dist/lib/confirm-action/confirm-action-state.js.map +1 -0
  38. package/dist/lib/confirm-action/confirm-action.d.ts +28 -0
  39. package/dist/lib/confirm-action/confirm-action.d.ts.map +1 -0
  40. package/dist/lib/confirm-action/confirm-action.js +129 -0
  41. package/dist/lib/confirm-action/confirm-action.js.map +1 -0
  42. package/dist/lib/confirm-action/index.d.ts +3 -0
  43. package/dist/lib/confirm-action/index.d.ts.map +1 -0
  44. package/dist/lib/confirm-action/index.js +3 -0
  45. package/dist/lib/confirm-action/index.js.map +1 -0
  46. package/dist/lib/crud/entity-crud-form.d.ts +5 -1
  47. package/dist/lib/crud/entity-crud-form.d.ts.map +1 -1
  48. package/dist/lib/crud/entity-crud-form.js +5 -10
  49. package/dist/lib/crud/entity-crud-form.js.map +1 -1
  50. package/dist/lib/crud/make-entity-crud.d.ts.map +1 -1
  51. package/dist/lib/crud/make-entity-crud.js +120 -20
  52. package/dist/lib/crud/make-entity-crud.js.map +1 -1
  53. package/dist/lib/crud/make-entity-crud.types.d.ts +18 -1
  54. package/dist/lib/crud/make-entity-crud.types.d.ts.map +1 -1
  55. package/dist/lib/crud/make-entity-crud.types.js.map +1 -1
  56. package/dist/lib/crud/use-link-labels.d.ts +32 -0
  57. package/dist/lib/crud/use-link-labels.d.ts.map +1 -0
  58. package/dist/lib/crud/use-link-labels.js +76 -0
  59. package/dist/lib/crud/use-link-labels.js.map +1 -0
  60. package/dist/lib/i18n/catalog/en.d.ts.map +1 -1
  61. package/dist/lib/i18n/catalog/en.js +4 -4
  62. package/dist/lib/i18n/catalog/en.js.map +1 -1
  63. package/dist/lib/i18n/catalog/es.d.ts +4 -2
  64. package/dist/lib/i18n/catalog/es.d.ts.map +1 -1
  65. package/dist/lib/i18n/catalog/es.js +4 -4
  66. package/dist/lib/i18n/catalog/es.js.map +1 -1
  67. package/dist/lib/i18n/catalog/index.d.ts +4 -4
  68. package/dist/lib/theme/theme-cookies.d.ts +27 -0
  69. package/dist/lib/theme/theme-cookies.d.ts.map +1 -0
  70. package/dist/lib/theme/theme-cookies.js +18 -0
  71. package/dist/lib/theme/theme-cookies.js.map +1 -0
  72. package/dist/lib/workspace/pending-flows.d.ts.map +1 -1
  73. package/dist/lib/workspace/pending-flows.js +15 -6
  74. package/dist/lib/workspace/pending-flows.js.map +1 -1
  75. package/dist/lib/workspace/workspace-shell.d.ts.map +1 -1
  76. package/dist/lib/workspace/workspace-shell.js +11 -2
  77. package/dist/lib/workspace/workspace-shell.js.map +1 -1
  78. package/dist/server.d.ts +2 -0
  79. package/dist/server.d.ts.map +1 -1
  80. package/dist/server.js +5 -0
  81. package/dist/server.js.map +1 -1
  82. package/package.json +9 -9
  83. package/dist/lib/crud/validation-messages.d.ts +0 -13
  84. package/dist/lib/crud/validation-messages.d.ts.map +0 -1
  85. package/dist/lib/crud/validation-messages.js +0 -36
  86. package/dist/lib/crud/validation-messages.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/crud/make-entity-crud.tsx"],"sourcesContent":["'use client';\n\nimport {\n deleteUCFactory,\n EntityIdTag,\n type EntityRepositoryTag,\n EntityTag,\n getUCFactory,\n loadUCFactory,\n saveUCFactory,\n} from '@entifix/business';\nimport {\n coerceFiltering,\n describeEntityColumns,\n type EntifixFailure,\n type Entity,\n type EntityConstructor,\n type EntityId,\n type EntityMetadataSource,\n type EntitySelection,\n type EntityUseCaseRunner,\n type EntityWriter,\n envelopeEntityName,\n extractMetaEntity,\n type FilterGroup,\n Internal,\n isFailure,\n parseRsql,\n serializeRsql,\n settled,\n type UseCaseDescriptor,\n} from '@entifix/core';\nimport { EntityTable, useCasesForSurface } from '@entifix/react-controls';\nimport {\n entityQueryScope,\n type OptimisticMutation,\n useDataLoading,\n useEntityRecord,\n useOptimisticMutation,\n} from '@entifix/react-integration';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { Cause, Context, Effect, Exit } from 'effect';\nimport { useParams, useRouter } from 'next/navigation';\nimport { useEffect, useRef } from 'react';\n\nimport { useLocaleHref } from '../i18n/index.js';\nimport { useEntityNavHost } from '../workspace/entity-nav.js';\nimport { EntityCrudForm } from './entity-crud-form.js';\nimport type {\n AnyFilterGroup,\n EntityCrud,\n EntityCrudLinkSource,\n EntityCrudOptions,\n EntityCrudSingleViewProps,\n} from './make-entity-crud.types.js';\nimport { CATALOG_NEW_SLUG, slugToEntityId } from './slug.js';\nimport { useCrudRenderLink } from './use-crud-render-link.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: one repository adapter.\n * Exported because a hand-built screen — a wizard reading records and\n * resolving pickers — runs against exactly the same.\n */\nexport type CrudContext = EntityRepositoryTag;\n\n/**\n * One repository adapter, by its key, as the context the use-cases run\n * against.\n *\n * The cast is 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.\n */\nexport function crudContextOf<TAdapters>(\n adapters: TAdapters,\n repository: keyof TAdapters,\n): Context.Context<CrudContext> {\n return adapters[repository] as Context.Context<EntityRepositoryTag>;\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 */\n/**\n * A rejected write, as something the form's error slot can render.\n *\n * A typed failure is kept as it is: `useErrorMessage` translates its own code,\n * a business refusal and an outage alike. Anything else is a bug that reached\n * the screen, and is shown as `Internal` — never with its own text, which\n * nobody wrote for a user.\n */\nfunction asFailure(failure: unknown): EntifixFailure {\n return isFailure(failure) ? failure : new Internal();\n}\n\n/**\n * What a write failed with *synchronously* — before any flow took it — or\n * `undefined`. A flow's own failure is toasted by the `PendingFlowsProvider`\n * that settles it, so showing it in the error slot too would tell the operator\n * twice.\n */\nfunction syncFailure(\n mutation: OptimisticMutation<never, unknown>,\n): EntifixFailure | undefined {\n return mutation.status === 'failed' && mutation.flowId === undefined\n ? asFailure(mutation.failure)\n : undefined;\n}\n\n/**\n * A runner's verbs, looked up by the key the served `$metadata` named. A\n * single verb answers either settle mode, so it is run through the optimistic\n * API; a bulk run reports per row and is awaited as a promise whose rejection\n * carries the failure itself.\n */\nfunction verbsOf(\n runner: EntityUseCaseRunner | undefined,\n served: readonly UseCaseDescriptor[] | undefined,\n) {\n if (runner === undefined) return undefined;\n // The key always comes from the served document, so it names a verb in it.\n const descriptor = (key: string) =>\n served?.find(candidate => candidate.key === key) as UseCaseDescriptor;\n return {\n run: (key: string, id: EntityId) => runner.run(descriptor(key), id),\n bulk: (key: string, selection: EntitySelection<Entity>) =>\n Effect.runPromiseExit(runner.bulk(descriptor(key), selection)).then(\n exit =>\n Exit.isSuccess(exit)\n ? exit.value\n : Promise.reject(Cause.squash(exit.cause)),\n ),\n };\n}\n\ntype Verbs = NonNullable<ReturnType<typeof verbsOf>>;\n\n/**\n * One verb on one record, through the optimistic API: `done` runs once the\n * verb took effect — at once when it settled, or when the flow it was handed\n * to completed.\n */\nfunction useVerb(verbs: Verbs | undefined, done: () => void) {\n const verb = useOptimisticMutation<\n { readonly key: string; readonly id: EntityId },\n unknown\n >({\n // Only ever sent from a handler that exists because `verbs` does.\n write: ({ key, id }) => (verbs as Verbs).run(key, id),\n confirm: done,\n });\n const run = (key: string, id: EntityId) => {\n void verb.mutate({ key, id }).then(\n result => {\n if (result._tag === 'settled') done();\n },\n // Shown through `syncFailure`, from the mutation's own state.\n () => undefined,\n );\n };\n return { verb, run };\n}\n\n/** Whether the component is still mounted: a flow can settle after it left. */\nfunction useMounted() {\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n return mounted;\n}\n\n/**\n * Runs each link's `useBaseFiltering` against the record being edited, in link\n * order, with `undefined` for a link that declares none.\n *\n * Legal for the reason `useEntityLinkSources` gives: the links are a\n * factory-time array, and whether a link carries a rule is fixed with it, so\n * the same hooks run in the same order on every render. The lint rule cannot\n * see a hook called through a member, so there is nothing for it to flag.\n */\nfunction useLinkFilters<TEntity extends Entity>(\n links: readonly {\n readonly useBaseFiltering?: (\n record: TEntity | undefined,\n ) => AnyFilterGroup | undefined;\n }[],\n record: TEntity | undefined,\n): (AnyFilterGroup | undefined)[] {\n return links.map(link => link.useBaseFiltering?.(record));\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 hiddenFields = [],\n columns,\n toolbar,\n pageSize,\n initialFiltering,\n links = [],\n metadataSource: givenMetadataSource,\n metadata,\n useCases,\n write,\n } = options;\n\n if (givenMetadataSource !== undefined && metadata !== undefined) {\n throw new Error(\n `${entityConstructor.name} was given both metadataSource and metadata; pass one`,\n );\n }\n // An adapter value, so it is resolved per render from the same `useAdapters()`\n // the records come from — the host's composition, never the caller's module.\n const metadataSourceOf = (adapters: TAdapters) =>\n metadata === undefined\n ? givenMetadataSource\n : (adapters[metadata] as EntityMetadataSource);\n\n // Through the service's own trust boundary rather than a second walk of the\n // tree: serialized the way a load request carries it, then coerced against\n // the entity's `filterable` allowlist exactly as a service coerces a query.\n // Whatever would answer `400` on the wire throws here instead, when the\n // screen is generated, naming the member.\n // An emptied group serializes to nothing and filters nothing, so there is\n // nothing to check.\n const initialRsql =\n initialFiltering === undefined ? '' : serializeRsql([initialFiltering]);\n if (initialRsql !== '') {\n coerceFiltering(entityConstructor, parseRsql(initialRsql));\n }\n\n const meta = extractMetaEntity(entityConstructor);\n if (meta.key !== catalogKey) {\n throw new Error(\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 Error(\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 flow's intent records and what\n // `entityQueryScopeFor` keys on — one derivation, so the two can never\n // 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 Error(\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 // 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 metadataSource = metadataSourceOf(adapters);\n const affordances = useEntityAffordances(entityConstructor, metadataSource);\n const renderLink = useCrudRenderLink(catalogKey);\n\n const pager = useDataLoading<TEntity, CrudContext>({\n uc: loadUCFactory<TEntity>(),\n ctx: crudContextOf(adapters, repository),\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 ...(pageSize === undefined ? {} : { initialPageSize: pageSize }),\n ...(initialFiltering === undefined ? {} : { initialFiltering }),\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 serving affordances accepts\n // for every action surface.\n const canRunBulk =\n useCasesForSurface('bulk-bar', affordances.metadata?.useCases).length > 0;\n\n const verbs = verbsOf(\n useCases === undefined\n ? undefined\n : (adapters[useCases] as EntityUseCaseRunner),\n affordances.metadata?.useCases,\n );\n\n const bulk = useEntityBulk<TEntity>({\n run:\n canRunBulk && verbs !== undefined\n ? (key, selection) =>\n verbs.bulk(key, selection as EntitySelection<Entity>)\n : undefined,\n // A bulk write changed the rows underneath the listing, so the page is\n // re-read; the selection deliberately survives it (\"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; the runner takes an id, because that is what a route needs.\n // 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 rowVerb = useVerb(verbs, () => {\n void queryClient.invalidateQueries({ queryKey: scope });\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 = verbs !== undefined && rowUseCases.length > 0;\n\n const handleRowUseCase = canRunRowUseCase\n ? (key: string, item: TEntity) => {\n if (item.id == null) return;\n rowVerb.run(key, item.id);\n }\n : undefined;\n\n return (\n <div className=\"flex flex-col gap-s\">\n <EntityTable\n entityConstructor={entityConstructor}\n {...pager}\n items={pager.items}\n totalItems={pager.totalItems}\n hrefFor={id => withLocale(`${basePath}/${String(id)}`)}\n newHref={withLocale(`${basePath}/${CATALOG_NEW_SLUG}`)}\n renderLink={renderLink}\n {...affordances}\n {...bulk.tableProps}\n onUseCase={handleRowUseCase}\n error={syncFailure(rowVerb.verb) ?? 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 metadataSource = metadataSourceOf(adapters);\n // The same served document the form reads its buttons from, so a key the\n // form hands back always names a verb in it.\n const affordances = useEntityAffordances(entityConstructor, metadataSource);\n const router = useRouter();\n const withLocale = useLocaleHref();\n const params = useParams<{ slug: string }>();\n const mounted = useMounted();\n const id = slugToEntityId(slug ?? params.slug);\n\n const ctx = crudContextOf(adapters, repository);\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 // Against the record as loaded, not the draft: the rule is about which\n // record this is, not what the operator has typed into it.\n const linkFilters = useLinkFilters(linkPlans, entity);\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(\n (plan, index) => ({\n field: plan.field,\n descriptor: plan.descriptor,\n config: {\n entityConstructor: plan.entityConstructor,\n loadUc: loadUCFactory(),\n getUc: getUCFactory(),\n ctx: crudContextOf(adapters, plan.repository),\n // The config's target is erased to `Entity`, and the host's filter to\n // `any`; the two meet here, where neither type is the real target's.\n baseFiltering: linkFilters[index] as FilterGroup<Entity> | undefined,\n },\n }),\n );\n\n // Inside a workspace tab, \"back to the list\" is the list's tab, not a URL\n // that would leave the workspace. A host's own callbacks still win.\n const host = useEntityNavHost();\n const renderLink = useCrudRenderLink(catalogKey);\n const queryClient = useQueryClient();\n // The list this page returns to has its page cached, and it is no longer\n // true. Invalidated rather than patched: the service is the authority on\n // the row it stored.\n //\n // ⚠️ Invisible while every Open was a document load, which threw the cache\n // away anyway (#20): the first client-side navigation back to the list\n // showed the record as it was before the save.\n const refreshList = () =>\n queryClient.invalidateQueries({\n queryKey: entityQueryScope(entityConstructor),\n });\n const toList = () =>\n host === undefined\n ? router.push(withLocale(basePath))\n : host.toList(catalogKey);\n const afterSave = onSaved ?? toList;\n const afterDelete = onDeleted ?? toList;\n\n // Through the host's writer when it named one, which answers both settle\n // modes; otherwise through the repository, where every write settles.\n const writer =\n write === undefined ? undefined : (adapters[write] as EntityWriter);\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 write — or a failed flow — deliberately keeps the draft and the\n // form: the edit is still the user's only copy of what they typed.\n //\n // ⚠️ A flow can complete after the operator left this page, so leaving it\n // is guarded on still being here: a navigation from a form nobody is\n // looking at would pull them away from wherever they went.\n const saveMutation = useOptimisticMutation<TEntity, TEntity>({\n write: next =>\n writer === undefined\n ? Effect.map(\n Effect.provide(\n saveUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityTag, next)),\n ),\n settled,\n )\n : writer.save(next),\n intent: () => ({ entity: entityName, write: 'save' }),\n confirm: () => {\n draft?.clear();\n void refreshList();\n if (mounted.current) afterSave();\n },\n });\n const deleteMutation = useOptimisticMutation<EntityId, void>({\n write: target =>\n writer === undefined\n ? Effect.as(\n Effect.provide(\n deleteUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityIdTag, target)),\n ),\n settled(undefined),\n )\n : writer.delete(target),\n intent: () => ({ entity: entityName, write: 'delete' }),\n confirm: () => {\n draft?.clear();\n void refreshList();\n if (mounted.current) afterDelete();\n },\n });\n\n const handleSave = async (next: TEntity) => {\n const result = await saveMutation.mutate(next).catch(() => undefined);\n // Failed, or pending: the form stays, and the mutation says which. A\n // pending write leaves through the mutation's `confirm`, once its flow\n // completed.\n if (result?._tag !== 'settled') return;\n draft?.clear();\n void refreshList();\n afterSave();\n };\n\n const handleDelete = async () => {\n const result = await deleteMutation.mutate(id).catch(() => undefined);\n if (result?._tag !== 'settled') return;\n draft?.clear();\n void refreshList();\n afterDelete();\n };\n\n /**\n * An `entity`-bound verb, on the record being shown.\n *\n * It **reloads** — once the verb took effect, which for one the server\n * handed to a flow is when the flow completed — 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 verbs = verbsOf(\n useCases === undefined\n ? undefined\n : (adapters[useCases] as EntityUseCaseRunner),\n affordances.metadata?.useCases,\n );\n const recordVerb = useVerb(verbs, () => void reload());\n const handleUseCase =\n verbs === undefined || id == null\n ? undefined\n : (key: string) => recordVerb.run(key, id);\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={saveMutation.status === 'running'}\n isPending={[saveMutation, deleteMutation, recordVerb.verb].some(\n mutation => mutation.status === 'pending',\n )}\n isDeleting={deleteMutation.status === 'running'}\n error={\n loadError ??\n syncFailure(saveMutation) ??\n syncFailure(deleteMutation) ??\n syncFailure(recordVerb.verb)\n }\n onSave={handleSave}\n onDelete={id == null ? undefined : handleDelete}\n onUseCase={handleUseCase}\n backHref={withLocale(basePath)}\n renderLink={renderLink}\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","EntityIdTag","EntityTag","getUCFactory","loadUCFactory","saveUCFactory","coerceFiltering","describeEntityColumns","envelopeEntityName","extractMetaEntity","Internal","isFailure","parseRsql","serializeRsql","settled","EntityTable","useCasesForSurface","entityQueryScope","useDataLoading","useEntityRecord","useOptimisticMutation","useQueryClient","Cause","Context","Effect","Exit","useParams","useRouter","useEffect","useRef","useLocaleHref","useEntityNavHost","EntityCrudForm","CATALOG_NEW_SLUG","slugToEntityId","useCrudRenderLink","useEntityAffordances","useEntityBulk","TARGET_NAME_PROPERTY","crudContextOf","adapters","repository","asFailure","failure","syncFailure","mutation","status","flowId","undefined","verbsOf","runner","served","descriptor","key","find","candidate","run","id","bulk","selection","runPromiseExit","then","exit","isSuccess","value","Promise","reject","squash","cause","useVerb","verbs","done","verb","write","confirm","mutate","result","_tag","useMounted","mounted","current","useLinkFilters","links","record","map","link","useBaseFiltering","makeEntityCrud","entityConstructor","options","useAdapters","basePath","catalogKey","hiddenFields","columns","toolbar","pageSize","initialFiltering","metadataSource","givenMetadataSource","metadata","useCases","Error","name","metadataSourceOf","initialRsql","meta","String","labelKey","entityLabelKey","pluralKey","entityPluralKey","entityName","descriptors","linkPlans","entry","field","linkLabelProperty","labelProperty","linkSearchProperty","searchProperty","ListPage","affordances","withLocale","queryClient","scope","renderLink","pager","uc","ctx","queryKey","initialPageSize","canRunBulk","length","onCompleted","invalidateQueries","rowVerb","rowUseCases","canRunRowUseCase","handleRowUseCase","item","div","className","items","totalItems","hrefFor","newHref","tableProps","onUseCase","error","SingleViewPage","slug","onSaved","onDeleted","draft","loadError","router","params","entity","isLoading","reload","linkFilters","linkSources","plan","index","config","loadUc","getUc","baseFiltering","host","refreshList","toList","push","afterSave","afterDelete","writer","saveMutation","next","provide","pipe","add","save","intent","clear","deleteMutation","target","as","delete","handleSave","catch","handleDelete","recordVerb","handleUseCase","isSaving","isPending","some","isDeleting","onSave","onDelete","backHref","entityKey"],"mappings":"AAAA;;;AAEA,SACEA,eAAe,EACfC,WAAW,EAEXC,SAAS,EACTC,YAAY,EACZC,aAAa,EACbC,aAAa,QACR,oBAAoB;AAC3B,SACEC,eAAe,EACfC,qBAAqB,EASrBC,kBAAkB,EAClBC,iBAAiB,EAEjBC,QAAQ,EACRC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,OAAO,QAEF,gBAAgB;AACvB,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,0BAA0B;AAC1E,SACEC,gBAAgB,EAEhBC,cAAc,EACdC,e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QA;YACRC,WAAWA;YACXkC,UAAUjB,aAAalI,MAAM,KAAK;YAClCoJ,WAAW;gBAAClB;gBAAcQ;gBAAgBO,WAAWvH,IAAI;aAAC,CAAC2H,IAAI,CAC7DtJ,CAAAA,WAAYA,SAASC,MAAM,KAAK;YAElCsJ,YAAYZ,eAAe1I,MAAM,KAAK;YACtCuG,KAAK,GACHM,QAAAA,QAAAA,oBAAAA,YACA/G,YAAYoI,yBADZrB,QAEA/G,YAAY4I,2BAFZ7B,OAGA/G,YAAYmJ,WAAWvH,IAAI;YAE7B6H,QAAQT;YACRU,UAAU7I,MAAM,OAAOT,YAAY8I;YACnC1C,WAAW4C;YACXO,UAAU5E,WAAWhC;YACrBmC,YAAYA;YACZ4B,OAAOA;WAxBF/C,gBAAOmD,0BAAAA,OAAQrG,EAAE,oBAAIxB;IA2BhC;IAEA,OAAO;QACLuD;QACAgH,WAAW5G;QACXiB;QACAE;QACApB;QACA8B;QACA6B;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/lib/crud/make-entity-crud.tsx"],"sourcesContent":["'use client';\n\nimport {\n deleteUCFactory,\n type EntityFacetCounterTag,\n EntityIdTag,\n type EntityRepositoryTag,\n EntityTag,\n getUCFactory,\n loadUCFactory,\n saveUCFactory,\n} from '@entifix/business';\nimport {\n coerceFiltering,\n describeEntityColumns,\n type EntifixFailure,\n type Entity,\n type EntityConstructor,\n type EntityId,\n type EntityMetadataSource,\n type EntitySelection,\n type EntityUseCaseRunner,\n type EntityWriter,\n envelopeEntityName,\n extractMetaEntity,\n type FilterGroup,\n Internal,\n isFailure,\n parseRsql,\n serializeRsql,\n settled,\n type UseCaseDescriptor,\n} from '@entifix/core';\nimport {\n EntityColumn,\n EntityTable,\n useCasesForSurface,\n useFocusOnArrival,\n useT,\n useToasts,\n} from '@entifix/react-controls';\nimport {\n entityQueryScope,\n type OptimisticMutation,\n useDataLoading,\n useEntityRecord,\n useFacetCounts,\n useOptimisticMutation,\n} from '@entifix/react-integration';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { Cause, Context, Effect, Exit } from 'effect';\nimport { useParams, useRouter } from 'next/navigation';\nimport { useEffect, useRef } from 'react';\n\nimport { useBreadcrumbLabel } from '../back-office/breadcrumb-labels.js';\nimport { useLocaleHref } from '../i18n/index.js';\nimport { useEntityNavHost } from '../workspace/entity-nav.js';\nimport { EntityCrudForm } from './entity-crud-form.js';\nimport type {\n AnyFilterGroup,\n EntityCrud,\n EntityCrudLinkSource,\n EntityCrudOptions,\n EntityCrudSingleViewProps,\n} from './make-entity-crud.types.js';\nimport { CATALOG_NEW_SLUG, slugToEntityId } from './slug.js';\nimport { useCrudRenderLink } from './use-crud-render-link.js';\nimport { useEntityAffordances } from './use-entity-affordances.js';\nimport { useEntityBulk } from './use-entity-bulk.js';\nimport { LinkLabelCell, useLinkLabels } from './use-link-labels.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: one repository adapter.\n * Exported because a hand-built screen — a wizard reading records and\n * resolving pickers — runs against exactly the same.\n */\nexport type CrudContext = EntityRepositoryTag;\n\n/**\n * One repository adapter, by its key, as the context the use-cases run\n * against.\n *\n * The cast is 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.\n */\nexport function crudContextOf<TAdapters>(\n adapters: TAdapters,\n repository: keyof TAdapters,\n): Context.Context<CrudContext> {\n return adapters[repository] as Context.Context<EntityRepositoryTag>;\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 */\n/**\n * A rejected write, as something the form's error slot can render.\n *\n * A typed failure is kept as it is: `useErrorMessage` translates its own code,\n * a business refusal and an outage alike. Anything else is a bug that reached\n * the screen, and is shown as `Internal` — never with its own text, which\n * nobody wrote for a user.\n */\nfunction asFailure(failure: unknown): EntifixFailure {\n return isFailure(failure) ? failure : new Internal();\n}\n\n/**\n * What a write failed with *synchronously* — before any flow took it — or\n * `undefined`. A flow's own failure is toasted by the `PendingFlowsProvider`\n * that settles it, so showing it in the error slot too would tell the operator\n * twice.\n */\nfunction syncFailure(\n mutation: OptimisticMutation<never, unknown>,\n): EntifixFailure | undefined {\n return mutation.status === 'failed' && mutation.flowId === undefined\n ? asFailure(mutation.failure)\n : undefined;\n}\n\n/**\n * A runner's verbs, looked up by the key the served `$metadata` named. A\n * single verb answers either settle mode, so it is run through the optimistic\n * API; a bulk run reports per row and is awaited as a promise whose rejection\n * carries the failure itself.\n */\nfunction verbsOf(\n runner: EntityUseCaseRunner | undefined,\n served: readonly UseCaseDescriptor[] | undefined,\n) {\n if (runner === undefined) return undefined;\n // The key always comes from the served document, so it names a verb in it.\n const descriptor = (key: string) =>\n served?.find(candidate => candidate.key === key) as UseCaseDescriptor;\n return {\n run: (key: string, id: EntityId) => runner.run(descriptor(key), id),\n bulk: (key: string, selection: EntitySelection<Entity>) =>\n Effect.runPromiseExit(runner.bulk(descriptor(key), selection)).then(\n exit =>\n Exit.isSuccess(exit)\n ? exit.value\n : Promise.reject(Cause.squash(exit.cause)),\n ),\n };\n}\n\ntype Verbs = NonNullable<ReturnType<typeof verbsOf>>;\n\n/**\n * One verb on one record, through the optimistic API: `done` runs once the\n * verb took effect — at once when it settled, or when the flow it was handed\n * to completed.\n */\nfunction useVerb(verbs: Verbs | undefined, done: () => void) {\n const verb = useOptimisticMutation<\n { readonly key: string; readonly id: EntityId },\n unknown\n >({\n // Only ever sent from a handler that exists because `verbs` does.\n write: ({ key, id }) => (verbs as Verbs).run(key, id),\n confirm: done,\n });\n const run = (key: string, id: EntityId) => {\n void verb.mutate({ key, id }).then(\n result => {\n if (result._tag === 'settled') done();\n },\n // Shown through `syncFailure`, from the mutation's own state.\n () => undefined,\n );\n };\n return { verb, run };\n}\n\n/** Whether the component is still mounted: a flow can settle after it left. */\nfunction useMounted() {\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n return mounted;\n}\n\n/**\n * Runs each link's `useBaseFiltering` against the record being edited, in link\n * order, with `undefined` for a link that declares none.\n *\n * Legal for the reason `useEntityLinkSources` gives: the links are a\n * factory-time array, and whether a link carries a rule is fixed with it, so\n * the same hooks run in the same order on every render. The lint rule cannot\n * see a hook called through a member, so there is nothing for it to flag.\n */\nfunction useLinkFilters<TEntity extends Entity>(\n links: readonly {\n readonly useBaseFiltering?: (\n record: TEntity | undefined,\n ) => AnyFilterGroup | undefined;\n }[],\n record: TEntity | undefined,\n): (AnyFilterGroup | undefined)[] {\n return links.map(link => link.useBaseFiltering?.(record));\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 hiddenFields = [],\n columns,\n toolbar,\n pageSize,\n initialFiltering,\n links = [],\n metadataSource: givenMetadataSource,\n metadata,\n useCases,\n write,\n delete: deletePolicy = 'confirm',\n facets,\n } = options;\n\n if (givenMetadataSource !== undefined && metadata !== undefined) {\n throw new Error(\n `${entityConstructor.name} was given both metadataSource and metadata; pass one`,\n );\n }\n // An adapter value, so it is resolved per render from the same `useAdapters()`\n // the records come from — the host's composition, never the caller's module.\n const metadataSourceOf = (adapters: TAdapters) =>\n metadata === undefined\n ? givenMetadataSource\n : (adapters[metadata] as EntityMetadataSource);\n\n // Through the service's own trust boundary rather than a second walk of the\n // tree: serialized the way a load request carries it, then coerced against\n // the entity's `filterable` allowlist exactly as a service coerces a query.\n // Whatever would answer `400` on the wire throws here instead, when the\n // screen is generated, naming the member.\n // An emptied group serializes to nothing and filters nothing, so there is\n // nothing to check.\n const initialRsql =\n initialFiltering === undefined ? '' : serializeRsql([initialFiltering]);\n if (initialRsql !== '') {\n coerceFiltering(entityConstructor, parseRsql(initialRsql));\n }\n\n const meta = extractMetaEntity(entityConstructor);\n if (meta.key !== catalogKey) {\n throw new Error(\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 Error(\n `${entityConstructor.name} must declare labelKey and pluralKey on @entity() to be generated`,\n );\n }\n // Narrowed once, for the closures below that TypeScript cannot follow.\n const labelKey: string = entityLabelKey;\n const pluralKey: string = entityPluralKey;\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 flow's intent records and what\n // `entityQueryScopeFor` keys on — one derivation, so the two can never\n // disagree about which entity they mean.\n const entityName = envelopeEntityName(entityConstructor);\n const descriptors = describeEntityColumns(entityConstructor);\n /** The members a filter panel offers choices for, and so counts. */\n const facetMembers = descriptors\n .filter(\n descriptor =>\n descriptor.filterable &&\n (descriptor.type === 'enum' || descriptor.type === 'boolean'),\n )\n .map(({ name, key }) => ({ name, key }));\n /** A record as the reader knows it: its first shown member that is filled in. */\n const recordLabelOf = (record: TEntity | undefined): string | undefined => {\n const named = descriptors.find(descriptor => {\n if (descriptor.type === 'id' || hiddenFields.includes(descriptor.name))\n return false;\n const value = (record as Record<string, unknown> | undefined)?.[\n descriptor.name\n ];\n return value != null && String(value) !== '';\n });\n return named === undefined\n ? undefined\n : String((record as Record<string, unknown>)[named.name]);\n };\n const linkPlans = links.map(link => {\n const descriptor = descriptors.find(entry => entry.name === link.field);\n if (descriptor === undefined) {\n throw new Error(\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 // 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 metadataSource = metadataSourceOf(adapters);\n const affordances = useEntityAffordances(entityConstructor, metadataSource);\n const renderLink = useCrudRenderLink(catalogKey);\n\n const pager = useDataLoading<TEntity, CrudContext>({\n uc: loadUCFactory<TEntity>(),\n ctx: crudContextOf(adapters, repository),\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 ...(pageSize === undefined ? {} : { initialPageSize: pageSize }),\n ...(initialFiltering === undefined ? {} : { initialFiltering }),\n });\n\n // A member that holds another record's id reads as that record's name.\n const linkLabel = useLinkLabels(\n linkPlans.map(plan => ({\n field: plan.field,\n entityConstructor: plan.entityConstructor,\n labelProperty: plan.descriptor.linkLabelProperty,\n ctx: crudContextOf(adapters, plan.repository),\n })),\n pager.items,\n );\n const linkColumns = linkPlans.map(plan => (\n <EntityColumn<TEntity>\n key={plan.field}\n field={plan.field}\n render={item => <LinkLabelCell label={linkLabel(plan.field, item)} />}\n />\n ));\n\n const facetCounts = useFacetCounts<TEntity>({\n ctx:\n facets === undefined\n ? undefined\n : (adapters[facets] as Context.Context<EntityFacetCounterTag>),\n members: facetMembers,\n filtering: pager.filtering,\n 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 serving affordances accepts\n // for every action surface.\n const canRunBulk =\n useCasesForSurface('bulk-bar', affordances.metadata?.useCases).length > 0;\n\n const verbs = verbsOf(\n useCases === undefined\n ? undefined\n : (adapters[useCases] as EntityUseCaseRunner),\n affordances.metadata?.useCases,\n );\n\n const bulk = useEntityBulk<TEntity>({\n run:\n canRunBulk && verbs !== undefined\n ? (key, selection) =>\n verbs.bulk(key, selection as EntitySelection<Entity>)\n : undefined,\n // A bulk write changed the rows underneath the listing, so the page is\n // re-read; the selection deliberately survives it (\"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; the runner takes an id, because that is what a route needs.\n // 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 rowVerb = useVerb(verbs, () => {\n void queryClient.invalidateQueries({ queryKey: scope });\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 = verbs !== undefined && rowUseCases.length > 0;\n\n const handleRowUseCase = canRunRowUseCase\n ? (key: string, item: TEntity) => {\n if (item.id == null) return;\n rowVerb.run(key, item.id);\n }\n : undefined;\n\n // The list's heading, and where focus lands when a save or a delete\n // brings the reader back here rather than falling to `<body>`.\n const heading = useRef<HTMLHeadingElement>(null);\n useFocusOnArrival(heading);\n const et = useT('entity');\n\n return (\n <div className=\"flex flex-col gap-s\">\n <h1\n ref={heading}\n tabIndex={-1}\n className=\"m-0 text-step-2 font-semibold text-content focus-ring\"\n >\n {et(pluralKey.replace(/^entity:/, ''))}\n </h1>\n <EntityTable\n entityConstructor={entityConstructor}\n {...pager}\n items={pager.items}\n totalItems={pager.totalItems}\n hrefFor={id => withLocale(`${basePath}/${String(id)}`)}\n newHref={withLocale(`${basePath}/${CATALOG_NEW_SLUG}`)}\n renderLink={renderLink}\n {...affordances}\n {...bulk.tableProps}\n onUseCase={handleRowUseCase}\n onRetry={pager.refetch}\n facets={facetCounts}\n error={syncFailure(rowVerb.verb) ?? pager.error}\n >\n {columns}\n {/* After the host's own: a host column for the same member wins. */}\n {linkColumns}\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 metadataSource = metadataSourceOf(adapters);\n // The same served document the form reads its buttons from, so a key the\n // form hands back always names a verb in it.\n const affordances = useEntityAffordances(entityConstructor, metadataSource);\n const router = useRouter();\n const withLocale = useLocaleHref();\n const params = useParams<{ slug: string }>();\n const mounted = useMounted();\n const id = slugToEntityId(slug ?? params.slug);\n\n const ctx = crudContextOf(adapters, repository);\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 // Against the record as loaded, not the draft: the rule is about which\n // record this is, not what the operator has typed into it.\n const linkFilters = useLinkFilters(linkPlans, entity);\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(\n (plan, index) => ({\n field: plan.field,\n descriptor: plan.descriptor,\n config: {\n entityConstructor: plan.entityConstructor,\n loadUc: loadUCFactory(),\n getUc: getUCFactory(),\n ctx: crudContextOf(adapters, plan.repository),\n // The config's target is erased to `Entity`, and the host's filter to\n // `any`; the two meet here, where neither type is the real target's.\n baseFiltering: linkFilters[index] as FilterGroup<Entity> | undefined,\n },\n }),\n );\n\n // Inside a workspace tab, \"back to the list\" is the list's tab, not a URL\n // that would leave the workspace. A host's own callbacks still win.\n const host = useEntityNavHost();\n const renderLink = useCrudRenderLink(catalogKey);\n const queryClient = useQueryClient();\n // The list this page returns to has its page cached, and it is no longer\n // true. Invalidated rather than patched: the service is the authority on\n // the row it stored.\n //\n // ⚠️ Invisible while every Open was a document load, which threw the cache\n // away anyway (#20): the first client-side navigation back to the list\n // showed the record as it was before the save.\n const refreshList = () =>\n queryClient.invalidateQueries({\n queryKey: entityQueryScope(entityConstructor),\n });\n const toList = () =>\n host === undefined\n ? router.push(withLocale(basePath))\n : host.toList(catalogKey);\n const afterSave = onSaved ?? toList;\n const afterDelete = onDeleted ?? toList;\n\n // Through the host's writer when it named one, which answers both settle\n // modes; otherwise through the repository, where every write settles.\n const writer =\n write === undefined ? undefined : (adapters[write] as EntityWriter);\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 write — or a failed flow — deliberately keeps the draft and the\n // form: the edit is still the user's only copy of what they typed.\n //\n // ⚠️ A flow can complete after the operator left this page, so leaving it\n // is guarded on still being here: a navigation from a form nobody is\n // looking at would pull them away from wherever they went.\n const saveMutation = useOptimisticMutation<TEntity, TEntity>({\n write: next =>\n writer === undefined\n ? Effect.map(\n Effect.provide(\n saveUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityTag, next)),\n ),\n settled,\n )\n : writer.save(next),\n intent: () => ({ entity: entityName, write: 'save' }),\n confirm: () => {\n draft?.clear();\n void refreshList();\n if (mounted.current) afterSave();\n },\n });\n const deleteMutation = useOptimisticMutation<EntityId, void>({\n write: target =>\n writer === undefined\n ? Effect.as(\n Effect.provide(\n deleteUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityIdTag, target)),\n ),\n settled(undefined),\n )\n : writer.delete(target),\n intent: () => ({ entity: entityName, write: 'delete' }),\n confirm: () => {\n draft?.clear();\n void refreshList();\n if (mounted.current) afterDelete();\n },\n });\n\n const handleSave = async (next: TEntity) => {\n const result = await saveMutation.mutate(next).catch(() => undefined);\n // Failed, or pending: the form stays, and the mutation says which. A\n // pending write leaves through the mutation's `confirm`, once its flow\n // completed.\n if (result?._tag !== 'settled') return;\n draft?.clear();\n void refreshList();\n // Said in the toast region every route shares, so it survives the\n // navigation that follows (ADR 0028).\n toasts?.show({\n tone: 'success',\n message: ct('state.saved', {\n object: recordNoun(next),\n }),\n });\n afterSave();\n };\n\n const toasts = useToasts();\n const ct = useT('controls');\n const et = useT('entity');\n /** What an announcement names: the record, or the entity for a blank one. */\n const recordNoun = (record: TEntity | undefined) =>\n recordLabelOf(record) ?? et(labelKey.replace(/^entity:/, ''));\n // The breadcrumb for this page's segment names the record, never its id:\n // \"Nuevo\" for a create, the record once it has loaded.\n useBreadcrumbLabel(\n slug ?? params.slug,\n id == null ? ct('form.new') : entity && recordNoun(entity),\n );\n /**\n * Saves a deleted record back under its id: what Undo runs under the\n * `undo` policy.\n */\n const restore = (record: TEntity) =>\n Effect.runPromise(\n writer === undefined\n ? Effect.asVoid(\n Effect.provide(\n saveUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityTag, record)),\n ),\n )\n : Effect.asVoid(writer.save(record)),\n ).then(\n () => refreshList(),\n (failure: unknown) => {\n toasts?.show({ tone: 'failure', failure: asFailure(failure) });\n },\n );\n\n const handleDelete = async () => {\n const snapshot = entity;\n const result = await deleteMutation.mutate(id).catch(() => undefined);\n if (result?._tag !== 'settled') return;\n draft?.clear();\n void refreshList();\n // Said once, in the toast region every route shares, so it survives the\n // navigation back to the list.\n const object = recordNoun(snapshot);\n const message = ct('confirm.deleted', { object });\n if (deletePolicy === 'undo' && snapshot !== undefined)\n toasts?.show({\n tone: 'undo',\n message,\n action: {\n label: ct('confirm.undo'),\n onAction: () => void restore(snapshot),\n },\n });\n else toasts?.show({ tone: 'success', message });\n afterDelete();\n };\n\n /**\n * An `entity`-bound verb, on the record being shown.\n *\n * It **reloads** — once the verb took effect, which for one the server\n * handed to a flow is when the flow completed — 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 verbs = verbsOf(\n useCases === undefined\n ? undefined\n : (adapters[useCases] as EntityUseCaseRunner),\n affordances.metadata?.useCases,\n );\n const recordVerb = useVerb(verbs, () => void reload());\n const handleUseCase =\n verbs === undefined || id == null\n ? undefined\n : (key: string) => recordVerb.run(key, id);\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={saveMutation.status === 'running'}\n isPending={[saveMutation, deleteMutation, recordVerb.verb].some(\n mutation => mutation.status === 'pending',\n )}\n isDeleting={deleteMutation.status === 'running'}\n error={\n loadError ??\n syncFailure(saveMutation) ??\n syncFailure(deleteMutation) ??\n syncFailure(recordVerb.verb)\n }\n onSave={handleSave}\n onRetry={loadError === undefined ? undefined : reload}\n onDelete={id == null ? undefined : handleDelete}\n deletePolicy={deletePolicy}\n onUseCase={handleUseCase}\n backHref={withLocale(basePath)}\n renderLink={renderLink}\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","EntityIdTag","EntityTag","getUCFactory","loadUCFactory","saveUCFactory","coerceFiltering","describeEntityColumns","envelopeEntityName","extractMetaEntity","Internal","isFailure","parseRsql","serializeRsql","settled","EntityColumn","EntityTable","useCasesForSurface","useFocusOnArrival","useT","useToasts","entityQueryScope","useDataLoading","useEntityRecord","useFacetCounts","useOptimisticMutation","useQueryClient","Cause","Context","Effect","Exit","useParams","useRouter","useEffect","useRef","useBreadcrumbLabel","useLocaleHref","useEntityNavHost","EntityCrudForm","CATALOG_NEW_SLUG","slugToEntityId","useCrudRenderLink","useEntityAffordances","useEntityBulk","LinkLabelCell","useLinkLabels","TARGET_NAME_PROPERTY","crudContextOf","adapters","repository","asFailure","failure","syncFailure","mutation","status","flowId","undefined","verbsOf","runner","served","descriptor","key","find","candidate","run","id","bulk","selection","runPromiseExit","then","exit","isSuccess","value","Promise","reject","squash","cause","useVerb","verbs","done","verb","write","confirm","mutate","result","_tag","useMounted","mounted","current","useLinkFilters","links","record","map","link","useBaseFiltering","makeEntityCrud","entityConstructor","options","useAdapters","basePath","catalogKey","hiddenFields","columns","toolbar","pageSize","initialFiltering","metadataSource","givenMetadataSource","metadata","useCases","delete","deletePolicy","facets","Error","name","metadataSourceOf","initialRsql","meta","String","labelKey","entityLabelKey","pluralKey","entityPluralKey","entityName","descriptors","facetMembers","filter","filterable","type","recordLabelOf","named","includes","linkPlans","entry","field","linkLabelProperty","labelProperty","linkSearchProperty","searchProperty","ListPage","affordances","withLocale","queryClient","scope","renderLink","pager","uc","ctx","queryKey","initialPageSize","linkLabel","plan","items","linkColumns","render","item","label","facetCounts","members","filtering","canRunBulk","length","onCompleted","invalidateQueries","rowVerb","rowUseCases","canRunRowUseCase","handleRowUseCase","heading","et","div","className","h1","ref","tabIndex","replace","totalItems","hrefFor","newHref","tableProps","onUseCase","onRetry","refetch","error","SingleViewPage","slug","onSaved","onDeleted","draft","loadError","router","params","entity","isLoading","reload","linkFilters","linkSources","index","config","loadUc","getUc","baseFiltering","host","refreshList","toList","push","afterSave","afterDelete","writer","saveMutation","next","provide","pipe","add","save","intent","clear","deleteMutation","target","as","handleSave","catch","toasts","show","tone","message","ct","object","recordNoun","restore","runPromise","asVoid","handleDelete","snapshot","action","onAction","recordVerb","handleUseCase","isSaving","isPending","some","isDeleting","onSave","onDelete","backHref","entityKey"],"mappings":"AAAA;;;AAEA,SACEA,eAAe,EAEfC,WAAW,EAEXC,SAAS,EACTC,YAAY,EACZC,aAAa,EACbC,aAAa,QACR,oBAAoB;AAC3B,SACEC,eAAe,EACfC,qBAAqB,EASrBC,kBAAkB,EAClBC,iBAAiB,EAEjBC,QAAQ,EACRC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,OAAO,QAEF,gBAAgB;AACvB,SACEC,YAAY,EACZC,WAAW,EACXC,kBAAkB,EAClBC,iBAAiB,EACjBC,IAAI,EACJC,SAAS,QACJ,0BAA0B;AACjC,SACEC,gBAAgB,EAEhBC,cAAc,EACdC,eAAe,EACfC,cAAc,EACdC,qBAAq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type { EntityRepositoryTag } from '@entifix/business';
1
+ import type { EntityFacetCounterTag, EntityRepositoryTag } from '@entifix/business';
2
2
  import type { Entity, EntityConstructor, EntityFieldDescriptor, EntityMetadataSource, EntityUseCaseRunner, EntityWriter, FilterGroup } from '@entifix/core';
3
3
  import type { EntityDraftStore, EntityLinkSourceConfig } from '@entifix/react-integration';
4
4
  import type { Context } from 'effect/Context';
@@ -170,6 +170,16 @@ export interface EntityCrudOptions<TAdapters, TEntity extends Entity> {
170
170
  * wrong type, throws here rather than answering `400` on every first load.
171
171
  */
172
172
  readonly initialFiltering?: FilterGroup<TEntity>;
173
+ /**
174
+ * How the record page's Delete is made safe
175
+ * ([ADR 0026](../../../../../../docs/adr/0026-actions-hierarchy-overflow-and-destructive-verbs.md)):
176
+ * `confirm` (the default) asks in an alert dialog naming the record; `typed`
177
+ * asks for its name to be typed first — for the records a fleet boots from;
178
+ * `undo` deletes at once and offers Undo, which saves the record back under
179
+ * its id, so it needs a store whose save puts a record back rather than
180
+ * refusing an id it no longer holds.
181
+ */
182
+ readonly delete?: 'confirm' | 'undo' | 'typed';
173
183
  /** Frozen at factory time — see `use-entity-link-sources.ts`. */
174
184
  readonly links?: readonly EntityCrudLink<TAdapters, TEntity>[];
175
185
  /**
@@ -222,6 +232,13 @@ export interface EntityCrudOptions<TAdapters, TEntity extends Entity> {
222
232
  * `PendingFlowsProvider` above while the form keeps its input.
223
233
  */
224
234
  readonly write?: AdapterKey<TAdapters, EntityWriter>;
235
+ /**
236
+ * An adapter context providing `EntityFacetCounterTag` — the REST client's
237
+ * facets adapter, typically. Supplied, the list's filter panel shows how
238
+ * many records hold each choice of an enum or boolean member, counted under
239
+ * the filters in effect less that member's own.
240
+ */
241
+ readonly facets?: AdapterKey<TAdapters, Context<EntityFacetCounterTag>>;
225
242
  }
226
243
  /**
227
244
  * Props both hosts pass. A route host passes none — the slug comes from the URL
@@ -1 +1 @@
1
- {"version":3,"file":"make-entity-crud.types.d.ts","sourceRoot":"","sources":["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C,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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/crud/make-entity-crud.types.ts"],"sourcesContent":["import type { EntityRepositoryTag } from '@entifix/business';\nimport type {\n Entity,\n EntityConstructor,\n EntityFieldDescriptor,\n EntityMetadataSource,\n EntityUseCaseRunner,\n EntityWriter,\n FilterGroup,\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 — a host's catalog check typically scans its\n * domain packages for `@useCase()` decorators and never `.tsx`, so a runtime\n * 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, TEntity extends Entity = Entity> {\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 * A restriction on what may be picked **for this record**, ANDed into every\n * quick and browse request — `useEntityLinkSource`'s `baseFiltering`, built\n * from the record being edited rather than fixed at factory time.\n *\n * A record-dependent rule is the case it exists for: a parent picker that\n * must not offer the record itself or anything beneath it. That rule needs\n * more than the record — its descendants are other records — which is why\n * this is a **hook** and not a function of the record: it may load what it\n * needs through the host's own adapters, and answer `undefined` until it has.\n *\n * Called on every render of the single view, under the rules of hooks: once\n * per link, unconditionally, with `undefined` while the record loads and\n * throughout a create. `undefined` back means no restriction. Its members\n * must be `filterable` on the target, or the service answers `400`. It\n * narrows the suggestions and nothing else — the service still has to refuse\n * a value the picker would not have offered.\n */\n readonly useBaseFiltering?: (\n record: TEntity | undefined,\n ) => AnyFilterGroup | undefined;\n}\n\n/**\n * A restriction over a picker's target, with the target's type erased — the\n * link names its target only as `EntityConstructor<Entity>`, so a filter typed\n * on the real target would not be assignable. Erased for the reason\n * {@link AnyEntityLinkSourceConfig} is.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyFilterGroup = FilterGroup<any>;\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 /**\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 */\n readonly toolbar?: ReactNode;\n /**\n * How many rows the list asks for on its first load. Defaults to\n * `useDataLoading`'s own default.\n *\n * Raised for a vocabulary that should be seen whole: `EntityTable` nests a\n * hierarchy only within the page it was given, so a tree larger than one page\n * shows the children whose parent fell on another page as roots.\n */\n readonly pageSize?: number;\n /**\n * The filter the list opens with — a worklist, where the default view of a\n * record class is the rows someone has to act on. Shown in the filter panel\n * as the user's own, so it can be changed or cleared; unlike a link's\n * `useBaseFiltering`, it restricts nothing.\n *\n * Checked when the screen is generated against the same allowlist a service\n * applies to a query: a member that is not `filterable`, or a value of the\n * wrong type, throws here rather than answering `400` on every first load.\n */\n readonly initialFiltering?: FilterGroup<TEntity>;\n /** Frozen at factory time — see `use-entity-link-sources.ts`. */\n readonly links?: readonly EntityCrudLink<TAdapters, TEntity>[];\n /**\n * Where the entity's served affordances come from — `GET /api/<entity>/$metadata`.\n *\n * Supplying it is what turns on every served affordance:\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 * Which adapter holds this entity's {@link EntityMetadataSource} — the same\n * source as {@link metadataSource}, resolved from the host's composition\n * instead of built by the caller.\n *\n * Prefer it: a source is a transport, and naming it by key keeps the module\n * that generates the screens free of the adapter that fetches, exactly as\n * {@link repository} already does for records. Supplying both is a build\n * error — two answers to where the document comes from.\n */\n readonly metadata?: AdapterKey<TAdapters, EntityMetadataSource>;\n /**\n * Which adapter runs this entity's `@useCase()` verbs — over REST against\n * the service that serves them, or in-process for records that live in the\n * browser. Resolved from the host's composition, as {@link repository} is.\n *\n * Supplying it lets the generated screens run what the served `$metadata`\n * lists for the caller: a row's menu and a form's buttons run a verb on a\n * record, and the bulk bar runs a `collection` verb over a selection,\n * reporting per row. A verb that resolves reloads what it changed; one that\n * refuses shows its coded message in the screen's error slot rather than as\n * a promise nobody catches.\n */\n readonly useCases?: AdapterKey<TAdapters, EntityUseCaseRunner>;\n /**\n * Which adapter makes this entity's saves and deletes, answering both\n * settle modes — `buildEntityRestAdapterWrite` over REST. Resolved from the\n * host's composition, as {@link repository} is.\n *\n * Omitted, the form writes through {@link repository}, and every write\n * settles. Supplied, a write the server hands to a flow keeps the form open\n * and waiting, with what was typed, until the flow settles: a completed one\n * returns to the list, and a failed one is toasted once by the\n * `PendingFlowsProvider` above while the form keeps its input.\n */\n readonly write?: AdapterKey<TAdapters, EntityWriter>;\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 */\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":"AAuTA;;;CAGC,GACD,WAIC"}
1
+ {"version":3,"sources":["../../../src/lib/crud/make-entity-crud.types.ts"],"sourcesContent":["import type {\n EntityFacetCounterTag,\n EntityRepositoryTag,\n} from '@entifix/business';\nimport type {\n Entity,\n EntityConstructor,\n EntityFieldDescriptor,\n EntityMetadataSource,\n EntityUseCaseRunner,\n EntityWriter,\n FilterGroup,\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 — a host's catalog check typically scans its\n * domain packages for `@useCase()` decorators and never `.tsx`, so a runtime\n * 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, TEntity extends Entity = Entity> {\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 * A restriction on what may be picked **for this record**, ANDed into every\n * quick and browse request — `useEntityLinkSource`'s `baseFiltering`, built\n * from the record being edited rather than fixed at factory time.\n *\n * A record-dependent rule is the case it exists for: a parent picker that\n * must not offer the record itself or anything beneath it. That rule needs\n * more than the record — its descendants are other records — which is why\n * this is a **hook** and not a function of the record: it may load what it\n * needs through the host's own adapters, and answer `undefined` until it has.\n *\n * Called on every render of the single view, under the rules of hooks: once\n * per link, unconditionally, with `undefined` while the record loads and\n * throughout a create. `undefined` back means no restriction. Its members\n * must be `filterable` on the target, or the service answers `400`. It\n * narrows the suggestions and nothing else — the service still has to refuse\n * a value the picker would not have offered.\n */\n readonly useBaseFiltering?: (\n record: TEntity | undefined,\n ) => AnyFilterGroup | undefined;\n}\n\n/**\n * A restriction over a picker's target, with the target's type erased — the\n * link names its target only as `EntityConstructor<Entity>`, so a filter typed\n * on the real target would not be assignable. Erased for the reason\n * {@link AnyEntityLinkSourceConfig} is.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyFilterGroup = FilterGroup<any>;\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 /**\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 */\n readonly toolbar?: ReactNode;\n /**\n * How many rows the list asks for on its first load. Defaults to\n * `useDataLoading`'s own default.\n *\n * Raised for a vocabulary that should be seen whole: `EntityTable` nests a\n * hierarchy only within the page it was given, so a tree larger than one page\n * shows the children whose parent fell on another page as roots.\n */\n readonly pageSize?: number;\n /**\n * The filter the list opens with — a worklist, where the default view of a\n * record class is the rows someone has to act on. Shown in the filter panel\n * as the user's own, so it can be changed or cleared; unlike a link's\n * `useBaseFiltering`, it restricts nothing.\n *\n * Checked when the screen is generated against the same allowlist a service\n * applies to a query: a member that is not `filterable`, or a value of the\n * wrong type, throws here rather than answering `400` on every first load.\n */\n readonly initialFiltering?: FilterGroup<TEntity>;\n /**\n * How the record page's Delete is made safe\n * ([ADR 0026](../../../../../../docs/adr/0026-actions-hierarchy-overflow-and-destructive-verbs.md)):\n * `confirm` (the default) asks in an alert dialog naming the record; `typed`\n * asks for its name to be typed first — for the records a fleet boots from;\n * `undo` deletes at once and offers Undo, which saves the record back under\n * its id, so it needs a store whose save puts a record back rather than\n * refusing an id it no longer holds.\n */\n readonly delete?: 'confirm' | 'undo' | 'typed';\n /** Frozen at factory time — see `use-entity-link-sources.ts`. */\n readonly links?: readonly EntityCrudLink<TAdapters, TEntity>[];\n /**\n * Where the entity's served affordances come from — `GET /api/<entity>/$metadata`.\n *\n * Supplying it is what turns on every served affordance:\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 * Which adapter holds this entity's {@link EntityMetadataSource} — the same\n * source as {@link metadataSource}, resolved from the host's composition\n * instead of built by the caller.\n *\n * Prefer it: a source is a transport, and naming it by key keeps the module\n * that generates the screens free of the adapter that fetches, exactly as\n * {@link repository} already does for records. Supplying both is a build\n * error — two answers to where the document comes from.\n */\n readonly metadata?: AdapterKey<TAdapters, EntityMetadataSource>;\n /**\n * Which adapter runs this entity's `@useCase()` verbs — over REST against\n * the service that serves them, or in-process for records that live in the\n * browser. Resolved from the host's composition, as {@link repository} is.\n *\n * Supplying it lets the generated screens run what the served `$metadata`\n * lists for the caller: a row's menu and a form's buttons run a verb on a\n * record, and the bulk bar runs a `collection` verb over a selection,\n * reporting per row. A verb that resolves reloads what it changed; one that\n * refuses shows its coded message in the screen's error slot rather than as\n * a promise nobody catches.\n */\n readonly useCases?: AdapterKey<TAdapters, EntityUseCaseRunner>;\n /**\n * Which adapter makes this entity's saves and deletes, answering both\n * settle modes — `buildEntityRestAdapterWrite` over REST. Resolved from the\n * host's composition, as {@link repository} is.\n *\n * Omitted, the form writes through {@link repository}, and every write\n * settles. Supplied, a write the server hands to a flow keeps the form open\n * and waiting, with what was typed, until the flow settles: a completed one\n * returns to the list, and a failed one is toasted once by the\n * `PendingFlowsProvider` above while the form keeps its input.\n */\n readonly write?: AdapterKey<TAdapters, EntityWriter>;\n\n /**\n * An adapter context providing `EntityFacetCounterTag` — the REST client's\n * facets adapter, typically. Supplied, the list's filter panel shows how\n * many records hold each choice of an enum or boolean member, counted under\n * the filters in effect less that member's own.\n */\n readonly facets?: AdapterKey<TAdapters, Context<EntityFacetCounterTag>>;\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 */\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":"AA4UA;;;CAGC,GACD,WAIC"}
@@ -0,0 +1,32 @@
1
+ import { type EntityRepositoryTag } from '@entifix/business';
2
+ import { type Entity, type EntityConstructor, type Locale } from '@entifix/core';
3
+ import { Context } from 'effect';
4
+ /** One member a list shows as the record it names, and where to read it. */
5
+ export interface LinkLabelPlan {
6
+ readonly field: string;
7
+ readonly entityConstructor: EntityConstructor<Entity>;
8
+ readonly labelProperty: string;
9
+ readonly ctx: Context.Context<EntityRepositoryTag>;
10
+ }
11
+ /** What a list cell knows about the record an id names. */
12
+ export type LinkLabel = {
13
+ readonly state: 'resolving';
14
+ } | {
15
+ readonly state: 'named';
16
+ readonly label: string;
17
+ } | {
18
+ readonly state: 'unnamed';
19
+ };
20
+ /** A target's label member as a reader sees it: localized, or as text. */
21
+ export declare const targetLabel: (raw: unknown, locale: Locale) => string | undefined;
22
+ /**
23
+ * The records a page of rows refers to by id, read once per distinct id and
24
+ * cached under the target's own scope, so a list column can name each one
25
+ * rather than print its key (#200).
26
+ */
27
+ export declare function useLinkLabels(plans: readonly LinkLabelPlan[], items: readonly Entity[]): (field: string, item: Entity) => LinkLabel | undefined;
28
+ /** A list cell for an id: the record's name, a skeleton while it is read. */
29
+ export declare function LinkLabelCell({ label }: {
30
+ label: LinkLabel | undefined;
31
+ }): import("react").JSX.Element;
32
+ //# sourceMappingURL=use-link-labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-link-labels.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/use-link-labels.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,MAAM,EACX,KAAK,iBAAiB,EAEtB,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,OAAO,EAAU,MAAM,QAAQ,CAAC;AAEzC,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACpD;AAED,2DAA2D;AAC3D,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAOlC,0EAA0E;AAC1E,eAAO,MAAM,WAAW,GACtB,KAAK,OAAO,EACZ,QAAQ,MAAM,KACb,MAAM,GAAG,SAKO,CAAC;AAEpB;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,aAAa,EAAE,EAC/B,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,CAiDxD;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,SAAS,GAAG,SAAS,CAAA;CAAE,+BAKxE"}
@@ -0,0 +1,76 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { EntityIdTag, getUCFactory } from '@entifix/business';
4
+ import { isLocalizedText, localize } from '@entifix/core';
5
+ import { Skeleton, useLocale } from '@entifix/react-controls';
6
+ import { entityQueryScope } from '@entifix/react-integration';
7
+ import { useQueries } from '@tanstack/react-query';
8
+ import { Context, Effect } from 'effect';
9
+ const idOf = (item, field)=>{
10
+ const raw = item[field];
11
+ return raw == null || raw === '' ? undefined : String(raw);
12
+ };
13
+ /** A target's label member as a reader sees it: localized, or as text. */ export const targetLabel = (raw, locale)=>isLocalizedText(raw) ? localize(raw, locale) : raw == null || raw === '' ? undefined : String(raw);
14
+ /**
15
+ * The records a page of rows refers to by id, read once per distinct id and
16
+ * cached under the target's own scope, so a list column can name each one
17
+ * rather than print its key (#200).
18
+ */ export function useLinkLabels(plans, items) {
19
+ const locale = useLocale();
20
+ const requests = plans.flatMap((plan)=>[
21
+ ...new Set(items.map((item)=>idOf(item, plan.field)).filter((id)=>id !== undefined))
22
+ ].map((id)=>({
23
+ plan,
24
+ id
25
+ })));
26
+ const results = useQueries({
27
+ queries: requests.map(({ plan, id })=>({
28
+ queryKey: [
29
+ ...entityQueryScope(plan.entityConstructor),
30
+ 'label',
31
+ id
32
+ ],
33
+ queryFn: ()=>Effect.runPromise(Effect.provide(getUCFactory(), plan.ctx.pipe(Context.add(EntityIdTag, id))))
34
+ }))
35
+ });
36
+ const byKey = new Map(requests.map(({ plan, id }, index)=>[
37
+ `${plan.field}\u0000${id}`,
38
+ {
39
+ plan,
40
+ result: results[index]
41
+ }
42
+ ]));
43
+ return (field, item)=>{
44
+ var _result_data;
45
+ const id = idOf(item, field);
46
+ if (id === undefined) return undefined;
47
+ // Every id on the page was asked for above, so the entry is there.
48
+ const { plan, result } = byKey.get(`${field}\u0000${id}`);
49
+ if (result.isPending) return {
50
+ state: 'resolving'
51
+ };
52
+ const raw = (_result_data = result.data) == null ? void 0 : _result_data[plan.labelProperty];
53
+ const label = targetLabel(raw, locale);
54
+ return label === undefined ? {
55
+ state: 'unnamed'
56
+ } : {
57
+ state: 'named',
58
+ label
59
+ };
60
+ };
61
+ }
62
+ /** A list cell for an id: the record's name, a skeleton while it is read. */ export function LinkLabelCell({ label }) {
63
+ if ((label == null ? void 0 : label.state) === 'resolving') return /*#__PURE__*/ _jsx(Skeleton, {
64
+ shape: "line",
65
+ className: "w-16"
66
+ });
67
+ if ((label == null ? void 0 : label.state) === 'named') return /*#__PURE__*/ _jsx("span", {
68
+ children: label.label
69
+ });
70
+ return /*#__PURE__*/ _jsx("span", {
71
+ className: "text-content-muted",
72
+ children: "—"
73
+ });
74
+ }
75
+
76
+ //# sourceMappingURL=use-link-labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/crud/use-link-labels.tsx"],"sourcesContent":["'use client';\n\nimport {\n EntityIdTag,\n type EntityRepositoryTag,\n getUCFactory,\n} from '@entifix/business';\nimport {\n type Entity,\n type EntityConstructor,\n isLocalizedText,\n type Locale,\n localize,\n} from '@entifix/core';\nimport { Skeleton, useLocale } from '@entifix/react-controls';\nimport { entityQueryScope } from '@entifix/react-integration';\nimport { useQueries } from '@tanstack/react-query';\nimport { Context, Effect } from 'effect';\n\n/** One member a list shows as the record it names, and where to read it. */\nexport interface LinkLabelPlan {\n readonly field: string;\n readonly entityConstructor: EntityConstructor<Entity>;\n readonly labelProperty: string;\n readonly ctx: Context.Context<EntityRepositoryTag>;\n}\n\n/** What a list cell knows about the record an id names. */\nexport type LinkLabel =\n | { readonly state: 'resolving' }\n | { readonly state: 'named'; readonly label: string }\n | { readonly state: 'unnamed' };\n\nconst idOf = (item: Entity, field: string): string | undefined => {\n const raw = (item as unknown as Record<string, unknown>)[field];\n return raw == null || raw === '' ? undefined : String(raw);\n};\n\n/** A target's label member as a reader sees it: localized, or as text. */\nexport const targetLabel = (\n raw: unknown,\n locale: Locale,\n): string | undefined =>\n isLocalizedText(raw)\n ? localize(raw, locale)\n : raw == null || raw === ''\n ? undefined\n : String(raw);\n\n/**\n * The records a page of rows refers to by id, read once per distinct id and\n * cached under the target's own scope, so a list column can name each one\n * rather than print its key (#200).\n */\nexport function useLinkLabels(\n plans: readonly LinkLabelPlan[],\n items: readonly Entity[],\n): (field: string, item: Entity) => LinkLabel | undefined {\n const locale = useLocale();\n const requests = plans.flatMap(plan =>\n [\n ...new Set(\n items\n .map(item => idOf(item, plan.field))\n .filter((id): id is string => id !== undefined),\n ),\n ].map(id => ({ plan, id })),\n );\n\n const results = useQueries({\n queries: requests.map(({ plan, id }) => ({\n queryKey: [...entityQueryScope(plan.entityConstructor), 'label', id],\n queryFn: () =>\n Effect.runPromise(\n Effect.provide(\n getUCFactory<Entity>(),\n plan.ctx.pipe(Context.add(EntityIdTag, id)),\n ),\n ),\n })),\n });\n\n const byKey = new Map(\n requests.map(({ plan, id }, index) => [\n `${plan.field}\\u0000${id}`,\n { plan, result: results[index] },\n ]),\n );\n\n return (field, item) => {\n const id = idOf(item, field);\n if (id === undefined) return undefined;\n // Every id on the page was asked for above, so the entry is there.\n const { plan, result } = byKey.get(`${field}\\u0000${id}`) as {\n plan: LinkLabelPlan;\n result: (typeof results)[number];\n };\n if (result.isPending) return { state: 'resolving' };\n const raw = (result.data as Record<string, unknown> | undefined)?.[\n plan.labelProperty\n ];\n const label = targetLabel(raw, locale);\n return label === undefined\n ? { state: 'unnamed' }\n : { state: 'named', label };\n };\n}\n\n/** A list cell for an id: the record's name, a skeleton while it is read. */\nexport function LinkLabelCell({ label }: { label: LinkLabel | undefined }) {\n if (label?.state === 'resolving')\n return <Skeleton shape=\"line\" className=\"w-16\" />;\n if (label?.state === 'named') return <span>{label.label}</span>;\n return <span className=\"text-content-muted\">—</span>;\n}\n"],"names":["EntityIdTag","getUCFactory","isLocalizedText","localize","Skeleton","useLocale","entityQueryScope","useQueries","Context","Effect","idOf","item","field","raw","undefined","String","targetLabel","locale","useLinkLabels","plans","items","requests","flatMap","plan","Set","map","filter","id","results","queries","queryKey","entityConstructor","queryFn","runPromise","provide","ctx","pipe","add","byKey","Map","index","result","get","isPending","state","data","labelProperty","label","LinkLabelCell","shape","className","span"],"mappings":"AAAA;;AAEA,SACEA,WAAW,EAEXC,YAAY,QACP,oBAAoB;AAC3B,SAGEC,eAAe,EAEfC,QAAQ,QACH,gBAAgB;AACvB,SAASC,QAAQ,EAAEC,SAAS,QAAQ,0BAA0B;AAC9D,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AAgBzC,MAAMC,OAAO,CAACC,MAAcC;IAC1B,MAAMC,MAAM,AAACF,IAA2C,CAACC,MAAM;IAC/D,OAAOC,OAAO,QAAQA,QAAQ,KAAKC,Y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AAMI,GAAG,CAAC,GAAG9B,MAAM,MAAM,EAAEe,IAAI;QAIxD,IAAIc,OAAOE,SAAS,EAAE,OAAO;YAAEC,OAAO;QAAY;QAClD,MAAM/B,OAAO4B,eAAAA,OAAOI,IAAI,qBAAZ,AAACJ,YAAqD,CAChElB,KAAKuB,aAAa,CACnB;QACD,MAAMC,QAAQ/B,YAAYH,KAAKI;QAC/B,OAAO8B,UAAUjC,YACb;YAAE8B,OAAO;QAAU,IACnB;YAAEA,OAAO;YAASG;QAAM;IAC9B;AACF;AAEA,2EAA2E,GAC3E,OAAO,SAASC,cAAc,EAAED,KAAK,EAAoC;IACvE,IAAIA,CAAAA,yBAAAA,MAAOH,KAAK,MAAK,aACnB,qBAAO,KAACxC;QAAS6C,OAAM;QAAOC,WAAU;;IAC1C,IAAIH,CAAAA,yBAAAA,MAAOH,KAAK,MAAK,SAAS,qBAAO,KAACO;kBAAMJ,MAAMA,KAAK;;IACvD,qBAAO,KAACI;QAAKD,WAAU;kBAAqB;;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/en.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG,cAAc,SAAS,EAAE,KAAK,CAAC;AAE9C,eAAO,MAAM,KAAK,EAAE,OAmFnB,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/en.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG,cAAc,SAAS,EAAE,KAAK,CAAC;AAE9C,eAAO,MAAM,KAAK,EAAE,OAqFnB,CAAC"}
@@ -1,10 +1,9 @@
1
1
  export const shell = {
2
2
  nav: {
3
3
  primary: 'Primary',
4
- openInWorkspace: 'Open {{label}} in workspace',
5
- openInWorkspaceShort: 'Open in workspace',
6
- openInNewTab: 'Open {{label}} in a new tab',
7
- openInNewTabShort: 'Open in a new tab',
4
+ openInWorkspace: 'Open in workspace',
5
+ openInNewTab: 'Open in a new tab',
6
+ /** The one menu beside each destination: open it elsewhere. */ itemActions: 'Options for {{label}}',
8
7
  /**
9
8
  * The screen taxonomy. Translated like every other string rather
10
9
  * than kept in Spanish: what that decision fixed was which *Spanish* word
@@ -41,6 +40,7 @@ export const shell = {
41
40
  openInWorkspaceHint: 'Tab'
42
41
  },
43
42
  sidebar: {
43
+ /** The page's first stop: past the navigation, to the content. */ skipToContent: 'Skip to content',
44
44
  expand: 'Expand sidebar',
45
45
  collapse: 'Collapse sidebar',
46
46
  openMenu: 'Open the menu',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/i18n/catalog/en.ts"],"sourcesContent":["type EsShell = typeof import('./es.js').shell;\n\nexport const shell: EsShell = {\n nav: {\n primary: 'Primary',\n openInWorkspace: 'Open {{label}} in workspace',\n openInWorkspaceShort: 'Open in workspace',\n openInNewTab: 'Open {{label}} in a new tab',\n openInNewTabShort: 'Open in a new tab',\n /**\n * The screen taxonomy. Translated like every other string rather\n * than kept in Spanish: what that decision fixed was which *Spanish* word\n * ships to the default locale, not that the term is untranslatable.\n */\n screenType: {\n master: 'Definitions',\n operation: 'Operations',\n wizard: 'Wizards',\n report: 'Reports',\n },\n },\n commandPalette: {\n open: 'Search or run',\n title: 'Search or run',\n placeholder: 'Search a record, a screen or a command…',\n newPlaceholder: 'What would you like to create?',\n newLabel: 'New…',\n newTitle: 'New',\n back: 'Back',\n empty: 'No results',\n loading: 'Searching…',\n more_one: '{{count}} more',\n more_other: '{{count}} more',\n typeMore: 'Type at least {{count}} characters to search records.',\n groups: {\n actions: 'Actions',\n commands: 'Commands',\n navigation: 'Navigation',\n tabs: 'Open tabs',\n records: 'Records',\n },\n unavailableScope: 'Not available here: {{reason}}',\n unavailableReach: 'We could not reach this source: {{reason}}',\n openInWorkspaceHint: 'Tab',\n },\n sidebar: {\n expand: 'Expand sidebar',\n collapse: 'Collapse sidebar',\n openMenu: 'Open the menu',\n closeMenu: 'Close the menu',\n menu: 'Navigation menu',\n expandGroup: 'Expand {{group}}',\n collapseGroup: 'Collapse {{group}}',\n },\n session: {\n expiringSoon:\n 'Your session is about to expire. Save your work and sign in again to continue.',\n },\n breadcrumbs: {\n home: 'Home',\n // The `/new` segment, which every domain's create route shares. It was\n // an auth-specific string until one host started serving two domains,\n // at which point a catalog page's breadcrumb read \"New user\".\n new: 'New',\n },\n account: {\n profile: 'Profile',\n security: 'Security',\n sessions: 'Sessions',\n signOut: 'Sign out',\n },\n workspace: {\n copyLink: 'Copy link',\n empty: 'No open tabs. Pick a catalog from the sidebar to start.',\n unsupported: \"This tab can't be opened here.\",\n discardTitle: 'Discard changes',\n discard: 'This tab has unsaved changes. Closing it will lose them.',\n discardConfirm: 'Discard',\n // See the Spanish catalog for why a failure's reason is not a key here.\n pendingLabel: 'Save status',\n savePending_one: 'Saving 1 record…',\n savePending_other: 'Saving {{count}} records…',\n saveFailed: 'The record could not be saved.',\n saveFailedDismiss: 'Dismiss',\n },\n};\n"],"names":["shell","nav","primary","openInWorkspace","openInWorkspaceShort","openInNewTab","openInNewTabShort","screenType","master","operation","wizard","report","commandPalette","open","title","placeholder","newPlaceholder","newLabel","newTitle","back","empty","loading","more_one","more_other","typeMore","groups","actions","commands","navigation","tabs","records","unavailableScope","unavailableReach","openInWorkspaceHint","sidebar","expand","collapse","openMenu","closeMenu","menu","expandGroup","collapseGroup","session","expiringSoon","breadcrumbs","home","new","account","profile","security","sessions","signOut","workspace","copyLink","unsupported","discardTitle","discard","discardConfirm","pendingLabel","savePending_one","savePending_other","saveFailed","saveFailedDismiss"],"mappings":"AAEA,OAAO,MAAMA,QAAiB;IAC5BC,KAAK;QACHC,SAAS;QACTC,iBAAiB;QACjBC,sBAAsB;QACtBC,cAAc;QACdC,mBAAmB;QACnB;;;;KAIC,GACDC,YAAY;YACVC,QAAQ;YACRC,WAAW;YACXC,QAAQ;YACRC,QAAQ;QACV;IACF;IACAC,gBAAgB;QACdC,MAAM;QACNC,OAAO;QACPC,aAAa;QACbC,gBAAgB;QAChBC,UAAU;QACVC,UAAU;QACVC,MAAM;QACNC,OAAO;QACPC,SAAS;QACTC,UAAU;QACVC,YAAY;QACZC,UAAU;QACVC,QAAQ;YACNC,SAAS;YACTC,UAAU;YACVC,YAAY;YACZC,MAAM;YACNC,SAAS;QACX;QACAC,kBAAkB;QAClBC,kBAAkB;QAClBC,qBAAqB;IACvB;IACAC,SAAS;QACPC,QAAQ;QACRC,UAAU;QACVC,UAAU;QACVC,WAAW;QACXC,MAAM;QACNC,aAAa;QACbC,eAAe;IACjB;IACAC,SAAS;QACPC,cACE;IACJ;IACAC,aAAa;QACXC,MAAM;QACN,uEAAuE;QACvE,sEAAsE;QACtE,8DAA8D;QAC9DC,KAAK;IACP;IACAC,SAAS;QACPC,SAAS;QACTC,UAAU;QACVC,UAAU;QACVC,SAAS;IACX;IACAC,WAAW;QACTC,UAAU;QACVjC,OAAO;QACPkC,aAAa;QACbC,cAAc;QACdC,SAAS;QACTC,gBAAgB;QAChB,wEAAwE;QACxEC,cAAc;QACdC,iBAAiB;QACjBC,mBAAmB;QACnBC,YAAY;QACZC,mBAAmB;IACrB;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../src/lib/i18n/catalog/en.ts"],"sourcesContent":["type EsShell = typeof import('./es.js').shell;\n\nexport const shell: EsShell = {\n nav: {\n primary: 'Primary',\n openInWorkspace: 'Open in workspace',\n openInNewTab: 'Open in a new tab',\n /** The one menu beside each destination: open it elsewhere. */\n itemActions: 'Options for {{label}}',\n /**\n * The screen taxonomy. Translated like every other string rather\n * than kept in Spanish: what that decision fixed was which *Spanish* word\n * ships to the default locale, not that the term is untranslatable.\n */\n screenType: {\n master: 'Definitions',\n operation: 'Operations',\n wizard: 'Wizards',\n report: 'Reports',\n },\n },\n commandPalette: {\n open: 'Search or run',\n title: 'Search or run',\n placeholder: 'Search a record, a screen or a command…',\n newPlaceholder: 'What would you like to create?',\n newLabel: 'New…',\n newTitle: 'New',\n back: 'Back',\n empty: 'No results',\n loading: 'Searching…',\n more_one: '{{count}} more',\n more_other: '{{count}} more',\n typeMore: 'Type at least {{count}} characters to search records.',\n groups: {\n actions: 'Actions',\n commands: 'Commands',\n navigation: 'Navigation',\n tabs: 'Open tabs',\n records: 'Records',\n },\n unavailableScope: 'Not available here: {{reason}}',\n unavailableReach: 'We could not reach this source: {{reason}}',\n openInWorkspaceHint: 'Tab',\n },\n sidebar: {\n /** The page's first stop: past the navigation, to the content. */\n skipToContent: 'Skip to content',\n expand: 'Expand sidebar',\n collapse: 'Collapse sidebar',\n openMenu: 'Open the menu',\n closeMenu: 'Close the menu',\n menu: 'Navigation menu',\n expandGroup: 'Expand {{group}}',\n collapseGroup: 'Collapse {{group}}',\n },\n session: {\n expiringSoon:\n 'Your session is about to expire. Save your work and sign in again to continue.',\n },\n breadcrumbs: {\n home: 'Home',\n // The `/new` segment, which every domain's create route shares. It was\n // an auth-specific string until one host started serving two domains,\n // at which point a catalog page's breadcrumb read \"New user\".\n new: 'New',\n },\n account: {\n profile: 'Profile',\n security: 'Security',\n sessions: 'Sessions',\n signOut: 'Sign out',\n },\n workspace: {\n copyLink: 'Copy link',\n empty: 'No open tabs. Pick a catalog from the sidebar to start.',\n unsupported: \"This tab can't be opened here.\",\n discardTitle: 'Discard changes',\n discard: 'This tab has unsaved changes. Closing it will lose them.',\n discardConfirm: 'Discard',\n // See the Spanish catalog for why a failure's reason is not a key here.\n pendingLabel: 'Save status',\n savePending_one: 'Saving 1 record…',\n savePending_other: 'Saving {{count}} records…',\n saveFailed: 'The record could not be saved.',\n saveFailedDismiss: 'Dismiss',\n },\n};\n"],"names":["shell","nav","primary","openInWorkspace","openInNewTab","itemActions","screenType","master","operation","wizard","report","commandPalette","open","title","placeholder","newPlaceholder","newLabel","newTitle","back","empty","loading","more_one","more_other","typeMore","groups","actions","commands","navigation","tabs","records","unavailableScope","unavailableReach","openInWorkspaceHint","sidebar","skipToContent","expand","collapse","openMenu","closeMenu","menu","expandGroup","collapseGroup","session","expiringSoon","breadcrumbs","home","new","account","profile","security","sessions","signOut","workspace","copyLink","unsupported","discardTitle","discard","discardConfirm","pendingLabel","savePending_one","savePending_other","saveFailed","saveFailedDismiss"],"mappings":"AAEA,OAAO,MAAMA,QAAiB;IAC5BC,KAAK;QACHC,SAAS;QACTC,iBAAiB;QACjBC,cAAc;QACd,6DAA6D,GAC7DC,aAAa;QACb;;;;KAIC,GACDC,YAAY;YACVC,QAAQ;YACRC,WAAW;YACXC,QAAQ;YACRC,QAAQ;QACV;IACF;IACAC,gBAAgB;QACdC,MAAM;QACNC,OAAO;QACPC,aAAa;QACbC,gBAAgB;QAChBC,UAAU;QACVC,UAAU;QACVC,MAAM;QACNC,OAAO;QACPC,SAAS;QACTC,UAAU;QACVC,YAAY;QACZC,UAAU;QACVC,QAAQ;YACNC,SAAS;YACTC,UAAU;YACVC,YAAY;YACZC,MAAM;YACNC,SAAS;QACX;QACAC,kBAAkB;QAClBC,kBAAkB;QAClBC,qBAAqB;IACvB;IACAC,SAAS;QACP,gEAAgE,GAChEC,eAAe;QACfC,QAAQ;QACRC,UAAU;QACVC,UAAU;QACVC,WAAW;QACXC,MAAM;QACNC,aAAa;QACbC,eAAe;IACjB;IACAC,SAAS;QACPC,cACE;IACJ;IACAC,aAAa;QACXC,MAAM;QACN,uEAAuE;QACvE,sEAAsE;QACtE,8DAA8D;QAC9DC,KAAK;IACP;IACAC,SAAS;QACPC,SAAS;QACTC,UAAU;QACVC,UAAU;QACVC,SAAS;IACX;IACAC,WAAW;QACTC,UAAU;QACVlC,OAAO;QACPmC,aAAa;QACbC,cAAc;QACdC,SAAS;QACTC,gBAAgB;QAChB,wEAAwE;QACxEC,cAAc;QACdC,iBAAiB;QACjBC,mBAAmB;QACnBC,YAAY;QACZC,mBAAmB;IACrB;AACF,EAAE"}
@@ -3,9 +3,9 @@ export declare const shell: {
3
3
  nav: {
4
4
  primary: string;
5
5
  openInWorkspace: string;
6
- openInWorkspaceShort: string;
7
6
  openInNewTab: string;
8
- openInNewTabShort: string;
7
+ /** The one menu beside each destination: open it elsewhere. */
8
+ itemActions: string;
9
9
  /**
10
10
  * The screen taxonomy — the sidebar's top tier, above the
11
11
  * domain. `Definiciones` rather than `Maestros` because the ERP term needs
@@ -60,6 +60,8 @@ export declare const shell: {
60
60
  openInWorkspaceHint: string;
61
61
  };
62
62
  sidebar: {
63
+ /** The page's first stop: past the navigation, to the content. */
64
+ skipToContent: string;
63
65
  expand: string;
64
66
  collapse: string;
65
67
  openMenu: string;
@@ -1 +1 @@
1
- {"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/es.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,eAAO,MAAM,KAAK;;;;;;;QAOd;;;;;;WAMG;;;;;;;;IAQL;;;;OAIG;;QAED,4EAA4E;;QAE5E,qDAAqD;;;;;QAKrD,4EAA4E;;;;;;;QAO5E,2EAA2E;;;;;;;;;QAS3E;;;;WAIG;;;QAGH,uEAAuE;;;;;;;;;;;;IAezE;;;;;OAKG;;;;;;;;IAYH;;;;OAIG;;;;;;;;;;;;;;;;;;;;CAkCJ,CAAC"}
1
+ {"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/es.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,eAAO,MAAM,KAAK;;;;;QAKd,+DAA+D;;QAE/D;;;;;;WAMG;;;;;;;;IAQL;;;;OAIG;;QAED,4EAA4E;;QAE5E,qDAAqD;;;;;QAKrD,4EAA4E;;;;;;;QAO5E,2EAA2E;;;;;;;;;QAS3E;;;;WAIG;;;QAGH,uEAAuE;;;;QAIvE,kEAAkE;;;;;;;;;;IAapE;;;;;OAKG;;;;;;;;IAYH;;;;OAIG;;;;;;;;;;;;;;;;;;;;CAkCJ,CAAC"}
@@ -1,10 +1,9 @@
1
1
  /** Copy owned by the Next shells — back-office chrome and the tab workspace. */ export const shell = {
2
2
  nav: {
3
3
  primary: 'Principal',
4
- openInWorkspace: 'Abrir {{label}} en el espacio de trabajo',
5
- openInWorkspaceShort: 'Abrir en el espacio de trabajo',
6
- openInNewTab: 'Abrir {{label}} en una pestaña nueva',
7
- openInNewTabShort: 'Abrir en una pestaña nueva',
4
+ openInWorkspace: 'Abrir en el espacio de trabajo',
5
+ openInNewTab: 'Abrir en una pestaña nueva',
6
+ /** The one menu beside each destination: open it elsewhere. */ itemActions: 'Opciones de {{label}}',
8
7
  /**
9
8
  * The screen taxonomy — the sidebar's top tier, above the
10
9
  * domain. `Definiciones` rather than `Maestros` because the ERP term needs
@@ -51,6 +50,7 @@
51
50
  /** Sufijo del comando que abre un destino como pestaña del espacio. */ openInWorkspaceHint: 'Pestaña'
52
51
  },
53
52
  sidebar: {
53
+ /** The page's first stop: past the navigation, to the content. */ skipToContent: 'Saltar al contenido',
54
54
  expand: 'Expandir barra lateral',
55
55
  collapse: 'Contraer barra lateral',
56
56
  openMenu: 'Abrir el menú',