crawler4j-contracts
crawler4j-contracts 是 Core、SDK 与外部模块共享的稳定运行时契约包,当前源码版本基线为 0.4.5。
包含内容
- 提供
TaskContext/TaskResult/TaskOutcome/WorkflowLifecycleInfo等模块运行和生命周期契约 - 提供
ToolsCapability/ToolSpec/HttpClient等宿主扩展能力契约 - 提供
DatabaseClient,模块数据唯一正式入口为TaskContext.db - 提供 Hosted UI 页面 schema 类型
PageSchema及组件/action/CRUD TypedDict,并提供表格查询契约HostedDataTableQuery、泛型HostedDataTableQueryResult[RowT]、HostedDataTableSortSpec与QueryCallback,HostedDataTableQuery.to_query(...)可通过单字段search_transform/sort_transform/filter_transform把搜索、排序、分页和导航参数转换为 rows/count 查询回调,HostedDataTableQuery.to_result(...)与HostedDataTableQueryResult.from_query(...)可把仓储记录归一化为 UI 表格结果;query_handler不接收table_id,返回值不使用普通dict - Hosted UI
DataTable支持顶层selection_mode="multi"与 CRUDbulk_update_handler/toolbar.bulk_update,批量 handler 接收保序去重的主键数组和表单 payload;业务校验与数据库写入仍由模块负责 - Hosted UI
Input/Select与 CRUD Form 字段支持可选on_change={"type":"ui_action","name":...};handler 接收HostedFieldChangeEvent,Form scope 暴露短生命周期 opaqueform_id,模块可主动调用ui.form.reset(form_id, initial_values) - 提供
core-native-v2装饰器:@interface、@component、@workflow、@page、@page_action、@ui_action、@data_table、@data_view、@env_candidates、@env_cleanup_candidates - 提供
EnvCandidates链式环境候选查询 DSL,支持filter()、exclude()、intersect()、union()、minus()、order()、limit()与list(ctx) - 提供
EnvCandidateResult,让同步或异步候选函数把候选集合与最多 64 KiB 的 JSON-safe context 作为一次结果返回;选中环境后 workflow 从TaskContext.candidate_context读取该 context - 提供对象装配注解 helper:
object_param(...)、object_inject(...)。它们可用于 component 类属性或__init__参数注解,最终归一为ParameterSpec/InjectSpec object_param(...)支持string/text/integer/number/boolean/enum/array/object/json/date/datetime/time/url/path/secret,并可通过schema/item_schema描述object与array的结构;Literal[...]、list[T]、dict[str, T]、Optional[T]、datetime类型和pathlib.Path可被运行时注解推断TaskSpec/WorkflowSpec/EnvSelectorSpec/PageSpec已从 contracts 包移除;0.4.x 模块只能使用 v2 装饰器声明运行能力和页面- 不内置调度器、执行器、环境管理器、HTTP 客户端或其他第三方宿主适配器
TaskSignal/TaskSignalAction/EnvAction已从 contracts 移除;模块代码不得导入或发送这些流程/环境控制对象TaskContext只保留少量与契约紧耦合的辅助方法(如等待、停止状态记录、run_page_action执行器入口);截图等浏览器副作用由 Core 或宿主工具提供TaskContext.http为可选注入能力;contracts 包本身不再内置 aiohttp 风格默认实现- 供
crawler4j、crawler4j-sdk与标准模块共同依赖
模块运行时代码只应依赖本包。crawler4j-sdk 只作为开发依赖提供 CLI、脚手架、校验和打包辅助,不提供运行时 owner、TaskScript / TaskFlow、旧环境选择器或资源池 helper。
Hosted UI 用户按钮、CRUD handler 和表单提交使用 @ui_action;Hosted UI schema 不接受 Button.action.type="page_action"。DataTable CRUD handler 的 create/update/delete 入参必须是确定签名,payload 应使用模块自定义 TypedDict / dataclass 风格输入类型,不要用 Mapping[str, Any] 或裸 dict。浏览器页面自动化使用 @page_action,并由 workflow/component 通过 ctx.run_page_action(...) 调用。@page_action 不是内部拆分单元,不能在另一个 @page_action 中嵌套调用。
非数据库类宿主能力继续通过 TaskContext.tools 调用。环境选择统一声明为 candidates/*.py 中的 @env_candidates 同步或异步只读函数;它可返回 env id 列表、EnvCandidates 或 EnvCandidateResult。候选 surface 只提供只读模块数据和宿主管理的异步 http.request,不提供浏览器或环境写入工具。结构化 context 经 JSON-safe/64 KiB 校验后,只在成功选中环境时注入 TaskContext.candidate_context;旧返回值、固定环境和创建环境路径为 None,空候选不启动 workflow。账号状态、黑号、注册时间和会员等级等过滤由候选函数实时读取模块数据表完成,不使用资源池同步快照。需要被宿主识别为“已认领环境”的业务表必须通过 @data_table(..., env_binding_field="env_id") 声明绑定字段。批量环境清理候选统一声明为 cleanups/*.py 中的 @env_cleanup_candidates 同步纯函数,复用 EnvCandidates 查询 DSL,但只表达已绑定且业务上可丢弃的 env id,实际删除由宿主环境管理页预览确认和安全校验后执行;模块 workflow 不能通过运行结果指定环境处置。workflow/component 可选实现 setup(ctx, workflow) 做运行前准备,可选实现 cleanup(ctx, outcome) 做终态收尾;workflow 为当前 workflow 元信息,outcome.workflow 保存同一份信息,outcome.status 为 succeeded、failed、timed_out 或 cancelled。
Metadata
Release files for crawler4j-contracts 0.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| crawler4j_contracts-0.4.5.tar.gz | 37.0 kB | Without provenance | Details for crawler4j_contracts-0.4.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| crawler4j_contracts-0.4.5-py3-none-any.whl | Python 3 | none | any | Details for crawler4j_contracts-0.4.5-py3-none-any.whl |
Total release size: 74.2 kB
Release files / crawler4j_contracts-0.4.5.tar.gz
| Download URL | crawler4j_contracts-0.4.5.tar.gz |
|---|---|
| Size | 37.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e213c127879a243a1d9c7558a547df3dd196745ca6d191899782351983e6d066
|
|
BLAKE2b-256 checksum How to use checksums |
ffee14e7ce6fb944214afbec6006115dfd6205281de95219b82f9c7fc130014e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / crawler4j_contracts-0.4.5-py3-none-any.whl
| Download URL | crawler4j_contracts-0.4.5-py3-none-any.whl |
|---|---|
| Size | 37.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f79f2fd4f8a109527a9f0c11bdbc16c414366aae583955ca7b73c84fa81b618
|
|
BLAKE2b-256 checksum How to use checksums |
67f724ae0bfec9112d9b46e2dde71c0815037cd71a5c33cf42185efa4eca5639
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for crawler4j-contracts 0.4.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.