tiun 0.0.2.1 → 0.1.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.
- checksums.yaml +4 -4
- data/.forgejo/workflows/codeberg-tests.yml +226 -0
- data/.gitignore +7 -3
- data/.prettierrc.json +5 -0
- data/.rubocop.yml +221 -0
- data/AGENTS.md +132 -0
- data/Appraisals +18 -0
- data/CONTRIBUTING.md +80 -0
- data/CONTRIBUTING.ru.md +326 -0
- data/Gemfile +20 -1
- data/README.md +52 -23
- data/README.ru.md +72 -0
- data/Rakefile +10 -4
- data/TODO +2 -6
- data/bin/console +4 -3
- data/config/cucumber.yml +1 -0
- data/cucumber.mjs +6 -0
- data/docs/backend.md +73 -0
- data/docs/backend.ru.md +73 -0
- data/docs/components/approved.md +39 -0
- data/docs/components/approved.ru.md +39 -0
- data/docs/components/attachment-field.md +7 -0
- data/docs/components/attachment-field.ru.md +8 -0
- data/docs/components/attachment.md +48 -0
- data/docs/components/attachment.ru.md +48 -0
- data/docs/components/avatar.md +39 -0
- data/docs/components/avatar.ru.md +37 -0
- data/docs/components/chip.md +119 -0
- data/docs/components/chip.ru.md +99 -0
- data/docs/components/configuration.md +137 -0
- data/docs/components/configuration.ru.md +138 -0
- data/docs/components/daylight.md +41 -0
- data/docs/components/daylight.ru.md +41 -0
- data/docs/components/defaults.md +148 -0
- data/docs/components/defaults.ru.md +149 -0
- data/docs/components/documents.md +64 -0
- data/docs/components/documents.ru.md +64 -0
- data/docs/components/external-form-fields.ru.md +137 -0
- data/docs/components/external-renderers.md +50 -0
- data/docs/components/external-renderers.ru.md +51 -0
- data/docs/components/feedback.md +76 -0
- data/docs/components/feedback.ru.md +76 -0
- data/docs/components/footer.md +49 -0
- data/docs/components/footer.ru.md +49 -0
- data/docs/components/forms.md +177 -0
- data/docs/components/forms.ru.md +177 -0
- data/docs/components/images.md +111 -0
- data/docs/components/images.ru.md +111 -0
- data/docs/components/index.md +140 -0
- data/docs/components/index.ru.md +140 -0
- data/docs/components/intro.md +150 -0
- data/docs/components/intro.ru.md +150 -0
- data/docs/components/login.md +600 -0
- data/docs/components/login.ru.md +602 -0
- data/docs/components/methods.md +59 -0
- data/docs/components/methods.ru.md +59 -0
- data/docs/components/player.md +72 -0
- data/docs/components/player.ru.md +69 -0
- data/docs/components/profile.md +82 -0
- data/docs/components/profile.ru.md +82 -0
- data/docs/components/record-manager.md +69 -0
- data/docs/components/record-manager.ru.md +69 -0
- data/docs/components/row-column.ru.md +51 -0
- data/docs/components/rtfer.md +76 -0
- data/docs/components/rtfer.ru.md +76 -0
- data/docs/components/schema-calendar.md +86 -0
- data/docs/components/schema-calendar.ru.md +84 -0
- data/docs/components/schema-records.md +166 -0
- data/docs/components/schema-records.ru.md +166 -0
- data/docs/components/signup.md +194 -0
- data/docs/components/signup.ru.md +194 -0
- data/docs/components/slug-flow.md +97 -0
- data/docs/components/slug-flow.ru.md +59 -0
- data/docs/components/stockee.md +21 -0
- data/docs/components/stockee.ru.md +21 -0
- data/docs/components/text-views.md +64 -0
- data/docs/components/text-views.ru.md +57 -0
- data/docs/components/theme.md +212 -0
- data/docs/components/theme.ru.md +212 -0
- data/docs/components/tooltip.md +37 -0
- data/docs/components/tooltip.ru.md +30 -0
- data/docs/components/validation.md +153 -0
- data/docs/components/validation.ru.md +154 -0
- data/docs/components.md +31 -0
- data/docs/components.ru.md +31 -0
- data/docs/controller-names.md +23 -0
- data/docs/controller-names.ru.md +23 -0
- data/docs/examples/dneslov-frontend.md +38 -0
- data/docs/examples/dneslov-frontend.ru.md +39 -0
- data/docs/examples/dneslov-frontend.yaml +266 -0
- data/docs/frontend.md +316 -0
- data/docs/frontend.ru.md +332 -0
- data/docs/migrations/component-configuration.md +48 -0
- data/docs/migrations/component-configuration.ru.md +40 -0
- data/docs/migrations/component-shell-proposal.md +108 -0
- data/docs/migrations/component-shell-proposal.ru.md +150 -0
- data/docs/migrations/theme-layout.md +83 -0
- data/docs/migrations/theme-layout.ru.md +97 -0
- data/docs/reference.md +45 -0
- data/docs/reference.ru.md +1763 -0
- data/docs/resources.md +348 -0
- data/docs/resources.ru.md +349 -0
- data/docs/tasks/DNE-542.md +11 -0
- data/docs/tasks/DNE-566.md +8 -0
- data/docs/tasks/chip-segments.md +54 -0
- data/docs/tasks/configured-profile.md +73 -0
- data/docs/tasks/frontend/auth-form.md +7 -0
- data/docs/tasks/frontend/avatar.md +5 -0
- data/docs/tasks/frontend/component-removal.md +11 -0
- data/docs/tasks/frontend/dynamic-field.md +6 -0
- data/docs/tasks/frontend/field-caption.md +38 -0
- data/docs/tasks/frontend/form-core.md +65 -0
- data/docs/tasks/frontend/form-field-context.md +16 -0
- data/docs/tasks/frontend/form-session-renewal.md +58 -0
- data/docs/tasks/frontend/frontend-components.md +7 -0
- data/docs/tasks/frontend/frontend-docs.md +6 -0
- data/docs/tasks/frontend/frontend-layout.md +13 -0
- data/docs/tasks/frontend/frontend-methods.md +15 -0
- data/docs/tasks/frontend/frontend-other.md +13 -0
- data/docs/tasks/frontend/frontend-services.md +7 -0
- data/docs/tasks/frontend/fusion.md +22 -0
- data/docs/tasks/frontend/heading-core.md +5 -0
- data/docs/tasks/frontend/i18n-scope.md +37 -0
- data/docs/tasks/frontend/index-runtime.md +48 -0
- data/docs/tasks/frontend/inline-form.md +7 -0
- data/docs/tasks/frontend/intro-core.md +11 -0
- data/docs/tasks/frontend/login.md +8 -0
- data/docs/tasks/frontend/menu-branch.md +5 -0
- data/docs/tasks/frontend/paginator.md +7 -0
- data/docs/tasks/frontend/records-core.md +35 -0
- data/docs/tasks/frontend/resource-source-core.md +12 -0
- data/docs/tasks/frontend/signup.md +8 -0
- data/docs/tasks/frontend/span-body.md +16 -0
- data/docs/tasks/frontend/text-commonee.md +48 -0
- data/docs/tasks/frontend/theme-field.md +31 -0
- data/docs/tasks/frontend/theme-menu.md +8 -0
- data/docs/tasks/frontend/theme-settings.md +10 -0
- data/docs/tasks/frontend/view-content-core.md +12 -0
- data/docs/tasks/frontend/view-source-core.md +12 -0
- data/docs/tasks/ruby-extension-compatibility.ru.md +74 -0
- data/docs/tasks/todo-code-climate.md +8 -0
- data/docs/tasks/todo-compatibility.md +50 -0
- data/docs/tasks/todo-reek.md +5 -0
- data/docs/tasks/todo-yard-inch.md +7 -0
- data/eslint.config.mjs +15 -0
- data/exe/tiun +1 -0
- data/gemfiles/rails_7_0.gemfile +16 -0
- data/gemfiles/rails_7_2.gemfile +17 -0
- data/lib/config/locale/browser.en.yml +43 -0
- data/lib/config/locale/browser.ru.yml +35 -0
- data/lib/config/locale/confirmation.en.yml +16 -0
- data/lib/config/locale/confirmation.ru.yml +16 -0
- data/lib/config/locale/errors.en.yml +57 -0
- data/lib/config/locale/errors.ru.yml +47 -0
- data/lib/config/locale/form_delay.en.yml +11 -0
- data/lib/config/locale/form_delay.ru.yml +11 -0
- data/lib/config/locale/recovery.en.yml +14 -0
- data/lib/config/locale/ru.yml +272 -6
- data/lib/config/routes.rb +5 -11
- data/lib/tasks/tiun/translations.rake +12 -0
- data/lib/tiun/actor/validate.rb +3 -2
- data/lib/tiun/actor.rb +13 -10
- data/lib/tiun/api_not_found.rb +16 -0
- data/lib/tiun/attributes.rb +8 -7
- data/lib/tiun/auth/attribute_models.rb +32 -0
- data/lib/tiun/auth/controller/discord.rb +26 -0
- data/lib/tiun/auth/controller/facebook.rb +62 -0
- data/lib/tiun/auth/controller/github.rb +37 -0
- data/lib/tiun/auth/controller/kakao.rb +33 -0
- data/lib/tiun/auth/controller/oauth.rb +167 -0
- data/lib/tiun/auth/controller/ok.rb +8 -0
- data/lib/tiun/auth/controller/telegram.rb +188 -0
- data/lib/tiun/auth/controller/vk.rb +85 -0
- data/lib/tiun/auth/controller/wechat.rb +58 -0
- data/lib/tiun/auth/controller/weibo.rb +28 -0
- data/lib/tiun/auth/controller.rb +467 -150
- data/lib/tiun/auth/json_session.rb +19 -0
- data/lib/tiun/auth/token_identity.rb +37 -0
- data/lib/tiun/auth/user_identity.rb +27 -0
- data/lib/tiun/auth/views/oauth_address.html.erb +23 -0
- data/lib/tiun/auth.rb +184 -45
- data/lib/tiun/carrier_wave_store.rb +59 -0
- data/lib/tiun/cli.rb +52 -32
- data/lib/tiun/concern/resources.rb +85 -0
- data/lib/tiun/config_source.rb +52 -0
- data/lib/tiun/content_range.rb +123 -0
- data/lib/tiun/context/merge.rb +117 -0
- data/lib/tiun/context.rb +39 -0
- data/lib/tiun/controller/auth/identity.rb +201 -0
- data/lib/tiun/controller/auth/registration.rb +23 -0
- data/lib/tiun/controller/auth.rb +198 -0
- data/lib/tiun/controller/auto.rb.erb +10 -0
- data/lib/tiun/controller/base/actions.rb +156 -0
- data/lib/tiun/controller/base/assignment.rb +101 -0
- data/lib/tiun/controller/base/parameters.rb +198 -0
- data/lib/tiun/controller/base/params.rb +166 -0
- data/lib/tiun/controller/base/records.rb +107 -0
- data/lib/tiun/controller/base/representation.rb +97 -0
- data/lib/tiun/controller/base/scopes.rb +132 -0
- data/lib/tiun/controller/base.rb +52 -0
- data/lib/tiun/controller/component_assets.rb +96 -0
- data/lib/tiun/controller/meta.rb +248 -0
- data/lib/tiun/controller/translations.rb +22 -0
- data/lib/tiun/controller.rb +13 -0
- data/lib/tiun/core/boot.rb +210 -0
- data/lib/tiun/core/contexts.rb +53 -0
- data/lib/tiun/core/controller_contexts.rb +42 -0
- data/lib/tiun/core/defaults.rb +215 -0
- data/lib/tiun/core/evaluation.rb +105 -0
- data/lib/tiun/core/field_attributes.rb +78 -0
- data/lib/tiun/core/files.rb +153 -0
- data/lib/tiun/core/generation.rb +234 -0
- data/lib/tiun/core/methods.rb +104 -0
- data/lib/tiun/core/names.rb +140 -0
- data/lib/tiun/core/registry.rb +97 -0
- data/lib/tiun/core/reloading.rb +77 -0
- data/lib/tiun/core/resources.rb +308 -0
- data/lib/tiun/core/routing/forward.rb +206 -0
- data/lib/tiun/core/routing.rb +323 -0
- data/lib/tiun/core/types.rb +88 -0
- data/lib/tiun/core.rb +26 -0
- data/lib/tiun/core_helper.rb +85 -13
- data/lib/tiun/engine.rb +64 -20
- data/lib/tiun/error_handling.rb +121 -0
- data/lib/tiun/hooks.rb +131 -0
- data/lib/tiun/mailer/confirmation.rb +37 -0
- data/lib/tiun/mailer/recovery.rb +16 -0
- data/lib/tiun/migration.rb +72 -50
- data/lib/tiun/mixins.rb +128 -19
- data/lib/tiun/model/account/identity.rb +93 -0
- data/lib/tiun/model/account.rb +180 -7
- data/lib/tiun/model/auth/bcrypt.rb +47 -0
- data/lib/tiun/model/auth.rb +162 -36
- data/lib/tiun/model/auto.rb.erb +12 -0
- data/lib/tiun/model/me.rb +133 -0
- data/lib/tiun/model/settings.rb +186 -0
- data/lib/tiun/model/token/recovery.rb +48 -0
- data/lib/tiun/model/token.rb +37 -3
- data/lib/tiun/model.rb +82 -69
- data/lib/tiun/notification/service.rb +18 -0
- data/lib/tiun/notification.rb +6 -0
- data/lib/tiun/policy/default.rb +7 -0
- data/lib/tiun/policy.rb +84 -8
- data/lib/tiun/proceed/allowed_errors.rb +217 -0
- data/lib/tiun/proceed/auth.rb +50 -0
- data/lib/tiun/proceed/description.rb +89 -0
- data/lib/tiun/proceed/enums.rb +225 -0
- data/lib/tiun/proceed/hooks.rb +51 -0
- data/lib/tiun/proceed/pass_over_paths.rb +40 -0
- data/lib/tiun/proceed/policy.rb +172 -0
- data/lib/tiun/proceed/registration.rb +69 -0
- data/lib/tiun/proceed/schemas/component_nodes.rb +436 -0
- data/lib/tiun/proceed/schemas/constants.rb +116 -0
- data/lib/tiun/proceed/schemas/content.rb +68 -0
- data/lib/tiun/proceed/schemas/definitions.rb +181 -0
- data/lib/tiun/proceed/schemas/dictionary.rb +144 -0
- data/lib/tiun/proceed/schemas/fields.rb +182 -0
- data/lib/tiun/proceed/schemas/models.rb +50 -0
- data/lib/tiun/proceed/schemas/spans.rb +86 -0
- data/lib/tiun/proceed/schemas/values.rb +94 -0
- data/lib/tiun/proceed/schemas/view_paths.rb +86 -0
- data/lib/tiun/proceed/schemas/view_readiness.rb +51 -0
- data/lib/tiun/proceed/schemas/views.rb +192 -0
- data/lib/tiun/proceed/schemas.rb +137 -0
- data/lib/tiun/proceed/services.rb +79 -0
- data/lib/tiun/proceed/token_lifetimes.rb +49 -0
- data/lib/tiun/proceed/translations.rb +45 -0
- data/lib/tiun/proceed/versions.rb +315 -0
- data/lib/tiun/proceed.rb +23 -0
- data/lib/tiun/router.rb +40 -0
- data/lib/tiun/routes/mounts.rb +277 -0
- data/lib/tiun/routes.rb +150 -0
- data/lib/tiun/service/auto.rb.erb +5 -0
- data/lib/tiun/service/email_confirmation.rb +36 -0
- data/lib/tiun/service/job.rb +16 -0
- data/lib/tiun/service.rb +82 -0
- data/lib/tiun/services/translation.rb +297 -0
- data/lib/tiun/themes.rb +98 -0
- data/lib/tiun/translations/database.rb +72 -0
- data/lib/tiun/translations.rb +279 -0
- data/lib/tiun/version.rb +3 -3
- data/lib/tiun.rb +79 -486
- data/package-lock.json +4836 -0
- data/package.json +103 -0
- data/scripts/build-application.mjs +39 -0
- data/scripts/build-css.mjs +21 -0
- data/scripts/ci-badges.mjs +54 -0
- data/scripts/ci-badges.test.mjs +46 -0
- data/scripts/ci-coverage.mjs +26 -0
- data/scripts/ci-quality.mjs +80 -0
- data/scripts/ci-quality.sh +21 -0
- data/scripts/ci-quality.test.mjs +59 -0
- data/scripts/clean.mjs +3 -0
- data/scripts/publish-ci-badges.sh +45 -0
- data/src/auth/configuration.ts +50 -0
- data/src/browser/contracts.js +7 -0
- data/src/browser/mount.d.ts +26 -0
- data/src/browser/mount.jsx +1 -0
- data/src/browser/styles.js +17 -0
- data/src/browser/tiun.scss +23 -0
- data/src/browser/tiun.ts +1 -0
- data/src/calendar/configuration.ts +98 -0
- data/src/components/Avatar.tsx +45 -0
- data/src/components/Calendar.tsx +441 -0
- data/src/components/CatchWrapper.tsx +55 -0
- data/src/components/Chip.tsx +267 -0
- data/src/components/Column.tsx +13 -0
- data/src/components/Component.tsx +1039 -0
- data/src/components/Enum.tsx +142 -0
- data/src/components/Figure.tsx +11 -0
- data/src/components/FlexText.tsx +101 -0
- data/src/components/Footer.tsx +13 -0
- data/src/components/Grid.tsx +36 -0
- data/src/components/Heading.tsx +64 -0
- data/src/components/Image.tsx +168 -0
- data/src/components/Index.tsx +391 -0
- data/src/components/Intro.tsx +536 -0
- data/src/components/Loader.tsx +116 -0
- data/src/components/Lorem.tsx +379 -0
- data/src/components/Markdown.d.ts +17 -0
- data/src/components/Markdown.jsx +118 -0
- data/src/components/Menu.tsx +50 -0
- data/src/components/Modal.tsx +143 -0
- data/src/components/Paginator.tsx +265 -0
- data/src/components/Player.tsx +269 -0
- data/src/components/Records.tsx +1063 -0
- data/src/components/Row.tsx +193 -0
- data/src/components/Span.tsx +122 -0
- data/src/components/Step.tsx +19 -0
- data/src/components/Stockee.tsx +50 -0
- data/src/components/Toast.tsx +125 -0
- data/src/components/Tooltip.tsx +214 -0
- data/src/components/View.tsx +278 -0
- data/src/components/_palette.scss +26 -0
- data/src/components/calendar-browser.scss +133 -0
- data/src/components/calendar.scss +217 -0
- data/src/components/chip-browser.scss +270 -0
- data/src/components/chips.scss +95 -0
- data/src/components/column.scss +4 -0
- data/src/components/dashboard-browser.scss +81 -0
- data/src/components/dashboard.scss +117 -0
- data/src/components/description-browser.scss +112 -0
- data/src/components/document.scss +43 -0
- data/src/components/enum-browser.scss +33 -0
- data/src/components/enums.scss +56 -0
- data/src/components/footer.scss +51 -0
- data/src/components/form/ActionButton.tsx +66 -0
- data/src/components/form/Attachment.tsx +200 -0
- data/src/components/form/Block.tsx +55 -0
- data/src/components/form/BooleanBox.tsx +58 -0
- data/src/components/form/Collection.tsx +89 -0
- data/src/components/form/DynamicInput.tsx +806 -0
- data/src/components/form/ErrorSpan.tsx +17 -0
- data/src/components/form/ExternalField.tsx +554 -0
- data/src/components/form/FieldCaption.tsx +35 -0
- data/src/components/form/Form.tsx +407 -0
- data/src/components/form/HiddenField.tsx +10 -0
- data/src/components/form/JsonEditor.tsx +443 -0
- data/src/components/form/Login.tsx +381 -0
- data/src/components/form/NumberField.tsx +75 -0
- data/src/components/form/Pressee.tsx +101 -0
- data/src/components/form/RtferField.tsx +94 -0
- data/src/components/form/SelectField.tsx +73 -0
- data/src/components/form/SlugFlow.tsx +296 -0
- data/src/components/form/TextArea.tsx +5 -0
- data/src/components/form/TextField.tsx +6 -0
- data/src/components/form/Wye.tsx +67 -0
- data/src/components/form/auth.scss +366 -0
- data/src/components/form/changes.ts +239 -0
- data/src/components/form/context.ts +31 -0
- data/src/components/form/createForm.tsx +109 -0
- data/src/components/form/dynamic-field.scss +20 -0
- data/src/components/form/dynamicMatching.ts +44 -0
- data/src/components/form/form-browser.scss +106 -0
- data/src/components/form/forms.scss +1570 -0
- data/src/components/form/formsLib.ts +76 -0
- data/src/components/form/identity.ts +10 -0
- data/src/components/form/input.scss +37 -0
- data/src/components/form/layout.ts +72 -0
- data/src/components/form/login-browser.scss +30 -0
- data/src/components/form/render.tsx +94 -0
- data/src/components/form/resourceFields.ts +87 -0
- data/src/components/form/types.ts +214 -0
- data/src/components/form/values.ts +266 -0
- data/src/components/image.scss +67 -0
- data/src/components/intro-browser.scss +106 -0
- data/src/components/intro.scss +158 -0
- data/src/components/loader.scss +86 -0
- data/src/components/menu.scss +24 -0
- data/src/components/player.scss +48 -0
- data/src/components/records-browser.scss +62 -0
- data/src/components/records.scss +181 -0
- data/src/components/row.scss +31 -0
- data/src/components/stockee.scss +26 -0
- data/src/components/theme-palettes/compat.scss +15 -0
- data/src/components/theme-palettes/dark.scss +237 -0
- data/src/components/theme-palettes/light.scss +21 -0
- data/src/components/theme.scss +34 -0
- data/src/components/tiun_core.scss +9 -0
- data/src/components/toast.scss +63 -0
- data/src/components/tooltip.scss +22 -0
- data/src/components/view-browser.scss +321 -0
- data/src/components/view-controls.scss +385 -0
- data/src/concern/application.ts +56 -0
- data/src/concern/calendarViewProps.ts +28 -0
- data/src/concern/chipViewProps.ts +60 -0
- data/src/concern/documentHead.ts +66 -0
- data/src/concern/i18n.ts +70 -0
- data/src/concern/resourceRequest.ts +25 -0
- data/src/concern/schemaText.ts +6 -0
- data/src/concern/slugFlowProps.ts +76 -0
- data/src/concern/spanOptions.ts +37 -0
- data/src/concern/spansViewProps.tsx +103 -0
- data/src/concern/useFormAccess.ts +324 -0
- data/src/concern/useRecordsResource.ts +60 -0
- data/src/config/application.ts +57 -0
- data/src/config/componentDefaults.ts +106 -0
- data/src/config/components.ts +436 -0
- data/src/config/names.ts +72 -0
- data/src/config/records.ts +34 -0
- data/src/decorators/buttonBehaviours.tsx +46 -0
- data/src/decorators/configuration.ts +104 -0
- data/src/decorators/validation.ts +52 -0
- data/src/decorators/withAppearance.tsx +45 -0
- data/src/decorators/withCaption.tsx +21 -0
- data/src/decorators/withChildren.tsx +31 -0
- data/src/decorators/withClose.scss +37 -0
- data/src/decorators/withClose.tsx +44 -0
- data/src/decorators/withColumn.tsx +111 -0
- data/src/decorators/withDiscordAuth.tsx +4 -0
- data/src/decorators/withExternalAuth.tsx +50 -0
- data/src/decorators/withFacebookAuth.tsx +4 -0
- data/src/decorators/withField.tsx +91 -0
- data/src/decorators/withForm.tsx +365 -0
- data/src/decorators/withGithubAuth.tsx +4 -0
- data/src/decorators/withKakaoAuth.tsx +4 -0
- data/src/decorators/withMenuBranch.scss +45 -0
- data/src/decorators/withMenuBranch.tsx +109 -0
- data/src/decorators/withOkAuth.tsx +4 -0
- data/src/decorators/withPlayerList.tsx +77 -0
- data/src/decorators/withQuickLinkMark.ts +57 -0
- data/src/decorators/withRecordForm.tsx +561 -0
- data/src/decorators/withRequestActivity.scss +7 -0
- data/src/decorators/withRequestActivity.tsx +21 -0
- data/src/decorators/withRouter.tsx +395 -0
- data/src/decorators/withRouterLink.tsx +54 -0
- data/src/decorators/withTelegramAuth.tsx +4 -0
- data/src/decorators/withTextControl.tsx +194 -0
- data/src/decorators/withUnique.scss +39 -0
- data/src/decorators/withUnique.tsx +172 -0
- data/src/decorators/withUnsavedChanges.scss +39 -0
- data/src/decorators/withUnsavedChanges.tsx +312 -0
- data/src/decorators/withValidation.ts +38 -0
- data/src/decorators/withVkAuth.tsx +4 -0
- data/src/decorators/withWechatAuth.tsx +4 -0
- data/src/decorators/withWeiboAuth.tsx +4 -0
- data/src/intro/config.ts +72 -0
- data/src/intro/position.ts +70 -0
- data/src/layout/units.ts +21 -0
- data/src/records/types.ts +67 -0
- data/src/routing/nativePaths.ts +16 -0
- data/src/routing/routes.ts +337 -0
- data/src/schema/Schema.ts +2034 -0
- data/src/schema/dates.ts +17 -0
- data/src/schema.ts +274 -0
- data/src/services/Meta.ts +64 -0
- data/src/services/Resource.ts +480 -0
- data/src/services/Stock.ts +156 -0
- data/src/services/browser/requestActivity.d.ts +7 -0
- data/src/services/browser/requestActivity.js +119 -0
- data/src/services/browser/slugColor.js +13 -0
- data/src/services/calendar/clock.ts +169 -0
- data/src/services/calendar/dates.ts +127 -0
- data/src/services/calendar/daylight.ts +301 -0
- data/src/services/calendar/useCalendarDaylight.ts +76 -0
- data/src/services/calendar/utcTimeSource.ts +41 -0
- data/src/services/enumLookup.ts +96 -0
- data/src/services/form/blankCondition.ts +61 -0
- data/src/services/form/hoardValidation.ts +84 -0
- data/src/services/i18n/I18n.ts +227 -0
- data/src/services/i18n/messages.ts +185 -0
- data/src/services/load.ts +60 -0
- data/src/services/methods/aboutData.d.ts +9 -0
- data/src/services/methods/aboutData.js +32 -0
- data/src/services/methods/calendarChoices.d.ts +1 -0
- data/src/services/methods/calendarChoices.js +9 -0
- data/src/services/methods/eventDates.ts +96 -0
- data/src/services/methods/forms.ts +22 -0
- data/src/services/methods/mount.jsx +34 -0
- data/src/services/methods/paschal.ts +45 -0
- data/src/services/methods/prepared.ts +193 -0
- data/src/services/methods/query.ts +30 -0
- data/src/services/methods/registry.ts +22 -0
- data/src/services/methods/resolveReadResource.ts +57 -0
- data/src/services/methods.ts +156 -0
- data/src/services/records/range.ts +39 -0
- data/src/services/records/resource.ts +90 -0
- data/src/services/records/useRecordPages.ts +266 -0
- data/src/services/session/renewal.ts +394 -0
- data/src/services/textLink.ts +11 -0
- data/src/services/timer.ts +25 -0
- data/src/services/useAppearance.ts +496 -0
- data/src/services/useSwitch.ts +146 -0
- data/src/theme/cache.ts +88 -0
- data/src/theme/configuration.ts +261 -0
- data/src/theme/context.ts +48 -0
- data/src/theme/resource.ts +106 -0
- data/tiun.gemspec +53 -45
- data/tools/rubocop/compact_block_braces.rb +39 -0
- data/tools/rubocop/i18n_decorators.rb +15 -0
- data/tools/rubocop/spacing.rb +96 -0
- data/tsconfig.build.json +26 -0
- data/tsconfig.json +27 -0
- metadata +628 -72
- data/.rspec +0 -3
- data/.travis.yml +0 -7
- data/lib/tiun/autocontroller.rb.erb +0 -20
- data/lib/tiun/autolistserializer.rb.erb +0 -9
- data/lib/tiun/automodel.rb.erb +0 -10
- data/lib/tiun/autoserializer.rb.erb +0 -9
- data/lib/tiun/base.rb +0 -405
- data/lib/tiun/core_controller.rb +0 -6
- data/lib/tiun/list_serializer.rb +0 -20
- data/lib/tiun/meta_controller.rb +0 -13
- data/lib/tiun/serializer.rb +0 -31
- /data/lib/tiun/{automigration.rb.erb → migration/auto.rb.erb} +0 -0
- /data/lib/tiun/{autopolicy.rb.erb → policy/auto.rb.erb} +0 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Подготовка именованных компонентов без преобразования полей API и привязок.
|
|
4
|
+
module Tiun::Proceed::Schemas::ComponentNodes
|
|
5
|
+
include Tiun::Proceed::Schemas::Constants
|
|
6
|
+
|
|
7
|
+
LAYOUT_HTML_ERROR = 'layout.html: use document properties directly in layout'
|
|
8
|
+
|
|
9
|
+
BUILTIN_COMPONENTS = %w[lorem markdown enum stockee toast login chip image avatar pressee loader
|
|
10
|
+
records footer calendar menu heading figure row form modal view grid column
|
|
11
|
+
intro step].freeze
|
|
12
|
+
COMPONENT_LISTS = %i[children headers].freeze
|
|
13
|
+
SERVER_VIEW_LISTS = %i[children components headers].freeze
|
|
14
|
+
RECORD_ACTIONS = %i[index remove].freeze
|
|
15
|
+
VIEW_PROPERTY_ERRORS = {
|
|
16
|
+
record_manager: 'record_manager: declare an of: records child',
|
|
17
|
+
row: 'row: declare an of: row child inside records',
|
|
18
|
+
resource: 'resource: declare resources on the component that uses them',
|
|
19
|
+
form: 'form: declare a form in children',
|
|
20
|
+
method: 'method: declare allowed methods on the form',
|
|
21
|
+
prepare: 'prepare: declare a projector on the record component',
|
|
22
|
+
response_root: 'response_root: declare the response root on the form',
|
|
23
|
+
owner_key: 'owner_key: declare the owner field on the form',
|
|
24
|
+
source: 'source: declare data on the component that uses it'
|
|
25
|
+
}.freeze
|
|
26
|
+
|
|
27
|
+
# Проверяет массив определений, сохраняя свойства и порядок исходной схемы.
|
|
28
|
+
# @param entries [Array<OpenStruct>] Именованные компоненты.
|
|
29
|
+
# @param path [String] Путь раздела для диагностики.
|
|
30
|
+
# @param view [Boolean] Корневой вид Rails может опустить тип компонента.
|
|
31
|
+
# @param server [Boolean] Обрабатывает дерево серверного вида.
|
|
32
|
+
# @param definitions [Boolean] Глобальные определения компонентов.
|
|
33
|
+
# @param translation_path [String, nil] Базовый путь ссылок i18n; имя узла добавляется автоматически.
|
|
34
|
+
# @return [Array] Проверенные определения и предупреждения.
|
|
35
|
+
def proceeded_component_nodes entries, path, view: false, server: view, definitions: false, translation_path: nil
|
|
36
|
+
names = {}
|
|
37
|
+
|
|
38
|
+
proceeded_schema_list(entries, path) do |entry, position|
|
|
39
|
+
unless is_schema_component_name?(entry.name)
|
|
40
|
+
next [nil, ["Tiun: #{position}: expected snake_case name; entry ignored"]]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
source = "#{path}.#{entry.name}"
|
|
44
|
+
identity = component_identity(entry.name)
|
|
45
|
+
identity = "#{identity}:#{entry.version}" if definitions && entry.to_h.key?(:version)
|
|
46
|
+
if names[identity] == entry.name
|
|
47
|
+
next [nil, ["Tiun: #{position}: duplicate name #{entry.name}; entry ignored"]]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
message = component_name_error(entry.name, identity, names.keys, definitions && entry.of != 'view')
|
|
51
|
+
names[identity] = entry.name
|
|
52
|
+
translation_scope = translation_path
|
|
53
|
+
|
|
54
|
+
if translation_scope == 'tiun.components' && (view || entry.of == 'view')
|
|
55
|
+
translation_scope = "#{translation_scope}.view"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
component_path = [translation_scope, entry.name].compact.join('.')
|
|
59
|
+
|
|
60
|
+
message ? [nil, ["Tiun: #{source}: #{message}"]] :
|
|
61
|
+
proceeded_component_node(entry, source, view, component_path, server: server)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Вычисляет имя, под которым компонент известен на фронтенде.
|
|
66
|
+
# @param name [String] Исходное имя компонента.
|
|
67
|
+
# @return [String] Имя PascalCase без изменения оставшихся букв сегмента.
|
|
68
|
+
def component_identity name
|
|
69
|
+
name.split(/[_-]/).filter_map {|part| part[0].upcase + part[1, part.length] unless part.empty? }.join
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Находит повторное имя или попытку подменить встроенный компонент.
|
|
73
|
+
# @param name [String] Исходное имя.
|
|
74
|
+
# @param identity [String] Имя фронтенда.
|
|
75
|
+
# @param names [Array<String>] Имена в текущем массиве.
|
|
76
|
+
# @param definitions [Boolean] Глобальные определения, а не экземпляры.
|
|
77
|
+
# @return [String, nil] Причина отказа либо nil.
|
|
78
|
+
def component_name_error name, identity, names, definitions
|
|
79
|
+
return "duplicate component #{name}" if names.include?(identity)
|
|
80
|
+
base = component_identity(name.split(':', 2).first)
|
|
81
|
+
return unless definitions && BUILTIN_COMPONENTS.any? {|builtin| component_identity(builtin) == base }
|
|
82
|
+
|
|
83
|
+
"cannot redefine builtin component #{name}"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Проверяет обязательный of и рекурсивные массивы челяди.
|
|
87
|
+
# @param entry [OpenStruct] Исходный узел.
|
|
88
|
+
# @param source [String] Путь определения.
|
|
89
|
+
# @param view [Boolean] Корневому виду не требуется of.
|
|
90
|
+
# @param translation_path [String, nil] Путь ссылки i18n текущего узла.
|
|
91
|
+
# @param server [Boolean] Обрабатывает узел по правилам серверного вида.
|
|
92
|
+
# @return [Array] Копия узла и диагностические сообщения.
|
|
93
|
+
def proceeded_component_node entry, source, view, translation_path, server: view
|
|
94
|
+
error = component_node_error(entry, view, server: server)
|
|
95
|
+
|
|
96
|
+
return [nil, ["Tiun: #{source}: #{error}"]] if error
|
|
97
|
+
return proceeded_content_definition(entry, source) if !server && is_content_definition?(entry)
|
|
98
|
+
|
|
99
|
+
properties = Tiun::Context.deep_to_h(entry)
|
|
100
|
+
properties.delete(:head) unless server || entry.of == 'view'
|
|
101
|
+
if translation_path
|
|
102
|
+
properties[:caption] = ":#{translation_path}" if %w[menu pressee].include?(entry.of) && !properties.key?(:caption)
|
|
103
|
+
has_explicit_content = properties.keys.intersect?(%i[text children value])
|
|
104
|
+
properties[:text] = ":#{translation_path}" if %w[lorem step].include?(entry.of) && !has_explicit_content
|
|
105
|
+
properties[:labels] = fill_component_labels(properties[:labels], translation_path) if properties[:labels].is_a?(Hash)
|
|
106
|
+
end
|
|
107
|
+
lists, warnings = proceeded_component_lists(entry, source, translation_path, server: server)
|
|
108
|
+
attributes, property_warnings = prepare_component_properties(entry, properties, source, lists.keys)
|
|
109
|
+
warnings += property_warnings
|
|
110
|
+
|
|
111
|
+
[attributes.merge(lists).to_os, warnings]
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Строит путь перевода для подписей, у которых задано только имя.
|
|
115
|
+
def fill_component_labels labels, translation_path
|
|
116
|
+
labels.each_pair.with_object({}) do |(name, value), result|
|
|
117
|
+
path = "#{translation_path}.#{name}"
|
|
118
|
+
result[name] =
|
|
119
|
+
case value
|
|
120
|
+
when Hash then fill_component_labels(value, path)
|
|
121
|
+
when NilClass then ":#{path}"
|
|
122
|
+
else value
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def proceeded_component_lists entry, source, translation_path, server: false
|
|
128
|
+
keys = entry.to_h.keys & (server ? SERVER_VIEW_LISTS : COMPONENT_LISTS)
|
|
129
|
+
results = keys.to_h do |key|
|
|
130
|
+
[key, proceeded_component_nodes(entry[key], "#{source}.#{key}", server: server, translation_path: translation_path)]
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
[results.transform_values(&:first), results.values.flat_map(&:last)]
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Нормализует свойства узла, проверяя поля формы и адреса служб календаря.
|
|
137
|
+
# @param entry [OpenStruct] Исходный узел.
|
|
138
|
+
# @param properties [Hash] Собственные свойства узла.
|
|
139
|
+
# @param source [String] Путь узла для предупреждений.
|
|
140
|
+
# @param lists [Array<Symbol>] Ключи уже подготовленных списков челяди.
|
|
141
|
+
# @return [Array] Подготовленные свойства и предупреждения.
|
|
142
|
+
def prepare_component_properties entry, properties, source, lists
|
|
143
|
+
attributes = normalize_component_references(properties.except(*lists))
|
|
144
|
+
warnings = prepare_form_component(entry, properties, attributes, source)
|
|
145
|
+
|
|
146
|
+
if entry.of == 'calendar' && attributes.key?(:catch)
|
|
147
|
+
settings, messages = proceeded_calendar_catch(entry[:catch], "#{source}.catch")
|
|
148
|
+
|
|
149
|
+
attributes.delete(:catch)
|
|
150
|
+
attributes[:catch] = settings if settings
|
|
151
|
+
|
|
152
|
+
warnings += messages
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
[attributes, warnings]
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Проверяет поля компонента формы.
|
|
159
|
+
# @param entry [OpenStruct] Исходный узел.
|
|
160
|
+
# @param properties [Hash] Собственные свойства исходного узла.
|
|
161
|
+
# @param attributes [Hash] Подготовленные свойства, дополненные на месте.
|
|
162
|
+
# @param source [String] Путь компонента для предупреждений.
|
|
163
|
+
# @return [Array<String>] Предупреждения при проверке формы.
|
|
164
|
+
def prepare_form_component entry, properties, attributes, source
|
|
165
|
+
return [] unless entry.of == 'form'
|
|
166
|
+
|
|
167
|
+
attributes.delete(:appearance)
|
|
168
|
+
attributes.delete(:root)
|
|
169
|
+
return [] unless properties.key?(:fields)
|
|
170
|
+
|
|
171
|
+
fields, warnings = proceeded_form_fields(entry.fields, "#{source}.fields")
|
|
172
|
+
|
|
173
|
+
attributes[:fields] = fields
|
|
174
|
+
|
|
175
|
+
warnings
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Сохраняет двоеточие в привязках, которые Psych прочитал как Symbol.
|
|
179
|
+
# @param value [Object] Значение свойства YAML после чтения.
|
|
180
|
+
# @return [Object] Копия значения с привязками в строковом формате.
|
|
181
|
+
def normalize_component_references value
|
|
182
|
+
case value
|
|
183
|
+
when Hash then value.transform_values {|item| normalize_component_references(item) }
|
|
184
|
+
when Array then value.map {|item| normalize_component_references(item) }
|
|
185
|
+
when Symbol then ":#{value}"
|
|
186
|
+
else value
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Проверяет тип узла и явный выбор входных props.
|
|
191
|
+
# @param entry [OpenStruct] Исходный компонент.
|
|
192
|
+
# @param view [Boolean] Корневому виду не требуется of.
|
|
193
|
+
# @param server [Boolean] Проверяет узел по правилам серверного вида.
|
|
194
|
+
# @return [String, nil] Причина отказа либо nil.
|
|
195
|
+
def component_node_error entry, view = false, server: view
|
|
196
|
+
return 'of is required' unless view || is_schema_component_reference?(entry.of)
|
|
197
|
+
return 'components: declare children' if !server && entry.to_h.key?(:components)
|
|
198
|
+
if entry.to_h.key?(:props) && !is_component_props_valid?(entry.props)
|
|
199
|
+
return 'props: expected unique comma-separated fields'
|
|
200
|
+
end
|
|
201
|
+
if entry.to_h.key?(:with) && !is_component_with_valid?(entry.with)
|
|
202
|
+
return 'with: expected unique comma-separated decorator names'
|
|
203
|
+
end
|
|
204
|
+
if entry.of == 'modal' && entry.to_h.key?(:actions) && ![[], ['close']].include?(entry.actions)
|
|
205
|
+
return 'actions: expected a list containing close at most once'
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
footer_layout_error(entry) || view_component_error(entry, server: server) ||
|
|
209
|
+
records_component_error(entry, server: server) || view_document_error(entry) || component_style_error(entry)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Проверяет список имён декораторов для компонента.
|
|
213
|
+
# @param value [Object] Значение свойства with в YAML.
|
|
214
|
+
# @return [Boolean] Имена заданы строкой и перечислены без повторов.
|
|
215
|
+
def is_component_with_valid? value
|
|
216
|
+
return false unless value.is_a?(String)
|
|
217
|
+
|
|
218
|
+
names = value.split(',', -1).map(&:strip)
|
|
219
|
+
|
|
220
|
+
names.any? && names.uniq == names && names.all? {|name| /\A[a-z_][a-z0-9_]*\z/.match?(name) }
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Проверяет, что параметры сетки указаны у элемента челяди подвала.
|
|
224
|
+
# @param entry [OpenStruct] Исходный узел компонента.
|
|
225
|
+
# @return [String, nil] Указание, куда перенести устаревшее свойство.
|
|
226
|
+
def footer_layout_error entry
|
|
227
|
+
return unless entry.of == 'footer'
|
|
228
|
+
|
|
229
|
+
key = %i[configuration columns].find {|field| entry.to_h.key?(field) }
|
|
230
|
+
|
|
231
|
+
"#{key}: declare an of: grid child" if key
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# Проверяет свойства компонента с of: view.
|
|
235
|
+
# @param entry [OpenStruct] Исходный узел компонента.
|
|
236
|
+
# @param server [Boolean] Для серверного вида пропускает проверку имён component и form.
|
|
237
|
+
# @return [String, nil] Первое сообщение об ошибке либо nil.
|
|
238
|
+
def view_component_error entry, server: false
|
|
239
|
+
return unless entry.of == 'view'
|
|
240
|
+
|
|
241
|
+
properties = entry.to_h
|
|
242
|
+
invalid_property = VIEW_PROPERTY_ERRORS.keys.intersection(properties.keys).first
|
|
243
|
+
|
|
244
|
+
return VIEW_PROPERTY_ERRORS[invalid_property] if invalid_property
|
|
245
|
+
return 'mount_to: expected string' unless properties.fetch(:mount_to, '').is_a?(String)
|
|
246
|
+
return 'policy: expected permission names' unless is_view_policy_valid?(entry.policy)
|
|
247
|
+
return if server
|
|
248
|
+
|
|
249
|
+
invalid, = properties.slice(:component).find {|_key, value| !is_schema_component_reference?(value) }
|
|
250
|
+
|
|
251
|
+
"#{invalid}: expected a component name" if invalid
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Проверяет необязательное правило доступа HTML-вида.
|
|
255
|
+
# @param value [String, nil] Имена разрешений через запятую.
|
|
256
|
+
# @return [Boolean] Правило отсутствует либо содержит непустые имена.
|
|
257
|
+
def is_view_policy_valid? value
|
|
258
|
+
value.nil? || value.is_a?(String) && are_policy_values_valid?(value.split(',', -1).map(&:strip))
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def records_component_error entry, server: false
|
|
262
|
+
return unless entry.of == 'records'
|
|
263
|
+
return server_records_component_error(entry) if server
|
|
264
|
+
|
|
265
|
+
properties = entry.to_h
|
|
266
|
+
|
|
267
|
+
return 'root: declare the request root on the resource' if properties.key?(:root)
|
|
268
|
+
return unless properties.key?(:actions)
|
|
269
|
+
|
|
270
|
+
'actions: expected index or remove resource names' unless is_record_action_mapping_valid?(entry.actions)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# Проверяет ссылки на ресурсы записи в серверном виде.
|
|
274
|
+
# @param entry [OpenStruct] Описание records с явными действиями.
|
|
275
|
+
# @return [String, nil] Диагностика первого неверного параметра либо nil.
|
|
276
|
+
def server_records_component_error entry
|
|
277
|
+
return unless entry.to_h.keys.intersect?(%i[root actions])
|
|
278
|
+
|
|
279
|
+
actions = entry.actions
|
|
280
|
+
valid_actions = actions.respond_to?(:each_pair) && %i[read create index update remove].all? do |name|
|
|
281
|
+
is_schema_component_reference?(actions[name])
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
return 'records: require root, form and actions {read, create, index, update, remove}' unless
|
|
285
|
+
%i[root form].all? {|name| entry[name].is_a?(String) && !entry[name].empty? } && valid_actions
|
|
286
|
+
return if (entry.children || []).any? {|child| child.of == 'row' }
|
|
287
|
+
|
|
288
|
+
'records: declare an of: row child'
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Проверяет ключи действий Records и имена связанных ресурсов.
|
|
292
|
+
# @param actions [Object] Значение свойства actions, обычно словарь или OpenStruct.
|
|
293
|
+
# @return [Boolean] Заданы ли только допустимые пары действия и ресурса.
|
|
294
|
+
def is_record_action_mapping_valid? actions
|
|
295
|
+
actions.respond_to?(:each_pair) && actions.to_h.all? do |name, resource|
|
|
296
|
+
RECORD_ACTIONS.include?(name) && is_schema_component_reference?(resource)
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def is_schema_component_name? value
|
|
301
|
+
value.is_a?(String) && SCHEMA_NAME.match?(value)
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
# Принимает имя ссылки с необязательной числовой версией после двоеточия.
|
|
305
|
+
# @param value [Object] Значение ссылки на компонент или ресурс.
|
|
306
|
+
# @return [Boolean] Подходит ли значение по форме имени и разрядов версии.
|
|
307
|
+
def is_schema_component_reference? value
|
|
308
|
+
value.is_a?(String) && SCHEMA_REFERENCE.match?(value)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# Проверяет параметры HTML и форму ссылки на общий макет.
|
|
312
|
+
# @param entry [OpenStruct] Исходный компонент вида.
|
|
313
|
+
# @return [String, nil] Предупреждение о неверном параметре.
|
|
314
|
+
def view_document_error entry
|
|
315
|
+
return unless entry.of == 'view'
|
|
316
|
+
|
|
317
|
+
properties = Tiun::Context.deep_to_h(entry)
|
|
318
|
+
|
|
319
|
+
return 'path: use mount_to' if properties.key?(:path)
|
|
320
|
+
|
|
321
|
+
error = document_mapping_error(properties.fetch(:html, {}), 'html') || document_mapping_error(properties)
|
|
322
|
+
|
|
323
|
+
return error if error
|
|
324
|
+
|
|
325
|
+
layout = properties.fetch(:layout, {})
|
|
326
|
+
|
|
327
|
+
if layout.is_a?(String)
|
|
328
|
+
'layout: expected name' unless is_schema_component_name?(layout)
|
|
329
|
+
else
|
|
330
|
+
view_layout_error(layout)
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# Проверяет описание макета с параметрами документа на верхнем уровне.
|
|
335
|
+
# @param layout [Object] Значение layout.
|
|
336
|
+
# @return [String, nil] Сообщение о неверном параметре.
|
|
337
|
+
def view_layout_error layout
|
|
338
|
+
return LAYOUT_HTML_ERROR if layout.is_a?(Hash) && layout.key?(:html)
|
|
339
|
+
|
|
340
|
+
document_mapping_error(layout, 'layout')
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# Проверяет типы свойств документа на уровне вида, html либо макета.
|
|
344
|
+
# @param document [Object] Словарь свойств документа.
|
|
345
|
+
# @param path [String, nil] Имя обёртки в диагностике.
|
|
346
|
+
# @return [String, nil] Сообщение о первом неверном свойстве.
|
|
347
|
+
def document_mapping_error document, path = nil
|
|
348
|
+
return "#{path}: expected mapping" unless document.is_a?(Hash)
|
|
349
|
+
|
|
350
|
+
prefix = "#{path}." if path
|
|
351
|
+
|
|
352
|
+
invalid, = document.slice(:head, :body).find {|_part, value| !value.is_a?(Hash) }
|
|
353
|
+
|
|
354
|
+
return "#{prefix}#{invalid}: expected mapping" if invalid
|
|
355
|
+
|
|
356
|
+
invalid, = document.slice(:lang, :dir).find {|_part, value| !(value in String | Symbol) }
|
|
357
|
+
|
|
358
|
+
"#{prefix}#{invalid}: expected string" if invalid
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
# Проверяет запятую-разделитель и уникальность целевых имён props.
|
|
362
|
+
# @param value [Object] Значение параметра props.
|
|
363
|
+
# @return [Boolean] Корректный выбор входных полей.
|
|
364
|
+
def is_component_props_valid? value
|
|
365
|
+
return false unless value.is_a?(String) && /\S/.match?(value)
|
|
366
|
+
|
|
367
|
+
fields = component_props_fields(value)
|
|
368
|
+
|
|
369
|
+
return false unless fields.all? {|parts| component_prop_names_valid?(parts) }
|
|
370
|
+
|
|
371
|
+
targets = fields.map {|parts| component_prop_target(parts.last) }
|
|
372
|
+
|
|
373
|
+
targets.uniq == targets
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
# Проверяет исходное и целевое имя без доступа к прототипам.
|
|
377
|
+
# @param parts [Array<String>] Имена из одной записи props.
|
|
378
|
+
# @return [Boolean] Допустимые имена полей.
|
|
379
|
+
def component_prop_names_valid? parts
|
|
380
|
+
parts.length.between?(1, 2) && parts.all? do |name|
|
|
381
|
+
/\A[a-z_][a-z0-9_]*\z/i.match?(name) && !RESERVED_FIELD_ALIASES.include?(name)
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
# Преобразует целевое имя так же, как граница Schema на клиенте.
|
|
386
|
+
# @param name [String] Целевое имя поля.
|
|
387
|
+
# @return [String] Имя camelCase.
|
|
388
|
+
def component_prop_target name
|
|
389
|
+
return 'className' if name == 'class'
|
|
390
|
+
|
|
391
|
+
name.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
# Разделяет выбор полей, снимая префикс родительского поля для проверки имён.
|
|
395
|
+
# @param value [String] Список выбора props.
|
|
396
|
+
# @return [Array<Array<String>>] Исходное и необязательное целевое поле.
|
|
397
|
+
def component_props_fields value
|
|
398
|
+
value.split(',', -1).map do |field|
|
|
399
|
+
source, *targets = field.split(':', -1).map(&:strip)
|
|
400
|
+
|
|
401
|
+
[source.to_s.delete_prefix('^'), *targets]
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
# Проверяет классы частей компонента.
|
|
406
|
+
# @param entry [OpenStruct] Исходный узел.
|
|
407
|
+
# @return [String, nil] Причина отказа.
|
|
408
|
+
def component_style_error entry
|
|
409
|
+
return unless entry.to_h.key?(:class) && !is_component_classes_valid?(entry[:class])
|
|
410
|
+
|
|
411
|
+
'class: expected string or unique named parts'
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
# Проверяет строку класса либо массив именованных частей.
|
|
415
|
+
# @param value [Object] Параметр class.
|
|
416
|
+
# @return [Boolean] Допустимый формат без повторов.
|
|
417
|
+
def is_component_classes_valid? value
|
|
418
|
+
return true if value.is_a?(String)
|
|
419
|
+
return false unless value.is_a?(Array) && value.all? {|part| component_class_part_valid?(part) }
|
|
420
|
+
|
|
421
|
+
names = value.map {|part| component_prop_target(part.to_h.keys.first.to_s) }
|
|
422
|
+
|
|
423
|
+
names.uniq == names
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
# Проверяет одну именованную часть.
|
|
427
|
+
# @param part [Object] Одноэлементное отображение.
|
|
428
|
+
# @return [Boolean] Допустимое имя и строка CSS-классов.
|
|
429
|
+
def component_class_part_valid? part
|
|
430
|
+
return false unless part.respond_to?(:each_pair) && part.to_h.size == 1
|
|
431
|
+
|
|
432
|
+
name, classes = part.to_h.first
|
|
433
|
+
|
|
434
|
+
/\A[a-z][a-z0-9_]*\z/i.match?(name.to_s) && !RESERVED_FIELD_ALIASES.include?(name.to_s) && classes.is_a?(String)
|
|
435
|
+
end
|
|
436
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Таблицы допустимых параметров форм, видов и полей.
|
|
4
|
+
module Tiun::Proceed::Schemas::Constants
|
|
5
|
+
BOOLEAN_VALUES = [true, false].freeze
|
|
6
|
+
RESERVED_FIELD_ALIASES = %w[__proto__ prototype constructor].freeze
|
|
7
|
+
METHOD_NAME = /\A[\p{Ll}_][\p{Ll}\p{Nd}_]*(?:\.[\p{Ll}_][\p{Ll}\p{Nd}_]*)*\z/
|
|
8
|
+
SCHEMA_NAME_BODY = /[a-z_][a-z0-9_]*(?:\.[a-z_][a-z0-9_]*)*/
|
|
9
|
+
SCHEMA_NAME = /\A#{SCHEMA_NAME_BODY}\z/
|
|
10
|
+
SCHEMA_REFERENCE = /\A#{SCHEMA_NAME_BODY}(?::\d+(?:\.\d+)*)?\z/
|
|
11
|
+
TRANSLATION_REF = /\A:[\p{L}\p{N}_-]+(?:\.[\p{L}\p{N}_-]+)*\z/
|
|
12
|
+
FIELD_TYPES = %w[text tale select boolean number hidden block collection set dynamic json rtfer wye attachment
|
|
13
|
+
component layout].freeze
|
|
14
|
+
CONTENT_ELEMENTS = %w[span spans chip name flex_text calendar player image document slug_flow records].freeze
|
|
15
|
+
IMAGE_VIEW_CHECKS = {
|
|
16
|
+
native: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
17
|
+
view_as: ->(value) { %w[plain card].include?(value) },
|
|
18
|
+
description: ->(value) { value.is_a?(String) },
|
|
19
|
+
on_click: ->(value) { value.is_a?(String) },
|
|
20
|
+
**%i[width height].to_h do |key|
|
|
21
|
+
[key, ->(value) { value.is_a?(String) || value.is_a?(Numeric) && value.finite? && value.positive? }]
|
|
22
|
+
end,
|
|
23
|
+
min_height: ->(value) { value.is_a?(Integer) && value >= 0 }
|
|
24
|
+
}.freeze
|
|
25
|
+
RECORDS_VIEW_CHECKS = {
|
|
26
|
+
layout: ->(value) { %w[grid stack list].include?(value) },
|
|
27
|
+
width: ->(value) { value.is_a?(Numeric) && value.finite? && value.positive? },
|
|
28
|
+
gap: ->(value) { value.is_a?(Numeric) && value.finite? && value >= 0 },
|
|
29
|
+
dom_id: ->(value) { value.is_a?(String) && /\A[a-z][a-z0-9_-]*\z/.match?(value) }
|
|
30
|
+
}.freeze
|
|
31
|
+
FLOW_VIEW_CHECKS = {
|
|
32
|
+
flow_mode: ->(value) { %w[select display].include?(value) },
|
|
33
|
+
show_first: ->(value) { %w[selected skip].include?(value) },
|
|
34
|
+
**%i[key_from fields_to_select on_choose on_open].to_h do |key|
|
|
35
|
+
[key, ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) }]
|
|
36
|
+
end
|
|
37
|
+
}.freeze
|
|
38
|
+
FIELD_CHECKS = {
|
|
39
|
+
selectable: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
40
|
+
readonly: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
41
|
+
input_type: ->(value) { %w[text search email password].include?(value) },
|
|
42
|
+
wait_to_send: ->(value) { !Tiun::Translations.form_delay_seconds(value).nil? },
|
|
43
|
+
on_blur: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
44
|
+
on_enter: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
45
|
+
on_switch: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
46
|
+
**%i[min max step display_scale].to_h {|key| [key, ->(value) { value.is_a?(Numeric) && value.finite? }] },
|
|
47
|
+
required: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
48
|
+
switch: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
49
|
+
view: ->(value) { value.is_a?(String) && SCHEMA_REFERENCE.match?(value) },
|
|
50
|
+
prepare: ->(value) { value.is_a?(String) && METHOD_NAME.match?(value) },
|
|
51
|
+
name: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
52
|
+
of: ->(value) { FIELD_TYPES.include?(value.to_s) },
|
|
53
|
+
accept: ->(value) { value.is_a?(String) && !value.empty? },
|
|
54
|
+
max_bytes: ->(value) { value.is_a?(Integer) && value.positive? },
|
|
55
|
+
preview_renderer: ->(value) { value.is_a?(String) && SCHEMA_REFERENCE.match?(value) },
|
|
56
|
+
resource: ->(value) { value.is_a?(String) && SCHEMA_REFERENCE.match?(value) },
|
|
57
|
+
source: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
58
|
+
humanized_name: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
59
|
+
loadpath: ->(value) { value.is_a?(String) && !value.empty? && !/\s/.match?(value) },
|
|
60
|
+
key_name: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
61
|
+
value_name: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
62
|
+
query_key: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
63
|
+
display_scheme: lambda {|value|
|
|
64
|
+
value.is_a?(String) && /\A(?:[1-9]|1[0-2])(?:-(?:[1-9]|1[0-2])){0,3}\z/.match?(value)
|
|
65
|
+
},
|
|
66
|
+
variant: ->(value) { %w[underline outlined].include?(value) },
|
|
67
|
+
width_kind: ->(value) { %w[auto schemed].include?(value) },
|
|
68
|
+
wrap: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
69
|
+
nested: ->(value) { [true, false].include?(value) },
|
|
70
|
+
disabled: ->(value) { [true, false].include?(value) },
|
|
71
|
+
sun_image: ->(value) { value.is_a?(String) && !value.empty? && !/\s/.match?(value) },
|
|
72
|
+
moon_image: ->(value) { value.is_a?(String) && !value.empty? && !/\s/.match?(value) },
|
|
73
|
+
values: ->(value) { value.is_a?(Array) && value.size == 3 && value.uniq.size == 3 && value.all? {|item| item.is_a?(String) && !item.empty? } },
|
|
74
|
+
pics: ->(value) { value.is_a?(Array) && value.size == 2 && value.all? {|item| item.respond_to?(:each_pair) } },
|
|
75
|
+
eager_load: ->(value) { [true, false].include?(value) },
|
|
76
|
+
max_length: ->(value) { value.is_a?(Integer) && value.positive? },
|
|
77
|
+
rows: ->(value) { value.is_a?(Integer) && value.positive? },
|
|
78
|
+
unique_url: ->(value) { value.is_a?(String) && !value.empty? && !/\s/.match?(value) },
|
|
79
|
+
unique_field: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) }
|
|
80
|
+
}.freeze
|
|
81
|
+
FIELD_PROCESSORS = {
|
|
82
|
+
filter: :proceeded_schema_value, context_value: :proceeded_schema_value, context_values: :proceeded_schema_value,
|
|
83
|
+
true_value: :proceeded_schema_value, false_value: :proceeded_schema_value,
|
|
84
|
+
hint: :proceeded_schema_translation, title: :proceeded_schema_translation,
|
|
85
|
+
placeholder: :proceeded_schema_translation,
|
|
86
|
+
action: :proceeded_schema_translation, meta: :proceeded_form_fields,
|
|
87
|
+
aliases: :proceeded_field_aliases, validations: :proceeded_validation_labels, code_names: :proceeded_code_labels,
|
|
88
|
+
labels: :proceeded_field_labels,
|
|
89
|
+
context_names: :proceeded_schema_context, subscribe_to: :proceeded_schema_subscription,
|
|
90
|
+
visible_if: :proceeded_schema_visibility, default: :proceeded_schema_value,
|
|
91
|
+
humanized_default: :proceeded_schema_humanized_default,
|
|
92
|
+
transparency: :proceeded_dynamic_transparency, states: :proceeded_dynamic_states
|
|
93
|
+
}.freeze
|
|
94
|
+
COLUMN_CHECKS = {
|
|
95
|
+
icon: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
96
|
+
view: ->(value) { value.is_a?(String) && SCHEMA_REFERENCE.match?(value) },
|
|
97
|
+
renderer: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
98
|
+
href: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
99
|
+
navigate: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
100
|
+
inline: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
101
|
+
name: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
102
|
+
value: ->(value) { (value.is_a?(String) || value.is_a?(Symbol)) && SCHEMA_NAME.match?(value.to_s) },
|
|
103
|
+
width: lambda {|value|
|
|
104
|
+
(value.is_a?(Numeric) && value.real? && value.finite? && value >= 0) ||
|
|
105
|
+
(value.is_a?(String) && /\A\d+(?:\.\d+)?(?:px|rem|em|ch|%)\z/.match?(value))
|
|
106
|
+
},
|
|
107
|
+
head_to: ->(value) { %w[left auto right].include?(value) },
|
|
108
|
+
render_kind: ->(value) { %w[text md].include?(value) },
|
|
109
|
+
class: ->(value) { value.is_a?(String) },
|
|
110
|
+
class_name: ->(value) { value.is_a?(String) }
|
|
111
|
+
}.freeze
|
|
112
|
+
INTRO_CHECKS = {
|
|
113
|
+
seq_no: ->(value) { value.is_a?(Integer) && value >= 0 },
|
|
114
|
+
position: ->(value) { %w[auto bottom right left top].include?(value) }
|
|
115
|
+
}.freeze
|
|
116
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Рекурсивная структура отображения. Нет исполняемого HTML/JS в метаданных.
|
|
4
|
+
module Tiun::Proceed::Schemas::Content
|
|
5
|
+
include Tiun::Proceed::Schemas::Constants
|
|
6
|
+
|
|
7
|
+
CONTENT_TAGS = %w[div section article header footer main h1 h2 h3 h4 h5 h6 p span ul ol li table thead tbody tr td
|
|
8
|
+
th figure figcaption].freeze
|
|
9
|
+
CONTENT_CHECKS = {
|
|
10
|
+
uid: ->(value) { Tiun::Proceed.is_component_uid_valid?(value) },
|
|
11
|
+
native: ->(value) { BOOLEAN_VALUES.include?(value) },
|
|
12
|
+
role: ->(value) { value == 'heading' },
|
|
13
|
+
aria_level: ->(value) { value.is_a?(Integer) && (1..6).cover?(value) },
|
|
14
|
+
name: ->(value) { value.is_a?(String) && SCHEMA_NAME.match?(value) },
|
|
15
|
+
kind: ->(value) { %w[group text repeat view link component].include?(value) },
|
|
16
|
+
tag: ->(value) { CONTENT_TAGS.include?(value) },
|
|
17
|
+
class: ->(value) { value.is_a?(String) },
|
|
18
|
+
class_name: ->(value) { value.is_a?(String) },
|
|
19
|
+
surf_to: ->(value) { value.is_a?(String) },
|
|
20
|
+
path: ->(value) { value.is_a?(String) },
|
|
21
|
+
url: ->(value) { value.is_a?(String) },
|
|
22
|
+
prepare: ->(value) { value.is_a?(String) && METHOD_NAME.match?(value) },
|
|
23
|
+
**%i[source renderer view when component resource].to_h do |key|
|
|
24
|
+
[key, lambda {|value|
|
|
25
|
+
value.is_a?(String) && SCHEMA_NAME.match?(value)
|
|
26
|
+
}]
|
|
27
|
+
end
|
|
28
|
+
}.freeze
|
|
29
|
+
|
|
30
|
+
# Порядок и ссылки остаются данными, текст переводится клиентским реестром.
|
|
31
|
+
# @param entries [Array<OpenStruct>] Описания блоков.
|
|
32
|
+
# @param path [String] Путь для предупреждений.
|
|
33
|
+
# @return [Array] Блоки и диагностика.
|
|
34
|
+
def proceeded_content_blocks entries, path
|
|
35
|
+
error = content_limit_error(entries, path)
|
|
36
|
+
|
|
37
|
+
return [nil, ["Tiun: #{path}: #{error}"]] if error
|
|
38
|
+
|
|
39
|
+
processors = { text: :proceeded_schema_translation, children: :proceeded_content_blocks }
|
|
40
|
+
|
|
41
|
+
proceeded_named_schema_list(entries, path) do |entry, source|
|
|
42
|
+
result, warnings = proceeded_schema_properties(entry, CONTENT_CHECKS, processors, source)
|
|
43
|
+
|
|
44
|
+
if is_content_block_ready?(result)
|
|
45
|
+
[result, warnings]
|
|
46
|
+
else
|
|
47
|
+
[nil, warnings + ["Tiun: #{source}: kind or binding missing"]]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# @return [String, nil] Ошибка ограничения структуры.
|
|
53
|
+
def content_limit_error entries, path
|
|
54
|
+
return 'nesting exceeds 16 levels' if path.scan('.children').size > 16
|
|
55
|
+
return 'more than 256 blocks' if entries.is_a?(Array) && entries.size > 256
|
|
56
|
+
|
|
57
|
+
nil
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @return [Boolean] Полнота обязательных свойств блока.
|
|
61
|
+
def is_content_block_ready? result
|
|
62
|
+
return false unless result.kind
|
|
63
|
+
|
|
64
|
+
binding = { 'view' => :view, 'component' => :component, 'repeat' => :source }[result.kind]
|
|
65
|
+
|
|
66
|
+
!binding || !result[binding].nil?
|
|
67
|
+
end
|
|
68
|
+
end
|