/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ export type PathSegment = string | number; export type CanonicalPathSegment = string | Readonly<{ kind: 'index'; }>; export type SourceSpan = Readonly<{ start: number; end: number; }>; export type TemplatePathSegment = string | number; export type VariablePathRef = Readonly<{ varName: string; runtimeSegments: readonly PathSegment[]; runtimeKey: string; canonicalKey: string; span: SourceSpan; templatePath: readonly TemplatePathSegment[]; }>; export type ResolvePathPolicy = Readonly<{ allowAll: boolean; allowedPaths: ReadonlySet; unrestrictedVariables: ReadonlySet; }>; export type VariableExpressionErrorCode = 'bare-ctx' | 'ctx-call' | 'ctx-write' | 'dynamic-ctx-path' | 'invalid-expression' | 'reserved-helper' | 'unsafe-execution' | 'unreliable-scope'; export type VariableExpressionError = Readonly<{ code: VariableExpressionErrorCode; span: SourceSpan; templatePath: readonly TemplatePathSegment[]; }>; export type AnalyzedExpression = Readonly<{ source: string; compiled: string; helperIdentifier: string; expressionSpan: SourceSpan; placeholderSpan: SourceSpan; paths: readonly VariablePathRef[]; supported: boolean; }>; export type AnalyzedTemplateNode = Readonly<{ kind: 'string'; source: string; expressions: readonly AnalyzedExpression[]; }> | Readonly<{ kind: 'array'; items: readonly AnalyzedTemplateNode[]; }> | Readonly<{ kind: 'object'; entries: Readonly>; }> | Readonly<{ kind: 'value'; value: unknown; }>; export type AnalyzedTemplate = Readonly<{ value: AnalyzedTemplateNode; paths: readonly VariablePathRef[]; usage: Readonly>; errors: readonly VariableExpressionError[]; supported: boolean; }>; export type AnalyzeTemplateMode = 'request' | 'untrusted-request' | 'flow-model'; export declare function getVariableRuntimeKey(varName: string, runtimeSegments: readonly PathSegment[]): string; export declare function getVariableCanonicalKey(varName: string, runtimeSegments: readonly PathSegment[]): string; export declare function analyzeVariableTemplate(template: unknown, options?: Readonly<{ mode?: AnalyzeTemplateMode; }>): AnalyzedTemplate;