@nice2dev/ui 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.d.ts CHANGED
@@ -4793,6 +4793,12 @@ declare interface ESLintRuleContext {
4793
4793
  };
4794
4794
  }
4795
4795
 
4796
+ /**
4797
+ * The value of an expression in a scope. Throws on a syntax error. A text template — an expression
4798
+ * that is a single string with `{{path}}` in it — fills each `{{…}}` with that path's value.
4799
+ */
4800
+ export declare function evaluateNoCodeExpression(source: string, scope: Record<string, unknown>): unknown;
4801
+
4796
4802
  export { evaluateValidation }
4797
4803
 
4798
4804
  export { evaluateValidationRule }
@@ -7355,6 +7361,9 @@ export declare type NetworkNodeCategory = 'router' | 'switch' | 'access-point' |
7355
7361
 
7356
7362
  export declare type NetworkNodeStatus = 'online' | 'offline' | 'warning';
7357
7363
 
7364
+ /** A new step of a type, with empty settings. */
7365
+ export declare function newNoCodeStep(type: StepType): NiceNoCodeStep;
7366
+
7358
7367
  /** Tiny non-cryptographic id generator suitable for UI-only records. */
7359
7368
  export declare function newRecipeId(prefix?: string): string;
7360
7369
 
@@ -7378,6 +7387,9 @@ export { NICE_INTENT_EVENT }
7378
7387
 
7379
7388
  export { NICE_INTENTS }
7380
7389
 
7390
+ /** The kinds of step, in the order the editor offers them. */
7391
+ export declare const NICE_NO_CODE_STEP_TYPES: readonly ["read", "filter", "map", "aggregate", "set", "if", "forEach", "write", "callScript", "return"];
7392
+
7381
7393
  export { NICE_THEME_ARCHIVE }
7382
7394
 
7383
7395
  /** The archived themes in categories, as the catalog had them before 1.4.0. */
@@ -18136,6 +18148,152 @@ declare interface NiceNetworkNodePort {
18136
18148
  state: string;
18137
18149
  }
18138
18150
 
18151
+ /**
18152
+ * No-code scripts (1.4.6, R43 — documentation/PLAN.md §2: "skrypty… przede wszystkim no code operujące
18153
+ * na źródłach danych"): a script is a list of steps — read rows from a data source, filter, map,
18154
+ * aggregate, set variables, branch, loop, write rows, call another script, return a value — run by
18155
+ * {@link runNoCodeScript} against the host's data through a small I/O adapter. React-free.
18156
+ *
18157
+ * Values in steps are expressions of a tiny, safe language (no `eval`): numbers, `'strings'`,
18158
+ * `true` / `false` / `null`, variable paths (`order.total`, `rows.length`; inside a row step the
18159
+ * row's fields by name), `+ - * /`, comparisons, `&& || !`, parentheses — and text templates
18160
+ * (`'Hello {{customer.name}}'`).
18161
+ */
18162
+ /** A condition on a value: `field op value` (all conditions of a list must hold). */
18163
+ export declare interface NiceNoCodeCondition {
18164
+ /** A path into the row (or, outside a row step, into the variables). */
18165
+ field: string;
18166
+ op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'empty' | 'notEmpty';
18167
+ /** An expression. Not used by `empty` / `notEmpty`. */
18168
+ value?: string;
18169
+ }
18170
+
18171
+ /** How a script reaches the host's data. */
18172
+ export declare interface NiceNoCodeIo {
18173
+ read(source: string): Promise<ReadonlyArray<Record<string, unknown>>>;
18174
+ write?(target: string, rows: ReadonlyArray<Record<string, unknown>>, mode: 'insert' | 'update' | 'upsert' | 'delete'): Promise<void>;
18175
+ callScript?(name: string, args: Record<string, unknown>): Promise<unknown>;
18176
+ }
18177
+
18178
+ /** A problem found in a script. */
18179
+ export declare interface NiceNoCodeIssue {
18180
+ stepId?: string;
18181
+ message: string;
18182
+ }
18183
+
18184
+ /** What a run gives back: the returned value, the variables at the end, the steps it went through. */
18185
+ export declare interface NiceNoCodeRunResult {
18186
+ value: unknown;
18187
+ variables: Record<string, unknown>;
18188
+ /** Step ids in the order they ran (a loop's steps once per row). */
18189
+ trace: string[];
18190
+ }
18191
+
18192
+ /** A no-code script: its parameters and its steps. */
18193
+ export declare interface NiceNoCodeScript {
18194
+ parameters?: Array<{
18195
+ name: string;
18196
+ type?: string;
18197
+ description?: string;
18198
+ }>;
18199
+ steps: NiceNoCodeStep[];
18200
+ }
18201
+
18202
+ /**
18203
+ * {@link NiceNoCodeScriptEditor} — the steps of a no-code script, nested, with the picked step's
18204
+ * settings beside them and the script's problems marked.
18205
+ */
18206
+ export declare const NiceNoCodeScriptEditor: default_2.FC<NiceNoCodeScriptEditorProps>;
18207
+
18208
+ /** Props for the {@link NiceNoCodeScriptEditor} component. */
18209
+ export declare interface NiceNoCodeScriptEditorProps extends NiceBaseProps {
18210
+ /** The script — **controlled**. Omit it to let the editor keep its own copy. */
18211
+ value?: NiceNoCodeScript;
18212
+ /** The script at first in the uncontrolled mode. Default: no steps. */
18213
+ defaultValue?: NiceNoCodeScript;
18214
+ onChange?: (script: NiceNoCodeScript) => void;
18215
+ /** Data source keys offered by `read` and `write` steps. */
18216
+ dataSources?: string[];
18217
+ /** Script names offered by `callScript` steps. */
18218
+ scripts?: string[];
18219
+ /** The host's data: with it a Run button runs the script and shows its result. */
18220
+ io?: NiceNoCodeIo;
18221
+ readOnly?: boolean;
18222
+ }
18223
+
18224
+ /** One step of a no-code script. Each has an `id`, unique in the script. */
18225
+ export declare type NiceNoCodeStep = {
18226
+ id: string;
18227
+ type: 'read';
18228
+ /** The data source's key. */
18229
+ source: string;
18230
+ where?: NiceNoCodeCondition[];
18231
+ /** The variable the rows go to. */
18232
+ into: string;
18233
+ } | {
18234
+ id: string;
18235
+ type: 'filter';
18236
+ from: string;
18237
+ where: NiceNoCodeCondition[];
18238
+ into: string;
18239
+ } | {
18240
+ id: string;
18241
+ type: 'map';
18242
+ from: string;
18243
+ /** Each target field and its expression over the row. */
18244
+ fields: Array<{
18245
+ target: string;
18246
+ expression: string;
18247
+ }>;
18248
+ into: string;
18249
+ } | {
18250
+ id: string;
18251
+ type: 'aggregate';
18252
+ from: string;
18253
+ groupBy?: string[];
18254
+ measures: Array<{
18255
+ name: string;
18256
+ op: 'count' | 'sum' | 'avg' | 'min' | 'max';
18257
+ field?: string;
18258
+ }>;
18259
+ into: string;
18260
+ } | {
18261
+ id: string;
18262
+ type: 'set';
18263
+ variable: string;
18264
+ expression: string;
18265
+ } | {
18266
+ id: string;
18267
+ type: 'if';
18268
+ when: NiceNoCodeCondition[];
18269
+ then: NiceNoCodeStep[];
18270
+ else?: NiceNoCodeStep[];
18271
+ } | {
18272
+ id: string;
18273
+ type: 'forEach';
18274
+ from: string;
18275
+ as: string;
18276
+ steps: NiceNoCodeStep[];
18277
+ } | {
18278
+ id: string;
18279
+ type: 'write';
18280
+ /** The data source or entity written to. */
18281
+ target: string;
18282
+ from: string;
18283
+ mode?: 'insert' | 'update' | 'upsert' | 'delete';
18284
+ } | {
18285
+ id: string;
18286
+ type: 'callScript';
18287
+ script: string;
18288
+ /** Argument name → expression. */
18289
+ args?: Record<string, string>;
18290
+ into?: string;
18291
+ } | {
18292
+ id: string;
18293
+ type: 'return';
18294
+ expression: string;
18295
+ };
18296
+
18139
18297
  export declare interface NiceNotificationCategory {
18140
18298
  id: string;
18141
18299
  name: string;
@@ -26442,6 +26600,12 @@ declare interface NiceXLSXOptions extends NiceExportOptions {
26442
26600
  }>;
26443
26601
  }
26444
26602
 
26603
+ /** Whether every condition holds for `row` (its fields), with `scope` for the values' expressions. */
26604
+ export declare function noCodeConditionsHold(conditions: readonly NiceNoCodeCondition[] | undefined, row: Record<string, unknown>, scope: Record<string, unknown>): boolean;
26605
+
26606
+ /** The value at a dotted path (`order.lines.length`), or undefined. */
26607
+ export declare function noCodePath(scope: Record<string, unknown>, path: string): unknown;
26608
+
26445
26609
  /**
26446
26610
  * Node shape types
26447
26611
  */
@@ -27965,6 +28129,14 @@ export declare function runCLI(argv: string[]): Promise<string>;
27965
28129
  */
27966
28130
  export declare function runContractTests(contracts: NiceApiContract[], config: NiceContractTestConfig): Promise<NiceContractReport>;
27967
28131
 
28132
+ /**
28133
+ * Runs a script: its steps in order over `variables` (the arguments), reading and writing through
28134
+ * `io`. Stops at a `return` step (its value is the result) or after `maxSteps` (a loop gone wrong).
28135
+ */
28136
+ export declare function runNoCodeScript(script: NiceNoCodeScript, io: NiceNoCodeIo, args?: Record<string, unknown>, options?: {
28137
+ maxSteps?: number;
28138
+ }): Promise<NiceNoCodeRunResult>;
28139
+
27968
28140
  declare type RunStatus = 'queued' | 'in_progress' | 'completed' | 'failed' | 'cancelled' | 'waiting' | 'skipped';
27969
28141
 
27970
28142
  export { SafeAreaInsets }
@@ -29189,6 +29361,8 @@ declare interface StateSlice {
29189
29361
  computed?: ComputedField[];
29190
29362
  }
29191
29363
 
29364
+ declare type StepType = NiceNoCodeStep['type'];
29365
+
29192
29366
  export { StorageAdapter }
29193
29367
 
29194
29368
  export { StorageAuditResult }
@@ -31495,6 +31669,9 @@ export declare function validateDoc(doc: unknown): string[];
31495
31669
  /** Validate a module manifest and return error messages. */
31496
31670
  export declare function validateModuleManifest(m: NiceModuleManifest): string[];
31497
31671
 
31672
+ /** The script's problems: missing names, duplicate ids, expressions that do not parse. */
31673
+ export declare function validateNoCodeScript(script: NiceNoCodeScript): NiceNoCodeIssue[];
31674
+
31498
31675
  /** Validate an RBAC policy for structural issues. */
31499
31676
  export declare function validateRbacPolicy(policy: NiceRbacPolicy): string[];
31500
31677