@platforma-open/milaboratories.software-ptabler.schema 1.6.0 → 1.8.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/expressions.d.ts +95 -7
- package/package.json +1 -1
- package/src/expressions.ts +106 -6
package/dist/expressions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataType } from './common';
|
|
2
|
-
export type Expression = ComparisonExpression | BinaryArithmeticExpression | UnaryArithmeticExpression | CastExpression | BooleanLogicExpression | NotExpression | NullCheckExpression | StringJoinExpression | HashExpression | ColumnReferenceExpression | ConstantValueExpression | RankExpression | CumsumExpression | ExtendedUnaryStringExpression | StringDistanceExpression | FuzzyStringFilterExpression | WhenThenOtherwiseExpression | SubstringExpression | StringReplaceExpression | MinMaxExpression | FillNaExpression | WindowExpression;
|
|
2
|
+
export type Expression = ComparisonExpression | BinaryArithmeticExpression | UnaryArithmeticExpression | CastExpression | BooleanLogicExpression | NotExpression | NullCheckExpression | StringJoinExpression | HashExpression | ColumnReferenceExpression | ConstantValueExpression | RankExpression | CumsumExpression | ExtendedUnaryStringExpression | StringDistanceExpression | FuzzyStringFilterExpression | WhenThenOtherwiseExpression | SubstringExpression | StringReplaceExpression | StringContainsExpression | StringStartsWithExpression | StringEndsWithExpression | StringContainsAnyExpression | StringCountMatchesExpression | StringExtractExpression | MinMaxExpression | FillNaExpression | WindowExpression;
|
|
3
3
|
/** Represents all possible expression types in the system. */
|
|
4
4
|
export type ComparisonOperator = 'gt' | 'ge' | 'eq' | 'lt' | 'le' | 'neq';
|
|
5
5
|
/** Defines a comparison operation between two expressions. */
|
|
@@ -242,12 +242,12 @@ export interface SubstringExpression {
|
|
|
242
242
|
type: 'substring';
|
|
243
243
|
/** The expression whose string value will be used. */
|
|
244
244
|
value: Expression;
|
|
245
|
-
/** The starting position (0-indexed). */
|
|
246
|
-
start:
|
|
247
|
-
/** The length of the substring. Mutually exclusive with 'end'. */
|
|
248
|
-
length?:
|
|
249
|
-
/** The end position of the substring (exclusive). Mutually exclusive with 'length'. */
|
|
250
|
-
end?:
|
|
245
|
+
/** The starting position (0-indexed). Should evaluate to a number. */
|
|
246
|
+
start: Expression;
|
|
247
|
+
/** The length of the substring. Mutually exclusive with 'end'. Should evaluate to a number. */
|
|
248
|
+
length?: Expression;
|
|
249
|
+
/** The end position of the substring (exclusive). Mutually exclusive with 'length'. Should evaluate to a number. */
|
|
250
|
+
end?: Expression;
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
253
253
|
* Represents a string replacement operation.
|
|
@@ -276,6 +276,94 @@ export interface StringReplaceExpression {
|
|
|
276
276
|
/** If true, treat the pattern as a literal string. If false or undefined, treat it as a regex. Defaults to false. */
|
|
277
277
|
literal?: boolean;
|
|
278
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Represents a string contains operation.
|
|
281
|
+
* Checks if the string contains a substring that matches a pattern using regex or literal matching.
|
|
282
|
+
* Based on polars.Series.str.contains - supports both regex and literal pattern matching with optional case-insensitive flags.
|
|
283
|
+
*/
|
|
284
|
+
export interface StringContainsExpression {
|
|
285
|
+
/** The type of operation, always 'str_contains'. */
|
|
286
|
+
type: 'str_contains';
|
|
287
|
+
/** The input string expression to search in. */
|
|
288
|
+
value: Expression;
|
|
289
|
+
/** The pattern to search for. Can be a regex pattern (default) or literal string when literal=true. */
|
|
290
|
+
pattern: Expression | string;
|
|
291
|
+
/** If true, treat the pattern as a literal string. If false, treat it as a regex pattern. Defaults to false. */
|
|
292
|
+
literal?: boolean;
|
|
293
|
+
/** If true, raise an error if pattern is invalid regex. If false, return null for invalid patterns. Defaults to true. */
|
|
294
|
+
strict?: boolean;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Represents a string starts_with operation.
|
|
298
|
+
* Checks if the string starts with a specified prefix. Always uses literal matching (no regex support).
|
|
299
|
+
* Based on polars.Series.str.starts_with - only supports literal prefix matching.
|
|
300
|
+
*/
|
|
301
|
+
export interface StringStartsWithExpression {
|
|
302
|
+
/** The type of operation, always 'str_starts_with'. */
|
|
303
|
+
type: 'str_starts_with';
|
|
304
|
+
/** The input string expression to check. */
|
|
305
|
+
value: Expression;
|
|
306
|
+
/** The prefix to check for (always treated as literal string, no regex support). */
|
|
307
|
+
prefix: Expression | string;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Represents a string ends_with operation.
|
|
311
|
+
* Checks if the string ends with a specified suffix. Always uses literal matching (no regex support).
|
|
312
|
+
* Based on polars.Series.str.ends_with - only supports literal suffix matching.
|
|
313
|
+
*/
|
|
314
|
+
export interface StringEndsWithExpression {
|
|
315
|
+
/** The type of operation, always 'str_ends_with'. */
|
|
316
|
+
type: 'str_ends_with';
|
|
317
|
+
/** The input string expression to check. */
|
|
318
|
+
value: Expression;
|
|
319
|
+
/** The suffix to check for (always treated as literal string, no regex support). */
|
|
320
|
+
suffix: Expression | string;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Represents a string contains_any operation using the Aho-Corasick algorithm.
|
|
324
|
+
* Checks if the string contains any of the provided patterns using fast multi-pattern string matching.
|
|
325
|
+
* Based on polars.Series.str.contains_any - uses Aho-Corasick algorithm for efficient multi-pattern matching.
|
|
326
|
+
*/
|
|
327
|
+
export interface StringContainsAnyExpression {
|
|
328
|
+
/** The type of operation, always 'str_contains_any'. */
|
|
329
|
+
type: 'str_contains_any';
|
|
330
|
+
/** The input string expression to search in. */
|
|
331
|
+
value: Expression;
|
|
332
|
+
/** Array of literal string patterns to search for. Only immediate string values are supported, no expressions or regex patterns. */
|
|
333
|
+
patterns: string[];
|
|
334
|
+
/** Enable ASCII-aware case insensitive matching. When enabled, searching is performed without respect to case for ASCII letters (a-z and A-Z) only. Defaults to false. */
|
|
335
|
+
asciiCaseInsensitive?: boolean;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Represents a string count_matches operation.
|
|
339
|
+
* Counts the number of times a pattern occurs in the string using regex or literal matching.
|
|
340
|
+
* Based on polars.Series.str.count_matches - supports both regex and literal pattern matching.
|
|
341
|
+
*/
|
|
342
|
+
export interface StringCountMatchesExpression {
|
|
343
|
+
/** The type of operation, always 'str_count_matches'. */
|
|
344
|
+
type: 'str_count_matches';
|
|
345
|
+
/** The input string expression to count matches in. */
|
|
346
|
+
value: Expression;
|
|
347
|
+
/** The pattern to count occurrences of. Can be a regex pattern (default) or literal string when literal=true. */
|
|
348
|
+
pattern: Expression | string;
|
|
349
|
+
/** If true, treat the pattern as a literal string. If false, treat it as a regex pattern. Defaults to false. */
|
|
350
|
+
literal?: boolean;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Represents a string extract operation using regex patterns.
|
|
354
|
+
* Extracts the first match of a regex pattern from the string, optionally targeting specific capture groups.
|
|
355
|
+
* Based on polars.Series.str.extract - only supports regex patterns (no literal mode).
|
|
356
|
+
*/
|
|
357
|
+
export interface StringExtractExpression {
|
|
358
|
+
/** The type of operation, always 'str_extract'. */
|
|
359
|
+
type: 'str_extract';
|
|
360
|
+
/** The input string expression to extract from. */
|
|
361
|
+
value: Expression;
|
|
362
|
+
/** The regex pattern to extract. Must be a valid regex pattern - no literal string mode is supported. */
|
|
363
|
+
pattern: Expression | string;
|
|
364
|
+
/** The capture group index to extract. Group 0 is the entire match, group 1 is the first capture group, etc. Defaults to 0. */
|
|
365
|
+
groupIndex?: number;
|
|
366
|
+
}
|
|
279
367
|
/** Defines the supported min/max operators. */
|
|
280
368
|
export type MinMaxOperator = 'min' | 'max';
|
|
281
369
|
/** Represents a min or max operation on a list of expressions. */
|
package/package.json
CHANGED
package/src/expressions.ts
CHANGED
|
@@ -20,6 +20,12 @@ export type Expression =
|
|
|
20
20
|
| WhenThenOtherwiseExpression
|
|
21
21
|
| SubstringExpression
|
|
22
22
|
| StringReplaceExpression
|
|
23
|
+
| StringContainsExpression
|
|
24
|
+
| StringStartsWithExpression
|
|
25
|
+
| StringEndsWithExpression
|
|
26
|
+
| StringContainsAnyExpression
|
|
27
|
+
| StringCountMatchesExpression
|
|
28
|
+
| StringExtractExpression
|
|
23
29
|
| MinMaxExpression
|
|
24
30
|
| FillNaExpression
|
|
25
31
|
| WindowExpression;
|
|
@@ -321,12 +327,12 @@ export interface SubstringExpression {
|
|
|
321
327
|
type: 'substring';
|
|
322
328
|
/** The expression whose string value will be used. */
|
|
323
329
|
value: Expression;
|
|
324
|
-
/** The starting position (0-indexed). */
|
|
325
|
-
start:
|
|
326
|
-
/** The length of the substring. Mutually exclusive with 'end'. */
|
|
327
|
-
length?:
|
|
328
|
-
/** The end position of the substring (exclusive). Mutually exclusive with 'length'. */
|
|
329
|
-
end?:
|
|
330
|
+
/** The starting position (0-indexed). Should evaluate to a number. */
|
|
331
|
+
start: Expression;
|
|
332
|
+
/** The length of the substring. Mutually exclusive with 'end'. Should evaluate to a number. */
|
|
333
|
+
length?: Expression;
|
|
334
|
+
/** The end position of the substring (exclusive). Mutually exclusive with 'length'. Should evaluate to a number. */
|
|
335
|
+
end?: Expression;
|
|
330
336
|
}
|
|
331
337
|
|
|
332
338
|
/**
|
|
@@ -357,6 +363,100 @@ export interface StringReplaceExpression {
|
|
|
357
363
|
literal?: boolean;
|
|
358
364
|
}
|
|
359
365
|
|
|
366
|
+
/**
|
|
367
|
+
* Represents a string contains operation.
|
|
368
|
+
* Checks if the string contains a substring that matches a pattern using regex or literal matching.
|
|
369
|
+
* Based on polars.Series.str.contains - supports both regex and literal pattern matching with optional case-insensitive flags.
|
|
370
|
+
*/
|
|
371
|
+
export interface StringContainsExpression {
|
|
372
|
+
/** The type of operation, always 'str_contains'. */
|
|
373
|
+
type: 'str_contains';
|
|
374
|
+
/** The input string expression to search in. */
|
|
375
|
+
value: Expression;
|
|
376
|
+
/** The pattern to search for. Can be a regex pattern (default) or literal string when literal=true. */
|
|
377
|
+
pattern: Expression | string;
|
|
378
|
+
/** If true, treat the pattern as a literal string. If false, treat it as a regex pattern. Defaults to false. */
|
|
379
|
+
literal?: boolean;
|
|
380
|
+
/** If true, raise an error if pattern is invalid regex. If false, return null for invalid patterns. Defaults to true. */
|
|
381
|
+
strict?: boolean;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Represents a string starts_with operation.
|
|
386
|
+
* Checks if the string starts with a specified prefix. Always uses literal matching (no regex support).
|
|
387
|
+
* Based on polars.Series.str.starts_with - only supports literal prefix matching.
|
|
388
|
+
*/
|
|
389
|
+
export interface StringStartsWithExpression {
|
|
390
|
+
/** The type of operation, always 'str_starts_with'. */
|
|
391
|
+
type: 'str_starts_with';
|
|
392
|
+
/** The input string expression to check. */
|
|
393
|
+
value: Expression;
|
|
394
|
+
/** The prefix to check for (always treated as literal string, no regex support). */
|
|
395
|
+
prefix: Expression | string;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Represents a string ends_with operation.
|
|
400
|
+
* Checks if the string ends with a specified suffix. Always uses literal matching (no regex support).
|
|
401
|
+
* Based on polars.Series.str.ends_with - only supports literal suffix matching.
|
|
402
|
+
*/
|
|
403
|
+
export interface StringEndsWithExpression {
|
|
404
|
+
/** The type of operation, always 'str_ends_with'. */
|
|
405
|
+
type: 'str_ends_with';
|
|
406
|
+
/** The input string expression to check. */
|
|
407
|
+
value: Expression;
|
|
408
|
+
/** The suffix to check for (always treated as literal string, no regex support). */
|
|
409
|
+
suffix: Expression | string;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Represents a string contains_any operation using the Aho-Corasick algorithm.
|
|
414
|
+
* Checks if the string contains any of the provided patterns using fast multi-pattern string matching.
|
|
415
|
+
* Based on polars.Series.str.contains_any - uses Aho-Corasick algorithm for efficient multi-pattern matching.
|
|
416
|
+
*/
|
|
417
|
+
export interface StringContainsAnyExpression {
|
|
418
|
+
/** The type of operation, always 'str_contains_any'. */
|
|
419
|
+
type: 'str_contains_any';
|
|
420
|
+
/** The input string expression to search in. */
|
|
421
|
+
value: Expression;
|
|
422
|
+
/** Array of literal string patterns to search for. Only immediate string values are supported, no expressions or regex patterns. */
|
|
423
|
+
patterns: string[];
|
|
424
|
+
/** Enable ASCII-aware case insensitive matching. When enabled, searching is performed without respect to case for ASCII letters (a-z and A-Z) only. Defaults to false. */
|
|
425
|
+
asciiCaseInsensitive?: boolean;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Represents a string count_matches operation.
|
|
430
|
+
* Counts the number of times a pattern occurs in the string using regex or literal matching.
|
|
431
|
+
* Based on polars.Series.str.count_matches - supports both regex and literal pattern matching.
|
|
432
|
+
*/
|
|
433
|
+
export interface StringCountMatchesExpression {
|
|
434
|
+
/** The type of operation, always 'str_count_matches'. */
|
|
435
|
+
type: 'str_count_matches';
|
|
436
|
+
/** The input string expression to count matches in. */
|
|
437
|
+
value: Expression;
|
|
438
|
+
/** The pattern to count occurrences of. Can be a regex pattern (default) or literal string when literal=true. */
|
|
439
|
+
pattern: Expression | string;
|
|
440
|
+
/** If true, treat the pattern as a literal string. If false, treat it as a regex pattern. Defaults to false. */
|
|
441
|
+
literal?: boolean;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Represents a string extract operation using regex patterns.
|
|
446
|
+
* Extracts the first match of a regex pattern from the string, optionally targeting specific capture groups.
|
|
447
|
+
* Based on polars.Series.str.extract - only supports regex patterns (no literal mode).
|
|
448
|
+
*/
|
|
449
|
+
export interface StringExtractExpression {
|
|
450
|
+
/** The type of operation, always 'str_extract'. */
|
|
451
|
+
type: 'str_extract';
|
|
452
|
+
/** The input string expression to extract from. */
|
|
453
|
+
value: Expression;
|
|
454
|
+
/** The regex pattern to extract. Must be a valid regex pattern - no literal string mode is supported. */
|
|
455
|
+
pattern: Expression | string;
|
|
456
|
+
/** The capture group index to extract. Group 0 is the entire match, group 1 is the first capture group, etc. Defaults to 0. */
|
|
457
|
+
groupIndex?: number;
|
|
458
|
+
}
|
|
459
|
+
|
|
360
460
|
/** Defines the supported min/max operators. */
|
|
361
461
|
export type MinMaxOperator = 'min' | 'max';
|
|
362
462
|
|