@dudousxd/nestjs-catalog-react 0.1.0 → 0.2.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.
@@ -10,6 +10,26 @@ import { Tooltip, TooltipProvider } from './ui/tooltip';
10
10
  const MUTED = 'text-zinc-400 dark:text-zinc-500';
11
11
  const RULE = 'border-zinc-200 dark:border-zinc-800';
12
12
  const PANEL = 'bg-white dark:bg-zinc-900';
13
+ function PeopleSearch({ value, onChange, }) {
14
+ return (_jsxs("label", { className: "mt-3 block", children: [_jsx("span", { className: "sr-only", children: "Search people" }), _jsx("input", { type: "search", value: value, onChange: (event) => onChange(event.target.value), placeholder: "Search by name or email", className: cn('w-full rounded-md border px-3 py-1.5 text-sm', RULE, PANEL, 'placeholder:text-zinc-400 dark:placeholder:text-zinc-600') })] }));
15
+ }
16
+ /**
17
+ * What the page is NOT showing.
18
+ *
19
+ * Rendered whenever there is a page at all, not only when there is more than
20
+ * one: a bounded list that looks complete is the failure worth spending a line
21
+ * of UI on, because an operator who reads it as complete concludes somebody has
22
+ * no access when they were merely on the next page.
23
+ */
24
+ function PageBar({ page, onOffset, busy, }) {
25
+ const shown = page.people.length;
26
+ const first = page.total === 0 ? 0 : page.offset + 1;
27
+ const last = page.offset + shown;
28
+ const hasMore = last < page.total;
29
+ return (_jsxs("div", { className: cn('mt-3 flex items-center justify-between text-xs', MUTED), children: [_jsx("span", { children: page.total === 0
30
+ ? 'No people'
31
+ : `Showing ${first}–${last} of ${page.total.toLocaleString()}` }), (page.offset > 0 || hasMore) && (_jsxs("span", { className: "flex gap-2", children: [_jsx("button", { type: "button", disabled: page.offset === 0 || busy, onClick: () => onOffset(Math.max(0, page.offset - page.limit)), className: "disabled:opacity-40", children: "Previous" }), _jsx("button", { type: "button", disabled: !hasMore || busy, onClick: () => onOffset(page.offset + page.limit), className: "disabled:opacity-40", children: "Next" })] }))] }));
32
+ }
13
33
  /**
14
34
  * One page answering the two questions a shared catalog creates: which
15
35
  * application is allowed to touch what, and which person is behind it.
@@ -27,15 +47,31 @@ export function AccessConsole({ identity, onSignOut, signOutPending, canAddPeopl
27
47
  // from here. Long enough that moving between tabs is instant.
28
48
  staleTime: 30_000,
29
49
  });
50
+ // Paged, because a host's user table is its whole directory: this screen is
51
+ // embedded in applications with thousands of employees, and the endpoint caps
52
+ // what it will return regardless of what is asked for. The key carries the
53
+ // query so a search does not read a previous search's page from the cache.
54
+ const [search, setSearch] = useState('');
55
+ const [offset, setOffset] = useState(0);
30
56
  const people = useQuery({
31
- queryKey: catalogQueryKeys.people,
32
- queryFn: () => client.listPeople(),
57
+ queryKey: [...catalogQueryKeys.people, { search, offset }],
58
+ queryFn: () => client.listPeople({ ...(search ? { search } : {}), offset }),
33
59
  staleTime: 30_000,
60
+ // The count and the page it describes must not be shown apart. Without
61
+ // this, typing into the search blanks the list to a spinner and then shows
62
+ // a total for a different query for one frame.
63
+ placeholderData: (previous) => previous,
34
64
  });
35
65
  const mayAdminister = canAddPeople ?? identity?.scopes.includes('catalog:admin') ?? false;
36
- return (_jsx(TooltipProvider, { children: _jsxs("div", { className: "mx-auto max-w-5xl px-8 py-8", children: [_jsx("p", { className: cn('font-mono text-[11px] uppercase tracking-[0.18em]', MUTED), children: eyebrow }), _jsx("h1", { className: "mt-1 text-2xl font-semibold tracking-tight", children: title }), _jsx("p", { className: "mt-1 max-w-2xl text-sm text-zinc-500 dark:text-zinc-400", children: intro }), identity && (_jsx(YouPanel, { identity: identity, onSignOut: onSignOut, signOutPending: signOutPending })), _jsxs(Section, { title: "People", note: "Sign in to the console. Capped by the application they sign in through.", children: [mayAdminister && _jsx(AddPerson, {}), people.isPending && _jsx(Placeholder, { children: "Reading people\u2026" }), people.isError && (_jsx(Failed, { message: people.error instanceof Error
66
+ return (_jsx(TooltipProvider, { children: _jsxs("div", { className: "mx-auto max-w-5xl px-8 py-8", children: [_jsx("p", { className: cn('font-mono text-[11px] uppercase tracking-[0.18em]', MUTED), children: eyebrow }), _jsx("h1", { className: "mt-1 text-2xl font-semibold tracking-tight", children: title }), _jsx("p", { className: "mt-1 max-w-2xl text-sm text-zinc-500 dark:text-zinc-400", children: intro }), identity && (_jsx(YouPanel, { identity: identity, onSignOut: onSignOut, signOutPending: signOutPending })), _jsxs(Section, { title: "People", note: "Sign in to the console. Capped by the application they sign in through.", children: [_jsx(PeopleSearch, { value: search, onChange: (next) => {
67
+ setSearch(next);
68
+ // Back to the first page. Staying on page 3 of the previous
69
+ // search shows an empty list for a search that has matches.
70
+ setOffset(0);
71
+ } }), mayAdminister && _jsx(AddPerson, {}), people.isPending && _jsx(Placeholder, { children: "Reading people\u2026" }), people.isError && (_jsx(Failed, { message: people.error instanceof Error
37
72
  ? people.error.message
38
- : 'Could not read the people list.', onRetry: () => people.refetch() })), people.data?.map((person) => (_jsx(PersonCard, { person: person }, person.email))), people.data?.length === 0 && (_jsx(Placeholder, { children: "Nobody can sign in yet. Seed the first administrator from the environment before anybody can reach this console as a person." }))] }), _jsxs(Section, { title: "Applications", note: "Provisioned by an operator \u2014 a console that could hand grants out is one that stops leaving a trail.", children: [applications.isPending && _jsx(Placeholder, { children: "Reading applications\u2026" }), applications.isError && (_jsx(Failed, { message: applications.error instanceof Error
73
+ : 'Could not read the people list.', onRetry: () => people.refetch() })), people.data?.people.map((person) => (_jsx(PersonCard, { person: person }, person.email))), people.data?.people.length === 0 &&
74
+ (search ? (_jsxs(Placeholder, { children: ["Nobody matches \u201C", search, "\u201D."] })) : (_jsx(Placeholder, { children: "Nobody can sign in yet. Seed the first administrator from the environment before anybody can reach this console as a person." }))), people.data && (_jsx(PageBar, { page: people.data, onOffset: setOffset, busy: people.isFetching }))] }), _jsxs(Section, { title: "Applications", note: "Provisioned by an operator \u2014 a console that could hand grants out is one that stops leaving a trail.", children: [applications.isPending && _jsx(Placeholder, { children: "Reading applications\u2026" }), applications.isError && (_jsx(Failed, { message: applications.error instanceof Error
39
75
  ? applications.error.message
40
76
  : 'Could not read the application list.', onRetry: () => applications.refetch() })), applications.data?.map((principal) => (_jsx(PrincipalCard, { principal: principal }, principal.id))), applications.data?.length === 0 && (_jsx(Placeholder, { children: "No applications are provisioned." }))] })] }) }));
41
77
  }
package/dist/context.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { CatalogAuditEvent, CatalogConnection, CatalogConnector, CatalogObjectPage, CatalogQueryRelation, CatalogQueryResult, CatalogSnapshot, CatalogTraceList, CatalogTransform, ConnectionCheck, ConnectorRun, Dashboard, DashboardCard, ObjectQueryParams, PropertyPatch, SaveQueryInput, SavedQuery, TraceQuery, TransformLanguage, TransformResult, TypePatch } from '@dudousxd/nestjs-catalog/client';
2
2
  import { type ReactNode } from 'react';
3
+ import { type PeopleQuery } from './routes';
3
4
  import type { CatalogWorkflow, WorkflowDurability, WorkflowInput, WorkflowRun } from './workflow/model';
4
5
  /**
5
6
  * How these screens talk to the server.
@@ -125,6 +126,13 @@ export interface CatalogPrincipalSummary {
125
126
  lastSeenAt: string | null;
126
127
  ownedTypes: string[];
127
128
  }
129
+ export interface CatalogPeoplePage {
130
+ people: CatalogPersonSummary[];
131
+ /** How many match, ignoring the page. */
132
+ total: number;
133
+ limit: number;
134
+ offset: number;
135
+ }
128
136
  /** A person: signs in, and acts through an application that caps them. */
129
137
  export interface CatalogPersonSummary {
130
138
  email: string;
@@ -299,7 +307,12 @@ export interface CatalogClient {
299
307
  * becomes a button it stops leaving a reviewable trail.
300
308
  */
301
309
  listPrincipals(): Promise<CatalogPrincipalSummary[]>;
302
- listPeople(): Promise<CatalogPersonSummary[]>;
310
+ /**
311
+ * A PAGE, not the list. The server bounds it whatever is asked for, so a
312
+ * caller that ignores `total` is a screen that silently under-reports who has
313
+ * access — which reads as "this person has none" rather than "look further".
314
+ */
315
+ listPeople(query?: PeopleQuery): Promise<CatalogPeoplePage>;
303
316
  upsertPerson(input: PersonInput): Promise<PersonUpsertResult>;
304
317
  }
305
318
  export interface CatalogProviderProps {
package/dist/context.js CHANGED
@@ -56,7 +56,7 @@ export function CatalogProvider({ transport, pipelineBasePath = DEFAULT_PIPELINE
56
56
  deleteWorkflow: (id) => transport.delete(pipeline.workflow(id)),
57
57
  runWorkflow: (id) => transport.post(pipeline.runWorkflow(id), {}),
58
58
  listPrincipals: () => transport.get(access.principals()),
59
- listPeople: () => transport.get(access.people()),
59
+ listPeople: (query) => transport.get(access.people(query)),
60
60
  upsertPerson: (input) => transport.post(access.people(), input),
61
61
  };
62
62
  }, [transport, pipelineBasePath, accessBasePath]);
package/dist/routes.d.ts CHANGED
@@ -64,7 +64,18 @@ export interface PipelineRoutes {
64
64
  export declare function pipelineRoutes(basePath?: string): PipelineRoutes;
65
65
  export interface AccessRoutes {
66
66
  principals(): string;
67
- /** GET lists people; POST creates or updates one. */
68
- people(): string;
67
+ /**
68
+ * GET lists people; POST creates or updates one.
69
+ *
70
+ * The GET is PAGED — a host's user table is its whole directory, and the
71
+ * server caps whatever is asked for. Omitting the query is asking for the
72
+ * server's default page, never for all of them.
73
+ */
74
+ people(query?: PeopleQuery): string;
75
+ }
76
+ export interface PeopleQuery {
77
+ search?: string;
78
+ limit?: number;
79
+ offset?: number;
69
80
  }
70
81
  export declare function accessRoutes(basePath?: string): AccessRoutes;
package/dist/routes.js CHANGED
@@ -68,6 +68,16 @@ export function accessRoutes(basePath = DEFAULT_ACCESS_BASE_PATH) {
68
68
  const base = normalise(basePath);
69
69
  return {
70
70
  principals: () => `${base}/principals`,
71
- people: () => `${base}/people`,
71
+ people: (query) => {
72
+ const params = new URLSearchParams();
73
+ if (query?.search)
74
+ params.set('search', query.search);
75
+ if (query?.limit !== undefined)
76
+ params.set('limit', String(query.limit));
77
+ if (query?.offset !== undefined)
78
+ params.set('offset', String(query.offset));
79
+ const search = params.toString();
80
+ return search ? `${base}/people?${search}` : `${base}/people`;
81
+ },
72
82
  };
73
83
  }
@@ -22,7 +22,9 @@ import { type WorkflowEdge, type WorkflowIssueCode, type WorkflowNode } from '@d
22
22
  * - **A sink with no object type.** Core's type requires `targetType` on a sink
23
23
  * but its validator never checks that the string is non-empty, and the server
24
24
  * refuses one that is. The check is additive, not contradictory.
25
- * - **Two sinks writing the same type.** Core reports it as `duplicate-sink-type`.
25
+ *
26
+ * Two sinks writing the same type is NOT in that list: core reports it itself,
27
+ * as `duplicate-sink-type`, and is passed straight through.
26
28
  *
27
29
  * The consequence worth stating: nothing in the canvas may *skip* a server check
28
30
  * because this passed. Save always goes to the server, the server's refusal
@@ -15,9 +15,10 @@ import { WORKFLOW_NAME } from './name';
15
15
  * each sink commits its own type independently, which this screen is, rather
16
16
  * than to forbid the shape.
17
17
  *
18
- * The half of the rule that survives is enforced below as `duplicate-sink-type`:
19
- * two sinks writing the *same* type really is ambiguous, because it is two
20
- * snapshots of one type in one run with nothing to say which won.
18
+ * The half of the rule that survives is `duplicate-sink-type`: two sinks writing
19
+ * the *same* type really is ambiguous, because it is two snapshots of one type
20
+ * in one run with nothing to say which won. It is core's to raise, and this file
21
+ * raises no copy of it — see `validateWorkflow` below.
21
22
  *
22
23
  * Core now agrees: it emits `duplicate-sink-type` and no longer has
23
24
  * `multiple-sinks` or `mixed-output-types`. There is consequently nothing left
@@ -62,7 +63,18 @@ export function validateWorkflow(draft, options) {
62
63
  // Everything below is canvas-only. It runs whatever core said, because these
63
64
  // are different questions and suppressing them behind a structural error would
64
65
  // make somebody fix one problem to be told about the next.
65
- const sinkTypes = new Map();
66
+ //
67
+ // `duplicate-sink-type` is deliberately NOT among them any more. This file
68
+ // used to raise it as well, from the days when core did not — and once core
69
+ // started emitting it the canvas showed the same complaint twice, in two
70
+ // different wordings, ringing the same two nodes. Which is the drift this
71
+ // module's whole doctrine exists to prevent: the rules are core's.
72
+ //
73
+ // The one case the deleted copy caught and core does not is two sinks whose
74
+ // types differ only by surrounding whitespace, because it trimmed and core
75
+ // does not. That is a case core deliberately treats as two types, and a canvas
76
+ // that refused a graph the server accepts is the failure this file opens by
77
+ // describing.
66
78
  for (const node of nodes) {
67
79
  const name = nodeName(node);
68
80
  if (node.kind === 'transform') {
@@ -91,26 +103,7 @@ export function validateWorkflow(draft, options) {
91
103
  nodeIds: [node.id],
92
104
  edgeIds: [],
93
105
  });
94
- continue;
95
106
  }
96
- sinkTypes.set(type, [...(sinkTypes.get(type) ?? []), node.id]);
97
- }
98
- for (const [type, ids] of sinkTypes) {
99
- if (ids.length < 2)
100
- continue;
101
- const named = ids
102
- .map((id) => {
103
- const node = nodes.find((candidate) => candidate.id === id);
104
- return node ? `"${nodeName(node)}"` : `"${id}"`;
105
- })
106
- .join(' and ');
107
- problems.push({
108
- level: 'error',
109
- code: 'duplicate-sink-type',
110
- message: `${named} both write ${type}. Two sinks may write two different types — that is the point of a ${WORKFLOW_NAME.singular}, one read feeding several outputs — but two writing the same type would commit two snapshots of ${type} in one run with nothing to say which one won. Merge the branches into a single ${type} sink.`,
111
- nodeIds: ids,
112
- edgeIds: [],
113
- });
114
107
  }
115
108
  return problems;
116
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-catalog-react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Ready-made React screens for @dudousxd/nestjs-catalog — a model manager and a generic object explorer you can drop into your own app shell.",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",
@@ -74,7 +74,7 @@
74
74
  "@types/d3-array": "^3.2.2",
75
75
  "@types/d3-shape": "^3.1.8",
76
76
  "@types/react": "19.2.14",
77
- "@types/react-dom": "^19.2.4",
77
+ "@types/react-dom": "19.2.0",
78
78
  "@visx/curve": "4.0.1-alpha.0",
79
79
  "@visx/event": "4.0.1-alpha.0",
80
80
  "@visx/grid": "4.0.1-alpha.0",
@@ -90,11 +90,11 @@
90
90
  "motion": "^12.43.0",
91
91
  "prism-react-renderer": "2.4.1",
92
92
  "react": "19.2.0",
93
- "react-dom": "^19.2.8",
93
+ "react-dom": "19.2.0",
94
94
  "recharts": "2.15.4",
95
95
  "tailwind-merge": "3.4.1",
96
96
  "typescript": "5.9.3",
97
- "@dudousxd/nestjs-catalog": "0.1.0"
97
+ "@dudousxd/nestjs-catalog": "0.3.0"
98
98
  },
99
99
  "dependencies": {
100
100
  "clsx": "2.1.1",