@entifix/react-integration 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/event-source.d.ts +5 -4
- package/dist/event-source.d.ts.map +1 -1
- package/dist/event-source.js +5 -4
- package/dist/event-source.js.map +1 -1
- package/dist/hooks/use-data-loading/use-data-loading.d.ts +2 -2
- package/dist/hooks/use-data-loading/use-data-loading.d.ts.map +1 -1
- package/dist/hooks/use-data-loading/use-data-loading.js.map +1 -1
- package/dist/hooks/use-data-loading/use-data-loading.types.d.ts +3 -3
- package/dist/hooks/use-data-loading/use-data-loading.types.d.ts.map +1 -1
- package/dist/hooks/use-data-loading/use-data-loading.types.js.map +1 -1
- package/dist/hooks/use-entity-link-source/use-entity-link-source.d.ts.map +1 -1
- package/dist/hooks/use-entity-link-source/use-entity-link-source.js.map +1 -1
- package/dist/hooks/use-entity-link-source/use-entity-link-source.types.d.ts +3 -3
- package/dist/hooks/use-entity-link-source/use-entity-link-source.types.d.ts.map +1 -1
- package/dist/hooks/use-entity-link-source/use-entity-link-source.types.js.map +1 -1
- package/dist/hooks/use-entity-mutation/use-entity-mutation.d.ts +2 -2
- package/dist/hooks/use-entity-mutation/use-entity-mutation.d.ts.map +1 -1
- package/dist/hooks/use-entity-mutation/use-entity-mutation.js.map +1 -1
- package/dist/hooks/use-entity-mutation/use-entity-mutation.types.d.ts +4 -4
- package/dist/hooks/use-entity-mutation/use-entity-mutation.types.d.ts.map +1 -1
- package/dist/hooks/use-entity-mutation/use-entity-mutation.types.js.map +1 -1
- package/dist/hooks/use-entity-record/use-entity-record.d.ts +2 -2
- package/dist/hooks/use-entity-record/use-entity-record.d.ts.map +1 -1
- package/dist/hooks/use-entity-record/use-entity-record.js.map +1 -1
- package/dist/hooks/use-entity-record/use-entity-record.types.d.ts +3 -3
- package/dist/hooks/use-entity-record/use-entity-record.types.d.ts.map +1 -1
- package/dist/hooks/use-entity-record/use-entity-record.types.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/pending/pending-flow-store.d.ts +86 -0
- package/dist/pending/pending-flow-store.d.ts.map +1 -0
- package/dist/pending/pending-flow-store.js +124 -0
- package/dist/pending/pending-flow-store.js.map +1 -0
- package/dist/pending/use-optimistic-mutation.d.ts +61 -0
- package/dist/pending/use-optimistic-mutation.d.ts.map +1 -0
- package/dist/pending/use-optimistic-mutation.js +88 -0
- package/dist/pending/use-optimistic-mutation.js.map +1 -0
- package/dist/pending/use-pending-flow-settlement.d.ts +43 -0
- package/dist/pending/use-pending-flow-settlement.d.ts.map +1 -0
- package/dist/pending/use-pending-flow-settlement.js +126 -0
- package/dist/pending/use-pending-flow-settlement.js.map +1 -0
- package/dist/reactive/event-source-push-channel.d.ts +56 -0
- package/dist/reactive/event-source-push-channel.d.ts.map +1 -0
- package/dist/reactive/event-source-push-channel.js +118 -0
- package/dist/reactive/event-source-push-channel.js.map +1 -0
- package/dist/reactive/push-channel.d.ts +69 -0
- package/dist/reactive/push-channel.d.ts.map +1 -0
- package/dist/reactive/push-channel.js +33 -0
- package/dist/reactive/push-channel.js.map +1 -0
- package/dist/reactive/push-router.d.ts +26 -0
- package/dist/reactive/push-router.d.ts.map +1 -0
- package/dist/reactive/push-router.js +64 -0
- package/dist/reactive/push-router.js.map +1 -0
- package/dist/reactive/use-reactive-cache.d.ts +49 -0
- package/dist/reactive/use-reactive-cache.d.ts.map +1 -0
- package/dist/reactive/use-reactive-cache.js +106 -0
- package/dist/reactive/use-reactive-cache.js.map +1 -0
- package/package.json +7 -7
- package/dist/reactive/use-transaction-settlement.d.ts +0 -57
- package/dist/reactive/use-transaction-settlement.d.ts.map +0 -1
- package/dist/reactive/use-transaction-settlement.js +0 -137
- package/dist/reactive/use-transaction-settlement.js.map +0 -1
package/dist/event-source.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The browser
|
|
3
|
-
* same-origin URL.
|
|
2
|
+
* The browser transports behind `PushChannelTag` and `ReactiveChannelTag`:
|
|
3
|
+
* `EventSource` over a same-origin URL.
|
|
4
4
|
*
|
|
5
5
|
* Its own entry point because choosing the transport and using the port are
|
|
6
|
-
* different acts. A component that reacts to
|
|
7
|
-
* `
|
|
6
|
+
* different acts. A component that reacts to pushed events reads
|
|
7
|
+
* `PushChannelTag` from `.`; only the composition root that picks SSE
|
|
8
8
|
* imports this (ADR 0006).
|
|
9
9
|
*/
|
|
10
10
|
export * from './reactive/event-source-channel.js';
|
|
11
|
+
export * from './reactive/event-source-push-channel.js';
|
|
11
12
|
//# sourceMappingURL=event-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-source.d.ts","sourceRoot":"","sources":["../src/event-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"event-source.d.ts","sourceRoot":"","sources":["../src/event-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC"}
|
package/dist/event-source.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The browser
|
|
3
|
-
* same-origin URL.
|
|
2
|
+
* The browser transports behind `PushChannelTag` and `ReactiveChannelTag`:
|
|
3
|
+
* `EventSource` over a same-origin URL.
|
|
4
4
|
*
|
|
5
5
|
* Its own entry point because choosing the transport and using the port are
|
|
6
|
-
* different acts. A component that reacts to
|
|
7
|
-
* `
|
|
6
|
+
* different acts. A component that reacts to pushed events reads
|
|
7
|
+
* `PushChannelTag` from `.`; only the composition root that picks SSE
|
|
8
8
|
* imports this (ADR 0006).
|
|
9
9
|
*/ export * from './reactive/event-source-channel.js';
|
|
10
|
+
export * from './reactive/event-source-push-channel.js';
|
|
10
11
|
|
|
11
12
|
//# sourceMappingURL=event-source.js.map
|
package/dist/event-source.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/event-source.ts"],"sourcesContent":["/**\n * The browser
|
|
1
|
+
{"version":3,"sources":["../src/event-source.ts"],"sourcesContent":["/**\n * The browser transports behind `PushChannelTag` and `ReactiveChannelTag`:\n * `EventSource` over a same-origin URL.\n *\n * Its own entry point because choosing the transport and using the port are\n * different acts. A component that reacts to pushed events reads\n * `PushChannelTag` from `.`; only the composition root that picks SSE\n * imports this (ADR 0006).\n */\nexport * from './reactive/event-source-channel.js';\nexport * from './reactive/event-source-push-channel.js';\n"],"names":[],"mappings":"AAAA;;;;;;;;CAQC,GACD,cAAc,qCAAqC;AACnD,cAAc,0CAA0C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EntifixFailure, type Entity, type EntitySorting, type FilterGroup } from '@entifix/core';
|
|
2
2
|
import type { UseDataLoadingOptions } from './use-data-loading.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Runs an entity list use-case and caches the result through TanStack Query.
|
|
@@ -15,7 +15,7 @@ export declare function useDataLoading<TEntity extends Entity, TContext>({ uc, c
|
|
|
15
15
|
totalItems: number;
|
|
16
16
|
currentPage: number;
|
|
17
17
|
pageSize: number;
|
|
18
|
-
error:
|
|
18
|
+
error: EntifixFailure<string, string, import("@entifix/core").FailureCategory> | undefined;
|
|
19
19
|
filtering: FilterGroup<TEntity> | undefined;
|
|
20
20
|
sorting: EntitySorting<TEntity> | undefined;
|
|
21
21
|
onPageChange: (newPage: number) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-data-loading.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-data-loading/use-data-loading.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,MAAM,EAGX,KAAK,aAAa,EAClB,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"use-data-loading.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-data-loading/use-data-loading.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,MAAM,EAGX,KAAK,aAAa,EAClB,KAAK,WAAW,EAGjB,MAAM,eAAe,CAAC;AAavB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAiCzE;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,MAAM,EAAE,QAAQ,EAAE,EAC/D,EAAE,EACF,GAAG,EACH,eAAmC,EACnC,QAAQ,EACR,OAAc,EACd,aAAa,GACd,EAAE,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC;;;;;;;;;4BA0GE,MAAM;oCAIE,MAAM;mCAMP,WAAW,CAAC,OAAO,CAAC;+BAIxB,aAAa,CAAC,OAAO,CAAC;EAkBrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-data-loading/use-data-loading.ts"],"sourcesContent":["import { EntityLoadRequestTag } from '@entifix/business';\nimport {\n type Entity,\n type EntityLoadRequest,\n type EntityPage,\n type EntitySorting,\n type FilterGroup,\n serializeRsql,\n serializeSort,\n type TransitionalFailure,\n} from '@entifix/core';\nimport { keepPreviousData, useQuery } from '@tanstack/react-query';\nimport { Context, Effect } from 'effect';\nimport {\n useCallback,\n useEffect,\n useId,\n useMemo,\n useReducer,\n useRef,\n} from 'react';\n\nimport { combineFilterGroups } from '../../query/combine-filtering.js';\nimport type { UseDataLoadingOptions } from './use-data-loading.types.js';\n\nconst DEFAULT_PAGE_SIZE = 10;\n\n/**\n * The request the caller controls — page, size, and the *applied* filter/sort.\n * The response (items, loading, error) is owned by the query cache, not here.\n */\ninterface RequestState<T extends Entity> {\n currentPage: number;\n pageSize: number;\n filtering: FilterGroup<T> | undefined;\n sorting: EntitySorting<T> | undefined;\n}\n\ntype RequestAction<T extends Entity> = { set: Partial<RequestState<T>> };\n\nfunction requestReducer<T extends Entity>(\n state: RequestState<T>,\n action: RequestAction<T>,\n): RequestState<T> {\n return { ...state, ...action.set };\n}\n\nfunction initialRequest<T extends Entity>(pageSize: number): RequestState<T> {\n return {\n currentPage: 1,\n pageSize,\n filtering: undefined,\n sorting: undefined,\n };\n}\n\n/**\n * Runs an entity list use-case and caches the result through TanStack Query.\n *\n * The reducer owns the *request* (page/size/filter/sort); `useQuery` owns the\n * *fetch* — deduping, caching, and (with a shared `queryKey`) letting mutations\n * and reactive events invalidate the list. The public shape is unchanged: the\n * `uc`/`ctx` come in the same way and the Effect runs against the same provided\n * Tags, so callers and organisms are untouched.\n */\nexport function useDataLoading<TEntity extends Entity, TContext>({\n uc,\n ctx,\n initialPageSize = DEFAULT_PAGE_SIZE,\n queryKey,\n enabled = true,\n baseFiltering,\n}: UseDataLoadingOptions<TEntity, TContext>) {\n const [request, dispatch] = useReducer(\n requestReducer as (\n state: RequestState<TEntity>,\n action: RequestAction<TEntity>,\n ) => RequestState<TEntity>,\n initialPageSize,\n initialRequest<TEntity>,\n );\n\n // Callers rebuild `uc`/`ctx` inline every render, so hold the latest in refs\n // and keep them out of the query key — keying on their identity would refetch\n // on every render. Written in an effect (refs may not be set during render);\n // effects fire in order, so the query below always reads the latest.\n const ucRef = useRef(uc);\n const ctxRef = useRef(ctx);\n useEffect(() => {\n ucRef.current = uc;\n ctxRef.current = ctx;\n });\n\n // What actually goes on the wire: the caller's standing restriction ANDed with\n // whatever the user applied. Kept separate from `request.filtering` because the\n // restriction is not the user's filter — the panel must keep showing only what\n // they set, while the request keeps carrying both.\n const effectiveFiltering = useMemo(\n () => combineFilterGroups<TEntity>(baseFiltering, request.filtering),\n [baseFiltering, request.filtering],\n );\n\n // The applied filter/sort are rebuilt each render, so their *serialized* form\n // — the same codec the request needs anyway — is what keys the query: a stable\n // string that changes exactly when the query does.\n const rsql = useMemo(\n () => serializeRsql(effectiveFiltering ? [effectiveFiltering] : undefined),\n [effectiveFiltering],\n );\n const sort = useMemo(\n () => serializeSort(request.sorting ? [request.sorting] : undefined),\n [request.sorting],\n );\n\n const loadRequest = useMemo<EntityLoadRequest<TEntity>>(() => {\n const built: EntityLoadRequest<TEntity> = {\n page: request.currentPage,\n pageSize: request.pageSize,\n };\n // An empty group serializes to nothing; omit it rather than send a filter\n // that matches everything.\n if (rsql !== '' && effectiveFiltering) {\n built.filtering = [effectiveFiltering];\n }\n if (sort !== '' && request.sorting) {\n built.sorting = [request.sorting];\n }\n return built;\n }, [\n request.currentPage,\n request.pageSize,\n effectiveFiltering,\n request.sorting,\n rsql,\n sort,\n ]);\n\n // Falls back to a per-instance id so an un-scoped list never collides with\n // another in the shared cache — correct, just unshared (see the type doc).\n const instanceId = useId();\n const scope = queryKey ?? [instanceId];\n\n const query = useQuery<EntityPage<TEntity>, TransitionalFailure>({\n enabled,\n /**\n * Page, size, filter and sort are all part of the key, so every one of them\n * is a *different* query — and without this, `data` goes undefined the\n * instant any of them changes. The table would then see `items.length === 0`\n * with `isFetching` true, read it as a first load, and blank populated rows\n * to skeleton on every pagination click: the grey flash the loading contract\n * exists to prevent. Keeping the previous page is what makes \"skeleton only\n * on first load\" true rather than merely intended.\n */\n placeholderData: keepPreviousData,\n queryKey: [\n ...scope,\n 'load',\n request.currentPage,\n request.pageSize,\n rsql,\n sort,\n ],\n queryFn: () =>\n Effect.runPromise(\n Effect.provide(\n ucRef.current,\n ctxRef.current.pipe(\n Context.add(\n EntityLoadRequestTag,\n // The tag carries no generic, so the entity-typed request crosses\n // it — the same cast `loadUCFactory` makes reading it back.\n loadRequest as unknown as EntityLoadRequest,\n ),\n ),\n ),\n ),\n });\n\n const onPageChange = useCallback((newPage: number) => {\n dispatch({ set: { currentPage: newPage } });\n }, []);\n\n const onPageSizeChange = useCallback((newPageSize: number) => {\n dispatch({ set: { pageSize: newPageSize, currentPage: 1 } });\n }, []);\n\n // Narrowing the result set invalidates the page number: page 4 of the old\n // result is very likely past the end of the new one.\n const onFilteringChange = useCallback((filtering: FilterGroup<TEntity>) => {\n dispatch({ set: { filtering, currentPage: 1 } });\n }, []);\n\n const onSortingChange = useCallback((sorting: EntitySorting<TEntity>) => {\n dispatch({ set: { sorting, currentPage: 1 } });\n }, []);\n\n return {\n isLoading: query.isFetching,\n items: query.data?.items ?? ([] as Array<TEntity>),\n totalItems: query.data?.total ?? 0,\n currentPage: request.currentPage,\n pageSize: request.pageSize,\n error: query.error ?? undefined,\n filtering: request.filtering,\n sorting: request.sorting,\n onPageChange,\n onPageSizeChange,\n onFilteringChange,\n onSortingChange,\n };\n}\n"],"names":["EntityLoadRequestTag","serializeRsql","serializeSort","keepPreviousData","useQuery","Context","Effect","useCallback","useEffect","useId","useMemo","useReducer","useRef","combineFilterGroups","DEFAULT_PAGE_SIZE","requestReducer","state","action","set","initialRequest","pageSize","currentPage","filtering","undefined","sorting","useDataLoading","uc","ctx","initialPageSize","queryKey","enabled","baseFiltering","query","request","dispatch","ucRef","ctxRef","current","effectiveFiltering","rsql","sort","loadRequest","built","page","instanceId","scope","placeholderData","queryFn","runPromise","provide","pipe","add","onPageChange","newPage","onPageSizeChange","newPageSize","onFilteringChange","onSortingChange","isLoading","isFetching","items","data","totalItems","total","error"],"mappings":";AAAA,SAASA,oBAAoB,QAAQ,oBAAoB;AACzD,SAMEC,aAAa,EACbC,aAAa,QAER,gBAAgB;AACvB,SAASC,gBAAgB,EAAEC,QAAQ,QAAQ,wBAAwB;AACnE,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AACzC,SACEC,WAAW,EACXC,SAAS,EACTC,KAAK,EACLC,OAAO,EACPC,UAAU,EACVC,MAAM,QACD,QAAQ;AAEf,SAASC,mBAAmB,QAAQ,mCAAmC;AAGvE,MAAMC,oBAAoB;AAe1B,SAASC,eACPC,KAAsB,EACtBC,MAAwB;IAExB,OAAO,aAAKD,OAAUC,OAAOC,GAAG;AAClC;AAEA,SAASC,eAAiCC,QAAgB;IACxD,OAAO;QACLC,aAAa;QACbD;QACAE,WAAWC;QACXC,SAASD;IACX;AACF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BAAI;QACjC1C,aAAaY,QAAQZ,WAAW;QAChCD,UAAUa,QAAQb,QAAQ;QAC1B4C,KAAK,GAAEhC,eAAAA,MAAMgC,KAAK,YAAXhC,eAAeT;QACtBD,WAAWW,QAAQX,SAAS;QAC5BE,SAASS,QAAQT,OAAO;QACxB4B;QACAE;QACAE;QACAC;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-data-loading/use-data-loading.ts"],"sourcesContent":["import { EntityLoadRequestTag } from '@entifix/business';\nimport {\n type EntifixFailure,\n type Entity,\n type EntityLoadRequest,\n type EntityPage,\n type EntitySorting,\n type FilterGroup,\n serializeRsql,\n serializeSort,\n} from '@entifix/core';\nimport { keepPreviousData, useQuery } from '@tanstack/react-query';\nimport { Context, Effect } from 'effect';\nimport {\n useCallback,\n useEffect,\n useId,\n useMemo,\n useReducer,\n useRef,\n} from 'react';\n\nimport { combineFilterGroups } from '../../query/combine-filtering.js';\nimport type { UseDataLoadingOptions } from './use-data-loading.types.js';\n\nconst DEFAULT_PAGE_SIZE = 10;\n\n/**\n * The request the caller controls — page, size, and the *applied* filter/sort.\n * The response (items, loading, error) is owned by the query cache, not here.\n */\ninterface RequestState<T extends Entity> {\n currentPage: number;\n pageSize: number;\n filtering: FilterGroup<T> | undefined;\n sorting: EntitySorting<T> | undefined;\n}\n\ntype RequestAction<T extends Entity> = { set: Partial<RequestState<T>> };\n\nfunction requestReducer<T extends Entity>(\n state: RequestState<T>,\n action: RequestAction<T>,\n): RequestState<T> {\n return { ...state, ...action.set };\n}\n\nfunction initialRequest<T extends Entity>(pageSize: number): RequestState<T> {\n return {\n currentPage: 1,\n pageSize,\n filtering: undefined,\n sorting: undefined,\n };\n}\n\n/**\n * Runs an entity list use-case and caches the result through TanStack Query.\n *\n * The reducer owns the *request* (page/size/filter/sort); `useQuery` owns the\n * *fetch* — deduping, caching, and (with a shared `queryKey`) letting mutations\n * and reactive events invalidate the list. The public shape is unchanged: the\n * `uc`/`ctx` come in the same way and the Effect runs against the same provided\n * Tags, so callers and organisms are untouched.\n */\nexport function useDataLoading<TEntity extends Entity, TContext>({\n uc,\n ctx,\n initialPageSize = DEFAULT_PAGE_SIZE,\n queryKey,\n enabled = true,\n baseFiltering,\n}: UseDataLoadingOptions<TEntity, TContext>) {\n const [request, dispatch] = useReducer(\n requestReducer as (\n state: RequestState<TEntity>,\n action: RequestAction<TEntity>,\n ) => RequestState<TEntity>,\n initialPageSize,\n initialRequest<TEntity>,\n );\n\n // Callers rebuild `uc`/`ctx` inline every render, so hold the latest in refs\n // and keep them out of the query key — keying on their identity would refetch\n // on every render. Written in an effect (refs may not be set during render);\n // effects fire in order, so the query below always reads the latest.\n const ucRef = useRef(uc);\n const ctxRef = useRef(ctx);\n useEffect(() => {\n ucRef.current = uc;\n ctxRef.current = ctx;\n });\n\n // What actually goes on the wire: the caller's standing restriction ANDed with\n // whatever the user applied. Kept separate from `request.filtering` because the\n // restriction is not the user's filter — the panel must keep showing only what\n // they set, while the request keeps carrying both.\n const effectiveFiltering = useMemo(\n () => combineFilterGroups<TEntity>(baseFiltering, request.filtering),\n [baseFiltering, request.filtering],\n );\n\n // The applied filter/sort are rebuilt each render, so their *serialized* form\n // — the same codec the request needs anyway — is what keys the query: a stable\n // string that changes exactly when the query does.\n const rsql = useMemo(\n () => serializeRsql(effectiveFiltering ? [effectiveFiltering] : undefined),\n [effectiveFiltering],\n );\n const sort = useMemo(\n () => serializeSort(request.sorting ? [request.sorting] : undefined),\n [request.sorting],\n );\n\n const loadRequest = useMemo<EntityLoadRequest<TEntity>>(() => {\n const built: EntityLoadRequest<TEntity> = {\n page: request.currentPage,\n pageSize: request.pageSize,\n };\n // An empty group serializes to nothing; omit it rather than send a filter\n // that matches everything.\n if (rsql !== '' && effectiveFiltering) {\n built.filtering = [effectiveFiltering];\n }\n if (sort !== '' && request.sorting) {\n built.sorting = [request.sorting];\n }\n return built;\n }, [\n request.currentPage,\n request.pageSize,\n effectiveFiltering,\n request.sorting,\n rsql,\n sort,\n ]);\n\n // Falls back to a per-instance id so an un-scoped list never collides with\n // another in the shared cache — correct, just unshared (see the type doc).\n const instanceId = useId();\n const scope = queryKey ?? [instanceId];\n\n const query = useQuery<EntityPage<TEntity>, EntifixFailure>({\n enabled,\n /**\n * Page, size, filter and sort are all part of the key, so every one of them\n * is a *different* query — and without this, `data` goes undefined the\n * instant any of them changes. The table would then see `items.length === 0`\n * with `isFetching` true, read it as a first load, and blank populated rows\n * to skeleton on every pagination click: the grey flash the loading contract\n * exists to prevent. Keeping the previous page is what makes \"skeleton only\n * on first load\" true rather than merely intended.\n */\n placeholderData: keepPreviousData,\n queryKey: [\n ...scope,\n 'load',\n request.currentPage,\n request.pageSize,\n rsql,\n sort,\n ],\n queryFn: () =>\n Effect.runPromise(\n Effect.provide(\n ucRef.current,\n ctxRef.current.pipe(\n Context.add(\n EntityLoadRequestTag,\n // The tag carries no generic, so the entity-typed request crosses\n // it — the same cast `loadUCFactory` makes reading it back.\n loadRequest as unknown as EntityLoadRequest,\n ),\n ),\n ),\n ),\n });\n\n const onPageChange = useCallback((newPage: number) => {\n dispatch({ set: { currentPage: newPage } });\n }, []);\n\n const onPageSizeChange = useCallback((newPageSize: number) => {\n dispatch({ set: { pageSize: newPageSize, currentPage: 1 } });\n }, []);\n\n // Narrowing the result set invalidates the page number: page 4 of the old\n // result is very likely past the end of the new one.\n const onFilteringChange = useCallback((filtering: FilterGroup<TEntity>) => {\n dispatch({ set: { filtering, currentPage: 1 } });\n }, []);\n\n const onSortingChange = useCallback((sorting: EntitySorting<TEntity>) => {\n dispatch({ set: { sorting, currentPage: 1 } });\n }, []);\n\n return {\n isLoading: query.isFetching,\n items: query.data?.items ?? ([] as Array<TEntity>),\n totalItems: query.data?.total ?? 0,\n currentPage: request.currentPage,\n pageSize: request.pageSize,\n error: query.error ?? undefined,\n filtering: request.filtering,\n sorting: request.sorting,\n onPageChange,\n onPageSizeChange,\n onFilteringChange,\n onSortingChange,\n };\n}\n"],"names":["EntityLoadRequestTag","serializeRsql","serializeSort","keepPreviousData","useQuery","Context","Effect","useCallback","useEffect","useId","useMemo","useReducer","useRef","combineFilterGroups","DEFAULT_PAGE_SIZE","requestReducer","state","action","set","initialRequest","pageSize","currentPage","filtering","undefined","sorting","useDataLoading","uc","ctx","initialPageSize","queryKey","enabled","baseFiltering","query","request","dispatch","ucRef","ctxRef","current","effectiveFiltering","rsql","sort","loadRequest","built","page","instanceId","scope","placeholderData","queryFn","runPromise","provide","pipe","add","onPageChange","newPage","onPageSizeChange","newPageSize","onFilteringChange","onSortingChange","isLoading","isFetching","items","data","totalItems","total","error"],"mappings":";AAAA,SAASA,oBAAoB,QAAQ,oBAAoB;AACzD,SAOEC,aAAa,EACbC,aAAa,QACR,gBAAgB;AACvB,SAASC,gBAAgB,EAAEC,QAAQ,QAAQ,wBAAwB;AACnE,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AACzC,SACEC,WAAW,EACXC,SAAS,EACTC,KAAK,EACLC,OAAO,EACPC,UAAU,EACVC,MAAM,QACD,QAAQ;AAEf,SAASC,mBAAmB,QAAQ,mCAAmC;AAGvE,MAAMC,oBAAoB;AAe1B,SAASC,eACPC,KAAsB,EACtBC,MAAwB;IAExB,OAAO,aAAKD,OAAUC,OAAOC,GAAG;AAClC;AAEA,SAASC,eAAiCC,QAAgB;IACxD,OAAO;QACLC,aAAa;QACbD;QACAE,WAAWC;QACXC,SAASD;IACX;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASE,eAAiD,EAC/DC,EAAE,EACFC,GAAG,EACHC,kBAAkBd,iBAAiB,EACnCe,QAAQ,EACRC,UAAU,IAAI,EACdC,aAAa,EAC4B;qBAkIhCC;QAJAA,aACKA;IA9Hd,MAAM,CAACC,SAASC,SAAS,GAAGvB,WAC1BI,gBAIAa,iBACAT;IAGF,6EAA6E;IAC7E,8EAA8E;IAC9E,6EAA6E;IAC7E,qEAAqE;IACrE,MAAMgB,QAAQvB,OAAOc;IACrB,MAAMU,S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import { type EntifixFailure, Entity, EntityPage, EntitySorting, FilterGroup } from '@entifix/core';
|
|
3
3
|
import { Context, Effect } from 'effect';
|
|
4
4
|
export interface UseDataLoadingState<T extends Entity> {
|
|
5
5
|
isLoading: boolean;
|
|
@@ -7,7 +7,7 @@ export interface UseDataLoadingState<T extends Entity> {
|
|
|
7
7
|
totalItems: number;
|
|
8
8
|
currentPage: number;
|
|
9
9
|
pageSize: number;
|
|
10
|
-
error:
|
|
10
|
+
error: EntifixFailure | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* The filtering and sorting currently *applied* — not a draft. The controls
|
|
13
13
|
* commit through `onFilteringChange`/`onSortingChange`, so every value here
|
|
@@ -20,7 +20,7 @@ export type UseDataLoadingAction<T extends Entity> = {
|
|
|
20
20
|
set: Partial<UseDataLoadingState<T>>;
|
|
21
21
|
};
|
|
22
22
|
export interface UseDataLoadingOptions<TEntity extends Entity, TContext> {
|
|
23
|
-
uc: Effect.Effect<EntityPage<TEntity>,
|
|
23
|
+
uc: Effect.Effect<EntityPage<TEntity>, EntifixFailure, EntityLoadRequestTag | TContext>;
|
|
24
24
|
ctx: Context.Context<TContext>;
|
|
25
25
|
/**
|
|
26
26
|
* Page size for the first load; defaults to 10. Callers that need the whole
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-data-loading.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-data-loading/use-data-loading.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,WAAW,
|
|
1
|
+
{"version":3,"file":"use-data-loading.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-data-loading/use-data-loading.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EACnB,MAAM,EACN,UAAU,EACV,aAAa,EACb,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} from '@entifix/business';\nimport {\n Entity,\n EntityPage,\n EntitySorting,\n FilterGroup,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-data-loading/use-data-loading.types.ts"],"sourcesContent":["import { EntityLoadRequestTag } from '@entifix/business';\nimport {\n type EntifixFailure,\n Entity,\n EntityPage,\n EntitySorting,\n FilterGroup,\n} from '@entifix/core';\nimport { Context, Effect } from 'effect';\n\nexport interface UseDataLoadingState<T extends Entity> {\n isLoading: boolean;\n items: Array<T>;\n totalItems: number;\n currentPage: number;\n pageSize: number;\n error: EntifixFailure | undefined;\n /**\n * The filtering and sorting currently *applied* — not a draft. The controls\n * commit through `onFilteringChange`/`onSortingChange`, so every value here\n * has already been requested from the server.\n */\n filtering: FilterGroup<T> | undefined;\n sorting: EntitySorting<T> | undefined;\n}\n\nexport type UseDataLoadingAction<T extends Entity> = {\n set: Partial<UseDataLoadingState<T>>;\n};\n\nexport interface UseDataLoadingOptions<TEntity extends Entity, TContext> {\n uc: Effect.Effect<\n EntityPage<TEntity>,\n EntifixFailure,\n EntityLoadRequestTag | TContext\n >;\n ctx: Context.Context<TContext>;\n /**\n * Page size for the first load; defaults to 10. Callers that need the whole\n * set rather than a page — a relation picker, say — raise this.\n */\n initialPageSize?: number;\n /**\n * The stable prefix that scopes this list in the shared query cache — pass\n * {@link entityQueryScope}`(Ctor)` so refetches, optimistic writes, and\n * reactive invalidation of the same entity all address one cache entry.\n * Omit it and the hook falls back to a per-instance id: correct in isolation\n * (no cross-list collisions) but unshared, so nothing outside this hook can\n * invalidate it.\n */\n queryKey?: ReadonlyArray<unknown>;\n /**\n * `false` holds the request back without unmounting the hook — what a picker's\n * browse dialog needs, since a list nobody has opened yet must not be fetched.\n * Defaults to `true`, so every existing caller loads on mount as before.\n */\n enabled?: boolean;\n /**\n * A standing restriction ANDed into every request and never shown in the filter\n * panel — \"these are the rows this caller may see at all\", as opposed to the\n * filter the user is editing. A link picker narrowing what may be assigned uses\n * it; so would a listing scoped to one tenant.\n */\n baseFiltering?: FilterGroup<TEntity>;\n}\n"],"names":[],"mappings":"AA8BA,WAkCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-entity-link-source.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-link-source/use-entity-link-source.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-entity-link-source.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-link-source/use-entity-link-source.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AAWvB,OAAO,KAAK,EACV,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,mCAAmC,CAAC;AAuC3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,MAAM,EAAE,QAAQ,EAClE,MAAM,EAAE,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,EACjD,EACE,UAAU,EACV,UAAU,EACV,cAAc,GACf,EAAE,0BAA0B,CAAC,OAAO,CAAC,GACrC,gBAAgB,CAAC,OAAO,CAAC,CAuJ3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-entity-link-source/use-entity-link-source.ts"],"sourcesContent":["'use client';\n\nimport { EntityIdTag, EntityLoadRequestTag } from '@entifix/business';\nimport {\n describeEntityColumns,\n type Entity,\n type EntityLinkSource,\n type EntityLoadRequest,\n type EntityPage,\n type TransitionalFailure,\n} from '@entifix/core';\nimport { useQuery } from '@tanstack/react-query';\nimport { Context, Effect } from 'effect';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { combineFilterGroups } from '../../query/combine-filtering.js';\nimport {\n entityQueryKey,\n entityQueryScope,\n} from '../../query/entity-query-key.js';\nimport { useDataLoading } from '../use-data-loading/index.js';\nimport type {\n EntityLinkSourceConfig,\n UseEntityLinkSourceOptions,\n} from './use-entity-link-source.types.js';\n\nconst DEFAULT_QUICK_PAGE_SIZE = 10;\nconst DEFAULT_DEBOUNCE_MS = 250;\n\n/**\n * Fails loudly on a search property the service will reject.\n *\n * A member's `filterable` metadata is also the server-side filter allowlist, so a\n * quick search over a member that lacks it answers `400` — as an empty\n * suggestion list, which reads to the user as \"there are no brands\". Better to\n * break the developer's build than to lie to them.\n */\nfunction assertSearchable<TTarget extends Entity>(\n config: EntityLinkSourceConfig<TTarget, unknown>,\n searchProperty: string,\n): void {\n const target = describeEntityColumns(config.entityConstructor).find(\n column => column.name === searchProperty,\n );\n if (target?.type === 'localized') {\n // Queried one locale at a time, and this hook holds no locale: the bare\n // member is what the service would refuse.\n throw new Error(\n `Cannot search ${config.entityConstructor.name} by \"${searchProperty}\": ` +\n 'the member is localized, and a quick search has no locale to search ' +\n 'it in. Point the relation at a string member with `linkSearchProperty`.',\n );\n }\n if (target?.filterable === true) return;\n\n throw new Error(\n `Cannot search ${config.entityConstructor.name} by \"${searchProperty}\": ` +\n 'the member is not filterable, so the service would reject the query. ' +\n 'Declare it `filterable` on the target entity, or point the relation at ' +\n 'another member with `linkSearchProperty`.',\n );\n}\n\n/**\n * Produces the {@link EntityLinkSource} a link editor runs on: the quick\n * type-ahead, the browse list, and the label of whatever key is currently held.\n *\n * This is the data half of the link mechanism. It exists as a hook — rather than\n * inside the input — because `@entifix/react-controls` may not import this package\n * (both are T3, and the tier register declares no sideways edge between them), so\n * the two meet at the framework-free port declared in `@entifix/core`. A form\n * wrapper calls it once per relation and hands the results to `EntityForm`'s\n * `linkSources`.\n *\n * What may be picked is never decided here: the caller's `loadUc` (and optional\n * `baseFiltering`) is what restricts the set, so a domain rule about assignable\n * targets lives in a use-case, not in the UI.\n *\n * Three requests, each held back until it means something: the quick search runs\n * a small page and re-runs on a debounced term; the browse list does not fetch at\n * all until the dialog opens; and the label is only looked up when the caller has\n * an id but no instance — a draft restored from storage — because a picked target\n * already knows its own name.\n */\nexport function useEntityLinkSource<TTarget extends Entity, TContext>(\n config: EntityLinkSourceConfig<TTarget, TContext>,\n {\n descriptor,\n selectedId,\n selectedEntity,\n }: UseEntityLinkSourceOptions<TTarget>,\n): EntityLinkSource<TTarget> {\n const {\n entityConstructor,\n loadUc,\n getUc,\n ctx,\n baseFiltering,\n quickPageSize = DEFAULT_QUICK_PAGE_SIZE,\n debounceMs = DEFAULT_DEBOUNCE_MS,\n } = config;\n\n const searchProperty = descriptor.linkSearchProperty;\n assertSearchable(\n config as unknown as EntityLinkSourceConfig<TTarget, unknown>,\n searchProperty,\n );\n\n // Callers rebuild `loadUc`/`getUc`/`ctx` inline on every render, so the latest\n // are held in refs and kept out of the query keys — keying on their identity\n // would refetch on every render. Same reason and same shape as `useDataLoading`.\n const effects = useRef({ loadUc, getUc, ctx });\n useEffect(() => {\n effects.current = { loadUc, getUc, ctx };\n });\n\n const [term, setTerm] = useState('');\n const [debouncedTerm, setDebouncedTerm] = useState('');\n const [isOpen, setOpen] = useState(false);\n\n // Typing is not a request per keystroke: the term settles first, and only the\n // settled value reaches the service.\n useEffect(() => {\n const timer = setTimeout(() => setDebouncedTerm(term), debounceMs);\n return () => clearTimeout(timer);\n }, [term, debounceMs]);\n\n const quickRequest = useMemo<EntityLoadRequest<TTarget>>(() => {\n const filtering = combineFilterGroups<TTarget>(\n baseFiltering,\n debouncedTerm === ''\n ? undefined\n : {\n operator: 'and',\n values: [\n {\n property: searchProperty as keyof TTarget,\n operator: 'like',\n value: debouncedTerm,\n },\n ],\n },\n );\n\n const request: EntityLoadRequest<TTarget> = {\n page: 1,\n pageSize: quickPageSize,\n };\n if (filtering) request.filtering = [filtering];\n return request;\n }, [baseFiltering, debouncedTerm, quickPageSize, searchProperty]);\n\n const quickQuery = useQuery<EntityPage<TTarget>, TransitionalFailure>({\n queryKey: [\n ...entityQueryKey(entityConstructor, quickRequest),\n 'link-quick',\n ],\n queryFn: () =>\n Effect.runPromise(\n Effect.provide(\n effects.current.loadUc,\n effects.current.ctx.pipe(\n Context.add(\n EntityLoadRequestTag,\n // The tag carries no generic, so the entity-typed request crosses\n // it — the same cast `loadUCFactory` makes reading it back.\n quickRequest as unknown as EntityLoadRequest,\n ),\n ),\n ),\n ),\n });\n\n const browse = useDataLoading<TTarget, TContext>({\n uc: loadUc,\n ctx,\n queryKey: entityQueryScope(entityConstructor),\n baseFiltering,\n enabled: isOpen,\n });\n\n const needsLabel =\n selectedEntity === undefined && selectedId != null && getUc !== undefined;\n\n const labelQuery = useQuery<TTarget, TransitionalFailure>({\n queryKey: [\n ...entityQueryScope(entityConstructor),\n 'link-label',\n String(selectedId),\n ],\n enabled: needsLabel,\n queryFn: () =>\n Effect.runPromise(\n Effect.provide(\n // Guarded by `enabled`: the query only runs when both are present.\n effects.current.getUc as NonNullable<typeof getUc>,\n effects.current.ctx.pipe(Context.add(EntityIdTag, selectedId)),\n ),\n ),\n });\n\n // A blank label is as useless as a missing one, so both fall back to the key —\n // an unnamed row must still be distinguishable from the row above it.\n const labelOf = useCallback(\n (target: TTarget) => {\n const label = (target as Record<string, unknown>)[\n descriptor.linkLabelProperty\n ];\n return label == null || label === ''\n ? String(target.id ?? '')\n : String(label);\n },\n [descriptor.linkLabelProperty],\n );\n\n const resolved = selectedEntity ?? labelQuery.data;\n\n return {\n entityConstructor,\n labelOf,\n selected: {\n label: resolved === undefined ? undefined : labelOf(resolved),\n // The whole target, not only its name. The lookup above already fetched\n // it, and a form restoring a draft has nothing else to rebuild an\n // `embedded` relation from — the draft kept the id and lost the instance.\n entity: resolved,\n isLoading: needsLabel && labelQuery.isFetching,\n },\n quick: {\n term,\n setTerm,\n options: quickQuery.data?.items ?? [],\n isLoading: quickQuery.isFetching,\n error: quickQuery.error ?? undefined,\n },\n browse: {\n ...browse,\n isOpen,\n open: () => setOpen(true),\n close: () => setOpen(false),\n },\n };\n}\n"],"names":["EntityIdTag","EntityLoadRequestTag","describeEntityColumns","useQuery","Context","Effect","useCallback","useEffect","useMemo","useRef","useState","combineFilterGroups","entityQueryKey","entityQueryScope","useDataLoading","DEFAULT_QUICK_PAGE_SIZE","DEFAULT_DEBOUNCE_MS","assertSearchable","config","searchProperty","target","entityConstructor","find","column","name","type","Error","filterable","useEntityLinkSource","descriptor","selectedId","selectedEntity","quickQuery","loadUc","getUc","ctx","baseFiltering","quickPageSize","debounceMs","linkSearchProperty","effects","current","term","setTerm","debouncedTerm","setDebouncedTerm","isOpen","setOpen","timer","setTimeout","clearTimeout","quickRequest","filtering","undefined","operator","values","property","value","request","page","pageSize","queryKey","queryFn","runPromise","provide","pipe","add","browse","uc","enabled","needsLabel","labelQuery","String","labelOf","label","linkLabelProperty","id","resolved","data","selected","entity","isLoading","isFetching","quick","options","items","error","open","close"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAEC,oBAAoB,QAAQ,oBAAoB;AACtE,SACEC,qBAAqB,QAMhB,gBAAgB;AACvB,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AACzC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE1E,SAASC,mBAAmB,QAAQ,mCAAmC;AACvE,SACEC,cAAc,EACdC,gBAAgB,QACX,kCAAkC;AACzC,SAASC,cAAc,QAAQ,+BAA+B;AAM9D,MAAMC,0BAA0B;AAChC,MAAMC,sBAAsB;AAE5B;;;;;;;CAOC,GACD,SAASC,iBACPC,MAAgD,EAChDC,cAAsB;IAEtB,MAAMC,SAASlB,sBAAsBgB,OAAOG,iBAAiB,EAAEC,IAAI,CACjEC,CAAAA,SAAUA,OAAOC,IAAI,KAAKL;IAE5B,IAAIC,CAAAA,0BAAAA,OAAQK,IAAI,MAAK,aAAa;QAChC,wEAAwE;QACxE,2CAA2C;QAC3C,MAAM,IAAIC,MACR,CAAC,cAAc,EAAER,OAAOG,iBAAiB,CAACG,IAAI,CAAC,KAAK,EAAEL,eAAe,GAAG,CAAC,GACvE,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;QACAoD;QACAM,UAAU;YACRL,OAAOG,aAAaxB,YAAYA,YAAYoB,QAAQI;YACpD,wEAAwE;YACxE,kEAAkE;YAClE,0EAA0E;YAC1EG,QAAQH;YACRI,WAAWX,cAAcC,WAAWW,UAAU;QAChD;QACAC,OAAO;YACLzC;YACAC;YACAyC,OAAO,WAAEpD,mBAAAA,WAAW8C,IAAI,qBAAf9C,iBAAiBqD,KAAK,mBAAI,EAAE;YACrCJ,WAAWjD,WAAWkD,UAAU;YAChCI,KAAK,GAAEtD,oBAAAA,WAAWsD,KAAK,YAAhBtD,oBAAoBqB;QAC7B;QACAc,QAAQ,aACHA;YACHrB;YACAyC,MAAM,IAAMxC,QAAQ;YACpByC,OAAO,IAAMzC,QAAQ;;IAEzB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-entity-link-source/use-entity-link-source.ts"],"sourcesContent":["'use client';\n\nimport { EntityIdTag, EntityLoadRequestTag } from '@entifix/business';\nimport {\n describeEntityColumns,\n type EntifixFailure,\n type Entity,\n type EntityLinkSource,\n type EntityLoadRequest,\n type EntityPage,\n} from '@entifix/core';\nimport { useQuery } from '@tanstack/react-query';\nimport { Context, Effect } from 'effect';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { combineFilterGroups } from '../../query/combine-filtering.js';\nimport {\n entityQueryKey,\n entityQueryScope,\n} from '../../query/entity-query-key.js';\nimport { useDataLoading } from '../use-data-loading/index.js';\nimport type {\n EntityLinkSourceConfig,\n UseEntityLinkSourceOptions,\n} from './use-entity-link-source.types.js';\n\nconst DEFAULT_QUICK_PAGE_SIZE = 10;\nconst DEFAULT_DEBOUNCE_MS = 250;\n\n/**\n * Fails loudly on a search property the service will reject.\n *\n * A member's `filterable` metadata is also the server-side filter allowlist, so a\n * quick search over a member that lacks it answers `400` — as an empty\n * suggestion list, which reads to the user as \"there are no brands\". Better to\n * break the developer's build than to lie to them.\n */\nfunction assertSearchable<TTarget extends Entity>(\n config: EntityLinkSourceConfig<TTarget, unknown>,\n searchProperty: string,\n): void {\n const target = describeEntityColumns(config.entityConstructor).find(\n column => column.name === searchProperty,\n );\n if (target?.type === 'localized') {\n // Queried one locale at a time, and this hook holds no locale: the bare\n // member is what the service would refuse.\n throw new Error(\n `Cannot search ${config.entityConstructor.name} by \"${searchProperty}\": ` +\n 'the member is localized, and a quick search has no locale to search ' +\n 'it in. Point the relation at a string member with `linkSearchProperty`.',\n );\n }\n if (target?.filterable === true) return;\n\n throw new Error(\n `Cannot search ${config.entityConstructor.name} by \"${searchProperty}\": ` +\n 'the member is not filterable, so the service would reject the query. ' +\n 'Declare it `filterable` on the target entity, or point the relation at ' +\n 'another member with `linkSearchProperty`.',\n );\n}\n\n/**\n * Produces the {@link EntityLinkSource} a link editor runs on: the quick\n * type-ahead, the browse list, and the label of whatever key is currently held.\n *\n * This is the data half of the link mechanism. It exists as a hook — rather than\n * inside the input — because `@entifix/react-controls` may not import this package\n * (both are T3, and the tier register declares no sideways edge between them), so\n * the two meet at the framework-free port declared in `@entifix/core`. A form\n * wrapper calls it once per relation and hands the results to `EntityForm`'s\n * `linkSources`.\n *\n * What may be picked is never decided here: the caller's `loadUc` (and optional\n * `baseFiltering`) is what restricts the set, so a domain rule about assignable\n * targets lives in a use-case, not in the UI.\n *\n * Three requests, each held back until it means something: the quick search runs\n * a small page and re-runs on a debounced term; the browse list does not fetch at\n * all until the dialog opens; and the label is only looked up when the caller has\n * an id but no instance — a draft restored from storage — because a picked target\n * already knows its own name.\n */\nexport function useEntityLinkSource<TTarget extends Entity, TContext>(\n config: EntityLinkSourceConfig<TTarget, TContext>,\n {\n descriptor,\n selectedId,\n selectedEntity,\n }: UseEntityLinkSourceOptions<TTarget>,\n): EntityLinkSource<TTarget> {\n const {\n entityConstructor,\n loadUc,\n getUc,\n ctx,\n baseFiltering,\n quickPageSize = DEFAULT_QUICK_PAGE_SIZE,\n debounceMs = DEFAULT_DEBOUNCE_MS,\n } = config;\n\n const searchProperty = descriptor.linkSearchProperty;\n assertSearchable(\n config as unknown as EntityLinkSourceConfig<TTarget, unknown>,\n searchProperty,\n );\n\n // Callers rebuild `loadUc`/`getUc`/`ctx` inline on every render, so the latest\n // are held in refs and kept out of the query keys — keying on their identity\n // would refetch on every render. Same reason and same shape as `useDataLoading`.\n const effects = useRef({ loadUc, getUc, ctx });\n useEffect(() => {\n effects.current = { loadUc, getUc, ctx };\n });\n\n const [term, setTerm] = useState('');\n const [debouncedTerm, setDebouncedTerm] = useState('');\n const [isOpen, setOpen] = useState(false);\n\n // Typing is not a request per keystroke: the term settles first, and only the\n // settled value reaches the service.\n useEffect(() => {\n const timer = setTimeout(() => setDebouncedTerm(term), debounceMs);\n return () => clearTimeout(timer);\n }, [term, debounceMs]);\n\n const quickRequest = useMemo<EntityLoadRequest<TTarget>>(() => {\n const filtering = combineFilterGroups<TTarget>(\n baseFiltering,\n debouncedTerm === ''\n ? undefined\n : {\n operator: 'and',\n values: [\n {\n property: searchProperty as keyof TTarget,\n operator: 'like',\n value: debouncedTerm,\n },\n ],\n },\n );\n\n const request: EntityLoadRequest<TTarget> = {\n page: 1,\n pageSize: quickPageSize,\n };\n if (filtering) request.filtering = [filtering];\n return request;\n }, [baseFiltering, debouncedTerm, quickPageSize, searchProperty]);\n\n const quickQuery = useQuery<EntityPage<TTarget>, EntifixFailure>({\n queryKey: [\n ...entityQueryKey(entityConstructor, quickRequest),\n 'link-quick',\n ],\n queryFn: () =>\n Effect.runPromise(\n Effect.provide(\n effects.current.loadUc,\n effects.current.ctx.pipe(\n Context.add(\n EntityLoadRequestTag,\n // The tag carries no generic, so the entity-typed request crosses\n // it — the same cast `loadUCFactory` makes reading it back.\n quickRequest as unknown as EntityLoadRequest,\n ),\n ),\n ),\n ),\n });\n\n const browse = useDataLoading<TTarget, TContext>({\n uc: loadUc,\n ctx,\n queryKey: entityQueryScope(entityConstructor),\n baseFiltering,\n enabled: isOpen,\n });\n\n const needsLabel =\n selectedEntity === undefined && selectedId != null && getUc !== undefined;\n\n const labelQuery = useQuery<TTarget, EntifixFailure>({\n queryKey: [\n ...entityQueryScope(entityConstructor),\n 'link-label',\n String(selectedId),\n ],\n enabled: needsLabel,\n queryFn: () =>\n Effect.runPromise(\n Effect.provide(\n // Guarded by `enabled`: the query only runs when both are present.\n effects.current.getUc as NonNullable<typeof getUc>,\n effects.current.ctx.pipe(Context.add(EntityIdTag, selectedId)),\n ),\n ),\n });\n\n // A blank label is as useless as a missing one, so both fall back to the key —\n // an unnamed row must still be distinguishable from the row above it.\n const labelOf = useCallback(\n (target: TTarget) => {\n const label = (target as Record<string, unknown>)[\n descriptor.linkLabelProperty\n ];\n return label == null || label === ''\n ? String(target.id ?? '')\n : String(label);\n },\n [descriptor.linkLabelProperty],\n );\n\n const resolved = selectedEntity ?? labelQuery.data;\n\n return {\n entityConstructor,\n labelOf,\n selected: {\n label: resolved === undefined ? undefined : labelOf(resolved),\n // The whole target, not only its name. The lookup above already fetched\n // it, and a form restoring a draft has nothing else to rebuild an\n // `embedded` relation from — the draft kept the id and lost the instance.\n entity: resolved,\n isLoading: needsLabel && labelQuery.isFetching,\n },\n quick: {\n term,\n setTerm,\n options: quickQuery.data?.items ?? [],\n isLoading: quickQuery.isFetching,\n error: quickQuery.error ?? undefined,\n },\n browse: {\n ...browse,\n isOpen,\n open: () => setOpen(true),\n close: () => setOpen(false),\n },\n };\n}\n"],"names":["EntityIdTag","EntityLoadRequestTag","describeEntityColumns","useQuery","Context","Effect","useCallback","useEffect","useMemo","useRef","useState","combineFilterGroups","entityQueryKey","entityQueryScope","useDataLoading","DEFAULT_QUICK_PAGE_SIZE","DEFAULT_DEBOUNCE_MS","assertSearchable","config","searchProperty","target","entityConstructor","find","column","name","type","Error","filterable","useEntityLinkSource","descriptor","selectedId","selectedEntity","quickQuery","loadUc","getUc","ctx","baseFiltering","quickPageSize","debounceMs","linkSearchProperty","effects","current","term","setTerm","debouncedTerm","setDebouncedTerm","isOpen","setOpen","timer","setTimeout","clearTimeout","quickRequest","filtering","undefined","operator","values","property","value","request","page","pageSize","queryKey","queryFn","runPromise","provide","pipe","add","browse","uc","enabled","needsLabel","labelQuery","String","labelOf","label","linkLabelProperty","id","resolved","data","selected","entity","isLoading","isFetching","quick","options","items","error","open","close"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAEC,oBAAoB,QAAQ,oBAAoB;AACtE,SACEC,qBAAqB,QAMhB,gBAAgB;AACvB,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AACzC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE1E,SAASC,mBAAmB,QAAQ,mCAAmC;AACvE,SACEC,cAAc,EACdC,gBAAgB,QACX,kCAAkC;AACzC,SAASC,cAAc,QAAQ,+BAA+B;AAM9D,MAAMC,0BAA0B;AAChC,MAAMC,sBAAsB;AAE5B;;;;;;;CAOC,GACD,SAASC,iBACPC,MAAgD,EAChDC,cAAsB;IAEtB,MAAMC,SAASlB,sBAAsBgB,OAAOG,iBAAiB,EAAEC,IAAI,CACjEC,CAAAA,SAAUA,OAAOC,IAAI,KAAKL;IAE5B,IAAIC,CAAAA,0BAAAA,OAAQK,IAAI,MAAK,aAAa;QAChC,wEAAwE;QACxE,2CAA2C;QAC3C,MAAM,IAAIC,MACR,CAAC,cAAc,EAAER,OAAOG,iBAAiB,CAACG,IAAI,CAAC,KAAK,EAAEL,eAAe,GAAG,CAAC,GACvE,yEACA;IAEN;IACA,IAAIC,CAAAA,0BAAAA,OAAQO,UAAU,MAAK,MAAM;IAEjC,MAAM,IAAID,MACR,CAAC,cAAc,EAAER,OAAOG,iBAAiB,CAACG,IAAI,CAAC,KAAK,EAAEL,eAAe,GAAG,CAAC,GACvE,0EACA,4EACA;AAEN;AAEA;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASS,oBACdV,MAAiD,EACjD,EACEW,UAAU,EACVC,UAA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WAAWkD,UAAU;YAChCI,KAAK,GAAEtD,oBAAAA,WAAWsD,KAAK,YAAhBtD,oBAAoBqB;QAC7B;QACAc,QAAQ,aACHA;YACHrB;YACAyC,MAAM,IAAMxC,QAAQ;YACpByC,OAAO,IAAMzC,QAAQ;;IAEzB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntityIdTag, EntityLoadRequestTag } from '@entifix/business';
|
|
2
|
-
import type { Entity, EntityConstructor, EntityFieldDescriptor, EntityId, EntityPage, FilterGroup
|
|
2
|
+
import type { EntifixFailure, Entity, EntityConstructor, EntityFieldDescriptor, EntityId, EntityPage, FilterGroup } from '@entifix/core';
|
|
3
3
|
import type { Context, Effect } from 'effect';
|
|
4
4
|
/**
|
|
5
5
|
* Where a picker's targets come from, and what may be picked.
|
|
@@ -13,13 +13,13 @@ import type { Context, Effect } from 'effect';
|
|
|
13
13
|
export interface EntityLinkSourceConfig<TTarget extends Entity, TContext> {
|
|
14
14
|
entityConstructor: EntityConstructor<TTarget>;
|
|
15
15
|
/** Lists the targets. Supplies {@link EntityLoadRequestTag} per request. */
|
|
16
|
-
loadUc: Effect.Effect<EntityPage<TTarget>,
|
|
16
|
+
loadUc: Effect.Effect<EntityPage<TTarget>, EntifixFailure, EntityLoadRequestTag | TContext>;
|
|
17
17
|
/**
|
|
18
18
|
* Loads one target by id — how a draft restored from storage turns its held
|
|
19
19
|
* foreign key back into a name. Omit it and the input falls back to showing
|
|
20
20
|
* the bare key.
|
|
21
21
|
*/
|
|
22
|
-
getUc?: Effect.Effect<TTarget,
|
|
22
|
+
getUc?: Effect.Effect<TTarget, EntifixFailure, EntityIdTag | TContext>;
|
|
23
23
|
ctx: Context.Context<TContext>;
|
|
24
24
|
/**
|
|
25
25
|
* ANDed into every quick and browse request, so a caller can narrow the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-entity-link-source.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-link-source/use-entity-link-source.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,QAAQ,EACR,UAAU,EACV,WAAW,
|
|
1
|
+
{"version":3,"file":"use-entity-link-source.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-link-source/use-entity-link-source.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,iBAAiB,EACjB,qBAAqB,EACrB,QAAQ,EACR,UAAU,EACV,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAsB,CAAC,OAAO,SAAS,MAAM,EAAE,QAAQ;IACtE,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC9C,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC,MAAM,CACnB,UAAU,CAAC,OAAO,CAAC,EACnB,cAAc,EACd,oBAAoB,GAAG,QAAQ,CAChC,CAAC;IACF;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,WAAW,GAAG,QAAQ,CAAC,CAAC;IACvE,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/B;;;OAGG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACrC,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B,CAAC,OAAO,SAAS,MAAM;IAChE;;;OAGG;IACH,UAAU,EAAE,qBAAqB,CAAC;IAClC,iDAAiD;IACjD,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-entity-link-source/use-entity-link-source.types.ts"],"sourcesContent":["import type { EntityIdTag, EntityLoadRequestTag } from '@entifix/business';\nimport type {\n Entity,\n EntityConstructor,\n EntityFieldDescriptor,\n EntityId,\n EntityPage,\n FilterGroup,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-entity-link-source/use-entity-link-source.types.ts"],"sourcesContent":["import type { EntityIdTag, EntityLoadRequestTag } from '@entifix/business';\nimport type {\n EntifixFailure,\n Entity,\n EntityConstructor,\n EntityFieldDescriptor,\n EntityId,\n EntityPage,\n FilterGroup,\n} from '@entifix/core';\nimport type { Context, Effect } from 'effect';\n\n/**\n * Where a picker's targets come from, and what may be picked.\n *\n * The use-cases are the parametrization seam: a domain that must restrict what is\n * assignable supplies its own list use-case (only active brands, only leaf\n * categories) instead of the generic `loadUCFactory`, and the picker never learns\n * the rule. {@link baseFiltering} is the lighter version of the same idea for a\n * restriction that needs no use-case of its own.\n */\nexport interface EntityLinkSourceConfig<TTarget extends Entity, TContext> {\n entityConstructor: EntityConstructor<TTarget>;\n /** Lists the targets. Supplies {@link EntityLoadRequestTag} per request. */\n loadUc: Effect.Effect<\n EntityPage<TTarget>,\n EntifixFailure,\n EntityLoadRequestTag | TContext\n >;\n /**\n * Loads one target by id — how a draft restored from storage turns its held\n * foreign key back into a name. Omit it and the input falls back to showing\n * the bare key.\n */\n getUc?: Effect.Effect<TTarget, EntifixFailure, EntityIdTag | TContext>;\n ctx: Context.Context<TContext>;\n /**\n * ANDed into every quick and browse request, so a caller can narrow the\n * selectable set without writing a use-case.\n */\n baseFiltering?: FilterGroup<TTarget>;\n /** How many suggestions the quick search asks for. Defaults to 10. */\n quickPageSize?: number;\n /** Milliseconds of quiet before a typed term is sent. Defaults to 250. */\n debounceMs?: number;\n}\n\nexport interface UseEntityLinkSourceOptions<TTarget extends Entity> {\n /**\n * The relation being edited. Its `linkSearchProperty` is what the quick search\n * filters on and its `linkLabelProperty` is what a target reads as.\n */\n descriptor: EntityFieldDescriptor;\n /** The foreign key the draft currently holds. */\n selectedId?: EntityId;\n /**\n * The instance behind {@link selectedId} when the caller already has it — the\n * one the user just picked, or the one a loaded record carried. Present, it\n * spares the label request entirely.\n */\n selectedEntity?: TTarget;\n}\n"],"names":[],"mappings":"AA+CA,WAcC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EntifixFailure, type Entity, type EntityId } from '@entifix/core';
|
|
2
2
|
import type { UseEntityMutationOptions } from './use-entity-mutation.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Runs the write use-cases from a component — the mutating counterpart to
|
|
@@ -17,6 +17,6 @@ export declare function useEntityMutation<TEntity extends Entity, TContext>({ sa
|
|
|
17
17
|
remove: (id: EntityId) => Promise<boolean>;
|
|
18
18
|
isSaving: boolean;
|
|
19
19
|
isDeleting: boolean;
|
|
20
|
-
error:
|
|
20
|
+
error: EntifixFailure | undefined;
|
|
21
21
|
};
|
|
22
22
|
//# sourceMappingURL=use-entity-mutation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-entity-mutation.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-mutation/use-entity-mutation.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-entity-mutation.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-mutation/use-entity-mutation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIhF,OAAO,KAAK,EAEV,wBAAwB,EAEzB,MAAM,gCAAgC,CAAC;AAexC;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,MAAM,EAAE,QAAQ,EAAE,EAClE,MAAM,EACN,QAAQ,EACR,GAAG,GACJ,EAAE,wBAAwB,CAAC,OAAO,EAAE,QAAQ,CAAC;mBAI3B,OAAO,KAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;iBAmB1C,QAAQ,KAAG,OAAO,CAAC,OAAO,CAAC;;;;EAmBzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-entity-mutation/use-entity-mutation.ts"],"sourcesContent":["import { EntityIdTag, EntityTag } from '@entifix/business';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-entity-mutation/use-entity-mutation.ts"],"sourcesContent":["import { EntityIdTag, EntityTag } from '@entifix/business';\nimport { type EntifixFailure, type Entity, type EntityId } from '@entifix/core';\nimport { Context, Effect } from 'effect';\nimport { useCallback, useReducer } from 'react';\n\nimport type {\n UseEntityMutationAction,\n UseEntityMutationOptions,\n UseEntityMutationState,\n} from './use-entity-mutation.types.js';\n\nconst initialState: UseEntityMutationState = {\n isSaving: false,\n isDeleting: false,\n error: undefined,\n};\n\nfunction reducer(\n state: UseEntityMutationState,\n action: UseEntityMutationAction,\n): UseEntityMutationState {\n return { ...state, ...action.set };\n}\n\n/**\n * Runs the write use-cases from a component — the mutating counterpart to\n * {@link useDataLoading}.\n *\n * Inputs are provided as tags at call time ({@link EntityTag} for a save,\n * {@link EntityIdTag} for a delete), so the use-cases stay unaware of both React\n * and the transport behind `ctx`.\n *\n * `save` resolves to the entity the *repository* returned rather than the one\n * passed in. That distinction matters: a create round-trips through the store's\n * id generation, so only the returned entity is addressable.\n */\nexport function useEntityMutation<TEntity extends Entity, TContext>({\n saveUc,\n deleteUc,\n ctx,\n}: UseEntityMutationOptions<TEntity, TContext>) {\n const [state, dispatch] = useReducer(reducer, initialState);\n\n const save = useCallback(\n async (entity: TEntity): Promise<TEntity | undefined> => {\n dispatch({ set: { isSaving: true, error: undefined } });\n try {\n const saved = await Effect.runPromise(\n Effect.provide(saveUc, ctx.pipe(Context.add(EntityTag, entity))),\n );\n dispatch({ set: { isSaving: false } });\n return saved;\n } catch (error) {\n dispatch({\n set: { isSaving: false, error: error as EntifixFailure },\n });\n return undefined;\n }\n },\n [saveUc, ctx],\n );\n\n const remove = useCallback(\n async (id: EntityId): Promise<boolean> => {\n dispatch({ set: { isDeleting: true, error: undefined } });\n try {\n await Effect.runPromise(\n Effect.provide(deleteUc, ctx.pipe(Context.add(EntityIdTag, id))),\n );\n dispatch({ set: { isDeleting: false } });\n return true;\n } catch (error) {\n dispatch({\n set: { isDeleting: false, error: error as EntifixFailure },\n });\n return false;\n }\n },\n [deleteUc, ctx],\n );\n\n return { ...state, save, remove };\n}\n"],"names":["EntityIdTag","EntityTag","Context","Effect","useCallback","useReducer","initialState","isSaving","isDeleting","error","undefined","reducer","state","action","set","useEntityMutation","saveUc","deleteUc","ctx","dispatch","save","entity","saved","runPromise","provide","pipe","add","remove","id"],"mappings":";AAAA,SAASA,WAAW,EAAEC,SAAS,QAAQ,oBAAoB;AAE3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AACzC,SAASC,WAAW,EAAEC,UAAU,QAAQ,QAAQ;AAQhD,MAAMC,eAAuC;IAC3CC,UAAU;IACVC,YAAY;IACZC,OAAOC;AACT;AAEA,SAASC,QACPC,KAA6B,EAC7BC,MAA+B;IAE/B,OAAO,aAAKD,OAAUC,OAAOC,GAAG;AAClC;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,kBAAoD,EAClEC,MAAM,EACNC,QAAQ,EACRC,GAAG,EACyC;IAC5C,MAAM,CAACN,OAAOO,SAAS,GAAGd,WAAWM,SAASL;IAE9C,MAAMc,OAAOhB,YACX,OAAOiB;QACLF,SAAS;YAAEL,KAAK;gBAAEP,UAAU;gBAAME,OAAOC;YAAU;QAAE;QACrD,IAAI;YACF,MAAMY,QAAQ,MAAMnB,OAAOoB,UAAU,CACnCpB,OAAOqB,OAAO,CAACR,QAAQE,IAAIO,IAAI,CAACvB,QAAQwB,GAAG,CAACzB,WAAWoB;YAEzDF,SAAS;gBAAEL,KAAK;oBAAEP,UAAU;gBAAM;YAAE;YACpC,OAAOe;QACT,EAAE,OAAOb,OAAO;YACdU,SAAS;gBACPL,KAAK;oBAAEP,UAAU;oBAAOE,OAAOA;gBAAwB;YACzD;YACA,OAAOC;QACT;IACF,GACA;QAACM;QAAQE;KAAI;IAGf,MAAMS,SAASvB,YACb,OAAOwB;QACLT,SAAS;YAAEL,KAAK;gBAAEN,YAAY;gBAAMC,OAAOC;YAAU;QAAE;QACvD,IAAI;YACF,MAAMP,OAAOoB,UAAU,CACrBpB,OAAOqB,OAAO,CAACP,UAAUC,IAAIO,IAAI,CAACvB,QAAQwB,GAAG,CAAC1B,aAAa4B;YAE7DT,SAAS;gBAAEL,KAAK;oBAAEN,YAAY;gBAAM;YAAE;YACtC,OAAO;QACT,EAAE,OAAOC,OAAO;YACdU,SAAS;gBACPL,KAAK;oBAAEN,YAAY;oBAAOC,OAAOA;gBAAwB;YAC3D;YACA,OAAO;QACT;IACF,GACA;QAACQ;QAAUC;KAAI;IAGjB,OAAO,aAAKN;QAAOQ;QAAMO;;AAC3B"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { EntityIdTag, EntityTag } from '@entifix/business';
|
|
2
|
-
import {
|
|
2
|
+
import { type EntifixFailure, Entity } from '@entifix/core';
|
|
3
3
|
import { Context, Effect } from 'effect';
|
|
4
4
|
export interface UseEntityMutationState {
|
|
5
5
|
isSaving: boolean;
|
|
6
6
|
isDeleting: boolean;
|
|
7
|
-
error:
|
|
7
|
+
error: EntifixFailure | undefined;
|
|
8
8
|
}
|
|
9
9
|
export type UseEntityMutationAction = {
|
|
10
10
|
set: Partial<UseEntityMutationState>;
|
|
11
11
|
};
|
|
12
12
|
export interface UseEntityMutationOptions<TEntity extends Entity, TContext> {
|
|
13
13
|
/** A save use-case; the hook supplies {@link EntityTag}. */
|
|
14
|
-
saveUc: Effect.Effect<TEntity,
|
|
14
|
+
saveUc: Effect.Effect<TEntity, EntifixFailure, EntityTag | TContext>;
|
|
15
15
|
/** A delete use-case; the hook supplies {@link EntityIdTag}. */
|
|
16
|
-
deleteUc: Effect.Effect<void,
|
|
16
|
+
deleteUc: Effect.Effect<void, EntifixFailure, EntityIdTag | TContext>;
|
|
17
17
|
ctx: Context.Context<TContext>;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=use-entity-mutation.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-entity-mutation.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-mutation/use-entity-mutation.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-entity-mutation.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-mutation/use-entity-mutation.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,MAAM,EAAE,QAAQ;IACxE,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IACrE,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,WAAW,GAAG,QAAQ,CAAC,CAAC;IACtE,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-entity-mutation/use-entity-mutation.types.ts"],"sourcesContent":["import { EntityIdTag, EntityTag } from '@entifix/business';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-entity-mutation/use-entity-mutation.types.ts"],"sourcesContent":["import { EntityIdTag, EntityTag } from '@entifix/business';\nimport { type EntifixFailure, Entity } from '@entifix/core';\nimport { Context, Effect } from 'effect';\n\nexport interface UseEntityMutationState {\n isSaving: boolean;\n isDeleting: boolean;\n error: EntifixFailure | undefined;\n}\n\nexport type UseEntityMutationAction = {\n set: Partial<UseEntityMutationState>;\n};\n\nexport interface UseEntityMutationOptions<TEntity extends Entity, TContext> {\n /** A save use-case; the hook supplies {@link EntityTag}. */\n saveUc: Effect.Effect<TEntity, EntifixFailure, EntityTag | TContext>;\n /** A delete use-case; the hook supplies {@link EntityIdTag}. */\n deleteUc: Effect.Effect<void, EntifixFailure, EntityIdTag | TContext>;\n ctx: Context.Context<TContext>;\n}\n"],"names":[],"mappings":"AAcA,WAMC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EntifixFailure, type Entity } from '@entifix/core';
|
|
2
2
|
import type { UseEntityRecordOptions } from './use-entity-record.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Loads a single entity by id — the read half of an entity form.
|
|
@@ -16,6 +16,6 @@ export declare function useEntityRecord<TEntity extends Entity, TContext>({ uc,
|
|
|
16
16
|
setEntity: (entity: TEntity | undefined) => void;
|
|
17
17
|
entity: TEntity | undefined;
|
|
18
18
|
isLoading: boolean;
|
|
19
|
-
error:
|
|
19
|
+
error: EntifixFailure | undefined;
|
|
20
20
|
};
|
|
21
21
|
//# sourceMappingURL=use-entity-record.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-entity-record.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-record/use-entity-record.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"use-entity-record.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-record/use-entity-record.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAIjE,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,8BAA8B,CAAC;AAmBtC;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAS,MAAM,EAAE,QAAQ,EAAE,EAChE,EAAE,EACF,GAAG,EACH,EAAE,GACH,EAAE,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC;;wBAgE/B,OAAO,GAAG,SAAS;;;;EAK/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-entity-record/use-entity-record.ts"],"sourcesContent":["import { EntityIdTag } from '@entifix/business';\nimport { type
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-entity-record/use-entity-record.ts"],"sourcesContent":["import { EntityIdTag } from '@entifix/business';\nimport { type EntifixFailure, type Entity } from '@entifix/core';\nimport { Context, Effect } from 'effect';\nimport { useCallback, useEffect, useReducer, useRef, useState } from 'react';\n\nimport type {\n UseEntityRecordAction,\n UseEntityRecordOptions,\n UseEntityRecordState,\n} from './use-entity-record.types.js';\n\nfunction getInitialState<\n TEntity extends Entity,\n>(): UseEntityRecordState<TEntity> {\n return {\n entity: undefined,\n isLoading: false,\n error: undefined,\n };\n}\n\nfunction reducer<TEntity extends Entity>(\n state: UseEntityRecordState<TEntity>,\n action: UseEntityRecordAction<TEntity>,\n): UseEntityRecordState<TEntity> {\n return { ...state, ...action.set };\n}\n\n/**\n * Loads a single entity by id — the read half of an entity form.\n *\n * The id is provided through {@link EntityIdTag} at call time, mirroring how\n * {@link useDataLoading} provides the load request: the use-case stays\n * environment-agnostic and the hook is the only place that knows it is running\n * in React.\n *\n * When `id` is `undefined` the hook does not fetch. That is the create case —\n * there is no record yet — and it is a deliberate no-op rather than an error.\n */\nexport function useEntityRecord<TEntity extends Entity, TContext>({\n uc,\n ctx,\n id,\n}: UseEntityRecordOptions<TEntity, TContext>) {\n const [state, dispatch] = useReducer(\n reducer as (\n state: UseEntityRecordState<TEntity>,\n action: UseEntityRecordAction<TEntity>,\n ) => UseEntityRecordState<TEntity>,\n getInitialState<TEntity>(),\n );\n // Bumped to re-run the fetch on demand.\n const [reloadToken, setReloadToken] = useState(0);\n\n // Callers build `uc`/`ctx` inline, so they are fresh objects on every render.\n // Holding the latest in refs keeps them out of the fetch effect's\n // dependencies: keying the fetch on their identity would re-run it on every\n // render, and its dispatch would render again — an unbreakable loop. The\n // fetch is keyed on `id`/`reloadToken`, which is what actually selects a\n // record.\n const ucRef = useRef(uc);\n const ctxRef = useRef(ctx);\n\n // Refs may not be written during render; this runs before the fetch effect\n // below (effects fire in declaration order), so it always sees the latest.\n useEffect(() => {\n ucRef.current = uc;\n ctxRef.current = ctx;\n });\n\n useEffect(() => {\n if (id == null) {\n return;\n }\n\n // Guards against a slow response for a previous id landing after a newer one.\n let active = true;\n dispatch({ set: { isLoading: true, error: undefined } });\n\n Effect.runPromise(\n Effect.provide(\n ucRef.current,\n ctxRef.current.pipe(Context.add(EntityIdTag, id)),\n ),\n )\n .then(entity => {\n if (active) {\n dispatch({ set: { entity, isLoading: false } });\n }\n })\n .catch((error: unknown) => {\n if (active) {\n dispatch({\n set: { error: error as EntifixFailure, isLoading: false },\n });\n }\n });\n\n return () => {\n active = false;\n };\n }, [id, reloadToken]);\n\n const reload = useCallback(() => setReloadToken(token => token + 1), []);\n\n /** Replaces the held record, e.g. with the entity a save returned. */\n const setEntity = useCallback(\n (entity: TEntity | undefined) => dispatch({ set: { entity } }),\n [],\n );\n\n return { ...state, reload, setEntity };\n}\n"],"names":["EntityIdTag","Context","Effect","useCallback","useEffect","useReducer","useRef","useState","getInitialState","entity","undefined","isLoading","error","reducer","state","action","set","useEntityRecord","uc","ctx","id","dispatch","reloadToken","setReloadToken","ucRef","ctxRef","current","active","runPromise","provide","pipe","add","then","catch","reload","token","setEntity"],"mappings":";AAAA,SAASA,WAAW,QAAQ,oBAAoB;AAEhD,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AACzC,SAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAQ7E,SAASC;IAGP,OAAO;QACLC,QAAQC;QACRC,WAAW;QACXC,OAAOF;IACT;AACF;AAEA,SAASG,QACPC,KAAoC,EACpCC,MAAsC;IAEtC,OAAO,aAAKD,OAAUC,OAAOC,GAAG;AAClC;AAEA;;;;;;;;;;CAUC,GACD,OAAO,SAASC,gBAAkD,EAChEC,EAAE,EACFC,GAAG,EACHC,EAAE,EACwC;IAC1C,MAAM,CAACN,OAAOO,SAAS,GAAGhB,WACxBQ,SAIAL;IAEF,wCAAwC;IACxC,MAAM,CAACc,aAAaC,eAAe,GAAGhB,SAAS;IAE/C,8EAA8E;IAC9E,kEAAkE;IAClE,4EAA4E;IAC5E,yEAAyE;IACzE,yEAAyE;IACzE,UAAU;IACV,MAAMiB,QAAQlB,OAAOY;IACrB,MAAMO,SAASnB,OAAOa;IAEtB,2EAA2E;IAC3E,2EAA2E;IAC3Ef,UAAU;QACRoB,MAAME,OAAO,GAAGR;QAChBO,OAAOC,OAAO,GAAGP;IACnB;IAEAf,UAAU;QACR,IAAIgB,MAAM,MAAM;YACd;QACF;QAEA,8EAA8E;QAC9E,IAAIO,SAAS;QACbN,SAAS;YAAEL,KAAK;gBAAEL,WAAW;gBAAMC,OAAOF;YAAU;QAAE;QAEtDR,OAAO0B,UAAU,CACf1B,OAAO2B,OAAO,CACZL,MAAME,OAAO,EACbD,OAAOC,OAAO,CAACI,IAAI,CAAC7B,QAAQ8B,GAAG,CAAC/B,aAAaoB,OAG9CY,IAAI,CAACvB,CAAAA;YACJ,IAAIkB,QAAQ;gBACVN,SAAS;oBAAEL,KAAK;wBAAEP;wBAAQE,WAAW;oBAAM;gBAAE;YAC/C;QACF,GACCsB,KAAK,CAAC,CAACrB;YACN,IAAIe,QAAQ;gBACVN,SAAS;oBACPL,KAAK;wBAAEJ,OAAOA;wBAAyBD,WAAW;oBAAM;gBAC1D;YACF;QACF;QAEF,OAAO;YACLgB,SAAS;QACX;IACF,GAAG;QAACP;QAAIE;KAAY;IAEpB,MAAMY,SAAS/B,YAAY,IAAMoB,eAAeY,CAAAA,QAASA,QAAQ,IAAI,EAAE;IAEvE,oEAAoE,GACpE,MAAMC,YAAYjC,YAChB,CAACM,SAAgCY,SAAS;YAAEL,KAAK;gBAAEP;YAAO;QAAE,IAC5D,EAAE;IAGJ,OAAO,aAAKK;QAAOoB;QAAQE;;AAC7B"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { EntityIdTag } from '@entifix/business';
|
|
2
|
-
import { Entity, EntityId
|
|
2
|
+
import { type EntifixFailure, Entity, EntityId } from '@entifix/core';
|
|
3
3
|
import { Context, Effect } from 'effect';
|
|
4
4
|
export interface UseEntityRecordState<TEntity extends Entity> {
|
|
5
5
|
entity: TEntity | undefined;
|
|
6
6
|
isLoading: boolean;
|
|
7
|
-
error:
|
|
7
|
+
error: EntifixFailure | undefined;
|
|
8
8
|
}
|
|
9
9
|
export type UseEntityRecordAction<TEntity extends Entity> = {
|
|
10
10
|
set: Partial<UseEntityRecordState<TEntity>>;
|
|
11
11
|
};
|
|
12
12
|
export interface UseEntityRecordOptions<TEntity extends Entity, TContext> {
|
|
13
13
|
/** A get use-case; the hook supplies {@link EntityIdTag}. */
|
|
14
|
-
uc: Effect.Effect<TEntity,
|
|
14
|
+
uc: Effect.Effect<TEntity, EntifixFailure, EntityIdTag | TContext>;
|
|
15
15
|
ctx: Context.Context<TContext>;
|
|
16
16
|
/**
|
|
17
17
|
* The record to load. `undefined` means "nothing to load yet" — the create
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-entity-record.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-record/use-entity-record.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-entity-record.types.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-entity-record/use-entity-record.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,MAAM;IAC1D,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,MAAM,qBAAqB,CAAC,OAAO,SAAS,MAAM,IAAI;IAC1D,GAAG,EAAE,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,WAAW,sBAAsB,CAAC,OAAO,SAAS,MAAM,EAAE,QAAQ;IACtE,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,WAAW,GAAG,QAAQ,CAAC,CAAC;IACnE,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/B;;;OAGG;IACH,EAAE,EAAE,QAAQ,CAAC;CACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/use-entity-record/use-entity-record.types.ts"],"sourcesContent":["import { EntityIdTag } from '@entifix/business';\nimport { Entity, EntityId
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/use-entity-record/use-entity-record.types.ts"],"sourcesContent":["import { EntityIdTag } from '@entifix/business';\nimport { type EntifixFailure, Entity, EntityId } from '@entifix/core';\nimport { Context, Effect } from 'effect';\n\nexport interface UseEntityRecordState<TEntity extends Entity> {\n entity: TEntity | undefined;\n isLoading: boolean;\n error: EntifixFailure | undefined;\n}\n\nexport type UseEntityRecordAction<TEntity extends Entity> = {\n set: Partial<UseEntityRecordState<TEntity>>;\n};\n\nexport interface UseEntityRecordOptions<TEntity extends Entity, TContext> {\n /** A get use-case; the hook supplies {@link EntityIdTag}. */\n uc: Effect.Effect<TEntity, EntifixFailure, EntityIdTag | TContext>;\n ctx: Context.Context<TContext>;\n /**\n * The record to load. `undefined` means \"nothing to load yet\" — the create\n * case — and the hook stays idle rather than fetching.\n */\n id: EntityId;\n}\n"],"names":[],"mappings":"AAcA,WASC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,14 @@ export * from './hooks/use-entity-mutation/index.js';
|
|
|
7
7
|
export * from './hooks/use-entity-record/index.js';
|
|
8
8
|
export * from './hooks/use-entity-use-cases/index.js';
|
|
9
9
|
export * from './hooks/use-wizard/index.js';
|
|
10
|
+
export * from './pending/pending-flow-store.js';
|
|
11
|
+
export * from './pending/use-optimistic-mutation.js';
|
|
12
|
+
export * from './pending/use-pending-flow-settlement.js';
|
|
10
13
|
export * from './query/combine-filtering.js';
|
|
11
14
|
export * from './query/entity-query-key.js';
|
|
12
15
|
export * from './query/query-provider.js';
|
|
16
|
+
export * from './reactive/push-channel.js';
|
|
13
17
|
export * from './reactive/reactive-channel.js';
|
|
18
|
+
export * from './reactive/use-reactive-cache.js';
|
|
14
19
|
export * from './reactive/use-reactive-invalidation.js';
|
|
15
|
-
export * from './reactive/use-transaction-settlement.js';
|
|
16
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,0CAA0C,CAAC;AACzD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,yCAAyC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,11 +7,15 @@ export * from './hooks/use-entity-mutation/index.js';
|
|
|
7
7
|
export * from './hooks/use-entity-record/index.js';
|
|
8
8
|
export * from './hooks/use-entity-use-cases/index.js';
|
|
9
9
|
export * from './hooks/use-wizard/index.js';
|
|
10
|
+
export * from './pending/pending-flow-store.js';
|
|
11
|
+
export * from './pending/use-optimistic-mutation.js';
|
|
12
|
+
export * from './pending/use-pending-flow-settlement.js';
|
|
10
13
|
export * from './query/combine-filtering.js';
|
|
11
14
|
export * from './query/entity-query-key.js';
|
|
12
15
|
export * from './query/query-provider.js';
|
|
16
|
+
export * from './reactive/push-channel.js';
|
|
13
17
|
export * from './reactive/reactive-channel.js';
|
|
18
|
+
export * from './reactive/use-reactive-cache.js';
|
|
14
19
|
export * from './reactive/use-reactive-invalidation.js';
|
|
15
|
-
export * from './reactive/use-transaction-settlement.js';
|
|
16
20
|
|
|
17
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './context/adapters-context/index.js';\nexport * from './hooks/use-data-loading/index.js';\nexport * from './hooks/use-entity-form/index.js';\nexport * from './hooks/use-entity-link-resolver/index.js';\nexport * from './hooks/use-entity-link-source/index.js';\nexport * from './hooks/use-entity-mutation/index.js';\nexport * from './hooks/use-entity-record/index.js';\nexport * from './hooks/use-entity-use-cases/index.js';\nexport * from './hooks/use-wizard/index.js';\nexport * from './query/combine-filtering.js';\nexport * from './query/entity-query-key.js';\nexport * from './query/query-provider.js';\nexport * from './reactive/reactive-channel.js';\nexport * from './reactive/use-reactive-
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './context/adapters-context/index.js';\nexport * from './hooks/use-data-loading/index.js';\nexport * from './hooks/use-entity-form/index.js';\nexport * from './hooks/use-entity-link-resolver/index.js';\nexport * from './hooks/use-entity-link-source/index.js';\nexport * from './hooks/use-entity-mutation/index.js';\nexport * from './hooks/use-entity-record/index.js';\nexport * from './hooks/use-entity-use-cases/index.js';\nexport * from './hooks/use-wizard/index.js';\nexport * from './pending/pending-flow-store.js';\nexport * from './pending/use-optimistic-mutation.js';\nexport * from './pending/use-pending-flow-settlement.js';\nexport * from './query/combine-filtering.js';\nexport * from './query/entity-query-key.js';\nexport * from './query/query-provider.js';\nexport * from './reactive/push-channel.js';\nexport * from './reactive/reactive-channel.js';\nexport * from './reactive/use-reactive-cache.js';\nexport * from './reactive/use-reactive-invalidation.js';\n"],"names":[],"mappings":"AAAA,cAAc,sCAAsC;AACpD,cAAc,oCAAoC;AAClD,cAAc,mCAAmC;AACjD,cAAc,4CAA4C;AAC1D,cAAc,0CAA0C;AACxD,cAAc,uCAAuC;AACrD,cAAc,qCAAqC;AACnD,cAAc,wCAAwC;AACtD,cAAc,8BAA8B;AAC5C,cAAc,kCAAkC;AAChD,cAAc,uCAAuC;AACrD,cAAc,2CAA2C;AACzD,cAAc,+BAA+B;AAC7C,cAAc,8BAA8B;AAC5C,cAAc,4BAA4B;AAC1C,cAAc,6BAA6B;AAC3C,cAAc,iCAAiC;AAC/C,cAAc,mCAAmC;AACjD,cAAc,0CAA0C"}
|