@metaobjectsdev/tanstack 1.0.0-rc.4 → 1.0.0-rc.5
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/entity-fetcher.d.ts +36 -2
- package/dist/entity-fetcher.d.ts.map +1 -1
- package/dist/entity-fetcher.js +37 -3
- package/dist/entity-fetcher.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/entity-fetcher.tsx +38 -3
- package/src/index.ts +6 -1
package/dist/entity-fetcher.d.ts
CHANGED
|
@@ -22,6 +22,40 @@ export interface EntityFetcherProviderProps {
|
|
|
22
22
|
}
|
|
23
23
|
/** Wrap your app (or admin subtree) to supply a fetcher to generated hooks. */
|
|
24
24
|
export declare function EntityFetcherProvider({ fetcher, baseUrl, children, }: EntityFetcherProviderProps): import("react").JSX.Element;
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The fetcher from context, already bound to `baseUrl`.
|
|
27
|
+
*
|
|
28
|
+
* **Every path you hand this is rewritten**: `baseUrl` is prefixed onto it. That
|
|
29
|
+
* is exactly right for the ENTITY-RELATIVE paths generated hooks emit
|
|
30
|
+
* (`${Entity.$path}/…`), and it is the reason for the name — the argument is an
|
|
31
|
+
* entity path, not an application path.
|
|
32
|
+
*
|
|
33
|
+
* It is NOT a general-purpose `fetch`. Handing it an absolute app route silently
|
|
34
|
+
* relocates the request: with `baseUrl="/api"`, `/internal/leads/1/notes` becomes
|
|
35
|
+
* `/api/internal/leads/1/notes`, and an already-prefixed `/api/decisions/1`
|
|
36
|
+
* becomes `/api/api/decisions/1`. Both are type-correct, so nothing in the
|
|
37
|
+
* compiler, the unit suite or `meta verify` can see them — only a request that
|
|
38
|
+
* 404s at runtime. An adopter who had followed the "the fetcher is the ONE place
|
|
39
|
+
* base-URL policy lives" advice and shared this seam with hand-written call sites
|
|
40
|
+
* lost ten write actions this way, silently.
|
|
41
|
+
*
|
|
42
|
+
* For non-entity paths, call your own transport directly, or compose `joinBaseUrl`
|
|
43
|
+
* from `@metaobjectsdev/runtime-web` yourself where you DO want the prefix.
|
|
44
|
+
*
|
|
45
|
+
* Throws if no `<EntityFetcherProvider>` is above it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useEntityPathFetcher(): EntityFetcher;
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Renamed to {@link useEntityPathFetcher}. Identical behaviour — the
|
|
50
|
+
* new name says what the hook does to the path it is given, which is what the old
|
|
51
|
+
* name hid: before 1.0 the provider passed its fetcher through unchanged, so
|
|
52
|
+
* "entity fetcher" was an accurate description of a hook that rewrote nothing.
|
|
53
|
+
* 1.0 made it BIND the fetcher to `baseUrl` (generated hooks stopped composing
|
|
54
|
+
* `$apiPrefix` themselves), and the name did not move with the behaviour.
|
|
55
|
+
*
|
|
56
|
+
* This alias will be removed in a future major. If you share this seam with
|
|
57
|
+
* hand-written non-entity call sites, read {@link useEntityPathFetcher} first —
|
|
58
|
+
* those paths are being rewritten.
|
|
59
|
+
*/
|
|
60
|
+
export declare const useEntityFetcher: typeof useEntityPathFetcher;
|
|
27
61
|
//# sourceMappingURL=entity-fetcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-fetcher.d.ts","sourceRoot":"","sources":["../src/entity-fetcher.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI9E,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,OAAO,EAAE,aAAa,CAAC;IACvB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,0BAA0B,+BAU5B;AAED
|
|
1
|
+
{"version":3,"file":"entity-fetcher.d.ts","sourceRoot":"","sources":["../src/entity-fetcher.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI9E,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,OAAO,EAAE,aAAa,CAAC;IACvB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,0BAA0B,+BAU5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,oBAAoB,IAAI,aAAa,CASpD;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,6BAAuB,CAAC"}
|
package/dist/entity-fetcher.js
CHANGED
|
@@ -9,13 +9,47 @@ export function EntityFetcherProvider({ fetcher, baseUrl, children, }) {
|
|
|
9
9
|
const value = useMemo(() => ((path, init) => fetcher(joinBaseUrl(baseUrl, path), init)), [fetcher, baseUrl]);
|
|
10
10
|
return _jsx(EntityFetcherContext.Provider, { value: value, children: children });
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The fetcher from context, already bound to `baseUrl`.
|
|
14
|
+
*
|
|
15
|
+
* **Every path you hand this is rewritten**: `baseUrl` is prefixed onto it. That
|
|
16
|
+
* is exactly right for the ENTITY-RELATIVE paths generated hooks emit
|
|
17
|
+
* (`${Entity.$path}/…`), and it is the reason for the name — the argument is an
|
|
18
|
+
* entity path, not an application path.
|
|
19
|
+
*
|
|
20
|
+
* It is NOT a general-purpose `fetch`. Handing it an absolute app route silently
|
|
21
|
+
* relocates the request: with `baseUrl="/api"`, `/internal/leads/1/notes` becomes
|
|
22
|
+
* `/api/internal/leads/1/notes`, and an already-prefixed `/api/decisions/1`
|
|
23
|
+
* becomes `/api/api/decisions/1`. Both are type-correct, so nothing in the
|
|
24
|
+
* compiler, the unit suite or `meta verify` can see them — only a request that
|
|
25
|
+
* 404s at runtime. An adopter who had followed the "the fetcher is the ONE place
|
|
26
|
+
* base-URL policy lives" advice and shared this seam with hand-written call sites
|
|
27
|
+
* lost ten write actions this way, silently.
|
|
28
|
+
*
|
|
29
|
+
* For non-entity paths, call your own transport directly, or compose `joinBaseUrl`
|
|
30
|
+
* from `@metaobjectsdev/runtime-web` yourself where you DO want the prefix.
|
|
31
|
+
*
|
|
32
|
+
* Throws if no `<EntityFetcherProvider>` is above it.
|
|
33
|
+
*/
|
|
34
|
+
export function useEntityPathFetcher() {
|
|
14
35
|
const fetcher = useContext(EntityFetcherContext);
|
|
15
36
|
if (!fetcher) {
|
|
16
|
-
throw new Error("
|
|
37
|
+
throw new Error("useEntityPathFetcher() called outside <EntityFetcherProvider>. " +
|
|
17
38
|
"Wrap your app (or the relevant subtree) with EntityFetcherProvider fetcher={...}.");
|
|
18
39
|
}
|
|
19
40
|
return fetcher;
|
|
20
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Renamed to {@link useEntityPathFetcher}. Identical behaviour — the
|
|
44
|
+
* new name says what the hook does to the path it is given, which is what the old
|
|
45
|
+
* name hid: before 1.0 the provider passed its fetcher through unchanged, so
|
|
46
|
+
* "entity fetcher" was an accurate description of a hook that rewrote nothing.
|
|
47
|
+
* 1.0 made it BIND the fetcher to `baseUrl` (generated hooks stopped composing
|
|
48
|
+
* `$apiPrefix` themselves), and the name did not move with the behaviour.
|
|
49
|
+
*
|
|
50
|
+
* This alias will be removed in a future major. If you share this seam with
|
|
51
|
+
* hand-written non-entity call sites, read {@link useEntityPathFetcher} first —
|
|
52
|
+
* those paths are being rewritten.
|
|
53
|
+
*/
|
|
54
|
+
export const useEntityFetcher = useEntityPathFetcher;
|
|
21
55
|
//# sourceMappingURL=entity-fetcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-fetcher.js","sourceRoot":"","sources":["../src/entity-fetcher.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAsB,MAAM,6BAA6B,CAAC;AAE9E,MAAM,oBAAoB,GAAG,aAAa,CAAuB,IAAI,CAAC,CAAC;AAuBvE,+EAA+E;AAC/E,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,OAAO,EACP,QAAQ,GACmB;IAC3B,sFAAsF;IACtF,oFAAoF;IACpF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CACH,CAAC,CAAK,IAAY,EAAE,IAAkB,EAAE,EAAE,CACxC,OAAO,CAAI,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAkB,EAClE,CAAC,OAAO,EAAE,OAAO,CAAC,CACnB,CAAC;IACF,OAAO,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAiC,CAAC;AACjG,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"entity-fetcher.js","sourceRoot":"","sources":["../src/entity-fetcher.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAsB,MAAM,6BAA6B,CAAC;AAE9E,MAAM,oBAAoB,GAAG,aAAa,CAAuB,IAAI,CAAC,CAAC;AAuBvE,+EAA+E;AAC/E,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,OAAO,EACP,QAAQ,GACmB;IAC3B,sFAAsF;IACtF,oFAAoF;IACpF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CACH,CAAC,CAAK,IAAY,EAAE,IAAkB,EAAE,EAAE,CACxC,OAAO,CAAI,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAkB,EAClE,CAAC,OAAO,EAAE,OAAO,CAAC,CACnB,CAAC;IACF,OAAO,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAiC,CAAC;AACjG,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,iEAAiE;YAC/D,mFAAmF,CACtF,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export { EntityFetcherProvider,
|
|
1
|
+
export { EntityFetcherProvider, useEntityPathFetcher,
|
|
2
|
+
/** @deprecated Renamed to `useEntityPathFetcher`. */
|
|
3
|
+
useEntityFetcher, } from "./entity-fetcher.js";
|
|
2
4
|
export type { EntityFetcherProviderProps } from "./entity-fetcher.js";
|
|
3
5
|
export type { EntityFetcher, GridConfig } from "@metaobjectsdev/runtime-web";
|
|
4
6
|
export { defaultCellRenderers, imageCell, type CellRenderer, type ImageCellOptions, } from "./cell-renderers.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,oBAAoB;AACpB,qDAAqD;AACrD,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EACL,oBAAoB,EACpB,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,KAAK,yBAAyB,GAC/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Public API surface for @metaobjectsdev/tanstack.
|
|
2
|
-
export { EntityFetcherProvider,
|
|
2
|
+
export { EntityFetcherProvider, useEntityPathFetcher,
|
|
3
|
+
/** @deprecated Renamed to `useEntityPathFetcher`. */
|
|
4
|
+
useEntityFetcher, } from "./entity-fetcher.js";
|
|
3
5
|
export { defaultCellRenderers, imageCell, } from "./cell-renderers.js";
|
|
4
6
|
export { CellRendererProvider, useCellRenderers, } from "./cell-renderer-provider.js";
|
|
5
7
|
export { EntityGrid } from "./entity-grid.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,OAAO,EACL,qBAAqB,EACrB,oBAAoB;AACpB,qDAAqD;AACrD,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,oBAAoB,EACpB,SAAS,GAGV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,gBAAgB,GAEjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAA8C,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metaobjectsdev/tanstack",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.5",
|
|
4
4
|
"description": "TanStack runtime for metaobjects: EntityFetcherProvider, EntityGrid, default cell renderers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@metaobjectsdev/runtime-web": "1.0.0-rc.
|
|
48
|
+
"@metaobjectsdev/runtime-web": "1.0.0-rc.5"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@tanstack/react-query": "^5.90.0",
|
package/src/entity-fetcher.tsx
CHANGED
|
@@ -41,14 +41,49 @@ export function EntityFetcherProvider({
|
|
|
41
41
|
return <EntityFetcherContext.Provider value={value}>{children}</EntityFetcherContext.Provider>;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The fetcher from context, already bound to `baseUrl`.
|
|
46
|
+
*
|
|
47
|
+
* **Every path you hand this is rewritten**: `baseUrl` is prefixed onto it. That
|
|
48
|
+
* is exactly right for the ENTITY-RELATIVE paths generated hooks emit
|
|
49
|
+
* (`${Entity.$path}/…`), and it is the reason for the name — the argument is an
|
|
50
|
+
* entity path, not an application path.
|
|
51
|
+
*
|
|
52
|
+
* It is NOT a general-purpose `fetch`. Handing it an absolute app route silently
|
|
53
|
+
* relocates the request: with `baseUrl="/api"`, `/internal/leads/1/notes` becomes
|
|
54
|
+
* `/api/internal/leads/1/notes`, and an already-prefixed `/api/decisions/1`
|
|
55
|
+
* becomes `/api/api/decisions/1`. Both are type-correct, so nothing in the
|
|
56
|
+
* compiler, the unit suite or `meta verify` can see them — only a request that
|
|
57
|
+
* 404s at runtime. An adopter who had followed the "the fetcher is the ONE place
|
|
58
|
+
* base-URL policy lives" advice and shared this seam with hand-written call sites
|
|
59
|
+
* lost ten write actions this way, silently.
|
|
60
|
+
*
|
|
61
|
+
* For non-entity paths, call your own transport directly, or compose `joinBaseUrl`
|
|
62
|
+
* from `@metaobjectsdev/runtime-web` yourself where you DO want the prefix.
|
|
63
|
+
*
|
|
64
|
+
* Throws if no `<EntityFetcherProvider>` is above it.
|
|
65
|
+
*/
|
|
66
|
+
export function useEntityPathFetcher(): EntityFetcher {
|
|
46
67
|
const fetcher = useContext(EntityFetcherContext);
|
|
47
68
|
if (!fetcher) {
|
|
48
69
|
throw new Error(
|
|
49
|
-
"
|
|
70
|
+
"useEntityPathFetcher() called outside <EntityFetcherProvider>. " +
|
|
50
71
|
"Wrap your app (or the relevant subtree) with EntityFetcherProvider fetcher={...}.",
|
|
51
72
|
);
|
|
52
73
|
}
|
|
53
74
|
return fetcher;
|
|
54
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated Renamed to {@link useEntityPathFetcher}. Identical behaviour — the
|
|
79
|
+
* new name says what the hook does to the path it is given, which is what the old
|
|
80
|
+
* name hid: before 1.0 the provider passed its fetcher through unchanged, so
|
|
81
|
+
* "entity fetcher" was an accurate description of a hook that rewrote nothing.
|
|
82
|
+
* 1.0 made it BIND the fetcher to `baseUrl` (generated hooks stopped composing
|
|
83
|
+
* `$apiPrefix` themselves), and the name did not move with the behaviour.
|
|
84
|
+
*
|
|
85
|
+
* This alias will be removed in a future major. If you share this seam with
|
|
86
|
+
* hand-written non-entity call sites, read {@link useEntityPathFetcher} first —
|
|
87
|
+
* those paths are being rewritten.
|
|
88
|
+
*/
|
|
89
|
+
export const useEntityFetcher = useEntityPathFetcher;
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// Public API surface for @metaobjectsdev/tanstack.
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
EntityFetcherProvider,
|
|
4
|
+
useEntityPathFetcher,
|
|
5
|
+
/** @deprecated Renamed to `useEntityPathFetcher`. */
|
|
6
|
+
useEntityFetcher,
|
|
7
|
+
} from "./entity-fetcher.js";
|
|
3
8
|
export type { EntityFetcherProviderProps } from "./entity-fetcher.js";
|
|
4
9
|
export type { EntityFetcher, GridConfig } from "@metaobjectsdev/runtime-web";
|
|
5
10
|
export {
|