@dyrected/admin 2.5.34 → 2.5.36

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.
@@ -1,4 +1,15 @@
1
1
  import { LucideIcon } from 'lucide-react';
2
2
  import { AdminIconName } from '@dyrected/core';
3
+ /**
4
+ * Type guard — returns `true` if `value` is a string that matches a known
5
+ * Lucide icon name (i.e. a valid `AdminIconName`).
6
+ */
3
7
  export declare function isAdminIconName(value: unknown): value is AdminIconName;
8
+ /**
9
+ * Returns the Lucide icon component for `value` if it is a valid `AdminIconName`,
10
+ * otherwise returns `fallback`.
11
+ *
12
+ * @param value - An untrusted value that may or may not be an icon name.
13
+ * @param fallback - The icon to use when `value` is not a valid icon name.
14
+ */
4
15
  export declare function resolveAdminIcon(value: unknown, fallback: LucideIcon): LucideIcon;
@@ -1,16 +1,32 @@
1
1
  import { WhereClause, WhereOperatorName } from '@dyrected/core';
2
+ /**
3
+ * A single filter rule in the admin filter builder.
4
+ * An array of rules is AND'd together and converted to a `WhereClause`
5
+ * before being passed to `collection.find({ where })`.
6
+ */
2
7
  export interface FilterRule {
8
+ /** Field name from the collection schema. */
3
9
  field: string;
10
+ /** Comparison operator (e.g. `"equals"`, `"contains"`, `"gt"`). */
4
11
  operator: WhereOperatorName;
12
+ /** Comparison value. `undefined` when the operator is `"exists"`. */
5
13
  value: unknown;
6
14
  }
7
15
  /**
8
- * Converts an array of FilterRules into a WhereClause.
9
- * All rules are ANDed together.
16
+ * Converts an array of `FilterRule`s into a flat `WhereClause`.
17
+ * All rules are AND'd together. When the same field appears more than once
18
+ * the extra conditions are moved into the top-level `AND` array.
19
+ *
20
+ * @param rules - Active filter rules from the filter builder UI.
21
+ * @returns A `WhereClause` ready to pass to `collection.find({ where })`.
10
22
  */
11
23
  export declare function rulesToWhere(rules: FilterRule[]): WhereClause;
12
24
  /**
13
- * Converts a flat WhereClause back into an array of FilterRules.
14
- * Best effort extraction for UI state.
25
+ * Converts a flat `WhereClause` back into an array of `FilterRule`s.
26
+ * Best-effort: nested `AND` conditions are unpacked; `OR` clauses are ignored.
27
+ * Used to restore filter builder state from the URL `?where=` param.
28
+ *
29
+ * @param where - A `WhereClause` object, typically parsed from the URL.
30
+ * @returns An array of `FilterRule`s suitable for rendering in the filter builder.
15
31
  */
16
32
  export declare function whereToRules(where: WhereClause | undefined): FilterRule[];
@@ -1,3 +1,22 @@
1
1
  import { ClassValue } from 'clsx';
2
+ /**
3
+ * Merges Tailwind class names, resolving conflicts with the `dy-` prefix.
4
+ * Drop-in replacement for `clsx` that handles Dyrected's scoped Tailwind build.
5
+ */
2
6
  export declare function cn(...inputs: ClassValue[]): string;
7
+ /**
8
+ * Resolves a media field value to an absolute URL.
9
+ *
10
+ * Handles three input shapes:
11
+ * - A fully-qualified URL (`https://...`) — returned as-is.
12
+ * - A root-relative path (`/uploads/...`) — origin prepended from `baseUrl`.
13
+ * - A bare filename or storage path (`default/photo.jpg`) — prefixed with `/api/media/`.
14
+ *
15
+ * Bare strings that look like document IDs (no extension, no slash) are returned
16
+ * as an empty string so they are not treated as media assets.
17
+ *
18
+ * @param val - A media field value: a URL string, storage path, or a document object with a `url` or `filename` property.
19
+ * @param baseUrl - The Dyrected backend base URL, used to build the origin for relative paths.
20
+ * @returns A fully-qualified URL string, or `""` if the value cannot be resolved.
21
+ */
3
22
  export declare function getMediaUrl(val: string | any, baseUrl: string): string;
@@ -28,5 +28,12 @@ export interface DyrectedProviderProps {
28
28
  components?: DyrectedContextType['components'];
29
29
  }
30
30
  export declare function DyrectedProvider({ children, apiKey: initialApiKey, baseUrl: initialBaseUrl, siteId: initialSiteId, initialToken, defaultTechStack, components }: DyrectedProviderProps): import("react/jsx-runtime").JSX.Element;
31
+ /**
32
+ * Returns the Dyrected admin context: the SDK client, current user, loaded
33
+ * schemas, auth helpers, and registered component overrides.
34
+ *
35
+ * Must be called within a component tree wrapped by `DyrectedProvider`.
36
+ * Throws if called outside of that context.
37
+ */
31
38
  export declare const useDyrected: () => DyrectedContextType;
32
39
  export {};
@@ -1,23 +1,36 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { AdminConfig, CollectionConfig, GlobalConfig } from '@dyrected/core';
3
3
  import { DyrectedClient, PaginatedResult } from '@dyrected/sdk';
4
+ /** All collection and global schemas returned by the backend, plus optional admin config. */
4
5
  export interface AdminSchemas {
5
6
  collections: CollectionConfig[];
6
7
  globals: GlobalConfig[];
7
8
  admin?: AdminConfig;
8
9
  }
10
+ /** Props injected into custom dashboard slot components. */
9
11
  export interface DashboardSlotProps {
12
+ /** Authenticated SDK client — use this to call any API. */
10
13
  client: DyrectedClient;
14
+ /** Currently logged-in user document, or `null` when unauthenticated. */
11
15
  user: Record<string, unknown> | null;
16
+ /** All schemas loaded from the backend. */
12
17
  schemas: AdminSchemas;
13
18
  }
19
+ /** Props injected into custom collection list slot components. */
14
20
  export interface CollectionListSlotProps {
21
+ /** Authenticated SDK client. */
15
22
  client: DyrectedClient;
23
+ /** Currently logged-in user document, or `null` when unauthenticated. */
16
24
  user: Record<string, unknown> | null;
25
+ /** Schema config for the collection being rendered. */
17
26
  collection: CollectionConfig;
27
+ /** URL slug of the collection (e.g. `"posts"`). */
18
28
  collectionSlug: string;
29
+ /** Raw paginated response from the last `find()` call. */
19
30
  response: PaginatedResult<Record<string, unknown>> | undefined;
31
+ /** Unwrapped document array from `response`. */
20
32
  documents: Record<string, unknown>[];
33
+ /** `true` while the list query is in-flight. */
21
34
  isLoading: boolean;
22
35
  pagination: {
23
36
  page: number;
@@ -27,16 +40,47 @@ export interface CollectionListSlotProps {
27
40
  hasPrevPage: boolean;
28
41
  };
29
42
  permissions: {
43
+ /** Whether the current user may read documents in this collection. */
30
44
  canRead: boolean;
45
+ /** Whether the current user may create new documents. */
31
46
  canCreate: boolean;
32
47
  };
33
48
  urls: {
49
+ /** Admin URL for the collection list view. */
34
50
  collection: string;
51
+ /** Admin URL for the new-document form. */
35
52
  create: string;
36
53
  };
37
54
  }
55
+ /**
56
+ * Custom component overrides passed to `<DyrectedAdmin />`.
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * <DyrectedAdmin
61
+ * components={{
62
+ * fields: { color: ColorPickerField },
63
+ * dashboard: { analytics: AnalyticsWidget },
64
+ * collectionList: { posts: PostsListView },
65
+ * }}
66
+ * />
67
+ * ```
68
+ */
38
69
  export interface AdminComponents {
70
+ /**
71
+ * Custom field renderers keyed by field type name.
72
+ * A component registered here replaces the built-in renderer for every
73
+ * field whose `type` matches the key.
74
+ */
39
75
  fields?: Record<string, ComponentType<any>>;
76
+ /**
77
+ * Custom dashboard slot components keyed by a slot name of your choice.
78
+ * All registered components are rendered inside the dashboard page.
79
+ */
40
80
  dashboard?: Record<string, ComponentType<DashboardSlotProps>>;
81
+ /**
82
+ * Custom collection list slot components keyed by collection slug.
83
+ * The registered component replaces the entire list view for that collection.
84
+ */
41
85
  collectionList?: Record<string, ComponentType<CollectionListSlotProps>>;
42
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyrected/admin",
3
- "version": "2.5.34",
3
+ "version": "2.5.36",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -54,6 +54,7 @@
54
54
  "jexl": "^2.3.0",
55
55
  "lucide-react": "^1.14.0",
56
56
  "react-blurhash": "^0.3.0",
57
+ "react-datasheet-grid": "^4.1.2",
57
58
  "react-day-picker": "^9.14.0",
58
59
  "react-dropzone": "^15.0.0",
59
60
  "react-hook-form": "^7.75.0",
@@ -62,8 +63,8 @@
62
63
  "tailwind-merge": "^3.5.0",
63
64
  "tailwindcss-animate": "^1.0.7",
64
65
  "zod": "^3.25.76",
65
- "@dyrected/core": "^2.5.34",
66
- "@dyrected/sdk": "^2.5.34"
66
+ "@dyrected/core": "^2.5.36",
67
+ "@dyrected/sdk": "^2.5.36"
67
68
  },
68
69
  "peerDependencies": {
69
70
  "@tanstack/react-query": "^5.0.0",