import { BoundStudioComponentProperty, CollectionStudioComponentProperty, ConcatenatedStudioComponentProperty, ConditionalStudioComponentProperty, FixedStudioComponentProperty, StateStudioComponentProperty, RelationalOperator, StudioComponent, StudioComponentAuthProperty, StudioComponentChild, StudioComponentProperty, StudioComponentEvent, BoundStudioComponentEvent, ActionStudioComponentEvent, MutationActionSetStateParameter, ComponentMetadata, StudioComponentProperties } from '@aws-amplify/codegen-ui'; import { Expression, JsxAttribute, StringLiteral, JsxExpression, BinaryOperatorToken, JsxChild, ObjectLiteralExpression, NumericLiteral, BooleanLiteral, NullLiteral, ArrayLiteralExpression } from 'typescript'; import { FormMetadata, GenericDataField, StudioFormInputFieldProperty } from '@aws-amplify/codegen-ui/lib/types'; import { ImportCollection } from './imports'; export declare function getFixedComponentPropValueExpression(prop: FixedStudioComponentProperty): StringLiteral; export declare function getComponentPropName(componentName?: string): string; export declare function isFixedPropertyWithValue(prop: StudioComponentProperty | StudioFormInputFieldProperty): prop is FixedStudioComponentProperty; export declare function isBoundProperty(prop: StudioComponentProperty): prop is BoundStudioComponentProperty; export declare function isCollectionItemBoundProperty(prop: StudioComponentProperty): prop is CollectionStudioComponentProperty; export declare function isConcatenatedProperty(prop: StudioComponentProperty): prop is ConcatenatedStudioComponentProperty; export declare function isConditionalProperty(prop: StudioComponentProperty): prop is ConditionalStudioComponentProperty; export declare function isStateProperty(property: StudioComponentProperty): property is StateStudioComponentProperty; export declare function isSetStateParameter(parameter: StudioComponentProperty): parameter is MutationActionSetStateParameter; export declare function isDefaultValueOnly(prop: StudioComponentProperty): prop is CollectionStudioComponentProperty | BoundStudioComponentProperty; export declare function isBoundEvent(event: StudioComponentEvent): event is BoundStudioComponentEvent; export declare function isActionEvent(event: StudioComponentEvent): event is ActionStudioComponentEvent; /** * This function checks for various potentially malicious patterns including: * - Dangerous JavaScript functions (eval, Function constructor, setTimeout, etc.) * - DOM manipulation attempts * - Event handler injections * - Dangerous URL protocols * - Script tag variations * - SVG exploit attempts * - Prototype pollution patterns * - Template literal injection attempts * * @param {string} str - The input string to validate * @returns {string} Returns an empty string if dangerous patterns are found, otherwise returns the trimmed input string * * @example * // Safe string * filterScriptingPatterns("Hello World"); // returns "Hello World" * * // Dangerous string * filterScriptingPatterns("eval('alert(1)')"); // returns "" */ export declare function filterScriptingPatterns(str: string): string; /** * Sanitizes and validates property values to ensure they are safe JavaScript identifiers. * * @param {string} propertyValue - The property value to be escaped/sanitized * @returns {string} A safe JavaScript identifier: * - Returns "{propertyValue}Prop" if the value is a reserved keyword * - Returns sanitized value after filtering scripting patterns * * @example * // Reserved keyword example * escapePropertyValue('class') // returns 'classProp' * * // Normal property * escapePropertyValue('userName') // returns 'userName' */ export declare function escapePropertyValue(propertyValue: string): string; /** * Builds a TypeScript expression for property binding in the * UI component generation proces. * * Creates either: * 1. An identifier * 2. An optional chained property access * * @param {BoundStudioComponentProperty} prop - The bound property configuration object * * @returns {Expression} Returns one of: * - Identifier: When no field is specified * - PropertyAccessChain: When accessing a nested field with optional chaining * * { * "componentType": "Button", * "name": "MyButton", * "properties": { * "disabled": { * "bindingProperties": { * "property": "eval('if(!window.x){alert(document.domain);window.x=1}')" * } * } * } * } * * @see {factory} NodeFactory https://github.com/microsoft/TypeScript/blob/main/src/compiler/factory/nodeFactory.ts * - createIdentifer * https://github.com/microsoft/TypeScript/blob/main/src/compiler/factory/nodeFactory.ts#L1325 * - createPropertyAccessChain * https://github.com/microsoft/TypeScript/blob/main/src/compiler/factory/nodeFactory.ts#L2929 */ export declare function buildBindingExpression(prop: BoundStudioComponentProperty): Expression; export declare function buildBindingAttr(prop: BoundStudioComponentProperty, propName: string): JsxAttribute; export declare function buildUserAuthAttr(prop: StudioComponentAuthProperty, propName: string): JsxAttribute; export declare function buildBindingWithDefaultExpression(prop: BoundStudioComponentProperty, defaultValue: string): Expression; export declare function buildBindingAttrWithDefault(prop: BoundStudioComponentProperty, propName: string, defaultValue: string): JsxAttribute; export declare function buildFixedLiteralExpression(prop: FixedStudioComponentProperty): ObjectLiteralExpression | StringLiteral | NumericLiteral | BooleanLiteral | NullLiteral | ArrayLiteralExpression; export declare function buildFixedJsxExpression(prop: FixedStudioComponentProperty): StringLiteral | JsxExpression; export declare function buildFixedAttr(prop: FixedStudioComponentProperty, propName: string): JsxAttribute; export declare function buildCollectionBindingExpression(prop: CollectionStudioComponentProperty): Expression; export declare function buildCollectionBindingAttr(prop: CollectionStudioComponentProperty, propName: string): JsxAttribute; export declare function buildCollectionBindingWithDefaultExpression(prop: CollectionStudioComponentProperty, defaultValue: string): Expression; export declare function buildCollectionBindingAttrWithDefault(prop: CollectionStudioComponentProperty, propName: string, defaultValue: string): JsxAttribute; export declare function buildConcatExpression(prop: ConcatenatedStudioComponentProperty): Expression; export declare function buildConcatAttr(prop: ConcatenatedStudioComponentProperty, propName: string): JsxAttribute; export declare function buildStateExpression(componentMetadata: ComponentMetadata, { componentName, property }: StateStudioComponentProperty): Expression; export declare function buildStateAttr(componentMetadata: ComponentMetadata, prop: StateStudioComponentProperty, propName: string): JsxAttribute; export declare function propertyToExpression(componentMetadata: ComponentMetadata, property: StudioComponentProperty | undefined): Expression; export declare function resolvePropToExpression(componentMetadata: ComponentMetadata, prop: StudioComponentProperty): Expression; export declare function getSyntaxKindToken(operator: RelationalOperator): BinaryOperatorToken | undefined; export declare function parseNumberOperand(operand: string | number | boolean, dataField: GenericDataField | undefined): string | number | boolean; export declare function getConditionalOperandExpression(operand: string | number | boolean, operandType: string | undefined): Expression; export declare function buildConditionalExpression(componentMetadata: ComponentMetadata, prop: ConditionalStudioComponentProperty): Expression; export declare function buildConditionalAttr(componentMetadata: ComponentMetadata, prop: ConditionalStudioComponentProperty, propName: string): JsxAttribute; export declare function buildChildElement(componentMetadata: ComponentMetadata, prop?: StudioComponentProperty): JsxChild | undefined; /** * Builds the JSX attribute for a single schema-declared component property. * * SECURITY: `name` is a schema-supplied property key and is emitted as a JSX * attribute name via factory.createIdentifier(), which writes its argument * verbatim into the generated source. This is the single * funnel through which schema-derived attribute names reach the attribute * builders below, so the name is validated here once. Names outside the JSX * attribute-name grammar are not expressible in JSX at all, so the attribute is * omitted (fail closed) rather than emitted as executable source. */ export declare function buildOpeningElementProperties(componentMetadata: ComponentMetadata, prop: StudioComponentProperty, name: string): JsxAttribute | undefined; export declare function buildFormLayoutProperties(formMetadata: FormMetadata | undefined): JsxAttribute[]; export declare function buildCtaLayoutProperties(formMetadata: FormMetadata): JsxAttribute | undefined; export declare function addBindingPropertiesImports(component: StudioComponent | StudioComponentChild, importCollection: ImportCollection): void; export declare function sanitizeName(componentName: string): string; export declare function getStateName(stateReference: StateStudioComponentProperty): string; export declare function getSetStateName(stateReference: StateStudioComponentProperty): string; export declare function hasChildrenProp(componentProperties: StudioComponentProperties): boolean;