@fougere/admin 0.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/dist/dashboard.d.ts +74 -0
  4. package/dist/dashboard.d.ts.map +1 -0
  5. package/dist/dashboard.js +334 -0
  6. package/dist/dashboard.js.map +1 -0
  7. package/dist/extensions.d.ts +27 -0
  8. package/dist/extensions.d.ts.map +1 -0
  9. package/dist/extensions.js +74 -0
  10. package/dist/extensions.js.map +1 -0
  11. package/dist/facets.d.ts +60 -0
  12. package/dist/facets.d.ts.map +1 -0
  13. package/dist/facets.js +39 -0
  14. package/dist/facets.js.map +1 -0
  15. package/dist/index.d.ts +19 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +19 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/provider.d.ts +163 -0
  20. package/dist/provider.d.ts.map +1 -0
  21. package/dist/provider.js +205 -0
  22. package/dist/provider.js.map +1 -0
  23. package/dist/react.d.ts +70 -0
  24. package/dist/react.d.ts.map +1 -0
  25. package/dist/react.js +235 -0
  26. package/dist/react.js.map +1 -0
  27. package/dist/resources.d.ts +69 -0
  28. package/dist/resources.d.ts.map +1 -0
  29. package/dist/resources.js +92 -0
  30. package/dist/resources.js.map +1 -0
  31. package/dist/runtime.d.ts +22 -0
  32. package/dist/runtime.d.ts.map +1 -0
  33. package/dist/runtime.js +36 -0
  34. package/dist/runtime.js.map +1 -0
  35. package/dist/theme.d.ts +10 -0
  36. package/dist/theme.d.ts.map +1 -0
  37. package/dist/theme.js +419 -0
  38. package/dist/theme.js.map +1 -0
  39. package/dist/topology-page.d.ts +8 -0
  40. package/dist/topology-page.d.ts.map +1 -0
  41. package/dist/topology-page.js +69 -0
  42. package/dist/topology-page.js.map +1 -0
  43. package/dist/topology.d.ts +46 -0
  44. package/dist/topology.d.ts.map +1 -0
  45. package/dist/topology.js +58 -0
  46. package/dist/topology.js.map +1 -0
  47. package/package.json +76 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * How the system is arranged, as the app itself reports it.
3
+ *
4
+ * The card answers what a process HOSTS; this answers what SHAPE it is in — which fronds
5
+ * run here, which answered from somewhere else, and who called whom. It is served by
6
+ * `@fougere/observability` on `rpc.topology`, so absence is an ordinary answer: an app
7
+ * that never installed the package has no topology to publish, and says so by refusing
8
+ * the op. Nothing here is declared — a frond is remote because it answered a call nobody
9
+ * hosts, never because a config line said so.
10
+ */
11
+ import { CALL_ENDPOINT, fetcher as browserFetcher, sendCall, } from '@fougere/app/client';
12
+ import { EMPTY_INVOCATION, ErrorCode, } from '@fougere/core/contract';
13
+ /**
14
+ * The report, or `undefined` when the app serves no topology at all.
15
+ *
16
+ * The refusal is DISTINGUISHED, not swallowed: a `NOT_FOUND` on the op is the package not
17
+ * being wired — something the panel can explain — while anything else is a real failure
18
+ * and stays a failure. One reserved op that is absent must not read as an app that is down.
19
+ */
20
+ export async function fetchTopology(endpoint = CALL_ENDPOINT, fetcher = browserFetcher) {
21
+ try {
22
+ return await sendCall(fetcher, { entity: 'rpc', op: 'topology' }, EMPTY_INVOCATION, endpoint);
23
+ }
24
+ catch (error) {
25
+ if (error?.code === ErrorCode.NOT_FOUND)
26
+ return undefined;
27
+ throw error;
28
+ }
29
+ }
30
+ /**
31
+ * The report read as a graph, local fronds first.
32
+ *
33
+ * Two passes over `edges` rather than one index per direction: a topology is bounded by
34
+ * fronds², so the whole thing is smaller than one page of rows and an index would be a
35
+ * second structure to keep true.
36
+ */
37
+ export function nodesOf(report) {
38
+ const order = { local: 0, remote: 1 };
39
+ return [...report.fronds]
40
+ .sort((a, b) => order[a.placement] - order[b.placement] || a.frond.localeCompare(b.frond))
41
+ .map((frond) => ({
42
+ ...frond,
43
+ calls: report.edges.filter((edge) => edge.from === frond.frond),
44
+ calledBy: report.edges.filter((edge) => edge.to === frond.frond),
45
+ }));
46
+ }
47
+ /**
48
+ * A frond this process called that publishes nothing of its own shape.
49
+ *
50
+ * The honest reading of `entities: 0, doors: 0` on a remote: its shape is published by the
51
+ * process that owns it, under its own service name — so a panel pointed here can say the
52
+ * frond is reachable and cannot say what it holds. Worth naming rather than drawing as an
53
+ * empty frond, which reads as a frond with nothing in it.
54
+ */
55
+ export function isOpaque(node) {
56
+ return node.placement === 'remote' && node.entities === 0 && node.doors === 0;
57
+ }
58
+ //# sourceMappingURL=topology.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topology.js","sourceRoot":"","sources":["../src/topology.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,aAAa,EACb,OAAO,IAAI,cAAc,EACzB,QAAQ,GAET,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gBAAgB,EAChB,SAAS,GAIV,MAAM,wBAAwB,CAAC;AAIhC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAQ,GAAG,aAAa,EACxB,OAAO,GAAY,cAAc;IAEjC,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CACnB,OAAO,EACP,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,EACjC,gBAAgB,EAChB,QAAQ,CACS,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA4B,EAAE,IAAI,KAAK,SAAS,CAAC,SAAS;YAAE,OAAO,SAAS,CAAC;QAClF,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAUD;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,MAAsB;IAC5C,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACtC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;SACtB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SACzF,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACf,GAAG,KAAK;QACR,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,CAAC;QAC/D,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,KAAK,CAAC;KACjE,CAAC,CAAC,CAAC;AACR,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAoB;IAC3C,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAChF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@fougere/admin",
3
+ "version": "0.3.0-alpha.0",
4
+ "description": "A back-office derived from what the app already says it hosts — a react-admin DataProvider over the Fougere wire.",
5
+ "keywords": [
6
+ "fougere",
7
+ "react-admin",
8
+ "admin",
9
+ "back-office",
10
+ "typescript",
11
+ "crud"
12
+ ],
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/chok/fougere.git",
17
+ "directory": "packages/app/admin"
18
+ },
19
+ "type": "module",
20
+ "main": "dist/index.js",
21
+ "types": "dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js"
26
+ },
27
+ "./react": {
28
+ "types": "./dist/react.d.ts",
29
+ "import": "./dist/react.js"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "dependencies": {
36
+ "@fougere/app": "0.3.0-alpha.0",
37
+ "@fougere/core": "0.3.0-alpha.0",
38
+ "@fougere/schema": "0.3.0-alpha.0"
39
+ },
40
+ "devDependencies": {
41
+ "@mui/material": "^9.3.1",
42
+ "@types/react": "^19.2.2",
43
+ "react": "19.2.8",
44
+ "react-admin": "^5.15.1",
45
+ "react-router-dom": "^7.9.6",
46
+ "vitest": "^4.1.0"
47
+ },
48
+ "peerDependencies": {
49
+ "@mui/material": "^5.16.12 || ^6.0.0 || ^7.0.0 || ^9.0.0",
50
+ "react": "^18.3.0 || ^19.0.0",
51
+ "react-admin": "^5.0.0",
52
+ "react-router-dom": "^6.22.0 || ^7.0.0"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "@mui/material": {
56
+ "optional": true
57
+ },
58
+ "react": {
59
+ "optional": true
60
+ },
61
+ "react-admin": {
62
+ "optional": true
63
+ },
64
+ "react-router-dom": {
65
+ "optional": true
66
+ }
67
+ },
68
+ "publishConfig": {
69
+ "access": "public"
70
+ },
71
+ "scripts": {
72
+ "build": "rm -rf dist && tsc",
73
+ "test": "vitest run",
74
+ "typecheck": "tsc --noEmit -p tsconfig.test.json"
75
+ }
76
+ }