@creatio-devkit/common 0.832.1 → 0.834.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/AI_GUIDES_INDEX.md +38 -0
- package/CHANGELOG.md +20 -0
- package/DEFERRED_REMOTE_MIGRATION_AI_GUIDE.md +1338 -0
- package/ICON_REQUIREMENTS_AI_GUIDE.md +586 -0
- package/LICENSE.md +1 -1
- package/REMOTE_COMPONENT_RUNTIME_AI_GUIDE.md +1568 -0
- package/WCAG_ACCESSIBILITY_AI_GUIDE.md +1002 -0
- package/fesm2022/creatio-devkit-common.mjs +616 -89
- package/fesm2022/creatio-devkit-common.mjs.map +1 -1
- package/index.d.ts +3573 -2914
- package/package.json +3 -7
- package/esm2022/creatio-devkit-common.mjs +0 -5
- package/esm2022/index.mjs +0 -2
- package/esm2022/lib/base-exports.mjs +0 -5
- package/esm2022/lib/external/file-viewer/file-viewer-factory.service.mjs +0 -26
- package/esm2022/lib/external/file-viewer/file-viewer-instance.model.mjs +0 -51
- package/esm2022/lib/external/file-viewer/file-viewer-options.model.mjs +0 -2
- package/esm2022/lib/external/file-viewer/index.mjs +0 -4
- package/esm2022/lib/external/functions/aggregation-adapter.mjs +0 -72
- package/esm2022/lib/external/functions/date-part-type-adapter.mjs +0 -48
- package/esm2022/lib/external/functions/function-type-adapter.mjs +0 -28
- package/esm2022/lib/external/functions/index.mjs +0 -5
- package/esm2022/lib/external/functions/order-direction-adapter.mjs +0 -28
- package/esm2022/lib/external/models/attribute-value-config.mjs +0 -2
- package/esm2022/lib/external/models/date-time/grouped-date-value.mjs +0 -2
- package/esm2022/lib/external/models/date-time/index.mjs +0 -2
- package/esm2022/lib/external/models/file-value.model.mjs +0 -2
- package/esm2022/lib/external/models/index.mjs +0 -4
- package/esm2022/lib/index.mjs +0 -18
- package/esm2022/lib/internal/constants/default-size.const.mjs +0 -5
- package/esm2022/lib/internal/constants/index.mjs +0 -3
- package/esm2022/lib/internal/constants/metadata.const.mjs +0 -17
- package/esm2022/lib/internal/decorators/design-time-view-element/design-time-view-element.decorator.mjs +0 -19
- package/esm2022/lib/internal/decorators/design-time-view-element/index.mjs +0 -2
- package/esm2022/lib/internal/decorators/implement-using-handler-chain/implement-using-handler-chain.decorator.mjs +0 -25
- package/esm2022/lib/internal/decorators/implement-using-handler-chain/index.mjs +0 -2
- package/esm2022/lib/internal/decorators/index.mjs +0 -4
- package/esm2022/lib/internal/decorators/request/index.mjs +0 -2
- package/esm2022/lib/internal/decorators/request/request.decorator.mjs +0 -15
- package/esm2022/lib/internal/enums/designer-group-type.enum.mjs +0 -16
- package/esm2022/lib/internal/enums/handler-source-type.enum.mjs +0 -12
- package/esm2022/lib/internal/enums/index.mjs +0 -4
- package/esm2022/lib/internal/enums/view-element-group-type.enum.mjs +0 -13
- package/esm2022/lib/internal/models/attribute-property-config.interface.mjs +0 -2
- package/esm2022/lib/internal/models/converter/converter-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/converter/index.mjs +0 -2
- package/esm2022/lib/internal/models/data-source-load-parameters.mjs +0 -2
- package/esm2022/lib/internal/models/design-time-view-element-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/handler-chain-service-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/index.mjs +0 -20
- package/esm2022/lib/internal/models/injection-context/index.mjs +0 -2
- package/esm2022/lib/internal/models/injection-context/injection-context.mjs +0 -2
- package/esm2022/lib/internal/models/interface-designer-item/base-interface-designer-item-registration-config.mjs +0 -2
- package/esm2022/lib/internal/models/interface-designer-item/index.mjs +0 -4
- package/esm2022/lib/internal/models/interface-designer-item/interface-designer-item-registration-config.model.mjs +0 -7
- package/esm2022/lib/internal/models/interface-designer-item/toolbar-view-element-config.mjs +0 -2
- package/esm2022/lib/internal/models/interface-designer-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/internal-interface-designer-item-registration-config.model.mjs +0 -2
- package/esm2022/lib/internal/models/internal-module-definition.mjs +0 -2
- package/esm2022/lib/internal/models/lazy-module-metadata.mjs +0 -2
- package/esm2022/lib/internal/models/lazy-module-ref.mjs +0 -26
- package/esm2022/lib/internal/models/lazy-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/remote-build-info.mjs +0 -9
- package/esm2022/lib/internal/models/request/index.mjs +0 -2
- package/esm2022/lib/internal/models/request/method-invoke-request.mjs +0 -12
- package/esm2022/lib/internal/models/request-handler/contexed-handler-scope-config.mjs +0 -2
- package/esm2022/lib/internal/models/request-handler/handler-config.mjs +0 -2
- package/esm2022/lib/internal/models/request-handler/handler-source.mjs +0 -2
- package/esm2022/lib/internal/models/request-handler/index.mjs +0 -6
- package/esm2022/lib/internal/models/request-handler/request-handler-factory.mjs +0 -2
- package/esm2022/lib/internal/models/request-handler/request-handler-registration-config.model.mjs +0 -2
- package/esm2022/lib/internal/models/transaction/index.mjs +0 -4
- package/esm2022/lib/internal/models/transaction/transaction-factory.mjs +0 -2
- package/esm2022/lib/internal/models/transaction/transaction-operation.mjs +0 -2
- package/esm2022/lib/internal/models/transaction/transaction.mjs +0 -2
- package/esm2022/lib/internal/models/validator/index.mjs +0 -4
- package/esm2022/lib/internal/models/validator/validator-parameters.mjs +0 -2
- package/esm2022/lib/internal/models/validator/validator-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/validator/validator-schema-config.model.mjs +0 -2
- package/esm2022/lib/internal/models/view-element/angular-view-element-registration-config.model.mjs +0 -2
- package/esm2022/lib/internal/models/view-element/index.mjs +0 -2
- package/esm2022/lib/internal/models/view-element-registry-item.mjs +0 -2
- package/esm2022/lib/internal/services/base-handler-chain.service.mjs +0 -3
- package/esm2022/lib/internal/services/base-registry/base-registry.mjs +0 -31
- package/esm2022/lib/internal/services/base-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/bootstrap-notifier/bootstrap-notifier.mjs +0 -28
- package/esm2022/lib/internal/services/bootstrap-notifier/index.mjs +0 -2
- package/esm2022/lib/internal/services/chat-message-type-registry/chat-message-type-registry.mjs +0 -22
- package/esm2022/lib/internal/services/chat-message-type-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/design-time-view-element-registry/design-time-view-element-registry.mjs +0 -32
- package/esm2022/lib/internal/services/design-time-view-element-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/element-registration-checker/element-registration-checker.mjs +0 -60
- package/esm2022/lib/internal/services/element-registration-checker/index.mjs +0 -2
- package/esm2022/lib/internal/services/global-converters-registry/converter-registry.mjs +0 -36
- package/esm2022/lib/internal/services/global-converters-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/handler-chain-services-registry/handler-chain-services-registry.mjs +0 -26
- package/esm2022/lib/internal/services/handler-chain-services-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/index.mjs +0 -17
- package/esm2022/lib/internal/services/interface-designer-item-registry/index.mjs +0 -3
- package/esm2022/lib/internal/services/interface-designer-item-registry/interface-designer-item-registry.mjs +0 -53
- package/esm2022/lib/internal/services/interface-designer-item-registry/mobile-interface-designer-item-registry.mjs +0 -12
- package/esm2022/lib/internal/services/lazy-modules-manager/index.mjs +0 -2
- package/esm2022/lib/internal/services/lazy-modules-manager/lazy-modules-manager.mjs +0 -35
- package/esm2022/lib/internal/services/pkg-topology-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/pkg-topology-registry/pkg-topology-registry.mjs +0 -18
- package/esm2022/lib/internal/services/remote-entries-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/remote-entries-registry/remote-entries-registry.mjs +0 -18
- package/esm2022/lib/internal/services/request-handler-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/request-handler-registry/request-handler-registry.service.mjs +0 -131
- package/esm2022/lib/internal/services/request-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/request-registry/request-registry.service.mjs +0 -33
- package/esm2022/lib/internal/services/request-resolver/base-requests-resolver.mjs +0 -6
- package/esm2022/lib/internal/services/request-resolver/index.mjs +0 -3
- package/esm2022/lib/internal/services/request-resolver/requests-resolver.mjs +0 -17
- package/esm2022/lib/internal/services/validator-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/validator-registry/validator-registry.mjs +0 -45
- package/esm2022/lib/internal/services/view-element-registry/base-view-element-registry.mjs +0 -74
- package/esm2022/lib/internal/services/view-element-registry/index.mjs +0 -4
- package/esm2022/lib/internal/services/view-element-registry/mobile-view-element-registry.mjs +0 -13
- package/esm2022/lib/internal/services/view-element-registry/view-element-registry.mjs +0 -12
- package/esm2022/lib/internal/types/index.mjs +0 -3
- package/esm2022/lib/internal/types/internal-resolve-dependency-fn.type.mjs +0 -2
- package/esm2022/lib/internal/types/localizable-values.type.mjs +0 -2
- package/esm2022/lib/internal/utils/handlers-order-comparer.mjs +0 -42
- package/esm2022/lib/internal/utils/index.mjs +0 -8
- package/esm2022/lib/internal/utils/instantiate.mjs +0 -24
- package/esm2022/lib/internal/utils/localization-utils.mjs +0 -24
- package/esm2022/lib/internal/utils/metadata-utils.mjs +0 -236
- package/esm2022/lib/internal/utils/module-utils.mjs +0 -38
- package/esm2022/lib/internal/utils/object-deep-keys/index.mjs +0 -2
- package/esm2022/lib/internal/utils/object-deep-keys/object-deep-keys.mjs +0 -13
- package/esm2022/lib/internal/utils/request-handler-scopes.mjs +0 -10
- package/esm2022/lib/public/decorators/chat-message-type/chat-message-type.decorator.mjs +0 -20
- package/esm2022/lib/public/decorators/chat-message-type/index.mjs +0 -2
- package/esm2022/lib/public/decorators/converter/converter.decorator.mjs +0 -21
- package/esm2022/lib/public/decorators/converter/index.mjs +0 -2
- package/esm2022/lib/public/decorators/index.mjs +0 -12
- package/esm2022/lib/public/decorators/inject/index.mjs +0 -2
- package/esm2022/lib/public/decorators/inject/inject.decorator.mjs +0 -19
- package/esm2022/lib/public/decorators/input/index.mjs +0 -2
- package/esm2022/lib/public/decorators/input/input.decorator.mjs +0 -25
- package/esm2022/lib/public/decorators/interface-designer-item/index.mjs +0 -4
- package/esm2022/lib/public/decorators/interface-designer-item/interface-designer-item-decorator-utils.mjs +0 -29
- package/esm2022/lib/public/decorators/interface-designer-item/interface-designer-item.decorator.mjs +0 -10
- package/esm2022/lib/public/decorators/interface-designer-item/mobile-interface-designer-item.decorator.mjs +0 -10
- package/esm2022/lib/public/decorators/module/index.mjs +0 -2
- package/esm2022/lib/public/decorators/module/module.decorator.mjs +0 -9
- package/esm2022/lib/public/decorators/output/index.mjs +0 -2
- package/esm2022/lib/public/decorators/output/output.decorator.mjs +0 -19
- package/esm2022/lib/public/decorators/request-handler/index.mjs +0 -2
- package/esm2022/lib/public/decorators/request-handler/request-handler.decorator.mjs +0 -22
- package/esm2022/lib/public/decorators/validation-input/index.mjs +0 -2
- package/esm2022/lib/public/decorators/validation-input/validation-input.decorator.mjs +0 -27
- package/esm2022/lib/public/decorators/validator/index.mjs +0 -2
- package/esm2022/lib/public/decorators/validator/validator.decorator.mjs +0 -25
- package/esm2022/lib/public/decorators/view-element/index.mjs +0 -4
- package/esm2022/lib/public/decorators/view-element/mobile-view-element.decorator.mjs +0 -9
- package/esm2022/lib/public/decorators/view-element/view-element-decorator-utils.mjs +0 -33
- package/esm2022/lib/public/decorators/view-element/view-element.decorator.mjs +0 -10
- package/esm2022/lib/public/enums/data-source-load-type.enum.mjs +0 -10
- package/esm2022/lib/public/enums/index.mjs +0 -5
- package/esm2022/lib/public/enums/process-status.enum.mjs +0 -28
- package/esm2022/lib/public/enums/view-element-property.enum.mjs +0 -9
- package/esm2022/lib/public/enums/view-model-collection-action-type.enum.mjs +0 -24
- package/esm2022/lib/public/functions/bootstrap-crt-module-handler-chain-services.mjs +0 -32
- package/esm2022/lib/public/functions/bootstrap-crt-module.mjs +0 -357
- package/esm2022/lib/public/functions/bootstrapped-crt-modules.mjs +0 -8
- package/esm2022/lib/public/functions/crt-module-context-hooks.mjs +0 -30
- package/esm2022/lib/public/functions/define-render-config.mjs +0 -16
- package/esm2022/lib/public/functions/index.mjs +0 -10
- package/esm2022/lib/public/functions/localize.mjs +0 -29
- package/esm2022/lib/public/functions/register-angular-view-element.mjs +0 -13
- package/esm2022/lib/public/functions/register-view-element.mjs +0 -21
- package/esm2022/lib/public/functions/reset-globals.mjs +0 -37
- package/esm2022/lib/public/handlers/base-request-handler.mjs +0 -37
- package/esm2022/lib/public/handlers/index.mjs +0 -2
- package/esm2022/lib/public/models/ai-context/ai-context-part.mjs +0 -2
- package/esm2022/lib/public/models/ai-context/index.mjs +0 -2
- package/esm2022/lib/public/models/base-response.model.mjs +0 -2
- package/esm2022/lib/public/models/converter/converter-config.mjs +0 -2
- package/esm2022/lib/public/models/converter/index.mjs +0 -2
- package/esm2022/lib/public/models/converter.model.mjs +0 -2
- package/esm2022/lib/public/models/entity.model.mjs +0 -2
- package/esm2022/lib/public/models/error-info.model.mjs +0 -2
- package/esm2022/lib/public/models/image-value.model.mjs +0 -2
- package/esm2022/lib/public/models/index.mjs +0 -21
- package/esm2022/lib/public/models/input/index.mjs +0 -2
- package/esm2022/lib/public/models/input/input-registration-config.model.mjs +0 -6
- package/esm2022/lib/public/models/interface-designer-item/index.mjs +0 -2
- package/esm2022/lib/public/models/interface-designer-item/interface-designer-item-definition.mjs +0 -2
- package/esm2022/lib/public/models/item-creation-config.mjs +0 -2
- package/esm2022/lib/public/models/license/index.mjs +0 -2
- package/esm2022/lib/public/models/license/license-restriction-operation-values.model.mjs +0 -2
- package/esm2022/lib/public/models/localizable-value.mjs +0 -20
- package/esm2022/lib/public/models/mask-settings.mjs +0 -2
- package/esm2022/lib/public/models/module-definition.mjs +0 -2
- package/esm2022/lib/public/models/process-engine/index.mjs +0 -4
- package/esm2022/lib/public/models/process-engine/process-parameter-value.model.mjs +0 -2
- package/esm2022/lib/public/models/process-engine/run-process-request.model.mjs +0 -12
- package/esm2022/lib/public/models/process-engine/run-process-response.model.mjs +0 -2
- package/esm2022/lib/public/models/request/base-request-config.mjs +0 -8
- package/esm2022/lib/public/models/request/data-source-request.mjs +0 -11
- package/esm2022/lib/public/models/request/handle-view-model-attribute-change.request.mjs +0 -29
- package/esm2022/lib/public/models/request/index.mjs +0 -6
- package/esm2022/lib/public/models/request/model-event.model.mjs +0 -2
- package/esm2022/lib/public/models/request/view-model-attribute-change-event-options.mjs +0 -2
- package/esm2022/lib/public/models/request-handler/index.mjs +0 -2
- package/esm2022/lib/public/models/request-handler/request-handler-definition.mjs +0 -2
- package/esm2022/lib/public/models/validation/base-validator.mjs +0 -40
- package/esm2022/lib/public/models/validation/crt-control-state.mjs +0 -2
- package/esm2022/lib/public/models/validation/crt-validation-errors.mjs +0 -2
- package/esm2022/lib/public/models/validation/crt-validator-fn.mjs +0 -2
- package/esm2022/lib/public/models/validation/index.mjs +0 -8
- package/esm2022/lib/public/models/validation/validation-info.mjs +0 -2
- package/esm2022/lib/public/models/validation/validator-config.mjs +0 -2
- package/esm2022/lib/public/models/validation/validator-parameter-values.mjs +0 -2
- package/esm2022/lib/public/models/view-element/base-view-element-registration-config.mjs +0 -2
- package/esm2022/lib/public/models/view-element/index.mjs +0 -6
- package/esm2022/lib/public/models/view-element/view-element-registration-config.mjs +0 -2
- package/esm2022/lib/public/models/view-element/view-element-render-strategy.mjs +0 -18
- package/esm2022/lib/public/models/view-element/view-element-reuse-strategy.enum.mjs +0 -15
- package/esm2022/lib/public/models/view-element/view-element-slot-definition.mjs +0 -2
- package/esm2022/lib/public/models/view-model-collection/index.mjs +0 -3
- package/esm2022/lib/public/models/view-model-collection/view-model-collection-change.model.mjs +0 -2
- package/esm2022/lib/public/models/view-model-collection/view-model-collection.model.mjs +0 -2
- package/esm2022/lib/public/services/ai-context/ai-context.service.mjs +0 -86
- package/esm2022/lib/public/services/ai-context/index.mjs +0 -2
- package/esm2022/lib/public/services/crt-zone/crt-zone.service.mjs +0 -22
- package/esm2022/lib/public/services/crt-zone/index.mjs +0 -2
- package/esm2022/lib/public/services/dialog-service/dialog.service.mjs +0 -24
- package/esm2022/lib/public/services/dialog-service/index.mjs +0 -2
- package/esm2022/lib/public/services/feature/feature.service.mjs +0 -26
- package/esm2022/lib/public/services/feature/index.mjs +0 -2
- package/esm2022/lib/public/services/handler-chain/handler-chain.service.mjs +0 -71
- package/esm2022/lib/public/services/handler-chain/index.mjs +0 -2
- package/esm2022/lib/public/services/handler-chain/internal-handler-chain.mjs +0 -195
- package/esm2022/lib/public/services/http-client/http-client.service.mjs +0 -83
- package/esm2022/lib/public/services/http-client/http-headers.mjs +0 -2
- package/esm2022/lib/public/services/http-client/http-response.mjs +0 -2
- package/esm2022/lib/public/services/http-client/index.mjs +0 -4
- package/esm2022/lib/public/services/index.mjs +0 -17
- package/esm2022/lib/public/services/license/index.mjs +0 -2
- package/esm2022/lib/public/services/license/license.service.mjs +0 -30
- package/esm2022/lib/public/services/mask-service/index.mjs +0 -2
- package/esm2022/lib/public/services/mask-service/mask.service.mjs +0 -46
- package/esm2022/lib/public/services/message-channel/index.mjs +0 -2
- package/esm2022/lib/public/services/message-channel/message-channel.service.mjs +0 -27
- package/esm2022/lib/public/services/model/index.mjs +0 -2
- package/esm2022/lib/public/services/model/model.mjs +0 -102
- package/esm2022/lib/public/services/process-engine/index.mjs +0 -2
- package/esm2022/lib/public/services/process-engine/process-engine.service.mjs +0 -27
- package/esm2022/lib/public/services/rights/index.mjs +0 -2
- package/esm2022/lib/public/services/rights/rights.service.mjs +0 -26
- package/esm2022/lib/public/services/schema-modal/index.mjs +0 -3
- package/esm2022/lib/public/services/schema-modal/schema-modal-config.model.mjs +0 -2
- package/esm2022/lib/public/services/schema-modal/schema-modal.service.mjs +0 -23
- package/esm2022/lib/public/services/sys-settings/index.mjs +0 -3
- package/esm2022/lib/public/services/sys-settings/sys-setting.model.mjs +0 -24
- package/esm2022/lib/public/services/sys-settings/sys-settings.service.mjs +0 -36
- package/esm2022/lib/public/services/sys-values/index.mjs +0 -3
- package/esm2022/lib/public/services/sys-values/sys-values.mjs +0 -2
- package/esm2022/lib/public/services/sys-values/sys-values.service.mjs +0 -23
- package/esm2022/lib/public/services/transaction-factory/index.mjs +0 -2
- package/esm2022/lib/public/services/transaction-factory/transaction-factory.service.mjs +0 -40
|
@@ -0,0 +1,1568 @@
|
|
|
1
|
+
# Remote Component Runtime AI Guide
|
|
2
|
+
|
|
3
|
+
**ATTENTION AI AGENT:** This is a directive instruction set, not documentation. Follow rules exactly.
|
|
4
|
+
|
|
5
|
+
**Audience:** AI assistant generating runtime part of a Creatio Freedom UI custom component.
|
|
6
|
+
|
|
7
|
+
**⚠️ CRITICAL - Reserved HTML Attribute Names:**
|
|
8
|
+
- **NEVER use `readonly` as @Input property name** - conflicts with native HTML attribute in Angular Custom Elements
|
|
9
|
+
- **Use `readOnly` (camelCase) instead** for readonly/editable state properties
|
|
10
|
+
- Other reserved names to avoid: `disabled`, `hidden`, `title`, `id`, `name`, `value` (use with caution or prefix)
|
|
11
|
+
- When in doubt, use camelCase variants: `isDisabled`, `isReadOnly`, `currentValue`
|
|
12
|
+
|
|
13
|
+
**Related guides:**
|
|
14
|
+
- **Design-time guide:** See REMOTE_COMPONENT_DESIGN_TIME_AI_GUIDE.md from @creatio-devkit/interface-designer package
|
|
15
|
+
- **Accessibility guide:** See WCAG_ACCESSIBILITY_AI_GUIDE.md from @creatio-devkit/common package (MANDATORY for all components)
|
|
16
|
+
- **Icon guide:** See ICON_REQUIREMENTS_AI_GUIDE.md from @creatio-devkit/common package
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 📝 Placeholder Registry
|
|
21
|
+
|
|
22
|
+
**INSTRUCTION:** Replace `{{PLACEHOLDERS}}` using this registry. NEVER leave placeholders unreplaced.
|
|
23
|
+
|
|
24
|
+
| Placeholder | Source | Transform | Example |
|
|
25
|
+
|-------------|--------|-----------|---------|
|
|
26
|
+
| `{{PREFIX}}` | `SESSION.prefix` | as-is | `usr` |
|
|
27
|
+
| `{{COMPONENT_NAME_KEBAB}}` | User input | kebab-case | `status-indicator` |
|
|
28
|
+
| `{{COMPONENT_NAME_PASCAL}}` | User input | PascalCase | `StatusIndicator` |
|
|
29
|
+
| `{{COMPONENT_NAME_UPPER}}` | User input | UPPER_SNAKE | `STATUS_INDICATOR` |
|
|
30
|
+
| `{{NAME}}` | Alias of `{{COMPONENT_NAME_KEBAB}}` | kebab-case | `status-indicator` |
|
|
31
|
+
| `{{PROJECT_NAME}}` | Nx project name | as-is | `lib.devkit.sample-remote-entry` |
|
|
32
|
+
| `{{MODULE_NAME}}` | Project context | as-is | `hello` |
|
|
33
|
+
| `{{PROPERTY_NAME}}` | Runtime @Input | camelCase | `visible` |
|
|
34
|
+
| `{{PROPERTY_TYPE}}` | Infer from default | TS type | `boolean` |
|
|
35
|
+
| `{{DEFAULT_VALUE}}` | Sensible default | as-is | `true` |
|
|
36
|
+
|
|
37
|
+
**Auto-Generation:**
|
|
38
|
+
```
|
|
39
|
+
User: "Create StatusIndicator component"
|
|
40
|
+
→ SESSION.component_name_kebab = "status-indicator"
|
|
41
|
+
→ SESSION.component_name_pascal = "StatusIndicator"
|
|
42
|
+
→ SESSION.component_name_upper = "STATUS_INDICATOR"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 🔄 Session State Machine
|
|
48
|
+
|
|
49
|
+
**Track state. Update after each action.**
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
SESSION_STATE:
|
|
53
|
+
phase: null # [config|generate|validate|complete]
|
|
54
|
+
prefix: null # From angular.json
|
|
55
|
+
component_name: null # User input (all forms)
|
|
56
|
+
scope: null # [runtime-only|runtime+designer]
|
|
57
|
+
remote_format: null # [legacy-module|deferred-remote]
|
|
58
|
+
input_shape: null # [scalar|collection]
|
|
59
|
+
input_shape_source: null # [contract-signals|default-scalar]
|
|
60
|
+
files: [] # Generated files
|
|
61
|
+
validated: false
|
|
62
|
+
score: 0 # Confidence 0-100
|
|
63
|
+
|
|
64
|
+
TRANSITIONS:
|
|
65
|
+
null → config: Read angular.json, ask questions, set vars
|
|
66
|
+
config → generate: Create files, replace placeholders
|
|
67
|
+
generate → validate: Run lint/tests, check registration
|
|
68
|
+
validate → complete: Present to user
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 🚨 Pre-Generation Checklist
|
|
74
|
+
|
|
75
|
+
**EXECUTE IN ORDER. DO NOT SKIP.**
|
|
76
|
+
|
|
77
|
+
### ✅ Step 1: Determine Scope [BLOCKING]
|
|
78
|
+
**ORDER: 1/4 - Affects which guides to use**
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// ASK if unclear:
|
|
82
|
+
"Should this component appear in Interface Designer toolbar? [Y/n]"
|
|
83
|
+
|
|
84
|
+
// STORE:
|
|
85
|
+
if (answer === "Y") {
|
|
86
|
+
SESSION.scope = "runtime+designer";
|
|
87
|
+
// MUST also read: REMOTE_COMPONENT_DESIGN_TIME_AI_GUIDE.md
|
|
88
|
+
|
|
89
|
+
// CRITICAL: Design-time dependency check
|
|
90
|
+
const packageJson = readJson('package.json');
|
|
91
|
+
const hasInterfaceDesignerDep = Boolean(
|
|
92
|
+
packageJson?.dependencies?.['@creatio/interface-designer'] ||
|
|
93
|
+
packageJson?.devDependencies?.['@creatio/interface-designer']
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
if (!hasInterfaceDesignerDep) {
|
|
97
|
+
INFORM_USER:
|
|
98
|
+
"Right panel (properties panel) requires @creatio/interface-designer, but it is missing in package.json.";
|
|
99
|
+
ASK_USER:
|
|
100
|
+
"Dependency @creatio/interface-designer is missing. Do you want me to add it to package.json now? [Y/n]";
|
|
101
|
+
RULE:
|
|
102
|
+
"NEVER modify package.json or run npm/yarn/pnpm install for @creatio/interface-designer without explicit user confirmation in the current turn.";
|
|
103
|
+
PROPOSE_INSTALL:
|
|
104
|
+
"Install it first? Example: npm i @creatio/interface-designer";
|
|
105
|
+
WAIT_FOR_CONFIRMATION_BEFORE_GENERATING_PANEL();
|
|
106
|
+
|
|
107
|
+
if (userAnswer !== "Y") {
|
|
108
|
+
SESSION.scope = "runtime-only";
|
|
109
|
+
RULE:
|
|
110
|
+
"If user declined dependency installation, DO NOT generate design-time files/properties panel even if panel requirements are present in task description.";
|
|
111
|
+
INFORM_USER:
|
|
112
|
+
"Proceeding with runtime-only component because @creatio/interface-designer is not available and installation was declined.";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
SESSION.scope = "runtime-only";
|
|
117
|
+
// This guide only
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### ✅ Step 2: Extract Prefix [BLOCKING]
|
|
124
|
+
**ORDER: 2/4 - Must complete before generation**
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# ACTION:
|
|
128
|
+
rg -n "\"prefix\"" angular.json
|
|
129
|
+
# OR read file directly with PowerShell
|
|
130
|
+
|
|
131
|
+
# STORE:
|
|
132
|
+
SESSION.prefix = <result>
|
|
133
|
+
|
|
134
|
+
# VALIDATE:
|
|
135
|
+
if (SESSION.prefix === null) { SESSION.prefix = "usr"; }
|
|
136
|
+
if (SESSION.prefix === "crt") { → See ESCAPE HATCH #2 }
|
|
137
|
+
|
|
138
|
+
# VERIFY:
|
|
139
|
+
assert(SESSION.prefix !== null && SESSION.prefix !== "crt")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Edge case:** Multiple projects? → ESCAPE HATCH #1
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### ✅ Step 3: Get Component Name [BLOCKING]
|
|
147
|
+
**ORDER: 3/4 - Required for placeholders**
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// ACTION: Extract from user request
|
|
151
|
+
const userInput = "StatusIndicator"; // or "status indicator" or "status-indicator"
|
|
152
|
+
|
|
153
|
+
// TRANSFORM:
|
|
154
|
+
SESSION.component_name_kebab = toKebab(userInput); // "status-indicator"
|
|
155
|
+
SESSION.component_name_pascal = toPascal(userInput); // "StatusIndicator"
|
|
156
|
+
SESSION.component_name_upper = toUpperSnake(userInput); // "STATUS_INDICATOR"
|
|
157
|
+
|
|
158
|
+
// VERIFY:
|
|
159
|
+
assert(all transformations !== null)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### ✅ Step 4: Detect Binding Cardinality [BLOCKING]
|
|
165
|
+
**ORDER: 4/4 - Required for correct runtime generation**
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
const strongCollectionSignals = [
|
|
169
|
+
USER_REQUEST_MENTIONS_ANY(['line items', 'table rows', 'collection list']),
|
|
170
|
+
USER_REQUEST_MENTIONS_ANY(['add column', 'remove column', 'columns list']),
|
|
171
|
+
USER_REQUEST_MENTIONS_ANY(['collection attribute']),
|
|
172
|
+
RUNTIME_TEMPLATE_HAS_ROW_LOOP, // @for row of ...
|
|
173
|
+
DESIGN_TIME_USES_COLLECTION_API, // isCollection: true / bindToAttribute(items)
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
if (strongCollectionSignals.some(Boolean)) {
|
|
177
|
+
SESSION_STATE.input_shape = 'collection';
|
|
178
|
+
SESSION_STATE.input_shape_source = 'contract-signals';
|
|
179
|
+
} else {
|
|
180
|
+
SESSION_STATE.input_shape = 'scalar';
|
|
181
|
+
SESSION_STATE.input_shape_source = 'default-scalar';
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
⚠️ `entitySchema` and `dataSourceName` MUST NOT be used to infer cardinality.
|
|
186
|
+
|
|
187
|
+
**BLOCKING RULES (collection):**
|
|
188
|
+
- Runtime MUST resolve row values asynchronously (`await Promise.resolve(...)`, `Promise.all(...)`).
|
|
189
|
+
- NEVER rely on framework internals (`__zone_symbol__state`, `__zone_symbol__value`).
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
**TRANSITION:**
|
|
194
|
+
```typescript
|
|
195
|
+
if (Steps 1-4 complete) {
|
|
196
|
+
SESSION_STATE.phase = 'generate';
|
|
197
|
+
PROCEED_TO_TEMPLATES();
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Deferred Remote Decision (NEW FORMAT)
|
|
204
|
+
|
|
205
|
+
**CRITICAL:** This guide supports TWO registration formats. Keep the old instructions unchanged for legacy remotes. Switch to deferred-remote instructions only when the project already follows the new `RemoteEntryDefinition` + feature-based structure.
|
|
206
|
+
|
|
207
|
+
### Detect the format first
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// Check main.ts and potential alternative entry files
|
|
211
|
+
const mainFiles = ['src/main.ts', 'src/index.ts'];
|
|
212
|
+
const hasDeferredEntryDefinition = mainFiles.some((file) =>
|
|
213
|
+
fileExists(file) &&
|
|
214
|
+
(fileContains(file, 'RemoteEntryDefinition') ||
|
|
215
|
+
fileContains(file, 'features: [') ||
|
|
216
|
+
fileContains(file, 'export default') && fileContains(file, 'features'))
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
const hasFeatureFolders =
|
|
220
|
+
dirExists('src/app/features/runtime') &&
|
|
221
|
+
dirExists('src/app/features/design');
|
|
222
|
+
|
|
223
|
+
if (hasDeferredEntryDefinition || hasFeatureFolders) {
|
|
224
|
+
SESSION_STATE.remote_format = 'deferred-remote';
|
|
225
|
+
} else {
|
|
226
|
+
SESSION_STATE.remote_format = 'legacy-module';
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Routing rule
|
|
231
|
+
|
|
232
|
+
```yaml
|
|
233
|
+
If SESSION_STATE.remote_format == legacy-module:
|
|
234
|
+
- Keep using all existing instructions in this guide as-is
|
|
235
|
+
- Keep @CrtInterfaceDesignerItem on runtime component when designer support is required
|
|
236
|
+
- Keep module-based registration flow from "Component Registration in Module"
|
|
237
|
+
|
|
238
|
+
If SESSION_STATE.remote_format == deferred-remote:
|
|
239
|
+
- DO NOT use @CrtInterfaceDesignerItem on runtime component
|
|
240
|
+
- Keep @CrtViewElement / @Input / @Output / @CrtInput / @CrtOutput on runtime component
|
|
241
|
+
- Register runtime component through:
|
|
242
|
+
- runtime.feature-definition.ts
|
|
243
|
+
- runtime.feature-activation.ts
|
|
244
|
+
- runtime.designer-definitions.ts
|
|
245
|
+
- If component has a custom properties panel, register that panel separately through:
|
|
246
|
+
- design.feature-definition.ts
|
|
247
|
+
- design.feature-activation.ts
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Minimal deferred-remote file set for one runtime component
|
|
251
|
+
|
|
252
|
+
```text
|
|
253
|
+
src/main.ts
|
|
254
|
+
src/app/remote-app-context.ts
|
|
255
|
+
src/app/features/runtime/
|
|
256
|
+
runtime-feature.ids.ts
|
|
257
|
+
runtime-feature.module.ts
|
|
258
|
+
runtime.feature-definition.ts
|
|
259
|
+
runtime.feature-activation.ts
|
|
260
|
+
runtime.designer-definitions.ts
|
|
261
|
+
view-elements/{{COMPONENT_NAME_KEBAB}}/{{COMPONENT_NAME_KEBAB}}.component.ts
|
|
262
|
+
|
|
263
|
+
src/app/features/design/ # only when a custom panel exists
|
|
264
|
+
design-feature.ids.ts
|
|
265
|
+
design-feature.module.ts
|
|
266
|
+
design.feature-definition.ts
|
|
267
|
+
design.feature-activation.ts
|
|
268
|
+
property-panels/{{COMPONENT_NAME_KEBAB}}/{{COMPONENT_NAME_KEBAB}}-panel.component.ts
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## 🚪 Escape Hatches (Edge Cases)
|
|
274
|
+
|
|
275
|
+
### ESCAPE HATCH #1: Multiple Projects in Monorepo
|
|
276
|
+
**DETECTION:** `(rg -n "\"prefix\"" angular.json | Measure-Object).Count > 1`
|
|
277
|
+
|
|
278
|
+
**SOLUTION:**
|
|
279
|
+
```typescript
|
|
280
|
+
const prefixes = extractAllPrefixes(angular_json); // ["usr", "admin", "public"]
|
|
281
|
+
|
|
282
|
+
ASK_USER: `Found ${prefixes.length} projects with prefixes: ${prefixes.join(', ')}. Which project? [${prefixes[0]}]`
|
|
283
|
+
|
|
284
|
+
WAIT_FOR_ANSWER;
|
|
285
|
+
|
|
286
|
+
SESSION.prefix = USER_ANSWER || prefixes[0];
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### ESCAPE HATCH #2: User is Creatio Internal (crt prefix)
|
|
292
|
+
**DETECTION:** `SESSION.prefix === "crt"`
|
|
293
|
+
|
|
294
|
+
**SOLUTION:**
|
|
295
|
+
```typescript
|
|
296
|
+
ASK_USER: "⚠️ 'crt' prefix is for Creatio internal only. Are you internal dev? [Y/n]"
|
|
297
|
+
|
|
298
|
+
if (answer === "Y") {
|
|
299
|
+
ALLOW_CRT_PREFIX();
|
|
300
|
+
WARN: "Using 'crt' - won't work in customer projects";
|
|
301
|
+
} else {
|
|
302
|
+
SESSION.prefix = "usr";
|
|
303
|
+
INFORM: "Changed to 'usr' for external compatibility";
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
### ESCAPE HATCH #3: Component Exists
|
|
310
|
+
**DETECTION:** File exists at `src/app/view-elements/{{NAME}}/{{NAME}}.component.ts`
|
|
311
|
+
|
|
312
|
+
**SOLUTION:**
|
|
313
|
+
```typescript
|
|
314
|
+
ASK_USER: "Component '{{NAME}}' exists. Choose action:"
|
|
315
|
+
OPTIONS:
|
|
316
|
+
1. "Overwrite (⚠️ loses changes)"
|
|
317
|
+
2. "Rename to '{{NAME}}-v2'"
|
|
318
|
+
3. "Cancel"
|
|
319
|
+
|
|
320
|
+
EXECUTE_BASED_ON_CHOICE();
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
### ESCAPE HATCH #4: No angular.json Found
|
|
326
|
+
**DETECTION:** `!fileExists('angular.json')`
|
|
327
|
+
|
|
328
|
+
**SOLUTION:**
|
|
329
|
+
```typescript
|
|
330
|
+
SEARCH: Find angular.json up to 3 parent directories
|
|
331
|
+
|
|
332
|
+
if (FOUND) {
|
|
333
|
+
USE_THAT_PATH();
|
|
334
|
+
} else {
|
|
335
|
+
// Auto-detect workspace metadata first. Ask only if ambiguous.
|
|
336
|
+
SEARCH_FOR: 'workspace.json' or 'nx.json'
|
|
337
|
+
if (FOUND_WORKSPACE_METADATA) {
|
|
338
|
+
WARN: "angular.json not found. Using workspace metadata and fallback prefix 'usr' if needed";
|
|
339
|
+
SESSION.prefix = SESSION.prefix || "usr";
|
|
340
|
+
} else {
|
|
341
|
+
ASK_IF_AMBIGUOUS: "No workspace config found. Confirm fallback prefix 'usr'? [Y/n]"
|
|
342
|
+
SESSION.prefix = "usr";
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## 🧪 Dry-Run Mode
|
|
350
|
+
|
|
351
|
+
**EXECUTE before actual generation. Show user the plan.**
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# DRY RUN REPORT
|
|
355
|
+
==================================================
|
|
356
|
+
Component: {{PREFIX}}-{{COMPONENT_NAME_KEBAB}}
|
|
357
|
+
Prefix: ${SESSION.prefix}
|
|
358
|
+
Scope: ${SESSION.scope}
|
|
359
|
+
|
|
360
|
+
Files to create:
|
|
361
|
+
✓ src/app/view-elements/${NAME}/${NAME}.component.ts
|
|
362
|
+
✓ src/app/view-elements/${NAME}/${NAME}.component.html
|
|
363
|
+
✓ src/app/view-elements/${NAME}/${NAME}.component.scss
|
|
364
|
+
✓ src/app/view-elements/${NAME}/${NAME}.component.spec.ts
|
|
365
|
+
${SESSION.scope === 'runtime+designer' ? '✓ Design-time files' : ''}
|
|
366
|
+
|
|
367
|
+
Files to modify:
|
|
368
|
+
✓ src/app/${MODULE}.module.ts (add registration)
|
|
369
|
+
|
|
370
|
+
Conflicts: ${CHECK_FOR_CONFLICTS()}
|
|
371
|
+
|
|
372
|
+
Ready to generate: ${CONFLICTS.length === 0 ? 'YES' : 'NO - resolve conflicts first'}
|
|
373
|
+
==================================================
|
|
374
|
+
|
|
375
|
+
Proceed with generation? [Y/n]
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**If user confirms → proceed. If not → abort gracefully.**
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## 📊 Confidence Self-Assessment
|
|
383
|
+
|
|
384
|
+
**CALCULATE before presenting code. Minimum 90/100 to proceed.**
|
|
385
|
+
|
|
386
|
+
**🚨 MANDATORY: Tests are BLOCKING requirement - cannot proceed without passing tests**
|
|
387
|
+
|
|
388
|
+
```typescript
|
|
389
|
+
let CONFIDENCE = 0;
|
|
390
|
+
|
|
391
|
+
// Prefix extracted correctly? (+20)
|
|
392
|
+
if (SESSION.prefix !== null && SESSION.prefix !== 'crt') { CONFIDENCE += 20; }
|
|
393
|
+
|
|
394
|
+
// All placeholders replaced? (+20)
|
|
395
|
+
const unreplacedCount = countPlaceholders(generatedCode);
|
|
396
|
+
if (unreplacedCount === 0) { CONFIDENCE += 20; }
|
|
397
|
+
|
|
398
|
+
// Lint passed? (+20)
|
|
399
|
+
const lintResult = runSync('npm run lint -- --fix');
|
|
400
|
+
if (lintResult.exitCode === 0) { CONFIDENCE += 20; }
|
|
401
|
+
|
|
402
|
+
// 🚨 MANDATORY: Tests passed? (+20) - BLOCKING
|
|
403
|
+
const testResult = runSync('npm test');
|
|
404
|
+
const testFileExists = fileExists(`src/app/view-elements/${NAME}/${NAME}.component.spec.ts`);
|
|
405
|
+
if (testResult.exitCode === 0 && testFileExists) {
|
|
406
|
+
CONFIDENCE += 20;
|
|
407
|
+
} else {
|
|
408
|
+
ERROR: "❌ BLOCKING: Tests must be generated and pass before presenting code";
|
|
409
|
+
GENERATE_TESTS_IF_MISSING();
|
|
410
|
+
FIX_FAILING_TESTS();
|
|
411
|
+
RETRY();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// 🚨 MANDATORY: WCAG conformance audit against WCAG_ACCESSIBILITY_AI_GUIDE.md - BLOCKING
|
|
415
|
+
const wcagAuditResult = runWcagCodeAudit(generatedCode, 'WCAG_ACCESSIBILITY_AI_GUIDE.md');
|
|
416
|
+
const wcagPassed = wcagAuditResult.critical.length === 0 && wcagAuditResult.major.length === 0;
|
|
417
|
+
if (!wcagPassed) {
|
|
418
|
+
ERROR: `❌ BLOCKING: WCAG audit failed (critical: ${wcagAuditResult.critical.length}, major: ${wcagAuditResult.major.length})`;
|
|
419
|
+
FIX_WCAG_VIOLATIONS(wcagAuditResult);
|
|
420
|
+
RETRY();
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Custom element registration found? (+10)
|
|
424
|
+
const hasRegistration = /customElements\.define/.test(moduleCode);
|
|
425
|
+
if (hasRegistration) { CONFIDENCE += 10; }
|
|
426
|
+
|
|
427
|
+
// Decorators paired correctly? (+10)
|
|
428
|
+
const inputsMatch = countDecorators('@Input') === countDecorators('@CrtInput');
|
|
429
|
+
const outputsMatch = countDecorators('@Output') === countDecorators('@CrtOutput');
|
|
430
|
+
if (inputsMatch && outputsMatch) { CONFIDENCE += 10; }
|
|
431
|
+
|
|
432
|
+
SESSION_STATE.score = CONFIDENCE;
|
|
433
|
+
|
|
434
|
+
// DECISION:
|
|
435
|
+
if (CONFIDENCE >= 90) {
|
|
436
|
+
PRESENT_TO_USER();
|
|
437
|
+
} else if (CONFIDENCE >= 70) {
|
|
438
|
+
WARN: "⚠️ Medium confidence. Review before use.";
|
|
439
|
+
PRESENT_WITH_WARNING();
|
|
440
|
+
} else {
|
|
441
|
+
ERROR: "❌ Low confidence. Fixing issues...";
|
|
442
|
+
AUTO_FIX_AND_RETRY();
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### WCAG Generation Checklist (MANDATORY)
|
|
447
|
+
|
|
448
|
+
**Apply these requirements DURING code generation, NOT after:**
|
|
449
|
+
|
|
450
|
+
**🚨 CRITICAL (Blocking) — Must include in EVERY component:**
|
|
451
|
+
```yaml
|
|
452
|
+
✅ Semantic HTML elements:
|
|
453
|
+
- Use <button> for clickable actions, NOT <div> with click handler
|
|
454
|
+
- Use <input>, <select>, <textarea> for form controls
|
|
455
|
+
- Use <label> for input labels with [for] or wrapping
|
|
456
|
+
|
|
457
|
+
✅ Accessible names for ALL interactive elements:
|
|
458
|
+
- aria-label="descriptive text" OR visible text content
|
|
459
|
+
- NEVER leave buttons/inputs without accessible name
|
|
460
|
+
|
|
461
|
+
✅ Keyboard support:
|
|
462
|
+
- @HostListener('keydown') for Enter/Space on custom interactive elements
|
|
463
|
+
- Proper tabindex management (0 for focusable, -1 for programmatic)
|
|
464
|
+
- Focus trap in modals (if applicable)
|
|
465
|
+
|
|
466
|
+
✅ Form label association:
|
|
467
|
+
- <label [for]="uniqueInputId">Label text</label>
|
|
468
|
+
- OR <label><input />Label text</label>
|
|
469
|
+
- Generated unique IDs for inputs
|
|
470
|
+
|
|
471
|
+
✅ ARIA state synchronization:
|
|
472
|
+
- [attr.aria-disabled]="disabled" synced with [disabled]
|
|
473
|
+
- [attr.aria-checked]="checked" for checkboxes/radio
|
|
474
|
+
- [attr.aria-expanded]="isOpen" for collapsibles
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**⚠️ IMPORTANT (Strongly recommended):**
|
|
478
|
+
```yaml
|
|
479
|
+
✅ Focus visibility:
|
|
480
|
+
- CSS :focus-visible styles
|
|
481
|
+
- Outline never set to 'none' without alternative
|
|
482
|
+
|
|
483
|
+
✅ Color not sole indicator:
|
|
484
|
+
- Error states: use icon + color + text
|
|
485
|
+
- Status: use icon/text, not color only
|
|
486
|
+
|
|
487
|
+
✅ Dynamic content announcements:
|
|
488
|
+
- aria-live="polite" for status messages
|
|
489
|
+
- aria-live="assertive" for errors
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
**Self-check before presenting code:**
|
|
493
|
+
```typescript
|
|
494
|
+
// AI internal validation:
|
|
495
|
+
const wcagChecks = {
|
|
496
|
+
hasSemanticHTML: code.includes('<button>') || code.includes('<input>'),
|
|
497
|
+
hasAccessibleNames: code.includes('aria-label') || hasVisibleText,
|
|
498
|
+
hasKeyboardSupport: code.includes('@HostListener(\'keydown\')'),
|
|
499
|
+
hasLabelAssociation: code.includes('[for]=') || code.includes('<label>'),
|
|
500
|
+
hasAriaSync: code.includes('[attr.aria-') && code.includes(']="'),
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
const allCriticalPassed = Object.values(wcagChecks).every(v => v);
|
|
504
|
+
if (!allCriticalPassed) {
|
|
505
|
+
REGENERATE_WITH_FIXES(); // Do NOT present to user
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
**OUTPUT FORMAT:**
|
|
510
|
+
```
|
|
511
|
+
🎯 Generation Confidence: ${CONFIDENCE}/100
|
|
512
|
+
|
|
513
|
+
${CONFIDENCE >= 90 ? '✅' : '⚠️'} Checks:
|
|
514
|
+
${SESSION.prefix ? '✅' : '❌'} Prefix extracted: ${SESSION.prefix}
|
|
515
|
+
${unreplacedCount === 0 ? '✅' : '❌'} Placeholders replaced: ${countTotal - unreplacedCount}/${countTotal}
|
|
516
|
+
${lintPassed ? '✅' : '❌'} Lint passed
|
|
517
|
+
${testFileExists ? '✅' : '❌'} Test file generated: ${testFileExists ? 'YES' : 'MISSING (BLOCKING)'}
|
|
518
|
+
${testsPassed ? '✅' : '❌'} Tests passed: ${passedTests}/${totalTests} ${!testsPassed ? '(BLOCKING)' : ''}
|
|
519
|
+
${wcagPassed ? '✅' : '❌'} WCAG audit (WCAG_ACCESSIBILITY_AI_GUIDE.md): ${wcagPassed ? 'Passed' : `Failed (critical: ${wcagAuditResult.critical.length}, major: ${wcagAuditResult.major.length})`}
|
|
520
|
+
${hasRegistration ? '✅' : '❌'} Custom element registration: ${hasRegistration ? 'Found' : 'MISSING'}
|
|
521
|
+
${decoratorsPaired ? '✅' : '❌'} Decorators paired correctly
|
|
522
|
+
|
|
523
|
+
${CONFIDENCE >= 90 ? 'Ready to use ✅' : 'Review recommended ⚠️'}
|
|
524
|
+
${!testFileExists || !testsPassed ? '🚨 BLOCKING: Must fix tests before proceeding' : ''}
|
|
525
|
+
${!wcagPassed ? '🚨 BLOCKING: Must fix WCAG violations before proceeding' : ''}
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
## 🔧 Component Templates & Real-World Examples
|
|
531
|
+
|
|
532
|
+
### 📚 Template Categories
|
|
533
|
+
|
|
534
|
+
Components can be categorized by complexity:
|
|
535
|
+
1. **Simple Display Components** - Display data with minimal interaction
|
|
536
|
+
2. **Input Components** - Handle user input and emit changes
|
|
537
|
+
3. **Data-Bound Components** - Connect to data sources
|
|
538
|
+
|
|
539
|
+
---
|
|
540
|
+
|
|
541
|
+
## 🎨 Component Icon Requirements
|
|
542
|
+
|
|
543
|
+
```yaml
|
|
544
|
+
✅ MANDATORY: Store icon SVG as a SEPARATE FILE (icon.svg)
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
**Detailed specifications:** `ICON_REQUIREMENTS_AI_GUIDE.md`
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
## 📋 EXAMPLE 1: Simple Input Component with Two-Way Binding
|
|
552
|
+
|
|
553
|
+
> **⚠️ Format:** This example follows the **legacy-module** format. For deferred-remote projects, see [Component Registration in Deferred Remote Features](#component-registration-in-deferred-remote-features).
|
|
554
|
+
|
|
555
|
+
**Use case:** Text input field with label and value change event
|
|
556
|
+
|
|
557
|
+
```typescript
|
|
558
|
+
// FILE: src/lib/{{COMPONENT_NAME_KEBAB}}/{{COMPONENT_NAME_KEBAB}}.component.ts
|
|
559
|
+
|
|
560
|
+
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
|
|
561
|
+
import { CrtInput, CrtInterfaceDesignerItem, CrtOutput, CrtViewElement } from '@creatio-devkit/common';
|
|
562
|
+
|
|
563
|
+
const ICON_SVG = '<svg>...</svg>'; // ⚠️ Create icon.svg file first, then inline here
|
|
564
|
+
|
|
565
|
+
@CrtInterfaceDesignerItem({
|
|
566
|
+
toolbarConfig: {
|
|
567
|
+
caption: '{{COMPONENT_NAME_PASCAL}}',
|
|
568
|
+
icon: ICON_SVG,
|
|
569
|
+
},
|
|
570
|
+
propertiesPanel: '{{PREFIX}}.{{COMPONENT_NAME_PASCAL}}Panel',
|
|
571
|
+
})
|
|
572
|
+
@CrtViewElement({
|
|
573
|
+
selector: '{{PREFIX}}-{{COMPONENT_NAME_KEBAB}}',
|
|
574
|
+
type: '{{PREFIX}}.{{COMPONENT_NAME_PASCAL}}',
|
|
575
|
+
})
|
|
576
|
+
@Component({
|
|
577
|
+
selector: '{{PREFIX}}-{{COMPONENT_NAME_KEBAB}}',
|
|
578
|
+
templateUrl: './{{COMPONENT_NAME_KEBAB}}.component.html',
|
|
579
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
580
|
+
encapsulation: ViewEncapsulation.ShadowDom,
|
|
581
|
+
})
|
|
582
|
+
export class {{COMPONENT_NAME_PASCAL}}Component {
|
|
583
|
+
@Input()
|
|
584
|
+
@CrtInput()
|
|
585
|
+
public label = '';
|
|
586
|
+
|
|
587
|
+
@Input()
|
|
588
|
+
@CrtInput()
|
|
589
|
+
public value = '';
|
|
590
|
+
|
|
591
|
+
@Output()
|
|
592
|
+
@CrtOutput()
|
|
593
|
+
public readonly valueChange = new EventEmitter<string>();
|
|
594
|
+
|
|
595
|
+
protected onInput(event: Event): void {
|
|
596
|
+
const value = (event.target as HTMLInputElement).value;
|
|
597
|
+
this.valueChange.emit(value);
|
|
598
|
+
this.value = value;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
**HTML Template:**
|
|
604
|
+
```html
|
|
605
|
+
<!-- FILE: src/lib/{{COMPONENT_NAME_KEBAB}}/{{COMPONENT_NAME_KEBAB}}.component.html -->
|
|
606
|
+
<label>
|
|
607
|
+
{{ label }}:
|
|
608
|
+
<input type="text" [value]="value" (input)="onInput($event)" />
|
|
609
|
+
</label>
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
**Key patterns:**
|
|
613
|
+
- ✅ `@Input() + @CrtInput()` paired decorators for properties
|
|
614
|
+
- ✅ `@Output() + @CrtOutput()` paired decorators for events
|
|
615
|
+
- ✅ `ViewEncapsulation.ShadowDom` for runtime isolation
|
|
616
|
+
- ✅ `ChangeDetectionStrategy.OnPush` for performance
|
|
617
|
+
- ✅ Two-way binding pattern with `valueChange` event
|
|
618
|
+
|
|
619
|
+
---
|
|
620
|
+
|
|
621
|
+
## 📋 EXAMPLE 2: Display Component with Multiple Visual Properties
|
|
622
|
+
|
|
623
|
+
> **⚠️ Format:** This example follows the **legacy-module** format. For deferred-remote projects, see [Component Registration in Deferred Remote Features](#component-registration-in-deferred-remote-features).
|
|
624
|
+
|
|
625
|
+
**Use case:** Label/text display with styling options and click event
|
|
626
|
+
|
|
627
|
+
```typescript
|
|
628
|
+
// FILE: src/lib/{{COMPONENT_NAME_KEBAB}}/{{COMPONENT_NAME_KEBAB}}.component.ts
|
|
629
|
+
|
|
630
|
+
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
|
|
631
|
+
import { CrtInput, CrtInterfaceDesignerItem, CrtOutput, CrtViewElement } from '@creatio-devkit/common';
|
|
632
|
+
|
|
633
|
+
const DEFAULT_TEXT = 'Default Label';
|
|
634
|
+
const ICON_SVG = '<svg>...</svg>'; // ⚠️ Create icon.svg file first, then inline here
|
|
635
|
+
|
|
636
|
+
@CrtInterfaceDesignerItem({
|
|
637
|
+
toolbarConfig: {
|
|
638
|
+
caption: 'Custom Label',
|
|
639
|
+
icon: ICON_SVG,
|
|
640
|
+
},
|
|
641
|
+
propertiesPanel: '{{PREFIX}}.{{COMPONENT_NAME_PASCAL}}Panel',
|
|
642
|
+
})
|
|
643
|
+
@CrtViewElement({
|
|
644
|
+
selector: '{{PREFIX}}-{{COMPONENT_NAME_KEBAB}}',
|
|
645
|
+
type: '{{PREFIX}}.{{COMPONENT_NAME_PASCAL}}',
|
|
646
|
+
})
|
|
647
|
+
@Component({
|
|
648
|
+
selector: '{{PREFIX}}-{{COMPONENT_NAME_KEBAB}}',
|
|
649
|
+
templateUrl: './{{COMPONENT_NAME_KEBAB}}.component.html',
|
|
650
|
+
styleUrls: ['./{{COMPONENT_NAME_KEBAB}}.component.scss'],
|
|
651
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
652
|
+
encapsulation: ViewEncapsulation.ShadowDom,
|
|
653
|
+
})
|
|
654
|
+
export class {{COMPONENT_NAME_PASCAL}}Component {
|
|
655
|
+
@Input()
|
|
656
|
+
@CrtInput()
|
|
657
|
+
public visible = true;
|
|
658
|
+
|
|
659
|
+
@Input({ transform: (value: string | null | undefined) => value?.trim() || DEFAULT_TEXT })
|
|
660
|
+
@CrtInput()
|
|
661
|
+
public text: string = DEFAULT_TEXT;
|
|
662
|
+
|
|
663
|
+
@Input()
|
|
664
|
+
@CrtInput()
|
|
665
|
+
public color = 'black';
|
|
666
|
+
|
|
667
|
+
@Input()
|
|
668
|
+
@CrtInput()
|
|
669
|
+
public description: string;
|
|
670
|
+
|
|
671
|
+
@Output()
|
|
672
|
+
@CrtOutput()
|
|
673
|
+
public clicked = new EventEmitter<void>();
|
|
674
|
+
|
|
675
|
+
public onLabelClick(): void {
|
|
676
|
+
this.clicked.emit();
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
**HTML Template:**
|
|
682
|
+
```html
|
|
683
|
+
<!-- FILE: src/lib/{{COMPONENT_NAME_KEBAB}}/{{COMPONENT_NAME_KEBAB}}.component.html -->
|
|
684
|
+
@if (visible) {
|
|
685
|
+
<div class="custom-label" data-testid="custom-label">
|
|
686
|
+
@if (description) {
|
|
687
|
+
<div class="custom-label__description">{{ description }}</div>
|
|
688
|
+
}
|
|
689
|
+
<span class="custom-label__text" [style.color]="color">{{ text }}</span>
|
|
690
|
+
<button type="button" (click)="onLabelClick()">Action</button>
|
|
691
|
+
</div>
|
|
692
|
+
}
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
**Key patterns:**
|
|
696
|
+
- ✅ Input transformers for data sanitization: `@Input({ transform: ... })`
|
|
697
|
+
- ✅ Conditional rendering with `@if` control flow
|
|
698
|
+
- ✅ Multiple styled properties (color, text, visibility)
|
|
699
|
+
- ✅ BEM-style CSS classes for styling
|
|
700
|
+
- ✅ Default value constants for consistency
|
|
701
|
+
|
|
702
|
+
---
|
|
703
|
+
|
|
704
|
+
## 🔄 Two-Way Data Binding for Data Source Integration
|
|
705
|
+
|
|
706
|
+
**CRITICAL REQUIREMENT:** Components with user-editable @Input properties MUST implement two-way data binding.
|
|
707
|
+
|
|
708
|
+
### 📋 Core Requirements
|
|
709
|
+
|
|
710
|
+
**1. When Two-Way Binding is REQUIRED:**
|
|
711
|
+
- Component allows user to modify an @Input property through UI interaction
|
|
712
|
+
- Property should sync with Creatio Data Source
|
|
713
|
+
|
|
714
|
+
**2. When Two-Way Binding is NOT needed:**
|
|
715
|
+
- Component is display-only (no user input)
|
|
716
|
+
- Property is configuration-only (not bound to Data Source)
|
|
717
|
+
|
|
718
|
+
### ✅ Mandatory Pattern
|
|
719
|
+
|
|
720
|
+
For EACH user-editable @Input property:
|
|
721
|
+
|
|
722
|
+
**A. Structure:**
|
|
723
|
+
```typescript
|
|
724
|
+
// 1. Private field for internal state
|
|
725
|
+
private _propertyName: Type = defaultValue;
|
|
726
|
+
|
|
727
|
+
// 2. Public @Input for external binding
|
|
728
|
+
@Input()
|
|
729
|
+
@CrtInput()
|
|
730
|
+
public propertyName: Type = defaultValue;
|
|
731
|
+
|
|
732
|
+
// 3. @Output event with "Change" suffix
|
|
733
|
+
@Output()
|
|
734
|
+
@CrtOutput()
|
|
735
|
+
public readonly propertyNameChange = new EventEmitter<Type>();
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
**B. Lifecycle:**
|
|
739
|
+
```typescript
|
|
740
|
+
// 4. Implement OnChanges interface
|
|
741
|
+
export class MyComponent implements OnChanges {
|
|
742
|
+
|
|
743
|
+
// 5. Handle external changes (Data Source → Component)
|
|
744
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
745
|
+
if (changes['propertyName']) {
|
|
746
|
+
this._propertyName = this._normalize(changes['propertyName'].currentValue);
|
|
747
|
+
this._cdr.markForCheck();
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// 6. Handle internal changes (Component → Data Source)
|
|
752
|
+
protected onPropertyChange(newValue: Type): void {
|
|
753
|
+
this._propertyName = this._normalize(newValue);
|
|
754
|
+
this.propertyName = this._propertyName; // Update @Input
|
|
755
|
+
this.propertyNameChange.emit(this._propertyName); // Emit event
|
|
756
|
+
this._cdr.markForCheck();
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
### 🚨 Critical Rules
|
|
762
|
+
|
|
763
|
+
**1. ALWAYS update THREE things on internal change:**
|
|
764
|
+
- `this._propertyName` (private state)
|
|
765
|
+
- `this.propertyName` (@Input property)
|
|
766
|
+
- `this.propertyNameChange.emit()` (event)
|
|
767
|
+
|
|
768
|
+
**2. For multiple editable properties:**
|
|
769
|
+
- Create SEPARATE @Output for EACH property
|
|
770
|
+
- Each property follows the same pattern independently
|
|
771
|
+
|
|
772
|
+
**3. DON'T use @Input setters:**
|
|
773
|
+
- Use `OnChanges` instead
|
|
774
|
+
- Setters are unreliable with Angular Custom Elements
|
|
775
|
+
|
|
776
|
+
**4. DON'T use complex objects as @Input:**
|
|
777
|
+
- Use flat primitive properties
|
|
778
|
+
- Creatio Data Source works with primitive types
|
|
779
|
+
|
|
780
|
+
### ⚠️ Consequences of Missing Two-Way Binding
|
|
781
|
+
|
|
782
|
+
Without proper implementation:
|
|
783
|
+
- "Save" button won't appear when user modifies value
|
|
784
|
+
- Changes won't propagate to other bound UI fields
|
|
785
|
+
- Data won't persist to Data Source
|
|
786
|
+
- ViewModel won't detect modifications
|
|
787
|
+
|
|
788
|
+
---
|
|
789
|
+
|
|
790
|
+
## 📋 Component Registration in Module
|
|
791
|
+
|
|
792
|
+
**CRITICAL:** Components MUST be registered as custom elements.
|
|
793
|
+
|
|
794
|
+
```typescript
|
|
795
|
+
// FILE: src/lib/{{MODULE_NAME}}.module.ts
|
|
796
|
+
|
|
797
|
+
import { CommonModule } from '@angular/common';
|
|
798
|
+
import { CUSTOM_ELEMENTS_SCHEMA, Injector, NgModule } from '@angular/core';
|
|
799
|
+
import { createCustomElement } from '@angular/elements';
|
|
800
|
+
import { bootstrapCrtModule, CrtModule, Type } from '@creatio-devkit/common';
|
|
801
|
+
|
|
802
|
+
import { {{COMPONENT_NAME_PASCAL}}Component } from './{{COMPONENT_NAME_KEBAB}}/{{COMPONENT_NAME_KEBAB}}.component';
|
|
803
|
+
|
|
804
|
+
@CrtModule({
|
|
805
|
+
viewElements: [{{COMPONENT_NAME_PASCAL}}Component],
|
|
806
|
+
})
|
|
807
|
+
@NgModule({
|
|
808
|
+
declarations: [{{COMPONENT_NAME_PASCAL}}Component],
|
|
809
|
+
imports: [CommonModule],
|
|
810
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
811
|
+
})
|
|
812
|
+
export class {{MODULE_NAME_PASCAL}}Module {
|
|
813
|
+
constructor(private injector: Injector) {
|
|
814
|
+
// CRITICAL: Registration MUST happen BEFORE bootstrapCrtModule
|
|
815
|
+
this.define('{{PREFIX}}-{{COMPONENT_NAME_KEBAB}}', {{COMPONENT_NAME_PASCAL}}Component);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
private define(selector: string, component: Type): void {
|
|
819
|
+
if (!customElements.get(selector)) {
|
|
820
|
+
customElements.define(selector, createCustomElement(component, { injector: this.injector }));
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// Bootstrap call
|
|
826
|
+
bootstrapCrtModule({{MODULE_NAME_PASCAL}}Module);
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
**Key patterns:**
|
|
830
|
+
- ✅ `@CrtModule({ viewElements: [...] })` decorator
|
|
831
|
+
- ✅ `CUSTOM_ELEMENTS_SCHEMA` in schemas array
|
|
832
|
+
- ✅ Custom element registration in constructor
|
|
833
|
+
- ✅ Guard against duplicate registration with `customElements.get()`
|
|
834
|
+
- ✅ `bootstrapCrtModule()` call AFTER module definition
|
|
835
|
+
|
|
836
|
+
---
|
|
837
|
+
|
|
838
|
+
## Component Registration in Deferred Remote Features
|
|
839
|
+
|
|
840
|
+
**USE THIS SECTION ONLY WHEN `SESSION_STATE.remote_format === 'deferred-remote'`.**
|
|
841
|
+
|
|
842
|
+
**CRITICAL differences from legacy format:**
|
|
843
|
+
- Runtime component stays a normal `@CrtViewElement`, but MUST NOT use `@CrtInterfaceDesignerItem`
|
|
844
|
+
- Designer metadata moves to `runtime.designer-definitions.ts`
|
|
845
|
+
- Runtime registration moves from eager module bootstrap to `runtime.feature-activation.ts`
|
|
846
|
+
- Property panel registration moves to the separate design feature
|
|
847
|
+
|
|
848
|
+
### 1. Runtime component stays lightweight
|
|
849
|
+
|
|
850
|
+
```typescript
|
|
851
|
+
import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core';
|
|
852
|
+
import { CrtInput, CrtViewElement } from '@creatio-devkit/common';
|
|
853
|
+
|
|
854
|
+
@CrtViewElement({
|
|
855
|
+
selector: '{{PREFIX}}-{{COMPONENT_NAME_KEBAB}}',
|
|
856
|
+
type: '{{PREFIX}}.{{COMPONENT_NAME_PASCAL}}',
|
|
857
|
+
})
|
|
858
|
+
@Component({
|
|
859
|
+
selector: '{{PREFIX}}-{{COMPONENT_NAME_KEBAB}}',
|
|
860
|
+
templateUrl: './{{COMPONENT_NAME_KEBAB}}.component.html',
|
|
861
|
+
styleUrls: ['./{{COMPONENT_NAME_KEBAB}}.component.scss'],
|
|
862
|
+
encapsulation: ViewEncapsulation.ShadowDom,
|
|
863
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
864
|
+
})
|
|
865
|
+
export class {{COMPONENT_NAME_PASCAL}}Component {
|
|
866
|
+
@Input()
|
|
867
|
+
@CrtInput()
|
|
868
|
+
public value = '';
|
|
869
|
+
}
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
**Deferred-remote rule:** runtime component contains runtime behavior only. Toolbar caption, icon, defaults, and `propertiesPanel` MUST NOT live on the component decorator.
|
|
873
|
+
|
|
874
|
+
### 2. Publish runtime discovery in `runtime.feature-definition.ts`
|
|
875
|
+
|
|
876
|
+
```typescript
|
|
877
|
+
import type { RemoteDesignerDefinitionsLoadContext, RemoteFeatureDefinition } from '@creatio-devkit/common';
|
|
878
|
+
|
|
879
|
+
import {
|
|
880
|
+
{{COMPONENT_NAME_UPPER}}_TYPE,
|
|
881
|
+
RUNTIME_FEATURE_ID,
|
|
882
|
+
} from './runtime-feature.ids';
|
|
883
|
+
|
|
884
|
+
export const runtimeFeatureDefinition = {
|
|
885
|
+
id: RUNTIME_FEATURE_ID,
|
|
886
|
+
discovery: {
|
|
887
|
+
viewElements: [{ type: {{COMPONENT_NAME_UPPER}}_TYPE }],
|
|
888
|
+
},
|
|
889
|
+
loadDesignerDefinitions: (context: RemoteDesignerDefinitionsLoadContext) =>
|
|
890
|
+
import('./runtime.designer-definitions').then((m) => m.loadRuntimeDesignerDefinitions(context)),
|
|
891
|
+
activate: () =>
|
|
892
|
+
import('./runtime.feature-activation').then((m) => m.activateRuntimeFeature()),
|
|
893
|
+
} satisfies RemoteFeatureDefinition;
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
**Rules:**
|
|
897
|
+
- `discovery.viewElements[].type` MUST exactly match `@CrtViewElement({ type })`
|
|
898
|
+
- Keep this file lightweight: IDs only, no icons, no heavy defaults, no runtime side effects
|
|
899
|
+
- If the component exposes handlers/validators/converters, publish them here too
|
|
900
|
+
|
|
901
|
+
### 3. Return toolbox metadata in `runtime.designer-definitions.ts`
|
|
902
|
+
|
|
903
|
+
```typescript
|
|
904
|
+
import type {
|
|
905
|
+
RemoteDesignerDefinitionsLoadContext,
|
|
906
|
+
RemoteFeatureDesignerDefinitions,
|
|
907
|
+
} from '@creatio-devkit/common';
|
|
908
|
+
|
|
909
|
+
import { {{COMPONENT_NAME_UPPER}}_ICON } from './runtime.designer-definitions.icons';
|
|
910
|
+
import {
|
|
911
|
+
{{COMPONENT_NAME_UPPER}}_PANEL_TYPE,
|
|
912
|
+
{{COMPONENT_NAME_UPPER}}_TYPE,
|
|
913
|
+
} from './runtime-feature.ids';
|
|
914
|
+
|
|
915
|
+
export function loadRuntimeDesignerDefinitions(
|
|
916
|
+
_context: RemoteDesignerDefinitionsLoadContext,
|
|
917
|
+
): Promise<RemoteFeatureDesignerDefinitions> {
|
|
918
|
+
return Promise.resolve({
|
|
919
|
+
viewElements: [
|
|
920
|
+
{
|
|
921
|
+
type: {{COMPONENT_NAME_UPPER}}_TYPE,
|
|
922
|
+
toolbarConfig: {
|
|
923
|
+
caption: '{{COMPONENT_NAME_PASCAL}}',
|
|
924
|
+
icon: {{COMPONENT_NAME_UPPER}}_ICON,
|
|
925
|
+
},
|
|
926
|
+
defaultPropertyValues: {
|
|
927
|
+
value: '',
|
|
928
|
+
},
|
|
929
|
+
propertiesPanel: {{COMPONENT_NAME_UPPER}}_PANEL_TYPE,
|
|
930
|
+
},
|
|
931
|
+
],
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
**Rules:**
|
|
937
|
+
- `propertiesPanel` is set here, not on the runtime component
|
|
938
|
+
- If there is no custom panel, omit `propertiesPanel`
|
|
939
|
+
- Keep translations/localization here if the remote supports localized toolbox metadata
|
|
940
|
+
|
|
941
|
+
### 4. Activate the runtime feature in `runtime.feature-activation.ts`
|
|
942
|
+
|
|
943
|
+
```typescript
|
|
944
|
+
import { ProviderToken, Type } from '@angular/core';
|
|
945
|
+
import { createCustomElement } from '@angular/elements';
|
|
946
|
+
import { bootstrapCrtModule } from '@creatio-devkit/common';
|
|
947
|
+
|
|
948
|
+
import { ensureFeatureModuleRef } from '../../remote-app-context';
|
|
949
|
+
import { {{COMPONENT_NAME_PASCAL}}Component } from './view-elements/{{COMPONENT_NAME_KEBAB}}/{{COMPONENT_NAME_KEBAB}}.component';
|
|
950
|
+
import { RuntimeFeatureModule } from './runtime-feature.module';
|
|
951
|
+
import {
|
|
952
|
+
{{COMPONENT_NAME_UPPER}}_SELECTOR,
|
|
953
|
+
REMOTE_NAME,
|
|
954
|
+
} from './runtime-feature.ids';
|
|
955
|
+
|
|
956
|
+
function defineCustomElement(selector: string, component: Type<unknown>, injector: unknown): void {
|
|
957
|
+
if (!customElements.get(selector)) {
|
|
958
|
+
customElements.define(selector, createCustomElement(component, { injector }));
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
export async function activateRuntimeFeature(): Promise<void> {
|
|
963
|
+
const moduleRef = await ensureFeatureModuleRef(RuntimeFeatureModule);
|
|
964
|
+
const injector = moduleRef.injector;
|
|
965
|
+
|
|
966
|
+
defineCustomElement({{COMPONENT_NAME_UPPER}}_SELECTOR, {{COMPONENT_NAME_PASCAL}}Component, injector);
|
|
967
|
+
|
|
968
|
+
bootstrapCrtModule(REMOTE_NAME, RuntimeFeatureModule, {
|
|
969
|
+
resolveDependency: (token: unknown) => injector.get(token as ProviderToken<unknown>),
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
**Rules:**
|
|
975
|
+
- Custom element registration happens in `activateRuntimeFeature()`, not in the Angular module constructor
|
|
976
|
+
- Keep `customElements.get(...)` guard
|
|
977
|
+
- Use `ensureFeatureModuleRef(...)` so activation is idempotent
|
|
978
|
+
- Call `bootstrapCrtModule(...)` after custom element registration
|
|
979
|
+
|
|
980
|
+
### 5. Runtime feature module owns declarations
|
|
981
|
+
|
|
982
|
+
```typescript
|
|
983
|
+
@CrtModule({
|
|
984
|
+
viewElements: [{{COMPONENT_NAME_PASCAL}}Component],
|
|
985
|
+
})
|
|
986
|
+
@NgModule({
|
|
987
|
+
declarations: [{{COMPONENT_NAME_PASCAL}}Component],
|
|
988
|
+
imports: [CommonModule],
|
|
989
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
990
|
+
})
|
|
991
|
+
export class RuntimeFeatureModule {}
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
**Rule:** in deferred remotes, this module is bootstrapped from `runtime.feature-activation.ts`, not from `src/main.ts`.
|
|
995
|
+
|
|
996
|
+
### 6. Wire the entry definition
|
|
997
|
+
|
|
998
|
+
```typescript
|
|
999
|
+
import type { RemoteEntryDefinition } from '@creatio-devkit/common';
|
|
1000
|
+
|
|
1001
|
+
import { designFeatureDefinition } from './app/features/design/design.feature-definition';
|
|
1002
|
+
import { runtimeFeatureDefinition } from './app/features/runtime/runtime.feature-definition';
|
|
1003
|
+
|
|
1004
|
+
export default {
|
|
1005
|
+
remoteName: '{{PROJECT_NAME}}',
|
|
1006
|
+
features: [runtimeFeatureDefinition, designFeatureDefinition],
|
|
1007
|
+
} satisfies RemoteEntryDefinition;
|
|
1008
|
+
```
|
|
1009
|
+
|
|
1010
|
+
**Rule:** if the remote has no custom panel, `features` may contain only `runtimeFeatureDefinition`.
|
|
1011
|
+
|
|
1012
|
+
### Deferred-remote checklist for runtime component
|
|
1013
|
+
|
|
1014
|
+
```markdown
|
|
1015
|
+
- [ ] Runtime component keeps `@CrtViewElement`, `@Input`, `@Output`, `@CrtInput`, `@CrtOutput`
|
|
1016
|
+
- [ ] Runtime component does NOT use `@CrtInterfaceDesignerItem`
|
|
1017
|
+
- [ ] `runtime.feature-definition.ts` publishes the component type in `discovery.viewElements`
|
|
1018
|
+
- [ ] `runtime.designer-definitions.ts` returns toolbar caption, icon, defaults, and `propertiesPanel` when needed
|
|
1019
|
+
- [ ] `runtime.feature-activation.ts` defines the custom element and calls `bootstrapCrtModule(...)`
|
|
1020
|
+
- [ ] `RuntimeFeatureModule` declares the component and includes it in `@CrtModule({ viewElements })`
|
|
1021
|
+
- [ ] `src/main.ts` exports `RemoteEntryDefinition`
|
|
1022
|
+
- [ ] If custom panel exists, the panel is registered through the separate design feature
|
|
1023
|
+
```
|
|
1024
|
+
|
|
1025
|
+
---
|
|
1026
|
+
|
|
1027
|
+
## 📋 Generation Checklist (Before Presenting)
|
|
1028
|
+
|
|
1029
|
+
**FINAL VALIDATION:**
|
|
1030
|
+
**Command mode:** Use `npm` commands for standalone projects. Use `npx nx ...` only in Nx monorepo workspaces.
|
|
1031
|
+
|
|
1032
|
+
**🚨 MANDATORY: TEST GENERATION IS REQUIRED**
|
|
1033
|
+
- Tests MUST be generated for ALL new components
|
|
1034
|
+
- Tests MUST pass before code is presented to the user
|
|
1035
|
+
- Tests MUST cover component initialization, inputs, outputs, and shadow DOM rendering
|
|
1036
|
+
- If tests fail, FIX issues before presenting code
|
|
1037
|
+
|
|
1038
|
+
```markdown
|
|
1039
|
+
- [ ] SESSION.prefix extracted and stored
|
|
1040
|
+
- [ ] All {{PLACEHOLDERS}} replaced
|
|
1041
|
+
- [ ] Files generated: component.ts, .html, .scss, .spec.ts
|
|
1042
|
+
- [ ] Module updated with customElements.define()
|
|
1043
|
+
- [ ] Registration BEFORE bootstrapCrtModule()
|
|
1044
|
+
- [ ] ViewEncapsulation.ShadowDom (NOT Emulated)
|
|
1045
|
+
- [ ] Every @Input has @CrtInput
|
|
1046
|
+
- [ ] Every @Output has @CrtOutput
|
|
1047
|
+
- [ ] Tests use .shadowRoot for queries
|
|
1048
|
+
- [ ] **MANDATORY: .spec.ts test file generated with comprehensive tests**
|
|
1049
|
+
- [ ] **MANDATORY: All tests pass (npm test) before presenting code**
|
|
1050
|
+
- [ ] **MANDATORY: Run WCAG code audit against WCAG_ACCESSIBILITY_AI_GUIDE.md**
|
|
1051
|
+
- [ ] **MANDATORY: WCAG audit has 0 critical and 0 major violations (BLOCKING)**
|
|
1052
|
+
- [ ] **MANDATORY: WCAG accessibility requirements met (see WCAG_ACCESSIBILITY_AI_GUIDE.md)**
|
|
1053
|
+
- [ ] Accessibility: Semantic HTML used (button, input, label, etc.)
|
|
1054
|
+
- [ ] Accessibility: All interactive elements have accessible names
|
|
1055
|
+
- [ ] Accessibility: Keyboard support (Tab, Enter, Space, Escape)
|
|
1056
|
+
- [ ] Accessibility: Focus management implemented correctly
|
|
1057
|
+
- [ ] Accessibility: ARIA attributes for dynamic states
|
|
1058
|
+
- [ ] Accessibility: Tests added to .spec.ts
|
|
1059
|
+
- [ ] npm run build passed (component builds successfully)
|
|
1060
|
+
- [ ] npm run lint -- --fix passed
|
|
1061
|
+
- [ ] Confidence score >= 90
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
**If ALL checked → PRESENT. If any unchecked → FIX first.**
|
|
1065
|
+
|
|
1066
|
+
---
|
|
1067
|
+
|
|
1068
|
+
## 🧪 Test Templates (MANDATORY)
|
|
1069
|
+
|
|
1070
|
+
**🚨 CRITICAL: You MUST generate .spec.ts file with comprehensive tests for EVERY component**
|
|
1071
|
+
|
|
1072
|
+
### Template 1: Simple Component with @Input/@Output
|
|
1073
|
+
|
|
1074
|
+
Use this template for components with basic inputs, outputs, and simple rendering logic.
|
|
1075
|
+
|
|
1076
|
+
```typescript
|
|
1077
|
+
import { Component, ViewChild } from '@angular/core';
|
|
1078
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
1079
|
+
|
|
1080
|
+
import { Crt{{ComponentName}}Component } from './{{component-name}}.component';
|
|
1081
|
+
|
|
1082
|
+
// Test host wrapper to test component as it will be used
|
|
1083
|
+
@Component({
|
|
1084
|
+
standalone: false,
|
|
1085
|
+
template: `
|
|
1086
|
+
<crt-{{component-name}}
|
|
1087
|
+
[propertyOne]="propertyOne"
|
|
1088
|
+
[propertyTwo]="propertyTwo"
|
|
1089
|
+
(eventName)="onEventName($event)"
|
|
1090
|
+
></crt-{{component-name}}>
|
|
1091
|
+
`,
|
|
1092
|
+
})
|
|
1093
|
+
class TestHostComponent {
|
|
1094
|
+
public propertyOne = /* default value */;
|
|
1095
|
+
public propertyTwo = /* default value */;
|
|
1096
|
+
public readonly eventNameSpy = jest.fn();
|
|
1097
|
+
|
|
1098
|
+
@ViewChild(Crt{{ComponentName}}Component)
|
|
1099
|
+
public readonly component: Crt{{ComponentName}}Component;
|
|
1100
|
+
|
|
1101
|
+
public onEventName(value: unknown): void {
|
|
1102
|
+
this.eventNameSpy(value);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
describe('Crt{{ComponentName}}Component', () => {
|
|
1107
|
+
let fixture: ComponentFixture<TestHostComponent>;
|
|
1108
|
+
let host: TestHostComponent;
|
|
1109
|
+
|
|
1110
|
+
function getNativeElement(): HTMLElement {
|
|
1111
|
+
const result = fixture.nativeElement.querySelector('crt-{{component-name}}') as HTMLElement | null;
|
|
1112
|
+
if (!result) {
|
|
1113
|
+
throw new Error('crt-{{component-name}} element not found');
|
|
1114
|
+
}
|
|
1115
|
+
return result;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
afterEach(() => {
|
|
1119
|
+
jest.restoreAllMocks();
|
|
1120
|
+
});
|
|
1121
|
+
|
|
1122
|
+
beforeEach(async () => {
|
|
1123
|
+
await TestBed.configureTestingModule({
|
|
1124
|
+
declarations: [Crt{{ComponentName}}Component, TestHostComponent],
|
|
1125
|
+
}).compileComponents();
|
|
1126
|
+
|
|
1127
|
+
fixture = TestBed.createComponent(TestHostComponent);
|
|
1128
|
+
host = fixture.componentInstance;
|
|
1129
|
+
fixture.detectChanges();
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
it('should create', () => {
|
|
1133
|
+
expect(host.component).toBeDefined();
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
// CRITICAL: Always test shadowRoot queries
|
|
1137
|
+
describe('rendering', () => {
|
|
1138
|
+
it('should render in shadow DOM', () => {
|
|
1139
|
+
const element = getNativeElement();
|
|
1140
|
+
expect(element.shadowRoot).not.toBeNull();
|
|
1141
|
+
});
|
|
1142
|
+
|
|
1143
|
+
it('should render expected elements', () => {
|
|
1144
|
+
const element = getNativeElement();
|
|
1145
|
+
const targetElement = element.shadowRoot?.querySelector('[data-testid="your-element"]');
|
|
1146
|
+
expect(targetElement).not.toBeNull();
|
|
1147
|
+
});
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
// Test each @Input property
|
|
1151
|
+
describe('propertyOne input', () => {
|
|
1152
|
+
it('should have default value', () => {
|
|
1153
|
+
expect(host.component.propertyOne).toBe(/* expected default */);
|
|
1154
|
+
});
|
|
1155
|
+
|
|
1156
|
+
it('should update when input changes', () => {
|
|
1157
|
+
host.propertyOne = /* new value */;
|
|
1158
|
+
fixture.detectChanges();
|
|
1159
|
+
|
|
1160
|
+
const element = getNativeElement();
|
|
1161
|
+
const targetElement = element.shadowRoot?.querySelector('[data-testid="target"]');
|
|
1162
|
+
expect(targetElement?.textContent).toContain(/* expected text */);
|
|
1163
|
+
});
|
|
1164
|
+
|
|
1165
|
+
it('should handle edge cases', () => {
|
|
1166
|
+
// Test: null, undefined, empty string, etc.
|
|
1167
|
+
host.propertyOne = null;
|
|
1168
|
+
fixture.detectChanges();
|
|
1169
|
+
// Assert expected behavior
|
|
1170
|
+
});
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
// Test each @Output event
|
|
1174
|
+
describe('eventName output', () => {
|
|
1175
|
+
it('should emit event when triggered', () => {
|
|
1176
|
+
const element = getNativeElement();
|
|
1177
|
+
const button = element.shadowRoot?.querySelector('button') as HTMLButtonElement | null;
|
|
1178
|
+
|
|
1179
|
+
button?.click();
|
|
1180
|
+
|
|
1181
|
+
expect(host.eventNameSpy).toHaveBeenCalledTimes(1);
|
|
1182
|
+
expect(host.eventNameSpy).toHaveBeenCalledWith(/* expected value */);
|
|
1183
|
+
});
|
|
1184
|
+
|
|
1185
|
+
it('should emit multiple times', () => {
|
|
1186
|
+
const element = getNativeElement();
|
|
1187
|
+
const input = element.shadowRoot?.querySelector('input') as HTMLInputElement | null;
|
|
1188
|
+
|
|
1189
|
+
input.value = 'First';
|
|
1190
|
+
input.dispatchEvent(new Event('input'));
|
|
1191
|
+
|
|
1192
|
+
input.value = 'Second';
|
|
1193
|
+
input.dispatchEvent(new Event('input'));
|
|
1194
|
+
|
|
1195
|
+
expect(host.eventNameSpy).toHaveBeenCalledTimes(2);
|
|
1196
|
+
expect(host.eventNameSpy).toHaveBeenNthCalledWith(1, 'First');
|
|
1197
|
+
expect(host.eventNameSpy).toHaveBeenNthCalledWith(2, 'Second');
|
|
1198
|
+
});
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
// Test input transformers if present
|
|
1202
|
+
describe('input transformers', () => {
|
|
1203
|
+
it('should transform input value', () => {
|
|
1204
|
+
host.propertyTwo = /* value that needs transformation */;
|
|
1205
|
+
fixture.detectChanges();
|
|
1206
|
+
|
|
1207
|
+
expect(host.component.propertyTwo).toBe(/* transformed value */);
|
|
1208
|
+
});
|
|
1209
|
+
});
|
|
1210
|
+
});
|
|
1211
|
+
```
|
|
1212
|
+
|
|
1213
|
+
### Template 2: Component with Async Operations
|
|
1214
|
+
|
|
1215
|
+
Use this template for components that fetch data, call APIs, or have async lifecycle methods.
|
|
1216
|
+
|
|
1217
|
+
```typescript
|
|
1218
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
1219
|
+
import { of, throwError } from 'rxjs';
|
|
1220
|
+
|
|
1221
|
+
import { Crt{{ComponentName}}Component } from './{{component-name}}.component';
|
|
1222
|
+
import { YourService } from './your.service';
|
|
1223
|
+
|
|
1224
|
+
describe('Crt{{ComponentName}}Component (Async)', () => {
|
|
1225
|
+
let component: Crt{{ComponentName}}Component;
|
|
1226
|
+
let fixture: ComponentFixture<Crt{{ComponentName}}Component>;
|
|
1227
|
+
let yourServiceMock: jest.Mocked<YourService>;
|
|
1228
|
+
|
|
1229
|
+
beforeEach(async () => {
|
|
1230
|
+
yourServiceMock = {
|
|
1231
|
+
fetchData: jest.fn(),
|
|
1232
|
+
updateData: jest.fn(),
|
|
1233
|
+
} as unknown as jest.Mocked<YourService>;
|
|
1234
|
+
|
|
1235
|
+
await TestBed.configureTestingModule({
|
|
1236
|
+
declarations: [Crt{{ComponentName}}Component],
|
|
1237
|
+
providers: [
|
|
1238
|
+
{ provide: YourService, useValue: yourServiceMock },
|
|
1239
|
+
],
|
|
1240
|
+
}).compileComponents();
|
|
1241
|
+
|
|
1242
|
+
fixture = TestBed.createComponent(Crt{{ComponentName}}Component);
|
|
1243
|
+
component = fixture.componentInstance;
|
|
1244
|
+
});
|
|
1245
|
+
|
|
1246
|
+
afterEach(() => {
|
|
1247
|
+
jest.restoreAllMocks();
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1250
|
+
describe('async data loading', () => {
|
|
1251
|
+
it('should load data on init', async () => {
|
|
1252
|
+
const mockData = { id: 1, name: 'Test' };
|
|
1253
|
+
yourServiceMock.fetchData.mockReturnValue(of(mockData));
|
|
1254
|
+
|
|
1255
|
+
fixture.detectChanges(); // Triggers ngOnInit
|
|
1256
|
+
await fixture.whenStable(); // Wait for async operations
|
|
1257
|
+
|
|
1258
|
+
expect(yourServiceMock.fetchData).toHaveBeenCalledTimes(1);
|
|
1259
|
+
expect(component.data).toEqual(mockData);
|
|
1260
|
+
});
|
|
1261
|
+
|
|
1262
|
+
it('should handle loading state', async () => {
|
|
1263
|
+
yourServiceMock.fetchData.mockReturnValue(of({}));
|
|
1264
|
+
|
|
1265
|
+
expect(component.isLoading).toBe(false);
|
|
1266
|
+
|
|
1267
|
+
fixture.detectChanges();
|
|
1268
|
+
expect(component.isLoading).toBe(true); // During fetch
|
|
1269
|
+
|
|
1270
|
+
await fixture.whenStable();
|
|
1271
|
+
expect(component.isLoading).toBe(false); // After fetch
|
|
1272
|
+
});
|
|
1273
|
+
|
|
1274
|
+
it('should handle errors gracefully', async () => {
|
|
1275
|
+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => void 0);
|
|
1276
|
+
yourServiceMock.fetchData.mockReturnValue(
|
|
1277
|
+
throwError(() => new Error('Network error'))
|
|
1278
|
+
);
|
|
1279
|
+
|
|
1280
|
+
fixture.detectChanges();
|
|
1281
|
+
await fixture.whenStable();
|
|
1282
|
+
|
|
1283
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
1284
|
+
expect.stringContaining('Network error')
|
|
1285
|
+
);
|
|
1286
|
+
expect(component.data).toBeNull(); // Or your error state
|
|
1287
|
+
});
|
|
1288
|
+
});
|
|
1289
|
+
|
|
1290
|
+
describe('async user interactions', () => {
|
|
1291
|
+
it('should handle async save operation', async () => {
|
|
1292
|
+
yourServiceMock.updateData.mockReturnValue(of({ success: true }));
|
|
1293
|
+
|
|
1294
|
+
await component.onSave();
|
|
1295
|
+
|
|
1296
|
+
expect(yourServiceMock.updateData).toHaveBeenCalledTimes(1);
|
|
1297
|
+
expect(component.isSaving).toBe(false);
|
|
1298
|
+
});
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
### Template 3: Component with Content Projection (slots)
|
|
1304
|
+
|
|
1305
|
+
```typescript
|
|
1306
|
+
import { Component } from '@angular/core';
|
|
1307
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
1308
|
+
|
|
1309
|
+
import { Crt{{ComponentName}}Component } from './{{component-name}}.component';
|
|
1310
|
+
|
|
1311
|
+
@Component({
|
|
1312
|
+
template: `
|
|
1313
|
+
<crt-{{component-name}}>
|
|
1314
|
+
<div slot="header">Header Content</div>
|
|
1315
|
+
<div slot="content">Main Content</div>
|
|
1316
|
+
<div slot="footer">Footer Content</div>
|
|
1317
|
+
</crt-{{component-name}}>
|
|
1318
|
+
`,
|
|
1319
|
+
})
|
|
1320
|
+
class TestHostWithSlotsComponent {}
|
|
1321
|
+
|
|
1322
|
+
describe('Crt{{ComponentName}}Component (Slots)', () => {
|
|
1323
|
+
let fixture: ComponentFixture<TestHostWithSlotsComponent>;
|
|
1324
|
+
|
|
1325
|
+
beforeEach(async () => {
|
|
1326
|
+
await TestBed.configureTestingModule({
|
|
1327
|
+
declarations: [Crt{{ComponentName}}Component, TestHostWithSlotsComponent],
|
|
1328
|
+
}).compileComponents();
|
|
1329
|
+
|
|
1330
|
+
fixture = TestBed.createComponent(TestHostWithSlotsComponent);
|
|
1331
|
+
fixture.detectChanges();
|
|
1332
|
+
});
|
|
1333
|
+
|
|
1334
|
+
it('should project header slot content', () => {
|
|
1335
|
+
const element = fixture.nativeElement.querySelector('crt-{{component-name}}');
|
|
1336
|
+
const headerSlot = element.shadowRoot?.querySelector('slot[name="header"]') as HTMLSlotElement | null;
|
|
1337
|
+
const assignedNodes = headerSlot?.assignedNodes() ?? [];
|
|
1338
|
+
|
|
1339
|
+
expect(assignedNodes.length).toBeGreaterThan(0);
|
|
1340
|
+
expect(assignedNodes[0].textContent).toContain('Header Content');
|
|
1341
|
+
});
|
|
1342
|
+
|
|
1343
|
+
it('should project content slot content', () => {
|
|
1344
|
+
const element = fixture.nativeElement.querySelector('crt-{{component-name}}');
|
|
1345
|
+
const contentSlot = element.shadowRoot?.querySelector('slot[name="content"]') as HTMLSlotElement | null;
|
|
1346
|
+
const assignedNodes = contentSlot?.assignedNodes() ?? [];
|
|
1347
|
+
|
|
1348
|
+
expect(assignedNodes.length).toBeGreaterThan(0);
|
|
1349
|
+
expect(assignedNodes[0].textContent).toContain('Main Content');
|
|
1350
|
+
});
|
|
1351
|
+
|
|
1352
|
+
it('should render default content when slot is empty', () => {
|
|
1353
|
+
// Create fixture without slot content
|
|
1354
|
+
const emptyFixture = TestBed.createComponent(Crt{{ComponentName}}Component);
|
|
1355
|
+
emptyFixture.detectChanges();
|
|
1356
|
+
|
|
1357
|
+
const element = emptyFixture.nativeElement;
|
|
1358
|
+
const defaultContent = element.shadowRoot?.querySelector('[data-testid="default-content"]');
|
|
1359
|
+
expect(defaultContent).not.toBeNull();
|
|
1360
|
+
});
|
|
1361
|
+
});
|
|
1362
|
+
```
|
|
1363
|
+
|
|
1364
|
+
### 🎯 Test Coverage Requirements
|
|
1365
|
+
|
|
1366
|
+
**MANDATORY test cases for ALL components:**
|
|
1367
|
+
|
|
1368
|
+
1. **Component Creation** ✅
|
|
1369
|
+
- `should create` test
|
|
1370
|
+
|
|
1371
|
+
2. **Shadow DOM** ✅ (CRITICAL for runtime components)
|
|
1372
|
+
- Verify `shadowRoot` exists
|
|
1373
|
+
- All queries MUST use `.shadowRoot?.querySelector()`
|
|
1374
|
+
- Never query directly on element without shadowRoot
|
|
1375
|
+
|
|
1376
|
+
3. **@Input Properties** ✅
|
|
1377
|
+
- Default values
|
|
1378
|
+
- Value changes reflect in template
|
|
1379
|
+
- Edge cases (null, undefined, empty)
|
|
1380
|
+
- Input transformers if present
|
|
1381
|
+
|
|
1382
|
+
4. **@Output Events** ✅
|
|
1383
|
+
- Events emit with correct values
|
|
1384
|
+
- Multiple emissions work correctly
|
|
1385
|
+
- Event handlers called
|
|
1386
|
+
|
|
1387
|
+
5. **Conditional Rendering** ✅
|
|
1388
|
+
- `@if` conditions work correctly
|
|
1389
|
+
- `@for` loops render correct number of items
|
|
1390
|
+
- Hidden elements not in DOM
|
|
1391
|
+
|
|
1392
|
+
6. **Async Operations** (if component has API calls)
|
|
1393
|
+
- Loading states
|
|
1394
|
+
- Success cases
|
|
1395
|
+
- Error handling
|
|
1396
|
+
- Use `await fixture.whenStable()`
|
|
1397
|
+
|
|
1398
|
+
7. **Slots/Content Projection** (if component has slots)
|
|
1399
|
+
- Slot content projected correctly
|
|
1400
|
+
- Default fallback content shown when slot empty
|
|
1401
|
+
- Use `slot.assignedNodes()`
|
|
1402
|
+
|
|
1403
|
+
### 🚨 Common Mistakes to AVOID
|
|
1404
|
+
|
|
1405
|
+
```typescript
|
|
1406
|
+
// ❌ WRONG: Querying without shadowRoot
|
|
1407
|
+
const button = fixture.nativeElement.querySelector('button');
|
|
1408
|
+
|
|
1409
|
+
// ✅ CORRECT: Query through shadowRoot
|
|
1410
|
+
const element = fixture.nativeElement.querySelector('crt-component');
|
|
1411
|
+
const button = element.shadowRoot?.querySelector('button');
|
|
1412
|
+
|
|
1413
|
+
// ❌ WRONG: Not waiting for async operations
|
|
1414
|
+
fixture.detectChanges();
|
|
1415
|
+
expect(component.data).toBeDefined(); // May fail!
|
|
1416
|
+
|
|
1417
|
+
// ✅ CORRECT: Wait for async
|
|
1418
|
+
fixture.detectChanges();
|
|
1419
|
+
await fixture.whenStable();
|
|
1420
|
+
expect(component.data).toBeDefined();
|
|
1421
|
+
|
|
1422
|
+
// ❌ WRONG: Not testing edge cases
|
|
1423
|
+
it('should display text', () => {
|
|
1424
|
+
component.text = 'Hello';
|
|
1425
|
+
expect(component.text).toBe('Hello');
|
|
1426
|
+
});
|
|
1427
|
+
|
|
1428
|
+
// ✅ CORRECT: Test edge cases
|
|
1429
|
+
it('should handle null text', () => {
|
|
1430
|
+
component.text = null;
|
|
1431
|
+
expect(component.text).toBe(''); // or default value
|
|
1432
|
+
});
|
|
1433
|
+
|
|
1434
|
+
it('should handle empty string', () => {
|
|
1435
|
+
component.text = '';
|
|
1436
|
+
expect(component.text).toBe(''); // or default value
|
|
1437
|
+
});
|
|
1438
|
+
```
|
|
1439
|
+
|
|
1440
|
+
### 📝 Test File Naming Convention
|
|
1441
|
+
|
|
1442
|
+
- Runtime component: `{{component-name}}.component.spec.ts`
|
|
1443
|
+
- Example: `custom-input.component.spec.ts`
|
|
1444
|
+
- Location: Same directory as component file
|
|
1445
|
+
|
|
1446
|
+
---
|
|
1447
|
+
|
|
1448
|
+
## 📚 Quick Reference: Common Patterns
|
|
1449
|
+
|
|
1450
|
+
### Pattern 1: Input with Default Value
|
|
1451
|
+
```typescript
|
|
1452
|
+
@Input()
|
|
1453
|
+
@CrtInput()
|
|
1454
|
+
public myProperty = 'default value';
|
|
1455
|
+
```
|
|
1456
|
+
|
|
1457
|
+
### Pattern 2: Input with Transformer
|
|
1458
|
+
```typescript
|
|
1459
|
+
@Input({ transform: (v: string) => v?.trim() || 'default' })
|
|
1460
|
+
@CrtInput()
|
|
1461
|
+
public text: string = 'default';
|
|
1462
|
+
```
|
|
1463
|
+
|
|
1464
|
+
### Pattern 3: Output Event
|
|
1465
|
+
```typescript
|
|
1466
|
+
@Output()
|
|
1467
|
+
@CrtOutput()
|
|
1468
|
+
public readonly myEvent = new EventEmitter<MyType>();
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
### Pattern 4: Conditional Rendering (Angular 17+)
|
|
1472
|
+
```typescript
|
|
1473
|
+
@if (condition) {
|
|
1474
|
+
<div>Content</div>
|
|
1475
|
+
}
|
|
1476
|
+
```
|
|
1477
|
+
|
|
1478
|
+
### Pattern 5: List Iteration
|
|
1479
|
+
```typescript
|
|
1480
|
+
@for (item of items; track item.id) {
|
|
1481
|
+
<div>{{ item.name }}</div>
|
|
1482
|
+
}
|
|
1483
|
+
```
|
|
1484
|
+
|
|
1485
|
+
### Pattern 6: Inline Styles in Component
|
|
1486
|
+
```typescript
|
|
1487
|
+
@Component({
|
|
1488
|
+
styles: [`
|
|
1489
|
+
:host {
|
|
1490
|
+
display: block;
|
|
1491
|
+
}
|
|
1492
|
+
.my-class {
|
|
1493
|
+
color: red;
|
|
1494
|
+
}
|
|
1495
|
+
`],
|
|
1496
|
+
})
|
|
1497
|
+
```
|
|
1498
|
+
|
|
1499
|
+
### Pattern 7: Inline Template in Component
|
|
1500
|
+
```typescript
|
|
1501
|
+
@Component({
|
|
1502
|
+
template: `
|
|
1503
|
+
<div class="wrapper">
|
|
1504
|
+
<h1>{{ title }}</h1>
|
|
1505
|
+
</div>
|
|
1506
|
+
`,
|
|
1507
|
+
})
|
|
1508
|
+
```
|
|
1509
|
+
|
|
1510
|
+
---
|
|
1511
|
+
|
|
1512
|
+
## 🗂️ Collection Input — Runtime Components
|
|
1513
|
+
|
|
1514
|
+
When a Creatio page binds a ViewModel collection to a component `@Input`, each item is a `ViewModelContext` — property access returns a **Promise**. Use `await item[col]` to read values.
|
|
1515
|
+
|
|
1516
|
+
### @Input declarations
|
|
1517
|
+
|
|
1518
|
+
```typescript
|
|
1519
|
+
import { ViewModelCollection, ViewModelContext } from '@creatio-devkit/common';
|
|
1520
|
+
|
|
1521
|
+
@Input() @CrtInput() public set items(value: ViewModelCollection<ViewModelContext>) { ... }
|
|
1522
|
+
|
|
1523
|
+
// columns is written by panel as string[] constant
|
|
1524
|
+
@Input() @CrtInput() public set columns(value: string[]) { ... }
|
|
1525
|
+
```
|
|
1526
|
+
|
|
1527
|
+
### Resolving row values — use signals + Promise.all
|
|
1528
|
+
|
|
1529
|
+
```typescript
|
|
1530
|
+
export class {{COMPONENT_NAME_PASCAL}}Component {
|
|
1531
|
+
private _itemsCollection: ViewModelCollection<ViewModelContext> | null = null;
|
|
1532
|
+
protected readonly columnsToDisplay = signal<string[]>([]);
|
|
1533
|
+
protected readonly itemsToDisplay = signal<Record<string, string>[]>([]);
|
|
1534
|
+
|
|
1535
|
+
@Input() @CrtInput()
|
|
1536
|
+
public set items(value: ViewModelCollection<ViewModelContext>) {
|
|
1537
|
+
if (!value) return;
|
|
1538
|
+
this._itemsCollection = value;
|
|
1539
|
+
this._updateItemsToDisplay(value);
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
@Input() @CrtInput()
|
|
1543
|
+
public set columns(value: string[]) {
|
|
1544
|
+
// Deduplicate and trim
|
|
1545
|
+
this.columnsToDisplay.set(Array.from(new Set(value.map((c) => c.trim()).filter(Boolean))));
|
|
1546
|
+
if (this._itemsCollection) this._updateItemsToDisplay(this._itemsCollection);
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
private async _updateItemsToDisplay(value: ViewModelCollection<ViewModelContext>): Promise<void> {
|
|
1550
|
+
const columns = this.columnsToDisplay();
|
|
1551
|
+
if (!columns.length) { this.itemsToDisplay.set([]); return; }
|
|
1552
|
+
|
|
1553
|
+
const items = await Promise.all(
|
|
1554
|
+
value.map(async (item) => {
|
|
1555
|
+
const entries = await Promise.all(
|
|
1556
|
+
columns.map(async (col) => {
|
|
1557
|
+
const raw = await item[col];
|
|
1558
|
+
return [col, raw == null ? '' : String(raw)] as const;
|
|
1559
|
+
}),
|
|
1560
|
+
);
|
|
1561
|
+
return Object.fromEntries(entries);
|
|
1562
|
+
}),
|
|
1563
|
+
);
|
|
1564
|
+
this.itemsToDisplay.set(items);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
```
|
|
1568
|
+
|