@nice2dev/ui-forms 1.4.5 → 1.4.7

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