@stll/template-conditions 0.5.3 → 0.5.4
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 +62 -62
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CompareNode, CompareOp, Condition, ConditionNode, ConditionNode as ConditionNode$1, GroupNode, Operand, PredicateNode, PredicateOp, conditionHasFormula, conditionNodeSchema, conditionSchema, emptyCondition } from "@stll/conditions";
|
|
2
2
|
//#region src/path.d.ts
|
|
3
3
|
/** Resolve a dotted path like `company.name` against data. */
|
|
4
|
-
declare const resolvePath: (path: string, data: Record<string, unknown>) => unknown;
|
|
4
|
+
export declare const resolvePath: (path: string, data: Record<string, unknown>) => unknown;
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/parse.d.ts
|
|
7
7
|
/** Bare words the tokenizer reads as operators or literals; a data path can
|
|
8
8
|
* never be one of them. */
|
|
9
|
-
declare const CONDITION_RESERVED_WORDS: readonly ["and", "or", "not", "in", "is", "defined", "true", "false"];
|
|
10
|
-
declare const parseCondition: (expression: string) => ConditionNode$1 | null;
|
|
9
|
+
export declare const CONDITION_RESERVED_WORDS: readonly ["and", "or", "not", "in", "is", "defined", "true", "false"];
|
|
10
|
+
export declare const parseCondition: (expression: string) => ConditionNode$1 | null;
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/referenced-paths.d.ts
|
|
13
13
|
/**
|
|
@@ -23,7 +23,7 @@ declare const parseCondition: (expression: string) => ConditionNode$1 | null;
|
|
|
23
23
|
* deciding what a condition depends on must not read that as "depends on
|
|
24
24
|
* nothing".
|
|
25
25
|
*/
|
|
26
|
-
declare const referencedConditionPaths: (expression: string) => string[] | null;
|
|
26
|
+
export declare const referencedConditionPaths: (expression: string) => string[] | null;
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/compute.d.ts
|
|
29
29
|
/**
|
|
@@ -43,9 +43,9 @@ declare const referencedConditionPaths: (expression: string) => string[] | null;
|
|
|
43
43
|
* non-numeric variable, division producing a non-finite result) so callers
|
|
44
44
|
* can fall back to leaving the field unfilled rather than emitting `NaN`.
|
|
45
45
|
*/
|
|
46
|
-
declare const NUMERIC_FUNCTION_NAMES: readonly ["min", "max", "round", "abs", "floor", "ceil"];
|
|
46
|
+
export declare const NUMERIC_FUNCTION_NAMES: readonly ["min", "max", "round", "abs", "floor", "ceil"];
|
|
47
47
|
type NumericFunctionName = (typeof NUMERIC_FUNCTION_NAMES)[number];
|
|
48
|
-
declare const evaluateNumericExpression: (expression: string, data: Record<string, unknown>) => number | undefined;
|
|
48
|
+
export declare const evaluateNumericExpression: (expression: string, data: Record<string, unknown>) => number | undefined;
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region src/field-values.d.ts
|
|
51
51
|
/**
|
|
@@ -67,10 +67,10 @@ declare const evaluateNumericExpression: (expression: string, data: Record<strin
|
|
|
67
67
|
* STRUCTURAL shapes so the package stays free of api/web imports; callers pass
|
|
68
68
|
* their own field objects, which structurally satisfy these.
|
|
69
69
|
*/
|
|
70
|
-
declare const DATE_FORMAT_STYLES: readonly ["long", "medium", "short", "iso"];
|
|
70
|
+
export declare const DATE_FORMAT_STYLES: readonly ["long", "medium", "short", "iso"];
|
|
71
71
|
type DateFormatStyle = (typeof DATE_FORMAT_STYLES)[number];
|
|
72
72
|
/** Stable exemplar for date-format configuration previews. */
|
|
73
|
-
declare const DATE_FORMAT_EXAMPLE_ISO = "2028-06-13";
|
|
73
|
+
export declare const DATE_FORMAT_EXAMPLE_ISO = "2028-06-13";
|
|
74
74
|
/** Locale-aware date rendering config. "iso" leaves the submitted value as-is;
|
|
75
75
|
* the other styles map to `Intl.DateTimeFormat` `dateStyle`. */
|
|
76
76
|
type FieldDateFormat = {
|
|
@@ -85,7 +85,7 @@ type FieldDateFormat = {
|
|
|
85
85
|
* 2028". The "iso" style returns the value unchanged; an invalid calendar date
|
|
86
86
|
* returns null.
|
|
87
87
|
*/
|
|
88
|
-
declare const formatDate: (value: string, dateFormat: FieldDateFormat) => string | null;
|
|
88
|
+
export declare const formatDate: (value: string, dateFormat: FieldDateFormat) => string | null;
|
|
89
89
|
/**
|
|
90
90
|
* Minimal STRUCTURAL config of a field, carrying only what the deterministic
|
|
91
91
|
* transforms read. Callers (api FieldMeta, web StudioField) structurally
|
|
@@ -112,7 +112,7 @@ type DeterministicFieldConfig = {
|
|
|
112
112
|
* Formula and date return null when the expression or value does not yield a
|
|
113
113
|
* value, so the caller leaves the field as-is.
|
|
114
114
|
*/
|
|
115
|
-
declare const renderDeterministicFieldValue: (field: DeterministicFieldConfig, values: Record<string, unknown>) => string | null;
|
|
115
|
+
export declare const renderDeterministicFieldValue: (field: DeterministicFieldConfig, values: Record<string, unknown>) => string | null;
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/condition-builder.d.ts
|
|
118
118
|
/**
|
|
@@ -120,7 +120,7 @@ declare const renderDeterministicFieldValue: (field: DeterministicFieldConfig, v
|
|
|
120
120
|
* Returns an empty string for an empty tree (caller treats that as "no
|
|
121
121
|
* condition" / always-visible).
|
|
122
122
|
*/
|
|
123
|
-
declare const serializeCondition: (node: ConditionNode$1) => string;
|
|
123
|
+
export declare const serializeCondition: (node: ConditionNode$1) => string;
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/markers.d.ts
|
|
126
126
|
/**
|
|
@@ -159,7 +159,7 @@ type FilterCall = {
|
|
|
159
159
|
args: readonly FilterArgument[];
|
|
160
160
|
};
|
|
161
161
|
/** The loop properties addressable inside a `{% for %}` body. */
|
|
162
|
-
declare const LOOP_PROPERTIES: readonly ["index", "index0", "first", "last", "length"];
|
|
162
|
+
export declare const LOOP_PROPERTIES: readonly ["index", "index0", "first", "last", "length"];
|
|
163
163
|
type LoopProperty = (typeof LOOP_PROPERTIES)[number];
|
|
164
164
|
type MarkerMeta = {
|
|
165
165
|
kind: "placeholder";
|
|
@@ -199,7 +199,7 @@ type MarkerMeta = {
|
|
|
199
199
|
kind: "endfor";
|
|
200
200
|
};
|
|
201
201
|
type DirectiveKind = MarkerMeta["kind"];
|
|
202
|
-
declare const DIRECTIVE_KINDS: readonly ["placeholder", "clause", "num", "ref", "loop", "if", "elif", "else", "endif", "for", "endfor"];
|
|
202
|
+
export declare const DIRECTIVE_KINDS: readonly ["placeholder", "clause", "num", "ref", "loop", "if", "elif", "else", "endif", "for", "endfor"];
|
|
203
203
|
declare const DIRECTIVE_PLACEMENT: {
|
|
204
204
|
readonly placeholder: "inline";
|
|
205
205
|
readonly clause: "inline";
|
|
@@ -215,19 +215,19 @@ declare const DIRECTIVE_PLACEMENT: {
|
|
|
215
215
|
};
|
|
216
216
|
type BlockDirectiveKind = { [TKind in DirectiveKind]: (typeof DIRECTIVE_PLACEMENT)[TKind] extends "block" ? TKind : never; }[DirectiveKind];
|
|
217
217
|
/** Directives that occupy their own paragraph, in canonical grammar order. */
|
|
218
|
-
declare const BLOCK_DIRECTIVE_KINDS: readonly ["if", "elif", "else", "endif", "for", "endfor"];
|
|
219
|
-
declare const isBlockDirectiveKind: (kind: unknown) => kind is BlockDirectiveKind;
|
|
218
|
+
export declare const BLOCK_DIRECTIVE_KINDS: readonly ["if", "elif", "else", "endif", "for", "endfor"];
|
|
219
|
+
export declare const isBlockDirectiveKind: (kind: unknown) => kind is BlockDirectiveKind;
|
|
220
220
|
/**
|
|
221
221
|
* Every filter the dialect accepts on a fillable value. The names are the
|
|
222
222
|
* grammar's; which manifest property each one writes is decided by the field
|
|
223
223
|
* catalogue in the api, which is total over BOTH this list and the manifest
|
|
224
224
|
* keys, so neither side can gain an entry the other has not decided.
|
|
225
225
|
*/
|
|
226
|
-
declare const FILTER_NAMES: readonly ["text", "number", "date", "checkbox", "select", "options_from", "label", "hint", "required", "pattern", "min", "max", "min_length", "max_length", "min_items", "max_items", "ai", "lookup", "matter", "contact", "party", "attorney", "firm", "formula", "condition"];
|
|
226
|
+
export declare const FILTER_NAMES: readonly ["text", "number", "date", "checkbox", "select", "options_from", "label", "hint", "required", "pattern", "min", "max", "min_length", "max_length", "min_items", "max_items", "ai", "lookup", "matter", "contact", "party", "attorney", "firm", "formula", "condition"];
|
|
227
227
|
type FilterName = (typeof FILTER_NAMES)[number];
|
|
228
228
|
/** Normalise one marker's inner text: typographic quotes become straight
|
|
229
229
|
* quotes, fixed-width spaces become ordinary ones. */
|
|
230
|
-
declare const normalizeMarkerInner: (inner: string) => string;
|
|
230
|
+
export declare const normalizeMarkerInner: (inner: string) => string;
|
|
231
231
|
/**
|
|
232
232
|
* What an output marker holds between its braces: anything but a brace or a
|
|
233
233
|
* double quote, plus whole double-quoted arguments, whose braces are content
|
|
@@ -246,39 +246,39 @@ declare const normalizeMarkerInner: (inner: string) => string;
|
|
|
246
246
|
* adversarial input: a `{{` with no closing `}}` costs one failed pass, not a
|
|
247
247
|
* polynomial retry.
|
|
248
248
|
*/
|
|
249
|
-
declare const MARKER_OUTPUT_BODY: string;
|
|
249
|
+
export declare const MARKER_OUTPUT_BODY: string;
|
|
250
250
|
/** What a tag holds between `{%` and `%}`: anything but a brace, and a `%`
|
|
251
251
|
* only where it does not close the tag. */
|
|
252
|
-
declare const MARKER_STATEMENT_BODY: string;
|
|
252
|
+
export declare const MARKER_STATEMENT_BODY: string;
|
|
253
253
|
/**
|
|
254
254
|
* Any marker span: an output `{{...}}` (group `output`) or a tag `{%...%}`
|
|
255
255
|
* (group `statement`, with the docxtpl placement in group `prefix`).
|
|
256
256
|
*/
|
|
257
|
-
declare const markerPattern: () => RegExp;
|
|
257
|
+
export declare const markerPattern: () => RegExp;
|
|
258
258
|
/** Inline value marker, including its filter chain; group `name` is the path
|
|
259
259
|
* the value comes from and group `filters` the untouched chain. */
|
|
260
|
-
declare const placeholderPattern: () => RegExp;
|
|
260
|
+
export declare const placeholderPattern: () => RegExp;
|
|
261
261
|
/** `{{ clause("Name") }}` / `{{ clause("Name", "v3") }}`. */
|
|
262
|
-
declare const clauseSlotPattern: () => RegExp;
|
|
262
|
+
export declare const clauseSlotPattern: () => RegExp;
|
|
263
263
|
/** `{{ num("key") }}` — the `key` group. */
|
|
264
|
-
declare const numPattern: () => RegExp;
|
|
264
|
+
export declare const numPattern: () => RegExp;
|
|
265
265
|
/** `{{ ref("key") }}` — the `key` group. */
|
|
266
|
-
declare const refPattern: () => RegExp;
|
|
266
|
+
export declare const refPattern: () => RegExp;
|
|
267
267
|
/** `{{ loop.index }}` and its siblings — the `property` group. */
|
|
268
|
-
declare const loopPattern: () => RegExp;
|
|
268
|
+
export declare const loopPattern: () => RegExp;
|
|
269
269
|
/** Cheap presence test for any numbering marker (no capture). */
|
|
270
|
-
declare const hasNumberingPattern: () => RegExp;
|
|
270
|
+
export declare const hasNumberingPattern: () => RegExp;
|
|
271
271
|
/** Cheap presence test for any tag (no capture). */
|
|
272
|
-
declare const hasBlockDirectivePattern: () => RegExp;
|
|
272
|
+
export declare const hasBlockDirectivePattern: () => RegExp;
|
|
273
273
|
/** A whole line that is a single block tag — `prefix`, `tag` and `expr`. */
|
|
274
|
-
declare const blockDirectiveLinePattern: () => RegExp;
|
|
274
|
+
export declare const blockDirectiveLinePattern: () => RegExp;
|
|
275
275
|
/** Whether `value` is a valid field path per the marker grammar (dotted
|
|
276
276
|
* segments of letters/digits/underscore/dash — no brackets or spaces). */
|
|
277
|
-
declare const isFieldPath: (value: string) => boolean;
|
|
277
|
+
export declare const isFieldPath: (value: string) => boolean;
|
|
278
278
|
/** Whether `value` is safe to use as a dotted object path. */
|
|
279
|
-
declare const isSafeFieldPath: (value: string) => boolean;
|
|
279
|
+
export declare const isSafeFieldPath: (value: string) => boolean;
|
|
280
280
|
/** Whether `value` is a valid name for authoring a `clause("NAME")` slot. */
|
|
281
|
-
declare const isClauseSlotName: (value: string) => boolean;
|
|
281
|
+
export declare const isClauseSlotName: (value: string) => boolean;
|
|
282
282
|
/** Which brace pair carried the marker text. */
|
|
283
283
|
type MarkerForm = "output" | "statement";
|
|
284
284
|
/** Where a tag's docxtpl prefix says the tag belongs. `"none"` is a bare tag,
|
|
@@ -288,7 +288,7 @@ type MarkerPrefix = "none" | "paragraph" | "row";
|
|
|
288
288
|
* Classify the inner text of one marker. Returns `null` when the text is not a
|
|
289
289
|
* recognized directive (so a recognizer can leave stray braces alone).
|
|
290
290
|
*/
|
|
291
|
-
declare const classifyMarker: (innerRaw: string, form?: MarkerForm) => MarkerMeta | null;
|
|
291
|
+
export declare const classifyMarker: (innerRaw: string, form?: MarkerForm) => MarkerMeta | null;
|
|
292
292
|
type ScannedMarker = {
|
|
293
293
|
/** Offset of the opening brace pair in the source text. */
|
|
294
294
|
start: number;
|
|
@@ -307,23 +307,23 @@ type ScannedMarker = {
|
|
|
307
307
|
* Find every recognized marker in `text`, in document order, with offsets and
|
|
308
308
|
* classified metadata. Unrecognized spans are skipped.
|
|
309
309
|
*/
|
|
310
|
-
declare const scanMarkers: (text: string) => ScannedMarker[];
|
|
310
|
+
export declare const scanMarkers: (text: string) => ScannedMarker[];
|
|
311
311
|
/**
|
|
312
312
|
* Rewrite every `{{ ... }}` output marker in `text` through `replace`, which
|
|
313
313
|
* receives the whole marker and its raw inner text and returns the replacement.
|
|
314
314
|
* Tags are left untouched. The single scan is the same one the classifier uses,
|
|
315
315
|
* so a caller that rewrites marker text never needs its own regex.
|
|
316
316
|
*/
|
|
317
|
-
declare const replaceOutputMarkers: (text: string, replace: (raw: string, inner: string) => string) => string;
|
|
317
|
+
export declare const replaceOutputMarkers: (text: string, replace: (raw: string, inner: string) => string) => string;
|
|
318
318
|
/**
|
|
319
319
|
* The values-map key one marker substitutes from, or `null` when the marker is
|
|
320
320
|
* not a substitution target (a tag, or a `loop.*` token the loop expander
|
|
321
321
|
* resolves first). One function so the key discovery writes is the key the
|
|
322
322
|
* patcher reads.
|
|
323
323
|
*/
|
|
324
|
-
declare const substitutionKey: (meta: MarkerMeta) => string | null;
|
|
324
|
+
export declare const substitutionKey: (meta: MarkerMeta) => string | null;
|
|
325
325
|
/** The values-map key for one clause slot. */
|
|
326
|
-
declare const clauseSlotKey: (name: string, version?: string) => string;
|
|
326
|
+
export declare const clauseSlotKey: (name: string, version?: string) => string;
|
|
327
327
|
/** A marker-shaped span that classifies to nothing. */
|
|
328
328
|
type InvalidMarker = {
|
|
329
329
|
/** Offset of the opening brace pair in the source text. */
|
|
@@ -342,20 +342,20 @@ type InvalidMarker = {
|
|
|
342
342
|
* recognizer skips, so they print literally at fill time. This is the exact
|
|
343
343
|
* complement of {@link scanMarkers}: a span is in one list or the other.
|
|
344
344
|
*/
|
|
345
|
-
declare const scanInvalidMarkers: (text: string) => InvalidMarker[];
|
|
345
|
+
export declare const scanInvalidMarkers: (text: string) => InvalidMarker[];
|
|
346
346
|
/** The loop alias the codemod (and the legacy-marker message) generates for a
|
|
347
347
|
* `{{#each path}}`: the singular of the last plain-word segment, else `item`. */
|
|
348
|
-
declare const legacyLoopAlias: (path: string) => string;
|
|
348
|
+
export declare const legacyLoopAlias: (path: string) => string;
|
|
349
349
|
/** Translate an old-dialect condition expression to the Jinja surface:
|
|
350
350
|
* `!a` becomes `not a`, `a contains "x"` becomes `"x" in a`. */
|
|
351
|
-
declare const translateLegacyExpression: (expr: string) => string;
|
|
351
|
+
export declare const translateLegacyExpression: (expr: string) => string;
|
|
352
352
|
/**
|
|
353
353
|
* The Jinja marker that replaces one old-dialect marker's inner text, or
|
|
354
354
|
* `null` when the text is not old-dialect. Shared by the rejection message and
|
|
355
355
|
* the codemod, so the fix an author is told to make is the fix the script
|
|
356
356
|
* would have made.
|
|
357
357
|
*/
|
|
358
|
-
declare const legacyMarkerReplacement: (innerRaw: string) => string | null;
|
|
358
|
+
export declare const legacyMarkerReplacement: (innerRaw: string) => string | null;
|
|
359
359
|
/**
|
|
360
360
|
* Why a marker-shaped span misses the grammar in a way that names the
|
|
361
361
|
* authoring mistake rather than merely failing to classify. Consumers derive
|
|
@@ -363,7 +363,7 @@ declare const legacyMarkerReplacement: (innerRaw: string) => string | null;
|
|
|
363
363
|
* drift.
|
|
364
364
|
*/
|
|
365
365
|
type MarkerDefectKind = "legacy_marker" | "unsupported_tag" | "unknown_filter" | "python_expression" | "bracket_index";
|
|
366
|
-
declare const MARKER_DEFECT_KINDS: readonly ["legacy_marker", "unsupported_tag", "unknown_filter", "python_expression", "bracket_index"];
|
|
366
|
+
export declare const MARKER_DEFECT_KINDS: readonly ["legacy_marker", "unsupported_tag", "unknown_filter", "python_expression", "bracket_index"];
|
|
367
367
|
/** One diagnosis of a rejected span: the kind plus the construct to quote. */
|
|
368
368
|
type MarkerDefect = {
|
|
369
369
|
kind: MarkerDefectKind;
|
|
@@ -377,9 +377,9 @@ type MarkerDefect = {
|
|
|
377
377
|
* the text is a recognized directive ({@link classifyMarker} accepts it) or an
|
|
378
378
|
* unrecognizable span with no specific diagnosis (`{{my field}}`).
|
|
379
379
|
*/
|
|
380
|
-
declare const classifyMarkerDefect: (innerRaw: string, form?: MarkerForm) => MarkerDefect | null;
|
|
380
|
+
export declare const classifyMarkerDefect: (innerRaw: string, form?: MarkerForm) => MarkerDefect | null;
|
|
381
381
|
/** Exhaustiveness guard — pass the discriminant in a `switch` default branch. */
|
|
382
|
-
declare const assertNever: (value: never) => never;
|
|
382
|
+
export declare const assertNever: (value: never) => never;
|
|
383
383
|
//#endregion
|
|
384
384
|
//#region src/loop-scope.d.ts
|
|
385
385
|
/**
|
|
@@ -402,14 +402,14 @@ type RowScope = {
|
|
|
402
402
|
/** The array path the manifest speaks, enclosing loops included. */
|
|
403
403
|
scopedPath: string;
|
|
404
404
|
};
|
|
405
|
-
declare const rowScopePaths: (rowScopes: readonly RowScope[]) => string[];
|
|
405
|
+
export declare const rowScopePaths: (rowScopes: readonly RowScope[]) => string[];
|
|
406
406
|
/** A path already under the innermost repeat is left alone; anything else is
|
|
407
407
|
* read as a name relative to it. */
|
|
408
|
-
declare const qualifyRowScopedPath: (path: string, rowPaths?: readonly string[]) => string;
|
|
408
|
+
export declare const qualifyRowScopedPath: (path: string, rowPaths?: readonly string[]) => string;
|
|
409
409
|
/** The manifest path for a marker written inside these loops. */
|
|
410
|
-
declare const qualifyRowScopedPlaceholder: (path: string, rowScopes: readonly RowScope[]) => string;
|
|
410
|
+
export declare const qualifyRowScopedPlaceholder: (path: string, rowScopes: readonly RowScope[]) => string;
|
|
411
411
|
/** The manifest path for an array a `{% for %}` opens inside these loops. */
|
|
412
|
-
declare const qualifyLoopPath: (declaredPath: string, rowScopes: readonly RowScope[]) => string;
|
|
412
|
+
export declare const qualifyLoopPath: (declaredPath: string, rowScopes: readonly RowScope[]) => string;
|
|
413
413
|
//#endregion
|
|
414
414
|
//#region src/field-config.d.ts
|
|
415
415
|
/** Where a field's value comes from, when a record supplies it. Only the shape
|
|
@@ -481,20 +481,20 @@ type MarkerFieldConfig = {
|
|
|
481
481
|
* takes and what to call it. These are the ones a `{% for %}` tag may carry,
|
|
482
482
|
* since the loop path names the array, not one of its values.
|
|
483
483
|
*/
|
|
484
|
-
declare const ARRAY_FILTER_NAMES: readonly ["label", "hint", "required", "min_items", "max_items"];
|
|
485
|
-
declare const isArrayFilterName: (name: FilterName) => boolean;
|
|
484
|
+
export declare const ARRAY_FILTER_NAMES: readonly ["label", "hint", "required", "min_items", "max_items"];
|
|
485
|
+
export declare const isArrayFilterName: (name: FilterName) => boolean;
|
|
486
486
|
/**
|
|
487
487
|
* The filter chain that declares this field in a document, in the catalogue's
|
|
488
488
|
* own order so a chain the writer produces and one an author wrote read the
|
|
489
489
|
* same.
|
|
490
490
|
*/
|
|
491
|
-
declare const filtersFromFieldConfig: (field: MarkerFieldConfig) => FilterCall[];
|
|
491
|
+
export declare const filtersFromFieldConfig: (field: MarkerFieldConfig) => FilterCall[];
|
|
492
492
|
/**
|
|
493
493
|
* The chain a `{% for %}` opener carries for this array: the repeat's own
|
|
494
494
|
* filters and nothing else, derived from {@link ARRAY_FILTER_NAMES}, so a
|
|
495
495
|
* value filter can never be written where the reader refuses it.
|
|
496
496
|
*/
|
|
497
|
-
declare const arrayFiltersFromFieldConfig: (field: MarkerFieldConfig) => FilterCall[];
|
|
497
|
+
export declare const arrayFiltersFromFieldConfig: (field: MarkerFieldConfig) => FilterCall[];
|
|
498
498
|
//#endregion
|
|
499
499
|
//#region src/render.d.ts
|
|
500
500
|
/** Why a value has no spelling the scanner reads back as itself. */
|
|
@@ -502,12 +502,12 @@ type UnwritableReason = "tag-delimiter" | "number-spelling";
|
|
|
502
502
|
/** The reason this literal cannot be written in a marker of this form, or
|
|
503
503
|
* `null` when it can. A boolean always can; a string can in a `{{ }}` marker,
|
|
504
504
|
* because the writer quotes and escapes it. */
|
|
505
|
-
declare const unwritableMarkerLiteral: (value: MarkerLiteral, form?: MarkerForm) => UnwritableReason | null;
|
|
505
|
+
export declare const unwritableMarkerLiteral: (value: MarkerLiteral, form?: MarkerForm) => UnwritableReason | null;
|
|
506
506
|
/** Every value in a chain the grammar has no spelling for, with the filter it
|
|
507
507
|
* was written on and why, so a caller can refuse a configuration before it
|
|
508
508
|
* rewrites a document into something the scanner would read differently. A
|
|
509
509
|
* repeat's chain goes in a tag, so pass `"statement"` for one. */
|
|
510
|
-
declare const unwritableFilterValues: (filters: readonly FilterCall[], form?: MarkerForm) => {
|
|
510
|
+
export declare const unwritableFilterValues: (filters: readonly FilterCall[], form?: MarkerForm) => {
|
|
511
511
|
filter: string;
|
|
512
512
|
value: MarkerLiteral;
|
|
513
513
|
reason: UnwritableReason;
|
|
@@ -517,9 +517,9 @@ declare const unwritableFilterValues: (filters: readonly FilterCall[], form?: Ma
|
|
|
517
517
|
* required`. An empty chain renders the empty string, which is what a marker
|
|
518
518
|
* that configures nothing carries.
|
|
519
519
|
*/
|
|
520
|
-
declare const renderFilterChain: (filters: readonly FilterCall[]) => string;
|
|
520
|
+
export declare const renderFilterChain: (filters: readonly FilterCall[]) => string;
|
|
521
521
|
/** One value marker: `{{ path }}` or `{{ path | filters }}`. */
|
|
522
|
-
declare const renderValueMarker: (path: string, filters: readonly FilterCall[]) => string;
|
|
522
|
+
export declare const renderValueMarker: (path: string, filters: readonly FilterCall[]) => string;
|
|
523
523
|
type ConditionTagOptions = {
|
|
524
524
|
/** Which branch opener this is; `elif` keeps its place in the chain. */
|
|
525
525
|
kind: "if" | "elif";
|
|
@@ -535,7 +535,7 @@ type ConditionTagOptions = {
|
|
|
535
535
|
* the tag is the only place a document has for it, so a builder's rule is
|
|
536
536
|
* serialized here rather than stored beside the document under a name.
|
|
537
537
|
*/
|
|
538
|
-
declare const renderConditionTag: ({ expression, kind, prefix }: ConditionTagOptions) => string;
|
|
538
|
+
export declare const renderConditionTag: ({ expression, kind, prefix }: ConditionTagOptions) => string;
|
|
539
539
|
type ForOpenerOptions = {
|
|
540
540
|
alias: string;
|
|
541
541
|
path: string;
|
|
@@ -545,7 +545,7 @@ type ForOpenerOptions = {
|
|
|
545
545
|
prefix: MarkerPrefix;
|
|
546
546
|
};
|
|
547
547
|
/** One `{% for %}` opener, keeping its placement prefix. */
|
|
548
|
-
declare const renderForOpener: ({ alias, filters, path, prefix }: ForOpenerOptions) => string;
|
|
548
|
+
export declare const renderForOpener: ({ alias, filters, path, prefix }: ForOpenerOptions) => string;
|
|
549
549
|
//#endregion
|
|
550
550
|
//#region src/row-blocks.d.ts
|
|
551
551
|
/** One end of a row block, addressed within the row that was scanned. */
|
|
@@ -573,10 +573,10 @@ type RowBlockPair = {
|
|
|
573
573
|
* `{% else %}`, a pair wrapping the paragraphs of a single cell — is left to the
|
|
574
574
|
* engine's existing structure errors rather than guessed at.
|
|
575
575
|
*/
|
|
576
|
-
declare const detectRowBlockPair: (cells: readonly (readonly string[])[]) => RowBlockPair | null;
|
|
576
|
+
export declare const detectRowBlockPair: (cells: readonly (readonly string[])[]) => RowBlockPair | null;
|
|
577
577
|
//#endregion
|
|
578
578
|
//#region src/index.d.ts
|
|
579
|
-
type NamedCondition = {
|
|
579
|
+
export type NamedCondition = {
|
|
580
580
|
name: string;
|
|
581
581
|
/** The `{% if %}` expression string. Authoritative unless `node` is set. */
|
|
582
582
|
expression: string;
|
|
@@ -594,7 +594,7 @@ type NamedCondition = {
|
|
|
594
594
|
* Prevents stack overflow when a long chain of named
|
|
595
595
|
* conditions (A→B→C→...→Z) is evaluated without cycles.
|
|
596
596
|
*/
|
|
597
|
-
declare const MAX_CONDITION_DEPTH = 50;
|
|
597
|
+
export declare const MAX_CONDITION_DEPTH = 50;
|
|
598
598
|
/**
|
|
599
599
|
* Evaluate a template `{% if ... %}` condition. The expression is parsed into
|
|
600
600
|
* the canonical `@stll/conditions` AST and evaluated by the shared evaluator.
|
|
@@ -607,6 +607,6 @@ declare const MAX_CONDITION_DEPTH = 50;
|
|
|
607
607
|
* An empty or unparseable expression is `false` ("no condition" never gates a
|
|
608
608
|
* branch true).
|
|
609
609
|
*/
|
|
610
|
-
declare const evaluateCondition: (expression: string, data: Record<string, unknown>, namedConditions?: readonly NamedCondition[], _resolved?: ReadonlySet<string>, _depth?: number) => boolean;
|
|
610
|
+
export declare const evaluateCondition: (expression: string, data: Record<string, unknown>, namedConditions?: readonly NamedCondition[], _resolved?: ReadonlySet<string>, _depth?: number) => boolean;
|
|
611
611
|
//#endregion
|
|
612
|
-
export {
|
|
612
|
+
export { type BlockDirectiveKind, type CompareNode, type CompareOp, type Condition, type ConditionNode, type ConditionTagOptions, type DateFormatStyle, type DeterministicFieldConfig, type DirectiveKind, type FieldDateFormat, type FilterArgument, type FilterCall, type FilterName, type ForOpenerOptions, type GroupNode, type InvalidMarker, type LoopProperty, type MarkerDefect, type MarkerDefectKind, type MarkerFieldConfig, type MarkerFieldInputType, type MarkerFieldLookup, type MarkerFieldSource, type MarkerFieldValidation, type MarkerForm, type MarkerLiteral, type MarkerMeta, type MarkerPrefix, type NumericFunctionName, type Operand, type PredicateNode, type PredicateOp, type RowBlockMarker, type RowBlockPair, type RowScope, type ScannedMarker, type UnwritableReason, conditionHasFormula, conditionNodeSchema, conditionSchema, emptyCondition };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/template-conditions",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "A document-template marker and condition engine: {{...}} marker grammar, parse, compute, serialize, field values.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"condition",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"prepack": "bun run build"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@stll/conditions": "^0.
|
|
52
|
+
"@stll/conditions": "^0.4.0",
|
|
53
53
|
"better-result": "3.0.1",
|
|
54
54
|
"temporal-polyfill": "1.0.4"
|
|
55
55
|
},
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@stll/typescript-config": "0.0.0",
|
|
59
59
|
"bun-types": "1.4.2",
|
|
60
60
|
"fast-check": "^4.9.0",
|
|
61
|
-
"tsdown": "0.
|
|
61
|
+
"tsdown": "0.23.0"
|
|
62
62
|
},
|
|
63
63
|
"main": "./dist/index.js",
|
|
64
64
|
"types": "./dist/index.d.ts"
|