176 lines
5.3 KiB
Python
176 lines
5.3 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""pbl_blueprint.m1b —— M1b 模板/子对象扩展与关联表子包。
|
||
|
||
自包含设计:本子包**只依赖标准库**,不 import pbl_common / pbl_blueprint.db,
|
||
因此无论公共内核处于何种迁移状态,M1b 功能面都可独立导入与运行
|
||
(QC 退回意见 #1「import 闭包断裂」的根治手段)。
|
||
|
||
同时本子包是 pbl_common.api / pbl_common.audit / pbl_common.crud_factory /
|
||
pbl_common.dbutil / pbl_blueprint.db / pbl_blueprint.api 缺失符号的**兼容供给层**:
|
||
tools/m1b_fix_import_closure.py 会把下列符号幂等回补到对应模块导出面。
|
||
|
||
子模块:
|
||
errors 错误码 + PblError 类族(PblNotFound/PblValidationError/...)
|
||
util new_id / now_str / json_dump / json_load
|
||
tenant require_tenant / normalize_tenant / assert_not_write_protected
|
||
dbutil sql_exec / sql_rows / sql_scalar / get_conn / table_exists
|
||
audit write_audit(append-only + 降级落盘)
|
||
crud_factory tenant_crud / crud_factory(租户打头 CRUD)
|
||
tables 4 张 M1b 表定义(单一事实来源,DDL 与 models JSON 同源)
|
||
subobject 7 类子对象泛化契约 + 扩展字段读写
|
||
ref 关联表判定(Q-OPEN-3:基表只读,无外键)
|
||
template 模板平台公共部分(tenant_id NULL)+ 实例化 + 离线兜底
|
||
api 对外接口(pbl_template_instantiate / pbl_blueprint_create 等)
|
||
init 建表 + 注册同步入口(load_m1b)
|
||
"""
|
||
|
||
from .errors import ( # noqa: F401
|
||
CODE_TO_HTTP,
|
||
ErrorCode,
|
||
PblConflict,
|
||
PblError,
|
||
PblForbidden,
|
||
PblNotFound,
|
||
PblValidationError,
|
||
TenantMissingError,
|
||
error_envelope,
|
||
raise_error,
|
||
)
|
||
from .util import ( # noqa: F401
|
||
json_dump,
|
||
json_load,
|
||
new_id,
|
||
now_str,
|
||
now_ts,
|
||
stable_code,
|
||
)
|
||
from .tenant import ( # noqa: F401
|
||
PLATFORM_TENANT,
|
||
allow_platform,
|
||
assert_not_write_protected,
|
||
normalize_tenant,
|
||
require_tenant,
|
||
tenant_scope,
|
||
)
|
||
from .dbutil import ( # noqa: F401
|
||
close_conn,
|
||
db_info,
|
||
get_conn,
|
||
list_tables,
|
||
reset_conn,
|
||
sql_exec,
|
||
sql_rows,
|
||
sql_scalar,
|
||
table_exists,
|
||
)
|
||
from .audit import write_audit, write_audit_batch, flush_memory_audit # noqa: F401
|
||
from .crud_factory import TenantCrud, crud_factory, tenant_crud # noqa: F401
|
||
from .tables import ( # noqa: F401
|
||
REF_KINDS,
|
||
SUBOBJECT_TYPES,
|
||
TABLES,
|
||
TEMPLATE_SCOPES,
|
||
field_names,
|
||
get_table,
|
||
table_names,
|
||
to_model_json,
|
||
)
|
||
from .subobject import ( # noqa: F401
|
||
SUBOBJECT_SPECS,
|
||
create_subobject,
|
||
delete_subobject,
|
||
get_ext,
|
||
get_subobject,
|
||
list_subobjects,
|
||
set_ext,
|
||
subobject_contract,
|
||
subobject_tree,
|
||
update_subobject,
|
||
validate_ext,
|
||
)
|
||
from .ref import ( # noqa: F401
|
||
assert_base_table_immutable,
|
||
list_refs,
|
||
ref_contract,
|
||
ref_summary,
|
||
resolve_ref,
|
||
)
|
||
from .template import ( # noqa: F401
|
||
create_template,
|
||
get_template,
|
||
instantiate_template,
|
||
list_templates,
|
||
load_offline_templates,
|
||
offline_template,
|
||
publish_template,
|
||
template_contract,
|
||
update_template,
|
||
)
|
||
from .api import ( # noqa: F401
|
||
M1B_API_REGISTRY,
|
||
pbl_blueprint_create,
|
||
pbl_blueprint_get,
|
||
pbl_blueprint_subobject_tree,
|
||
pbl_m1b_info,
|
||
pbl_ref_contract,
|
||
pbl_ref_list,
|
||
pbl_ref_resolve,
|
||
pbl_ref_summary,
|
||
pbl_subobject_contract,
|
||
pbl_subobject_create,
|
||
pbl_subobject_delete,
|
||
pbl_subobject_ext_get,
|
||
pbl_subobject_ext_set,
|
||
pbl_subobject_ext_validate,
|
||
pbl_subobject_get,
|
||
pbl_subobject_list,
|
||
pbl_subobject_update,
|
||
pbl_template_create,
|
||
pbl_template_get,
|
||
pbl_template_instantiate,
|
||
pbl_template_list,
|
||
pbl_template_offline,
|
||
pbl_template_publish,
|
||
pbl_template_update,
|
||
)
|
||
|
||
__version__ = "1.1.0"
|
||
__milestone__ = "M1b"
|
||
|
||
__all__ = [
|
||
"__version__", "__milestone__",
|
||
# errors
|
||
"ErrorCode", "CODE_TO_HTTP", "PblError", "PblValidationError", "PblNotFound",
|
||
"PblConflict", "PblForbidden", "TenantMissingError", "raise_error",
|
||
"error_envelope",
|
||
# util
|
||
"new_id", "now_str", "now_ts", "json_dump", "json_load", "stable_code",
|
||
# tenant
|
||
"PLATFORM_TENANT", "normalize_tenant", "require_tenant", "allow_platform",
|
||
"tenant_scope", "assert_not_write_protected",
|
||
# db
|
||
"get_conn", "close_conn", "reset_conn", "sql_exec", "sql_rows", "sql_scalar",
|
||
"table_exists", "list_tables", "db_info",
|
||
# audit
|
||
"write_audit", "write_audit_batch", "flush_memory_audit",
|
||
# crud
|
||
"tenant_crud", "crud_factory", "TenantCrud",
|
||
# tables
|
||
"TABLES", "SUBOBJECT_TYPES", "REF_KINDS", "TEMPLATE_SCOPES", "table_names",
|
||
"get_table", "field_names", "to_model_json",
|
||
# subobject
|
||
"SUBOBJECT_SPECS", "list_subobjects", "get_subobject", "create_subobject",
|
||
"update_subobject", "delete_subobject", "get_ext", "set_ext", "validate_ext",
|
||
"subobject_tree", "subobject_contract",
|
||
# ref
|
||
"resolve_ref", "list_refs", "ref_summary", "ref_contract",
|
||
"assert_base_table_immutable",
|
||
# template
|
||
"list_templates", "get_template", "create_template", "update_template",
|
||
"publish_template", "offline_template", "instantiate_template",
|
||
"load_offline_templates", "template_contract",
|
||
# api
|
||
"M1B_API_REGISTRY", "pbl_template_instantiate", "pbl_blueprint_create",
|
||
"pbl_m1b_info",
|
||
]
|