@nice2dev/ui-forms 1.4.4 → 1.4.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/index.cjs +6 -6
- package/dist/index.d.ts +134 -2
- package/dist/index.mjs +2809 -2447
- package/dist/studio.cjs +10 -7
- package/dist/studio.d.ts +134 -2
- package/dist/studio.mjs +696 -552
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,18 @@ import { NiceViewDefinition } from '@nice2dev/ui';
|
|
|
16
16
|
import { NiceWorkflowDefinition } from '@nice2dev/ui';
|
|
17
17
|
import { RefAttributes } from 'react';
|
|
18
18
|
|
|
19
|
+
/** The layout with a new folder in `group` (inside `parent` / `section`); returns its id too. */
|
|
20
|
+
export declare function addStudioFolder(layout: NiceStudioLayout, folder: Omit<NiceStudioLayoutFolder, 'id'>): {
|
|
21
|
+
layout: NiceStudioLayout;
|
|
22
|
+
id: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** The layout with a new section; returns the layout and the section's id. */
|
|
26
|
+
export declare function addStudioSection(layout: NiceStudioLayout, label: string): {
|
|
27
|
+
layout: NiceStudioLayout;
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
19
31
|
/** Generated fields → NiceSchemaForm fields, with their validation rules. */
|
|
20
32
|
export declare function aiFormConfigToFormFields(config: {
|
|
21
33
|
fields: readonly NiceAIFormFieldLike[];
|
|
@@ -57,6 +69,9 @@ export declare function deriveDefaultRbac(module: {
|
|
|
57
69
|
/** Reads how `text` is written: BOM, line breaks, indentation, final newline, colon spacing. */
|
|
58
70
|
export declare function detectJsonTextFormat(text: string): NiceJsonTextFormat;
|
|
59
71
|
|
|
72
|
+
/** An empty layout: no sections, no folders — the flat tree. */
|
|
73
|
+
export declare const emptyStudioLayout: () => NiceStudioLayout;
|
|
74
|
+
|
|
60
75
|
/**
|
|
61
76
|
* The file changes that store a document's new model: only files whose text differs from what
|
|
62
77
|
* was read, plus files the encoder adds or removes.
|
|
@@ -213,6 +228,12 @@ export declare interface FormSectionDefinition {
|
|
|
213
228
|
*/
|
|
214
229
|
export declare function i18nFileKind(o?: NiceI18nFileKindOptions): NiceStudioFileKind<NiceStudioTranslations>;
|
|
215
230
|
|
|
231
|
+
/** Whether a layout holds nothing (its file can go). */
|
|
232
|
+
export declare const isEmptyStudioLayout: (layout: NiceStudioLayout) => boolean;
|
|
233
|
+
|
|
234
|
+
/** Whether a path is a module's layout file. */
|
|
235
|
+
export declare const isStudioLayoutPath: (path: string) => boolean;
|
|
236
|
+
|
|
216
237
|
/**
|
|
217
238
|
* A file holding a list of entries edited one at a time (views, workflows). Entries the editor
|
|
218
239
|
* does not understand stay raw and round-trip as they are.
|
|
@@ -713,6 +734,9 @@ export declare interface NiceStudioAction {
|
|
|
713
734
|
onSelect: () => void;
|
|
714
735
|
}
|
|
715
736
|
|
|
737
|
+
/** The studio's own editors. */
|
|
738
|
+
export declare type NiceStudioBuiltinEditorId = 'manifest' | 'entities' | 'i18n' | 'views' | 'workflows' | 'permissions' | 'rbac' | 'dataSources' | 'seeds' | 'hooks' | 'script' | 'json' | 'text';
|
|
739
|
+
|
|
716
740
|
/** What a file kind's decode and encode know about the module. */
|
|
717
741
|
export declare interface NiceStudioCodecContext {
|
|
718
742
|
moduleId: string;
|
|
@@ -734,8 +758,11 @@ export declare interface NiceStudioDocument<M = unknown> {
|
|
|
734
758
|
error?: string;
|
|
735
759
|
}
|
|
736
760
|
|
|
737
|
-
/**
|
|
738
|
-
|
|
761
|
+
/**
|
|
762
|
+
* The editors a file kind can open in: a built-in one, or the id of an editor the host registers
|
|
763
|
+
* (1.4.5 — the union was closed; an unknown id opens as raw JSON / text until one is registered).
|
|
764
|
+
*/
|
|
765
|
+
export declare type NiceStudioEditorId = NiceStudioBuiltinEditorId | (string & {});
|
|
739
766
|
|
|
740
767
|
/** New and removed files of an encoded document. */
|
|
741
768
|
export declare interface NiceStudioEncoded {
|
|
@@ -795,6 +822,11 @@ export declare interface NiceStudioFileKind<M = unknown> {
|
|
|
795
822
|
/** The document a file belongs to (files with the same group open together). Default: the path. */
|
|
796
823
|
group?(path: string): string;
|
|
797
824
|
editor: NiceStudioEditorId;
|
|
825
|
+
/**
|
|
826
|
+
* The tree group its documents are listed under (1.4.5): one of the preset's `groups`, or a
|
|
827
|
+
* built-in group id. Default: the built-in group of its editor (none for raw JSON / text).
|
|
828
|
+
*/
|
|
829
|
+
treeGroup?: string;
|
|
798
830
|
/** The files of one document → the editor's model. Throwing opens the files as raw JSON / text. */
|
|
799
831
|
decode(files: readonly NiceStudioFile[], ctx: NiceStudioCodecContext): M;
|
|
800
832
|
/** The model → the document's files (only their text; unchanged files may be returned as they were). */
|
|
@@ -811,6 +843,20 @@ export declare interface NiceStudioGeneratedModule {
|
|
|
811
843
|
}>;
|
|
812
844
|
}
|
|
813
845
|
|
|
846
|
+
/**
|
|
847
|
+
* A group of the tree a preset adds (1.4.5): its documents — of the kinds whose `treeGroup` names
|
|
848
|
+
* it — are listed one per row under it, like scripts.
|
|
849
|
+
*/
|
|
850
|
+
export declare interface NiceStudioGroupDef {
|
|
851
|
+
id: string;
|
|
852
|
+
label: string;
|
|
853
|
+
labelKey?: string;
|
|
854
|
+
/** NiceIcon name. */
|
|
855
|
+
icon?: string;
|
|
856
|
+
/** Where it goes among the groups (the built-in ones are 10, 20, … 100). Default: after them. */
|
|
857
|
+
order?: number;
|
|
858
|
+
}
|
|
859
|
+
|
|
814
860
|
/** A problem found in a module. */
|
|
815
861
|
export declare interface NiceStudioIssue {
|
|
816
862
|
severity: 'error' | 'warning' | 'info';
|
|
@@ -844,6 +890,40 @@ export declare interface NiceStudioItem<D> {
|
|
|
844
890
|
rawReason?: string;
|
|
845
891
|
}
|
|
846
892
|
|
|
893
|
+
/** The layout of a module — the content of its `{prefix}.studio.json`. */
|
|
894
|
+
export declare interface NiceStudioLayout {
|
|
895
|
+
version: 1;
|
|
896
|
+
sections: NiceStudioLayoutSection[];
|
|
897
|
+
folders: NiceStudioLayoutFolder[];
|
|
898
|
+
/** By entry ref, `group:key` — `entities:Customer`, `views:customer-list`. */
|
|
899
|
+
placement: Record<string, NiceStudioLayoutPlacement>;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/** A folder inside one group of a module (entities, views…), optionally nested and in a section. */
|
|
903
|
+
export declare interface NiceStudioLayoutFolder {
|
|
904
|
+
id: string;
|
|
905
|
+
label: string;
|
|
906
|
+
/** The group it belongs to: `entities`, `views`, `workflows`, a preset's own group… */
|
|
907
|
+
group: string;
|
|
908
|
+
/** The folder it sits in. */
|
|
909
|
+
parent?: string;
|
|
910
|
+
/** The section it sits in (absent: the module's own groups). */
|
|
911
|
+
section?: string;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/** Where one entry sits: a section, a folder, an order among its siblings. */
|
|
915
|
+
export declare interface NiceStudioLayoutPlacement {
|
|
916
|
+
section?: string;
|
|
917
|
+
folder?: string;
|
|
918
|
+
order?: number;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/** A section of a module: a band of the tree that holds groups (Sales, Warehouse…). */
|
|
922
|
+
export declare interface NiceStudioLayoutSection {
|
|
923
|
+
id: string;
|
|
924
|
+
label: string;
|
|
925
|
+
}
|
|
926
|
+
|
|
847
927
|
/** What validators and generators get. */
|
|
848
928
|
export declare interface NiceStudioModuleContext {
|
|
849
929
|
key: NiceStudioModuleKey;
|
|
@@ -919,6 +999,11 @@ export declare interface NiceStudioPackage {
|
|
|
919
999
|
/** Computed from the modules (e.g. their `category`) rather than stored: it cannot be edited. */
|
|
920
1000
|
derived?: boolean;
|
|
921
1001
|
readOnly?: boolean;
|
|
1002
|
+
/**
|
|
1003
|
+
* The package it sits in (1.4.5): packages nest in the tree. An id with `/` (`Finance/Banking`, an
|
|
1004
|
+
* OmniVerk category path) nests under the part before its last `/` without it.
|
|
1005
|
+
*/
|
|
1006
|
+
parentId?: string;
|
|
922
1007
|
}
|
|
923
1008
|
|
|
924
1009
|
/** An extra part of a module (payments, webhooks — anything host-specific): a row under the module in the tree, its content full-screen. */
|
|
@@ -951,6 +1036,8 @@ export declare interface NiceStudioPreset {
|
|
|
951
1036
|
id: string;
|
|
952
1037
|
/** Tried in order; a path no kind matches opens as raw JSON (`*.json`) or text. */
|
|
953
1038
|
kinds: NiceStudioFileKind[];
|
|
1039
|
+
/** Groups of the tree the preset adds to the built-in ones (1.4.5). */
|
|
1040
|
+
groups?: NiceStudioGroupDef[];
|
|
954
1041
|
/** The manifest's sections, each a form over part of the manifest. */
|
|
955
1042
|
manifestSections?: NiceManifestSection[];
|
|
956
1043
|
entities?: NiceStudioEntityOptions;
|
|
@@ -1123,6 +1210,12 @@ export declare function parseJsonText(text: string): {
|
|
|
1123
1210
|
format: NiceJsonTextFormat;
|
|
1124
1211
|
};
|
|
1125
1212
|
|
|
1213
|
+
/**
|
|
1214
|
+
* A layout from its file's text — what it can read of it: unknown fields and broken entries are
|
|
1215
|
+
* dropped, a text that does not parse gives the empty layout.
|
|
1216
|
+
*/
|
|
1217
|
+
export declare function parseStudioLayout(text: string | undefined): NiceStudioLayout;
|
|
1218
|
+
|
|
1126
1219
|
/**
|
|
1127
1220
|
* `previous` with its content replaced by `next`, changing as few bytes as possible. Falls back
|
|
1128
1221
|
* to {@link stringifyJsonText} in the file's own format when the text cannot be patched (invalid
|
|
@@ -1133,9 +1226,36 @@ export declare function patchJsonText(previous: string, next: unknown, options?:
|
|
|
1133
1226
|
/** {@link patchJsonText}, also telling whether the patch was exact. */
|
|
1134
1227
|
export declare function patchJsonTextDetailed(previous: string, next: unknown, options?: NiceJsonPatchOptions): NiceJsonPatchResult;
|
|
1135
1228
|
|
|
1229
|
+
/**
|
|
1230
|
+
* The layout with an entry put somewhere: into a folder (its section follows the folder's), into a
|
|
1231
|
+
* section (out of any folder), or back to its group (`{}`).
|
|
1232
|
+
*/
|
|
1233
|
+
export declare function placeStudioEntry(layout: NiceStudioLayout, ref: string, target: {
|
|
1234
|
+
folder?: string;
|
|
1235
|
+
section?: string;
|
|
1236
|
+
}): NiceStudioLayout;
|
|
1237
|
+
|
|
1136
1238
|
/** The translations inside a file: `translations`, `keys`, or the whole file when it is a flat map. */
|
|
1137
1239
|
export declare function readTranslations(root: unknown): Record<string, string>;
|
|
1138
1240
|
|
|
1241
|
+
/**
|
|
1242
|
+
* The layout without a section or folder. What it held moves up: a folder's entries and folders go
|
|
1243
|
+
* to its parent (or the group), a section's folders and entries back to the module's own groups.
|
|
1244
|
+
*/
|
|
1245
|
+
export declare function removeStudioLayoutNode(layout: NiceStudioLayout, node: {
|
|
1246
|
+
kind: 'section' | 'folder';
|
|
1247
|
+
id: string;
|
|
1248
|
+
}): NiceStudioLayout;
|
|
1249
|
+
|
|
1250
|
+
/** The layout after an entry was renamed — its placement follows it (`entities:Old` → `entities:New`). */
|
|
1251
|
+
export declare function renameStudioEntryRef(layout: NiceStudioLayout, from: string, to: string): NiceStudioLayout;
|
|
1252
|
+
|
|
1253
|
+
/** The layout with a section or folder renamed. */
|
|
1254
|
+
export declare function renameStudioLayoutNode(layout: NiceStudioLayout, node: {
|
|
1255
|
+
kind: 'section' | 'folder';
|
|
1256
|
+
id: string;
|
|
1257
|
+
}, label: string): NiceStudioLayout;
|
|
1258
|
+
|
|
1139
1259
|
/** The kind a path opens with: the first that matches, else JSON or text. */
|
|
1140
1260
|
export declare function resolveFileKind(kinds: readonly NiceStudioFileKind[], path: string): NiceStudioFileKind;
|
|
1141
1261
|
|
|
@@ -1149,12 +1269,24 @@ export declare function safeJson<T = unknown>(text: string, fallback: T): T;
|
|
|
1149
1269
|
/** Convert a FormSchema into DevExtreme-style form items. */
|
|
1150
1270
|
export declare function schemaToFormItems(schema: FormSchema): any[];
|
|
1151
1271
|
|
|
1272
|
+
/** A layout's file text: two-space JSON with a final newline, in the line ending of `previous`. */
|
|
1273
|
+
export declare function serializeStudioLayout(layout: NiceStudioLayout, previous?: string): string;
|
|
1274
|
+
|
|
1152
1275
|
/** A file-name-safe id out of a display name: "Bike rental" → `bike-rental`. */
|
|
1153
1276
|
export declare function slugifyModuleId(name: string): string;
|
|
1154
1277
|
|
|
1155
1278
|
/** Writes `value` in a given format (defaults: two spaces, LF, final newline, no BOM). */
|
|
1156
1279
|
export declare function stringifyJsonText(value: unknown, format?: Partial<NiceJsonTextFormat>): string;
|
|
1157
1280
|
|
|
1281
|
+
/** The ref of an entry in a layout: `group:key`. */
|
|
1282
|
+
export declare const studioEntryRef: (group: string, key: string) => string;
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* The path of a module's layout file: the one it has, else `{prefix}.studio.json` after the prefix
|
|
1286
|
+
* of its files, else `module.studio.json`.
|
|
1287
|
+
*/
|
|
1288
|
+
export declare function studioLayoutPath(files: readonly NiceStudioFile[]): string;
|
|
1289
|
+
|
|
1158
1290
|
/** Any other file, edited as text. */
|
|
1159
1291
|
export declare const textFallbackKind: NiceStudioFileKind<string>;
|
|
1160
1292
|
|