Compare commits
2 Commits
1142e90a35
...
5c7c039e52
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c7c039e52 | |||
| 9f3e34e81a |
@@ -0,0 +1,724 @@
|
||||
# 埋点系统新增周、月、季、年维度映射表计划
|
||||
|
||||
## 目标
|
||||
|
||||
在 Genarrative 的埋点/统计系统中新增“周、月、季、年”维度映射表,让后续统计查询可以按不同时间粒度稳定聚合,而不是只依赖运行时临时计算日期范围。
|
||||
|
||||
本计划只做设计与落地步骤,不直接修改业务代码。
|
||||
|
||||
## 当前上下文与初步发现
|
||||
|
||||
1. 当前仓库根目录为 `/home/dsk/workspace/Genarrative`。
|
||||
2. 远端更新后已定位到当前真实埋点/任务系统:
|
||||
- 原始埋点表:`tracking_event`
|
||||
- 日聚合投影表:`tracking_daily_stat`
|
||||
- 任务配置表:`profile_task_config`
|
||||
- 任务进度表:`profile_task_progress`
|
||||
- 领奖记录表:`profile_task_reward_claim`
|
||||
3. 相关文件:
|
||||
- `server-rs/crates/spacetime-module/src/runtime/profile.rs`
|
||||
- `server-rs/crates/module-runtime/src/domain.rs`
|
||||
- `server-rs/crates/module-runtime/src/application.rs`
|
||||
- `server-rs/crates/api-server/src/runtime_profile.rs`
|
||||
- `apps/admin-web/src/pages/AdminTaskConfigPage.tsx`
|
||||
- `apps/admin-web/src/api/adminApiTypes.ts`
|
||||
- `apps/admin-web/src/config/trackingEventDefinitions.ts`
|
||||
- `docs/technical/PROFILE_TASK_AND_TRACKING_SYSTEM_2026-05-03.md`
|
||||
- `docs/tracking/TRACKING_QUERY_PLAYBOOK_2026-05-03.md`
|
||||
4. 当前 `tracking_event` 是明细表,`tracking_daily_stat` 是统一日汇总表,不按范围拆表;它通过 `event_key + scope_kind + scope_id + day_key` 区分不同聚合桶。
|
||||
5. 当前任务系统是“个人任务系统”,首版任务配置均面向用户维度;后台暴露“埋点范围”选择会导致运营误配。
|
||||
6. 已决定采用任务配置方案 B:
|
||||
- 后台任务配置不再让运营手动选择埋点范围。
|
||||
- 后端个人任务配置统一限制为 `RuntimeTrackingScopeKind::User`。
|
||||
- 若 API 收到非 `user` 的 `scopeKind`,应拒绝或兼容忽略但最终落库必须为 `User`;推荐直接拒绝并返回清晰错误。
|
||||
7. 已发现一个需要纳入本计划修复的语义问题:`profile_task_tracking_scope_id` 里 `RuntimeTrackingScopeKind::Work` 当前返回 `user_id`,这不符合 work 维度语义。即使个人任务暂不支持 work,也应避免错误映射继续存在。
|
||||
8. 当前日期桶使用北京时间自然日:`day_key = floor((occurred_at_micros + 8h) / 1d)`;周/月/季/年映射表应优先沿用这一业务日口径,除非产品另行确认。
|
||||
9. 如果新增正式后端表,需要同步:
|
||||
- 表定义
|
||||
- reducer/procedure
|
||||
- migration.rs
|
||||
- 生成绑定
|
||||
- spacetime-client facade
|
||||
- shared-contracts / API DTO,如有接口暴露
|
||||
|
||||
## 关键假设
|
||||
|
||||
在未定位现有埋点模块前,先按以下假设规划:
|
||||
|
||||
1. 当前已有某种事件明细表或统计事实表,例如:
|
||||
- `telemetry_event`
|
||||
- `analytics_event`
|
||||
- `metric_event`
|
||||
- `narrative_telemetry`
|
||||
- 或类似命名
|
||||
2. 新增的“映射表”用于把具体日期或事件时间映射到时间维度 bucket。
|
||||
3. 映射维度包括:
|
||||
- 周:week
|
||||
- 月:month
|
||||
- 季:quarter
|
||||
- 年:year
|
||||
4. 已明确选择“一张通用日期维度映射表”方案:`analytics_date_dimension`。
|
||||
5. 统计口径需要明确:
|
||||
- 周从周一还是周日开始
|
||||
- 是否使用 ISO week
|
||||
- 季度是自然季度还是财务季度
|
||||
- 时区使用 UTC 还是业务本地时区
|
||||
|
||||
## 推荐设计方向
|
||||
|
||||
### 方案 A:单一时间维度映射表,推荐
|
||||
|
||||
新增一张日历维度表,每一行对应一个自然日,并包含它归属的周、月、季、年。
|
||||
|
||||
表概念:
|
||||
|
||||
```text
|
||||
analytics_date_dimension
|
||||
```
|
||||
|
||||
建议字段:
|
||||
|
||||
```text
|
||||
date_key string 例如 2026-05-04
|
||||
calendar_date string 真实日期,按 YYYY-MM-DD 存储
|
||||
weekday u8 1-7 或 0-6,需要统一约定
|
||||
iso_week_key string 例如 2026-W19
|
||||
week_start_date_key string 例如 2026-05-04
|
||||
week_end_date_key string 例如 2026-05-10
|
||||
month_key string 例如 2026-05
|
||||
month_start_date_key string
|
||||
month_end_date_key string
|
||||
quarter_key string 例如 2026-Q2
|
||||
year_key string 例如 2026
|
||||
created_at timestamp/string
|
||||
updated_at timestamp/string
|
||||
```
|
||||
|
||||
优点:
|
||||
|
||||
- 一张表即可支持日、周、月、季、年映射。
|
||||
- 便于后续新增半月、财年、节假日、自然周等维度。
|
||||
- 查询逻辑简单:事件日期 join/date_key 映射到目标粒度。
|
||||
- 数据量很小,按 20 年也只有约 7300 行。
|
||||
|
||||
缺点:
|
||||
|
||||
- 需要在事件时间写入或统计查询时把 timestamp 归一为 date_key。
|
||||
- 如果要支持多时区,可能需要增加 timezone 字段或多套 calendar。
|
||||
|
||||
### 方案 B:四张独立映射表
|
||||
|
||||
分别新增:
|
||||
|
||||
```text
|
||||
analytics_week_dimension
|
||||
analytics_month_dimension
|
||||
analytics_quarter_dimension
|
||||
analytics_year_dimension
|
||||
```
|
||||
|
||||
优点:
|
||||
|
||||
- 每个粒度表结构更纯粹。
|
||||
- 查询时可以直接针对目标粒度表。
|
||||
|
||||
缺点:
|
||||
|
||||
- 表更多,维护复杂。
|
||||
- 日期归属关系仍然需要额外处理。
|
||||
- 容易出现周/月/季/年口径漂移。
|
||||
|
||||
### 最终选择
|
||||
|
||||
本计划采用方案 A:单一 `analytics_date_dimension` 日期维表,而不是四张独立映射表。
|
||||
|
||||
如业务未来明确要求“周、月、季、年各自有独立映射表”,也应优先在日期维表基础上派生视图或物化派生表,而不是一开始拆成四张重复表。
|
||||
|
||||
## 后端设计建议
|
||||
|
||||
### 1. 明确埋点领域归属
|
||||
|
||||
先定位现有埋点模块。如果没有独立模块,建议新增或归入:
|
||||
|
||||
```text
|
||||
server-rs/crates/module-analytics/
|
||||
```
|
||||
|
||||
或如果当前项目已有 telemetry 命名,则保持已有命名,例如:
|
||||
|
||||
```text
|
||||
server-rs/crates/module-telemetry/
|
||||
```
|
||||
|
||||
领域层职责:
|
||||
|
||||
- 时间粒度定义
|
||||
- date_key/week_key/month_key/quarter_key/year_key 生成规则
|
||||
- 时间维度校验
|
||||
- 事件聚合查询输入的纯规则
|
||||
|
||||
不应包含:
|
||||
|
||||
- SpacetimeDB 表读写
|
||||
- Axum handler
|
||||
- HTTP response
|
||||
|
||||
### 2. SpacetimeDB 表设计
|
||||
|
||||
在 `spacetime-module` 中新增时间维度表。
|
||||
|
||||
建议表名:
|
||||
|
||||
```text
|
||||
analytics_date_dimension
|
||||
```
|
||||
|
||||
建议主键:
|
||||
|
||||
```text
|
||||
date_key
|
||||
```
|
||||
|
||||
建议索引:
|
||||
|
||||
```text
|
||||
iso_week_key
|
||||
month_key
|
||||
quarter_key
|
||||
year_key
|
||||
```
|
||||
|
||||
如果 SpacetimeDB 表定义已有统一命名规范,应按现有规范命名。
|
||||
|
||||
### 3. 初始化/补全 reducer
|
||||
|
||||
新增 reducer 或内部 procedure,用于生成指定日期范围内的维度数据。
|
||||
|
||||
建议能力:
|
||||
|
||||
```text
|
||||
seed_analytics_date_dimensions(start_date, end_date)
|
||||
ensure_analytics_date_dimension_for_date(date_key)
|
||||
ensure_analytics_date_dimensions_for_range(start_date, end_date)
|
||||
```
|
||||
|
||||
设计原则:
|
||||
|
||||
- 可幂等执行。
|
||||
- 已存在 date_key 时不重复插入。
|
||||
- 支持一次补一段日期。
|
||||
- 避免一次补太大范围导致事务过重。
|
||||
- 生产环境建议按年份或月份分批。
|
||||
|
||||
### 4. 事件表和映射表关系
|
||||
|
||||
如果事件表目前只有 timestamp,建议新增或计算出:
|
||||
|
||||
```text
|
||||
event_date_key
|
||||
```
|
||||
|
||||
可选策略:
|
||||
|
||||
1. 写入事件时同步写 `event_date_key`。
|
||||
2. 查询统计时从 timestamp 临时计算 date_key。
|
||||
3. 后台迁移为历史事件补 `event_date_key`。
|
||||
|
||||
推荐:
|
||||
|
||||
- 新事件写入时保存 `event_date_key`。
|
||||
- 历史事件通过批量迁移 reducer 分批补齐。
|
||||
|
||||
### 5. 聚合查询设计
|
||||
|
||||
支持按粒度查询时,API 或 facade 可以接收:
|
||||
|
||||
```text
|
||||
granularity = day | week | month | quarter | year
|
||||
start_date
|
||||
end_date
|
||||
metric/event_name
|
||||
filters
|
||||
```
|
||||
|
||||
内部根据粒度选择 bucket key:
|
||||
|
||||
```text
|
||||
day -> date_key
|
||||
week -> iso_week_key 或 week_key
|
||||
month -> month_key
|
||||
quarter -> quarter_key
|
||||
year -> year_key
|
||||
```
|
||||
|
||||
返回结构建议统一:
|
||||
|
||||
```text
|
||||
bucket_key
|
||||
bucket_label
|
||||
bucket_start_date
|
||||
bucket_end_date
|
||||
value
|
||||
```
|
||||
|
||||
## 可能涉及的文件
|
||||
|
||||
由于当前尚未定位明确埋点模块,以下是预计文件范围。
|
||||
|
||||
### 必查文件/目录
|
||||
|
||||
```text
|
||||
./Genarrative/server-rs/crates/
|
||||
./Genarrative/server-rs/crates/spacetime-module/src/
|
||||
./Genarrative/server-rs/crates/spacetime-client/src/
|
||||
./Genarrative/server-rs/crates/shared-contracts/src/
|
||||
./Genarrative/server-rs/crates/api-server/src/
|
||||
./Genarrative/packages/shared/src/contracts/
|
||||
./Genarrative/src/services/
|
||||
```
|
||||
|
||||
### 可能新增文件
|
||||
|
||||
如果采用 analytics 命名:
|
||||
|
||||
```text
|
||||
server-rs/crates/module-analytics/src/domain.rs
|
||||
server-rs/crates/module-analytics/src/commands.rs
|
||||
server-rs/crates/module-analytics/src/application.rs
|
||||
server-rs/crates/module-analytics/src/errors.rs
|
||||
server-rs/crates/module-analytics/src/events.rs
|
||||
server-rs/crates/shared-contracts/src/analytics.rs
|
||||
server-rs/crates/spacetime-client/src/analytics.rs
|
||||
server-rs/crates/api-server/src/analytics.rs
|
||||
packages/shared/src/contracts/analytics.ts
|
||||
```
|
||||
|
||||
如果只是新增 SpacetimeDB 映射表且暂不暴露 API,则可能只需:
|
||||
|
||||
```text
|
||||
server-rs/crates/spacetime-module/src/**
|
||||
server-rs/crates/spacetime-module/src/migration.rs
|
||||
server-rs/crates/spacetime-client/src/** # 如果查询会被 api-server 使用
|
||||
```
|
||||
|
||||
## 详细实施步骤
|
||||
|
||||
### Step 1:复核现有埋点系统与任务配置链路
|
||||
|
||||
当前已定位真实链路,实施前再做一次只读复核,确认远端最新代码没有继续变化。
|
||||
|
||||
已知核心表:
|
||||
|
||||
```text
|
||||
tracking_event # 原始埋点明细
|
||||
tracking_daily_stat # 日聚合投影
|
||||
profile_task_config # 个人任务配置
|
||||
profile_task_progress # 个人任务进度
|
||||
profile_task_reward_claim # 领奖记录
|
||||
```
|
||||
|
||||
已知核心文件:
|
||||
|
||||
```text
|
||||
server-rs/crates/spacetime-module/src/runtime/profile.rs
|
||||
server-rs/crates/module-runtime/src/domain.rs
|
||||
server-rs/crates/module-runtime/src/application.rs
|
||||
server-rs/crates/api-server/src/runtime_profile.rs
|
||||
apps/admin-web/src/pages/AdminTaskConfigPage.tsx
|
||||
apps/admin-web/src/api/adminApiTypes.ts
|
||||
apps/admin-web/src/config/trackingEventDefinitions.ts
|
||||
docs/technical/PROFILE_TASK_AND_TRACKING_SYSTEM_2026-05-03.md
|
||||
docs/tracking/TRACKING_QUERY_PLAYBOOK_2026-05-03.md
|
||||
```
|
||||
|
||||
重点确认:
|
||||
|
||||
1. `tracking_event` 是否仍包含 `event_key/scope_kind/scope_id/day_key/user_id/occurred_at`。
|
||||
2. `tracking_daily_stat` 是否仍按 `event_key + scope_kind + scope_id + day_key` 生成 `stat_id`。
|
||||
3. `profile_task_config` 是否仍包含 `scope_kind` 和 `sort_order`。
|
||||
4. 后台 `AdminTaskConfigPage` 是否仍暴露“埋点范围”下拉。
|
||||
5. `profile_task_tracking_scope_id` 中 `Work => user_id` 的错误映射是否仍存在。
|
||||
|
||||
### Step 1.5:先收紧个人任务配置的埋点范围,采用方案 B
|
||||
|
||||
在做周/月/季/年维度映射前,先修正个人任务配置边界,避免后续在错误配置模型上继续扩展。
|
||||
|
||||
目标行为:
|
||||
|
||||
```text
|
||||
个人任务配置只支持用户维度埋点。
|
||||
后台页面不再展示“埋点范围”。
|
||||
后端不允许 profile_task_config 被写入 site/work/module 维度。
|
||||
```
|
||||
|
||||
建议实现:
|
||||
|
||||
1. 前端隐藏 `AdminTaskConfigPage` 的“埋点范围”选择。
|
||||
- 文件:`apps/admin-web/src/pages/AdminTaskConfigPage.tsx`
|
||||
- 移除或隐藏:`scopeKinds` 下拉 UI。
|
||||
- 保存请求仍可兼容传 `scopeKind: 'user'`,避免一次性改动 API contract。
|
||||
2. 后端 upsert 校验 `scopeKind` 必须为 `RuntimeTrackingScopeKind::User`。
|
||||
- 文件:`server-rs/crates/api-server/src/runtime_profile.rs`
|
||||
- 或更底层:`server-rs/crates/module-runtime/src/domain.rs` / `server-rs/crates/spacetime-module/src/runtime/profile.rs` 的输入构造函数。
|
||||
- 推荐在领域输入构造处兜底校验,API 层返回清晰错误。
|
||||
3. 若暂不改 API DTO,则保持字段存在但限定值只能是 `user`。
|
||||
- 文件:`apps/admin-web/src/api/adminApiTypes.ts`
|
||||
- `AdminUpsertProfileTaskConfigRequest.scopeKind` 可保留,前端固定传 `user`。
|
||||
4. 更新后台埋点定义注册表的语义:
|
||||
- 文件:`apps/admin-web/src/config/trackingEventDefinitions.ts`
|
||||
- 当前每个 event definition 包含 `scopeKind`,如果个人任务统一 `user`,可以保留为只读内部默认值;但不要让运营在页面改。
|
||||
5. 更新技术文档:
|
||||
- `docs/technical/PROFILE_TASK_AND_TRACKING_SYSTEM_2026-05-03.md`
|
||||
- 明确“个人任务首版只支持用户维度埋点,后台不开放 scope_kind 配置”。
|
||||
|
||||
验收:
|
||||
|
||||
```text
|
||||
后台任务配置页不再出现“埋点范围”选择。
|
||||
保存 daily_login 后落库 scope_kind 仍为 User。
|
||||
直接调用后台 upsert 接口传 site/work/module 时被拒绝,或最终不会落库为非 User;推荐拒绝。
|
||||
```
|
||||
|
||||
### Step 1.6:修复 Work 范围错误返回 user_id 的语义问题
|
||||
|
||||
当前函数:
|
||||
|
||||
```text
|
||||
server-rs/crates/spacetime-module/src/runtime/profile.rs
|
||||
profile_task_tracking_scope_id(user_id, config)
|
||||
```
|
||||
|
||||
当前问题:
|
||||
|
||||
```rust
|
||||
RuntimeTrackingScopeKind::Work => user_id.to_string()
|
||||
```
|
||||
|
||||
这会把 work 维度错误映射为用户 ID。虽然个人任务将限制为 User,但保留这个分支会误导后续扩展。
|
||||
|
||||
推荐修复策略:
|
||||
|
||||
1. 对个人任务进度计算来说,`Work` 不应进入该函数。
|
||||
2. 将 `profile_task_tracking_scope_id` 改为返回 `Result<String, String>` 或 `Option<String>`。
|
||||
3. 对不支持的范围返回错误,而不是伪造 scope_id:
|
||||
|
||||
```text
|
||||
Site -> "site",如果个人任务仍不允许 site,则上游先拒绝
|
||||
Module -> "profile",如果个人任务仍不允许 module,则上游先拒绝
|
||||
User -> user_id
|
||||
Work -> error: personal task progress does not support work scope without work_id
|
||||
```
|
||||
|
||||
更严格的推荐:
|
||||
|
||||
```text
|
||||
个人任务链路只接受 User。
|
||||
Work/Site/Module 在 profile_task_progress_count 前就被拒绝。
|
||||
profile_task_tracking_scope_id 只保留 User 分支,或者非 User 返回错误。
|
||||
```
|
||||
|
||||
需要同步调整调用点:
|
||||
|
||||
```text
|
||||
profile_task_progress_count
|
||||
refresh_profile_task_progress
|
||||
build_profile_task_center_snapshot
|
||||
claim_profile_task_reward
|
||||
```
|
||||
|
||||
避免因为函数返回 `Result` 后调用链未处理错误。
|
||||
|
||||
验收:
|
||||
|
||||
```text
|
||||
不存在 Work => user_id 的映射。
|
||||
个人任务配置非 User 时不会静默算出错误进度。
|
||||
相关测试覆盖:User 正常;Work/Site/Module 被拒绝。
|
||||
|
||||
```
|
||||
|
||||
### Step 2:确定时间口径
|
||||
|
||||
必须先确认:
|
||||
|
||||
1. 周维度是否使用 ISO week。
|
||||
2. 周开始日是周一还是周日。
|
||||
3. 月/季/年是否按自然日历。
|
||||
4. 统计时区是 UTC、服务器时区,还是用户本地时区。
|
||||
5. 跨年周如何命名,例如 `2025-W01` 可能开始于 2024 年末。
|
||||
|
||||
推荐默认:
|
||||
|
||||
```text
|
||||
时区:UTC,除非产品明确要求中国时区
|
||||
周:ISO week,周一开始
|
||||
月:自然月
|
||||
季:自然季度
|
||||
年:自然年
|
||||
```
|
||||
|
||||
如果业务面向国内用户,建议考虑:
|
||||
|
||||
```text
|
||||
时区:Asia/Shanghai
|
||||
周:周一开始
|
||||
```
|
||||
|
||||
### Step 3:设计 date dimension 表
|
||||
|
||||
设计字段和 key 格式,写入技术文档。
|
||||
|
||||
建议 key 格式:
|
||||
|
||||
```text
|
||||
date_key: 2026-05-04
|
||||
week_key: 2026-W19
|
||||
month_key: 2026-05
|
||||
quarter_key: 2026-Q2
|
||||
year_key: 2026
|
||||
```
|
||||
|
||||
注意:
|
||||
|
||||
- `week_key` 建议使用 ISO week-year,不一定等于 calendar year。
|
||||
- `quarter_key` 使用 calendar year。
|
||||
|
||||
### Step 4:新增领域纯函数
|
||||
|
||||
在领域层或 shared-kernel 中实现纯函数:
|
||||
|
||||
```text
|
||||
resolve_date_dimension(date, timezone) -> AnalyticsDateDimension
|
||||
resolve_bucket_key(date_dimension, granularity) -> String
|
||||
resolve_bucket_range(bucket_key, granularity) -> start/end date
|
||||
```
|
||||
|
||||
要求:
|
||||
|
||||
- 有单元测试。
|
||||
- 覆盖跨年周。
|
||||
- 覆盖闰年 2 月。
|
||||
- 覆盖季度边界。
|
||||
|
||||
### Step 5:新增 SpacetimeDB 表
|
||||
|
||||
在 `spacetime-module` 中新增表。
|
||||
|
||||
遵守约束:
|
||||
|
||||
- 新增表通常安全。
|
||||
- 不修改已有表字段。
|
||||
- 如果必须给已有事件表加 `event_date_key`,必须加在表定义末尾并提供 default。
|
||||
- 若要补历史数据,使用 reducer 分批迁移。
|
||||
|
||||
### Step 6:新增 seed/ensure reducer
|
||||
|
||||
新增幂等 reducer:
|
||||
|
||||
```text
|
||||
seed_analytics_date_dimensions(start_date, end_date)
|
||||
ensure_analytics_date_dimension_for_date(date_key)
|
||||
```
|
||||
|
||||
验证点:
|
||||
|
||||
- 重复执行不会重复插入。
|
||||
- 日期范围非法时返回稳定错误。
|
||||
- 单次范围过大时拒绝或分页。
|
||||
|
||||
### Step 7:接入事件写入链路
|
||||
|
||||
如果现有事件写入链路存在,新增:
|
||||
|
||||
```text
|
||||
event_date_key
|
||||
```
|
||||
|
||||
策略:
|
||||
|
||||
- 新事件写入时同步计算并保存。
|
||||
- 写入前确保对应 date dimension 存在。
|
||||
- 历史事件通过迁移 reducer 补齐。
|
||||
|
||||
如果暂不改事件表,也可以在查询阶段临时映射,但性能和一致性较差。
|
||||
|
||||
### Step 8:接入聚合查询
|
||||
|
||||
如已有统计接口,扩展请求参数:
|
||||
|
||||
```text
|
||||
granularity: day | week | month | quarter | year
|
||||
```
|
||||
|
||||
查询逻辑改为:
|
||||
|
||||
```text
|
||||
事件/事实表
|
||||
→ event_date_key
|
||||
→ analytics_date_dimension
|
||||
→ 取对应 bucket key
|
||||
→ group by bucket key
|
||||
```
|
||||
|
||||
返回 bucket 时包含:
|
||||
|
||||
```text
|
||||
bucket_key
|
||||
bucket_start_date
|
||||
bucket_end_date
|
||||
value
|
||||
```
|
||||
|
||||
### Step 9:补 shared contracts 和前端 contracts
|
||||
|
||||
如果有 API 暴露,需要补:
|
||||
|
||||
```text
|
||||
server-rs/crates/shared-contracts/src/analytics.rs
|
||||
packages/shared/src/contracts/analytics.ts
|
||||
```
|
||||
|
||||
建议 DTO:
|
||||
|
||||
```text
|
||||
AnalyticsGranularity = day | week | month | quarter | year
|
||||
AnalyticsBucketMetric
|
||||
AnalyticsMetricQueryRequest
|
||||
AnalyticsMetricQueryResponse
|
||||
```
|
||||
|
||||
### Step 10:补测试
|
||||
|
||||
测试范围:
|
||||
|
||||
1. 领域日期映射测试
|
||||
2. SpacetimeDB reducer 幂等测试
|
||||
3. API 查询维度测试
|
||||
4. 历史事件迁移测试,如涉及
|
||||
5. 跨边界日期测试
|
||||
6. 个人任务配置 scope 限制测试
|
||||
7. `Work => user_id` 错误映射回归测试
|
||||
|
||||
重点用例:
|
||||
|
||||
```text
|
||||
2024-02-29 闰年
|
||||
2025-12-29 ISO week 可能属于 2026-W01
|
||||
2026-01-01 跨年周
|
||||
2026-03-31 Q1 结束
|
||||
2026-04-01 Q2 开始
|
||||
2026-12-31 年末
|
||||
```
|
||||
|
||||
任务配置重点用例:
|
||||
|
||||
```text
|
||||
admin upsert daily_login + scopeKind=user -> 成功
|
||||
admin upsert daily_login + scopeKind=site -> 失败,错误信息说明个人任务仅支持 user
|
||||
admin upsert daily_login + scopeKind=module -> 失败
|
||||
admin upsert daily_login + scopeKind=work -> 失败
|
||||
任务中心读取 daily_login -> 按 User + 当前 user_id 查询进度
|
||||
代码中不存在 Work => user_id 的静默映射
|
||||
```
|
||||
|
||||
## 测试与验证命令
|
||||
|
||||
具体命令需在定位模块后确认。初步建议:
|
||||
|
||||
```text
|
||||
npm run typecheck
|
||||
npm test
|
||||
```
|
||||
|
||||
后端如涉及 Rust:
|
||||
|
||||
```text
|
||||
cargo test -p module-analytics
|
||||
cargo test -p spacetime-module
|
||||
cargo test -p api-server
|
||||
```
|
||||
|
||||
涉及 API smoke:
|
||||
|
||||
```text
|
||||
npm run api-server
|
||||
```
|
||||
|
||||
然后验证:
|
||||
|
||||
```text
|
||||
GET /healthz
|
||||
```
|
||||
|
||||
涉及 SpacetimeDB schema:
|
||||
|
||||
- 需要生成绑定。
|
||||
- 需要确认 migration.rs 对齐。
|
||||
- 需要确认 publish 不触发不安全 schema 变更。
|
||||
|
||||
## 风险与权衡
|
||||
|
||||
### 风险 1:个人任务 scope_kind 被误配置导致进度异常
|
||||
|
||||
当前个人任务系统本质上按用户维度计算进度。如果允许运营配置 `site/work/module`,可能导致任务进度查错 `tracking_daily_stat` 聚合桶,出现任务永远不可领取或错误可领取。
|
||||
|
||||
缓解:
|
||||
|
||||
```text
|
||||
采用方案 B:后台隐藏埋点范围,后端限制个人任务配置只能写入 User。
|
||||
```
|
||||
|
||||
### 风险 2:Work 维度缺少 work_id,上游却静默用 user_id 代替
|
||||
|
||||
当前 `profile_task_tracking_scope_id` 中 `Work => user_id` 是错误语义。若后续扩展作品任务,会把作品维度统计错误映射到用户维度。
|
||||
|
||||
缓解:
|
||||
|
||||
```text
|
||||
移除 Work => user_id 映射;非 User 的个人任务配置应被拒绝。未来做作品任务时新增明确 work_id 来源和任务类型。
|
||||
```
|
||||
|
||||
### 风险 3:时区口径影响统计结果
|
||||
|
||||
周/月/季/年映射对时区敏感。当前日桶使用北京时间自然日:`floor((occurred_at_micros + 8h) / 1d)`。新增映射表应明确沿用北京时间业务日,还是切换为 UTC/用户本地时区。
|
||||
|
||||
### 风险 4:ISO week 跨年
|
||||
|
||||
ISO week-year 与自然年不同。若前端展示按自然年理解,可能产生认知差异。
|
||||
|
||||
### 风险 5:修改已有事件表可能触发 SpacetimeDB 迁移限制
|
||||
|
||||
如果已有事件表需要新增字段:
|
||||
|
||||
- 字段必须加末尾。
|
||||
- 必须提供 default。
|
||||
- 历史数据要分批迁移。
|
||||
|
||||
### 风险 5:表设计过早绑定单一业务
|
||||
|
||||
建议用通用 date dimension,而不是为某个单一埋点写死周/月/季/年表,避免后续复用困难。
|
||||
|
||||
## 待确认问题
|
||||
|
||||
1. 周维度使用 ISO week 还是自然周?周一开始还是周日开始?
|
||||
2. 周/月/季/年映射是否沿用当前北京时间业务日口径?
|
||||
3. 这个映射表服务的是所有埋点,还是只服务个人任务/运营后台统计?
|
||||
4. 是否需要 API 暴露这些映射关系,还是只用于后端聚合?
|
||||
5. 是否需要回填历史事件?历史数据规模多大?
|
||||
6. 未来是否会存在非个人任务,例如整站任务、模块任务、作品任务?如果会,应另行设计任务类型和 `scope_id` 来源,不应复用当前个人任务配置页直接开放 scope。
|
||||
|
||||
## 建议结论
|
||||
|
||||
优先采用“一张通用日期维度映射表”的设计:
|
||||
|
||||
```text
|
||||
analytics_date_dimension
|
||||
```
|
||||
|
||||
通过字段同时提供:
|
||||
|
||||
```text
|
||||
day / week / month / quarter / year
|
||||
```
|
||||
|
||||
后续统计按 `granularity` 选择 bucket key 聚合。这样比直接新增四张独立映射表更稳定、更容易复用,也更容易处理跨年周、季度边界和历史回填。
|
||||
@@ -0,0 +1,271 @@
|
||||
# 邀请码有效期与后台二次确认实施计划
|
||||
|
||||
> **For Hermes:** 按 plan 模式,仅输出并保存实施计划,不直接改业务代码。
|
||||
|
||||
**Goal:** 为邀请码新增开始日期与截止日期,并让后台所有会修改数据的操作在提交前增加二次确认,降低误操作风险。
|
||||
|
||||
**Architecture:**
|
||||
邀请码仍作为“用户稳定邀请身份码”保留,不做停用删除;在数据层增加 `starts_at` / `expires_at`,前台填写邀请码时按时间窗校验,后台列表与编辑页展示状态。后台所有写操作统一先弹二次确认,再真正调用 API,避免对兑换码、邀请码、任务配置等管理动作误触发。
|
||||
|
||||
**Tech Stack:**
|
||||
Rust / SpacetimeDB / Axum / shared-contracts / TS + React 的 admin-web。
|
||||
|
||||
---
|
||||
|
||||
## 当前上下文
|
||||
|
||||
- 邀请码当前只有 `user_id`、`invite_code`、`metadata_json`、`created_at`、`updated_at`,没有状态字段。
|
||||
- 目前后台存在邀请码管理入口,但没有停用能力,也没有有效期概念。
|
||||
- 邀请码用于 `redeem_profile_referral_invite_code` 时的实时校验,适合增加“时间窗”而不是“禁用删除”。
|
||||
- 后台已存在兑换码、任务配置等可写操作;本次要求把所有后台操作统一加二次确认,包括新增、编辑、禁用、删除等写入口。
|
||||
|
||||
---
|
||||
|
||||
## 设计原则
|
||||
|
||||
1. **邀请码不做软删除**:保留历史记录和邀请链路。
|
||||
2. **有效期由时间窗推导**:
|
||||
- `starts_at` 为空表示立即生效。
|
||||
- `expires_at` 为空表示长期有效。
|
||||
3. **前台只拒绝新绑定**:已绑定关系不回溯修改。
|
||||
4. **后台写操作统一确认**:所有会触发 POST / PATCH / DELETE 的管理动作,在真正提交前必须弹出二次确认。
|
||||
5. **尽量少改接口语义**:优先在现有 admin upsert/list 体系内扩展字段,而不是新增一套并行 API。
|
||||
|
||||
---
|
||||
|
||||
## 方案概要
|
||||
|
||||
### 邀请码时间窗
|
||||
|
||||
新增字段:
|
||||
- `starts_at: Option<Timestamp>`
|
||||
- `expires_at: Option<Timestamp>`
|
||||
|
||||
校验规则:
|
||||
- 当前时间 `< starts_at`:返回“邀请码未生效”
|
||||
- 当前时间 `>= expires_at`:返回“邀请码已过期”
|
||||
- 其他情况允许填写
|
||||
|
||||
建议把状态展示为:
|
||||
- 未生效
|
||||
- 有效
|
||||
- 已过期
|
||||
- 长期有效(两个字段都为空或仅无截止)
|
||||
|
||||
### 后台二次确认
|
||||
|
||||
对 admin-web 所有管理动作统一加确认弹窗/对话框,至少覆盖:
|
||||
- 兑换码新增/更新
|
||||
- 兑换码停用
|
||||
- 邀请码新增/更新
|
||||
- 任务配置新增/更新
|
||||
- 任务配置停用
|
||||
- 其他后续新增的后台写操作
|
||||
|
||||
确认文案要求:
|
||||
- 显示对象标识(如 code / inviteCode / taskId)
|
||||
- 显示操作类型(新增 / 更新 / 停用)
|
||||
- 明确提醒“该操作会立即影响线上数据”
|
||||
- 允许取消返回,不调用 API
|
||||
|
||||
---
|
||||
|
||||
## 预期修改文件
|
||||
|
||||
### 1. 服务端领域与契约
|
||||
- `server-rs/crates/spacetime-module/src/runtime/profile.rs`
|
||||
- `ProfileInviteCode` 表结构新增开始/截止字段
|
||||
- 邀请码 upsert 逻辑写入时间窗
|
||||
- 邀请码 redeem 逻辑增加时间窗校验
|
||||
- 邀请中心快照补充时间窗/状态
|
||||
- `server-rs/crates/spacetime-module/src/migration.rs`
|
||||
- 兼容旧表数据,给旧邀请码补默认空值
|
||||
- `server-rs/crates/shared-contracts/src/runtime*.rs` 或对应生成/手写契约文件
|
||||
- `AdminUpsertProfileInviteCodeRequest` 扩展字段
|
||||
- `ProfileInviteCodeAdminResponse` 扩展字段
|
||||
- 如需要,增加时间窗相关状态枚举或派生字段
|
||||
- `server-rs/crates/spacetime-client/src/module_bindings/*`
|
||||
- 重新生成 bindings
|
||||
- mapper 补齐新字段
|
||||
|
||||
### 2. API Server
|
||||
- `server-rs/crates/api-server/src/runtime_profile.rs`
|
||||
- 接收/转发邀请码时间窗参数
|
||||
- 返回新增字段给后台
|
||||
- 如需要,调整校验错误文案
|
||||
- `server-rs/crates/api-server/src/app.rs`
|
||||
- 若有新路由或错误码需挂接,在此统一登记
|
||||
|
||||
### 3. Admin Web
|
||||
- `apps/admin-web/src/api/adminApiTypes.ts`
|
||||
- 增加邀请码时间窗字段
|
||||
- 如有需要,增加后台操作请求结构字段
|
||||
- `apps/admin-web/src/api/adminApiClient.ts`
|
||||
- 透传新的请求/响应字段
|
||||
- `apps/admin-web/src/app/adminRoutes.ts`
|
||||
- 不一定需要改,但如果新增独立页面/子面板,需要在此登记
|
||||
- `apps/admin-web/src/styles/admin.css`
|
||||
- 确认弹窗与时间窗展示样式
|
||||
- `apps/admin-web/src/**` 实际管理页面组件
|
||||
- 邀请码编辑表单
|
||||
- 邀请码列表状态展示
|
||||
- 所有写操作前的二次确认弹窗
|
||||
|
||||
### 4. 文档
|
||||
- `docs/technical/` 或 `docs/design/`
|
||||
- 补一份邀请码时间窗与后台确认交互说明
|
||||
- 如现有文档已经覆盖后台管理规范,则优先补充现有文档,不重复造新说明页
|
||||
|
||||
---
|
||||
|
||||
## 分步实施计划
|
||||
|
||||
### Task 1: 明确数据模型与契约扩展
|
||||
**Objective:** 定义邀请码开始/截止日期字段及其在响应中的展示方式。
|
||||
|
||||
**要点:**
|
||||
- 确认字段名采用 `starts_at` / `expires_at`,避免与现有字段语义冲突。
|
||||
- 确认时间类型统一用 `Timestamp` / 毫秒微秒整数转换策略。
|
||||
- 明确返回给后台的字段是否需要附带派生状态(如 `status`)。
|
||||
|
||||
**产出:**
|
||||
- 契约字段定义
|
||||
- 状态枚举/派生规则
|
||||
|
||||
---
|
||||
|
||||
### Task 2: 更新 SpacetimeDB 表与迁移
|
||||
**Objective:** 让邀请码表可保存有效期,并兼容旧数据。
|
||||
|
||||
**要点:**
|
||||
- 修改 `ProfileInviteCode` 表结构。
|
||||
- 更新迁移逻辑,旧记录默认无开始/截止。
|
||||
- 检查是否需要补充索引或查询辅助字段。
|
||||
|
||||
**验证:**
|
||||
- 旧数据能正常读取。
|
||||
- 新数据能写入开始/截止。
|
||||
|
||||
---
|
||||
|
||||
### Task 3: 实现邀请填写时的时间窗校验
|
||||
**Objective:** 在邀请码被填写时正确拒绝未生效或已过期的邀请码。
|
||||
|
||||
**要点:**
|
||||
- 在 `redeem_profile_referral_invite_code_record` 内增加开始/截止校验。
|
||||
- 保持“自己的邀请码不能填”“邀请码不存在”等原有错误优先级清晰。
|
||||
- 保留历史绑定关系不受影响。
|
||||
|
||||
**验证:**
|
||||
- 未到开始时间时返回明确错误。
|
||||
- 超过截止时间时返回明确错误。
|
||||
- 正常区间可绑定成功。
|
||||
|
||||
---
|
||||
|
||||
### Task 4: 扩展后台邀请码管理接口
|
||||
**Objective:** 让后台可以创建/修改邀请码时间窗,并在列表中查看状态。
|
||||
|
||||
**要点:**
|
||||
- 扩展 `AdminUpsertProfileInviteCodeRequest`。
|
||||
- 扩展 `ProfileInviteCodeAdminResponse`。
|
||||
- `api-server` 接口负责接收新字段并转发。
|
||||
- 列表接口返回可读时间字段与状态。
|
||||
|
||||
**验证:**
|
||||
- 后台表单提交后,返回结果包含时间窗信息。
|
||||
- 列表页能看到状态与时间。
|
||||
|
||||
---
|
||||
|
||||
### Task 5: 给后台所有写操作加二次确认
|
||||
**Objective:** 统一拦截所有后台写动作,避免误点直接生效。
|
||||
|
||||
**覆盖范围建议:**
|
||||
- 邀请码新增/更新
|
||||
- 兑换码新增/更新/停用
|
||||
- 任务配置新增/更新/停用
|
||||
- 后续新增的管理写操作
|
||||
|
||||
**实现要求:**
|
||||
- 在真正调用 API 之前弹出确认框。
|
||||
- 确认框需要展示对象名、操作类型、影响范围。
|
||||
- 取消后不发送请求。
|
||||
- 尽量抽象出通用确认组件/通用 action 包装函数,避免每个页面重复写。
|
||||
|
||||
**验证:**
|
||||
- 点击“保存”不会直接提交,需先确认。
|
||||
- 点击“取消”不会发请求。
|
||||
- 所有后台写入口行为一致。
|
||||
|
||||
---
|
||||
|
||||
### Task 6: 补充文档与交互说明
|
||||
**Objective:** 把新规则写进项目文档,避免后续实现偏差。
|
||||
|
||||
**要点:**
|
||||
- 记录邀请码时间窗语义。
|
||||
- 记录后台二次确认规范。
|
||||
- 说明哪些动作属于“必须确认”的写操作。
|
||||
|
||||
---
|
||||
|
||||
## 测试与验证
|
||||
|
||||
### 服务端
|
||||
- 邀请码时间窗单测 / 集成测试
|
||||
- 邀请码 redeem 流程回归测试
|
||||
- 旧数据兼容测试
|
||||
|
||||
### API / 前端
|
||||
- 管理后台列表展示正确
|
||||
- 表单提交能回传新字段
|
||||
- 二次确认取消后不请求接口
|
||||
- 二次确认确认后正常提交
|
||||
|
||||
### 推荐验证命令
|
||||
- 视项目现有脚本执行对应后端测试
|
||||
- 前端按 admin-web 构建/测试脚本验证
|
||||
- 如涉及生成绑定,先确认生成产物无漏字段
|
||||
|
||||
---
|
||||
|
||||
## 风险与权衡
|
||||
|
||||
1. **时间字段格式不统一**
|
||||
- 风险:前后端对时间单位理解不一致。
|
||||
- 处理:在契约层明确是 ISO 字符串还是微秒整数,并全链路统一。
|
||||
|
||||
2. **后台“所有操作”范围过大**
|
||||
- 风险:遗漏某些写入口。
|
||||
- 处理:先枚举现有写 API,再做统一确认封装。
|
||||
|
||||
3. **邀请码过期后历史链接解释成本**
|
||||
- 风险:用户误以为历史邀请码失效影响已绑定关系。
|
||||
- 处理:文案明确“仅影响新填写,不影响已绑定记录”。
|
||||
|
||||
4. **契约与生成绑定联动较多**
|
||||
- 风险:字段变更后生成文件数量较多。
|
||||
- 处理:先改源契约与服务端,再统一重生成 bindings。
|
||||
|
||||
---
|
||||
|
||||
## 待确认问题
|
||||
|
||||
1. `starts_at` / `expires_at` 在接口里要返回 **ISO 字符串** 还是 **微秒整数**?
|
||||
2. 后台二次确认是否统一用一个全局弹窗组件,还是页面级本地实现?
|
||||
3. 邀请码列表是否需要直接展示“状态标签”还是只展示时间字段由前端推导?
|
||||
4. 现有后台所有写操作里,是否还要覆盖调试类接口,还是仅覆盖业务管理接口?
|
||||
|
||||
---
|
||||
|
||||
## 建议执行顺序
|
||||
|
||||
1. 先确认时间字段格式与确认弹窗范围。
|
||||
2. 再改服务端契约与迁移。
|
||||
3. 再改 redeem 校验与后台接口。
|
||||
4. 最后统一改 admin-web 的二次确认与表单展示。
|
||||
|
||||
---
|
||||
|
||||
**结论:** 这是一个适合分阶段落地的改动,建议先做“邀请码时间窗 + 后台统一二次确认”的基础能力,再补交互细节。
|
||||
@@ -122,6 +122,8 @@ export interface AdminUpsertProfileRedeemCodeRequest {
|
||||
export interface AdminUpsertProfileInviteCodeRequest {
|
||||
inviteCode: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
startsAt?: string | null;
|
||||
expiresAt?: string | null;
|
||||
}
|
||||
|
||||
export interface AdminDisableProfileRedeemCodeRequest {
|
||||
@@ -166,6 +168,9 @@ export interface ProfileInviteCodeAdminResponse {
|
||||
userId: string;
|
||||
inviteCode: string;
|
||||
metadata: Record<string, unknown>;
|
||||
startsAt?: string | null;
|
||||
expiresAt?: string | null;
|
||||
status: 'pending' | 'active' | 'expired';
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
105
apps/admin-web/src/components/useAdminWriteConfirm.tsx
Normal file
105
apps/admin-web/src/components/useAdminWriteConfirm.tsx
Normal file
@@ -0,0 +1,105 @@
|
||||
import {useCallback, useEffect, useRef, useState} from 'react';
|
||||
|
||||
interface AdminWriteConfirmOptions {
|
||||
action: string;
|
||||
target: string;
|
||||
}
|
||||
|
||||
interface PendingConfirm extends AdminWriteConfirmOptions {
|
||||
resolve: (confirmed: boolean) => void;
|
||||
}
|
||||
|
||||
export function useAdminWriteConfirm() {
|
||||
const [pendingConfirm, setPendingConfirm] = useState<PendingConfirm | null>(null);
|
||||
const cancelButtonRef = useRef<HTMLButtonElement | null>(null);
|
||||
|
||||
const confirmWrite = useCallback((options: AdminWriteConfirmOptions) => {
|
||||
return new Promise<boolean>((resolve) => {
|
||||
setPendingConfirm((current) => {
|
||||
if (current) {
|
||||
current.resolve(false);
|
||||
}
|
||||
return {...options, resolve};
|
||||
});
|
||||
});
|
||||
}, []);
|
||||
|
||||
const closeConfirm = useCallback(
|
||||
(confirmed: boolean) => {
|
||||
const current = pendingConfirm;
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
setPendingConfirm(null);
|
||||
current.resolve(confirmed);
|
||||
},
|
||||
[pendingConfirm],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!pendingConfirm) {
|
||||
return;
|
||||
}
|
||||
|
||||
cancelButtonRef.current?.focus();
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
closeConfirm(false);
|
||||
}
|
||||
};
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
return () => window.removeEventListener('keydown', handleKeyDown);
|
||||
}, [closeConfirm, pendingConfirm]);
|
||||
|
||||
const confirmDialog = pendingConfirm ? (
|
||||
<div
|
||||
aria-modal="true"
|
||||
aria-labelledby="admin-write-confirm-title"
|
||||
className="admin-confirm-backdrop"
|
||||
role="dialog"
|
||||
onMouseDown={(event) => {
|
||||
if (event.target === event.currentTarget) {
|
||||
closeConfirm(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<section className="admin-confirm-panel">
|
||||
<div className="admin-panel-heading">
|
||||
<h3 id="admin-write-confirm-title">确认操作</h3>
|
||||
<span>{pendingConfirm.action}</span>
|
||||
</div>
|
||||
<dl className="admin-info-list">
|
||||
<div>
|
||||
<dt>操作</dt>
|
||||
<dd>{pendingConfirm.action}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>对象</dt>
|
||||
<dd>{pendingConfirm.target}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div className="admin-confirm-warning">该操作会立即影响线上数据</div>
|
||||
<div className="admin-confirm-actions">
|
||||
<button
|
||||
className="admin-secondary-button"
|
||||
ref={cancelButtonRef}
|
||||
type="button"
|
||||
onClick={() => closeConfirm(false)}
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
className="admin-danger-button"
|
||||
type="button"
|
||||
onClick={() => closeConfirm(true)}
|
||||
>
|
||||
确认
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
) : null;
|
||||
|
||||
return {confirmWrite, confirmDialog};
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
AdminDebugHttpMethod,
|
||||
AdminDebugHttpResponse,
|
||||
} from '../api/adminApiTypes';
|
||||
import {useAdminWriteConfirm} from '../components/useAdminWriteConfirm';
|
||||
import {formatUnknownJson, handlePageError} from './pageUtils';
|
||||
|
||||
interface AdminDebugHttpPageProps {
|
||||
@@ -33,6 +34,7 @@ export function AdminDebugHttpPage({
|
||||
const [result, setResult] = useState<AdminDebugHttpResponse | null>(null);
|
||||
const [errorMessage, setErrorMessage] = useState('');
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const {confirmWrite, confirmDialog} = useAdminWriteConfirm();
|
||||
|
||||
const jsonPreview = useMemo(
|
||||
() => formatUnknownJson(result?.bodyJson),
|
||||
@@ -46,6 +48,16 @@ export function AdminDebugHttpPage({
|
||||
}
|
||||
|
||||
setErrorMessage('');
|
||||
if (method !== 'GET') {
|
||||
const confirmed = await confirmWrite({
|
||||
action: `${method} 调试请求`,
|
||||
target: path.trim(),
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
const response = await debugAdminHttp(token, {
|
||||
@@ -209,6 +221,7 @@ export function AdminDebugHttpPage({
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
{confirmDialog}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,11 @@ import {
|
||||
listProfileInviteCodes,
|
||||
upsertProfileInviteCode,
|
||||
} from '../api/adminApiClient';
|
||||
import type {ProfileInviteCodeAdminResponse} from '../api/adminApiTypes';
|
||||
import type {
|
||||
AdminUpsertProfileInviteCodeRequest,
|
||||
ProfileInviteCodeAdminResponse,
|
||||
} from '../api/adminApiTypes';
|
||||
import {useAdminWriteConfirm} from '../components/useAdminWriteConfirm';
|
||||
import {handlePageError} from './pageUtils';
|
||||
|
||||
interface AdminInviteCodePageProps {
|
||||
@@ -22,12 +26,15 @@ export function AdminInviteCodePage({
|
||||
onResultChange,
|
||||
}: AdminInviteCodePageProps) {
|
||||
const [inviteCode, setInviteCode] = useState('');
|
||||
const [startsAt, setStartsAt] = useState('');
|
||||
const [expiresAt, setExpiresAt] = useState('');
|
||||
const [metadataText, setMetadataText] = useState('{}');
|
||||
const [errorMessage, setErrorMessage] = useState('');
|
||||
const [listErrorMessage, setListErrorMessage] = useState('');
|
||||
const [entries, setEntries] = useState<ProfileInviteCodeAdminResponse[]>([]);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const {confirmWrite, confirmDialog} = useAdminWriteConfirm();
|
||||
|
||||
useEffect(() => {
|
||||
void refreshInviteCodes();
|
||||
@@ -54,12 +61,29 @@ export function AdminInviteCodePage({
|
||||
}
|
||||
|
||||
setErrorMessage('');
|
||||
const validityError = validateValidityWindow(startsAt, expiresAt);
|
||||
if (validityError) {
|
||||
setErrorMessage(validityError);
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmed = await confirmWrite({
|
||||
action: '保存邀请码',
|
||||
target: inviteCode.trim(),
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSaving(true);
|
||||
try {
|
||||
const response = await upsertProfileInviteCode(token, {
|
||||
const payload: AdminUpsertProfileInviteCodeRequest = {
|
||||
inviteCode: inviteCode.trim(),
|
||||
metadata: parseMetadata(metadataText),
|
||||
});
|
||||
startsAt: startsAt ? toIsoDateTime(startsAt) : null,
|
||||
expiresAt: expiresAt ? toIsoDateTime(expiresAt) : null,
|
||||
};
|
||||
const response = await upsertProfileInviteCode(token, payload);
|
||||
onResultChange(response);
|
||||
upsertEntry(response);
|
||||
fillForm(response);
|
||||
@@ -89,9 +113,13 @@ export function AdminInviteCodePage({
|
||||
|
||||
function fillForm(entry: ProfileInviteCodeAdminResponse) {
|
||||
setInviteCode(entry.inviteCode);
|
||||
setStartsAt(toDateTimeLocalValue(entry.startsAt));
|
||||
setExpiresAt(toDateTimeLocalValue(entry.expiresAt));
|
||||
setMetadataText(JSON.stringify(entry.metadata, null, 2));
|
||||
}
|
||||
|
||||
const validityError = validateValidityWindow(startsAt, expiresAt);
|
||||
|
||||
return (
|
||||
<section className="admin-page">
|
||||
<div className="admin-page-heading">
|
||||
@@ -127,6 +155,25 @@ export function AdminInviteCodePage({
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div className="admin-form-row">
|
||||
<label className="admin-field">
|
||||
<span>开始时间</span>
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={startsAt}
|
||||
onChange={(event) => setStartsAt(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="admin-field">
|
||||
<span>截止时间</span>
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={expiresAt}
|
||||
onChange={(event) => setExpiresAt(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label className="admin-field">
|
||||
<span>Metadata JSON</span>
|
||||
<textarea
|
||||
@@ -142,10 +189,20 @@ export function AdminInviteCodePage({
|
||||
{errorMessage}
|
||||
</div>
|
||||
) : null}
|
||||
{validityError ? (
|
||||
<div className="admin-alert" role="status">
|
||||
{validityError}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<button
|
||||
className="admin-primary-button"
|
||||
disabled={isSaving || !inviteCode.trim() || !isMetadataReady(metadataText)}
|
||||
disabled={
|
||||
isSaving ||
|
||||
!inviteCode.trim() ||
|
||||
!isMetadataReady(metadataText) ||
|
||||
Boolean(validityError)
|
||||
}
|
||||
type="submit"
|
||||
>
|
||||
<Save size={17} aria-hidden="true" />
|
||||
@@ -165,8 +222,8 @@ export function AdminInviteCodePage({
|
||||
<thead>
|
||||
<tr>
|
||||
<th>邀请码</th>
|
||||
<th>有效期</th>
|
||||
<th>创建</th>
|
||||
<th>更新</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -181,8 +238,13 @@ export function AdminInviteCodePage({
|
||||
{entry.inviteCode}
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
<span className={`admin-status ${inviteValidityClass(entry)}`}>
|
||||
{inviteValidityLabel(entry)}
|
||||
</span>
|
||||
<small>{formatValidityWindow(entry)}</small>
|
||||
</td>
|
||||
<td>{entry.createdAt}</td>
|
||||
<td>{entry.updatedAt}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -206,6 +268,10 @@ export function AdminInviteCodePage({
|
||||
<dt>邀请码</dt>
|
||||
<dd>{result.inviteCode}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>有效期</dt>
|
||||
<dd>{formatValidityWindow(result)}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>创建</dt>
|
||||
<dd>{result.createdAt}</dd>
|
||||
@@ -229,6 +295,7 @@ export function AdminInviteCodePage({
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
{confirmDialog}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -255,6 +322,84 @@ function isMetadataReady(value: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function validateValidityWindow(startsAt: string, expiresAt: string) {
|
||||
if (!startsAt || !expiresAt) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const startsAtTime = Date.parse(toIsoDateTime(startsAt));
|
||||
const expiresAtTime = Date.parse(toIsoDateTime(expiresAt));
|
||||
if (!Number.isFinite(startsAtTime) || !Number.isFinite(expiresAtTime)) {
|
||||
return '有效期时间无效';
|
||||
}
|
||||
|
||||
return startsAtTime < expiresAtTime ? '' : '截止时间必须晚于开始时间';
|
||||
}
|
||||
|
||||
function toIsoDateTime(value: string) {
|
||||
const time = Date.parse(value);
|
||||
if (!Number.isFinite(time)) {
|
||||
throw new Error('有效期时间无效');
|
||||
}
|
||||
return new Date(time).toISOString();
|
||||
}
|
||||
|
||||
function toDateTimeLocalValue(value?: string | null) {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const date = new Date(value);
|
||||
if (!Number.isFinite(date.getTime())) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const offsetMs = date.getTimezoneOffset() * 60 * 1000;
|
||||
return new Date(date.getTime() - offsetMs).toISOString().slice(0, 16);
|
||||
}
|
||||
|
||||
function inviteValidityLabel(entry: ProfileInviteCodeAdminResponse) {
|
||||
const now = Date.now();
|
||||
const startsAtTime = entry.startsAt ? Date.parse(entry.startsAt) : null;
|
||||
const expiresAtTime = entry.expiresAt ? Date.parse(entry.expiresAt) : null;
|
||||
|
||||
if (startsAtTime && Number.isFinite(startsAtTime) && now < startsAtTime) {
|
||||
return '未生效';
|
||||
}
|
||||
if (expiresAtTime && Number.isFinite(expiresAtTime) && now >= expiresAtTime) {
|
||||
return '已过期';
|
||||
}
|
||||
if (entry.startsAt || entry.expiresAt) {
|
||||
return '有效';
|
||||
}
|
||||
return '长期有效';
|
||||
}
|
||||
|
||||
function inviteValidityClass(entry: ProfileInviteCodeAdminResponse) {
|
||||
const label = inviteValidityLabel(entry);
|
||||
if (label === '已过期') {
|
||||
return 'admin-status-error';
|
||||
}
|
||||
if (label === '未生效') {
|
||||
return 'admin-status-pending';
|
||||
}
|
||||
return 'admin-status-ok';
|
||||
}
|
||||
|
||||
function formatValidityWindow(entry: ProfileInviteCodeAdminResponse) {
|
||||
const startsAt = entry.startsAt ? formatDateTime(entry.startsAt) : '立即';
|
||||
const expiresAt = entry.expiresAt ? formatDateTime(entry.expiresAt) : '长期';
|
||||
return `${startsAt} / ${expiresAt}`;
|
||||
}
|
||||
|
||||
function formatDateTime(value: string) {
|
||||
const date = new Date(value);
|
||||
if (!Number.isFinite(date.getTime())) {
|
||||
return value;
|
||||
}
|
||||
return date.toLocaleString('zh-CN', {hour12: false});
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
ProfileRedeemCodeAdminResponse,
|
||||
ProfileRedeemCodeMode,
|
||||
} from '../api/adminApiTypes';
|
||||
import {useAdminWriteConfirm} from '../components/useAdminWriteConfirm';
|
||||
import {handlePageError, splitLines} from './pageUtils';
|
||||
|
||||
interface AdminRedeemCodePageProps {
|
||||
@@ -46,6 +47,7 @@ export function AdminRedeemCodePage({
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isDisabling, setIsDisabling] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const {confirmWrite, confirmDialog} = useAdminWriteConfirm();
|
||||
|
||||
useEffect(() => {
|
||||
void refreshRedeemCodes();
|
||||
@@ -72,6 +74,14 @@ export function AdminRedeemCodePage({
|
||||
}
|
||||
|
||||
setErrorMessage('');
|
||||
const confirmed = await confirmWrite({
|
||||
action: '保存兑换码',
|
||||
target: code.trim(),
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSaving(true);
|
||||
try {
|
||||
const response = await upsertProfileRedeemCode(token, {
|
||||
@@ -101,6 +111,14 @@ export function AdminRedeemCodePage({
|
||||
}
|
||||
|
||||
setDisableErrorMessage('');
|
||||
const confirmed = await confirmWrite({
|
||||
action: '停用兑换码',
|
||||
target: disableCode.trim(),
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsDisabling(true);
|
||||
try {
|
||||
const response = await disableProfileRedeemCode(token, {
|
||||
@@ -376,6 +394,7 @@ export function AdminRedeemCodePage({
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
{confirmDialog}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
ProfileTaskCycle,
|
||||
TrackingScopeKind,
|
||||
} from '../api/adminApiTypes';
|
||||
import {useAdminWriteConfirm} from '../components/useAdminWriteConfirm';
|
||||
import {
|
||||
filterAdminTrackingEventDefinitions,
|
||||
findAdminTrackingEventDefinition,
|
||||
@@ -28,12 +29,7 @@ const taskCycles: Array<{value: ProfileTaskCycle; label: string}> = [
|
||||
{value: 'daily', label: '每日'},
|
||||
];
|
||||
|
||||
const scopeKinds: Array<{value: TrackingScopeKind; label: string}> = [
|
||||
{value: 'user', label: '用户'},
|
||||
{value: 'site', label: '整站'},
|
||||
{value: 'work', label: '作品'},
|
||||
{value: 'module', label: '模块'},
|
||||
];
|
||||
const profileTaskScopeKind = 'user' satisfies TrackingScopeKind;
|
||||
|
||||
export function AdminTaskConfigPage({
|
||||
token,
|
||||
@@ -49,7 +45,6 @@ export function AdminTaskConfigPage({
|
||||
const [eventKeySearch, setEventKeySearch] = useState('每日登录');
|
||||
const [isEventKeyPickerOpen, setIsEventKeyPickerOpen] = useState(false);
|
||||
const [cycle, setCycle] = useState<ProfileTaskCycle>('daily');
|
||||
const [scopeKind, setScopeKind] = useState<TrackingScopeKind>('user');
|
||||
const [threshold, setThreshold] = useState('1');
|
||||
const [rewardPoints, setRewardPoints] = useState('10');
|
||||
const [sortOrder, setSortOrder] = useState('10');
|
||||
@@ -61,6 +56,7 @@ export function AdminTaskConfigPage({
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isDisabling, setIsDisabling] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const {confirmWrite, confirmDialog} = useAdminWriteConfirm();
|
||||
|
||||
useEffect(() => {
|
||||
void refreshTaskConfigs();
|
||||
@@ -102,6 +98,14 @@ export function AdminTaskConfigPage({
|
||||
}
|
||||
|
||||
setErrorMessage('');
|
||||
const confirmed = await confirmWrite({
|
||||
action: '保存任务配置',
|
||||
target: taskId.trim(),
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSaving(true);
|
||||
try {
|
||||
const response = await upsertProfileTaskConfig(token, {
|
||||
@@ -110,7 +114,7 @@ export function AdminTaskConfigPage({
|
||||
description,
|
||||
eventKey: eventKey.trim(),
|
||||
cycle,
|
||||
scopeKind,
|
||||
scopeKind: profileTaskScopeKind,
|
||||
threshold: parsePositiveInteger(threshold),
|
||||
rewardPoints: parsePositiveInteger(rewardPoints),
|
||||
enabled,
|
||||
@@ -132,6 +136,14 @@ export function AdminTaskConfigPage({
|
||||
}
|
||||
|
||||
setDisableErrorMessage('');
|
||||
const confirmed = await confirmWrite({
|
||||
action: '停用任务配置',
|
||||
target: disableTaskId.trim(),
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsDisabling(true);
|
||||
try {
|
||||
const response = await disableProfileTaskConfig(token, {
|
||||
@@ -165,7 +177,6 @@ export function AdminTaskConfigPage({
|
||||
setDescription(entry.description);
|
||||
setEventKey(entry.eventKey);
|
||||
setCycle(entry.cycle);
|
||||
setScopeKind(entry.scopeKind);
|
||||
setThreshold(String(entry.threshold));
|
||||
setRewardPoints(String(entry.rewardPoints));
|
||||
setSortOrder(String(entry.sortOrder));
|
||||
@@ -181,7 +192,6 @@ export function AdminTaskConfigPage({
|
||||
setEventKey(nextEventKey);
|
||||
if (nextDefinition) {
|
||||
setEventKeySearch(nextDefinition.title);
|
||||
setScopeKind(nextDefinition.scopeKind);
|
||||
} else {
|
||||
setEventKeySearch(nextEventKey);
|
||||
}
|
||||
@@ -349,21 +359,6 @@ export function AdminTaskConfigPage({
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="admin-field">
|
||||
<span>埋点范围</span>
|
||||
<select
|
||||
value={scopeKind}
|
||||
onChange={(event) =>
|
||||
setScopeKind(event.target.value as TrackingScopeKind)
|
||||
}
|
||||
>
|
||||
{scopeKinds.map((item) => (
|
||||
<option key={item.value} value={item.value}>
|
||||
{item.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="admin-form-row">
|
||||
@@ -530,6 +525,7 @@ export function AdminTaskConfigPage({
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
{confirmDialog}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -457,6 +457,47 @@ button:disabled {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.admin-confirm-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 80;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: rgba(23, 33, 43, 0.42);
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.admin-confirm-panel {
|
||||
display: grid;
|
||||
width: min(100%, 420px);
|
||||
gap: 16px;
|
||||
border: 1px solid #d8e2e8;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 22px 60px rgba(23, 33, 43, 0.24);
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.admin-confirm-warning {
|
||||
border: 1px solid #efc894;
|
||||
border-radius: 8px;
|
||||
color: #8a5a1b;
|
||||
background: #fffaf3;
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.admin-confirm-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.admin-confirm-actions button {
|
||||
min-width: 92px;
|
||||
}
|
||||
|
||||
.admin-primary-button {
|
||||
color: #ffffff;
|
||||
background: #126e82;
|
||||
@@ -575,6 +616,11 @@ button:disabled {
|
||||
background: #e6f5ed;
|
||||
}
|
||||
|
||||
.admin-status-pending {
|
||||
color: #8a5a1b;
|
||||
background: #fff4df;
|
||||
}
|
||||
|
||||
.admin-status-error {
|
||||
color: #8a2f2f;
|
||||
background: #fff1ef;
|
||||
@@ -755,6 +801,14 @@ button:disabled {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.admin-confirm-panel {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.admin-confirm-actions {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.admin-login-brand h1,
|
||||
.admin-page-heading h2 {
|
||||
font-size: 22px;
|
||||
|
||||
20
docs/experience/ADMIN_TASK_CONFIG_SCOPE_LOCK_2026-05-04.md
Normal file
20
docs/experience/ADMIN_TASK_CONFIG_SCOPE_LOCK_2026-05-04.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# AdminTaskConfigPage 埋点范围收口记录(2026-05-04)
|
||||
|
||||
## 变更目标
|
||||
- 前端隐藏「埋点范围」选择项。
|
||||
- 保存任务配置时固定传递 `scopeKind=user`,避免运营在后台选择其他范围。
|
||||
|
||||
## 落地结果
|
||||
- `apps/admin-web/src/pages/AdminTaskConfigPage.tsx`
|
||||
- 移除了「埋点范围」下拉选择 UI。
|
||||
- 保存时改为固定提交 `scopeKind: 'user'`。
|
||||
- 回填表单时不再读取或维护 `scopeKind` 的可编辑状态。
|
||||
|
||||
## 验证结果
|
||||
- 已检查页面源码,确认不再存在「埋点范围」字段与可编辑逻辑。
|
||||
- 已执行 `npm run admin-web:typecheck`。
|
||||
- 当前验证失败原因为环境缺少 `node_modules/typescript/bin/tsc`,属于依赖安装状态问题,不是本次前端改动引入的代码错误。
|
||||
|
||||
## 遗留说明
|
||||
- `apps/admin-web/src/api/adminApiTypes.ts` 中仍保留 `TrackingScopeKind` 类型,供接口契约与其他前端模块兼容使用。
|
||||
- `apps/admin-web/src/config/trackingEventDefinitions.ts` 仍保留事件定义中的 `scopeKind` 元数据,但页面不再允许运营修改。
|
||||
@@ -192,6 +192,8 @@ export interface AdminDisableProfileRedeemCodeRequest {
|
||||
|
||||
export interface AdminUpsertProfileInviteCodeRequest {
|
||||
inviteCode: string;
|
||||
startsAt?: string | null;
|
||||
expiresAt?: string | null;
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
@@ -215,6 +217,9 @@ export interface ProfileRedeemCodeAdminListResponse {
|
||||
export interface ProfileInviteCodeAdminResponse {
|
||||
userId: string;
|
||||
inviteCode: string;
|
||||
startsAt: string | null;
|
||||
expiresAt: string | null;
|
||||
status: 'pending' | 'active' | 'expired';
|
||||
metadata: Record<string, unknown>;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -376,6 +381,9 @@ export interface ProfileInviteCodeAdminListResponse {
|
||||
{
|
||||
"userId": "admin:root:SPRING2026",
|
||||
"inviteCode": "SPRING2026",
|
||||
"startsAt": "2026-05-01T00:00:00Z",
|
||||
"expiresAt": "2026-06-01T00:00:00Z",
|
||||
"status": "active",
|
||||
"metadata": {
|
||||
"batch": "spring"
|
||||
},
|
||||
@@ -393,6 +401,8 @@ export interface ProfileInviteCodeAdminListResponse {
|
||||
```json
|
||||
{
|
||||
"inviteCode": "SPRING2026",
|
||||
"startsAt": "2026-05-01T00:00:00Z",
|
||||
"expiresAt": "2026-06-01T00:00:00Z",
|
||||
"metadata": {
|
||||
"batch": "spring"
|
||||
}
|
||||
@@ -405,6 +415,9 @@ export interface ProfileInviteCodeAdminListResponse {
|
||||
{
|
||||
"userId": "admin",
|
||||
"inviteCode": "SPRING2026",
|
||||
"startsAt": "2026-05-01T00:00:00Z",
|
||||
"expiresAt": "2026-06-01T00:00:00Z",
|
||||
"status": "active",
|
||||
"metadata": {
|
||||
"batch": "spring"
|
||||
},
|
||||
@@ -415,6 +428,118 @@ export interface ProfileInviteCodeAdminListResponse {
|
||||
|
||||
邀请码页的 metadata 输入必须先在前端解析为 JSON 对象;空字符串按 `{}` 处理,数组、字符串、数字等非对象值直接提示错误。最终标准化、长度限制和邀请码合法性以 `server-rs` 为准。
|
||||
|
||||
#### 4.8.1 邀请码有效期语义
|
||||
|
||||
邀请码仍然是“用户稳定邀请身份码”,不做删除或软删除。本轮只增加时间窗字段,用于控制**新填写邀请码**是否允许绑定:
|
||||
|
||||
1. `startsAt` / 后端 `starts_at`:邀请码开始生效时间;为空表示立即生效。
|
||||
2. `expiresAt` / 后端 `expires_at`:邀请码截止时间;为空表示长期有效。
|
||||
3. 两个字段都为空时,邀请码视为长期有效。
|
||||
4. `expiresAt` 采用左闭右开语义:当前时间 `>= expiresAt` 时视为已过期。
|
||||
5. 时间字段在管理 API JSON 中统一使用 ISO 8601 UTC 字符串或 `null`;SpacetimeDB 内部仍按 `Timestamp` 存储,契约层负责转换,前端不得自行假设微秒/毫秒整数。
|
||||
6. 有效期只影响用户之后调用填写邀请码接口建立新邀请关系;已绑定的邀请关系、历史奖励、统计和审计记录不回溯修改。
|
||||
|
||||
字段合法性要求:
|
||||
|
||||
1. `startsAt` 和 `expiresAt` 均允许为空。
|
||||
2. 若两者都存在,必须满足 `startsAt < expiresAt`;相等或开始晚于截止应由后端拒绝,前端可提前提示但不能替代后端校验。
|
||||
3. 后台编辑已有邀请码时,空值代表清空该边界;不要用空字符串写入契约。
|
||||
|
||||
#### 4.8.2 用户填写邀请码的错误优先级与校验逻辑
|
||||
|
||||
填写邀请码时,后端是唯一业务真相。前端只展示后端错误,不复制完整业务规则。推荐校验优先级如下:
|
||||
|
||||
1. **请求身份与输入基础校验**:未登录、空邀请码、格式不合法等请求级错误优先返回。
|
||||
2. **用户自身状态校验**:用户不存在、用户资料不可用、已绑定过邀请关系等与当前用户直接相关的错误优先于邀请码时间窗。
|
||||
3. **邀请码查找**:按标准化后的邀请码查找记录;不存在时返回“邀请码不存在或不可用”。
|
||||
4. **自邀请校验**:邀请码归属用户等于当前用户时,返回“不能填写自己的邀请码”。
|
||||
5. **时间窗校验**:
|
||||
- `starts_at` 存在且当前时间 `< starts_at`,返回“邀请码未生效”。
|
||||
- `expires_at` 存在且当前时间 `>= expires_at`,返回“邀请码已过期”。
|
||||
6. **绑定写入与奖励发放**:只有以上校验全部通过,才写入邀请绑定、奖励或相关流水。
|
||||
|
||||
该顺序的目标是避免用“未生效/已过期”泄露不该暴露的用户状态,同时保证用户看到的错误与实际阻断原因一致。若后续新增风控、封禁、黑名单等规则,应在写入前补入,并在本节同步明确优先级。
|
||||
|
||||
#### 4.8.3 后台邀请码列表状态展示规则
|
||||
|
||||
后台列表状态可由后端返回 `status`,也可在前端用同一规则从 `startsAt` / `expiresAt` 派生;如果两者同时存在,列表展示以后端 `status` 为准,并仅把前端派生结果用于兜底。
|
||||
|
||||
| 条件 | 状态值 | 中文标签 | 展示建议 |
|
||||
| --- | --- | --- | --- |
|
||||
| `startsAt` 存在且当前时间 `< startsAt` | `pending` | 未生效 | 展示开始时间,提示尚不能被新用户填写 |
|
||||
| `expiresAt` 存在且当前时间 `>= expiresAt` | `expired` | 已过期 | 展示截止时间,提示不再允许新绑定 |
|
||||
| 其他情况 | `active` | 有效 | 正常高亮展示 |
|
||||
|
||||
补充展示规则:
|
||||
|
||||
1. 两个字段都为空时状态为 `active`,中文可展示为“长期有效”。
|
||||
2. `startsAt` 为空、`expiresAt` 未来存在时状态为 `active`,中文可展示为“有效至 YYYY-MM-DD HH:mm”。
|
||||
3. `startsAt` 未来、`expiresAt` 为空时状态为 `pending`,中文可展示为“YYYY-MM-DD HH:mm 生效”。
|
||||
4. 列表至少展示邀请码、状态、开始时间、截止时间、更新时间;metadata 可保留折叠/摘要展示,避免挤占移动端宽度。
|
||||
5. 列表状态只用于运营理解,不作为安全边界;真正是否可填写仍以后端 redeem 校验为准。
|
||||
|
||||
### 4.9 后台写操作二次确认规范
|
||||
|
||||
后台所有会修改线上数据的操作,在真正调用 API 前必须二次确认;取消确认时不得发送任何请求。该规范覆盖当前和未来新增的管理写入口,不限于 profile 模块。
|
||||
|
||||
必须二次确认的操作包括但不限于:
|
||||
|
||||
1. 创建/更新兑换码:`POST /admin/api/profile/redeem-codes`。
|
||||
2. 停用兑换码:`POST /admin/api/profile/redeem-codes/disable`。
|
||||
3. 创建/更新邀请码:`POST /admin/api/profile/invite-codes`。
|
||||
4. 创建/更新个人任务配置:`POST /admin/api/profile/tasks`。
|
||||
5. 停用个人任务配置:`POST /admin/api/profile/tasks/disable`。
|
||||
6. 后续任何 `POST` / `PATCH` / `PUT` / `DELETE` 管理接口,只要会修改数据、触发任务、写审计或影响线上配置,均默认纳入确认。
|
||||
|
||||
交互要求:
|
||||
|
||||
1. 确认弹窗必须在 API 调用前出现,确认后才进入 loading 和提交状态。
|
||||
2. 弹窗必须展示操作类型(新增、更新、停用、删除、发布等)、对象标识(如 `code`、`inviteCode`、`taskId`)和影响说明。
|
||||
3. 默认按钮顺序为“取消 / 确认”,取消不应有危险色;危险操作(停用、删除、覆盖线上配置)确认按钮使用警示样式。
|
||||
4. 弹窗文案统一提示“该操作会立即影响线上数据”,但不要在页面常驻展示大段规则说明。
|
||||
5. 支持键盘和移动端:Esc 或取消按钮关闭;移动端弹窗宽度自适应,不遮挡关键对象信息。
|
||||
6. loading 期间锁定确认按钮和原页面提交按钮,避免重复写入。
|
||||
7. 成功后按现有页面规则刷新列表或合并返回记录;失败时展示后端错误,不能静默关闭为成功。
|
||||
|
||||
建议抽象通用确认能力,例如 `confirmAdminWriteAction({ actionLabel, targetLabel, riskLevel, onConfirm })` 或通用 `AdminConfirmDialog`,页面只传入对象与回调,避免每个页面重复实现不同交互。
|
||||
|
||||
#### 4.9.1 二次确认文案模板
|
||||
|
||||
```text
|
||||
标题:确认{操作类型}{对象类型}
|
||||
正文:即将{操作类型}「{对象标识}」。该操作会立即影响线上数据。
|
||||
取消按钮:取消
|
||||
确认按钮:确认{操作类型}
|
||||
```
|
||||
|
||||
示例:
|
||||
|
||||
1. `确认更新邀请码`:即将更新「SPRING2026」的有效期与 metadata。该操作会立即影响线上数据。
|
||||
2. `确认停用兑换码`:即将停用「WELCOME2026」。该操作会立即影响线上数据。
|
||||
3. `确认更新任务配置`:即将更新「daily_login」。该操作会立即影响线上数据。
|
||||
|
||||
### 4.10 邀请码有效期与二次确认改动范围
|
||||
|
||||
实现本设计时预期改动范围如下,未列出的层级不要擅自承接业务规则:
|
||||
|
||||
1. `server-rs/crates/spacetime-module/src/runtime/profile.rs`:邀请码表结构、upsert、redeem 时间窗校验与后台列表投影。
|
||||
2. `server-rs/crates/spacetime-module/src/migration.rs`:旧邀请码记录迁移,默认 `starts_at = None`、`expires_at = None`。
|
||||
3. `server-rs/crates/shared-contracts/src/**`:管理请求/响应 DTO 增加 `startsAt`、`expiresAt`、`status` 等字段。
|
||||
4. `server-rs/crates/spacetime-client/src/module_bindings/**` 与 mapper:按表结构变更重新生成/补齐绑定字段。
|
||||
5. `server-rs/crates/api-server/src/runtime_profile.rs`:接收、校验、转发并返回邀请码时间窗字段;保持错误 envelope 兼容后台读取逻辑。
|
||||
6. `apps/admin-web/src/api/adminApiTypes.ts` 与 `adminApiClient.ts`:同步契约字段,不在 client 层写业务判断。
|
||||
7. `apps/admin-web/src/pages/AdminInviteCodePage.tsx`:有效期表单、列表状态展示、保存前确认。
|
||||
8. `apps/admin-web/src/pages/AdminRedeemCodePage.tsx`、`AdminTaskConfigPage.tsx` 及后续写页面:统一接入写操作二次确认。
|
||||
9. `apps/admin-web/src/styles/admin.css`:状态标签、确认弹窗与移动端样式。
|
||||
|
||||
验证建议:
|
||||
|
||||
1. 服务端单测覆盖:未生效邀请码拒绝、已过期邀请码拒绝、有效时间窗可绑定、空时间窗长期有效、已绑定关系不受后续过期影响。
|
||||
2. 管理 API 覆盖:upsert 能写入/清空 `startsAt`、`expiresAt`;列表返回状态正确;`startsAt >= expiresAt` 被拒绝。
|
||||
3. 前端交互覆盖:点击保存/停用不会直接请求,取消确认不请求,确认后只请求一次,失败展示后端错误。
|
||||
4. 回归兑换码与任务配置页面,确认所有写操作均有统一二次确认。
|
||||
5. 修改后端时按项目约束运行对应 Rust 测试、`npm run api-server` 联调和 `/healthz`;修改前端时运行 `npm run admin-web:typecheck`、`npm run admin-web:build`;文档或中文改动后运行 `npm run check:encoding`。
|
||||
|
||||
## 5. 鉴权与会话
|
||||
|
||||
1. token key 固定为 `genarrative_admin_token`。
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
# Analytics Date Dimension 与个人任务埋点范围收口记录(2026-05-04)
|
||||
|
||||
## 背景
|
||||
|
||||
本记录用于收口 `.hermes/plans/2026-05-04_022223-analytics-time-dimension-mapping.md` 中当前阶段已经落地的内容,并明确尚未执行的后续范围。
|
||||
|
||||
本阶段目标不是完整上线运营统计查询,而是先完成两件基础工作:
|
||||
|
||||
1. 收紧个人任务系统的埋点范围,避免运营或接口把个人任务错误配置为 `site`、`module`、`work` 等非用户维度。
|
||||
2. 新增统一日期维表 `analytics_date_dimension`,为后续按周、月、季、年聚合埋点数据提供稳定的日期 bucket 映射。
|
||||
|
||||
## 当前已完成范围
|
||||
|
||||
### 1. 个人任务埋点范围锁定为 User
|
||||
|
||||
当前个人任务系统首版只支持用户维度埋点。
|
||||
|
||||
已完成:
|
||||
|
||||
- Admin 任务配置页不再展示“埋点范围”选择。
|
||||
- Admin 保存任务配置时固定传 `scopeKind: 'user'`。
|
||||
- API 层拒绝非 `user` 的个人任务配置。
|
||||
- 领域输入构造层拒绝非 `User` 的个人任务配置。
|
||||
- `Work => user_id` 的错误映射已移除。
|
||||
- 任务进度刷新、任务中心快照、领奖链路遇到非 `User` 的异常个人任务配置时显式报错,不再静默按 0 进度处理。
|
||||
|
||||
相关文件:
|
||||
|
||||
```text
|
||||
apps/admin-web/src/pages/AdminTaskConfigPage.tsx
|
||||
apps/admin-web/src/api/adminApiTypes.ts
|
||||
server-rs/crates/api-server/src/runtime_profile.rs
|
||||
server-rs/crates/module-runtime/src/commands.rs
|
||||
server-rs/crates/module-runtime/src/errors.rs
|
||||
server-rs/crates/spacetime-module/src/runtime/profile.rs
|
||||
```
|
||||
|
||||
### 2. 日期维表领域模型与纯函数
|
||||
|
||||
已在 `module-runtime` 中补充日期维表快照和纯函数。
|
||||
|
||||
日期维表使用现有北京时间业务日 `day_key` 语义:
|
||||
|
||||
```text
|
||||
date_key = floor((occurred_at_micros + 8h) / 1d)
|
||||
```
|
||||
|
||||
已完成能力:
|
||||
|
||||
- 从 `YYYY-MM-DD` 解析业务日 `date_key`。
|
||||
- 从 `date_key` 构造日期维表快照。
|
||||
- 生成 ISO weekday:周一=1,周日=7。
|
||||
- 生成 ISO week key:`YYYYWW`,跨年周按 ISO week-year。
|
||||
- 生成 week/month/quarter/year 的 key 和起止 `date_key`。
|
||||
- 限制日期维表支持范围为:
|
||||
- `2000-01-01`
|
||||
- 到 `2100-12-31`
|
||||
|
||||
相关文件:
|
||||
|
||||
```text
|
||||
server-rs/crates/module-runtime/src/domain.rs
|
||||
server-rs/crates/module-runtime/src/application.rs
|
||||
server-rs/crates/module-runtime/src/lib.rs
|
||||
```
|
||||
|
||||
### 3. SpacetimeDB 日期维表与 reducer
|
||||
|
||||
已新增 SpacetimeDB 表:
|
||||
|
||||
```text
|
||||
analytics_date_dimension
|
||||
```
|
||||
|
||||
表字段包括:
|
||||
|
||||
```text
|
||||
date_key
|
||||
calendar_date
|
||||
weekday
|
||||
iso_week_key
|
||||
week_start_date_key
|
||||
week_end_date_key
|
||||
month_key
|
||||
month_start_date_key
|
||||
month_end_date_key
|
||||
quarter_key
|
||||
quarter_start_date_key
|
||||
quarter_end_date_key
|
||||
year_key
|
||||
year_start_date_key
|
||||
year_end_date_key
|
||||
created_at
|
||||
updated_at
|
||||
```
|
||||
|
||||
已新增索引:
|
||||
|
||||
```text
|
||||
iso_week_key
|
||||
month_key
|
||||
quarter_key
|
||||
year_key
|
||||
```
|
||||
|
||||
已新增 reducer:
|
||||
|
||||
```text
|
||||
ensure_analytics_date_dimension_for_date
|
||||
seed_analytics_date_dimensions
|
||||
```
|
||||
|
||||
当前 reducer 行为:
|
||||
|
||||
- `ensure` 单日幂等补齐。
|
||||
- `seed` 按日期范围幂等补齐。
|
||||
- `seed` 拒绝 `start_date > end_date`。
|
||||
- `seed` 单次最多允许 `ANALYTICS_DATE_DIMENSION_MAX_SEED_DAYS = 3660` 天。
|
||||
- 裸 `date_key` 进入 ensure 前先做支持范围校验,避免极端整数进入日历算法。
|
||||
|
||||
相关文件:
|
||||
|
||||
```text
|
||||
server-rs/crates/spacetime-module/src/runtime/analytics_date_dimension.rs
|
||||
server-rs/crates/spacetime-module/src/runtime/mod.rs
|
||||
server-rs/crates/spacetime-module/src/migration.rs
|
||||
docs/technical/SPACETIMEDB_TABLE_CATALOG.md
|
||||
```
|
||||
|
||||
### 4. SpacetimeDB Rust client bindings
|
||||
|
||||
已按项目脚本生成 Rust bindings,并在生成参数中显式包含 private tables/functions:
|
||||
|
||||
```bash
|
||||
PATH="/tmp/spacetime-bin:$PATH" npm run spacetime:generate -- --rust-only
|
||||
```
|
||||
|
||||
本次已修改生成脚本:
|
||||
|
||||
```text
|
||||
scripts/generate-spacetime-bindings.mjs
|
||||
```
|
||||
|
||||
在 `spacetime generate` 参数中加入:
|
||||
|
||||
```text
|
||||
--include-private
|
||||
```
|
||||
|
||||
说明:SpacetimeDB CLI 2.1.0 的参数名是 `--include-private`,不是 `--non-private`。该参数含义是将 private tables/functions 也包含进生成代码,满足 api-server 通过 Rust bindings 访问 module private table/reducer 的需求。
|
||||
|
||||
```text
|
||||
spacetimedb tool version 2.1.0; spacetimedb-lib version 2.1.0
|
||||
```
|
||||
|
||||
生成脚本:
|
||||
|
||||
```text
|
||||
scripts/generate-spacetime-bindings.mjs
|
||||
```
|
||||
|
||||
已新增 analytics date dimension 相关 bindings:
|
||||
|
||||
```text
|
||||
server-rs/crates/spacetime-client/src/module_bindings/analytics_date_dimension_ensure_input_type.rs
|
||||
server-rs/crates/spacetime-client/src/module_bindings/analytics_date_dimension_seed_input_type.rs
|
||||
server-rs/crates/spacetime-client/src/module_bindings/analytics_date_dimension_type.rs
|
||||
server-rs/crates/spacetime-client/src/module_bindings/analytics_date_dimension_table.rs
|
||||
server-rs/crates/spacetime-client/src/module_bindings/ensure_analytics_date_dimension_for_date_reducer.rs
|
||||
server-rs/crates/spacetime-client/src/module_bindings/seed_analytics_date_dimensions_reducer.rs
|
||||
```
|
||||
|
||||
并更新了:
|
||||
|
||||
```text
|
||||
server-rs/crates/spacetime-client/src/module_bindings/mod.rs
|
||||
```
|
||||
|
||||
注意:
|
||||
|
||||
- `analytics_date_dimension` 表当前是 private table;由于生成脚本已加 `--include-private`,本次 codegen 已生成 `analytics_date_dimension_table.rs`,可通过 `ctx.db.analytics_date_dimension()` 访问 client cache / query builder。
|
||||
- bindings 目录是自动生成产物,本次以项目脚本整体刷新,除新增 analytics 文件外,也带来了大量已存在 table/reducer/procedure 文件的格式化/生成器输出差异。
|
||||
|
||||
### 5. 测试覆盖
|
||||
|
||||
已新增测试:
|
||||
|
||||
```text
|
||||
server-rs/crates/module-runtime/tests/analytics_date_dimension.rs
|
||||
server-rs/crates/module-runtime/tests/profile_task_scope.rs
|
||||
server-rs/crates/shared-contracts/tests/profile_task_contract.rs
|
||||
```
|
||||
|
||||
覆盖重点:
|
||||
|
||||
- `2024-02-29` 闰年。
|
||||
- `2025-12-29` ISO week 跨年。
|
||||
- `2026-01-01` 跨年周。
|
||||
- `2026-03-31` Q1 结束。
|
||||
- `2026-04-01` Q2 开始。
|
||||
- `2026-12-31` 年末。
|
||||
- 非法日期解析失败。
|
||||
- 超出日期维表支持范围失败。
|
||||
- 个人任务 `scopeKind=user` 成功。
|
||||
- 个人任务 `scopeKind=site/module/work` 失败。
|
||||
- `work` scope 不会静默映射到 `user_id`。
|
||||
- Admin 个人任务配置 contract 保持 `scopeKind: user`。
|
||||
|
||||
## 已验证命令
|
||||
|
||||
从 `server-rs/` 执行:
|
||||
|
||||
```bash
|
||||
cargo fmt -p module-runtime -p spacetime-module -p spacetime-client
|
||||
cargo test -p spacetime-client --no-run
|
||||
cargo test -p spacetime-module --no-run
|
||||
cargo test -p module-runtime --test analytics_date_dimension
|
||||
cargo test -p module-runtime --test profile_task_scope
|
||||
cargo test -p shared-contracts --test profile_task_contract
|
||||
```
|
||||
|
||||
从项目根目录执行:
|
||||
|
||||
```bash
|
||||
npm run admin-web:typecheck
|
||||
```
|
||||
|
||||
当前结果:
|
||||
|
||||
- `spacetime-client --no-run` 编译通过。
|
||||
- `spacetime-module --no-run` 编译通过。
|
||||
- `analytics_date_dimension` 测试通过:8 passed。
|
||||
- `profile_task_scope` 测试通过:3 passed。
|
||||
- `profile_task_contract` 测试通过:2 passed。
|
||||
- `admin-web:typecheck` 通过。
|
||||
|
||||
已知非本阶段阻塞:
|
||||
|
||||
- 完整运行 `cargo test -p spacetime-module` 时,曾出现既有 puzzle 测试失败:
|
||||
|
||||
```text
|
||||
puzzle::tests::puzzle_preview_is_publishable_with_complete_draft FAILED
|
||||
assertion failed: preview.publish_ready
|
||||
```
|
||||
|
||||
该失败与当前埋点范围和日期维表改动无直接关系,本阶段以 `cargo test -p spacetime-module --no-run` 作为编译门禁。
|
||||
|
||||
## 当前未完成 / 暂缓项
|
||||
|
||||
### 1. 暂未新增 spacetime-client facade
|
||||
|
||||
当前没有新增:
|
||||
|
||||
```text
|
||||
SpacetimeClient::ensure_analytics_date_dimension_for_date
|
||||
SpacetimeClient::seed_analytics_date_dimensions
|
||||
```
|
||||
|
||||
原因:
|
||||
|
||||
- 生成脚本已加入 `--include-private`,private reducer/type/table bindings 已可用于后续 facade 实现。
|
||||
- 但 Step 7/8/9 暂缓,尚未由 `api-server` 或统计查询链路调用该能力。
|
||||
- 如后续只是 SpacetimeDB module 内部写入统计时 ensure,可以直接复用 module 内部 helper,不一定需要远程 client facade。
|
||||
- 若后续需要由 API 或运维接口触发 seed/ensure,可基于本次已生成的 reducer bindings 再补 facade。
|
||||
|
||||
### 2. Step 7/8/9 暂缓
|
||||
|
||||
本阶段未接入:
|
||||
|
||||
- 事件写入链路自动 ensure 日期维表。
|
||||
- 聚合查询 API 的 `granularity = day | week | month | quarter | year`。
|
||||
- shared contracts / 前端 analytics contracts。
|
||||
- 历史事件回填。
|
||||
|
||||
这些应作为后续阶段单独设计和落地。
|
||||
|
||||
## 后续建议顺序
|
||||
|
||||
1. 如需提交本阶段改动,确认是否接受 `module_bindings` 整体刷新带来的大量生成文件 diff。
|
||||
2. 如希望 diff 更小,可评估仅提交 analytics date dimension 相关生成文件与 `mod.rs`;但需要非常谨慎,因为 `module_bindings` 是自动生成产物。
|
||||
3. 如需要由 `api-server` 触发 seed/ensure,再补 `spacetime-client` facade。
|
||||
4. 进入 Step 7/8/9:事件写入链路、聚合查询 API、前端 contracts。
|
||||
|
||||
## 阶段结论
|
||||
|
||||
当前阶段已经完成“个人任务埋点范围收紧”和“日期维表 module 侧能力”的核心落地,并已生成 SpacetimeDB Rust client bindings。
|
||||
|
||||
剩余工作不再是 bindings 环境阻塞,而是后续业务接入范围:是否增加 `spacetime-client` facade,以及是否继续推进事件写入链路、聚合查询 API 和前端 analytics contracts。
|
||||
18
docs/technical/RUNTIME_PROFILE_TASK_SCOPE_2026-05-04.md
Normal file
18
docs/technical/RUNTIME_PROFILE_TASK_SCOPE_2026-05-04.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# 个人任务 scope 限制说明(2026-05-04)
|
||||
|
||||
## 背景
|
||||
|
||||
个人任务配置首版只支持按用户维度统计进度,即 `RuntimeTrackingScopeKind::User` / API `scopeKind: "user"`。`site`、`module`、`work` 未来可作为全站、模块或作品维度任务扩展,但当前不应被个人任务配置接受。
|
||||
|
||||
## 后端约束
|
||||
|
||||
- HTTP 管理接口 `admin_upsert_profile_task_config` 在解析 `scopeKind` 后立即校验:非 `user` 返回 400,并提示“个人任务 scopeKind 首版仅支持 user”。
|
||||
- 领域构造函数 `build_runtime_profile_task_config_admin_upsert_input` 兜底校验:非 `RuntimeTrackingScopeKind::User` 返回 `RuntimeProfileFieldError::UnsupportedProfileTaskScopeKind`。
|
||||
- SpacetimeDB 模块内 `profile_task_tracking_scope_id` 不再把 `Work` 静默映射到 `user_id`;非 User scope 返回 `None`,个人任务进度读取按 0 处理,避免错误串桶。
|
||||
|
||||
## 测试覆盖
|
||||
|
||||
`module-runtime` 单元测试覆盖:
|
||||
|
||||
- `User` scope 可成功构造个人任务配置输入。
|
||||
- `Site` / `Module` / `Work` scope 均被拒绝,错误为 `UnsupportedProfileTaskScopeKind`。
|
||||
@@ -24,7 +24,7 @@ spacetime sql <db> "SELECT * FROM custom_world_gallery_entry"
|
||||
| --- | --- |
|
||||
| 运维迁移 | `database_migration_operator`, `database_migration_import_chunk` |
|
||||
| 认证 | `auth_store_snapshot`, `user_account`, `auth_identity`, `refresh_session` |
|
||||
| 运行时档案 | `runtime_setting`, `runtime_snapshot`, `user_browse_history`, `profile_dashboard_state`, `profile_wallet_ledger`, `tracking_event`, `tracking_daily_stat`, `profile_task_config`, `profile_task_progress`, `profile_task_reward_claim`, `profile_redeem_code`, `profile_redeem_code_usage`, `profile_invite_code`, `profile_referral_relation`, `profile_played_world`, `profile_membership`, `profile_recharge_order`, `profile_save_archive` |
|
||||
| 运行时档案 | `runtime_setting`, `runtime_snapshot`, `user_browse_history`, `profile_dashboard_state`, `profile_wallet_ledger`, `analytics_date_dimension`, `tracking_event`, `tracking_daily_stat`, `profile_task_config`, `profile_task_progress`, `profile_task_reward_claim`, `profile_redeem_code`, `profile_redeem_code_usage`, `profile_invite_code`, `profile_referral_relation`, `profile_played_world`, `profile_membership`, `profile_recharge_order`, `profile_save_archive` |
|
||||
| RPG 运行时 | `story_session`, `story_event`, `npc_state`, `inventory_slot`, `battle_state`, `treasure_record`, `quest_record`, `quest_log`, `player_progression`, `chapter_progression` |
|
||||
| 世界创作 | `custom_world_profile`, `custom_world_session`, `custom_world_agent_session`, `custom_world_agent_message`, `custom_world_agent_operation`, `custom_world_draft_card`, `custom_world_gallery_entry` |
|
||||
| 拼图 | `puzzle_agent_session`, `puzzle_agent_message`, `puzzle_work_profile`, `puzzle_event`, `puzzle_runtime_run`, `puzzle_leaderboard_entry` |
|
||||
@@ -158,6 +158,20 @@ SELECT * FROM profile_wallet_ledger WHERE user_id = '<user_id>';
|
||||
SELECT * FROM profile_wallet_ledger WHERE user_id = '<user_id>' ORDER BY created_at DESC;
|
||||
```
|
||||
|
||||
### `analytics_date_dimension`
|
||||
|
||||
- 作用:分析日期维表,每个北京时间业务自然日一行,用于把日桶映射到周、月、季度和年。
|
||||
- 结构:`date_key PK: i64`, `calendar_date: String`, `weekday: u8`, `iso_week_key: i32`, `week_start_date_key: i64`, `week_end_date_key: i64`, `month_key: i32`, `month_start_date_key: i64`, `month_end_date_key: i64`, `quarter_key: i32`, `quarter_start_date_key: i64`, `quarter_end_date_key: i64`, `year_key: i32`, `year_start_date_key: i64`, `year_end_date_key: i64`, `created_at: Timestamp`, `updated_at: Timestamp`。
|
||||
- 索引:主键 `date_key`,`iso_week_key`,`month_key`,`quarter_key`,`year_key`。
|
||||
- 写入口:`ensure_analytics_date_dimension_for_date({ date_key })` 幂等补单日;`seed_analytics_date_dimensions({ start_date, end_date })` 按 `YYYY-MM-DD` 闭区间幂等批量补种,单次最多 `3660` 天。
|
||||
- 口径:`date_key` 沿用当前埋点日桶 `floor((occurred_at_micros + 8h) / 1d)`,`calendar_date` 是该北京时间业务日的公历日期。
|
||||
|
||||
```sql
|
||||
SELECT * FROM analytics_date_dimension WHERE date_key = <date_key>;
|
||||
SELECT * FROM analytics_date_dimension WHERE iso_week_key = 202501 ORDER BY date_key;
|
||||
SELECT * FROM analytics_date_dimension WHERE month_key = 202402 ORDER BY date_key;
|
||||
```
|
||||
|
||||
### `tracking_event`
|
||||
|
||||
- 作用:埋点原始事件表,保存整站、作品、模块和用户层的原始事实。
|
||||
|
||||
@@ -142,6 +142,7 @@ function buildGenerateArgs(target, outDir) {
|
||||
outDir,
|
||||
'--module-path',
|
||||
MODULE_PATH,
|
||||
'--include-private',
|
||||
'--yes',
|
||||
];
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ use shared_contracts::runtime::{
|
||||
RedeemProfileRewardCodeRequest, RedeemProfileRewardCodeResponse, TRACKING_SCOPE_KIND_MODULE,
|
||||
TRACKING_SCOPE_KIND_SITE, TRACKING_SCOPE_KIND_USER, TRACKING_SCOPE_KIND_WORK,
|
||||
};
|
||||
use shared_kernel::{offset_datetime_to_unix_micros, parse_rfc3339};
|
||||
use spacetime_client::SpacetimeClientError;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
@@ -369,6 +370,14 @@ pub async fn admin_upsert_profile_task_config(
|
||||
AppError::from_status(StatusCode::BAD_REQUEST).with_message(error),
|
||||
)
|
||||
})?;
|
||||
// 中文注释:个人任务配置首版只开放 User scope,HTTP 层先返回清晰错误,领域层再兜底。
|
||||
if scope_kind != RuntimeTrackingScopeKind::User {
|
||||
return Err(runtime_profile_error_response(
|
||||
&request_context,
|
||||
AppError::from_status(StatusCode::BAD_REQUEST)
|
||||
.with_message("个人任务 scopeKind 首版仅支持 user"),
|
||||
));
|
||||
}
|
||||
let updated_at_micros = OffsetDateTime::now_utc().unix_timestamp_nanos() / 1_000;
|
||||
let record = state
|
||||
.spacetime_client()
|
||||
@@ -558,6 +567,10 @@ pub async fn admin_upsert_profile_invite_code(
|
||||
) -> Result<Json<Value>, Response> {
|
||||
let metadata_json = normalize_admin_invite_code_metadata(payload.metadata)
|
||||
.map_err(|error| runtime_profile_error_response(&request_context, error))?;
|
||||
let starts_at_micros = parse_admin_invite_code_time_field("startsAt", payload.starts_at)
|
||||
.map_err(|error| runtime_profile_error_response(&request_context, error))?;
|
||||
let expires_at_micros = parse_admin_invite_code_time_field("expiresAt", payload.expires_at)
|
||||
.map_err(|error| runtime_profile_error_response(&request_context, error))?;
|
||||
let updated_at_micros = OffsetDateTime::now_utc().unix_timestamp_nanos() / 1_000;
|
||||
let record = state
|
||||
.spacetime_client()
|
||||
@@ -565,6 +578,8 @@ pub async fn admin_upsert_profile_invite_code(
|
||||
admin.session().username.clone(),
|
||||
payload.invite_code,
|
||||
metadata_json,
|
||||
starts_at_micros,
|
||||
expires_at_micros,
|
||||
updated_at_micros as i64,
|
||||
)
|
||||
.await
|
||||
@@ -873,6 +888,27 @@ fn normalize_admin_invite_code_metadata(metadata: Option<Value>) -> Result<Strin
|
||||
Ok(metadata_json)
|
||||
}
|
||||
|
||||
fn parse_admin_invite_code_time_field(
|
||||
field: &'static str,
|
||||
value: Option<String>,
|
||||
) -> Result<Option<i64>, AppError> {
|
||||
let Some(value) = value else {
|
||||
return Ok(None);
|
||||
};
|
||||
let value = value.trim();
|
||||
if value.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let parsed = parse_rfc3339(value).map_err(|error| {
|
||||
AppError::from_status(StatusCode::BAD_REQUEST)
|
||||
.with_message(format!("邀请码 {field} 必须是 RFC3339 时间字符串"))
|
||||
.with_details(json!({ "field": field, "message": error }))
|
||||
})?;
|
||||
|
||||
Ok(Some(offset_datetime_to_unix_micros(parsed)))
|
||||
}
|
||||
|
||||
fn parse_profile_redeem_code_mode(raw: &str) -> Result<RuntimeProfileRedeemCodeMode, String> {
|
||||
match raw.trim().to_ascii_lowercase().as_str() {
|
||||
"public" => Ok(RuntimeProfileRedeemCodeMode::Public),
|
||||
@@ -932,6 +968,9 @@ fn build_profile_invite_code_admin_response(
|
||||
user_id: record.user_id,
|
||||
invite_code: record.invite_code,
|
||||
metadata,
|
||||
starts_at: record.starts_at,
|
||||
expires_at: record.expires_at,
|
||||
status: record.status.as_str().to_string(),
|
||||
created_at: record.created_at,
|
||||
updated_at: record.updated_at,
|
||||
}
|
||||
@@ -1256,9 +1295,8 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
async fn admin_profile_task_routes_require_admin_authentication() {
|
||||
let app = build_router(
|
||||
AppState::new(admin_enabled_test_config()).expect("state should build"),
|
||||
);
|
||||
let app =
|
||||
build_router(AppState::new(admin_enabled_test_config()).expect("state should build"));
|
||||
|
||||
let list_response = app
|
||||
.clone()
|
||||
@@ -1302,9 +1340,8 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
async fn admin_profile_code_list_routes_require_admin_authentication() {
|
||||
let app = build_router(
|
||||
AppState::new(admin_enabled_test_config()).expect("state should build"),
|
||||
);
|
||||
let app =
|
||||
build_router(AppState::new(admin_enabled_test_config()).expect("state should build"));
|
||||
|
||||
for uri in [
|
||||
"/admin/api/profile/redeem-codes",
|
||||
|
||||
@@ -223,6 +223,189 @@ pub fn runtime_profile_beijing_day_key(now_micros: i64) -> i64 {
|
||||
.div_euclid(PROFILE_RUNTIME_DAY_MICROS)
|
||||
}
|
||||
|
||||
/// 从 YYYY-MM-DD 解析分析业务日 date_key。
|
||||
///
|
||||
/// 这里故意不引入时区库:date_key 本身就是“北京时间日历日期自 Unix 纪元起的天数”。
|
||||
pub fn parse_analytics_calendar_date_key(
|
||||
calendar_date: &str,
|
||||
) -> Result<i64, RuntimeProfileFieldError> {
|
||||
let (year, month, day) = parse_calendar_date_parts(calendar_date)?;
|
||||
validate_calendar_date(year, month, day)?;
|
||||
let date_key = days_from_civil(year, month, day);
|
||||
validate_analytics_date_dimension_date_key(date_key)?;
|
||||
Ok(date_key)
|
||||
}
|
||||
|
||||
/// 校验分析日期维表 date_key 是否位于业务允许范围内。
|
||||
///
|
||||
/// 裸 i64 date_key 可由 reducer 直接传入,因此在进入日历算法前先限制范围,避免极端输入
|
||||
/// 生成无意义日期或触发整数边界风险。
|
||||
pub fn validate_analytics_date_dimension_date_key(
|
||||
date_key: i64,
|
||||
) -> Result<(), RuntimeProfileFieldError> {
|
||||
let min_date_key = days_from_civil(2000, 1, 1);
|
||||
let max_date_key = days_from_civil(2100, 12, 31);
|
||||
if date_key < min_date_key || date_key > max_date_key {
|
||||
return Err(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn build_analytics_date_dimension_from_date_key(
|
||||
date_key: i64,
|
||||
) -> AnalyticsDateDimensionSnapshot {
|
||||
let (year, month, day) = civil_from_days(date_key);
|
||||
let weekday = weekday_from_date_key(date_key);
|
||||
let iso_week_key = iso_week_key(year, month, day, weekday);
|
||||
let week_start_date_key = date_key - i64::from(weekday - 1);
|
||||
let week_end_date_key = week_start_date_key + 6;
|
||||
let month_start_date_key = days_from_civil(year, month, 1);
|
||||
let month_end_date_key = days_from_civil(year, month, days_in_month(year, month));
|
||||
let quarter = (month - 1) / 3 + 1;
|
||||
let quarter_start_month = (quarter - 1) * 3 + 1;
|
||||
let quarter_end_month = quarter_start_month + 2;
|
||||
let quarter_start_date_key = days_from_civil(year, quarter_start_month, 1);
|
||||
let quarter_end_date_key = days_from_civil(
|
||||
year,
|
||||
quarter_end_month,
|
||||
days_in_month(year, quarter_end_month),
|
||||
);
|
||||
let year_start_date_key = days_from_civil(year, 1, 1);
|
||||
let year_end_date_key = days_from_civil(year, 12, 31);
|
||||
|
||||
AnalyticsDateDimensionSnapshot {
|
||||
date_key,
|
||||
calendar_date: format!("{year:04}-{month:02}-{day:02}"),
|
||||
weekday,
|
||||
iso_week_key,
|
||||
week_start_date_key,
|
||||
week_end_date_key,
|
||||
month_key: year * 100 + i32::from(month),
|
||||
month_start_date_key,
|
||||
month_end_date_key,
|
||||
quarter_key: year * 10 + i32::from(quarter),
|
||||
quarter_start_date_key,
|
||||
quarter_end_date_key,
|
||||
year_key: year,
|
||||
year_start_date_key,
|
||||
year_end_date_key,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_calendar_date_parts(
|
||||
calendar_date: &str,
|
||||
) -> Result<(i32, u8, u8), RuntimeProfileFieldError> {
|
||||
let mut parts = calendar_date.trim().split('-');
|
||||
let year = parts
|
||||
.next()
|
||||
.and_then(|value| value.parse::<i32>().ok())
|
||||
.ok_or(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate)?;
|
||||
let month = parts
|
||||
.next()
|
||||
.and_then(|value| value.parse::<u8>().ok())
|
||||
.ok_or(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate)?;
|
||||
let day = parts
|
||||
.next()
|
||||
.and_then(|value| value.parse::<u8>().ok())
|
||||
.ok_or(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate)?;
|
||||
if parts.next().is_some() {
|
||||
return Err(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate);
|
||||
}
|
||||
Ok((year, month, day))
|
||||
}
|
||||
|
||||
fn validate_calendar_date(year: i32, month: u8, day: u8) -> Result<(), RuntimeProfileFieldError> {
|
||||
if !(1..=12).contains(&month) || day == 0 || day > days_in_month(year, month) {
|
||||
return Err(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn days_in_month(year: i32, month: u8) -> u8 {
|
||||
match month {
|
||||
1 | 3 | 5 | 7 | 8 | 10 | 12 => 31,
|
||||
4 | 6 | 9 | 11 => 30,
|
||||
2 if is_leap_year(year) => 29,
|
||||
2 => 28,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_leap_year(year: i32) -> bool {
|
||||
(year % 4 == 0 && year % 100 != 0) || year % 400 == 0
|
||||
}
|
||||
|
||||
fn weekday_from_date_key(date_key: i64) -> u8 {
|
||||
// 中文注释:1970-01-01 是周四;这里返回 ISO weekday,周一=1,周日=7。
|
||||
(date_key + 3).rem_euclid(7) as u8 + 1
|
||||
}
|
||||
|
||||
fn iso_week_key(year: i32, month: u8, day: u8, weekday: u8) -> i32 {
|
||||
let ordinal = ordinal_day(year, month, day);
|
||||
let week = (i32::from(ordinal) - i32::from(weekday) + 10).div_euclid(7);
|
||||
let iso_year = if week < 1 {
|
||||
year - 1
|
||||
} else if week > iso_weeks_in_year(year) {
|
||||
year + 1
|
||||
} else {
|
||||
year
|
||||
};
|
||||
let iso_week = if week < 1 {
|
||||
iso_weeks_in_year(year - 1)
|
||||
} else if week > iso_weeks_in_year(year) {
|
||||
1
|
||||
} else {
|
||||
week
|
||||
};
|
||||
iso_year * 100 + iso_week
|
||||
}
|
||||
|
||||
fn ordinal_day(year: i32, month: u8, day: u8) -> u16 {
|
||||
(1..month)
|
||||
.map(|current_month| u16::from(days_in_month(year, current_month)))
|
||||
.sum::<u16>()
|
||||
+ u16::from(day)
|
||||
}
|
||||
|
||||
fn iso_weeks_in_year(year: i32) -> i32 {
|
||||
let jan_first_weekday = weekday_from_date_key(days_from_civil(year, 1, 1));
|
||||
if jan_first_weekday == 4 || (jan_first_weekday == 3 && is_leap_year(year)) {
|
||||
53
|
||||
} else {
|
||||
52
|
||||
}
|
||||
}
|
||||
|
||||
fn days_from_civil(year: i32, month: u8, day: u8) -> i64 {
|
||||
// 中文注释:Howard Hinnant civil calendar 算法,返回 1970-01-01 起的日序号。
|
||||
let adjusted_year = year - if month <= 2 { 1 } else { 0 };
|
||||
let era = adjusted_year.div_euclid(400);
|
||||
let year_of_era = adjusted_year - era * 400;
|
||||
let month = i32::from(month);
|
||||
let day = i32::from(day);
|
||||
let month_prime = month + if month > 2 { -3 } else { 9 };
|
||||
let day_of_year = (153 * month_prime + 2) / 5 + day - 1;
|
||||
let day_of_era = year_of_era * 365 + year_of_era / 4 - year_of_era / 100 + day_of_year;
|
||||
i64::from(era * 146_097 + day_of_era - 719_468)
|
||||
}
|
||||
|
||||
fn civil_from_days(date_key: i64) -> (i32, u8, u8) {
|
||||
// 中文注释:days_from_civil 的反向算法,避免依赖运行环境时区。
|
||||
let z = date_key + 719_468;
|
||||
let era = z.div_euclid(146_097);
|
||||
let day_of_era = z - era * 146_097;
|
||||
let year_of_era = (day_of_era - day_of_era / 1_460 + day_of_era / 36_524
|
||||
- day_of_era / 146_096)
|
||||
.div_euclid(365);
|
||||
let mut year = year_of_era + era * 400;
|
||||
let day_of_year = day_of_era - (365 * year_of_era + year_of_era / 4 - year_of_era / 100);
|
||||
let month_prime = (5 * day_of_year + 2).div_euclid(153);
|
||||
let day = day_of_year - (153 * month_prime + 2).div_euclid(5) + 1;
|
||||
let month = month_prime + if month_prime < 10 { 3 } else { -9 };
|
||||
year += if month <= 2 { 1 } else { 0 };
|
||||
(year as i32, month as u8, day as u8)
|
||||
}
|
||||
|
||||
pub fn build_default_runtime_profile_task_config(
|
||||
updated_at_micros: i64,
|
||||
updated_by: String,
|
||||
@@ -416,10 +599,21 @@ pub fn build_runtime_profile_redeem_code_record(
|
||||
pub fn build_runtime_profile_invite_code_record(
|
||||
snapshot: RuntimeProfileInviteCodeSnapshot,
|
||||
) -> RuntimeProfileInviteCodeRecord {
|
||||
let status = crate::commands::resolve_runtime_profile_invite_code_status(
|
||||
snapshot.starts_at_micros,
|
||||
snapshot.expires_at_micros,
|
||||
snapshot.updated_at_micros,
|
||||
);
|
||||
|
||||
RuntimeProfileInviteCodeRecord {
|
||||
user_id: snapshot.user_id,
|
||||
invite_code: snapshot.invite_code,
|
||||
metadata_json: snapshot.metadata_json,
|
||||
starts_at: snapshot.starts_at_micros.map(format_utc_micros),
|
||||
starts_at_micros: snapshot.starts_at_micros,
|
||||
expires_at: snapshot.expires_at_micros.map(format_utc_micros),
|
||||
expires_at_micros: snapshot.expires_at_micros,
|
||||
status,
|
||||
created_at: format_utc_micros(snapshot.created_at_micros),
|
||||
created_at_micros: snapshot.created_at_micros,
|
||||
updated_at: format_utc_micros(snapshot.updated_at_micros),
|
||||
|
||||
@@ -89,8 +89,8 @@ pub fn build_runtime_tracking_event_input(
|
||||
) -> Result<RuntimeTrackingEventInput, RuntimeProfileFieldError> {
|
||||
let event_id = normalize_required_string(event_id)
|
||||
.ok_or(RuntimeProfileFieldError::MissingTrackingEventId)?;
|
||||
let event_key =
|
||||
normalize_required_string(event_key).ok_or(RuntimeProfileFieldError::MissingTaskEventKey)?;
|
||||
let event_key = normalize_required_string(event_key)
|
||||
.ok_or(RuntimeProfileFieldError::MissingTaskEventKey)?;
|
||||
let scope_id = normalize_required_string(scope_id)
|
||||
.ok_or(RuntimeProfileFieldError::MissingTrackingScopeId)?;
|
||||
let metadata_json = normalize_tracking_metadata_json(metadata_json)?;
|
||||
@@ -151,8 +151,12 @@ pub fn build_runtime_profile_task_config_admin_upsert_input(
|
||||
let task_id = normalize_profile_task_id(task_id)?;
|
||||
let title =
|
||||
normalize_required_string(title).ok_or(RuntimeProfileFieldError::MissingTaskTitle)?;
|
||||
let event_key =
|
||||
normalize_required_string(event_key).ok_or(RuntimeProfileFieldError::MissingTaskEventKey)?;
|
||||
let event_key = normalize_required_string(event_key)
|
||||
.ok_or(RuntimeProfileFieldError::MissingTaskEventKey)?;
|
||||
// 中文注释:个人任务首版只按用户维度累计,避免 site/work/module 误复用用户桶。
|
||||
if scope_kind != RuntimeTrackingScopeKind::User {
|
||||
return Err(RuntimeProfileFieldError::UnsupportedProfileTaskScopeKind);
|
||||
}
|
||||
if threshold == 0 {
|
||||
return Err(RuntimeProfileFieldError::InvalidTaskThreshold);
|
||||
}
|
||||
@@ -326,17 +330,25 @@ pub fn build_runtime_profile_invite_code_admin_upsert_input(
|
||||
admin_user_id: String,
|
||||
invite_code: String,
|
||||
metadata_json: String,
|
||||
starts_at_micros: Option<i64>,
|
||||
expires_at_micros: Option<i64>,
|
||||
updated_at_micros: i64,
|
||||
) -> Result<RuntimeProfileInviteCodeAdminUpsertInput, RuntimeProfileFieldError> {
|
||||
let admin_user_id = normalize_runtime_profile_user_id(admin_user_id)?;
|
||||
let invite_code =
|
||||
normalize_invite_code(invite_code).ok_or(RuntimeProfileFieldError::MissingInviteCode)?;
|
||||
let metadata_json = normalize_invite_code_metadata_json(metadata_json)?;
|
||||
crate::commands::validate_runtime_profile_invite_code_validity_window(
|
||||
starts_at_micros,
|
||||
expires_at_micros,
|
||||
)?;
|
||||
|
||||
Ok(RuntimeProfileInviteCodeAdminUpsertInput {
|
||||
admin_user_id,
|
||||
invite_code,
|
||||
metadata_json,
|
||||
starts_at_micros,
|
||||
expires_at_micros,
|
||||
updated_at_micros,
|
||||
})
|
||||
}
|
||||
@@ -639,6 +651,40 @@ pub fn normalize_invite_code_metadata_json(
|
||||
serde_json::to_string(&parsed).map_err(|_| RuntimeProfileFieldError::InvalidInviteCodeMetadata)
|
||||
}
|
||||
|
||||
pub fn validate_runtime_profile_invite_code_validity_window(
|
||||
starts_at_micros: Option<i64>,
|
||||
expires_at_micros: Option<i64>,
|
||||
) -> Result<(), RuntimeProfileFieldError> {
|
||||
if matches!((starts_at_micros, expires_at_micros), (Some(starts_at), Some(expires_at)) if starts_at > expires_at)
|
||||
{
|
||||
return Err(RuntimeProfileFieldError::InvalidInviteCodeValidityWindow);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn resolve_runtime_profile_invite_code_status(
|
||||
starts_at_micros: Option<i64>,
|
||||
expires_at_micros: Option<i64>,
|
||||
now_micros: i64,
|
||||
) -> RuntimeProfileInviteCodeStatus {
|
||||
if starts_at_micros
|
||||
.map(|starts_at| now_micros < starts_at)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
return RuntimeProfileInviteCodeStatus::Pending;
|
||||
}
|
||||
|
||||
if expires_at_micros
|
||||
.map(|expires_at| now_micros >= expires_at)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
return RuntimeProfileInviteCodeStatus::Expired;
|
||||
}
|
||||
|
||||
RuntimeProfileInviteCodeStatus::Active
|
||||
}
|
||||
|
||||
fn normalize_tracking_metadata_json(value: String) -> Result<String, RuntimeProfileFieldError> {
|
||||
let trimmed = value.trim();
|
||||
if trimmed.is_empty() {
|
||||
|
||||
@@ -21,6 +21,10 @@ pub const PROFILE_INVITE_CODE_METADATA_DEFAULT_JSON: &str = "{}";
|
||||
pub const PROFILE_INVITE_CODE_METADATA_MAX_BYTES: usize = 4096;
|
||||
pub const PROFILE_RUNTIME_DAY_MICROS: i64 = 86_400_000_000;
|
||||
pub const PROFILE_TASK_BEIJING_OFFSET_MICROS: i64 = 28_800_000_000;
|
||||
pub const ANALYTICS_DATE_DIMENSION_MAX_SEED_DAYS: i64 = 3_660;
|
||||
// 中文注释:日期维表当前只预置运营统计可接受的业务日期范围,避免裸 date_key 极值进入日历算法。
|
||||
pub const ANALYTICS_DATE_DIMENSION_MIN_DATE: &str = "2000-01-01";
|
||||
pub const ANALYTICS_DATE_DIMENSION_MAX_DATE: &str = "2100-12-31";
|
||||
pub const PROFILE_TASK_ID_DAILY_LOGIN: &str = "daily_login";
|
||||
pub const PROFILE_TASK_EVENT_KEY_DAILY_LOGIN: &str = "daily_login";
|
||||
pub const PROFILE_TASK_DEFAULT_TITLE_DAILY_LOGIN: &str = "每日登录";
|
||||
@@ -30,6 +34,30 @@ pub const SAVE_SNAPSHOT_VERSION: u32 = 2;
|
||||
pub const DEFAULT_SAVE_ARCHIVE_SUMMARY_TEXT: &str = "继续推进上一次保存的故事。";
|
||||
pub const PROFILE_RECHARGE_PAYMENT_CHANNEL_MOCK: &str = "mock";
|
||||
|
||||
/// 分析日期维表的纯领域快照。
|
||||
///
|
||||
/// date_key 沿用现有北京时间自然日桶:floor((occurred_at_micros + 8h) / 1d)。
|
||||
/// calendar_date 使用该业务日对应的公历日期,格式固定为 YYYY-MM-DD。
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct AnalyticsDateDimensionSnapshot {
|
||||
pub date_key: i64,
|
||||
pub calendar_date: String,
|
||||
pub weekday: u8,
|
||||
pub iso_week_key: i32,
|
||||
pub week_start_date_key: i64,
|
||||
pub week_end_date_key: i64,
|
||||
pub month_key: i32,
|
||||
pub month_start_date_key: i64,
|
||||
pub month_end_date_key: i64,
|
||||
pub quarter_key: i32,
|
||||
pub quarter_start_date_key: i64,
|
||||
pub quarter_end_date_key: i64,
|
||||
pub year_key: i32,
|
||||
pub year_start_date_key: i64,
|
||||
pub year_end_date_key: i64,
|
||||
}
|
||||
|
||||
/// 运行时平台主题。
|
||||
///
|
||||
/// 当前只冻结 light/dark 两种主题,避免各层散落字符串字面量。
|
||||
@@ -411,6 +439,24 @@ impl RuntimeProfileTaskStatus {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum RuntimeProfileInviteCodeStatus {
|
||||
Pending,
|
||||
Active,
|
||||
Expired,
|
||||
}
|
||||
|
||||
impl RuntimeProfileInviteCodeStatus {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Pending => "pending",
|
||||
Self::Active => "active",
|
||||
Self::Expired => "expired",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct RuntimeTrackingEventInput {
|
||||
@@ -904,6 +950,8 @@ pub struct RuntimeProfileInviteCodeAdminUpsertInput {
|
||||
pub admin_user_id: String,
|
||||
pub invite_code: String,
|
||||
pub metadata_json: String,
|
||||
pub starts_at_micros: Option<i64>,
|
||||
pub expires_at_micros: Option<i64>,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
@@ -919,6 +967,8 @@ pub struct RuntimeProfileInviteCodeSnapshot {
|
||||
pub user_id: String,
|
||||
pub invite_code: String,
|
||||
pub metadata_json: String,
|
||||
pub starts_at_micros: Option<i64>,
|
||||
pub expires_at_micros: Option<i64>,
|
||||
pub created_at_micros: i64,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
@@ -1289,6 +1339,11 @@ pub struct RuntimeProfileInviteCodeRecord {
|
||||
pub user_id: String,
|
||||
pub invite_code: String,
|
||||
pub metadata_json: String,
|
||||
pub starts_at: Option<String>,
|
||||
pub starts_at_micros: Option<i64>,
|
||||
pub expires_at: Option<String>,
|
||||
pub expires_at_micros: Option<i64>,
|
||||
pub status: RuntimeProfileInviteCodeStatus,
|
||||
pub created_at: String,
|
||||
pub created_at_micros: i64,
|
||||
pub updated_at: String,
|
||||
|
||||
@@ -52,6 +52,7 @@ pub enum RuntimeProfileFieldError {
|
||||
InvalidRedeemCodeReward,
|
||||
InvalidRedeemCodeMaxUses,
|
||||
InvalidInviteCodeMetadata,
|
||||
InvalidInviteCodeValidityWindow,
|
||||
MissingTaskId,
|
||||
MissingTaskTitle,
|
||||
MissingTaskEventKey,
|
||||
@@ -59,6 +60,7 @@ pub enum RuntimeProfileFieldError {
|
||||
MissingTrackingScopeId,
|
||||
InvalidTaskCycle,
|
||||
InvalidTaskScopeKind,
|
||||
UnsupportedProfileTaskScopeKind,
|
||||
InvalidTaskThreshold,
|
||||
InvalidTaskReward,
|
||||
TaskDisabled,
|
||||
@@ -77,6 +79,7 @@ pub enum RuntimeProfileFieldError {
|
||||
actual_session_id: String,
|
||||
},
|
||||
NonPersistentRuntimeSnapshot,
|
||||
InvalidAnalyticsCalendarDate,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RuntimeProfileFieldError {
|
||||
@@ -98,6 +101,7 @@ impl std::fmt::Display for RuntimeProfileFieldError {
|
||||
Self::InvalidInviteCodeMetadata => {
|
||||
f.write_str("邀请码 metadata 必须是合法 JSON object")
|
||||
}
|
||||
Self::InvalidInviteCodeValidityWindow => f.write_str("邀请码开始时间不能晚于截止时间"),
|
||||
Self::MissingTaskId => f.write_str("profile_task.task_id 不能为空"),
|
||||
Self::MissingTaskTitle => f.write_str("profile_task.title 不能为空"),
|
||||
Self::MissingTaskEventKey => f.write_str("profile_task.event_key 不能为空"),
|
||||
@@ -105,6 +109,9 @@ impl std::fmt::Display for RuntimeProfileFieldError {
|
||||
Self::MissingTrackingScopeId => f.write_str("tracking_event.scope_id 不能为空"),
|
||||
Self::InvalidTaskCycle => f.write_str("profile_task.cycle 无效"),
|
||||
Self::InvalidTaskScopeKind => f.write_str("profile_task.scope_kind 无效"),
|
||||
Self::UnsupportedProfileTaskScopeKind => {
|
||||
f.write_str("个人任务 scope_kind 首版仅支持 user")
|
||||
}
|
||||
Self::InvalidTaskThreshold => f.write_str("profile_task.threshold 必须大于 0"),
|
||||
Self::InvalidTaskReward => f.write_str("profile_task.reward_points 必须大于 0"),
|
||||
Self::TaskDisabled => f.write_str("任务已停用"),
|
||||
@@ -130,6 +137,9 @@ impl std::fmt::Display for RuntimeProfileFieldError {
|
||||
Self::NonPersistentRuntimeSnapshot => {
|
||||
f.write_str("预览或测试运行态不能创建正式 checkpoint")
|
||||
}
|
||||
Self::InvalidAnalyticsCalendarDate => {
|
||||
f.write_str("analytics_date_dimension.calendar_date 必须是合法 YYYY-MM-DD 日期")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
mod application;
|
||||
mod application;
|
||||
mod commands;
|
||||
mod domain;
|
||||
mod errors;
|
||||
@@ -465,6 +465,57 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_handles_iso_week_across_year() {
|
||||
let date_key = parse_analytics_calendar_date_key("2024-12-31").unwrap();
|
||||
let dimension = build_analytics_date_dimension_from_date_key(date_key);
|
||||
|
||||
assert_eq!(dimension.calendar_date, "2024-12-31");
|
||||
assert_eq!(dimension.weekday, 2);
|
||||
assert_eq!(dimension.iso_week_key, 202501);
|
||||
assert_eq!(
|
||||
dimension.week_start_date_key,
|
||||
parse_analytics_calendar_date_key("2024-12-30").unwrap()
|
||||
);
|
||||
assert_eq!(
|
||||
dimension.week_end_date_key,
|
||||
parse_analytics_calendar_date_key("2025-01-05").unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_handles_leap_day() {
|
||||
let date_key = parse_analytics_calendar_date_key("2024-02-29").unwrap();
|
||||
let dimension = build_analytics_date_dimension_from_date_key(date_key);
|
||||
|
||||
assert_eq!(dimension.calendar_date, "2024-02-29");
|
||||
assert_eq!(dimension.weekday, 4);
|
||||
assert_eq!(dimension.month_key, 202402);
|
||||
assert_eq!(dimension.month_end_date_key, date_key);
|
||||
assert_eq!(dimension.quarter_key, 20241);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_handles_quarter_boundary() {
|
||||
let date_key = parse_analytics_calendar_date_key("2024-04-01").unwrap();
|
||||
let dimension = build_analytics_date_dimension_from_date_key(date_key);
|
||||
|
||||
assert_eq!(dimension.quarter_key, 20242);
|
||||
assert_eq!(dimension.quarter_start_date_key, date_key);
|
||||
assert_eq!(
|
||||
dimension.quarter_end_date_key,
|
||||
parse_analytics_calendar_date_key("2024-06-30").unwrap()
|
||||
);
|
||||
assert_eq!(
|
||||
dimension.year_start_date_key,
|
||||
parse_analytics_calendar_date_key("2024-01-01").unwrap()
|
||||
);
|
||||
assert_eq!(
|
||||
dimension.year_end_date_key,
|
||||
parse_analytics_calendar_date_key("2024-12-31").unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_profile_task_status_matches_progress_and_claim() {
|
||||
assert_eq!(
|
||||
@@ -525,6 +576,51 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_task_config_input_accepts_only_user_scope() {
|
||||
let input = build_runtime_profile_task_config_admin_upsert_input(
|
||||
"admin".to_string(),
|
||||
PROFILE_TASK_ID_DAILY_LOGIN.to_string(),
|
||||
"每日登录".to_string(),
|
||||
"".to_string(),
|
||||
PROFILE_TASK_EVENT_KEY_DAILY_LOGIN.to_string(),
|
||||
RuntimeProfileTaskCycle::Daily,
|
||||
RuntimeTrackingScopeKind::User,
|
||||
1,
|
||||
10,
|
||||
true,
|
||||
10,
|
||||
1,
|
||||
)
|
||||
.expect("user scope should be accepted");
|
||||
assert_eq!(input.scope_kind, RuntimeTrackingScopeKind::User);
|
||||
|
||||
for scope_kind in [
|
||||
RuntimeTrackingScopeKind::Site,
|
||||
RuntimeTrackingScopeKind::Module,
|
||||
RuntimeTrackingScopeKind::Work,
|
||||
] {
|
||||
assert_eq!(
|
||||
build_runtime_profile_task_config_admin_upsert_input(
|
||||
"admin".to_string(),
|
||||
PROFILE_TASK_ID_DAILY_LOGIN.to_string(),
|
||||
"每日登录".to_string(),
|
||||
"".to_string(),
|
||||
PROFILE_TASK_EVENT_KEY_DAILY_LOGIN.to_string(),
|
||||
RuntimeProfileTaskCycle::Daily,
|
||||
scope_kind,
|
||||
1,
|
||||
10,
|
||||
true,
|
||||
10,
|
||||
1,
|
||||
)
|
||||
.expect_err("non-user scope should fail"),
|
||||
RuntimeProfileFieldError::UnsupportedProfileTaskScopeKind
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recharge_product_catalog_matches_reference_prices() {
|
||||
let point_products = runtime_profile_recharge_point_products();
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
use module_runtime::{
|
||||
AnalyticsDateDimensionSnapshot, RuntimeProfileFieldError,
|
||||
build_analytics_date_dimension_from_date_key, parse_analytics_calendar_date_key,
|
||||
validate_analytics_date_dimension_date_key,
|
||||
};
|
||||
|
||||
fn dimension(calendar_date: &str) -> AnalyticsDateDimensionSnapshot {
|
||||
let date_key = parse_analytics_calendar_date_key(calendar_date).expect("日期应可解析");
|
||||
build_analytics_date_dimension_from_date_key(date_key)
|
||||
}
|
||||
|
||||
fn date_key(calendar_date: &str) -> i64 {
|
||||
parse_analytics_calendar_date_key(calendar_date).expect("日期应可解析")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_handles_leap_day() {
|
||||
// 中文注释:2024 是闰年,2 月应包含 29 日且属于 ISO 第 9 周。
|
||||
let snapshot = dimension("2024-02-29");
|
||||
|
||||
assert_eq!(snapshot.calendar_date, "2024-02-29");
|
||||
assert_eq!(snapshot.weekday, 4);
|
||||
assert_eq!(snapshot.iso_week_key, 202409);
|
||||
assert_eq!(snapshot.week_start_date_key, date_key("2024-02-26"));
|
||||
assert_eq!(snapshot.week_end_date_key, date_key("2024-03-03"));
|
||||
assert_eq!(snapshot.month_key, 202402);
|
||||
assert_eq!(snapshot.month_start_date_key, date_key("2024-02-01"));
|
||||
assert_eq!(snapshot.month_end_date_key, date_key("2024-02-29"));
|
||||
assert_eq!(snapshot.quarter_key, 20241);
|
||||
assert_eq!(snapshot.year_key, 2024);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_uses_iso_week_year_across_year_boundary() {
|
||||
// 中文注释:2025-12-29 是周一,但 ISO week-year 已经进入 2026-W01。
|
||||
let snapshot = dimension("2025-12-29");
|
||||
|
||||
assert_eq!(snapshot.calendar_date, "2025-12-29");
|
||||
assert_eq!(snapshot.weekday, 1);
|
||||
assert_eq!(snapshot.iso_week_key, 202601);
|
||||
assert_eq!(snapshot.week_start_date_key, date_key("2025-12-29"));
|
||||
assert_eq!(snapshot.week_end_date_key, date_key("2026-01-04"));
|
||||
assert_eq!(snapshot.month_key, 202512);
|
||||
assert_eq!(snapshot.quarter_key, 20254);
|
||||
assert_eq!(snapshot.year_key, 2025);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_handles_new_year_inside_iso_week() {
|
||||
// 中文注释:2026-01-01 仍落在 2026-W01,周范围跨自然年。
|
||||
let snapshot = dimension("2026-01-01");
|
||||
|
||||
assert_eq!(snapshot.calendar_date, "2026-01-01");
|
||||
assert_eq!(snapshot.weekday, 4);
|
||||
assert_eq!(snapshot.iso_week_key, 202601);
|
||||
assert_eq!(snapshot.week_start_date_key, date_key("2025-12-29"));
|
||||
assert_eq!(snapshot.week_end_date_key, date_key("2026-01-04"));
|
||||
assert_eq!(snapshot.month_key, 202601);
|
||||
assert_eq!(snapshot.month_start_date_key, date_key("2026-01-01"));
|
||||
assert_eq!(snapshot.month_end_date_key, date_key("2026-01-31"));
|
||||
assert_eq!(snapshot.quarter_key, 20261);
|
||||
assert_eq!(snapshot.year_key, 2026);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_handles_q1_end() {
|
||||
// 中文注释:Q1 结束日应映射到 2026Q1,季度边界为 1 月 1 日到 3 月 31 日。
|
||||
let snapshot = dimension("2026-03-31");
|
||||
|
||||
assert_eq!(snapshot.calendar_date, "2026-03-31");
|
||||
assert_eq!(snapshot.weekday, 2);
|
||||
assert_eq!(snapshot.iso_week_key, 202614);
|
||||
assert_eq!(snapshot.month_key, 202603);
|
||||
assert_eq!(snapshot.month_start_date_key, date_key("2026-03-01"));
|
||||
assert_eq!(snapshot.month_end_date_key, date_key("2026-03-31"));
|
||||
assert_eq!(snapshot.quarter_key, 20261);
|
||||
assert_eq!(snapshot.quarter_start_date_key, date_key("2026-01-01"));
|
||||
assert_eq!(snapshot.quarter_end_date_key, date_key("2026-03-31"));
|
||||
assert_eq!(snapshot.year_key, 2026);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_handles_q2_start() {
|
||||
// 中文注释:Q2 开始日应映射到 2026Q2,季度边界为 4 月 1 日到 6 月 30 日。
|
||||
let snapshot = dimension("2026-04-01");
|
||||
|
||||
assert_eq!(snapshot.calendar_date, "2026-04-01");
|
||||
assert_eq!(snapshot.weekday, 3);
|
||||
assert_eq!(snapshot.iso_week_key, 202614);
|
||||
assert_eq!(snapshot.month_key, 202604);
|
||||
assert_eq!(snapshot.month_start_date_key, date_key("2026-04-01"));
|
||||
assert_eq!(snapshot.month_end_date_key, date_key("2026-04-30"));
|
||||
assert_eq!(snapshot.quarter_key, 20262);
|
||||
assert_eq!(snapshot.quarter_start_date_key, date_key("2026-04-01"));
|
||||
assert_eq!(snapshot.quarter_end_date_key, date_key("2026-06-30"));
|
||||
assert_eq!(snapshot.year_key, 2026);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_handles_year_end() {
|
||||
// 中文注释:2026 年末属于 2026-W53,且所有自然年边界应保持在 2026 年内。
|
||||
let snapshot = dimension("2026-12-31");
|
||||
|
||||
assert_eq!(snapshot.calendar_date, "2026-12-31");
|
||||
assert_eq!(snapshot.weekday, 4);
|
||||
assert_eq!(snapshot.iso_week_key, 202653);
|
||||
assert_eq!(snapshot.week_start_date_key, date_key("2026-12-28"));
|
||||
assert_eq!(snapshot.week_end_date_key, date_key("2027-01-03"));
|
||||
assert_eq!(snapshot.month_key, 202612);
|
||||
assert_eq!(snapshot.month_start_date_key, date_key("2026-12-01"));
|
||||
assert_eq!(snapshot.month_end_date_key, date_key("2026-12-31"));
|
||||
assert_eq!(snapshot.quarter_key, 20264);
|
||||
assert_eq!(snapshot.quarter_start_date_key, date_key("2026-10-01"));
|
||||
assert_eq!(snapshot.quarter_end_date_key, date_key("2026-12-31"));
|
||||
assert_eq!(snapshot.year_key, 2026);
|
||||
assert_eq!(snapshot.year_start_date_key, date_key("2026-01-01"));
|
||||
assert_eq!(snapshot.year_end_date_key, date_key("2026-12-31"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_key_parser_rejects_invalid_calendar_dates() {
|
||||
// 中文注释:非法日期和非 YYYY-MM-DD 字符串都必须解析失败,避免写入脏维表。
|
||||
assert_eq!(
|
||||
parse_analytics_calendar_date_key("2026-02-30"),
|
||||
Err(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate)
|
||||
);
|
||||
assert_eq!(
|
||||
parse_analytics_calendar_date_key("bad"),
|
||||
Err(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytics_date_dimension_rejects_out_of_supported_range() {
|
||||
// 中文注释:维表只允许受控业务日期范围,避免裸 date_key 极值进入 reducer 日历算法。
|
||||
assert_eq!(
|
||||
parse_analytics_calendar_date_key("1999-12-31"),
|
||||
Err(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate)
|
||||
);
|
||||
assert_eq!(
|
||||
parse_analytics_calendar_date_key("2101-01-01"),
|
||||
Err(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate)
|
||||
);
|
||||
assert_eq!(
|
||||
validate_analytics_date_dimension_date_key(i64::MAX),
|
||||
Err(RuntimeProfileFieldError::InvalidAnalyticsCalendarDate)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
use module_runtime::{
|
||||
RuntimeProfileFieldError, RuntimeProfileInviteCodeSnapshot, RuntimeProfileInviteCodeStatus,
|
||||
build_runtime_profile_invite_code_record, resolve_runtime_profile_invite_code_status,
|
||||
validate_runtime_profile_invite_code_validity_window,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn invite_code_validity_window_rejects_start_after_expire() {
|
||||
let result = validate_runtime_profile_invite_code_validity_window(Some(20), Some(10));
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
Err(RuntimeProfileFieldError::InvalidInviteCodeValidityWindow)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invite_code_validity_window_allows_open_ended_or_equal_boundary() {
|
||||
assert!(validate_runtime_profile_invite_code_validity_window(None, None).is_ok());
|
||||
assert!(validate_runtime_profile_invite_code_validity_window(Some(10), None).is_ok());
|
||||
assert!(validate_runtime_profile_invite_code_validity_window(None, Some(10)).is_ok());
|
||||
assert!(validate_runtime_profile_invite_code_validity_window(Some(10), Some(10)).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invite_code_status_uses_inclusive_start_and_exclusive_expire_boundary() {
|
||||
assert_eq!(
|
||||
resolve_runtime_profile_invite_code_status(Some(20), None, 19),
|
||||
RuntimeProfileInviteCodeStatus::Pending
|
||||
);
|
||||
assert_eq!(
|
||||
resolve_runtime_profile_invite_code_status(Some(20), Some(30), 20),
|
||||
RuntimeProfileInviteCodeStatus::Active
|
||||
);
|
||||
assert_eq!(
|
||||
resolve_runtime_profile_invite_code_status(Some(20), Some(30), 29),
|
||||
RuntimeProfileInviteCodeStatus::Active
|
||||
);
|
||||
assert_eq!(
|
||||
resolve_runtime_profile_invite_code_status(Some(20), Some(30), 30),
|
||||
RuntimeProfileInviteCodeStatus::Expired
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invite_code_record_formats_window_and_status() {
|
||||
let record = build_runtime_profile_invite_code_record(RuntimeProfileInviteCodeSnapshot {
|
||||
user_id: "user-1".to_string(),
|
||||
invite_code: "SY00000001".to_string(),
|
||||
metadata_json: "{}".to_string(),
|
||||
starts_at_micros: Some(0),
|
||||
expires_at_micros: Some(1_000_000),
|
||||
created_at_micros: 0,
|
||||
updated_at_micros: 1_000_000,
|
||||
});
|
||||
|
||||
assert_eq!(record.starts_at.as_deref(), Some("1970-01-01T00:00:00Z"));
|
||||
assert_eq!(record.expires_at.as_deref(), Some("1970-01-01T00:00:01Z"));
|
||||
assert_eq!(record.status, RuntimeProfileInviteCodeStatus::Expired);
|
||||
}
|
||||
83
server-rs/crates/module-runtime/tests/profile_task_scope.rs
Normal file
83
server-rs/crates/module-runtime/tests/profile_task_scope.rs
Normal file
@@ -0,0 +1,83 @@
|
||||
use module_runtime::{
|
||||
RuntimeProfileFieldError, RuntimeProfileTaskCycle, RuntimeTrackingScopeKind,
|
||||
build_runtime_profile_task_config_admin_upsert_input, build_runtime_tracking_daily_stat_id,
|
||||
};
|
||||
|
||||
fn build_task_scope_input(
|
||||
scope_kind: RuntimeTrackingScopeKind,
|
||||
) -> Result<module_runtime::RuntimeProfileTaskConfigAdminUpsertInput, RuntimeProfileFieldError> {
|
||||
build_runtime_profile_task_config_admin_upsert_input(
|
||||
"admin-1".to_string(),
|
||||
"daily-login".to_string(),
|
||||
"每日登录".to_string(),
|
||||
"".to_string(),
|
||||
"daily_login".to_string(),
|
||||
RuntimeProfileTaskCycle::Daily,
|
||||
scope_kind,
|
||||
1,
|
||||
10,
|
||||
true,
|
||||
10,
|
||||
1_000,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn admin_upsert_build_input_accepts_user_scope() {
|
||||
let input = build_task_scope_input(RuntimeTrackingScopeKind::User)
|
||||
.expect("个人任务 user scope 应允许保存");
|
||||
|
||||
assert_eq!(input.scope_kind, RuntimeTrackingScopeKind::User);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn admin_upsert_build_input_rejects_non_user_scope_with_clear_message() {
|
||||
for scope_kind in [
|
||||
RuntimeTrackingScopeKind::Site,
|
||||
RuntimeTrackingScopeKind::Module,
|
||||
RuntimeTrackingScopeKind::Work,
|
||||
] {
|
||||
let error = build_task_scope_input(scope_kind).expect_err("非 user scope 应拒绝保存");
|
||||
|
||||
assert_eq!(
|
||||
error,
|
||||
RuntimeProfileFieldError::UnsupportedProfileTaskScopeKind
|
||||
);
|
||||
assert!(
|
||||
error.to_string().contains("仅支持 user"),
|
||||
"错误信息应明确说明个人任务仅支持 user,实际为:{}",
|
||||
error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tracking_daily_stat_id_keeps_work_scope_separate_from_user_scope() {
|
||||
let user_id = "user-1";
|
||||
let work_id = "work-1";
|
||||
let day_key = 20_000;
|
||||
|
||||
let user_stat_id = build_runtime_tracking_daily_stat_id(
|
||||
"daily_login",
|
||||
RuntimeTrackingScopeKind::User,
|
||||
user_id,
|
||||
day_key,
|
||||
);
|
||||
let work_stat_id = build_runtime_tracking_daily_stat_id(
|
||||
"daily_login",
|
||||
RuntimeTrackingScopeKind::Work,
|
||||
work_id,
|
||||
day_key,
|
||||
);
|
||||
let invalid_work_with_user_id_stat_id = build_runtime_tracking_daily_stat_id(
|
||||
"daily_login",
|
||||
RuntimeTrackingScopeKind::Work,
|
||||
user_id,
|
||||
day_key,
|
||||
);
|
||||
|
||||
// 中文注释:Work 维度必须保留独立 scope_kind,不允许被静默当作 user_id 查询用户桶。
|
||||
assert!(user_stat_id.contains(":user:user-1:"));
|
||||
assert!(work_stat_id.contains(":work:work-1:"));
|
||||
assert_ne!(user_stat_id, invalid_work_with_user_id_stat_id);
|
||||
}
|
||||
@@ -412,6 +412,10 @@ pub struct AdminUpsertProfileInviteCodeRequest {
|
||||
pub invite_code: String,
|
||||
#[serde(default)]
|
||||
pub metadata: Option<serde_json::Value>,
|
||||
#[serde(default)]
|
||||
pub starts_at: Option<String>,
|
||||
#[serde(default)]
|
||||
pub expires_at: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
@@ -447,6 +451,9 @@ pub struct ProfileInviteCodeAdminResponse {
|
||||
pub user_id: String,
|
||||
pub invite_code: String,
|
||||
pub metadata: serde_json::Value,
|
||||
pub starts_at: Option<String>,
|
||||
pub expires_at: Option<String>,
|
||||
pub status: String,
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
use serde_json::json;
|
||||
use shared_contracts::runtime::{
|
||||
AdminUpsertProfileInviteCodeRequest, ProfileInviteCodeAdminResponse,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn admin_upsert_invite_code_request_accepts_optional_validity_window() {
|
||||
let request: AdminUpsertProfileInviteCodeRequest = serde_json::from_value(json!({
|
||||
"inviteCode": "SY00000001",
|
||||
"metadata": { "note": "测试" },
|
||||
"startsAt": "2026-05-04T00:00:00Z",
|
||||
"expiresAt": null
|
||||
}))
|
||||
.expect("邀请码管理请求应接受 startsAt/expiresAt");
|
||||
|
||||
assert_eq!(request.starts_at.as_deref(), Some("2026-05-04T00:00:00Z"));
|
||||
assert_eq!(request.expires_at, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn admin_invite_code_response_serializes_window_and_status_as_camel_case() {
|
||||
let response = ProfileInviteCodeAdminResponse {
|
||||
user_id: "user-1".to_string(),
|
||||
invite_code: "SY00000001".to_string(),
|
||||
metadata: json!({}),
|
||||
starts_at: Some("2026-05-04T00:00:00Z".to_string()),
|
||||
expires_at: None,
|
||||
status: "active".to_string(),
|
||||
created_at: "2026-05-04T00:00:00Z".to_string(),
|
||||
updated_at: "2026-05-04T00:00:00Z".to_string(),
|
||||
};
|
||||
|
||||
let value = serde_json::to_value(response).expect("邀请码管理响应应可序列化");
|
||||
assert_eq!(value["startsAt"], json!("2026-05-04T00:00:00Z"));
|
||||
assert_eq!(value["expiresAt"], json!(null));
|
||||
assert_eq!(value["status"], json!("active"));
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
use serde_json::json;
|
||||
use shared_contracts::runtime::{
|
||||
AdminUpsertProfileTaskConfigRequest, ProfileTaskConfigAdminResponse, TRACKING_SCOPE_KIND_USER,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn admin_upsert_profile_task_config_keeps_personal_task_scope_user() {
|
||||
let request: AdminUpsertProfileTaskConfigRequest = serde_json::from_value(json!({
|
||||
"taskId": "daily_login",
|
||||
"title": "每日登录",
|
||||
"description": "",
|
||||
"eventKey": "daily_login",
|
||||
"cycle": "daily",
|
||||
"scopeKind": "user",
|
||||
"threshold": 1,
|
||||
"rewardPoints": 10,
|
||||
"enabled": true,
|
||||
"sortOrder": 10
|
||||
}))
|
||||
.expect("个人任务配置请求应接受 user scope");
|
||||
|
||||
assert_eq!(request.scope_kind, TRACKING_SCOPE_KIND_USER);
|
||||
|
||||
let value = serde_json::to_value(request).expect("个人任务配置请求应可序列化");
|
||||
assert_eq!(value["scopeKind"], json!(TRACKING_SCOPE_KIND_USER));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn profile_task_config_admin_response_serializes_scope_kind_as_user() {
|
||||
let response = ProfileTaskConfigAdminResponse {
|
||||
task_id: "daily_login".to_string(),
|
||||
title: "每日登录".to_string(),
|
||||
description: "".to_string(),
|
||||
event_key: "daily_login".to_string(),
|
||||
cycle: "daily".to_string(),
|
||||
scope_kind: TRACKING_SCOPE_KIND_USER.to_string(),
|
||||
threshold: 1,
|
||||
reward_points: 10,
|
||||
enabled: true,
|
||||
sort_order: 10,
|
||||
created_by: "admin".to_string(),
|
||||
created_at: "2026-05-04T00:00:00Z".to_string(),
|
||||
updated_by: "admin".to_string(),
|
||||
updated_at: "2026-05-04T00:00:00Z".to_string(),
|
||||
};
|
||||
|
||||
let value = serde_json::to_value(response).expect("个人任务配置响应应可序列化");
|
||||
assert_eq!(value["scopeKind"], json!(TRACKING_SCOPE_KIND_USER));
|
||||
assert_eq!(value["taskId"], json!("daily_login"));
|
||||
assert_eq!(value["rewardPoints"], json!(10));
|
||||
}
|
||||
@@ -281,6 +281,8 @@ impl From<module_runtime::RuntimeProfileInviteCodeAdminUpsertInput>
|
||||
admin_user_id: input.admin_user_id,
|
||||
invite_code: input.invite_code,
|
||||
metadata_json: input.metadata_json,
|
||||
starts_at_micros: input.starts_at_micros,
|
||||
expires_at_micros: input.expires_at_micros,
|
||||
updated_at_micros: input.updated_at_micros,
|
||||
}
|
||||
}
|
||||
@@ -1997,6 +1999,8 @@ pub(crate) fn map_runtime_profile_invite_code_snapshot(
|
||||
user_id: snapshot.user_id,
|
||||
invite_code: snapshot.invite_code,
|
||||
metadata_json: snapshot.metadata_json,
|
||||
starts_at_micros: snapshot.starts_at_micros,
|
||||
expires_at_micros: snapshot.expires_at_micros,
|
||||
created_at_micros: snapshot.created_at_micros,
|
||||
updated_at_micros: snapshot.updated_at_micros,
|
||||
}
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait accept_quest {
|
||||
&self,
|
||||
input: QuestRecordInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl accept_quest for super::RemoteReducers {
|
||||
&self,
|
||||
input: QuestRecordInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(AcceptQuestArgs { input }, callback)
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait acknowledge_quest_completion {
|
||||
&self,
|
||||
input: QuestCompletionAckInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl acknowledge_quest_completion for super::RemoteReducers {
|
||||
&self,
|
||||
input: QuestCompletionAckInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(AcknowledgeQuestCompletionArgs { input }, callback)
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait admin_disable_profile_redeem_code {
|
||||
input: RuntimeProfileRedeemCodeAdminDisableInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl admin_disable_profile_redeem_code for super::RemoteProcedures {
|
||||
input: RuntimeProfileRedeemCodeAdminDisableInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileRedeemCodeAdminProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait admin_disable_profile_task_config {
|
||||
input: RuntimeProfileTaskConfigAdminDisableInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl admin_disable_profile_task_config for super::RemoteProcedures {
|
||||
input: RuntimeProfileTaskConfigAdminDisableInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileTaskConfigAdminProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait admin_list_profile_invite_codes {
|
||||
input: RuntimeProfileInviteCodeAdminListInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileInviteCodeAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileInviteCodeAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl admin_list_profile_invite_codes for super::RemoteProcedures {
|
||||
input: RuntimeProfileInviteCodeAdminListInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileInviteCodeAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileInviteCodeAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileInviteCodeAdminListProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait admin_list_profile_redeem_codes {
|
||||
input: RuntimeProfileRedeemCodeAdminListInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl admin_list_profile_redeem_codes for super::RemoteProcedures {
|
||||
input: RuntimeProfileRedeemCodeAdminListInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileRedeemCodeAdminListProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait admin_list_profile_task_configs {
|
||||
input: RuntimeProfileTaskConfigAdminListInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl admin_list_profile_task_configs for super::RemoteProcedures {
|
||||
input: RuntimeProfileTaskConfigAdminListInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminListProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileTaskConfigAdminListProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait admin_upsert_profile_invite_code {
|
||||
input: RuntimeProfileInviteCodeAdminUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileInviteCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileInviteCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl admin_upsert_profile_invite_code for super::RemoteProcedures {
|
||||
input: RuntimeProfileInviteCodeAdminUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileInviteCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileInviteCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileInviteCodeAdminProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait admin_upsert_profile_redeem_code {
|
||||
input: RuntimeProfileRedeemCodeAdminUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl admin_upsert_profile_redeem_code for super::RemoteProcedures {
|
||||
input: RuntimeProfileRedeemCodeAdminUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRedeemCodeAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileRedeemCodeAdminProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait admin_upsert_profile_task_config {
|
||||
input: RuntimeProfileTaskConfigAdminUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl admin_upsert_profile_task_config for super::RemoteProcedures {
|
||||
input: RuntimeProfileTaskConfigAdminUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskConfigAdminProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileTaskConfigAdminProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait advance_puzzle_next_level {
|
||||
input: PuzzleRunNextLevelInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleRunProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleRunProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl advance_puzzle_next_level for super::RemoteProcedures {
|
||||
input: PuzzleRunNextLevelInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleRunProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleRunProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, PuzzleRunProcedureResult>(
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::ai_result_reference_kind_type::AiResultReferenceKind;
|
||||
use super::ai_result_reference_type::AiResultReference;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `ai_result_reference`.
|
||||
///
|
||||
/// Obtain a handle from the [`AiResultReferenceTableAccess::ai_result_reference`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.ai_result_reference()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.ai_result_reference().on_insert(...)`.
|
||||
pub struct AiResultReferenceTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AiResultReference>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `ai_result_reference`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AiResultReferenceTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AiResultReferenceTableHandle`], which mediates access to the table `ai_result_reference`.
|
||||
fn ai_result_reference(&self) -> AiResultReferenceTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AiResultReferenceTableAccess for super::RemoteTables {
|
||||
fn ai_result_reference(&self) -> AiResultReferenceTableHandle<'_> {
|
||||
AiResultReferenceTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<AiResultReference>("ai_result_reference"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AiResultReferenceInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AiResultReferenceDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AiResultReferenceTableHandle<'ctx> {
|
||||
type Row = AiResultReference;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = AiResultReference> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = AiResultReferenceInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AiResultReferenceInsertCallbackId {
|
||||
AiResultReferenceInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AiResultReferenceInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AiResultReferenceDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AiResultReferenceDeleteCallbackId {
|
||||
AiResultReferenceDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AiResultReferenceDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AiResultReferenceUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AiResultReferenceTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AiResultReferenceUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AiResultReferenceUpdateCallbackId {
|
||||
AiResultReferenceUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AiResultReferenceUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `result_reference_row_id` unique index on the table `ai_result_reference`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AiResultReferenceResultReferenceRowIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.ai_result_reference().result_reference_row_id().find(...)`.
|
||||
pub struct AiResultReferenceResultReferenceRowIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AiResultReference, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AiResultReferenceTableHandle<'ctx> {
|
||||
/// Get a handle on the `result_reference_row_id` unique index on the table `ai_result_reference`.
|
||||
pub fn result_reference_row_id(&self) -> AiResultReferenceResultReferenceRowIdUnique<'ctx> {
|
||||
AiResultReferenceResultReferenceRowIdUnique {
|
||||
imp: self
|
||||
.imp
|
||||
.get_unique_constraint::<String>("result_reference_row_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AiResultReferenceResultReferenceRowIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `result_reference_row_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<AiResultReference> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<AiResultReference>("ai_result_reference");
|
||||
_table.add_unique_constraint::<String>("result_reference_row_id", |row| {
|
||||
&row.result_reference_row_id
|
||||
});
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AiResultReference>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<AiResultReference>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AiResultReference`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait ai_result_referenceQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AiResultReference`.
|
||||
fn ai_result_reference(&self) -> __sdk::__query_builder::Table<AiResultReference>;
|
||||
}
|
||||
|
||||
impl ai_result_referenceQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn ai_result_reference(&self) -> __sdk::__query_builder::Table<AiResultReference> {
|
||||
__sdk::__query_builder::Table::new("ai_result_reference")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::ai_task_stage_kind_type::AiTaskStageKind;
|
||||
use super::ai_task_stage_status_type::AiTaskStageStatus;
|
||||
use super::ai_task_stage_type::AiTaskStage;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `ai_task_stage`.
|
||||
///
|
||||
/// Obtain a handle from the [`AiTaskStageTableAccess::ai_task_stage`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.ai_task_stage()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.ai_task_stage().on_insert(...)`.
|
||||
pub struct AiTaskStageTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AiTaskStage>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `ai_task_stage`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AiTaskStageTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AiTaskStageTableHandle`], which mediates access to the table `ai_task_stage`.
|
||||
fn ai_task_stage(&self) -> AiTaskStageTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AiTaskStageTableAccess for super::RemoteTables {
|
||||
fn ai_task_stage(&self) -> AiTaskStageTableHandle<'_> {
|
||||
AiTaskStageTableHandle {
|
||||
imp: self.imp.get_table::<AiTaskStage>("ai_task_stage"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AiTaskStageInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AiTaskStageDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AiTaskStageTableHandle<'ctx> {
|
||||
type Row = AiTaskStage;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = AiTaskStage> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = AiTaskStageInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AiTaskStageInsertCallbackId {
|
||||
AiTaskStageInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AiTaskStageInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AiTaskStageDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AiTaskStageDeleteCallbackId {
|
||||
AiTaskStageDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AiTaskStageDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AiTaskStageUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AiTaskStageTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AiTaskStageUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AiTaskStageUpdateCallbackId {
|
||||
AiTaskStageUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AiTaskStageUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `task_stage_id` unique index on the table `ai_task_stage`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AiTaskStageTaskStageIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.ai_task_stage().task_stage_id().find(...)`.
|
||||
pub struct AiTaskStageTaskStageIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AiTaskStage, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AiTaskStageTableHandle<'ctx> {
|
||||
/// Get a handle on the `task_stage_id` unique index on the table `ai_task_stage`.
|
||||
pub fn task_stage_id(&self) -> AiTaskStageTaskStageIdUnique<'ctx> {
|
||||
AiTaskStageTaskStageIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("task_stage_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AiTaskStageTaskStageIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `task_stage_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<AiTaskStage> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<AiTaskStage>("ai_task_stage");
|
||||
_table.add_unique_constraint::<String>("task_stage_id", |row| &row.task_stage_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AiTaskStage>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<AiTaskStage>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AiTaskStage`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait ai_task_stageQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AiTaskStage`.
|
||||
fn ai_task_stage(&self) -> __sdk::__query_builder::Table<AiTaskStage>;
|
||||
}
|
||||
|
||||
impl ai_task_stageQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn ai_task_stage(&self) -> __sdk::__query_builder::Table<AiTaskStage> {
|
||||
__sdk::__query_builder::Table::new("ai_task_stage")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::ai_task_kind_type::AiTaskKind;
|
||||
use super::ai_task_status_type::AiTaskStatus;
|
||||
use super::ai_task_type::AiTask;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `ai_task`.
|
||||
///
|
||||
/// Obtain a handle from the [`AiTaskTableAccess::ai_task`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.ai_task()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.ai_task().on_insert(...)`.
|
||||
pub struct AiTaskTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AiTask>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `ai_task`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AiTaskTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AiTaskTableHandle`], which mediates access to the table `ai_task`.
|
||||
fn ai_task(&self) -> AiTaskTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AiTaskTableAccess for super::RemoteTables {
|
||||
fn ai_task(&self) -> AiTaskTableHandle<'_> {
|
||||
AiTaskTableHandle {
|
||||
imp: self.imp.get_table::<AiTask>("ai_task"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AiTaskInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AiTaskDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AiTaskTableHandle<'ctx> {
|
||||
type Row = AiTask;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = AiTask> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = AiTaskInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AiTaskInsertCallbackId {
|
||||
AiTaskInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AiTaskInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AiTaskDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AiTaskDeleteCallbackId {
|
||||
AiTaskDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AiTaskDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AiTaskUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AiTaskTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AiTaskUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AiTaskUpdateCallbackId {
|
||||
AiTaskUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AiTaskUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `task_id` unique index on the table `ai_task`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AiTaskTaskIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.ai_task().task_id().find(...)`.
|
||||
pub struct AiTaskTaskIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AiTask, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AiTaskTableHandle<'ctx> {
|
||||
/// Get a handle on the `task_id` unique index on the table `ai_task`.
|
||||
pub fn task_id(&self) -> AiTaskTaskIdUnique<'ctx> {
|
||||
AiTaskTaskIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("task_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AiTaskTaskIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `task_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<AiTask> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<AiTask>("ai_task");
|
||||
_table.add_unique_constraint::<String>("task_id", |row| &row.task_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AiTask>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<AiTask>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AiTask`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait ai_taskQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AiTask`.
|
||||
fn ai_task(&self) -> __sdk::__query_builder::Table<AiTask>;
|
||||
}
|
||||
|
||||
impl ai_taskQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn ai_task(&self) -> __sdk::__query_builder::Table<AiTask> {
|
||||
__sdk::__query_builder::Table::new("ai_task")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::ai_task_stage_kind_type::AiTaskStageKind;
|
||||
use super::ai_text_chunk_type::AiTextChunk;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `ai_text_chunk`.
|
||||
///
|
||||
/// Obtain a handle from the [`AiTextChunkTableAccess::ai_text_chunk`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.ai_text_chunk()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.ai_text_chunk().on_insert(...)`.
|
||||
pub struct AiTextChunkTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AiTextChunk>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `ai_text_chunk`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AiTextChunkTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AiTextChunkTableHandle`], which mediates access to the table `ai_text_chunk`.
|
||||
fn ai_text_chunk(&self) -> AiTextChunkTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AiTextChunkTableAccess for super::RemoteTables {
|
||||
fn ai_text_chunk(&self) -> AiTextChunkTableHandle<'_> {
|
||||
AiTextChunkTableHandle {
|
||||
imp: self.imp.get_table::<AiTextChunk>("ai_text_chunk"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AiTextChunkInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AiTextChunkDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AiTextChunkTableHandle<'ctx> {
|
||||
type Row = AiTextChunk;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = AiTextChunk> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = AiTextChunkInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AiTextChunkInsertCallbackId {
|
||||
AiTextChunkInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AiTextChunkInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AiTextChunkDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AiTextChunkDeleteCallbackId {
|
||||
AiTextChunkDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AiTextChunkDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AiTextChunkUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AiTextChunkTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AiTextChunkUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AiTextChunkUpdateCallbackId {
|
||||
AiTextChunkUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AiTextChunkUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `text_chunk_row_id` unique index on the table `ai_text_chunk`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AiTextChunkTextChunkRowIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.ai_text_chunk().text_chunk_row_id().find(...)`.
|
||||
pub struct AiTextChunkTextChunkRowIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AiTextChunk, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AiTextChunkTableHandle<'ctx> {
|
||||
/// Get a handle on the `text_chunk_row_id` unique index on the table `ai_text_chunk`.
|
||||
pub fn text_chunk_row_id(&self) -> AiTextChunkTextChunkRowIdUnique<'ctx> {
|
||||
AiTextChunkTextChunkRowIdUnique {
|
||||
imp: self
|
||||
.imp
|
||||
.get_unique_constraint::<String>("text_chunk_row_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AiTextChunkTextChunkRowIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `text_chunk_row_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<AiTextChunk> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<AiTextChunk>("ai_text_chunk");
|
||||
_table.add_unique_constraint::<String>("text_chunk_row_id", |row| &row.text_chunk_row_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AiTextChunk>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<AiTextChunk>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AiTextChunk`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait ai_text_chunkQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AiTextChunk`.
|
||||
fn ai_text_chunk(&self) -> __sdk::__query_builder::Table<AiTextChunk>;
|
||||
}
|
||||
|
||||
impl ai_text_chunkQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn ai_text_chunk(&self) -> __sdk::__query_builder::Table<AiTextChunk> {
|
||||
__sdk::__query_builder::Table::new("ai_text_chunk")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct AnalyticsDateDimensionEnsureInput {
|
||||
pub date_key: i64,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for AnalyticsDateDimensionEnsureInput {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct AnalyticsDateDimensionSeedInput {
|
||||
pub start_date: String,
|
||||
pub end_date: String,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for AnalyticsDateDimensionSeedInput {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::analytics_date_dimension_type::AnalyticsDateDimension;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `analytics_date_dimension`.
|
||||
///
|
||||
/// Obtain a handle from the [`AnalyticsDateDimensionTableAccess::analytics_date_dimension`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.analytics_date_dimension()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.analytics_date_dimension().on_insert(...)`.
|
||||
pub struct AnalyticsDateDimensionTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AnalyticsDateDimension>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `analytics_date_dimension`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AnalyticsDateDimensionTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AnalyticsDateDimensionTableHandle`], which mediates access to the table `analytics_date_dimension`.
|
||||
fn analytics_date_dimension(&self) -> AnalyticsDateDimensionTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AnalyticsDateDimensionTableAccess for super::RemoteTables {
|
||||
fn analytics_date_dimension(&self) -> AnalyticsDateDimensionTableHandle<'_> {
|
||||
AnalyticsDateDimensionTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<AnalyticsDateDimension>("analytics_date_dimension"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AnalyticsDateDimensionInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AnalyticsDateDimensionDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AnalyticsDateDimensionTableHandle<'ctx> {
|
||||
type Row = AnalyticsDateDimension;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = AnalyticsDateDimension> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = AnalyticsDateDimensionInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AnalyticsDateDimensionInsertCallbackId {
|
||||
AnalyticsDateDimensionInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AnalyticsDateDimensionInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AnalyticsDateDimensionDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AnalyticsDateDimensionDeleteCallbackId {
|
||||
AnalyticsDateDimensionDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AnalyticsDateDimensionDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AnalyticsDateDimensionUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AnalyticsDateDimensionTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AnalyticsDateDimensionUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AnalyticsDateDimensionUpdateCallbackId {
|
||||
AnalyticsDateDimensionUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AnalyticsDateDimensionUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `date_key` unique index on the table `analytics_date_dimension`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AnalyticsDateDimensionDateKeyUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.analytics_date_dimension().date_key().find(...)`.
|
||||
pub struct AnalyticsDateDimensionDateKeyUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AnalyticsDateDimension, i64>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AnalyticsDateDimensionTableHandle<'ctx> {
|
||||
/// Get a handle on the `date_key` unique index on the table `analytics_date_dimension`.
|
||||
pub fn date_key(&self) -> AnalyticsDateDimensionDateKeyUnique<'ctx> {
|
||||
AnalyticsDateDimensionDateKeyUnique {
|
||||
imp: self.imp.get_unique_constraint::<i64>("date_key"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AnalyticsDateDimensionDateKeyUnique<'ctx> {
|
||||
/// Find the subscribed row whose `date_key` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &i64) -> Option<AnalyticsDateDimension> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table =
|
||||
client_cache.get_or_make_table::<AnalyticsDateDimension>("analytics_date_dimension");
|
||||
_table.add_unique_constraint::<i64>("date_key", |row| &row.date_key);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AnalyticsDateDimension>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<AnalyticsDateDimension>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AnalyticsDateDimension`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait analytics_date_dimensionQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AnalyticsDateDimension`.
|
||||
fn analytics_date_dimension(&self) -> __sdk::__query_builder::Table<AnalyticsDateDimension>;
|
||||
}
|
||||
|
||||
impl analytics_date_dimensionQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn analytics_date_dimension(&self) -> __sdk::__query_builder::Table<AnalyticsDateDimension> {
|
||||
__sdk::__query_builder::Table::new("analytics_date_dimension")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct AnalyticsDateDimension {
|
||||
pub date_key: i64,
|
||||
pub calendar_date: String,
|
||||
pub weekday: u8,
|
||||
pub iso_week_key: i32,
|
||||
pub week_start_date_key: i64,
|
||||
pub week_end_date_key: i64,
|
||||
pub month_key: i32,
|
||||
pub month_start_date_key: i64,
|
||||
pub month_end_date_key: i64,
|
||||
pub quarter_key: i32,
|
||||
pub quarter_start_date_key: i64,
|
||||
pub quarter_end_date_key: i64,
|
||||
pub year_key: i32,
|
||||
pub year_start_date_key: i64,
|
||||
pub year_end_date_key: i64,
|
||||
pub created_at: __sdk::Timestamp,
|
||||
pub updated_at: __sdk::Timestamp,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for AnalyticsDateDimension {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
/// Column accessor struct for the table `AnalyticsDateDimension`.
|
||||
///
|
||||
/// Provides typed access to columns for query building.
|
||||
pub struct AnalyticsDateDimensionCols {
|
||||
pub date_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i64>,
|
||||
pub calendar_date: __sdk::__query_builder::Col<AnalyticsDateDimension, String>,
|
||||
pub weekday: __sdk::__query_builder::Col<AnalyticsDateDimension, u8>,
|
||||
pub iso_week_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i32>,
|
||||
pub week_start_date_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i64>,
|
||||
pub week_end_date_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i64>,
|
||||
pub month_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i32>,
|
||||
pub month_start_date_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i64>,
|
||||
pub month_end_date_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i64>,
|
||||
pub quarter_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i32>,
|
||||
pub quarter_start_date_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i64>,
|
||||
pub quarter_end_date_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i64>,
|
||||
pub year_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i32>,
|
||||
pub year_start_date_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i64>,
|
||||
pub year_end_date_key: __sdk::__query_builder::Col<AnalyticsDateDimension, i64>,
|
||||
pub created_at: __sdk::__query_builder::Col<AnalyticsDateDimension, __sdk::Timestamp>,
|
||||
pub updated_at: __sdk::__query_builder::Col<AnalyticsDateDimension, __sdk::Timestamp>,
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::HasCols for AnalyticsDateDimension {
|
||||
type Cols = AnalyticsDateDimensionCols;
|
||||
fn cols(table_name: &'static str) -> Self::Cols {
|
||||
AnalyticsDateDimensionCols {
|
||||
date_key: __sdk::__query_builder::Col::new(table_name, "date_key"),
|
||||
calendar_date: __sdk::__query_builder::Col::new(table_name, "calendar_date"),
|
||||
weekday: __sdk::__query_builder::Col::new(table_name, "weekday"),
|
||||
iso_week_key: __sdk::__query_builder::Col::new(table_name, "iso_week_key"),
|
||||
week_start_date_key: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"week_start_date_key",
|
||||
),
|
||||
week_end_date_key: __sdk::__query_builder::Col::new(table_name, "week_end_date_key"),
|
||||
month_key: __sdk::__query_builder::Col::new(table_name, "month_key"),
|
||||
month_start_date_key: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"month_start_date_key",
|
||||
),
|
||||
month_end_date_key: __sdk::__query_builder::Col::new(table_name, "month_end_date_key"),
|
||||
quarter_key: __sdk::__query_builder::Col::new(table_name, "quarter_key"),
|
||||
quarter_start_date_key: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"quarter_start_date_key",
|
||||
),
|
||||
quarter_end_date_key: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"quarter_end_date_key",
|
||||
),
|
||||
year_key: __sdk::__query_builder::Col::new(table_name, "year_key"),
|
||||
year_start_date_key: __sdk::__query_builder::Col::new(
|
||||
table_name,
|
||||
"year_start_date_key",
|
||||
),
|
||||
year_end_date_key: __sdk::__query_builder::Col::new(table_name, "year_end_date_key"),
|
||||
created_at: __sdk::__query_builder::Col::new(table_name, "created_at"),
|
||||
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Indexed column accessor struct for the table `AnalyticsDateDimension`.
|
||||
///
|
||||
/// Provides typed access to indexed columns for query building.
|
||||
pub struct AnalyticsDateDimensionIxCols {
|
||||
pub date_key: __sdk::__query_builder::IxCol<AnalyticsDateDimension, i64>,
|
||||
pub iso_week_key: __sdk::__query_builder::IxCol<AnalyticsDateDimension, i32>,
|
||||
pub month_key: __sdk::__query_builder::IxCol<AnalyticsDateDimension, i32>,
|
||||
pub quarter_key: __sdk::__query_builder::IxCol<AnalyticsDateDimension, i32>,
|
||||
pub year_key: __sdk::__query_builder::IxCol<AnalyticsDateDimension, i32>,
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::HasIxCols for AnalyticsDateDimension {
|
||||
type IxCols = AnalyticsDateDimensionIxCols;
|
||||
fn ix_cols(table_name: &'static str) -> Self::IxCols {
|
||||
AnalyticsDateDimensionIxCols {
|
||||
date_key: __sdk::__query_builder::IxCol::new(table_name, "date_key"),
|
||||
iso_week_key: __sdk::__query_builder::IxCol::new(table_name, "iso_week_key"),
|
||||
month_key: __sdk::__query_builder::IxCol::new(table_name, "month_key"),
|
||||
quarter_key: __sdk::__query_builder::IxCol::new(table_name, "quarter_key"),
|
||||
year_key: __sdk::__query_builder::IxCol::new(table_name, "year_key"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for AnalyticsDateDimension {}
|
||||
@@ -31,10 +31,10 @@ pub trait append_ai_text_chunk_and_return {
|
||||
input: AiTextChunkAppendInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl append_ai_text_chunk_and_return for super::RemoteProcedures {
|
||||
input: AiTextChunkAppendInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, AiTaskProcedureResult>(
|
||||
|
||||
@@ -34,10 +34,10 @@ pub trait apply_chapter_progression_ledger_entry_and_return {
|
||||
input: ChapterProgressionLedgerInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<ChapterProgressionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<ChapterProgressionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ impl apply_chapter_progression_ledger_entry_and_return for super::RemoteProcedur
|
||||
input: ChapterProgressionLedgerInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<ChapterProgressionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<ChapterProgressionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, ChapterProgressionProcedureResult>(
|
||||
|
||||
@@ -50,11 +50,9 @@ pub trait apply_chapter_progression_ledger_entry {
|
||||
&self,
|
||||
input: ChapterProgressionLedgerInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -63,11 +61,9 @@ impl apply_chapter_progression_ledger_entry for super::RemoteReducers {
|
||||
&self,
|
||||
input: ChapterProgressionLedgerInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp.invoke_reducer_with_callback(
|
||||
ApplyChapterProgressionLedgerEntryArgs { input },
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait apply_inventory_mutation {
|
||||
&self,
|
||||
input: InventoryMutationInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl apply_inventory_mutation for super::RemoteReducers {
|
||||
&self,
|
||||
input: InventoryMutationInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(ApplyInventoryMutationArgs { input }, callback)
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait apply_quest_signal {
|
||||
&self,
|
||||
input: QuestSignalApplyInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl apply_quest_signal for super::RemoteReducers {
|
||||
&self,
|
||||
input: QuestSignalApplyInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(ApplyQuestSignalArgs { input }, callback)
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::asset_entity_binding_type::AssetEntityBinding;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `asset_entity_binding`.
|
||||
///
|
||||
/// Obtain a handle from the [`AssetEntityBindingTableAccess::asset_entity_binding`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.asset_entity_binding()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.asset_entity_binding().on_insert(...)`.
|
||||
pub struct AssetEntityBindingTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AssetEntityBinding>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `asset_entity_binding`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AssetEntityBindingTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AssetEntityBindingTableHandle`], which mediates access to the table `asset_entity_binding`.
|
||||
fn asset_entity_binding(&self) -> AssetEntityBindingTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AssetEntityBindingTableAccess for super::RemoteTables {
|
||||
fn asset_entity_binding(&self) -> AssetEntityBindingTableHandle<'_> {
|
||||
AssetEntityBindingTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<AssetEntityBinding>("asset_entity_binding"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AssetEntityBindingInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AssetEntityBindingDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AssetEntityBindingTableHandle<'ctx> {
|
||||
type Row = AssetEntityBinding;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = AssetEntityBinding> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = AssetEntityBindingInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AssetEntityBindingInsertCallbackId {
|
||||
AssetEntityBindingInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AssetEntityBindingInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AssetEntityBindingDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AssetEntityBindingDeleteCallbackId {
|
||||
AssetEntityBindingDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AssetEntityBindingDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AssetEntityBindingUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AssetEntityBindingTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AssetEntityBindingUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AssetEntityBindingUpdateCallbackId {
|
||||
AssetEntityBindingUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AssetEntityBindingUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `binding_id` unique index on the table `asset_entity_binding`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AssetEntityBindingBindingIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.asset_entity_binding().binding_id().find(...)`.
|
||||
pub struct AssetEntityBindingBindingIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AssetEntityBinding, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AssetEntityBindingTableHandle<'ctx> {
|
||||
/// Get a handle on the `binding_id` unique index on the table `asset_entity_binding`.
|
||||
pub fn binding_id(&self) -> AssetEntityBindingBindingIdUnique<'ctx> {
|
||||
AssetEntityBindingBindingIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("binding_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AssetEntityBindingBindingIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `binding_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<AssetEntityBinding> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<AssetEntityBinding>("asset_entity_binding");
|
||||
_table.add_unique_constraint::<String>("binding_id", |row| &row.binding_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AssetEntityBinding>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<AssetEntityBinding>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AssetEntityBinding`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait asset_entity_bindingQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AssetEntityBinding`.
|
||||
fn asset_entity_binding(&self) -> __sdk::__query_builder::Table<AssetEntityBinding>;
|
||||
}
|
||||
|
||||
impl asset_entity_bindingQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn asset_entity_binding(&self) -> __sdk::__query_builder::Table<AssetEntityBinding> {
|
||||
__sdk::__query_builder::Table::new("asset_entity_binding")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::asset_object_access_policy_type::AssetObjectAccessPolicy;
|
||||
use super::asset_object_type::AssetObject;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `asset_object`.
|
||||
///
|
||||
/// Obtain a handle from the [`AssetObjectTableAccess::asset_object`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.asset_object()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.asset_object().on_insert(...)`.
|
||||
pub struct AssetObjectTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AssetObject>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `asset_object`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AssetObjectTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AssetObjectTableHandle`], which mediates access to the table `asset_object`.
|
||||
fn asset_object(&self) -> AssetObjectTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AssetObjectTableAccess for super::RemoteTables {
|
||||
fn asset_object(&self) -> AssetObjectTableHandle<'_> {
|
||||
AssetObjectTableHandle {
|
||||
imp: self.imp.get_table::<AssetObject>("asset_object"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AssetObjectInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AssetObjectDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AssetObjectTableHandle<'ctx> {
|
||||
type Row = AssetObject;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = AssetObject> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = AssetObjectInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AssetObjectInsertCallbackId {
|
||||
AssetObjectInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AssetObjectInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AssetObjectDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AssetObjectDeleteCallbackId {
|
||||
AssetObjectDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AssetObjectDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AssetObjectUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AssetObjectTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AssetObjectUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AssetObjectUpdateCallbackId {
|
||||
AssetObjectUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AssetObjectUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `asset_object_id` unique index on the table `asset_object`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AssetObjectAssetObjectIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.asset_object().asset_object_id().find(...)`.
|
||||
pub struct AssetObjectAssetObjectIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AssetObject, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AssetObjectTableHandle<'ctx> {
|
||||
/// Get a handle on the `asset_object_id` unique index on the table `asset_object`.
|
||||
pub fn asset_object_id(&self) -> AssetObjectAssetObjectIdUnique<'ctx> {
|
||||
AssetObjectAssetObjectIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("asset_object_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AssetObjectAssetObjectIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `asset_object_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<AssetObject> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<AssetObject>("asset_object");
|
||||
_table.add_unique_constraint::<String>("asset_object_id", |row| &row.asset_object_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AssetObject>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<AssetObject>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AssetObject`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait asset_objectQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AssetObject`.
|
||||
fn asset_object(&self) -> __sdk::__query_builder::Table<AssetObject>;
|
||||
}
|
||||
|
||||
impl asset_objectQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn asset_object(&self) -> __sdk::__query_builder::Table<AssetObject> {
|
||||
__sdk::__query_builder::Table::new("asset_object")
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,10 @@ pub trait attach_ai_result_reference_and_return {
|
||||
input: AiResultReferenceInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl attach_ai_result_reference_and_return for super::RemoteProcedures {
|
||||
input: AiResultReferenceInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, AiTaskProcedureResult>(
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::auth_identity_type::AuthIdentity;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `auth_identity`.
|
||||
///
|
||||
/// Obtain a handle from the [`AuthIdentityTableAccess::auth_identity`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.auth_identity()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.auth_identity().on_insert(...)`.
|
||||
pub struct AuthIdentityTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AuthIdentity>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `auth_identity`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AuthIdentityTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AuthIdentityTableHandle`], which mediates access to the table `auth_identity`.
|
||||
fn auth_identity(&self) -> AuthIdentityTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AuthIdentityTableAccess for super::RemoteTables {
|
||||
fn auth_identity(&self) -> AuthIdentityTableHandle<'_> {
|
||||
AuthIdentityTableHandle {
|
||||
imp: self.imp.get_table::<AuthIdentity>("auth_identity"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AuthIdentityInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AuthIdentityDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AuthIdentityTableHandle<'ctx> {
|
||||
type Row = AuthIdentity;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = AuthIdentity> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = AuthIdentityInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AuthIdentityInsertCallbackId {
|
||||
AuthIdentityInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AuthIdentityInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AuthIdentityDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AuthIdentityDeleteCallbackId {
|
||||
AuthIdentityDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AuthIdentityDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AuthIdentityUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AuthIdentityTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AuthIdentityUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AuthIdentityUpdateCallbackId {
|
||||
AuthIdentityUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AuthIdentityUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `identity_id` unique index on the table `auth_identity`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AuthIdentityIdentityIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.auth_identity().identity_id().find(...)`.
|
||||
pub struct AuthIdentityIdentityIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AuthIdentity, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AuthIdentityTableHandle<'ctx> {
|
||||
/// Get a handle on the `identity_id` unique index on the table `auth_identity`.
|
||||
pub fn identity_id(&self) -> AuthIdentityIdentityIdUnique<'ctx> {
|
||||
AuthIdentityIdentityIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("identity_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AuthIdentityIdentityIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `identity_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<AuthIdentity> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<AuthIdentity>("auth_identity");
|
||||
_table.add_unique_constraint::<String>("identity_id", |row| &row.identity_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AuthIdentity>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<AuthIdentity>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AuthIdentity`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait auth_identityQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AuthIdentity`.
|
||||
fn auth_identity(&self) -> __sdk::__query_builder::Table<AuthIdentity>;
|
||||
}
|
||||
|
||||
impl auth_identityQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn auth_identity(&self) -> __sdk::__query_builder::Table<AuthIdentity> {
|
||||
__sdk::__query_builder::Table::new("auth_identity")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::auth_store_snapshot_type::AuthStoreSnapshot;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `auth_store_snapshot`.
|
||||
///
|
||||
/// Obtain a handle from the [`AuthStoreSnapshotTableAccess::auth_store_snapshot`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.auth_store_snapshot()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.auth_store_snapshot().on_insert(...)`.
|
||||
pub struct AuthStoreSnapshotTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AuthStoreSnapshot>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `auth_store_snapshot`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AuthStoreSnapshotTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AuthStoreSnapshotTableHandle`], which mediates access to the table `auth_store_snapshot`.
|
||||
fn auth_store_snapshot(&self) -> AuthStoreSnapshotTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AuthStoreSnapshotTableAccess for super::RemoteTables {
|
||||
fn auth_store_snapshot(&self) -> AuthStoreSnapshotTableHandle<'_> {
|
||||
AuthStoreSnapshotTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<AuthStoreSnapshot>("auth_store_snapshot"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AuthStoreSnapshotInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AuthStoreSnapshotDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AuthStoreSnapshotTableHandle<'ctx> {
|
||||
type Row = AuthStoreSnapshot;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = AuthStoreSnapshot> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = AuthStoreSnapshotInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AuthStoreSnapshotInsertCallbackId {
|
||||
AuthStoreSnapshotInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AuthStoreSnapshotInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AuthStoreSnapshotDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AuthStoreSnapshotDeleteCallbackId {
|
||||
AuthStoreSnapshotDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AuthStoreSnapshotDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AuthStoreSnapshotUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AuthStoreSnapshotTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AuthStoreSnapshotUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AuthStoreSnapshotUpdateCallbackId {
|
||||
AuthStoreSnapshotUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AuthStoreSnapshotUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `snapshot_id` unique index on the table `auth_store_snapshot`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AuthStoreSnapshotSnapshotIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.auth_store_snapshot().snapshot_id().find(...)`.
|
||||
pub struct AuthStoreSnapshotSnapshotIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AuthStoreSnapshot, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AuthStoreSnapshotTableHandle<'ctx> {
|
||||
/// Get a handle on the `snapshot_id` unique index on the table `auth_store_snapshot`.
|
||||
pub fn snapshot_id(&self) -> AuthStoreSnapshotSnapshotIdUnique<'ctx> {
|
||||
AuthStoreSnapshotSnapshotIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("snapshot_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AuthStoreSnapshotSnapshotIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `snapshot_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<AuthStoreSnapshot> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<AuthStoreSnapshot>("auth_store_snapshot");
|
||||
_table.add_unique_constraint::<String>("snapshot_id", |row| &row.snapshot_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AuthStoreSnapshot>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<AuthStoreSnapshot>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AuthStoreSnapshot`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait auth_store_snapshotQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AuthStoreSnapshot`.
|
||||
fn auth_store_snapshot(&self) -> __sdk::__query_builder::Table<AuthStoreSnapshot>;
|
||||
}
|
||||
|
||||
impl auth_store_snapshotQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn auth_store_snapshot(&self) -> __sdk::__query_builder::Table<AuthStoreSnapshot> {
|
||||
__sdk::__query_builder::Table::new("auth_store_snapshot")
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,10 @@ pub trait authorize_database_migration_operator {
|
||||
input: DatabaseMigrationAuthorizeOperatorInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<DatabaseMigrationOperatorProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<DatabaseMigrationOperatorProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ impl authorize_database_migration_operator for super::RemoteProcedures {
|
||||
input: DatabaseMigrationAuthorizeOperatorInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<DatabaseMigrationOperatorProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<DatabaseMigrationOperatorProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, DatabaseMigrationOperatorProcedureResult>(
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::battle_mode_type::BattleMode;
|
||||
use super::battle_state_type::BattleState;
|
||||
use super::battle_status_type::BattleStatus;
|
||||
use super::combat_outcome_type::CombatOutcome;
|
||||
use super::runtime_item_reward_item_snapshot_type::RuntimeItemRewardItemSnapshot;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `battle_state`.
|
||||
///
|
||||
/// Obtain a handle from the [`BattleStateTableAccess::battle_state`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.battle_state()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.battle_state().on_insert(...)`.
|
||||
pub struct BattleStateTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<BattleState>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `battle_state`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait BattleStateTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`BattleStateTableHandle`], which mediates access to the table `battle_state`.
|
||||
fn battle_state(&self) -> BattleStateTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl BattleStateTableAccess for super::RemoteTables {
|
||||
fn battle_state(&self) -> BattleStateTableHandle<'_> {
|
||||
BattleStateTableHandle {
|
||||
imp: self.imp.get_table::<BattleState>("battle_state"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BattleStateInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct BattleStateDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for BattleStateTableHandle<'ctx> {
|
||||
type Row = BattleState;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = BattleState> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = BattleStateInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BattleStateInsertCallbackId {
|
||||
BattleStateInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: BattleStateInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = BattleStateDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BattleStateDeleteCallbackId {
|
||||
BattleStateDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: BattleStateDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BattleStateUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for BattleStateTableHandle<'ctx> {
|
||||
type UpdateCallbackId = BattleStateUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> BattleStateUpdateCallbackId {
|
||||
BattleStateUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: BattleStateUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `battle_state_id` unique index on the table `battle_state`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`BattleStateBattleStateIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.battle_state().battle_state_id().find(...)`.
|
||||
pub struct BattleStateBattleStateIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<BattleState, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> BattleStateTableHandle<'ctx> {
|
||||
/// Get a handle on the `battle_state_id` unique index on the table `battle_state`.
|
||||
pub fn battle_state_id(&self) -> BattleStateBattleStateIdUnique<'ctx> {
|
||||
BattleStateBattleStateIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("battle_state_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> BattleStateBattleStateIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `battle_state_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<BattleState> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<BattleState>("battle_state");
|
||||
_table.add_unique_constraint::<String>("battle_state_id", |row| &row.battle_state_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<BattleState>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<BattleState>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `BattleState`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait battle_stateQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `BattleState`.
|
||||
fn battle_state(&self) -> __sdk::__query_builder::Table<BattleState>;
|
||||
}
|
||||
|
||||
impl battle_stateQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn battle_state(&self) -> __sdk::__query_builder::Table<BattleState> {
|
||||
__sdk::__query_builder::Table::new("battle_state")
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,10 @@ pub trait begin_story_session_and_return {
|
||||
input: StorySessionInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<StorySessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<StorySessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl begin_story_session_and_return for super::RemoteProcedures {
|
||||
input: StorySessionInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<StorySessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<StorySessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, StorySessionProcedureResult>(
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait begin_story_session {
|
||||
&self,
|
||||
input: StorySessionInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl begin_story_session for super::RemoteReducers {
|
||||
&self,
|
||||
input: StorySessionInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(BeginStorySessionArgs { input }, callback)
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::big_fish_agent_message_kind_type::BigFishAgentMessageKind;
|
||||
use super::big_fish_agent_message_role_type::BigFishAgentMessageRole;
|
||||
use super::big_fish_agent_message_type::BigFishAgentMessage;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `big_fish_agent_message`.
|
||||
///
|
||||
/// Obtain a handle from the [`BigFishAgentMessageTableAccess::big_fish_agent_message`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.big_fish_agent_message()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.big_fish_agent_message().on_insert(...)`.
|
||||
pub struct BigFishAgentMessageTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<BigFishAgentMessage>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `big_fish_agent_message`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait BigFishAgentMessageTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`BigFishAgentMessageTableHandle`], which mediates access to the table `big_fish_agent_message`.
|
||||
fn big_fish_agent_message(&self) -> BigFishAgentMessageTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl BigFishAgentMessageTableAccess for super::RemoteTables {
|
||||
fn big_fish_agent_message(&self) -> BigFishAgentMessageTableHandle<'_> {
|
||||
BigFishAgentMessageTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<BigFishAgentMessage>("big_fish_agent_message"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BigFishAgentMessageInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct BigFishAgentMessageDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for BigFishAgentMessageTableHandle<'ctx> {
|
||||
type Row = BigFishAgentMessage;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = BigFishAgentMessage> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = BigFishAgentMessageInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BigFishAgentMessageInsertCallbackId {
|
||||
BigFishAgentMessageInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: BigFishAgentMessageInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = BigFishAgentMessageDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BigFishAgentMessageDeleteCallbackId {
|
||||
BigFishAgentMessageDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: BigFishAgentMessageDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BigFishAgentMessageUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for BigFishAgentMessageTableHandle<'ctx> {
|
||||
type UpdateCallbackId = BigFishAgentMessageUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> BigFishAgentMessageUpdateCallbackId {
|
||||
BigFishAgentMessageUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: BigFishAgentMessageUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `message_id` unique index on the table `big_fish_agent_message`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`BigFishAgentMessageMessageIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.big_fish_agent_message().message_id().find(...)`.
|
||||
pub struct BigFishAgentMessageMessageIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<BigFishAgentMessage, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> BigFishAgentMessageTableHandle<'ctx> {
|
||||
/// Get a handle on the `message_id` unique index on the table `big_fish_agent_message`.
|
||||
pub fn message_id(&self) -> BigFishAgentMessageMessageIdUnique<'ctx> {
|
||||
BigFishAgentMessageMessageIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("message_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> BigFishAgentMessageMessageIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `message_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<BigFishAgentMessage> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<BigFishAgentMessage>("big_fish_agent_message");
|
||||
_table.add_unique_constraint::<String>("message_id", |row| &row.message_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<BigFishAgentMessage>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<BigFishAgentMessage>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `BigFishAgentMessage`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait big_fish_agent_messageQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `BigFishAgentMessage`.
|
||||
fn big_fish_agent_message(&self) -> __sdk::__query_builder::Table<BigFishAgentMessage>;
|
||||
}
|
||||
|
||||
impl big_fish_agent_messageQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn big_fish_agent_message(&self) -> __sdk::__query_builder::Table<BigFishAgentMessage> {
|
||||
__sdk::__query_builder::Table::new("big_fish_agent_message")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::big_fish_asset_kind_type::BigFishAssetKind;
|
||||
use super::big_fish_asset_slot_type::BigFishAssetSlot;
|
||||
use super::big_fish_asset_status_type::BigFishAssetStatus;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `big_fish_asset_slot`.
|
||||
///
|
||||
/// Obtain a handle from the [`BigFishAssetSlotTableAccess::big_fish_asset_slot`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.big_fish_asset_slot()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.big_fish_asset_slot().on_insert(...)`.
|
||||
pub struct BigFishAssetSlotTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<BigFishAssetSlot>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `big_fish_asset_slot`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait BigFishAssetSlotTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`BigFishAssetSlotTableHandle`], which mediates access to the table `big_fish_asset_slot`.
|
||||
fn big_fish_asset_slot(&self) -> BigFishAssetSlotTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl BigFishAssetSlotTableAccess for super::RemoteTables {
|
||||
fn big_fish_asset_slot(&self) -> BigFishAssetSlotTableHandle<'_> {
|
||||
BigFishAssetSlotTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<BigFishAssetSlot>("big_fish_asset_slot"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BigFishAssetSlotInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct BigFishAssetSlotDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for BigFishAssetSlotTableHandle<'ctx> {
|
||||
type Row = BigFishAssetSlot;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = BigFishAssetSlot> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = BigFishAssetSlotInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BigFishAssetSlotInsertCallbackId {
|
||||
BigFishAssetSlotInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: BigFishAssetSlotInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = BigFishAssetSlotDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BigFishAssetSlotDeleteCallbackId {
|
||||
BigFishAssetSlotDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: BigFishAssetSlotDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BigFishAssetSlotUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for BigFishAssetSlotTableHandle<'ctx> {
|
||||
type UpdateCallbackId = BigFishAssetSlotUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> BigFishAssetSlotUpdateCallbackId {
|
||||
BigFishAssetSlotUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: BigFishAssetSlotUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `slot_id` unique index on the table `big_fish_asset_slot`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`BigFishAssetSlotSlotIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.big_fish_asset_slot().slot_id().find(...)`.
|
||||
pub struct BigFishAssetSlotSlotIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<BigFishAssetSlot, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> BigFishAssetSlotTableHandle<'ctx> {
|
||||
/// Get a handle on the `slot_id` unique index on the table `big_fish_asset_slot`.
|
||||
pub fn slot_id(&self) -> BigFishAssetSlotSlotIdUnique<'ctx> {
|
||||
BigFishAssetSlotSlotIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("slot_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> BigFishAssetSlotSlotIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `slot_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<BigFishAssetSlot> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<BigFishAssetSlot>("big_fish_asset_slot");
|
||||
_table.add_unique_constraint::<String>("slot_id", |row| &row.slot_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<BigFishAssetSlot>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<BigFishAssetSlot>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `BigFishAssetSlot`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait big_fish_asset_slotQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `BigFishAssetSlot`.
|
||||
fn big_fish_asset_slot(&self) -> __sdk::__query_builder::Table<BigFishAssetSlot>;
|
||||
}
|
||||
|
||||
impl big_fish_asset_slotQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn big_fish_asset_slot(&self) -> __sdk::__query_builder::Table<BigFishAssetSlot> {
|
||||
__sdk::__query_builder::Table::new("big_fish_asset_slot")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::big_fish_creation_session_type::BigFishCreationSession;
|
||||
use super::big_fish_creation_stage_type::BigFishCreationStage;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `big_fish_creation_session`.
|
||||
///
|
||||
/// Obtain a handle from the [`BigFishCreationSessionTableAccess::big_fish_creation_session`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.big_fish_creation_session()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.big_fish_creation_session().on_insert(...)`.
|
||||
pub struct BigFishCreationSessionTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<BigFishCreationSession>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `big_fish_creation_session`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait BigFishCreationSessionTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`BigFishCreationSessionTableHandle`], which mediates access to the table `big_fish_creation_session`.
|
||||
fn big_fish_creation_session(&self) -> BigFishCreationSessionTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl BigFishCreationSessionTableAccess for super::RemoteTables {
|
||||
fn big_fish_creation_session(&self) -> BigFishCreationSessionTableHandle<'_> {
|
||||
BigFishCreationSessionTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<BigFishCreationSession>("big_fish_creation_session"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BigFishCreationSessionInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct BigFishCreationSessionDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for BigFishCreationSessionTableHandle<'ctx> {
|
||||
type Row = BigFishCreationSession;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = BigFishCreationSession> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = BigFishCreationSessionInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BigFishCreationSessionInsertCallbackId {
|
||||
BigFishCreationSessionInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: BigFishCreationSessionInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = BigFishCreationSessionDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BigFishCreationSessionDeleteCallbackId {
|
||||
BigFishCreationSessionDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: BigFishCreationSessionDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BigFishCreationSessionUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for BigFishCreationSessionTableHandle<'ctx> {
|
||||
type UpdateCallbackId = BigFishCreationSessionUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> BigFishCreationSessionUpdateCallbackId {
|
||||
BigFishCreationSessionUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: BigFishCreationSessionUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `session_id` unique index on the table `big_fish_creation_session`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`BigFishCreationSessionSessionIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.big_fish_creation_session().session_id().find(...)`.
|
||||
pub struct BigFishCreationSessionSessionIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<BigFishCreationSession, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> BigFishCreationSessionTableHandle<'ctx> {
|
||||
/// Get a handle on the `session_id` unique index on the table `big_fish_creation_session`.
|
||||
pub fn session_id(&self) -> BigFishCreationSessionSessionIdUnique<'ctx> {
|
||||
BigFishCreationSessionSessionIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("session_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> BigFishCreationSessionSessionIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `session_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<BigFishCreationSession> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table =
|
||||
client_cache.get_or_make_table::<BigFishCreationSession>("big_fish_creation_session");
|
||||
_table.add_unique_constraint::<String>("session_id", |row| &row.session_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<BigFishCreationSession>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<BigFishCreationSession>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `BigFishCreationSession`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait big_fish_creation_sessionQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `BigFishCreationSession`.
|
||||
fn big_fish_creation_session(&self) -> __sdk::__query_builder::Table<BigFishCreationSession>;
|
||||
}
|
||||
|
||||
impl big_fish_creation_sessionQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn big_fish_creation_session(&self) -> __sdk::__query_builder::Table<BigFishCreationSession> {
|
||||
__sdk::__query_builder::Table::new("big_fish_creation_session")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::big_fish_run_status_type::BigFishRunStatus;
|
||||
use super::big_fish_runtime_run_type::BigFishRuntimeRun;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `big_fish_runtime_run`.
|
||||
///
|
||||
/// Obtain a handle from the [`BigFishRuntimeRunTableAccess::big_fish_runtime_run`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.big_fish_runtime_run()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.big_fish_runtime_run().on_insert(...)`.
|
||||
pub struct BigFishRuntimeRunTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<BigFishRuntimeRun>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `big_fish_runtime_run`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait BigFishRuntimeRunTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`BigFishRuntimeRunTableHandle`], which mediates access to the table `big_fish_runtime_run`.
|
||||
fn big_fish_runtime_run(&self) -> BigFishRuntimeRunTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl BigFishRuntimeRunTableAccess for super::RemoteTables {
|
||||
fn big_fish_runtime_run(&self) -> BigFishRuntimeRunTableHandle<'_> {
|
||||
BigFishRuntimeRunTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<BigFishRuntimeRun>("big_fish_runtime_run"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BigFishRuntimeRunInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct BigFishRuntimeRunDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for BigFishRuntimeRunTableHandle<'ctx> {
|
||||
type Row = BigFishRuntimeRun;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = BigFishRuntimeRun> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = BigFishRuntimeRunInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BigFishRuntimeRunInsertCallbackId {
|
||||
BigFishRuntimeRunInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: BigFishRuntimeRunInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = BigFishRuntimeRunDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BigFishRuntimeRunDeleteCallbackId {
|
||||
BigFishRuntimeRunDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: BigFishRuntimeRunDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BigFishRuntimeRunUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for BigFishRuntimeRunTableHandle<'ctx> {
|
||||
type UpdateCallbackId = BigFishRuntimeRunUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> BigFishRuntimeRunUpdateCallbackId {
|
||||
BigFishRuntimeRunUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: BigFishRuntimeRunUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `run_id` unique index on the table `big_fish_runtime_run`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`BigFishRuntimeRunRunIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.big_fish_runtime_run().run_id().find(...)`.
|
||||
pub struct BigFishRuntimeRunRunIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<BigFishRuntimeRun, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> BigFishRuntimeRunTableHandle<'ctx> {
|
||||
/// Get a handle on the `run_id` unique index on the table `big_fish_runtime_run`.
|
||||
pub fn run_id(&self) -> BigFishRuntimeRunRunIdUnique<'ctx> {
|
||||
BigFishRuntimeRunRunIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("run_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> BigFishRuntimeRunRunIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `run_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<BigFishRuntimeRun> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<BigFishRuntimeRun>("big_fish_runtime_run");
|
||||
_table.add_unique_constraint::<String>("run_id", |row| &row.run_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<BigFishRuntimeRun>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<BigFishRuntimeRun>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `BigFishRuntimeRun`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait big_fish_runtime_runQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `BigFishRuntimeRun`.
|
||||
fn big_fish_runtime_run(&self) -> __sdk::__query_builder::Table<BigFishRuntimeRun>;
|
||||
}
|
||||
|
||||
impl big_fish_runtime_runQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn big_fish_runtime_run(&self) -> __sdk::__query_builder::Table<BigFishRuntimeRun> {
|
||||
__sdk::__query_builder::Table::new("big_fish_runtime_run")
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,10 @@ pub trait bind_asset_object_to_entity_and_return {
|
||||
input: AssetEntityBindingInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AssetEntityBindingProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AssetEntityBindingProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl bind_asset_object_to_entity_and_return for super::RemoteProcedures {
|
||||
input: AssetEntityBindingInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AssetEntityBindingProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AssetEntityBindingProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, AssetEntityBindingProcedureResult>(
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait bind_asset_object_to_entity {
|
||||
&self,
|
||||
input: AssetEntityBindingInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl bind_asset_object_to_entity for super::RemoteReducers {
|
||||
&self,
|
||||
input: AssetEntityBindingInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(BindAssetObjectToEntityArgs { input }, callback)
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait cancel_ai_task_and_return {
|
||||
input: AiTaskCancelInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl cancel_ai_task_and_return for super::RemoteProcedures {
|
||||
input: AiTaskCancelInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, AiTaskProcedureResult>(
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::chapter_pace_band_type::ChapterPaceBand;
|
||||
use super::chapter_progression_type::ChapterProgression;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `chapter_progression`.
|
||||
///
|
||||
/// Obtain a handle from the [`ChapterProgressionTableAccess::chapter_progression`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.chapter_progression()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.chapter_progression().on_insert(...)`.
|
||||
pub struct ChapterProgressionTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<ChapterProgression>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `chapter_progression`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait ChapterProgressionTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`ChapterProgressionTableHandle`], which mediates access to the table `chapter_progression`.
|
||||
fn chapter_progression(&self) -> ChapterProgressionTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl ChapterProgressionTableAccess for super::RemoteTables {
|
||||
fn chapter_progression(&self) -> ChapterProgressionTableHandle<'_> {
|
||||
ChapterProgressionTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<ChapterProgression>("chapter_progression"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ChapterProgressionInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct ChapterProgressionDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for ChapterProgressionTableHandle<'ctx> {
|
||||
type Row = ChapterProgression;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = ChapterProgression> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = ChapterProgressionInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> ChapterProgressionInsertCallbackId {
|
||||
ChapterProgressionInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: ChapterProgressionInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = ChapterProgressionDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> ChapterProgressionDeleteCallbackId {
|
||||
ChapterProgressionDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: ChapterProgressionDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ChapterProgressionUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for ChapterProgressionTableHandle<'ctx> {
|
||||
type UpdateCallbackId = ChapterProgressionUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> ChapterProgressionUpdateCallbackId {
|
||||
ChapterProgressionUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: ChapterProgressionUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `chapter_progression_id` unique index on the table `chapter_progression`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`ChapterProgressionChapterProgressionIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.chapter_progression().chapter_progression_id().find(...)`.
|
||||
pub struct ChapterProgressionChapterProgressionIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<ChapterProgression, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> ChapterProgressionTableHandle<'ctx> {
|
||||
/// Get a handle on the `chapter_progression_id` unique index on the table `chapter_progression`.
|
||||
pub fn chapter_progression_id(&self) -> ChapterProgressionChapterProgressionIdUnique<'ctx> {
|
||||
ChapterProgressionChapterProgressionIdUnique {
|
||||
imp: self
|
||||
.imp
|
||||
.get_unique_constraint::<String>("chapter_progression_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> ChapterProgressionChapterProgressionIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `chapter_progression_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<ChapterProgression> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<ChapterProgression>("chapter_progression");
|
||||
_table.add_unique_constraint::<String>("chapter_progression_id", |row| {
|
||||
&row.chapter_progression_id
|
||||
});
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<ChapterProgression>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<ChapterProgression>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `ChapterProgression`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait chapter_progressionQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `ChapterProgression`.
|
||||
fn chapter_progression(&self) -> __sdk::__query_builder::Table<ChapterProgression>;
|
||||
}
|
||||
|
||||
impl chapter_progressionQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn chapter_progression(&self) -> __sdk::__query_builder::Table<ChapterProgression> {
|
||||
__sdk::__query_builder::Table::new("chapter_progression")
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,10 @@ pub trait claim_profile_task_reward_and_return {
|
||||
input: RuntimeProfileTaskClaimInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskClaimProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskClaimProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl claim_profile_task_reward_and_return for super::RemoteProcedures {
|
||||
input: RuntimeProfileTaskClaimInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskClaimProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileTaskClaimProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileTaskClaimProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait claim_puzzle_work_point_incentive {
|
||||
input: PuzzleWorkPointIncentiveClaimInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleWorkProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleWorkProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl claim_puzzle_work_point_incentive for super::RemoteProcedures {
|
||||
input: PuzzleWorkPointIncentiveClaimInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleWorkProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleWorkProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, PuzzleWorkProcedureResult>(
|
||||
|
||||
@@ -34,10 +34,10 @@ pub trait clear_database_migration_import_chunks {
|
||||
input: DatabaseMigrationImportChunksClearInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<DatabaseMigrationProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<DatabaseMigrationProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ impl clear_database_migration_import_chunks for super::RemoteProcedures {
|
||||
input: DatabaseMigrationImportChunksClearInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<DatabaseMigrationProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<DatabaseMigrationProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, DatabaseMigrationProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait clear_platform_browse_history_and_return {
|
||||
input: RuntimeBrowseHistoryClearInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeBrowseHistoryProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeBrowseHistoryProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl clear_platform_browse_history_and_return for super::RemoteProcedures {
|
||||
input: RuntimeBrowseHistoryClearInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeBrowseHistoryProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeBrowseHistoryProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeBrowseHistoryProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait click_match_3_d_item {
|
||||
input: Match3DRunClickInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DClickItemProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DClickItemProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl click_match_3_d_item for super::RemoteProcedures {
|
||||
input: Match3DRunClickInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DClickItemProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DClickItemProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, Match3DClickItemProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait compile_big_fish_draft {
|
||||
input: BigFishDraftCompileInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<BigFishSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<BigFishSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl compile_big_fish_draft for super::RemoteProcedures {
|
||||
input: BigFishDraftCompileInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<BigFishSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<BigFishSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, BigFishSessionProcedureResult>(
|
||||
|
||||
@@ -34,10 +34,10 @@ pub trait compile_custom_world_published_profile {
|
||||
input: CustomWorldPublishedProfileCompileInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<CustomWorldPublishedProfileCompileResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<CustomWorldPublishedProfileCompileResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ impl compile_custom_world_published_profile for super::RemoteProcedures {
|
||||
input: CustomWorldPublishedProfileCompileInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<CustomWorldPublishedProfileCompileResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<CustomWorldPublishedProfileCompileResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, CustomWorldPublishedProfileCompileResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait compile_match_3_d_draft {
|
||||
input: Match3DDraftCompileInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl compile_match_3_d_draft for super::RemoteProcedures {
|
||||
input: Match3DDraftCompileInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, Match3DAgentSessionProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait compile_puzzle_agent_draft {
|
||||
input: PuzzleDraftCompileInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl compile_puzzle_agent_draft for super::RemoteProcedures {
|
||||
input: PuzzleDraftCompileInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, PuzzleAgentSessionProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait complete_ai_stage_and_return {
|
||||
input: AiStageCompletionInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl complete_ai_stage_and_return for super::RemoteProcedures {
|
||||
input: AiStageCompletionInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, AiTaskProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait complete_ai_task_and_return {
|
||||
input: AiTaskFinishInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl complete_ai_task_and_return for super::RemoteProcedures {
|
||||
input: AiTaskFinishInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, AiTaskProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait confirm_asset_object_and_return {
|
||||
input: AssetObjectUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AssetObjectProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AssetObjectProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl confirm_asset_object_and_return for super::RemoteProcedures {
|
||||
input: AssetObjectUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AssetObjectProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AssetObjectProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, AssetObjectProcedureResult>(
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait confirm_asset_object {
|
||||
&self,
|
||||
input: AssetObjectUpsertInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl confirm_asset_object for super::RemoteReducers {
|
||||
&self,
|
||||
input: AssetObjectUpsertInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(ConfirmAssetObjectArgs { input }, callback)
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait consume_profile_wallet_points_and_return {
|
||||
input: RuntimeProfileWalletAdjustmentInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileWalletAdjustmentProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileWalletAdjustmentProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl consume_profile_wallet_points_and_return for super::RemoteProcedures {
|
||||
input: RuntimeProfileWalletAdjustmentInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileWalletAdjustmentProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileWalletAdjustmentProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileWalletAdjustmentProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait continue_story_and_return {
|
||||
input: StoryContinueInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<StorySessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<StorySessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl continue_story_and_return for super::RemoteProcedures {
|
||||
input: StoryContinueInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<StorySessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<StorySessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, StorySessionProcedureResult>(
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait continue_story {
|
||||
&self,
|
||||
input: StoryContinueInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl continue_story for super::RemoteReducers {
|
||||
&self,
|
||||
input: StoryContinueInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(ContinueStoryArgs { input }, callback)
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait create_ai_task_and_return {
|
||||
input: AiTaskCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl create_ai_task_and_return for super::RemoteProcedures {
|
||||
input: AiTaskCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<AiTaskProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, AiTaskProcedureResult>(
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait create_ai_task {
|
||||
&self,
|
||||
input: AiTaskCreateInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl create_ai_task for super::RemoteReducers {
|
||||
&self,
|
||||
input: AiTaskCreateInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(CreateAiTaskArgs { input }, callback)
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait create_battle_state_and_return {
|
||||
input: BattleStateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<BattleStateProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<BattleStateProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl create_battle_state_and_return for super::RemoteProcedures {
|
||||
input: BattleStateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<BattleStateProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<BattleStateProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, BattleStateProcedureResult>(
|
||||
|
||||
@@ -47,11 +47,9 @@ pub trait create_battle_state {
|
||||
&self,
|
||||
input: BattleStateInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
@@ -60,11 +58,9 @@ impl create_battle_state for super::RemoteReducers {
|
||||
&self,
|
||||
input: BattleStateInput,
|
||||
|
||||
callback: impl FnOnce(
|
||||
&super::ReducerEventContext,
|
||||
Result<Result<(), String>, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(CreateBattleStateArgs { input }, callback)
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait create_big_fish_session {
|
||||
input: BigFishSessionCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<BigFishSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<BigFishSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl create_big_fish_session for super::RemoteProcedures {
|
||||
input: BigFishSessionCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<BigFishSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<BigFishSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, BigFishSessionProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait create_custom_world_agent_session {
|
||||
input: CustomWorldAgentSessionCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<CustomWorldAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<CustomWorldAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl create_custom_world_agent_session for super::RemoteProcedures {
|
||||
input: CustomWorldAgentSessionCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<CustomWorldAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<CustomWorldAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, CustomWorldAgentSessionProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait create_match_3_d_agent_session {
|
||||
input: Match3DAgentSessionCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl create_match_3_d_agent_session for super::RemoteProcedures {
|
||||
input: Match3DAgentSessionCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<Match3DAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, Match3DAgentSessionProcedureResult>(
|
||||
|
||||
@@ -34,10 +34,10 @@ pub trait create_profile_recharge_order_and_return {
|
||||
input: RuntimeProfileRechargeOrderCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRechargeCenterProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRechargeCenterProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ impl create_profile_recharge_order_and_return for super::RemoteProcedures {
|
||||
input: RuntimeProfileRechargeOrderCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRechargeCenterProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<RuntimeProfileRechargeCenterProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, RuntimeProfileRechargeCenterProcedureResult>(
|
||||
|
||||
@@ -31,10 +31,10 @@ pub trait create_puzzle_agent_session {
|
||||
input: PuzzleAgentSessionCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ impl create_puzzle_agent_session for super::RemoteProcedures {
|
||||
input: PuzzleAgentSessionCreateInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
&super::ProcedureEventContext,
|
||||
Result<PuzzleAgentSessionProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, PuzzleAgentSessionProcedureResult>(
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::custom_world_agent_message_type::CustomWorldAgentMessage;
|
||||
use super::rpg_agent_message_kind_type::RpgAgentMessageKind;
|
||||
use super::rpg_agent_message_role_type::RpgAgentMessageRole;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `custom_world_agent_message`.
|
||||
///
|
||||
/// Obtain a handle from the [`CustomWorldAgentMessageTableAccess::custom_world_agent_message`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.custom_world_agent_message()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_agent_message().on_insert(...)`.
|
||||
pub struct CustomWorldAgentMessageTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<CustomWorldAgentMessage>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `custom_world_agent_message`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait CustomWorldAgentMessageTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`CustomWorldAgentMessageTableHandle`], which mediates access to the table `custom_world_agent_message`.
|
||||
fn custom_world_agent_message(&self) -> CustomWorldAgentMessageTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl CustomWorldAgentMessageTableAccess for super::RemoteTables {
|
||||
fn custom_world_agent_message(&self) -> CustomWorldAgentMessageTableHandle<'_> {
|
||||
CustomWorldAgentMessageTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<CustomWorldAgentMessage>("custom_world_agent_message"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldAgentMessageInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct CustomWorldAgentMessageDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for CustomWorldAgentMessageTableHandle<'ctx> {
|
||||
type Row = CustomWorldAgentMessage;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = CustomWorldAgentMessage> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = CustomWorldAgentMessageInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldAgentMessageInsertCallbackId {
|
||||
CustomWorldAgentMessageInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: CustomWorldAgentMessageInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = CustomWorldAgentMessageDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldAgentMessageDeleteCallbackId {
|
||||
CustomWorldAgentMessageDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: CustomWorldAgentMessageDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldAgentMessageUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for CustomWorldAgentMessageTableHandle<'ctx> {
|
||||
type UpdateCallbackId = CustomWorldAgentMessageUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldAgentMessageUpdateCallbackId {
|
||||
CustomWorldAgentMessageUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: CustomWorldAgentMessageUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `message_id` unique index on the table `custom_world_agent_message`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`CustomWorldAgentMessageMessageIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_agent_message().message_id().find(...)`.
|
||||
pub struct CustomWorldAgentMessageMessageIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<CustomWorldAgentMessage, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldAgentMessageTableHandle<'ctx> {
|
||||
/// Get a handle on the `message_id` unique index on the table `custom_world_agent_message`.
|
||||
pub fn message_id(&self) -> CustomWorldAgentMessageMessageIdUnique<'ctx> {
|
||||
CustomWorldAgentMessageMessageIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("message_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldAgentMessageMessageIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `message_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<CustomWorldAgentMessage> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table =
|
||||
client_cache.get_or_make_table::<CustomWorldAgentMessage>("custom_world_agent_message");
|
||||
_table.add_unique_constraint::<String>("message_id", |row| &row.message_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<CustomWorldAgentMessage>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<CustomWorldAgentMessage>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `CustomWorldAgentMessage`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait custom_world_agent_messageQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `CustomWorldAgentMessage`.
|
||||
fn custom_world_agent_message(&self) -> __sdk::__query_builder::Table<CustomWorldAgentMessage>;
|
||||
}
|
||||
|
||||
impl custom_world_agent_messageQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn custom_world_agent_message(&self) -> __sdk::__query_builder::Table<CustomWorldAgentMessage> {
|
||||
__sdk::__query_builder::Table::new("custom_world_agent_message")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::custom_world_agent_operation_type::CustomWorldAgentOperation;
|
||||
use super::rpg_agent_operation_status_type::RpgAgentOperationStatus;
|
||||
use super::rpg_agent_operation_type_type::RpgAgentOperationType;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `custom_world_agent_operation`.
|
||||
///
|
||||
/// Obtain a handle from the [`CustomWorldAgentOperationTableAccess::custom_world_agent_operation`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.custom_world_agent_operation()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_agent_operation().on_insert(...)`.
|
||||
pub struct CustomWorldAgentOperationTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<CustomWorldAgentOperation>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `custom_world_agent_operation`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait CustomWorldAgentOperationTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`CustomWorldAgentOperationTableHandle`], which mediates access to the table `custom_world_agent_operation`.
|
||||
fn custom_world_agent_operation(&self) -> CustomWorldAgentOperationTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl CustomWorldAgentOperationTableAccess for super::RemoteTables {
|
||||
fn custom_world_agent_operation(&self) -> CustomWorldAgentOperationTableHandle<'_> {
|
||||
CustomWorldAgentOperationTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<CustomWorldAgentOperation>("custom_world_agent_operation"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldAgentOperationInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct CustomWorldAgentOperationDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for CustomWorldAgentOperationTableHandle<'ctx> {
|
||||
type Row = CustomWorldAgentOperation;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = CustomWorldAgentOperation> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = CustomWorldAgentOperationInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldAgentOperationInsertCallbackId {
|
||||
CustomWorldAgentOperationInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: CustomWorldAgentOperationInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = CustomWorldAgentOperationDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldAgentOperationDeleteCallbackId {
|
||||
CustomWorldAgentOperationDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: CustomWorldAgentOperationDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldAgentOperationUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for CustomWorldAgentOperationTableHandle<'ctx> {
|
||||
type UpdateCallbackId = CustomWorldAgentOperationUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldAgentOperationUpdateCallbackId {
|
||||
CustomWorldAgentOperationUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: CustomWorldAgentOperationUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `operation_id` unique index on the table `custom_world_agent_operation`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`CustomWorldAgentOperationOperationIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_agent_operation().operation_id().find(...)`.
|
||||
pub struct CustomWorldAgentOperationOperationIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<CustomWorldAgentOperation, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldAgentOperationTableHandle<'ctx> {
|
||||
/// Get a handle on the `operation_id` unique index on the table `custom_world_agent_operation`.
|
||||
pub fn operation_id(&self) -> CustomWorldAgentOperationOperationIdUnique<'ctx> {
|
||||
CustomWorldAgentOperationOperationIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("operation_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldAgentOperationOperationIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `operation_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<CustomWorldAgentOperation> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table =
|
||||
client_cache.get_or_make_table::<CustomWorldAgentOperation>("custom_world_agent_operation");
|
||||
_table.add_unique_constraint::<String>("operation_id", |row| &row.operation_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<CustomWorldAgentOperation>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<CustomWorldAgentOperation>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `CustomWorldAgentOperation`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait custom_world_agent_operationQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `CustomWorldAgentOperation`.
|
||||
fn custom_world_agent_operation(
|
||||
&self,
|
||||
) -> __sdk::__query_builder::Table<CustomWorldAgentOperation>;
|
||||
}
|
||||
|
||||
impl custom_world_agent_operationQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn custom_world_agent_operation(
|
||||
&self,
|
||||
) -> __sdk::__query_builder::Table<CustomWorldAgentOperation> {
|
||||
__sdk::__query_builder::Table::new("custom_world_agent_operation")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::custom_world_agent_session_type::CustomWorldAgentSession;
|
||||
use super::rpg_agent_stage_type::RpgAgentStage;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `custom_world_agent_session`.
|
||||
///
|
||||
/// Obtain a handle from the [`CustomWorldAgentSessionTableAccess::custom_world_agent_session`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.custom_world_agent_session()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_agent_session().on_insert(...)`.
|
||||
pub struct CustomWorldAgentSessionTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<CustomWorldAgentSession>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `custom_world_agent_session`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait CustomWorldAgentSessionTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`CustomWorldAgentSessionTableHandle`], which mediates access to the table `custom_world_agent_session`.
|
||||
fn custom_world_agent_session(&self) -> CustomWorldAgentSessionTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl CustomWorldAgentSessionTableAccess for super::RemoteTables {
|
||||
fn custom_world_agent_session(&self) -> CustomWorldAgentSessionTableHandle<'_> {
|
||||
CustomWorldAgentSessionTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<CustomWorldAgentSession>("custom_world_agent_session"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldAgentSessionInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct CustomWorldAgentSessionDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for CustomWorldAgentSessionTableHandle<'ctx> {
|
||||
type Row = CustomWorldAgentSession;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = CustomWorldAgentSession> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = CustomWorldAgentSessionInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldAgentSessionInsertCallbackId {
|
||||
CustomWorldAgentSessionInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: CustomWorldAgentSessionInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = CustomWorldAgentSessionDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldAgentSessionDeleteCallbackId {
|
||||
CustomWorldAgentSessionDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: CustomWorldAgentSessionDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldAgentSessionUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for CustomWorldAgentSessionTableHandle<'ctx> {
|
||||
type UpdateCallbackId = CustomWorldAgentSessionUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldAgentSessionUpdateCallbackId {
|
||||
CustomWorldAgentSessionUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: CustomWorldAgentSessionUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `session_id` unique index on the table `custom_world_agent_session`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`CustomWorldAgentSessionSessionIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_agent_session().session_id().find(...)`.
|
||||
pub struct CustomWorldAgentSessionSessionIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<CustomWorldAgentSession, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldAgentSessionTableHandle<'ctx> {
|
||||
/// Get a handle on the `session_id` unique index on the table `custom_world_agent_session`.
|
||||
pub fn session_id(&self) -> CustomWorldAgentSessionSessionIdUnique<'ctx> {
|
||||
CustomWorldAgentSessionSessionIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("session_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldAgentSessionSessionIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `session_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<CustomWorldAgentSession> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table =
|
||||
client_cache.get_or_make_table::<CustomWorldAgentSession>("custom_world_agent_session");
|
||||
_table.add_unique_constraint::<String>("session_id", |row| &row.session_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<CustomWorldAgentSession>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<CustomWorldAgentSession>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `CustomWorldAgentSession`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait custom_world_agent_sessionQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `CustomWorldAgentSession`.
|
||||
fn custom_world_agent_session(&self) -> __sdk::__query_builder::Table<CustomWorldAgentSession>;
|
||||
}
|
||||
|
||||
impl custom_world_agent_sessionQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn custom_world_agent_session(&self) -> __sdk::__query_builder::Table<CustomWorldAgentSession> {
|
||||
__sdk::__query_builder::Table::new("custom_world_agent_session")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::custom_world_draft_card_type::CustomWorldDraftCard;
|
||||
use super::custom_world_role_asset_status_type::CustomWorldRoleAssetStatus;
|
||||
use super::rpg_agent_draft_card_kind_type::RpgAgentDraftCardKind;
|
||||
use super::rpg_agent_draft_card_status_type::RpgAgentDraftCardStatus;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `custom_world_draft_card`.
|
||||
///
|
||||
/// Obtain a handle from the [`CustomWorldDraftCardTableAccess::custom_world_draft_card`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.custom_world_draft_card()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_draft_card().on_insert(...)`.
|
||||
pub struct CustomWorldDraftCardTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<CustomWorldDraftCard>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `custom_world_draft_card`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait CustomWorldDraftCardTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`CustomWorldDraftCardTableHandle`], which mediates access to the table `custom_world_draft_card`.
|
||||
fn custom_world_draft_card(&self) -> CustomWorldDraftCardTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl CustomWorldDraftCardTableAccess for super::RemoteTables {
|
||||
fn custom_world_draft_card(&self) -> CustomWorldDraftCardTableHandle<'_> {
|
||||
CustomWorldDraftCardTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<CustomWorldDraftCard>("custom_world_draft_card"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldDraftCardInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct CustomWorldDraftCardDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for CustomWorldDraftCardTableHandle<'ctx> {
|
||||
type Row = CustomWorldDraftCard;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = CustomWorldDraftCard> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = CustomWorldDraftCardInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldDraftCardInsertCallbackId {
|
||||
CustomWorldDraftCardInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: CustomWorldDraftCardInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = CustomWorldDraftCardDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldDraftCardDeleteCallbackId {
|
||||
CustomWorldDraftCardDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: CustomWorldDraftCardDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldDraftCardUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for CustomWorldDraftCardTableHandle<'ctx> {
|
||||
type UpdateCallbackId = CustomWorldDraftCardUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldDraftCardUpdateCallbackId {
|
||||
CustomWorldDraftCardUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: CustomWorldDraftCardUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `card_id` unique index on the table `custom_world_draft_card`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`CustomWorldDraftCardCardIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_draft_card().card_id().find(...)`.
|
||||
pub struct CustomWorldDraftCardCardIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<CustomWorldDraftCard, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldDraftCardTableHandle<'ctx> {
|
||||
/// Get a handle on the `card_id` unique index on the table `custom_world_draft_card`.
|
||||
pub fn card_id(&self) -> CustomWorldDraftCardCardIdUnique<'ctx> {
|
||||
CustomWorldDraftCardCardIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("card_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldDraftCardCardIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `card_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<CustomWorldDraftCard> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<CustomWorldDraftCard>("custom_world_draft_card");
|
||||
_table.add_unique_constraint::<String>("card_id", |row| &row.card_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<CustomWorldDraftCard>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<CustomWorldDraftCard>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `CustomWorldDraftCard`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait custom_world_draft_cardQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `CustomWorldDraftCard`.
|
||||
fn custom_world_draft_card(&self) -> __sdk::__query_builder::Table<CustomWorldDraftCard>;
|
||||
}
|
||||
|
||||
impl custom_world_draft_cardQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn custom_world_draft_card(&self) -> __sdk::__query_builder::Table<CustomWorldDraftCard> {
|
||||
__sdk::__query_builder::Table::new("custom_world_draft_card")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::custom_world_profile_type::CustomWorldProfile;
|
||||
use super::custom_world_publication_status_type::CustomWorldPublicationStatus;
|
||||
use super::custom_world_theme_mode_type::CustomWorldThemeMode;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `custom_world_profile`.
|
||||
///
|
||||
/// Obtain a handle from the [`CustomWorldProfileTableAccess::custom_world_profile`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.custom_world_profile()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_profile().on_insert(...)`.
|
||||
pub struct CustomWorldProfileTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<CustomWorldProfile>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `custom_world_profile`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait CustomWorldProfileTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`CustomWorldProfileTableHandle`], which mediates access to the table `custom_world_profile`.
|
||||
fn custom_world_profile(&self) -> CustomWorldProfileTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl CustomWorldProfileTableAccess for super::RemoteTables {
|
||||
fn custom_world_profile(&self) -> CustomWorldProfileTableHandle<'_> {
|
||||
CustomWorldProfileTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<CustomWorldProfile>("custom_world_profile"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldProfileInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct CustomWorldProfileDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for CustomWorldProfileTableHandle<'ctx> {
|
||||
type Row = CustomWorldProfile;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = CustomWorldProfile> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = CustomWorldProfileInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldProfileInsertCallbackId {
|
||||
CustomWorldProfileInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: CustomWorldProfileInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = CustomWorldProfileDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldProfileDeleteCallbackId {
|
||||
CustomWorldProfileDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: CustomWorldProfileDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldProfileUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for CustomWorldProfileTableHandle<'ctx> {
|
||||
type UpdateCallbackId = CustomWorldProfileUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldProfileUpdateCallbackId {
|
||||
CustomWorldProfileUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: CustomWorldProfileUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `profile_id` unique index on the table `custom_world_profile`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`CustomWorldProfileProfileIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_profile().profile_id().find(...)`.
|
||||
pub struct CustomWorldProfileProfileIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<CustomWorldProfile, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldProfileTableHandle<'ctx> {
|
||||
/// Get a handle on the `profile_id` unique index on the table `custom_world_profile`.
|
||||
pub fn profile_id(&self) -> CustomWorldProfileProfileIdUnique<'ctx> {
|
||||
CustomWorldProfileProfileIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("profile_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldProfileProfileIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `profile_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<CustomWorldProfile> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<CustomWorldProfile>("custom_world_profile");
|
||||
_table.add_unique_constraint::<String>("profile_id", |row| &row.profile_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<CustomWorldProfile>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<CustomWorldProfile>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `CustomWorldProfile`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait custom_world_profileQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `CustomWorldProfile`.
|
||||
fn custom_world_profile(&self) -> __sdk::__query_builder::Table<CustomWorldProfile>;
|
||||
}
|
||||
|
||||
impl custom_world_profileQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn custom_world_profile(&self) -> __sdk::__query_builder::Table<CustomWorldProfile> {
|
||||
__sdk::__query_builder::Table::new("custom_world_profile")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::custom_world_generation_mode_type::CustomWorldGenerationMode;
|
||||
use super::custom_world_session_status_type::CustomWorldSessionStatus;
|
||||
use super::custom_world_session_type::CustomWorldSession;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `custom_world_session`.
|
||||
///
|
||||
/// Obtain a handle from the [`CustomWorldSessionTableAccess::custom_world_session`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.custom_world_session()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_session().on_insert(...)`.
|
||||
pub struct CustomWorldSessionTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<CustomWorldSession>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `custom_world_session`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait CustomWorldSessionTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`CustomWorldSessionTableHandle`], which mediates access to the table `custom_world_session`.
|
||||
fn custom_world_session(&self) -> CustomWorldSessionTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl CustomWorldSessionTableAccess for super::RemoteTables {
|
||||
fn custom_world_session(&self) -> CustomWorldSessionTableHandle<'_> {
|
||||
CustomWorldSessionTableHandle {
|
||||
imp: self
|
||||
.imp
|
||||
.get_table::<CustomWorldSession>("custom_world_session"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldSessionInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct CustomWorldSessionDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for CustomWorldSessionTableHandle<'ctx> {
|
||||
type Row = CustomWorldSession;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = CustomWorldSession> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = CustomWorldSessionInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldSessionInsertCallbackId {
|
||||
CustomWorldSessionInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: CustomWorldSessionInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = CustomWorldSessionDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldSessionDeleteCallbackId {
|
||||
CustomWorldSessionDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: CustomWorldSessionDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomWorldSessionUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for CustomWorldSessionTableHandle<'ctx> {
|
||||
type UpdateCallbackId = CustomWorldSessionUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> CustomWorldSessionUpdateCallbackId {
|
||||
CustomWorldSessionUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: CustomWorldSessionUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `session_id` unique index on the table `custom_world_session`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`CustomWorldSessionSessionIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.custom_world_session().session_id().find(...)`.
|
||||
pub struct CustomWorldSessionSessionIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<CustomWorldSession, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldSessionTableHandle<'ctx> {
|
||||
/// Get a handle on the `session_id` unique index on the table `custom_world_session`.
|
||||
pub fn session_id(&self) -> CustomWorldSessionSessionIdUnique<'ctx> {
|
||||
CustomWorldSessionSessionIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("session_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> CustomWorldSessionSessionIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `session_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &String) -> Option<CustomWorldSession> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<CustomWorldSession>("custom_world_session");
|
||||
_table.add_unique_constraint::<String>("session_id", |row| &row.session_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<CustomWorldSession>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<CustomWorldSession>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `CustomWorldSession`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait custom_world_sessionQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `CustomWorldSession`.
|
||||
fn custom_world_session(&self) -> __sdk::__query_builder::Table<CustomWorldSession>;
|
||||
}
|
||||
|
||||
impl custom_world_sessionQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn custom_world_session(&self) -> __sdk::__query_builder::Table<CustomWorldSession> {
|
||||
__sdk::__query_builder::Table::new("custom_world_session")
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user