@knkcs/mediahub-ui 0.2.0 → 0.4.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/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { JSX } from 'react';
3
3
  import { PersistOptions } from 'zustand/middleware';
4
4
  import { QueryClient } from '@tanstack/react-query';
5
5
  import { ReactNode } from 'react';
6
+ import { Schema } from '@knkcs/fieldkit/schema';
6
7
  import { StatusInfo } from '@knkcs/statushub-ui';
7
8
  import { StoreApi } from 'zustand';
8
9
  import { TFunction } from 'i18next';
@@ -93,6 +94,47 @@ export declare interface AIProcessClient {
93
94
  delete(id: string): Promise<void>;
94
95
  }
95
96
 
97
+ /**
98
+ * The AI-Processes tab of the packaged asset-type detail screen: the processes
99
+ * an asset type runs when an asset is analyzed, in order — listed, reordered,
100
+ * enabled/disabled, deleted, created and edited (knkCS/mediahub#157).
101
+ *
102
+ * No routing of its own: where a host's AI-connection settings live is the
103
+ * host's URL, so the "no connections" hint is text, not a link.
104
+ */
105
+ export declare function AIProcessesTab({ typeId, metadataSchema, }: AIProcessesTabProps): React.JSX.Element;
106
+
107
+ export declare namespace AIProcessesTab {
108
+ var displayName: string;
109
+ }
110
+
111
+ export declare interface AIProcessesTabProps {
112
+ /** The asset type whose processes are listed. */
113
+ typeId: string;
114
+ /** The asset type's metadata schema, source of the metadata output targets. */
115
+ metadataSchema: string | undefined;
116
+ }
117
+
118
+ /**
119
+ * Create or edit one AI process for an asset type. Packaged from the
120
+ * standalone's host-local dialog (knkCS/mediahub#157) — same behaviour, same
121
+ * mount semantics, strings under the package's i18n namespace.
122
+ */
123
+ export declare function AIProcessFormDialog({ open, onClose, assetTypeId, metadataAccessors, editProcess, }: AIProcessFormDialogProps): React.JSX.Element;
124
+
125
+ export declare namespace AIProcessFormDialog {
126
+ var displayName: string;
127
+ }
128
+
129
+ export declare interface AIProcessFormDialogProps {
130
+ open: boolean;
131
+ onClose: () => void;
132
+ assetTypeId: string;
133
+ metadataAccessors: MetadataAccessorOption[];
134
+ /** If provided, the dialog opens in edit mode for this process. */
135
+ editProcess?: AIProcessInfo;
136
+ }
137
+
96
138
  export declare interface AIProcessInfo {
97
139
  id: string;
98
140
  workspaceId: string;
@@ -365,6 +407,97 @@ export declare interface AssetTypeClient {
365
407
  delete(id: string): Promise<void>;
366
408
  }
367
409
 
410
+ /**
411
+ * Create an asset type. The screen the package owns, replacing the
412
+ * standalone's create dialog and core's create page (knkCS/mediahub#137/#140).
413
+ *
414
+ * The slug follows the name until it is edited by hand and then stops — the
415
+ * unconditional overwrite the standalone had silently discarded a slug someone
416
+ * typed on purpose. The server's rule (lowercase alphanumeric with hyphens, at
417
+ * least two characters) is stated on the form and enforced before submit,
418
+ * because without both a name like `Bild Anhang` produced a bare 400
419
+ * (knkcms/core#861).
420
+ */
421
+ export declare function AssetTypeCreate({ assetTypesPath, onCreated, onCancel, }: AssetTypeCreateProps): default_2.JSX.Element;
422
+
423
+ export declare namespace AssetTypeCreate {
424
+ var displayName: string;
425
+ }
426
+
427
+ export declare interface AssetTypeCreateProps {
428
+ /**
429
+ * The host's asset-type index path — used as the breadcrumb's target. A
430
+ * path, not a route: the screen never navigates, it only says where the
431
+ * list it belongs to lives (core's `docs/service-integration.md`).
432
+ */
433
+ assetTypesPath: string;
434
+ /** Called with the created asset type; the host decides where to go. */
435
+ onCreated?: (assetType: AssetTypeInfo) => void;
436
+ /** Called when the administrator abandons the form. */
437
+ onCancel?: () => void;
438
+ }
439
+
440
+ /**
441
+ * The packaged asset-type detail screen: view, edit and delete one asset type,
442
+ * with its fieldkit metadata schema on a second tab.
443
+ *
444
+ * **Correct against the wire, not against the declared type.** Connect omits
445
+ * empty repeated fields and empty strings from its JSON, and a host client that
446
+ * returns the wire object unmapped therefore delivers `undefined` where
447
+ * `AssetTypeInfo` promises `string` or `string[]`. Reading one of those
448
+ * unguarded is what took core's detail page down (knkcms/core#862, #863).
449
+ * Every field below is defaulted at the one place it is read, so an absent
450
+ * value renders as empty rather than throwing — and never flips a controlled
451
+ * input to uncontrolled, which is the quieter version of the same bug.
452
+ */
453
+ export declare function AssetTypeDetail({ typeId, assetTypesPath, onBack, onDeleted, }: AssetTypeDetailProps): default_2.JSX.Element;
454
+
455
+ export declare namespace AssetTypeDetail {
456
+ var displayName: string;
457
+ }
458
+
459
+ export declare interface AssetTypeDetailProps {
460
+ /** The asset type to show. */
461
+ typeId: string;
462
+ /**
463
+ * Typed path of the host's asset-type index, used for the breadcrumb back
464
+ * link. The screen never routes itself — the host owns its URLs
465
+ * (core's `docs/service-integration.md`).
466
+ */
467
+ assetTypesPath?: string;
468
+ /**
469
+ * Navigate back to the asset-type index. Given one, the screen renders a
470
+ * back affordance that confirms before discarding unsaved edits — the
471
+ * breadcrumb link above is the host's own navigation and the screen cannot
472
+ * intercept it.
473
+ */
474
+ onBack?: () => void;
475
+ /** Called after a successful delete; the host decides where to go next. */
476
+ onDeleted?: () => void;
477
+ }
478
+
479
+ /**
480
+ * The workspace's asset types, listed. The package owns the screen; both hosts
481
+ * compose it and keep their own routing to themselves (#142, parent #138).
482
+ */
483
+ export declare function AssetTypeIndex(props: AssetTypeIndexProps): React.JSX.Element;
484
+
485
+ export declare namespace AssetTypeIndex {
486
+ var displayName: string;
487
+ }
488
+
489
+ export declare interface AssetTypeIndexProps {
490
+ /**
491
+ * An asset type was opened. The host decides what that means — it receives
492
+ * the id and nothing else, because this package must not know either host's
493
+ * URL structure (core's `docs/service-integration.md`; spec #138). Screens,
494
+ * not routes: nothing here navigates and nothing here builds a path.
495
+ */
496
+ onOpen?: (assetTypeId: string) => void;
497
+ /** The reader asked for a new asset type. Same contract as `onOpen`. */
498
+ onCreate?: () => void;
499
+ }
500
+
368
501
  export declare interface AssetTypeInfo {
369
502
  id: string;
370
503
  workspaceId: string;
@@ -840,6 +973,19 @@ declare interface FolderTreeProps {
840
973
  onFolderSelect: (folderId: string) => void;
841
974
  }
842
975
 
976
+ /**
977
+ * Takes `string[] | undefined` although `AssetTypeInfo.allowedMimeTypes` is
978
+ * declared `string[]`, because a host client may return the wire object
979
+ * unmapped under that type. Connect omits an empty repeated field from the
980
+ * JSON, so an asset type with no MIME types arrives without the key at all and
981
+ * the declared type is a lie. The package's own client maps through
982
+ * `mapAssetType`, which defaults it; core's did not, and the detail page went
983
+ * down on "Cannot read properties of undefined (reading 'join')"
984
+ * (knkcms/core#863). Tolerating the absent list here is the fix, kept in one
985
+ * place for every host.
986
+ */
987
+ export declare const formatMimeTypeList: (value: string[] | undefined) => string;
988
+
843
989
  export declare interface GetUploadUrlParams {
844
990
  assetId: string;
845
991
  filename: string;
@@ -945,6 +1091,39 @@ export declare const i18nResources: {
945
1091
  unknownValue: string;
946
1092
  };
947
1093
  };
1094
+ assetTypeDetail: {
1095
+ breadcrumbAssetTypes: string;
1096
+ notFound: string;
1097
+ untitled: string;
1098
+ backButtonAria: string;
1099
+ generalTab: string;
1100
+ metadataTab: string;
1101
+ aiProcessesTab: string;
1102
+ nameLabel: string;
1103
+ nameRequired: string;
1104
+ slugLabel: string;
1105
+ descriptionLabel: string;
1106
+ descriptionPlaceholder: string;
1107
+ allowedMimeTypesLabel: string;
1108
+ allowedMimeTypesDescription: string;
1109
+ activeLabel: string;
1110
+ save: string;
1111
+ delete: string;
1112
+ saveSuccessToast: string;
1113
+ saveFailedToast: string;
1114
+ schemaSavedToast: string;
1115
+ deleteConfirmTitle: string;
1116
+ deleteConfirmMessage: string;
1117
+ deleteConfirmLabel: string;
1118
+ deleteSuccessToast: string;
1119
+ deleteFailedToast: string;
1120
+ discardSchemaConfirmTitle: string;
1121
+ discardSchemaConfirmMessage: string;
1122
+ discardSchemaConfirmLabel: string;
1123
+ discardConfirmTitle: string;
1124
+ discardConfirmMessage: string;
1125
+ discardConfirmLabel: string;
1126
+ };
948
1127
  assetLibrary: {
949
1128
  pageTitle: string;
950
1129
  uploadButton: string;
@@ -1176,6 +1355,108 @@ export declare const i18nResources: {
1176
1355
  closeLabel: string;
1177
1356
  resolveHint: string;
1178
1357
  };
1358
+ assetTypeCreate: {
1359
+ title: string;
1360
+ breadcrumbAssetTypes: string;
1361
+ nameLabel: string;
1362
+ namePlaceholder: string;
1363
+ nameRequired: string;
1364
+ slugLabel: string;
1365
+ slugHint: string;
1366
+ slugInvalid: string;
1367
+ descriptionLabel: string;
1368
+ descriptionPlaceholder: string;
1369
+ allowedMimeTypesLabel: string;
1370
+ allowedMimeTypesHint: string;
1371
+ allowedMimeTypesPlaceholder: string;
1372
+ metadataSchemaLabel: string;
1373
+ metadataSchemaHint: string;
1374
+ submit: string;
1375
+ cancel: string;
1376
+ createdToast: string;
1377
+ createFailedToast: string;
1378
+ };
1379
+ assetTypeIndex: {
1380
+ pageTitle: string;
1381
+ pageSubtitle: string;
1382
+ newButton: string;
1383
+ searchPlaceholder: string;
1384
+ typesCount: string;
1385
+ columnName: string;
1386
+ columnSlug: string;
1387
+ columnMimeTypes: string;
1388
+ columnFields: string;
1389
+ columnStatus: string;
1390
+ statusActive: string;
1391
+ statusInactive: string;
1392
+ actionDelete: string;
1393
+ deleteConfirmTitle: string;
1394
+ deleteConfirmMessage: string;
1395
+ deleteConfirmLabel: string;
1396
+ deleteSuccessToast: string;
1397
+ deleteFailedToast: string;
1398
+ noAssetTypesHeader: string;
1399
+ noAssetTypesDescription: string;
1400
+ noMatchesHeader: string;
1401
+ noMatchesDescription: string;
1402
+ loadFailedHeader: string;
1403
+ };
1404
+ aiProcesses: {
1405
+ intro: string;
1406
+ newProcess: string;
1407
+ noConnectionsHint: string;
1408
+ empty: string;
1409
+ outputCount_one: string;
1410
+ outputCount_other: string;
1411
+ active: string;
1412
+ inactive: string;
1413
+ enableAria: string;
1414
+ disableAria: string;
1415
+ moveUpAria: string;
1416
+ moveDownAria: string;
1417
+ editAria: string;
1418
+ deleteAria: string;
1419
+ deleteConfirmTitle: string;
1420
+ deleteConfirmMessage: string;
1421
+ deleteConfirmLabel: string;
1422
+ deletedToast: string;
1423
+ deleteFailedToast: string;
1424
+ updateFailedToast: string;
1425
+ reorderFailedToast: string;
1426
+ };
1427
+ aiProcessDialog: {
1428
+ createHeader: string;
1429
+ editHeader: string;
1430
+ createLabel: string;
1431
+ saveLabel: string;
1432
+ nameLabel: string;
1433
+ namePlaceholder: string;
1434
+ nameRequired: string;
1435
+ connectionLabel: string;
1436
+ connectionPlaceholder: string;
1437
+ connectionRequired: string;
1438
+ promptLabel: string;
1439
+ promptPlaceholder: string;
1440
+ promptRequired: string;
1441
+ outputsLabel: string;
1442
+ outputKeyLabel: string;
1443
+ outputKeyPlaceholder: string;
1444
+ outputKeyRequired: string;
1445
+ outputRequired: string;
1446
+ addOutput: string;
1447
+ removeOutputAria: string;
1448
+ targetLabel: string;
1449
+ targetDescription: string;
1450
+ targetTags: string;
1451
+ targetMetadata: string;
1452
+ metadataFieldLabel: string;
1453
+ metadataFieldPlaceholder: string;
1454
+ metadataFieldRequired: string;
1455
+ createdToast: string;
1456
+ createFailedToast: string;
1457
+ updatedToast: string;
1458
+ updateFailedToast: string;
1459
+ };
1179
1460
  };
1180
1461
  };
1181
1462
  de: {
@@ -1238,6 +1519,39 @@ export declare const i18nResources: {
1238
1519
  unknownValue: string;
1239
1520
  };
1240
1521
  };
1522
+ assetTypeDetail: {
1523
+ breadcrumbAssetTypes: string;
1524
+ notFound: string;
1525
+ untitled: string;
1526
+ backButtonAria: string;
1527
+ generalTab: string;
1528
+ metadataTab: string;
1529
+ aiProcessesTab: string;
1530
+ nameLabel: string;
1531
+ nameRequired: string;
1532
+ slugLabel: string;
1533
+ descriptionLabel: string;
1534
+ descriptionPlaceholder: string;
1535
+ allowedMimeTypesLabel: string;
1536
+ allowedMimeTypesDescription: string;
1537
+ activeLabel: string;
1538
+ save: string;
1539
+ delete: string;
1540
+ saveSuccessToast: string;
1541
+ saveFailedToast: string;
1542
+ schemaSavedToast: string;
1543
+ deleteConfirmTitle: string;
1544
+ deleteConfirmMessage: string;
1545
+ deleteConfirmLabel: string;
1546
+ deleteSuccessToast: string;
1547
+ deleteFailedToast: string;
1548
+ discardSchemaConfirmTitle: string;
1549
+ discardSchemaConfirmMessage: string;
1550
+ discardSchemaConfirmLabel: string;
1551
+ discardConfirmTitle: string;
1552
+ discardConfirmMessage: string;
1553
+ discardConfirmLabel: string;
1554
+ };
1241
1555
  assetLibrary: {
1242
1556
  pageTitle: string;
1243
1557
  uploadButton: string;
@@ -1469,6 +1783,108 @@ export declare const i18nResources: {
1469
1783
  closeLabel: string;
1470
1784
  resolveHint: string;
1471
1785
  };
1786
+ assetTypeCreate: {
1787
+ title: string;
1788
+ breadcrumbAssetTypes: string;
1789
+ nameLabel: string;
1790
+ namePlaceholder: string;
1791
+ nameRequired: string;
1792
+ slugLabel: string;
1793
+ slugHint: string;
1794
+ slugInvalid: string;
1795
+ descriptionLabel: string;
1796
+ descriptionPlaceholder: string;
1797
+ allowedMimeTypesLabel: string;
1798
+ allowedMimeTypesHint: string;
1799
+ allowedMimeTypesPlaceholder: string;
1800
+ metadataSchemaLabel: string;
1801
+ metadataSchemaHint: string;
1802
+ submit: string;
1803
+ cancel: string;
1804
+ createdToast: string;
1805
+ createFailedToast: string;
1806
+ };
1807
+ assetTypeIndex: {
1808
+ pageTitle: string;
1809
+ pageSubtitle: string;
1810
+ newButton: string;
1811
+ searchPlaceholder: string;
1812
+ typesCount: string;
1813
+ columnName: string;
1814
+ columnSlug: string;
1815
+ columnMimeTypes: string;
1816
+ columnFields: string;
1817
+ columnStatus: string;
1818
+ statusActive: string;
1819
+ statusInactive: string;
1820
+ actionDelete: string;
1821
+ deleteConfirmTitle: string;
1822
+ deleteConfirmMessage: string;
1823
+ deleteConfirmLabel: string;
1824
+ deleteSuccessToast: string;
1825
+ deleteFailedToast: string;
1826
+ noAssetTypesHeader: string;
1827
+ noAssetTypesDescription: string;
1828
+ noMatchesHeader: string;
1829
+ noMatchesDescription: string;
1830
+ loadFailedHeader: string;
1831
+ };
1832
+ aiProcesses: {
1833
+ intro: string;
1834
+ newProcess: string;
1835
+ noConnectionsHint: string;
1836
+ empty: string;
1837
+ outputCount_one: string;
1838
+ outputCount_other: string;
1839
+ active: string;
1840
+ inactive: string;
1841
+ enableAria: string;
1842
+ disableAria: string;
1843
+ moveUpAria: string;
1844
+ moveDownAria: string;
1845
+ editAria: string;
1846
+ deleteAria: string;
1847
+ deleteConfirmTitle: string;
1848
+ deleteConfirmMessage: string;
1849
+ deleteConfirmLabel: string;
1850
+ deletedToast: string;
1851
+ deleteFailedToast: string;
1852
+ updateFailedToast: string;
1853
+ reorderFailedToast: string;
1854
+ };
1855
+ aiProcessDialog: {
1856
+ createHeader: string;
1857
+ editHeader: string;
1858
+ createLabel: string;
1859
+ saveLabel: string;
1860
+ nameLabel: string;
1861
+ namePlaceholder: string;
1862
+ nameRequired: string;
1863
+ connectionLabel: string;
1864
+ connectionPlaceholder: string;
1865
+ connectionRequired: string;
1866
+ promptLabel: string;
1867
+ promptPlaceholder: string;
1868
+ promptRequired: string;
1869
+ outputsLabel: string;
1870
+ outputKeyLabel: string;
1871
+ outputKeyPlaceholder: string;
1872
+ outputKeyRequired: string;
1873
+ outputRequired: string;
1874
+ addOutput: string;
1875
+ removeOutputAria: string;
1876
+ targetLabel: string;
1877
+ targetDescription: string;
1878
+ targetTags: string;
1879
+ targetMetadata: string;
1880
+ metadataFieldLabel: string;
1881
+ metadataFieldPlaceholder: string;
1882
+ metadataFieldRequired: string;
1883
+ createdToast: string;
1884
+ createFailedToast: string;
1885
+ updatedToast: string;
1886
+ updateFailedToast: string;
1887
+ };
1472
1888
  };
1473
1889
  };
1474
1890
  };
@@ -1623,6 +2039,28 @@ export declare interface MediahubProviderProps {
1623
2039
  children: ReactNode;
1624
2040
  }
1625
2041
 
2042
+ export declare interface MetadataAccessorOption {
2043
+ label: string;
2044
+ value: string;
2045
+ }
2046
+
2047
+ /**
2048
+ * The asset type's fieldkit metadata schema, edited on a page with room for it
2049
+ * (spec knkCS/mediahub#138, story 7) rather than as a JSON textarea.
2050
+ */
2051
+ export declare const MetadataSchemaEditor: default_2.FC<MetadataSchemaEditorProps>;
2052
+
2053
+ export declare interface MetadataSchemaEditorProps {
2054
+ typeId: string;
2055
+ /**
2056
+ * The committed schema — SpecEditor's baseline. Content-equal re-parses on
2057
+ * background refetches are ignored by the editor's stability contract.
2058
+ */
2059
+ initialSchema: Schema;
2060
+ /** Wire into the screen's unsaved-changes tab guard. */
2061
+ onDirtyChange?: (dirty: boolean) => void;
2062
+ }
2063
+
1626
2064
  /**
1627
2065
  * Destination folder picker for moving a folder or an asset. Destinations
1628
2066
  * that would trip the server's leak guard (moving exposed content into a
@@ -1662,6 +2100,14 @@ export declare interface Page<T> {
1662
2100
  totalPages: number;
1663
2101
  }
1664
2102
 
2103
+ /**
2104
+ * A comma-separated MIME type field, both directions: the asset-type create and
2105
+ * detail screens edit `AssetTypeInfo.allowedMimeTypes` (a `string[]`) as one
2106
+ * plain-text input, so both parse the same way back into the array the mutation
2107
+ * sends.
2108
+ */
2109
+ export declare const parseMimeTypeList: (value: string) => string[];
2110
+
1665
2111
  declare interface PreferencesActions {
1666
2112
  toggleSidebar: () => void;
1667
2113
  setViewMode: (mode: "list" | "grid") => void;
@@ -1749,6 +2195,19 @@ declare type SelectionStore = SelectionState & SelectionActions;
1749
2195
  */
1750
2196
  export declare function showRpcErrorToast(err: unknown, fallbackTitle: string): void;
1751
2197
 
2198
+ /**
2199
+ * Convert a display name into a slug mediahub accepts: lowercase alphanumeric
2200
+ * with hyphens.
2201
+ *
2202
+ * Non-ASCII is a separator, not transliterated — "Bürgerdaten" becomes
2203
+ * "b-rgerdaten" — because the server's rule is the ASCII one and a
2204
+ * transliteration would produce a slug the user never saw derived.
2205
+ *
2206
+ * Both hosts carried their own copy of this (knkCS/mediahub#137); the package
2207
+ * owns it now so the asset-type screens share one derivation.
2208
+ */
2209
+ export declare function slugify(name: string): string;
2210
+
1752
2211
  export declare interface StatusCountInfo {
1753
2212
  statusSlug: string;
1754
2213
  name: string;