@entifix/next-shell 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/config/service-proxy-route.d.ts +4 -7
- package/dist/lib/config/service-proxy-route.d.ts.map +1 -1
- package/dist/lib/config/service-proxy-route.js +1 -25
- package/dist/lib/config/service-proxy-route.js.map +1 -1
- package/dist/lib/crud/entity-crud-form.d.ts +5 -3
- package/dist/lib/crud/entity-crud-form.d.ts.map +1 -1
- package/dist/lib/crud/entity-crud-form.js +2 -1
- package/dist/lib/crud/entity-crud-form.js.map +1 -1
- package/dist/lib/crud/index.d.ts +0 -1
- package/dist/lib/crud/index.d.ts.map +1 -1
- package/dist/lib/crud/index.js +0 -1
- package/dist/lib/crud/index.js.map +1 -1
- package/dist/lib/crud/make-entity-crud.d.ts +7 -12
- package/dist/lib/crud/make-entity-crud.d.ts.map +1 -1
- package/dist/lib/crud/make-entity-crud.js +154 -114
- package/dist/lib/crud/make-entity-crud.js.map +1 -1
- package/dist/lib/crud/make-entity-crud.types.d.ts +13 -1
- package/dist/lib/crud/make-entity-crud.types.d.ts.map +1 -1
- package/dist/lib/crud/make-entity-crud.types.js.map +1 -1
- package/dist/lib/session/bearer.d.ts +1 -1
- package/dist/lib/session/bearer.js +1 -1
- package/dist/lib/session/bearer.js.map +1 -1
- package/dist/lib/workspace/index.d.ts +1 -2
- package/dist/lib/workspace/index.d.ts.map +1 -1
- package/dist/lib/workspace/index.js +1 -2
- package/dist/lib/workspace/index.js.map +1 -1
- package/dist/lib/workspace/pending-flows.d.ts +48 -0
- package/dist/lib/workspace/pending-flows.d.ts.map +1 -0
- package/dist/lib/workspace/pending-flows.js +60 -0
- package/dist/lib/workspace/pending-flows.js.map +1 -0
- package/package.json +11 -11
- package/dist/lib/crud/hand-off-write.d.ts +0 -35
- package/dist/lib/crud/hand-off-write.d.ts.map +0 -1
- package/dist/lib/crud/hand-off-write.js +0 -27
- package/dist/lib/crud/hand-off-write.js.map +0 -1
- package/dist/lib/crud/pending-notice.d.ts +0 -31
- package/dist/lib/crud/pending-notice.d.ts.map +0 -1
- package/dist/lib/crud/pending-notice.js +0 -72
- package/dist/lib/crud/pending-notice.js.map +0 -1
- package/dist/lib/workspace/pending-state.d.ts +0 -85
- package/dist/lib/workspace/pending-state.d.ts.map +0 -1
- package/dist/lib/workspace/pending-state.js +0 -155
- package/dist/lib/workspace/pending-state.js.map +0 -1
- package/dist/lib/workspace/pending-transactions.d.ts +0 -44
- package/dist/lib/workspace/pending-transactions.d.ts.map +0 -1
- package/dist/lib/workspace/pending-transactions.js +0 -114
- package/dist/lib/workspace/pending-transactions.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntityRepositoryTag } from '@entifix/business';
|
|
2
|
-
import type { Entity, EntityConstructor, EntityFieldDescriptor, EntityMetadataSource, EntityUseCaseRunner, FilterGroup } from '@entifix/core';
|
|
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';
|
|
5
5
|
import type { CustomTypeOptions } from 'i18next';
|
|
@@ -199,6 +199,18 @@ export interface EntityCrudOptions<TAdapters, TEntity extends Entity> {
|
|
|
199
199
|
* a promise nobody catches.
|
|
200
200
|
*/
|
|
201
201
|
readonly useCases?: AdapterKey<TAdapters, EntityUseCaseRunner>;
|
|
202
|
+
/**
|
|
203
|
+
* Which adapter makes this entity's saves and deletes, answering both
|
|
204
|
+
* settle modes — `buildEntityRestAdapterWrite` over REST. Resolved from the
|
|
205
|
+
* host's composition, as {@link repository} is.
|
|
206
|
+
*
|
|
207
|
+
* Omitted, the form writes through {@link repository}, and every write
|
|
208
|
+
* settles. Supplied, a write the server hands to a flow keeps the form open
|
|
209
|
+
* and waiting, with what was typed, until the flow settles: a completed one
|
|
210
|
+
* returns to the list, and a failed one is toasted once by the
|
|
211
|
+
* `PendingFlowsProvider` above while the form keeps its input.
|
|
212
|
+
*/
|
|
213
|
+
readonly write?: AdapterKey<TAdapters, EntityWriter>;
|
|
202
214
|
}
|
|
203
215
|
/**
|
|
204
216
|
* 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":["../../../src/lib/crud/make-entity-crud.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,gBAAgB,CAC1B,cAAc,GAAG,eAAe,CAAC,oBAAoB,CAAC,IACpD,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,GAIhC,MAAM,GACN;KACG,CAAC,IAAI,MAAM,cAAc,GAAG,cAAc,CAAC,CAAC,CAAC,SAAS;QACrD,IAAI,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;QAC9C,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,GACG,CAAC,GACD,KAAK;CACV,CAAC,MAAM,cAAc,CA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,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 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 /** 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\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":"AA+RA;;;CAGC,GACD,WAIC"}
|
|
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 /** 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":"AA4SA;;;CAGC,GACD,WAIC"}
|
|
@@ -19,7 +19,7 @@ export declare const sessionToken: () => Promise<string | undefined>;
|
|
|
19
19
|
* same way — the per-backend proxy, the auth shell's hand-written handlers, and
|
|
20
20
|
* the record search fan-out — and none of them grants anything by doing so. They
|
|
21
21
|
* only carry; the service still verifies the token and applies its own
|
|
22
|
-
* `
|
|
22
|
+
* the endpoint's `guard`.
|
|
23
23
|
*/
|
|
24
24
|
export declare const bearerHeader: (token: string | undefined) => Record<string, string>;
|
|
25
25
|
//# sourceMappingURL=bearer.d.ts.map
|
|
@@ -23,7 +23,7 @@ import { cookies } from 'next/headers';
|
|
|
23
23
|
* same way — the per-backend proxy, the auth shell's hand-written handlers, and
|
|
24
24
|
* the record search fan-out — and none of them grants anything by doing so. They
|
|
25
25
|
* only carry; the service still verifies the token and applies its own
|
|
26
|
-
* `
|
|
26
|
+
* the endpoint's `guard`.
|
|
27
27
|
*/ export const bearerHeader = (token)=>token === undefined ? {} : {
|
|
28
28
|
Authorization: `Bearer ${token}`
|
|
29
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/session/bearer.ts"],"sourcesContent":["import { ACCESS_COOKIE } from '@entifix/core';\nimport { cookies } from 'next/headers';\n\n/**\n * The caller's access token, or `undefined` when they hold no session.\n *\n * `entifix_at` is httpOnly, so only the server can read it — which is the whole\n * reason a browser talks to a backend through this app's own origin rather than\n * calling `:310N` directly.\n */\nexport const sessionToken = async (): Promise<string | undefined> =>\n (await cookies()).get(ACCESS_COOKIE)?.value;\n\n/**\n * The token as a forwardable header, and `{}` when there is none.\n *\n * The empty case is the point: a header of `Bearer undefined` is not \"no\n * credential\", it is a malformed one, and a service that answers `401` to both\n * hides the difference right up until one of them starts answering something\n * else. Omitting the header lets the upstream apply its own rule for an\n * anonymous caller — which for `catalog-reference` reads is to allow it.\n *\n * This lives on its own because three server surfaces carry the same cookie the\n * same way — the per-backend proxy, the auth shell's hand-written handlers, and\n * the record search fan-out — and none of them grants anything by doing so. They\n * only carry; the service still verifies the token and applies its own\n * `
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/session/bearer.ts"],"sourcesContent":["import { ACCESS_COOKIE } from '@entifix/core';\nimport { cookies } from 'next/headers';\n\n/**\n * The caller's access token, or `undefined` when they hold no session.\n *\n * `entifix_at` is httpOnly, so only the server can read it — which is the whole\n * reason a browser talks to a backend through this app's own origin rather than\n * calling `:310N` directly.\n */\nexport const sessionToken = async (): Promise<string | undefined> =>\n (await cookies()).get(ACCESS_COOKIE)?.value;\n\n/**\n * The token as a forwardable header, and `{}` when there is none.\n *\n * The empty case is the point: a header of `Bearer undefined` is not \"no\n * credential\", it is a malformed one, and a service that answers `401` to both\n * hides the difference right up until one of them starts answering something\n * else. Omitting the header lets the upstream apply its own rule for an\n * anonymous caller — which for `catalog-reference` reads is to allow it.\n *\n * This lives on its own because three server surfaces carry the same cookie the\n * same way — the per-backend proxy, the auth shell's hand-written handlers, and\n * the record search fan-out — and none of them grants anything by doing so. They\n * only carry; the service still verifies the token and applies its own\n * the endpoint's `guard`.\n */\nexport const bearerHeader = (\n token: string | undefined,\n): Record<string, string> =>\n token === undefined ? {} : { Authorization: `Bearer ${token}` };\n"],"names":["ACCESS_COOKIE","cookies","sessionToken","get","value","bearerHeader","token","undefined","Authorization"],"mappings":"AAAA,SAASA,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,OAAO,QAAQ,eAAe;AAEvC;;;;;;CAMC,GACD,OAAO,MAAMC,eAAe;QAC1B;YAAA,OAAA,AAAC,CAAA,MAAMD,SAAQ,EAAGE,GAAG,CAACH,mCAAtB,KAAsCI,KAAK;EAAC;AAE9C;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMC,eAAe,CAC1BC,QAEAA,UAAUC,YAAY,CAAC,IAAI;QAAEC,eAAe,CAAC,OAAO,EAAEF,OAAO;IAAC,EAAE"}
|
|
@@ -2,8 +2,7 @@ export * from './drafts-state.js';
|
|
|
2
2
|
export * from './entity-nav.js';
|
|
3
3
|
export * from './entity-tab-kind.js';
|
|
4
4
|
export * from './idb-state-storage.js';
|
|
5
|
-
export * from './pending-
|
|
6
|
-
export * from './pending-transactions.js';
|
|
5
|
+
export * from './pending-flows.js';
|
|
7
6
|
export * from './tab-kind.js';
|
|
8
7
|
export * from './tab-state.js';
|
|
9
8
|
export * from './tabs-state.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/workspace/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/workspace/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
|
|
@@ -2,8 +2,7 @@ export * from './drafts-state.js';
|
|
|
2
2
|
export * from './entity-nav.js';
|
|
3
3
|
export * from './entity-tab-kind.js';
|
|
4
4
|
export * from './idb-state-storage.js';
|
|
5
|
-
export * from './pending-
|
|
6
|
-
export * from './pending-transactions.js';
|
|
5
|
+
export * from './pending-flows.js';
|
|
7
6
|
export * from './tab-kind.js';
|
|
8
7
|
export * from './tab-state.js';
|
|
9
8
|
export * from './tabs-state.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/workspace/index.ts"],"sourcesContent":["export * from './drafts-state.js';\nexport * from './entity-nav.js';\nexport * from './entity-tab-kind.js';\nexport * from './idb-state-storage.js';\nexport * from './pending-
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/workspace/index.ts"],"sourcesContent":["export * from './drafts-state.js';\nexport * from './entity-nav.js';\nexport * from './entity-tab-kind.js';\nexport * from './idb-state-storage.js';\nexport * from './pending-flows.js';\nexport * from './tab-kind.js';\nexport * from './tab-state.js';\nexport * from './tabs-state.js';\nexport * from './use-entity-draft.js';\nexport * from './workspace-scope.js';\nexport * from './workspace-shell.js';\n"],"names":[],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,uBAAuB;AACrC,cAAc,yBAAyB;AACvC,cAAc,qBAAqB;AACnC,cAAc,gBAAgB;AAC9B,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,wBAAwB;AACtC,cAAc,uBAAuB;AACrC,cAAc,uBAAuB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type FlowStatusRead, type PendingFlowStorage, type PushChannel } from '@entifix/react-integration';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* How long a pending flow nobody can account for is kept before it is
|
|
5
|
+
* dropped: no push arrived, and its status read answers nothing. Long enough
|
|
6
|
+
* for a flow that waits on a person, short enough that a lost one does not
|
|
7
|
+
* hold a form open across a working day.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PENDING_FLOW_MAX_AGE_MS: number;
|
|
10
|
+
export interface PendingFlowsProviderProps {
|
|
11
|
+
/**
|
|
12
|
+
* Whose pending flows these are — `workspaceScopeKey({ userId,
|
|
13
|
+
* organizationId })`, or `ANONYMOUS_WORKSPACE_SCOPE` for nobody in
|
|
14
|
+
* particular, which keeps flow ids and their age only.
|
|
15
|
+
*
|
|
16
|
+
* Required because IndexedDB belongs to the browser profile, not to
|
|
17
|
+
* whoever signed in.
|
|
18
|
+
*/
|
|
19
|
+
readonly scope: string;
|
|
20
|
+
/** The tab's push channel, where each pending flow's outcome arrives. */
|
|
21
|
+
readonly channel: PushChannel;
|
|
22
|
+
/**
|
|
23
|
+
* Reads a flow's status link when its push may have been missed —
|
|
24
|
+
* `buildFlowStatusReader()` over REST. Omitted, a flow settles by push
|
|
25
|
+
* alone, and one whose push was missed is dropped at the age bound.
|
|
26
|
+
*/
|
|
27
|
+
readonly readStatus?: FlowStatusRead;
|
|
28
|
+
readonly maxAgeMs?: number;
|
|
29
|
+
/** Defaults to IndexedDB, so a pending write survives a reload. */
|
|
30
|
+
readonly storage?: PendingFlowStorage;
|
|
31
|
+
readonly children: ReactNode;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Waits on every write this browser handed to a flow, and tells the operator
|
|
35
|
+
* once when one fails
|
|
36
|
+
* ([ADR 0022](../../../../../../docs/adr/0022-two-settle-modes-and-the-pending-flow-store.md)).
|
|
37
|
+
*
|
|
38
|
+
* It holds the pending-flow store the generated CRUD records into, persisted
|
|
39
|
+
* per principal, and settles each flow from its push or from a status read
|
|
40
|
+
* after a reconnect. A failed flow is shown through the host's
|
|
41
|
+
* `ToastRegion`, translated, exactly once — however many tabs or
|
|
42
|
+
* redeliveries report it.
|
|
43
|
+
*
|
|
44
|
+
* ⚠️ **Mount it inside a `ToastProvider`, and above the plain routes**, not
|
|
45
|
+
* only the workspace: a create is `/<basePath>/new` on the route host.
|
|
46
|
+
*/
|
|
47
|
+
export declare function PendingFlowsProvider({ scope, channel, readStatus, maxAgeMs, storage, children, }: PendingFlowsProviderProps): import("react").JSX.Element;
|
|
48
|
+
//# sourceMappingURL=pending-flows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-flows.d.ts","sourceRoot":"","sources":["../../../src/lib/workspace/pending-flows.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EAEvB,KAAK,WAAW,EAEjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,OAAO,CAAC;AAKhD;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAiB,CAAC;AAQtD,MAAM,WAAW,yBAAyB;IACxC;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,mEAAmE;IACnE,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC9B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,OAAO,EACP,UAAU,EACV,QAAkC,EAClC,OAA4B,EAC5B,QAAQ,GACT,EAAE,yBAAyB,+BAmC3B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useToasts } from '@entifix/react-controls';
|
|
5
|
+
import { makePendingFlowStore, PendingFlowStoreProvider, usePendingFlowSettlement } from '@entifix/react-integration';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
import { makeIndexedDbStateStorage } from './idb-state-storage.js';
|
|
8
|
+
import { ANONYMOUS_WORKSPACE_SCOPE } from './workspace-scope.js';
|
|
9
|
+
/**
|
|
10
|
+
* How long a pending flow nobody can account for is kept before it is
|
|
11
|
+
* dropped: no push arrived, and its status read answers nothing. Long enough
|
|
12
|
+
* for a flow that waits on a person, short enough that a lost one does not
|
|
13
|
+
* hold a form open across a working day.
|
|
14
|
+
*/ export const PENDING_FLOW_MAX_AGE_MS = 30 * 60 * 1000;
|
|
15
|
+
// Module scope: a storage per render would reopen the database each time.
|
|
16
|
+
const pendingFlowStorage = makeIndexedDbStateStorage('entifix-pending-flows', 'flows');
|
|
17
|
+
/**
|
|
18
|
+
* Waits on every write this browser handed to a flow, and tells the operator
|
|
19
|
+
* once when one fails
|
|
20
|
+
* ([ADR 0022](../../../../../../docs/adr/0022-two-settle-modes-and-the-pending-flow-store.md)).
|
|
21
|
+
*
|
|
22
|
+
* It holds the pending-flow store the generated CRUD records into, persisted
|
|
23
|
+
* per principal, and settles each flow from its push or from a status read
|
|
24
|
+
* after a reconnect. A failed flow is shown through the host's
|
|
25
|
+
* `ToastRegion`, translated, exactly once — however many tabs or
|
|
26
|
+
* redeliveries report it.
|
|
27
|
+
*
|
|
28
|
+
* ⚠️ **Mount it inside a `ToastProvider`, and above the plain routes**, not
|
|
29
|
+
* only the workspace: a create is `/<basePath>/new` on the route host.
|
|
30
|
+
*/ export function PendingFlowsProvider({ scope, channel, readStatus, maxAgeMs = PENDING_FLOW_MAX_AGE_MS, storage = pendingFlowStorage, children }) {
|
|
31
|
+
const toasts = useToasts();
|
|
32
|
+
// A store per principal: a sign-in under another scope must never read the
|
|
33
|
+
// previous one's pending writes.
|
|
34
|
+
const store = useMemo(()=>makePendingFlowStore({
|
|
35
|
+
storage,
|
|
36
|
+
key: `pending-flows:${scope}`,
|
|
37
|
+
anonymous: scope === ANONYMOUS_WORKSPACE_SCOPE
|
|
38
|
+
}), [
|
|
39
|
+
scope,
|
|
40
|
+
storage
|
|
41
|
+
]);
|
|
42
|
+
usePendingFlowSettlement(_extends({
|
|
43
|
+
channel,
|
|
44
|
+
store,
|
|
45
|
+
maxAgeMs
|
|
46
|
+
}, readStatus === undefined ? {} : {
|
|
47
|
+
readStatus
|
|
48
|
+
}, {
|
|
49
|
+
onFailure: (failure)=>{
|
|
50
|
+
toasts == null ? void 0 : toasts.showFailure(failure);
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
if (toasts === undefined) throw new Error('PendingFlowsProvider must sit inside a ToastProvider: a failed flow has nowhere else to be shown');
|
|
54
|
+
return /*#__PURE__*/ _jsx(PendingFlowStoreProvider, {
|
|
55
|
+
store: store,
|
|
56
|
+
children: children
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=pending-flows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/workspace/pending-flows.tsx"],"sourcesContent":["'use client';\n\nimport { useToasts } from '@entifix/react-controls';\nimport {\n type FlowStatusRead,\n makePendingFlowStore,\n type PendingFlowStorage,\n PendingFlowStoreProvider,\n type PushChannel,\n usePendingFlowSettlement,\n} from '@entifix/react-integration';\nimport { type ReactNode, useMemo } from 'react';\n\nimport { makeIndexedDbStateStorage } from './idb-state-storage.js';\nimport { ANONYMOUS_WORKSPACE_SCOPE } from './workspace-scope.js';\n\n/**\n * How long a pending flow nobody can account for is kept before it is\n * dropped: no push arrived, and its status read answers nothing. Long enough\n * for a flow that waits on a person, short enough that a lost one does not\n * hold a form open across a working day.\n */\nexport const PENDING_FLOW_MAX_AGE_MS = 30 * 60 * 1000;\n\n// Module scope: a storage per render would reopen the database each time.\nconst pendingFlowStorage = makeIndexedDbStateStorage(\n 'entifix-pending-flows',\n 'flows',\n);\n\nexport interface PendingFlowsProviderProps {\n /**\n * Whose pending flows these are — `workspaceScopeKey({ userId,\n * organizationId })`, or `ANONYMOUS_WORKSPACE_SCOPE` for nobody in\n * particular, which keeps flow ids and their age only.\n *\n * Required because IndexedDB belongs to the browser profile, not to\n * whoever signed in.\n */\n readonly scope: string;\n /** The tab's push channel, where each pending flow's outcome arrives. */\n readonly channel: PushChannel;\n /**\n * Reads a flow's status link when its push may have been missed —\n * `buildFlowStatusReader()` over REST. Omitted, a flow settles by push\n * alone, and one whose push was missed is dropped at the age bound.\n */\n readonly readStatus?: FlowStatusRead;\n readonly maxAgeMs?: number;\n /** Defaults to IndexedDB, so a pending write survives a reload. */\n readonly storage?: PendingFlowStorage;\n readonly children: ReactNode;\n}\n\n/**\n * Waits on every write this browser handed to a flow, and tells the operator\n * once when one fails\n * ([ADR 0022](../../../../../../docs/adr/0022-two-settle-modes-and-the-pending-flow-store.md)).\n *\n * It holds the pending-flow store the generated CRUD records into, persisted\n * per principal, and settles each flow from its push or from a status read\n * after a reconnect. A failed flow is shown through the host's\n * `ToastRegion`, translated, exactly once — however many tabs or\n * redeliveries report it.\n *\n * ⚠️ **Mount it inside a `ToastProvider`, and above the plain routes**, not\n * only the workspace: a create is `/<basePath>/new` on the route host.\n */\nexport function PendingFlowsProvider({\n scope,\n channel,\n readStatus,\n maxAgeMs = PENDING_FLOW_MAX_AGE_MS,\n storage = pendingFlowStorage,\n children,\n}: PendingFlowsProviderProps) {\n const toasts = useToasts();\n\n // A store per principal: a sign-in under another scope must never read the\n // previous one's pending writes.\n const store = useMemo(\n () =>\n makePendingFlowStore({\n storage,\n key: `pending-flows:${scope}`,\n anonymous: scope === ANONYMOUS_WORKSPACE_SCOPE,\n }),\n [scope, storage],\n );\n\n usePendingFlowSettlement({\n channel,\n store,\n maxAgeMs,\n ...(readStatus === undefined ? {} : { readStatus }),\n onFailure: failure => {\n toasts?.showFailure(failure);\n },\n });\n\n if (toasts === undefined)\n throw new Error(\n 'PendingFlowsProvider must sit inside a ToastProvider: a failed flow has nowhere else to be shown',\n );\n\n return (\n <PendingFlowStoreProvider store={store}>\n {children}\n </PendingFlowStoreProvider>\n );\n}\n"],"names":["useToasts","makePendingFlowStore","PendingFlowStoreProvider","usePendingFlowSettlement","useMemo","makeIndexedDbStateStorage","ANONYMOUS_WORKSPACE_SCOPE","PENDING_FLOW_MAX_AGE_MS","pendingFlowStorage","PendingFlowsProvider","scope","channel","readStatus","maxAgeMs","storage","children","toasts","store","key","anonymous","undefined","onFailure","failure","showFailure","Error"],"mappings":"AAAA;;;AAEA,SAASA,SAAS,QAAQ,0BAA0B;AACpD,SAEEC,oBAAoB,EAEpBC,wBAAwB,EAExBC,wBAAwB,QACnB,6BAA6B;AACpC,SAAyBC,OAAO,QAAQ,QAAQ;AAEhD,SAASC,yBAAyB,QAAQ,yBAAyB;AACnE,SAASC,yBAAyB,QAAQ,uBAAuB;AAEjE;;;;;CAKC,GACD,OAAO,MAAMC,0BAA0B,KAAK,KAAK,KAAK;AAEtD,0EAA0E;AAC1E,MAAMC,qBAAqBH,0BACzB,yBACA;AA2BF;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASI,qBAAqB,EACnCC,KAAK,EACLC,OAAO,EACPC,UAAU,EACVC,WAAWN,uBAAuB,EAClCO,UAAUN,kBAAkB,EAC5BO,QAAQ,EACkB;IAC1B,MAAMC,SAAShB;IAEf,2EAA2E;IAC3E,iCAAiC;IACjC,MAAMiB,QAAQb,QACZ,IACEH,qBAAqB;YACnBa;YACAI,KAAK,CAAC,cAAc,EAAER,OAAO;YAC7BS,WAAWT,UAAUJ;QACvB,IACF;QAACI;QAAOI;KAAQ;IAGlBX,yBAAyB;QACvBQ;QACAM;QACAJ;OACID,eAAeQ,YAAY,CAAC,IAAI;QAAER;IAAW;QACjDS,WAAWC,CAAAA;YACTN,0BAAAA,OAAQO,WAAW,CAACD;QACtB;;IAGF,IAAIN,WAAWI,WACb,MAAM,IAAII,MACR;IAGJ,qBACE,KAACtB;QAAyBe,OAAOA;kBAC9BF;;AAGP"}
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
"version": "0.
|
|
24
|
+
"version": "0.15.0",
|
|
25
25
|
"description": "Next.js application shell: back-office chrome, workspace tabs, CRUD screens derived from entity metadata, and session and proxy routes.",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"repository": {
|
|
@@ -51,23 +51,23 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@tanstack/react-query": "^5.105.1",
|
|
54
|
-
"effect": "4.0.
|
|
54
|
+
"effect": "4.0.7",
|
|
55
55
|
"i18next": "26.6.0",
|
|
56
56
|
"next": "16.4.3",
|
|
57
57
|
"react": "19.3.1",
|
|
58
58
|
"react-dom": "19.3.1",
|
|
59
59
|
"zustand": "^5.0.16",
|
|
60
|
-
"@entifix/testing-unit": "0.
|
|
60
|
+
"@entifix/testing-unit": "0.15.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"idb": "^8.0.4",
|
|
64
|
-
"@entifix/authz": "0.
|
|
65
|
-
"@entifix/business": "0.
|
|
66
|
-
"@entifix/core": "0.
|
|
67
|
-
"@entifix/react-controls": "0.
|
|
68
|
-
"@entifix/i18n": "0.
|
|
69
|
-
"@entifix/react-integration": "0.
|
|
70
|
-
"@entifix/transactions": "0.
|
|
64
|
+
"@entifix/authz": "0.15.0",
|
|
65
|
+
"@entifix/business": "0.15.0",
|
|
66
|
+
"@entifix/core": "0.15.0",
|
|
67
|
+
"@entifix/react-controls": "0.15.0",
|
|
68
|
+
"@entifix/i18n": "0.15.0",
|
|
69
|
+
"@entifix/react-integration": "0.15.0",
|
|
70
|
+
"@entifix/transactions": "0.15.0"
|
|
71
71
|
},
|
|
72
72
|
"files": [
|
|
73
73
|
"dist",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
],
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@tanstack/react-query": ">=5.101 <6",
|
|
79
|
-
"effect": "^4.0.
|
|
79
|
+
"effect": "^4.0.7",
|
|
80
80
|
"i18next": ">=26 <27",
|
|
81
81
|
"next": ">=16 <17",
|
|
82
82
|
"react": ">=19 <20",
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { PendingTransactionStore } from '@entifix/transactions';
|
|
2
|
-
export interface HandOffWriteOptions {
|
|
3
|
-
/** The saved record's id — the transaction id, for a tracked create. */
|
|
4
|
-
readonly id: string;
|
|
5
|
-
/** The record as the browser built it, shown until the service confirms. */
|
|
6
|
-
readonly record: unknown;
|
|
7
|
-
readonly pending: PendingTransactionStore;
|
|
8
|
-
/** The draft the write was composed in, if it had one. */
|
|
9
|
-
readonly draft?: {
|
|
10
|
-
clear(): void;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* What happens to a draft once its write has been handed over.
|
|
15
|
-
*
|
|
16
|
-
* A transactional create resolves at the `202`, **before** the write is
|
|
17
|
-
* durable, so the save adapter has already announced it and the id is in the
|
|
18
|
-
* pending set.
|
|
19
|
-
* Handing the record over *is* the question: the returned entity is otherwise
|
|
20
|
-
* indistinguishable from a plain REST create, and asking `entries.some(...)`
|
|
21
|
-
* beforehand would read a set captured before the `await` that announced it.
|
|
22
|
-
*
|
|
23
|
-
* ⚠️ A **still-pending write keeps its draft**. The write has not committed, and
|
|
24
|
-
* a failure minutes from now would otherwise have destroyed the operator's only
|
|
25
|
-
* copy of what they typed. Only a plain, committed write spends it.
|
|
26
|
-
*
|
|
27
|
-
* It lives here rather than inside `makeEntityCrud` because it is not the
|
|
28
|
-
* generator's rule — it is the rule for every screen that writes. A wizard's
|
|
29
|
-
* Finalizar performs the same three steps, and a second copy of them is where
|
|
30
|
-
* one of the two would eventually stop keeping the draft.
|
|
31
|
-
*
|
|
32
|
-
* @returns whether the write is still in flight.
|
|
33
|
-
*/
|
|
34
|
-
export declare function handOffWrite({ id, record, pending, draft, }: HandOffWriteOptions): boolean;
|
|
35
|
-
//# sourceMappingURL=hand-off-write.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hand-off-write.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/hand-off-write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAC1C,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,KAAK,IAAI,IAAI,CAAA;KAAE,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,EAAE,EACF,MAAM,EACN,OAAO,EACP,KAAK,GACN,EAAE,mBAAmB,GAAG,OAAO,CAK/B"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What happens to a draft once its write has been handed over.
|
|
3
|
-
*
|
|
4
|
-
* A transactional create resolves at the `202`, **before** the write is
|
|
5
|
-
* durable, so the save adapter has already announced it and the id is in the
|
|
6
|
-
* pending set.
|
|
7
|
-
* Handing the record over *is* the question: the returned entity is otherwise
|
|
8
|
-
* indistinguishable from a plain REST create, and asking `entries.some(...)`
|
|
9
|
-
* beforehand would read a set captured before the `await` that announced it.
|
|
10
|
-
*
|
|
11
|
-
* ⚠️ A **still-pending write keeps its draft**. The write has not committed, and
|
|
12
|
-
* a failure minutes from now would otherwise have destroyed the operator's only
|
|
13
|
-
* copy of what they typed. Only a plain, committed write spends it.
|
|
14
|
-
*
|
|
15
|
-
* It lives here rather than inside `makeEntityCrud` because it is not the
|
|
16
|
-
* generator's rule — it is the rule for every screen that writes. A wizard's
|
|
17
|
-
* Finalizar performs the same three steps, and a second copy of them is where
|
|
18
|
-
* one of the two would eventually stop keeping the draft.
|
|
19
|
-
*
|
|
20
|
-
* @returns whether the write is still in flight.
|
|
21
|
-
*/ export function handOffWrite({ id, record, pending, draft }) {
|
|
22
|
-
if (pending.attach(id, record)) return true;
|
|
23
|
-
draft == null ? void 0 : draft.clear();
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=hand-off-write.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/crud/hand-off-write.ts"],"sourcesContent":["import type { PendingTransactionStore } from '@entifix/transactions';\n\nexport interface HandOffWriteOptions {\n /** The saved record's id — the transaction id, for a tracked create. */\n readonly id: string;\n /** The record as the browser built it, shown until the service confirms. */\n readonly record: unknown;\n readonly pending: PendingTransactionStore;\n /** The draft the write was composed in, if it had one. */\n readonly draft?: { clear(): void };\n}\n\n/**\n * What happens to a draft once its write has been handed over.\n *\n * A transactional create resolves at the `202`, **before** the write is\n * durable, so the save adapter has already announced it and the id is in the\n * pending set.\n * Handing the record over *is* the question: the returned entity is otherwise\n * indistinguishable from a plain REST create, and asking `entries.some(...)`\n * beforehand would read a set captured before the `await` that announced it.\n *\n * ⚠️ A **still-pending write keeps its draft**. The write has not committed, and\n * a failure minutes from now would otherwise have destroyed the operator's only\n * copy of what they typed. Only a plain, committed write spends it.\n *\n * It lives here rather than inside `makeEntityCrud` because it is not the\n * generator's rule — it is the rule for every screen that writes. A wizard's\n * Finalizar performs the same three steps, and a second copy of them is where\n * one of the two would eventually stop keeping the draft.\n *\n * @returns whether the write is still in flight.\n */\nexport function handOffWrite({\n id,\n record,\n pending,\n draft,\n}: HandOffWriteOptions): boolean {\n if (pending.attach(id, record)) return true;\n\n draft?.clear();\n return false;\n}\n"],"names":["handOffWrite","id","record","pending","draft","attach","clear"],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASA,aAAa,EAC3BC,EAAE,EACFC,MAAM,EACNC,OAAO,EACPC,KAAK,EACe;IACpB,IAAID,QAAQE,MAAM,CAACJ,IAAIC,SAAS,OAAO;IAEvCE,yBAAAA,MAAOE,KAAK;IACZ,OAAO;AACT"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { PendingEntry } from '@entifix/transactions';
|
|
2
|
-
export interface PendingNoticeProps {
|
|
3
|
-
/** This entity's in-flight and failed writes, newest last. */
|
|
4
|
-
entries: readonly PendingEntry[];
|
|
5
|
-
/** Retires a failure the operator has read. */
|
|
6
|
-
onDismiss: (transactionId: string) => void;
|
|
7
|
-
className?: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* What became of the writes this browser started but the server has not
|
|
11
|
-
* finished.
|
|
12
|
-
*
|
|
13
|
-
* ⚠️ **This is the list's surface because the tab strip cannot be.** Only
|
|
14
|
-
* creates are transactional (`create: 'command'` fires on `isCreate` alone), and
|
|
15
|
-
* a create has no workspace tab — `EntityEditorTab` takes a required id, so
|
|
16
|
-
* `master:<key>` is the list and there is no address for a record that does not
|
|
17
|
-
* exist yet. A badge keyed on a pending record id would therefore be unreachable
|
|
18
|
-
* by construction, which is exactly the "declared, styled, never produced"
|
|
19
|
-
* defect the optimistic mutation contract exists to prevent. It renders here instead, where
|
|
20
|
-
* `afterSave()` actually puts the operator.
|
|
21
|
-
*
|
|
22
|
-
* `role="status"`, not `role="alert"` — the `BulkResult` reasoning: an outcome
|
|
23
|
-
* to read, not an interruption.
|
|
24
|
-
*
|
|
25
|
-
* The failure headline is a catalog key and never `entry.reason`, which is free
|
|
26
|
-
* text from whatever threw, in whatever language that code was written in. The
|
|
27
|
-
* reason is kept as secondary, explicitly-unlocalized detail; a translatable
|
|
28
|
-
* failure needs an error *code* on the event, which the event does not carry yet.
|
|
29
|
-
*/
|
|
30
|
-
export declare function PendingNotice({ entries, onDismiss, className, }: PendingNoticeProps): import("react").JSX.Element | null;
|
|
31
|
-
//# sourceMappingURL=pending-notice.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pending-notice.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/pending-notice.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IACjC,+CAA+C;IAC/C,SAAS,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,SAAS,EACT,SAAS,GACV,EAAE,kBAAkB,sCA0DpB"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button, cn, useT } from '@entifix/react-controls/primitives';
|
|
4
|
-
/**
|
|
5
|
-
* What became of the writes this browser started but the server has not
|
|
6
|
-
* finished.
|
|
7
|
-
*
|
|
8
|
-
* ⚠️ **This is the list's surface because the tab strip cannot be.** Only
|
|
9
|
-
* creates are transactional (`create: 'command'` fires on `isCreate` alone), and
|
|
10
|
-
* a create has no workspace tab — `EntityEditorTab` takes a required id, so
|
|
11
|
-
* `master:<key>` is the list and there is no address for a record that does not
|
|
12
|
-
* exist yet. A badge keyed on a pending record id would therefore be unreachable
|
|
13
|
-
* by construction, which is exactly the "declared, styled, never produced"
|
|
14
|
-
* defect the optimistic mutation contract exists to prevent. It renders here instead, where
|
|
15
|
-
* `afterSave()` actually puts the operator.
|
|
16
|
-
*
|
|
17
|
-
* `role="status"`, not `role="alert"` — the `BulkResult` reasoning: an outcome
|
|
18
|
-
* to read, not an interruption.
|
|
19
|
-
*
|
|
20
|
-
* The failure headline is a catalog key and never `entry.reason`, which is free
|
|
21
|
-
* text from whatever threw, in whatever language that code was written in. The
|
|
22
|
-
* reason is kept as secondary, explicitly-unlocalized detail; a translatable
|
|
23
|
-
* failure needs an error *code* on the event, which the event does not carry yet.
|
|
24
|
-
*/ export function PendingNotice({ entries, onDismiss, className }) {
|
|
25
|
-
// The `shell` namespace: this copy lives in `shell.ts`, and `useT()` with no
|
|
26
|
-
// argument reads `controls` — which resolves nothing and renders the key.
|
|
27
|
-
const t = useT('shell');
|
|
28
|
-
const saving = entries.filter((entry)=>entry.state === 'pending');
|
|
29
|
-
const failed = entries.filter((entry)=>entry.state === 'failed');
|
|
30
|
-
if (saving.length === 0 && failed.length === 0) return null;
|
|
31
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
32
|
-
role: "status",
|
|
33
|
-
"aria-label": t('workspace.pendingLabel'),
|
|
34
|
-
"data-testid": "pending-notice",
|
|
35
|
-
className: cn('flex flex-col gap-2xs rounded-lg border border-border bg-surface-elevated px-s py-2xs', className),
|
|
36
|
-
children: [
|
|
37
|
-
saving.length > 0 && /*#__PURE__*/ _jsx("span", {
|
|
38
|
-
className: "text-step-sm text-content-muted",
|
|
39
|
-
children: t('workspace.savePending', {
|
|
40
|
-
count: saving.length
|
|
41
|
-
})
|
|
42
|
-
}),
|
|
43
|
-
failed.map((entry)=>/*#__PURE__*/ _jsxs("div", {
|
|
44
|
-
className: "flex flex-wrap items-center gap-2xs",
|
|
45
|
-
children: [
|
|
46
|
-
/*#__PURE__*/ _jsx("span", {
|
|
47
|
-
className: "text-step-sm text-danger",
|
|
48
|
-
children: t('workspace.saveFailed')
|
|
49
|
-
}),
|
|
50
|
-
entry.reason !== undefined && // Untranslated on purpose, and marked as such: it is a server
|
|
51
|
-
// exception string, shown because a reason nobody can read is worse
|
|
52
|
-
// than one in the wrong language.
|
|
53
|
-
/*#__PURE__*/ _jsx("span", {
|
|
54
|
-
lang: "und",
|
|
55
|
-
className: "text-step-sm text-content-muted",
|
|
56
|
-
"data-testid": "pending-notice-reason",
|
|
57
|
-
children: entry.reason
|
|
58
|
-
}),
|
|
59
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
60
|
-
type: "button",
|
|
61
|
-
variant: "ghost",
|
|
62
|
-
size: "sm",
|
|
63
|
-
onClick: ()=>onDismiss(entry.transactionId),
|
|
64
|
-
children: t('workspace.saveFailedDismiss')
|
|
65
|
-
})
|
|
66
|
-
]
|
|
67
|
-
}, entry.transactionId))
|
|
68
|
-
]
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
//# sourceMappingURL=pending-notice.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/crud/pending-notice.tsx"],"sourcesContent":["'use client';\n\nimport { Button, cn, useT } from '@entifix/react-controls/primitives';\nimport type { PendingEntry } from '@entifix/transactions';\n\nexport interface PendingNoticeProps {\n /** This entity's in-flight and failed writes, newest last. */\n entries: readonly PendingEntry[];\n /** Retires a failure the operator has read. */\n onDismiss: (transactionId: string) => void;\n className?: string;\n}\n\n/**\n * What became of the writes this browser started but the server has not\n * finished.\n *\n * ⚠️ **This is the list's surface because the tab strip cannot be.** Only\n * creates are transactional (`create: 'command'` fires on `isCreate` alone), and\n * a create has no workspace tab — `EntityEditorTab` takes a required id, so\n * `master:<key>` is the list and there is no address for a record that does not\n * exist yet. A badge keyed on a pending record id would therefore be unreachable\n * by construction, which is exactly the \"declared, styled, never produced\"\n * defect the optimistic mutation contract exists to prevent. It renders here instead, where\n * `afterSave()` actually puts the operator.\n *\n * `role=\"status\"`, not `role=\"alert\"` — the `BulkResult` reasoning: an outcome\n * to read, not an interruption.\n *\n * The failure headline is a catalog key and never `entry.reason`, which is free\n * text from whatever threw, in whatever language that code was written in. The\n * reason is kept as secondary, explicitly-unlocalized detail; a translatable\n * failure needs an error *code* on the event, which the event does not carry yet.\n */\nexport function PendingNotice({\n entries,\n onDismiss,\n className,\n}: PendingNoticeProps) {\n // The `shell` namespace: this copy lives in `shell.ts`, and `useT()` with no\n // argument reads `controls` — which resolves nothing and renders the key.\n const t = useT('shell');\n\n const saving = entries.filter(entry => entry.state === 'pending');\n const failed = entries.filter(entry => entry.state === 'failed');\n\n if (saving.length === 0 && failed.length === 0) return null;\n\n return (\n <div\n role=\"status\"\n aria-label={t('workspace.pendingLabel')}\n data-testid=\"pending-notice\"\n className={cn(\n 'flex flex-col gap-2xs rounded-lg border border-border bg-surface-elevated px-s py-2xs',\n className,\n )}\n >\n {saving.length > 0 && (\n <span className=\"text-step-sm text-content-muted\">\n {t('workspace.savePending', { count: saving.length })}\n </span>\n )}\n\n {failed.map(entry => (\n <div\n key={entry.transactionId}\n className=\"flex flex-wrap items-center gap-2xs\"\n >\n <span className=\"text-step-sm text-danger\">\n {t('workspace.saveFailed')}\n </span>\n {entry.reason !== undefined && (\n // Untranslated on purpose, and marked as such: it is a server\n // exception string, shown because a reason nobody can read is worse\n // than one in the wrong language.\n <span\n lang=\"und\"\n className=\"text-step-sm text-content-muted\"\n data-testid=\"pending-notice-reason\"\n >\n {entry.reason}\n </span>\n )}\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => onDismiss(entry.transactionId)}\n >\n {t('workspace.saveFailedDismiss')}\n </Button>\n </div>\n ))}\n </div>\n );\n}\n"],"names":["Button","cn","useT","PendingNotice","entries","onDismiss","className","t","saving","filter","entry","state","failed","length","div","role","aria-label","data-testid","span","count","map","reason","undefined","lang","type","variant","size","onClick","transactionId"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,EAAE,EAAEC,IAAI,QAAQ,qCAAqC;AAWtE;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASC,cAAc,EAC5BC,OAAO,EACPC,SAAS,EACTC,SAAS,EACU;IACnB,6EAA6E;IAC7E,0EAA0E;IAC1E,MAAMC,IAAIL,KAAK;IAEf,MAAMM,SAASJ,QAAQK,MAAM,CAACC,CAAAA,QAASA,MAAMC,KAAK,KAAK;IACvD,MAAMC,SAASR,QAAQK,MAAM,CAACC,CAAAA,QAASA,MAAMC,KAAK,KAAK;IAEvD,IAAIH,OAAOK,MAAM,KAAK,KAAKD,OAAOC,MAAM,KAAK,GAAG,OAAO;IAEvD,qBACE,MAACC;QACCC,MAAK;QACLC,cAAYT,EAAE;QACdU,eAAY;QACZX,WAAWL,GACT,yFACAK;;YAGDE,OAAOK,MAAM,GAAG,mBACf,KAACK;gBAAKZ,WAAU;0BACbC,EAAE,yBAAyB;oBAAEY,OAAOX,OAAOK,MAAM;gBAAC;;YAItDD,OAAOQ,GAAG,CAACV,CAAAA,sBACV,MAACI;oBAECR,WAAU;;sCAEV,KAACY;4BAAKZ,WAAU;sCACbC,EAAE;;wBAEJG,MAAMW,MAAM,KAAKC,aAChB,8DAA8D;wBAC9D,oEAAoE;wBACpE,kCAAkC;sCAClC,KAACJ;4BACCK,MAAK;4BACLjB,WAAU;4BACVW,eAAY;sCAEXP,MAAMW,MAAM;;sCAGjB,KAACrB;4BACCwB,MAAK;4BACLC,SAAQ;4BACRC,MAAK;4BACLC,SAAS,IAAMtB,UAAUK,MAAMkB,aAAa;sCAE3CrB,EAAE;;;mBAxBAG,MAAMkB,aAAa;;;AA8BlC"}
|