hap-cli 0.9.15__tar.gz → 0.9.17__tar.gz
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.
- {hap_cli-0.9.15 → hap_cli-0.9.17}/PKG-INFO +1 -1
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/__init__.py +1 -1
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/role_cmd.py +12 -3
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/design/design.schema.json +10 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/fieldlower.py +11 -2
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/layout_check.py +46 -0
- hap_cli-0.9.17/hap_cli/core/money_currency.py +188 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/role.py +194 -2
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/workflow_node_dsl.py +66 -3
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/worksheet.py +17 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/worksheet_templates.py +7 -5
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/workflow.md +11 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/workflow.md +10 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/locale/messages.json +2 -2
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli.egg-info/PKG-INFO +1 -1
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli.egg-info/SOURCES.txt +1 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/MANIFEST.in +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/README.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/README.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/README_CN.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/__main__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/_entry.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/app_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/app_creator_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/app_editor_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/attachment_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/auth_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/calendar_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/chart_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/chat_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/chatbot_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/config_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/contact_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/department_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/group_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/guide_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/icon_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/instance_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/node_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/optionset_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/page_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/post_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/record_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/region_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/update_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/upload_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/v3_registry.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/workflow_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/commands/worksheet_cmd.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/context.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/action_spec_adapter.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/_hapmeta/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/_hapmeta/control_type_codes.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/_hapmeta/worksheet_templates.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/charts.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/cleanup.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/compiler.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/config.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/errors.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/examples/minimal.design.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/executor.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/fields.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/hap.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/merge.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/recording/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/recording/console.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/recording/jsonl.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/recording/mirror.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/recording/report.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/schema.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/seed/INSTRUCTIONS.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/seed/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/seed/cli.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/seed/executor.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/seed/resources/attachments.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/seed/resources/sample.docx +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/seed/resources/sample.pdf +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/seed/resources/sample_images.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/seed/template.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/selftest.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/smoke.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/steps.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/store.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/validate.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/app_creator/workflow_dsl.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/attachment.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/auth.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/calendar_mod.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/chart.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/chat.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/chatbot.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/cli_access.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/condition_dsl.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/contact.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/control_type_codes.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/department.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/_hapmeta/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/_hapmeta/control_type_codes.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/apply.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/componentlower.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/editspec/component.schema.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/editspec/custom-action.schema.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/editspec/envelope.schema.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/editspec/field.schema.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/editspec.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/errors.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/jsonschema_mini.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/models.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/ops.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/planner.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/editor/reader.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/field_normalizer.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/field_spec_adapter.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/filter_translator.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/filter_v3.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/flow_node.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/global_meta.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/group.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/guide.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/icon_index.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/instance.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/logger.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/optionset.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/page.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/post.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/record.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/record_defaults.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/record_discussions.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/record_form_checks.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/record_lookups.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/record_rules.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/relation_scope.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/relogin.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/response_crypto.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/role_perm_builder.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/rule_spec_adapter.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/session.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/token_crypto.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/update.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/upload.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/v3/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/v3/dispatcher.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/v3/render.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/v3/schema.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/view_spec_adapter.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/workflow.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/worksheet_form.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/core/worksheet_reference.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/approval.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/chart.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/messages.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/overview.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/post.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/record.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/setup.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/skills.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/en/worksheet.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/index.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/approval.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/chart.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/messages.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/overview.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/post.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/record.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/setup.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/skills.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/guide/zh-Hans/worksheet.md +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/i18n.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/locale/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/locale/messages.schema.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/utils/__init__.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/utils/atomic_write.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/utils/confirm.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/utils/formatting.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/utils/options.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli/utils/parameter_mapping.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli.egg-info/dependency_links.txt +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli.egg-info/entry_points.txt +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli.egg-info/requires.txt +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/hap_cli.egg-info/top_level.txt +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/setup.cfg +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/setup.py +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/INDEX.json +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/add_member_to_role.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/batch_delete_records.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/create_optionset.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/create_role.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/delete_optionset.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/delete_record.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/delete_role.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/delete_worksheet.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_app_info.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_app_knowledge_list.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_app_worksheets_list.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_optionset_list.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_record_details.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_record_discussions.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_record_list.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_record_logs.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_record_pivot_data.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_record_relations.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_record_share_link.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_regions.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_role_details.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/get_role_list.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/knowledge_search.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/leave_all_roles.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/remove_member_from_role.yaml +0 -0
- {hap_cli-0.9.15 → hap_cli-0.9.17}/sources/v3-api-schema/update_optionset.yaml +0 -0
|
@@ -9,6 +9,7 @@ from hap_cli.core import role as role_mod
|
|
|
9
9
|
from hap_cli.utils.formatting import output_json, output_kv, output_table
|
|
10
10
|
from hap_cli.i18n import t
|
|
11
11
|
from hap_cli.utils.confirm import confirm_or_abort
|
|
12
|
+
from hap_cli.utils.options import json_arg
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
@click.group(help=t('Role management.'))
|
|
@@ -189,8 +190,16 @@ def role_permissions(ctx, app_id, role_id):
|
|
|
189
190
|
@click.argument("app_id")
|
|
190
191
|
@click.argument("role_id")
|
|
191
192
|
@click.option("--permissions", "-P", default="",
|
|
192
|
-
help="Per-worksheet
|
|
193
|
-
"(only used with --permission-way 0)"
|
|
193
|
+
help="Per-worksheet rules as a JSON array, or @file to read "
|
|
194
|
+
"them from a file (only used with --permission-way 0). "
|
|
195
|
+
'Each rule: {"id": <worksheet id>, "recordDataScope": '
|
|
196
|
+
'{"read": ..., "edit": ..., "delete": ...}}, each 0 '
|
|
197
|
+
"(none), 20 (own records), 30 (own and subordinates') or "
|
|
198
|
+
"100 (all), plus optional recordActions / "
|
|
199
|
+
"worksheetActions / paymentActions as 'app role "
|
|
200
|
+
"permissions' shows them. Worksheets not listed keep "
|
|
201
|
+
"their current per-worksheet access; a role switching "
|
|
202
|
+
"to per-worksheet rules starts with none.")
|
|
194
203
|
@click.option("--permission-way", type=int, default=0,
|
|
195
204
|
help="Permission level: 0=custom (per-worksheet rules), "
|
|
196
205
|
"20=view all records, 30=manage own records, "
|
|
@@ -200,7 +209,7 @@ def role_set_permissions(ctx, app_id, role_id, permissions, permission_way):
|
|
|
200
209
|
"""Edit role permissions."""
|
|
201
210
|
try:
|
|
202
211
|
session = ctx.get_session()
|
|
203
|
-
sheets =
|
|
212
|
+
sheets = json_arg(permissions, what="permissions")
|
|
204
213
|
data = role_mod.set_role_permissions(
|
|
205
214
|
session, app_id, role_id,
|
|
206
215
|
permission_way=permission_way, sheets=sheets,
|
|
@@ -3350,6 +3350,16 @@
|
|
|
3350
3350
|
],
|
|
3351
3351
|
"description": "compute function 模式的结果数据类型,决定下游引用该节点结果的字段 id(text→string_fx_id / number→number_fx_id / date→date_fx_id / datetime→datetime_fx_id)。函数公式返回文本/日期时必须声明;省略默认 number。其他模式无需设置(number/date_diff 为数值、date 为日期)。"
|
|
3352
3352
|
},
|
|
3353
|
+
"precision": {
|
|
3354
|
+
"type": "integer",
|
|
3355
|
+
"minimum": 0,
|
|
3356
|
+
"maximum": 9,
|
|
3357
|
+
"description": "compute number 模式、或 output_type 为 number 的 function 模式:结果保留的小数位数(0-9),省略为 2。"
|
|
3358
|
+
},
|
|
3359
|
+
"null_zero": {
|
|
3360
|
+
"type": "boolean",
|
|
3361
|
+
"description": "compute number 模式:参与计算的字段值为空时视为 0。"
|
|
3362
|
+
},
|
|
3353
3363
|
"field": {
|
|
3354
3364
|
"type": "string",
|
|
3355
3365
|
"description": "rollup:被汇总的字段(工作表/字段);省略=记录数量(count)。"
|
|
@@ -200,8 +200,17 @@ def lower_field(field: dict[str, Any]) -> dict[str, Any]:
|
|
|
200
200
|
"""Return the raw control dict for one clean field definition."""
|
|
201
201
|
type_id = codes.resolve(field["type"])
|
|
202
202
|
advanced = _advanced_kwargs(field, type_id)
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
# A field with a raw ``control`` and no block may be a type that only
|
|
204
|
+
# works with its block's wiring (a relation, a formula); the raw
|
|
205
|
+
# control supplies that wiring, which build_control cannot check.
|
|
206
|
+
raw_wired = (not advanced and isinstance(field.get("control"), dict)
|
|
207
|
+
and (type_id in _BLOCK_TYPE_IDS.values()
|
|
208
|
+
or type_id in _FORMULA_TYPE_IDS))
|
|
209
|
+
if not raw_wired:
|
|
210
|
+
# build_control owns the per-type creation defaults — every type
|
|
211
|
+
# gets them, not only one with a block: without them a money
|
|
212
|
+
# field came out with no currency and no decimal places
|
|
213
|
+
# (bug #456384), unlike the same field from `worksheet create`.
|
|
205
214
|
ctrl = build_control(
|
|
206
215
|
type_id, field["name"],
|
|
207
216
|
required=bool(field.get("required")),
|
|
@@ -64,6 +64,7 @@ ADVANCED_SETTING_VALUE = "advanced_setting_value"
|
|
|
64
64
|
CHOOSERANGE_SHAPE = "chooserange_shape"
|
|
65
65
|
CHOOSERANGE_UNSUPPORTED = "chooserange_unsupported"
|
|
66
66
|
ADVANCED_SETTING_COERCED = "advanced_setting_coerced"
|
|
67
|
+
DEFAULTAREA_SHAPE = "defaultarea_shape"
|
|
67
68
|
|
|
68
69
|
# ``chooserange`` is two different settings sharing one name.
|
|
69
70
|
#
|
|
@@ -117,6 +118,46 @@ def _chooserange_findings(ctrl: dict[str, Any],
|
|
|
117
118
|
return []
|
|
118
119
|
|
|
119
120
|
|
|
121
|
+
# ``defaultarea`` on a phone column is its default country, stored as a
|
|
122
|
+
# serialised country object — the settings panel writes
|
|
123
|
+
# ``JSON.stringify(option.country)``, e.g.
|
|
124
|
+
# ``{"name":"Malaysia","iso2":"my","dialCode":"60"}`` (MDPublic
|
|
125
|
+
# src/pages/widgetConfig/widgetSetting/components/WidgetHighSetting/
|
|
126
|
+
# ControlSetting/TelConfig.jsx:136). The record form reads it as
|
|
127
|
+
# ``safeParse(defaultarea || '{}').iso2.toUpperCase()``
|
|
128
|
+
# (src/ming-ui/components/PhoneNumberInput/index.jsx:117-123): anything
|
|
129
|
+
# that does not parse to an object with an ``iso2`` throws, and every
|
|
130
|
+
# record's detail page shows "Program error" while the list view looks
|
|
131
|
+
# fine (bug #456394 — a bare ``"MY"`` saved through ``worksheet create``).
|
|
132
|
+
# Empty is how the product leaves it unset; it then falls back to the
|
|
133
|
+
# organisation's default region.
|
|
134
|
+
_PHONE_TYPE_ID = 3
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _defaultarea_findings(ctrl: dict[str, Any],
|
|
138
|
+
value: Any) -> list[dict[str, Any]]:
|
|
139
|
+
if ctrl.get("type") != _PHONE_TYPE_ID or value in ("", None):
|
|
140
|
+
return []
|
|
141
|
+
parsed: Any = None
|
|
142
|
+
if isinstance(value, str):
|
|
143
|
+
try:
|
|
144
|
+
parsed = json.loads(value)
|
|
145
|
+
except (ValueError, TypeError):
|
|
146
|
+
parsed = None
|
|
147
|
+
if isinstance(parsed, dict) and isinstance(parsed.get("iso2"), str) \
|
|
148
|
+
and parsed["iso2"].strip():
|
|
149
|
+
return []
|
|
150
|
+
return [_finding(
|
|
151
|
+
DEFAULTAREA_SHAPE, ctrl,
|
|
152
|
+
f"has a 'defaultarea' of {value!r}, which is not a country the "
|
|
153
|
+
"phone field can read. Write the default country as JSON text "
|
|
154
|
+
"with its lowercase two-letter code in 'iso2' — for example "
|
|
155
|
+
"'{\"name\": \"Malaysia\", \"iso2\": \"my\", \"dialCode\": "
|
|
156
|
+
"\"60\"}' — or leave it out to use the organization's default "
|
|
157
|
+
"region. Saved as anything else, no record of the worksheet can "
|
|
158
|
+
"be opened.")]
|
|
159
|
+
|
|
160
|
+
|
|
120
161
|
def _is_scalar(value: Any) -> bool:
|
|
121
162
|
"""A number or a switch — something with one obvious written form."""
|
|
122
163
|
return isinstance(value, (bool, int, float))
|
|
@@ -205,6 +246,11 @@ def advanced_setting_findings(
|
|
|
205
246
|
if found:
|
|
206
247
|
findings.extend(found)
|
|
207
248
|
continue
|
|
249
|
+
if key == "defaultarea":
|
|
250
|
+
found = _defaultarea_findings(ctrl, value)
|
|
251
|
+
if found:
|
|
252
|
+
findings.extend(found)
|
|
253
|
+
continue
|
|
208
254
|
if value is None or isinstance(value, str) or _is_scalar(value):
|
|
209
255
|
continue
|
|
210
256
|
findings.append(_finding(
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""Give a new money field the currency settings the product gives it.
|
|
2
|
+
|
|
3
|
+
A money field (type 8) carries two settings that only make sense together
|
|
4
|
+
(MDPublic / pd-openweb src/pages/widgetConfig/widgetSetting/settings/
|
|
5
|
+
money.jsx, identical in both, pd-openweb read at 2026-11-24):
|
|
6
|
+
|
|
7
|
+
* ``currency`` — ``{"currencycode", "symbol"}``;
|
|
8
|
+
* ``currencynames`` — the unit words the amount-in-words field reads,
|
|
9
|
+
keyed ``0`` traditional-Chinese prefix, ``1`` main unit plural, ``2``
|
|
10
|
+
main unit singular, ``3`` sub unit plural, ``4`` sub unit singular
|
|
11
|
+
(src/utils/domain/control/number.js formatNumberToWords).
|
|
12
|
+
|
|
13
|
+
The settings panel writes both every time. A new field starts from the
|
|
14
|
+
organization's region (``FixedData/GetRegionConfigInfos``); picking a
|
|
15
|
+
currency takes the names from ``Worksheet/GetWorksheetCurrencyInfos``.
|
|
16
|
+
The CLI used to send a fixed CNY ``currency`` and no ``currencynames``:
|
|
17
|
+
the form's live amount in words then had no unit words and a double space
|
|
18
|
+
before ONLY, while the server's stored value did have them (bug #456384,
|
|
19
|
+
reported on Nocoly SaaS where the organization's currency is HKD).
|
|
20
|
+
|
|
21
|
+
So on the way out, every money field being created gets:
|
|
22
|
+
|
|
23
|
+
* no ``currency`` key at all → the organization's default currency;
|
|
24
|
+
* a ``currency`` but no ``currencynames`` → the names of that currency;
|
|
25
|
+
* ``currency`` set to ``""`` → left without a currency, the way clearing
|
|
26
|
+
the picker leaves it.
|
|
27
|
+
"""
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
import json
|
|
31
|
+
import logging
|
|
32
|
+
from typing import Any, Callable, Optional
|
|
33
|
+
|
|
34
|
+
logger = logging.getLogger("hap_cli.money_currency")
|
|
35
|
+
|
|
36
|
+
MONEY_TYPE_ID = 8
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _names(record: dict[str, Any], *, plural: str, singular: str,
|
|
40
|
+
sub_plural: str, sub_singular: str) -> str:
|
|
41
|
+
def pick(key: str, lang: str) -> str:
|
|
42
|
+
return str((record.get(key) or {}).get(lang) or "")
|
|
43
|
+
return json.dumps({
|
|
44
|
+
"0": pick(singular, "3"),
|
|
45
|
+
"1": pick(plural, "1"),
|
|
46
|
+
"2": pick(singular, "1"),
|
|
47
|
+
"3": pick(sub_plural, "1"),
|
|
48
|
+
"4": pick(sub_singular, "1"),
|
|
49
|
+
}, ensure_ascii=False)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _names_from_currency_info(info: dict[str, Any]) -> str:
|
|
53
|
+
# money.jsx onChange: currencyName.3 / currencyNamePlural.1 /
|
|
54
|
+
# currencyName.1 / subCurrencyCodePlural.1 / subCurrencyCode.1
|
|
55
|
+
return _names(info, plural="currencyNamePlural", singular="currencyName",
|
|
56
|
+
sub_plural="subCurrencyCodePlural",
|
|
57
|
+
sub_singular="subCurrencyCode")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _settings_from_region(region: dict[str, Any]) -> dict[str, str]:
|
|
61
|
+
# money.jsx initial default: the region record spells the same words
|
|
62
|
+
# differently — currencyPluralNames / subunits / subunit.
|
|
63
|
+
return {
|
|
64
|
+
"currency": json.dumps({
|
|
65
|
+
"currencycode": region.get("currencyCode") or "",
|
|
66
|
+
"symbol": region.get("currencySymbol") or "",
|
|
67
|
+
}, ensure_ascii=False),
|
|
68
|
+
"currencynames": _names(region, plural="currencyPluralNames",
|
|
69
|
+
singular="currencyName",
|
|
70
|
+
sub_plural="subunits", sub_singular="subunit"),
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _new_money_controls(controls: list[dict[str, Any]],
|
|
75
|
+
is_existing: Callable[[Any], bool]
|
|
76
|
+
) -> list[dict[str, Any]]:
|
|
77
|
+
out: list[dict[str, Any]] = []
|
|
78
|
+
for ctrl in controls or []:
|
|
79
|
+
if not isinstance(ctrl, dict):
|
|
80
|
+
continue
|
|
81
|
+
if ctrl.get("type") == MONEY_TYPE_ID and \
|
|
82
|
+
not is_existing(ctrl.get("controlId")):
|
|
83
|
+
out.append(ctrl)
|
|
84
|
+
# A new sub-table carries its columns inline.
|
|
85
|
+
out.extend(_new_money_controls(ctrl.get("relationControls") or [],
|
|
86
|
+
is_existing))
|
|
87
|
+
return out
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _currency_code(ctrl: dict[str, Any], raw: Any) -> str:
|
|
91
|
+
try:
|
|
92
|
+
parsed = json.loads(raw) if isinstance(raw, str) else raw
|
|
93
|
+
except ValueError:
|
|
94
|
+
parsed = None
|
|
95
|
+
code = parsed.get("currencycode") if isinstance(parsed, dict) else None
|
|
96
|
+
if not isinstance(code, str) or not code.strip():
|
|
97
|
+
raise ValueError(
|
|
98
|
+
f"Money field {ctrl.get('controlName') or '?'!r} has a currency "
|
|
99
|
+
f"setting of {raw!r}. Write it as JSON text with the currency "
|
|
100
|
+
f"code, for example '{{\"currencycode\": \"HKD\", \"symbol\": "
|
|
101
|
+
f"\"$\"}}', or leave it out to use the organization's default "
|
|
102
|
+
f"currency.")
|
|
103
|
+
return code.strip().upper()
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def list_currencies(session: Any) -> list[dict[str, Any]]:
|
|
107
|
+
resp = session.api_call("Worksheet", "GetWorksheetCurrencyInfos", {})
|
|
108
|
+
data = resp.get("data") if isinstance(resp, dict) else resp
|
|
109
|
+
return data if isinstance(data, list) else []
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def region_config(session: Any, project_id: str) -> dict[str, Any]:
|
|
113
|
+
# GET, as fixedData.js getRegionConfigInfos sets ajaxOptions.type.
|
|
114
|
+
resp = session.api_call("FixedData", "GetRegionConfigInfos",
|
|
115
|
+
{"projectId": project_id}, method="GET")
|
|
116
|
+
data = resp.get("data") if isinstance(resp, dict) and "data" in resp \
|
|
117
|
+
and "currencyCode" not in resp else resp
|
|
118
|
+
return data if isinstance(data, dict) else {}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def fill_money_currency(
|
|
122
|
+
session: Any,
|
|
123
|
+
controls: list[dict[str, Any]],
|
|
124
|
+
*,
|
|
125
|
+
project_id: Optional[Callable[[], str]] = None,
|
|
126
|
+
is_existing: Callable[[Any], bool] = lambda _cid: False,
|
|
127
|
+
use_region_default: bool = True,
|
|
128
|
+
) -> list[dict[str, Any]]:
|
|
129
|
+
"""Complete the currency settings of every new money field, in place.
|
|
130
|
+
|
|
131
|
+
``project_id`` is called only when a field needs the organization's
|
|
132
|
+
default currency. ``use_region_default=False`` checks and completes
|
|
133
|
+
the currencies callers named but leaves unnamed ones alone (the
|
|
134
|
+
offline preflight of ``worksheet create``, before the sheet exists).
|
|
135
|
+
Raises ``ValueError`` for a currency that cannot be read or is not
|
|
136
|
+
one the product offers.
|
|
137
|
+
"""
|
|
138
|
+
targets = _new_money_controls(controls, is_existing)
|
|
139
|
+
if not targets:
|
|
140
|
+
return controls
|
|
141
|
+
currencies: Optional[dict[str, dict[str, Any]]] = None
|
|
142
|
+
region: Optional[dict[str, Any]] = None
|
|
143
|
+
for ctrl in targets:
|
|
144
|
+
adv = ctrl.get("advancedSetting")
|
|
145
|
+
if not isinstance(adv, dict):
|
|
146
|
+
adv = {}
|
|
147
|
+
if "currency" not in adv:
|
|
148
|
+
if not use_region_default:
|
|
149
|
+
continue
|
|
150
|
+
if region is None:
|
|
151
|
+
pid = project_id() if project_id else ""
|
|
152
|
+
try:
|
|
153
|
+
region = region_config(session, pid)
|
|
154
|
+
except Exception: # noqa: BLE001 — logged, field still saves
|
|
155
|
+
logger.warning("region config lookup failed for %s",
|
|
156
|
+
pid, exc_info=True)
|
|
157
|
+
region = {}
|
|
158
|
+
if region.get("currencyCode"):
|
|
159
|
+
adv = {**adv, **_settings_from_region(region)}
|
|
160
|
+
logger.info("money field %s: organization currency %s",
|
|
161
|
+
ctrl.get("controlName"), region["currencyCode"])
|
|
162
|
+
ctrl["advancedSetting"] = adv
|
|
163
|
+
continue
|
|
164
|
+
if adv.get("currency") in ("", None) or adv.get("currencynames"):
|
|
165
|
+
continue
|
|
166
|
+
code = _currency_code(ctrl, adv["currency"])
|
|
167
|
+
if currencies is None:
|
|
168
|
+
currencies = {str(c.get("currencyCode") or "").upper(): c
|
|
169
|
+
for c in list_currencies(session)
|
|
170
|
+
if isinstance(c, dict)}
|
|
171
|
+
info = currencies.get(code)
|
|
172
|
+
if info is None:
|
|
173
|
+
raise ValueError(
|
|
174
|
+
f"Money field {ctrl.get('controlName') or '?'!r} names the "
|
|
175
|
+
f"currency {code!r}, which is not one the product offers. "
|
|
176
|
+
f"Use a three-letter currency code such as CNY, HKD, USD "
|
|
177
|
+
f"or MYR.")
|
|
178
|
+
currency = json.loads(adv["currency"]) \
|
|
179
|
+
if isinstance(adv["currency"], str) else dict(adv["currency"])
|
|
180
|
+
currency["currencycode"] = code
|
|
181
|
+
if not currency.get("symbol"):
|
|
182
|
+
currency["symbol"] = info.get("symbol") or ""
|
|
183
|
+
ctrl["advancedSetting"] = {
|
|
184
|
+
**adv,
|
|
185
|
+
"currency": json.dumps(currency, ensure_ascii=False),
|
|
186
|
+
"currencynames": _names_from_currency_info(info),
|
|
187
|
+
}
|
|
188
|
+
return controls
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"""Role management module for Mingdao HAP."""
|
|
2
2
|
|
|
3
|
+
import copy
|
|
4
|
+
import logging
|
|
3
5
|
from typing import Any, Optional
|
|
4
6
|
|
|
5
7
|
from hap_cli.core.session import Session, require_code
|
|
6
8
|
|
|
9
|
+
logger = logging.getLogger("hap_cli.role")
|
|
10
|
+
|
|
7
11
|
|
|
8
12
|
def get_roles(
|
|
9
13
|
session: Session,
|
|
@@ -256,7 +260,8 @@ def set_role_permissions(
|
|
|
256
260
|
model["permissionWay"] = permission_way
|
|
257
261
|
if permission_way == 0:
|
|
258
262
|
if sheets is not None:
|
|
259
|
-
model["sheets"] = sheets
|
|
263
|
+
model["sheets"] = apply_sheet_rules(model.get("sheets") or [],
|
|
264
|
+
sheets)
|
|
260
265
|
else:
|
|
261
266
|
model.pop("sheets", None)
|
|
262
267
|
data: dict[str, Any] = {
|
|
@@ -265,10 +270,197 @@ def set_role_permissions(
|
|
|
265
270
|
project_id = project_id or str(model.get("projectId") or "")
|
|
266
271
|
if project_id:
|
|
267
272
|
data["projectId"] = project_id
|
|
268
|
-
|
|
273
|
+
result = require_code(
|
|
269
274
|
session.api_call("AppManagement", "EditAppRole", data),
|
|
270
275
|
action="permission change", meanings=_ROLE_SAVE_MEANINGS,
|
|
271
276
|
)
|
|
277
|
+
if permission_way == 0 and sheets:
|
|
278
|
+
_check_sheet_access_saved(session, app_id, role_id, model["sheets"],
|
|
279
|
+
sheets)
|
|
280
|
+
return result
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
# ── Per-worksheet rules ──────────────────────────────────────────────────
|
|
284
|
+
#
|
|
285
|
+
# The role model's ``sheets[]`` is not where a rule can be written as-is
|
|
286
|
+
# (bug #456396). Whether a role sees, edits or deletes in a worksheet is
|
|
287
|
+
# decided per view — ``views[].canRead / canEdit / canRemove`` — and the
|
|
288
|
+
# ``readLevel / editLevel / removeLevel`` beside them only say which
|
|
289
|
+
# records (20 own, 30 own and subordinates', 100 all): pd-openweb
|
|
290
|
+
# src/pages/Role/component/RoleSet/SheetTable.jsx changeSheetModel and
|
|
291
|
+
# TooltipSetting/sheetSet.jsx, MDPublic identical. Saving rules verbatim
|
|
292
|
+
# replaced the stored list with entries the server cannot read, and every
|
|
293
|
+
# worksheet came back unchecked.
|
|
294
|
+
#
|
|
295
|
+
# The rule shape accepted is the one ``app role permissions`` reads and
|
|
296
|
+
# ``app role create`` takes (V3 worksheetPermissions,
|
|
297
|
+
# sources/v3-api-schema/create_role.yaml): ``{id, recordDataScope:
|
|
298
|
+
# {read, edit, delete}, recordActions?, worksheetActions?,
|
|
299
|
+
# paymentActions?}``. It is merged onto the stored worksheet, so a
|
|
300
|
+
# worksheet not named keeps what it had. The product's own entry — one
|
|
301
|
+
# that carries ``sheetId`` and ``views`` — still round-trips unchanged.
|
|
302
|
+
|
|
303
|
+
_SCOPES = (0, 20, 30, 100)
|
|
304
|
+
_RULE_KEYS = {"id", "name", "recordDataScope", "recordActions",
|
|
305
|
+
"worksheetActions", "paymentActions"}
|
|
306
|
+
# V3 action name -> the role model's per-worksheet switch. ``add`` is the
|
|
307
|
+
# editor's "add" checkbox, ``canAdd``.
|
|
308
|
+
_RECORD_ACTIONS = {"share": "recordShare", "discuss": "recordDiscussion",
|
|
309
|
+
"systemPrint": "recordSystemPrinting",
|
|
310
|
+
"attachmentDownload": "recordAttachmentDownload",
|
|
311
|
+
"log": "recordLogging"}
|
|
312
|
+
_WORKSHEET_ACTIONS = {"shareView": "worksheetShareView",
|
|
313
|
+
"import": "worksheetImport",
|
|
314
|
+
"export": "worksheetExport",
|
|
315
|
+
"discuss": "worksheetDiscuss",
|
|
316
|
+
"batchOperation": "worksheetBatchOperation"}
|
|
317
|
+
_PAYMENT_ACTIONS = {"pay": "payment"}
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def _rule_error(i: int, what: str) -> ValueError:
|
|
321
|
+
return ValueError(f"Worksheet rule {i}: {what}")
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def _set_switch(sheet: dict[str, Any], key: str, enable: Any) -> None:
|
|
325
|
+
current = sheet.get(key)
|
|
326
|
+
sheet[key] = {**(current if isinstance(current, dict) else
|
|
327
|
+
{"range": 1, "allowExport": False}),
|
|
328
|
+
"enable": bool(enable)}
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def _apply_actions(sheet: dict[str, Any], i: int, block: Any, name: str,
|
|
332
|
+
mapping: dict[str, str], extra: tuple = ()) -> None:
|
|
333
|
+
if block is None:
|
|
334
|
+
return
|
|
335
|
+
if not isinstance(block, dict):
|
|
336
|
+
raise _rule_error(i, f"'{name}' must be an object.")
|
|
337
|
+
allowed = set(mapping) | set(extra)
|
|
338
|
+
unknown = sorted(set(block) - allowed)
|
|
339
|
+
if unknown:
|
|
340
|
+
raise _rule_error(
|
|
341
|
+
i, f"'{name}' does not take {', '.join(map(repr, unknown))}. "
|
|
342
|
+
f"It takes: {', '.join(sorted(allowed))}.")
|
|
343
|
+
for key, value in block.items():
|
|
344
|
+
if key in mapping:
|
|
345
|
+
_set_switch(sheet, mapping[key], value)
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def _apply_rule(sheet: dict[str, Any], rule: dict[str, Any],
|
|
349
|
+
i: int) -> dict[str, Any]:
|
|
350
|
+
scope = rule.get("recordDataScope")
|
|
351
|
+
if not isinstance(scope, dict):
|
|
352
|
+
raise _rule_error(
|
|
353
|
+
i, "needs 'recordDataScope': {\"read\", \"edit\", \"delete\"}, "
|
|
354
|
+
"each 0 (none), 20 (own records), 30 (own and "
|
|
355
|
+
"subordinates') or 100 (all records).")
|
|
356
|
+
levels = {}
|
|
357
|
+
for key in ("read", "edit", "delete"):
|
|
358
|
+
value = scope.get(key, 0)
|
|
359
|
+
if isinstance(value, bool) or value not in _SCOPES:
|
|
360
|
+
raise _rule_error(
|
|
361
|
+
i, f"recordDataScope.{key} is {value!r}; use 0, 20, 30 or "
|
|
362
|
+
f"100.")
|
|
363
|
+
levels[key] = value
|
|
364
|
+
if levels["read"] == 0 and (levels["edit"] or levels["delete"]):
|
|
365
|
+
raise _rule_error(
|
|
366
|
+
i, "a worksheet the role cannot read cannot be edited or "
|
|
367
|
+
"deleted in either; set read above 0, or edit and delete "
|
|
368
|
+
"to 0.")
|
|
369
|
+
out = copy.deepcopy(sheet)
|
|
370
|
+
read, edit, delete = (levels[k] > 0 for k in ("read", "edit", "delete"))
|
|
371
|
+
out["views"] = [{**v, "canRead": read, "canEdit": edit,
|
|
372
|
+
"canRemove": delete}
|
|
373
|
+
for v in (out.get("views") or []) if isinstance(v, dict)]
|
|
374
|
+
for key, level in (("readLevel", "read"), ("editLevel", "edit"),
|
|
375
|
+
("removeLevel", "delete")):
|
|
376
|
+
if levels[level]:
|
|
377
|
+
out[key] = levels[level]
|
|
378
|
+
record_actions = rule.get("recordActions")
|
|
379
|
+
_apply_actions(out, i, record_actions, "recordActions",
|
|
380
|
+
_RECORD_ACTIONS, extra=("add",))
|
|
381
|
+
if isinstance(record_actions, dict) and "add" in record_actions:
|
|
382
|
+
out["canAdd"] = bool(record_actions["add"])
|
|
383
|
+
if not read:
|
|
384
|
+
# changeSheetModel clears "add" along with "view".
|
|
385
|
+
out["canAdd"] = False
|
|
386
|
+
_apply_actions(out, i, rule.get("worksheetActions"), "worksheetActions",
|
|
387
|
+
_WORKSHEET_ACTIONS)
|
|
388
|
+
_apply_actions(out, i, rule.get("paymentActions"), "paymentActions",
|
|
389
|
+
_PAYMENT_ACTIONS)
|
|
390
|
+
return out
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def apply_sheet_rules(stored: list[dict[str, Any]],
|
|
394
|
+
rules: Any) -> list[dict[str, Any]]:
|
|
395
|
+
"""The role model's ``sheets`` with ``rules`` merged in."""
|
|
396
|
+
if not isinstance(rules, list):
|
|
397
|
+
raise ValueError("Worksheet rules must be a JSON array.")
|
|
398
|
+
by_id = {s.get("sheetId"): s for s in stored if isinstance(s, dict)}
|
|
399
|
+
updated: dict[str, dict[str, Any]] = {}
|
|
400
|
+
for i, rule in enumerate(rules, start=1):
|
|
401
|
+
if not isinstance(rule, dict):
|
|
402
|
+
raise _rule_error(i, "must be an object.")
|
|
403
|
+
if "sheetId" in rule:
|
|
404
|
+
if not isinstance(rule.get("views"), list):
|
|
405
|
+
raise _rule_error(
|
|
406
|
+
i, "an entry naming 'sheetId' is the role editor's own "
|
|
407
|
+
"form and has to carry its 'views' — that is where "
|
|
408
|
+
"view, edit and delete access is decided. Write "
|
|
409
|
+
"{\"id\": <worksheet id>, \"recordDataScope\": "
|
|
410
|
+
"{...}} instead.")
|
|
411
|
+
if rule["sheetId"] not in by_id:
|
|
412
|
+
raise _rule_error(
|
|
413
|
+
i, f"worksheet {rule['sheetId']!r} is not in this "
|
|
414
|
+
f"role's application.")
|
|
415
|
+
updated[rule["sheetId"]] = rule
|
|
416
|
+
continue
|
|
417
|
+
unknown = sorted(set(rule) - _RULE_KEYS)
|
|
418
|
+
if unknown or not rule.get("id"):
|
|
419
|
+
raise _rule_error(
|
|
420
|
+
i, (f"does not take {', '.join(map(repr, unknown))}. "
|
|
421
|
+
if unknown else "needs the worksheet 'id'. ")
|
|
422
|
+
+ "A rule is {\"id\": <worksheet id>, \"recordDataScope\": "
|
|
423
|
+
"{\"read\", \"edit\", \"delete\"}} plus optional "
|
|
424
|
+
"recordActions / worksheetActions / paymentActions — the "
|
|
425
|
+
"shape 'app role permissions' shows.")
|
|
426
|
+
sheet_id = rule["id"]
|
|
427
|
+
if sheet_id not in by_id:
|
|
428
|
+
raise _rule_error(
|
|
429
|
+
i, f"worksheet {sheet_id!r} is not in this role's "
|
|
430
|
+
f"application.")
|
|
431
|
+
updated[sheet_id] = _apply_rule(updated.get(sheet_id) or
|
|
432
|
+
by_id[sheet_id], rule, i)
|
|
433
|
+
return [updated.get(s.get("sheetId"), s) if isinstance(s, dict) else s
|
|
434
|
+
for s in stored]
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
def _view_access(sheet: dict[str, Any]) -> list[tuple]:
|
|
438
|
+
return [(v.get("viewId"), bool(v.get("canRead")), bool(v.get("canEdit")),
|
|
439
|
+
bool(v.get("canRemove")))
|
|
440
|
+
for v in sheet.get("views") or [] if isinstance(v, dict)]
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
def _check_sheet_access_saved(session: Session, app_id: str, role_id: str,
|
|
444
|
+
sent: list[dict[str, Any]],
|
|
445
|
+
rules: list[dict[str, Any]]) -> None:
|
|
446
|
+
"""Re-read the role: the save answers success either way."""
|
|
447
|
+
named = {r.get("id") or r.get("sheetId") for r in rules
|
|
448
|
+
if isinstance(r, dict)}
|
|
449
|
+
after = get_role_detail(session, app_id, role_id)
|
|
450
|
+
stored = {s.get("sheetId"): s for s in
|
|
451
|
+
(after.get("sheets") if isinstance(after, dict) else None) or []
|
|
452
|
+
if isinstance(s, dict)}
|
|
453
|
+
wrong = [s.get("sheetName") or s.get("sheetId") for s in sent
|
|
454
|
+
if isinstance(s, dict) and s.get("sheetId") in named
|
|
455
|
+
and _view_access(stored.get(s.get("sheetId")) or {})
|
|
456
|
+
!= _view_access(s)]
|
|
457
|
+
if wrong:
|
|
458
|
+
logger.warning("role %s: worksheet access not saved for %s",
|
|
459
|
+
role_id, wrong)
|
|
460
|
+
raise ValueError(
|
|
461
|
+
f"The role was saved, but reading it back shows different "
|
|
462
|
+
f"access on: {', '.join(map(str, wrong))}. Check the role in "
|
|
463
|
+
f"the role editor.")
|
|
272
464
|
|
|
273
465
|
|
|
274
466
|
def set_role_chatbots(
|