@nice2dev/ui-forms 1.4.5 → 1.4.6
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 +7 -5
- package/dist/index.d.ts +150 -7
- package/dist/index.mjs +3048 -2256
- package/dist/studio.cjs +21 -8
- package/dist/studio.d.ts +144 -7
- package/dist/studio.mjs +814 -605
- package/dist/ui-forms.css +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { NiceDataSourceSchemaTable } from '@nice2dev/ui';
|
|
|
8
8
|
import { NiceFieldValidationRule } from '@nice2dev/ui';
|
|
9
9
|
import { NiceFormItem } from '@nice2dev/ui';
|
|
10
10
|
import { NiceHookBinding } from '@nice2dev/ui';
|
|
11
|
+
import { NiceNoCodeIo } from '@nice2dev/ui';
|
|
12
|
+
import { NiceNoCodeStep } from '@nice2dev/ui';
|
|
11
13
|
import { NiceRbacModel } from '@nice2dev/ui';
|
|
12
14
|
import { NiceScriptRunnerProps } from '@nice2dev/ui';
|
|
13
15
|
import { NiceStandardProps } from '@nice2dev/ui';
|
|
@@ -58,12 +60,12 @@ export declare function defineManifestSection<TSchema extends JsonSchema>(sectio
|
|
|
58
60
|
|
|
59
61
|
/** A starter access model: admin / user × view / create / edit / delete over the module's views and entities. */
|
|
60
62
|
export declare function deriveDefaultRbac(module: {
|
|
61
|
-
manifest?:
|
|
63
|
+
manifest?: Row_2;
|
|
62
64
|
views?: ReadonlyArray<{
|
|
63
65
|
id: string;
|
|
64
66
|
name: string;
|
|
65
67
|
}>;
|
|
66
|
-
entities?: readonly
|
|
68
|
+
entities?: readonly Row_2[];
|
|
67
69
|
}): NiceRbacModel;
|
|
68
70
|
|
|
69
71
|
/** Reads how `text` is written: BOM, line breaks, indentation, final newline, colon spacing. */
|
|
@@ -82,7 +84,7 @@ export declare function encodeDocument(doc: NiceStudioDocument, model: unknown,
|
|
|
82
84
|
export declare const endsWithAny: (...suffixes: string[]) => (path: string) => boolean;
|
|
83
85
|
|
|
84
86
|
/** The module's entities as the tables NiceDataSourceBuilder queries. */
|
|
85
|
-
export declare function entitiesToSchemas(entities: readonly
|
|
87
|
+
export declare function entitiesToSchemas(entities: readonly Row_2[]): NiceDataSourceSchemaTable[];
|
|
86
88
|
|
|
87
89
|
/** The file name of a path. */
|
|
88
90
|
export declare const fileName: (path: string) => string;
|
|
@@ -222,12 +224,21 @@ export declare interface FormSectionDefinition {
|
|
|
222
224
|
fields: FormFieldDefinition[];
|
|
223
225
|
}
|
|
224
226
|
|
|
227
|
+
/** A list item back as the stored script: its definition merged onto the entry as stored. */
|
|
228
|
+
export declare function fromStudioScriptItem(item: NiceStudioItem<NiceStudioScriptDef>): unknown;
|
|
229
|
+
|
|
225
230
|
/**
|
|
226
231
|
* Translations split into one file per language, edited as one document. A new language gets a
|
|
227
232
|
* file shaped and formatted like its siblings; a language removed in the editor loses its file.
|
|
228
233
|
*/
|
|
229
234
|
export declare function i18nFileKind(o?: NiceI18nFileKindOptions): NiceStudioFileKind<NiceStudioTranslations>;
|
|
230
235
|
|
|
236
|
+
/**
|
|
237
|
+
* The kind of a stored script: its `kind`, else from what it holds — no-code steps, a SQL language
|
|
238
|
+
* or `sql` text, a C# language (server) — else browser code.
|
|
239
|
+
*/
|
|
240
|
+
export declare function inferStudioScriptKind(raw: Row): NiceStudioScriptKind;
|
|
241
|
+
|
|
231
242
|
/** Whether a layout holds nothing (its file can go). */
|
|
232
243
|
export declare const isEmptyStudioLayout: (layout: NiceStudioLayout) => boolean;
|
|
233
244
|
|
|
@@ -314,7 +325,7 @@ export declare function modulePrefix(files: readonly NiceStudioFile[]): string;
|
|
|
314
325
|
|
|
315
326
|
export declare const nativeDataSourcesKind: NiceStudioFileKind<NiceDataSourceDef[]>;
|
|
316
327
|
|
|
317
|
-
export declare const nativeEntitiesKind: NiceStudioFileKind<
|
|
328
|
+
export declare const nativeEntitiesKind: NiceStudioFileKind<Row_3[]>;
|
|
318
329
|
|
|
319
330
|
/** The file kinds of the native format, in matching order. */
|
|
320
331
|
export declare const nativeFileKinds: NiceStudioFileKind[];
|
|
@@ -323,17 +334,29 @@ export declare const nativeHooksKind: NiceStudioFileKind<NiceHookBinding[]>;
|
|
|
323
334
|
|
|
324
335
|
export declare const nativeI18nKind: NiceStudioFileKind<NiceStudioTranslations>;
|
|
325
336
|
|
|
326
|
-
export declare const nativeManifestKind: NiceStudioFileKind<
|
|
337
|
+
export declare const nativeManifestKind: NiceStudioFileKind<Row_3>;
|
|
327
338
|
|
|
328
339
|
export declare const nativeRbacKind: NiceStudioFileKind<NiceRbacModel>;
|
|
329
340
|
|
|
330
|
-
/**
|
|
341
|
+
/** `{id}.scripts.json`: `{ scripts: [...], phases: { postInstall: [...] } }` (1.4.6). */
|
|
342
|
+
export declare const nativeScriptsKind: NiceStudioFileKind<NiceStudioScripts>;
|
|
343
|
+
|
|
344
|
+
/** The studio's own format: manifest, entities, translations, views, workflows, data sources, access, hooks, scripts. */
|
|
331
345
|
export declare const nativeStudioPreset: NiceStudioPreset;
|
|
332
346
|
|
|
333
347
|
export declare const nativeViewsKind: NiceStudioFileKind<NiceStudioItem<NiceViewDefinition>[]>;
|
|
334
348
|
|
|
335
349
|
export declare const nativeWorkflowsKind: NiceStudioFileKind<NiceStudioItem<NiceWorkflowDefinition>[]>;
|
|
336
350
|
|
|
351
|
+
/** A new script of a kind, with a starting body in its language. */
|
|
352
|
+
export declare function newStudioScript(spec: NiceStudioNewScript): NiceStudioScriptDef;
|
|
353
|
+
|
|
354
|
+
/** The script kinds, in the order "Add script" offers them. */
|
|
355
|
+
export declare const NICE_STUDIO_SCRIPT_KINDS: readonly NiceStudioScriptKind[];
|
|
356
|
+
|
|
357
|
+
/** Install phases offered for database scripts when the preset names none. */
|
|
358
|
+
export declare const NICE_STUDIO_SCRIPT_PHASES: readonly string[];
|
|
359
|
+
|
|
337
360
|
/** A generated field, as an AI form generator describes it. */
|
|
338
361
|
export declare interface NiceAIFormFieldLike {
|
|
339
362
|
id?: string;
|
|
@@ -430,6 +453,11 @@ export declare interface NiceDevelopmentStudioProps extends NiceStandardProps {
|
|
|
430
453
|
reviewBeforeSave?: boolean;
|
|
431
454
|
/** Runs script files (`script` documents) in a NiceScriptRunner. */
|
|
432
455
|
scriptRunner?: Omit<NiceScriptRunnerProps, 'value' | 'onChange'>;
|
|
456
|
+
/**
|
|
457
|
+
* The host's data for a module's no-code scripts (1.4.6): with it the script editor's Run runs
|
|
458
|
+
* the steps against it (`read` a data source, `write` rows, `callScript`).
|
|
459
|
+
*/
|
|
460
|
+
scriptIo?: (module: NiceStudioModuleKey) => NiceNoCodeIo | undefined;
|
|
433
461
|
/** The host's own preview of a view (e.g. its runtime renderer): small in the preview, full beside the designer. */
|
|
434
462
|
renderViewPreview?: (ctx: NiceStudioViewPreviewContext) => React.ReactNode;
|
|
435
463
|
/** Extra parts of a module (payments, webhooks, …): rows under the module, opened full-screen. */
|
|
@@ -724,6 +752,22 @@ export declare interface NiceSchemaFormProps extends NiceStandardProps {
|
|
|
724
752
|
tutorial?: NiceComponentTutorial;
|
|
725
753
|
}
|
|
726
754
|
|
|
755
|
+
/** Options of {@link scriptsFileKind}. */
|
|
756
|
+
export declare interface NiceScriptsFileKindOptions {
|
|
757
|
+
id?: string;
|
|
758
|
+
label?: string;
|
|
759
|
+
labelKey?: string;
|
|
760
|
+
icon?: string;
|
|
761
|
+
match(path: string): boolean;
|
|
762
|
+
/** The property holding the scripts list. Default `scripts`; the file may also be the bare list. */
|
|
763
|
+
property?: string;
|
|
764
|
+
/**
|
|
765
|
+
* The property holding the database scripts per phase. Default `phases`. The same as `property`:
|
|
766
|
+
* that property holds either — a list of scripts or an object of phases (OmniVerk).
|
|
767
|
+
*/
|
|
768
|
+
phasesProperty?: string;
|
|
769
|
+
}
|
|
770
|
+
|
|
727
771
|
/** A host's own action in the studio's tree header (e.g. "Open a folder…"). */
|
|
728
772
|
export declare interface NiceStudioAction {
|
|
729
773
|
key: string;
|
|
@@ -735,7 +779,9 @@ export declare interface NiceStudioAction {
|
|
|
735
779
|
}
|
|
736
780
|
|
|
737
781
|
/** The studio's own editors. */
|
|
738
|
-
export declare type NiceStudioBuiltinEditorId = 'manifest' | 'entities' | 'i18n' | 'views' | 'workflows' | 'permissions' | 'rbac' | 'dataSources' | 'seeds' | 'hooks' | 'script'
|
|
782
|
+
export declare type NiceStudioBuiltinEditorId = 'manifest' | 'entities' | 'i18n' | 'views' | 'workflows' | 'permissions' | 'rbac' | 'dataSources' | 'seeds' | 'hooks' | 'script'
|
|
783
|
+
/** A list of named scripts and database scripts per phase ({@link NiceStudioScripts}, 1.4.6). */
|
|
784
|
+
| 'scriptList' | 'json' | 'text';
|
|
739
785
|
|
|
740
786
|
/** What a file kind's decode and encode know about the module. */
|
|
741
787
|
export declare interface NiceStudioCodecContext {
|
|
@@ -989,6 +1035,16 @@ export declare interface NiceStudioModuleSpec {
|
|
|
989
1035
|
permissions?: boolean;
|
|
990
1036
|
}
|
|
991
1037
|
|
|
1038
|
+
/** What "Add script" asks for. */
|
|
1039
|
+
export declare interface NiceStudioNewScript {
|
|
1040
|
+
kind: NiceStudioScriptKind;
|
|
1041
|
+
/** The display name; the script's `name` is made from it. */
|
|
1042
|
+
name: string;
|
|
1043
|
+
language?: string;
|
|
1044
|
+
category?: string;
|
|
1045
|
+
trigger?: string;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
992
1048
|
/** A group of modules in a workspace (a category, a product line). */
|
|
993
1049
|
export declare interface NiceStudioPackage {
|
|
994
1050
|
id: string;
|
|
@@ -1061,6 +1117,8 @@ export declare interface NiceStudioPreset {
|
|
|
1061
1117
|
path: string;
|
|
1062
1118
|
text: string;
|
|
1063
1119
|
} | undefined;
|
|
1120
|
+
/** Kinds, categories, triggers and phases of the module's scripts (1.4.6). */
|
|
1121
|
+
scripts?: NiceStudioScriptOptions;
|
|
1064
1122
|
/** Lifecycle triggers offered by a `hooks` document. */
|
|
1065
1123
|
hooks?: {
|
|
1066
1124
|
triggers: Array<{
|
|
@@ -1132,6 +1190,73 @@ export declare interface NiceStudioRevision {
|
|
|
1132
1190
|
path?: string;
|
|
1133
1191
|
}
|
|
1134
1192
|
|
|
1193
|
+
/** A named script of a module (1.4.6). Fields the studio does not edit stay in the stored entry. */
|
|
1194
|
+
export declare interface NiceStudioScriptDef {
|
|
1195
|
+
id?: string;
|
|
1196
|
+
/** The name other scripts and the app call it by (unique in the module). */
|
|
1197
|
+
name: string;
|
|
1198
|
+
displayName?: string;
|
|
1199
|
+
description?: string;
|
|
1200
|
+
kind: NiceStudioScriptKind;
|
|
1201
|
+
/** `typescript`, `javascript`, `csharp`, `sql`… (none for a no-code script). */
|
|
1202
|
+
language?: string;
|
|
1203
|
+
/** Free grouping: `formatting`, `validation`, `integration`… */
|
|
1204
|
+
category?: string;
|
|
1205
|
+
/** What runs it: an event, a schedule, a button (one of the preset's `scripts.triggers`). */
|
|
1206
|
+
trigger?: string;
|
|
1207
|
+
parameters?: NiceStudioScriptParameter[];
|
|
1208
|
+
returnType?: string;
|
|
1209
|
+
/** The code (frontend, backend, SQL). */
|
|
1210
|
+
source?: string;
|
|
1211
|
+
/** A file of the module holding the code instead of `source`. */
|
|
1212
|
+
sourcePath?: string;
|
|
1213
|
+
/** The steps of a no-code script. */
|
|
1214
|
+
steps?: NiceNoCodeStep[];
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
/**
|
|
1218
|
+
* What a script is (1.4.6): code run in the browser (`frontend`), code run on the server
|
|
1219
|
+
* (`backend`), no-code steps (`noCode`, run by `runNoCodeScript`) or a SQL query or procedure.
|
|
1220
|
+
*/
|
|
1221
|
+
export declare type NiceStudioScriptKind = 'frontend' | 'backend' | 'noCode' | 'sql';
|
|
1222
|
+
|
|
1223
|
+
/** How a preset's scripts look (1.4.6). */
|
|
1224
|
+
export declare interface NiceStudioScriptOptions {
|
|
1225
|
+
/** The kinds "Add script" offers. Default: all four. */
|
|
1226
|
+
kinds?: NiceStudioScriptKind[];
|
|
1227
|
+
/** Categories offered (the module's own are offered too). */
|
|
1228
|
+
categories?: string[];
|
|
1229
|
+
/** What can run a script. */
|
|
1230
|
+
triggers?: Array<{
|
|
1231
|
+
id: string;
|
|
1232
|
+
label: string;
|
|
1233
|
+
description?: string;
|
|
1234
|
+
}>;
|
|
1235
|
+
/** Install phases offered for database scripts. Default: preInstall, postInstall, preUninstall, postUninstall. */
|
|
1236
|
+
phases?: string[];
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
/** A parameter of a script. */
|
|
1240
|
+
export declare interface NiceStudioScriptParameter {
|
|
1241
|
+
name: string;
|
|
1242
|
+
/** Its type as the script's language writes it (`string`, `Date | string`, `decimal`). */
|
|
1243
|
+
type?: string;
|
|
1244
|
+
description?: string;
|
|
1245
|
+
default?: unknown;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/** The model of the `scriptList` editor (1.4.6): named scripts and database scripts per phase. */
|
|
1249
|
+
export declare interface NiceStudioScripts {
|
|
1250
|
+
scripts: Array<NiceStudioItem<NiceStudioScriptDef>>;
|
|
1251
|
+
/** SQL statements per install phase: `{ postInstall: ['CREATE INDEX …'] }`. */
|
|
1252
|
+
phases?: Record<string, string[]>;
|
|
1253
|
+
/**
|
|
1254
|
+
* What the file can hold when one property keeps either (OmniVerk's `scripts` is a list of
|
|
1255
|
+
* scripts or an object of phases): only named scripts, or only phases. Absent: both.
|
|
1256
|
+
*/
|
|
1257
|
+
holds?: 'scripts' | 'phases';
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1135
1260
|
/** The model of the `seeds` editor: rows per entity, plus demo rows. */
|
|
1136
1261
|
export declare interface NiceStudioSeeds {
|
|
1137
1262
|
seeds: Record<string, Array<Record<string, unknown>>>;
|
|
@@ -1263,12 +1388,21 @@ declare type Row = Record<string, unknown>;
|
|
|
1263
1388
|
|
|
1264
1389
|
declare type Row_2 = Record<string, unknown>;
|
|
1265
1390
|
|
|
1391
|
+
declare type Row_3 = Record<string, unknown>;
|
|
1392
|
+
|
|
1266
1393
|
/** Parses JSON without a BOM and returns `fallback` when the text is not JSON. */
|
|
1267
1394
|
export declare function safeJson<T = unknown>(text: string, fallback: T): T;
|
|
1268
1395
|
|
|
1269
1396
|
/** Convert a FormSchema into DevExtreme-style form items. */
|
|
1270
1397
|
export declare function schemaToFormItems(schema: FormSchema): any[];
|
|
1271
1398
|
|
|
1399
|
+
/**
|
|
1400
|
+
* A file of named scripts and database scripts per phase (the `scriptList` editor). Scripts the
|
|
1401
|
+
* form does not understand stay raw and round-trip as they are; a file whose phases are not lists
|
|
1402
|
+
* of SQL text opens as raw JSON.
|
|
1403
|
+
*/
|
|
1404
|
+
export declare function scriptsFileKind(o: NiceScriptsFileKindOptions): NiceStudioFileKind<NiceStudioScripts>;
|
|
1405
|
+
|
|
1272
1406
|
/** A layout's file text: two-space JSON with a final newline, in the line ending of `previous`. */
|
|
1273
1407
|
export declare function serializeStudioLayout(layout: NiceStudioLayout, previous?: string): string;
|
|
1274
1408
|
|
|
@@ -1287,9 +1421,18 @@ export declare const studioEntryRef: (group: string, key: string) => string;
|
|
|
1287
1421
|
*/
|
|
1288
1422
|
export declare function studioLayoutPath(files: readonly NiceStudioFile[]): string;
|
|
1289
1423
|
|
|
1424
|
+
/** `"Send invoice"` → `sendInvoice`: a name usable as a function's. */
|
|
1425
|
+
export declare function studioScriptIdentifier(name: string): string;
|
|
1426
|
+
|
|
1427
|
+
/** The languages of a kind, the first being the default (none for no-code). */
|
|
1428
|
+
export declare function studioScriptLanguages(kind: NiceStudioScriptKind): string[];
|
|
1429
|
+
|
|
1290
1430
|
/** Any other file, edited as text. */
|
|
1291
1431
|
export declare const textFallbackKind: NiceStudioFileKind<string>;
|
|
1292
1432
|
|
|
1433
|
+
/** A stored script as a list item: with a definition when the form can keep every field it edits. */
|
|
1434
|
+
export declare function toStudioScriptItem(raw: unknown, index: number): NiceStudioItem<NiceStudioScriptDef>;
|
|
1435
|
+
|
|
1293
1436
|
/**
|
|
1294
1437
|
* Validate a value object against a (subset of) Draft-07 JSON Schema.
|
|
1295
1438
|
* Covers required, type, enum, minLength/maxLength, minimum/maximum and pattern.
|