新增后台账号初始泥点配置

新增 profile_wallet_config 表和后台读写接口

注册赠送泥点改为读取后台配置并保留默认 100

后台新增账号配置页并同步数据契约文档
This commit is contained in:
2026-06-23 17:42:35 +08:00
parent 0c2c0c2c0f
commit afc2f03497
30 changed files with 1132 additions and 15 deletions
+23
View File
@@ -20,6 +20,7 @@ import type {
AdminUpsertProfileRechargeProductRequest,
AdminUpsertProfileRedeemCodeRequest,
AdminUpsertProfileTaskConfigRequest,
AdminUpsertProfileWalletConfigRequest,
AdminUpsertPublicWorkInteractionConfigRequest,
AdminWorkVisibilityListResponse,
ApiErrorEnvelope,
@@ -34,6 +35,7 @@ import type {
ProfileRedeemCodeAdminResponse,
ProfileTaskConfigAdminListResponse,
ProfileTaskConfigAdminResponse,
ProfileWalletConfigAdminResponse,
} from './adminApiTypes';
const API_RESPONSE_ENVELOPE_HEADER = 'x-genarrative-response-envelope';
@@ -359,6 +361,27 @@ export function disableProfileTaskConfig(
);
}
export function getProfileWalletConfig(token: string) {
return request<ProfileWalletConfigAdminResponse>(
'/admin/api/profile/wallet-config',
{ token },
);
}
export function upsertProfileWalletConfig(
token: string,
payload: AdminUpsertProfileWalletConfigRequest,
) {
return request<ProfileWalletConfigAdminResponse>(
'/admin/api/profile/wallet-config',
{
method: 'POST',
token,
body: payload,
},
);
}
export function listProfileRechargeProducts(token: string) {
return request<ProfileRechargeProductConfigAdminListResponse>(
'/admin/api/profile/recharge-products',
+13
View File
@@ -325,6 +325,10 @@ export interface AdminUpsertProfileRechargeProductRequest {
sortOrder: number;
}
export interface AdminUpsertProfileWalletConfigRequest {
initialMudPoints: number;
}
export interface ProfileRedeemCodeAdminResponse {
code: string;
mode: ProfileRedeemCodeMode;
@@ -401,6 +405,15 @@ export interface ProfileRechargeProductConfigAdminListResponse {
entries: ProfileRechargeProductConfigAdminResponse[];
}
export interface ProfileWalletConfigAdminResponse {
configId: string;
initialMudPoints: number;
createdBy: string;
createdAt: string;
updatedBy: string;
updatedAt: string;
}
export interface AdminTrackingEventEntryPayload {
eventId: string;
eventKey: string;
+14
View File
@@ -12,6 +12,7 @@ import type {
ProfileRechargeProductConfigAdminResponse,
ProfileRedeemCodeAdminResponse,
ProfileTaskConfigAdminResponse,
ProfileWalletConfigAdminResponse,
} from '../api/adminApiTypes';
import {
clearStoredAdminToken,
@@ -25,6 +26,7 @@ import {AdminInviteCodePage} from '../pages/AdminInviteCodePage';
import {AdminLoginPage} from '../pages/AdminLoginPage';
import {AdminEditorGenerationPricingPage} from '../pages/AdminEditorGenerationPricingPage';
import {AdminOverviewPage} from '../pages/AdminOverviewPage';
import {AdminProfileWalletConfigPage} from '../pages/AdminProfileWalletConfigPage';
import {AdminRechargeProductPage} from '../pages/AdminRechargeProductPage';
import {AdminRedeemCodePage} from '../pages/AdminRedeemCodePage';
import {AdminTaskConfigPage} from '../pages/AdminTaskConfigPage';
@@ -51,6 +53,8 @@ export function AdminApp() {
useState<ProfileInviteCodeAdminResponse | null>(null);
const [taskConfigResult, setTaskConfigResult] =
useState<ProfileTaskConfigAdminResponse | null>(null);
const [profileWalletConfigResult, setProfileWalletConfigResult] =
useState<ProfileWalletConfigAdminResponse | null>(null);
const [rechargeProductResult, setRechargeProductResult] =
useState<ProfileRechargeProductConfigAdminResponse | null>(null);
@@ -61,6 +65,7 @@ export function AdminApp() {
setRedeemResult(null);
setInviteResult(null);
setTaskConfigResult(null);
setProfileWalletConfigResult(null);
setRechargeProductResult(null);
setStatus('guest');
setLoginNotice(message);
@@ -131,6 +136,7 @@ export function AdminApp() {
setRedeemResult(null);
setInviteResult(null);
setTaskConfigResult(null);
setProfileWalletConfigResult(null);
setRechargeProductResult(null);
setLoginNotice('');
setStatus('authenticated');
@@ -228,6 +234,14 @@ export function AdminApp() {
onResultChange={setTaskConfigResult}
/>
) : null}
{routeId === 'profile-wallet' ? (
<AdminProfileWalletConfigPage
result={profileWalletConfigResult}
token={token}
onUnauthorized={handleUnauthorized}
onResultChange={setProfileWalletConfigResult}
/>
) : null}
{routeId === 'recharge-products' ? (
<AdminRechargeProductPage
result={rechargeProductResult}
+2
View File
@@ -6,6 +6,7 @@ import {
LogOut,
Megaphone,
Eye,
WalletCards,
ShieldCheck,
ListChecks,
SlidersHorizontal,
@@ -35,6 +36,7 @@ const routeIcons = {
tracking: Table2,
redeem: TicketPercent,
invite: TicketCheck,
'profile-wallet': WalletCards,
tasks: ListChecks,
'recharge-products': BadgeDollarSign,
'editor-generation-pricing': Coins,
+2
View File
@@ -6,6 +6,7 @@ export type AdminRouteId =
| 'tracking'
| 'redeem'
| 'invite'
| 'profile-wallet'
| 'tasks'
| 'recharge-products'
| 'editor-generation-pricing'
@@ -27,6 +28,7 @@ export const adminRoutes: AdminRouteDefinition[] = [
{id: 'tracking', label: '埋点数据', hash: '#tracking'},
{id: 'redeem', label: '兑换码', hash: '#redeem'},
{id: 'invite', label: '邀请码', hash: '#invite'},
{id: 'profile-wallet', label: '账号配置', hash: '#profile-wallet'},
{id: 'tasks', label: '任务配置', hash: '#tasks'},
{id: 'recharge-products', label: '充值商品', hash: '#recharge-products'},
{id: 'editor-generation-pricing', label: '模型定价', hash: '#editor-generation-pricing'},
@@ -0,0 +1,174 @@
import {RefreshCcw, Save} from 'lucide-react';
import {FormEvent, useEffect, useState} from 'react';
import {
getProfileWalletConfig,
upsertProfileWalletConfig,
} from '../api/adminApiClient';
import type {ProfileWalletConfigAdminResponse} from '../api/adminApiTypes';
import {useAdminWriteConfirm} from '../components/useAdminWriteConfirm';
import {handlePageError} from './pageUtils';
interface AdminProfileWalletConfigPageProps {
token: string;
result: ProfileWalletConfigAdminResponse | null;
onUnauthorized: (message?: string) => void;
onResultChange: (result: ProfileWalletConfigAdminResponse) => void;
}
export function AdminProfileWalletConfigPage({
token,
result,
onUnauthorized,
onResultChange,
}: AdminProfileWalletConfigPageProps) {
const [initialMudPoints, setInitialMudPoints] = useState('100');
const [isLoading, setIsLoading] = useState(false);
const [isSaving, setIsSaving] = useState(false);
const [loadErrorMessage, setLoadErrorMessage] = useState('');
const [errorMessage, setErrorMessage] = useState('');
const {confirmWrite, confirmDialog} = useAdminWriteConfirm();
useEffect(() => {
void refreshConfig();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [token]);
async function refreshConfig() {
setIsLoading(true);
setLoadErrorMessage('');
try {
const response = await getProfileWalletConfig(token);
onResultChange(response);
setInitialMudPoints(String(response.initialMudPoints));
} catch (error: unknown) {
handlePageError(error, onUnauthorized, setLoadErrorMessage);
} finally {
setIsLoading(false);
}
}
async function handleSave(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
if (isSaving) {
return;
}
const normalizedInitialMudPoints = parsePositiveInteger(initialMudPoints);
if (!normalizedInitialMudPoints) {
setErrorMessage('账号初始泥点数必须是大于 0 的整数');
return;
}
setErrorMessage('');
const confirmed = await confirmWrite({
action: '保存账号配置',
target: `${normalizedInitialMudPoints}泥点`,
});
if (!confirmed) {
return;
}
setIsSaving(true);
try {
const response = await upsertProfileWalletConfig(token, {
initialMudPoints: normalizedInitialMudPoints,
});
onResultChange(response);
setInitialMudPoints(String(response.initialMudPoints));
} catch (error: unknown) {
handlePageError(error, onUnauthorized, setErrorMessage);
} finally {
setIsSaving(false);
}
}
return (
<section className="admin-page">
<div className="admin-page-heading">
<div>
<h2></h2>
<p></p>
</div>
<button
className="admin-secondary-button"
disabled={isLoading}
type="button"
onClick={refreshConfig}
>
<RefreshCcw size={17} aria-hidden="true" />
<span>{isLoading ? '刷新中' : '刷新'}</span>
</button>
</div>
{loadErrorMessage ? (
<div className="admin-alert" role="status">
{loadErrorMessage}
</div>
) : null}
<div className="admin-two-column">
<form className="admin-panel admin-form" onSubmit={handleSave}>
<label className="admin-field">
<span></span>
<input
min={1}
step={1}
type="number"
value={initialMudPoints}
onChange={(event) => setInitialMudPoints(event.target.value)}
/>
</label>
{errorMessage ? (
<div className="admin-alert" role="status">
{errorMessage}
</div>
) : null}
<button
className="admin-primary-button"
disabled={isSaving || !parsePositiveInteger(initialMudPoints)}
type="submit"
>
<Save size={17} aria-hidden="true" />
<span>{isSaving ? '保存中' : '保存'}</span>
</button>
</form>
<section className="admin-panel admin-result-panel">
<div className="admin-panel-heading">
<h3></h3>
<span>{result?.configId ?? '-'}</span>
</div>
{result ? (
<dl className="admin-info-list">
<div>
<dt></dt>
<dd>{result.initialMudPoints}</dd>
</div>
<div>
<dt></dt>
<dd>{result.updatedBy || '-'}</dd>
</div>
<div>
<dt></dt>
<dd>{result.updatedAt}</dd>
</div>
</dl>
) : (
<div className="admin-empty-state">
{isLoading ? '加载中' : '暂无记录'}
</div>
)}
</section>
</div>
{confirmDialog}
</section>
);
}
function parsePositiveInteger(value: string) {
const parsed = Number.parseInt(value, 10);
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
}
@@ -198,7 +198,7 @@ npm run check:server-rs-ddd
## 用户钱包与编辑器生成扣费契约
1. 新用户账号完成注册并成功同步正式认证表后,注册赠送固定`100` 泥点流水原因仍使用 `new_user_registration_reward`,流水 ID 继续保持幂等,重复发放请求不得叠加余额。
1. 新用户账号完成注册并成功同步正式认证表后,注册赠送金额读取 `profile_wallet_config.initial_mud_points`;后台通过 `/admin/api/profile/wallet-config` 维护“账号初始泥点数”。未写入配置时默认仍`100` 泥点流水原因仍使用 `new_user_registration_reward`,流水 ID 继续保持幂等,重复发放请求不得叠加余额。
2. 编辑器画板所有会调用外部生成 provider 的入口都不从前端请求接收 `priceMudPoints`;实际扣费真相以后端运行时模型定价配置为准,前端按钮泥点只作为展示。
3. 编辑器图片生成 / 图片修改 / 图标 spritesheet / UI 设计图提取素材 / 视频 / 角色动作 / 音效 / 背景音乐必须在后端计算模型价格后使用 `execute_billable_asset_operation_with_cost` 预扣泥点;预扣失败必须 fail-closed,不得继续提交 VectorEngine、Ark、Suno 或 Vidu 上游任务。
4. 音频生成的编辑器链路虽然任务提交和结果发布分离,仍必须把提交时后端计算出的模型价格写入 `AudioAssetBindingTarget.billing_points_cost`,最终发布落资产时按该价格扣费;创作音频目标未提供该字段时才使用旧的创作音频固定成本。
@@ -680,6 +680,12 @@ npm run check:server-rs-ddd
- Rust 结构体:`ProfileWalletLedger`
- 源码:`server-rs/crates/spacetime-module/src/runtime/profile.rs`
### `profile_wallet_config`
- Rust 结构体:`ProfileWalletConfig`
- 源码:`server-rs/crates/spacetime-module/src/runtime/profile.rs`
- 作用:账号钱包全局配置真相源,当前维护新账号注册初始泥点数;表为空时业务回退 `100` 泥点。
### `public_work_like`
- Rust 结构体:`PublicWorkLike`
@@ -497,6 +497,7 @@ cargo test -p platform-auth --manifest-path server-rs/Cargo.toml aliyun_send_sms
- `profile_task_progress`
- `profile_task_reward_claim`
- `profile_wallet_ledger`
- `profile_wallet_config`
个人任务首版 scope 仅支持 `user`。每日登录任务按北京时间自然日 0 点重置;用户已登录并停留在“我的”页跨日时,前端需要先非阻断调用 refresh session 以写入新业务日 `daily_login`,再请求 `/api/profile/tasks` 刷新任务中心。认证成功后的 `daily_login` 必须通过 `SpacetimeClient::record_daily_login_tracking_event(...)` 调用 SpacetimeDB 专用 `record_daily_login_tracking_event_and_return` procedure,由数据库事务时间生成当日幂等事件并推进任务进度;不要改回普通 `record_tracking_event_after_success`、tracking outbox 或旧 `profile.login.daily` 事件键。后台、RPG、大鱼吃小鱼、Visual Novel、Story、Combat 等特定链路按 tracking 中间件排除规则处理;作品游玩统一使用 `work_play_start`
@@ -14,10 +14,11 @@ use crate::{
},
runtime_profile::{
admin_disable_profile_redeem_code, admin_disable_profile_task_config,
admin_list_profile_invite_codes, admin_list_profile_recharge_products,
admin_list_profile_redeem_codes, admin_list_profile_task_configs,
admin_upsert_profile_invite_code, admin_upsert_profile_recharge_product,
admin_upsert_profile_redeem_code, admin_upsert_profile_task_config,
admin_get_profile_wallet_config, admin_list_profile_invite_codes,
admin_list_profile_recharge_products, admin_list_profile_redeem_codes,
admin_list_profile_task_configs, admin_upsert_profile_invite_code,
admin_upsert_profile_recharge_product, admin_upsert_profile_redeem_code,
admin_upsert_profile_task_config, admin_upsert_profile_wallet_config,
},
state::AppState,
};
@@ -145,6 +146,15 @@ pub fn router(state: AppState) -> Router<AppState> {
middleware::from_fn_with_state(state.clone(), require_admin_auth),
),
)
.route(
"/admin/api/profile/wallet-config",
get(admin_get_profile_wallet_config)
.post(admin_upsert_profile_wallet_config)
.route_layer(middleware::from_fn_with_state(
state.clone(),
require_admin_auth,
)),
)
.route(
"/admin/api/profile/recharge-products",
get(admin_list_profile_recharge_products)
@@ -35,8 +35,8 @@ use shared_contracts::runtime::{
ANALYTICS_GRANULARITY_WEEK, ANALYTICS_GRANULARITY_YEAR, AdminDisableProfileRedeemCodeRequest,
AdminDisableProfileTaskConfigRequest, AdminUpsertProfileInviteCodeRequest,
AdminUpsertProfileRechargeProductRequest, AdminUpsertProfileRedeemCodeRequest,
AdminUpsertProfileTaskConfigRequest, AnalyticsBucketMetricResponse,
AnalyticsMetricQueryResponse, ClaimProfileTaskRewardResponse,
AdminUpsertProfileTaskConfigRequest, AdminUpsertProfileWalletConfigRequest,
AnalyticsBucketMetricResponse, AnalyticsMetricQueryResponse, ClaimProfileTaskRewardResponse,
ConfirmWechatProfileRechargeOrderResponse, CreateProfileRechargeOrderRequest,
CreateProfileRechargeOrderResponse, PROFILE_FEEDBACK_STATUS_OPEN,
PROFILE_MEMBERSHIP_TIER_MONTH, PROFILE_MEMBERSHIP_TIER_NORMAL, PROFILE_MEMBERSHIP_TIER_SEASON,
@@ -62,11 +62,12 @@ use shared_contracts::runtime::{
ProfileRedeemCodeAdminResponse, ProfileReferralInviteCenterResponse,
ProfileReferralInvitedUserResponse, ProfileTaskCenterResponse,
ProfileTaskConfigAdminListResponse, ProfileTaskConfigAdminResponse, ProfileTaskItemResponse,
ProfileWalletLedgerEntryResponse, ProfileWalletLedgerResponse,
RedeemProfileReferralInviteCodeRequest, RedeemProfileReferralInviteCodeResponse,
RedeemProfileRewardCodeRequest, RedeemProfileRewardCodeResponse, SubmitProfileFeedbackRequest,
SubmitProfileFeedbackResponse, TRACKING_SCOPE_KIND_MODULE, TRACKING_SCOPE_KIND_SITE,
TRACKING_SCOPE_KIND_USER, TRACKING_SCOPE_KIND_WORK, WechatMiniProgramPaymentParamsResponse,
ProfileWalletConfigAdminResponse, ProfileWalletLedgerEntryResponse,
ProfileWalletLedgerResponse, RedeemProfileReferralInviteCodeRequest,
RedeemProfileReferralInviteCodeResponse, RedeemProfileRewardCodeRequest,
RedeemProfileRewardCodeResponse, SubmitProfileFeedbackRequest, SubmitProfileFeedbackResponse,
TRACKING_SCOPE_KIND_MODULE, TRACKING_SCOPE_KIND_SITE, TRACKING_SCOPE_KIND_USER,
TRACKING_SCOPE_KIND_WORK, WechatMiniProgramPaymentParamsResponse,
WechatMiniProgramVirtualPayParamsResponse, WechatProfileRechargeOrderDoneEvent,
WechatProfileRechargeOrderErrorEvent,
};
@@ -819,6 +820,56 @@ pub async fn admin_disable_profile_task_config(
))
}
pub async fn admin_get_profile_wallet_config(
State(state): State<AppState>,
Extension(request_context): Extension<RequestContext>,
Extension(admin): Extension<AuthenticatedAdmin>,
) -> Result<Json<Value>, Response> {
let record = state
.spacetime_client()
.admin_get_profile_wallet_config(admin.session().subject.clone())
.await
.map_err(|error| {
runtime_profile_error_response(
&request_context,
map_runtime_profile_client_error(error),
)
})?;
Ok(json_success_body(
Some(&request_context),
build_profile_wallet_config_admin_response(record),
))
}
pub async fn admin_upsert_profile_wallet_config(
State(state): State<AppState>,
Extension(request_context): Extension<RequestContext>,
Extension(admin): Extension<AuthenticatedAdmin>,
Json(payload): Json<AdminUpsertProfileWalletConfigRequest>,
) -> Result<Json<Value>, Response> {
let updated_at_micros = OffsetDateTime::now_utc().unix_timestamp_nanos() / 1_000;
let record = state
.spacetime_client()
.admin_upsert_profile_wallet_config(
admin.session().subject.clone(),
payload.initial_mud_points,
updated_at_micros as i64,
)
.await
.map_err(|error| {
runtime_profile_error_response(
&request_context,
map_runtime_profile_client_error(error),
)
})?;
Ok(json_success_body(
Some(&request_context),
build_profile_wallet_config_admin_response(record),
))
}
pub async fn admin_list_profile_recharge_products(
State(state): State<AppState>,
Extension(request_context): Extension<RequestContext>,
@@ -1770,6 +1821,19 @@ fn build_profile_recharge_product_config_admin_response(
}
}
fn build_profile_wallet_config_admin_response(
record: module_runtime::RuntimeProfileWalletConfigRecord,
) -> ProfileWalletConfigAdminResponse {
ProfileWalletConfigAdminResponse {
config_id: record.config_id,
initial_mud_points: record.initial_mud_points,
created_by: record.created_by,
created_at: record.created_at,
updated_by: record.updated_by,
updated_at: record.updated_at,
}
}
fn normalize_admin_invite_code_metadata(metadata: Option<Value>) -> Result<String, AppError> {
let metadata = match metadata {
Some(Value::Null) | None => json!({}),
@@ -842,6 +842,28 @@ pub fn build_runtime_profile_wallet_ledger_entry_record(
}
}
pub fn build_runtime_profile_wallet_config_record(
snapshot: RuntimeProfileWalletConfigSnapshot,
) -> RuntimeProfileWalletConfigRecord {
let format_optional_audit_time = |micros: i64| {
if micros > 0 {
format_utc_micros(micros)
} else {
"-".to_string()
}
};
RuntimeProfileWalletConfigRecord {
config_id: snapshot.config_id,
initial_mud_points: snapshot.initial_mud_points,
created_by: snapshot.created_by,
created_at: format_optional_audit_time(snapshot.created_at_micros),
created_at_micros: snapshot.created_at_micros,
updated_by: snapshot.updated_by,
updated_at: format_optional_audit_time(snapshot.updated_at_micros),
updated_at_micros: snapshot.updated_at_micros,
}
}
pub fn build_runtime_profile_recharge_center_record(
snapshot: RuntimeProfileRechargeCenterSnapshot,
) -> RuntimeProfileRechargeCenterRecord {
@@ -78,6 +78,29 @@ pub fn build_runtime_profile_wallet_ledger_list_input(
Ok(RuntimeProfileWalletLedgerListInput { user_id })
}
pub fn build_runtime_profile_wallet_config_admin_get_input(
admin_user_id: String,
) -> Result<RuntimeProfileWalletConfigAdminGetInput, RuntimeProfileFieldError> {
let admin_user_id = normalize_runtime_profile_user_id(admin_user_id)?;
Ok(RuntimeProfileWalletConfigAdminGetInput { admin_user_id })
}
pub fn build_runtime_profile_wallet_config_admin_upsert_input(
admin_user_id: String,
initial_mud_points: u64,
updated_at_micros: i64,
) -> Result<RuntimeProfileWalletConfigAdminUpsertInput, RuntimeProfileFieldError> {
let admin_user_id = normalize_runtime_profile_user_id(admin_user_id)?;
if initial_mud_points == 0 || initial_mud_points > i64::MAX as u64 {
return Err(RuntimeProfileFieldError::InvalidInitialWalletPoints);
}
Ok(RuntimeProfileWalletConfigAdminUpsertInput {
admin_user_id,
initial_mud_points,
updated_at_micros,
})
}
pub fn build_runtime_tracking_event_input(
event_id: String,
event_key: String,
@@ -15,6 +15,7 @@ pub const DEFAULT_BROWSE_HISTORY_AUTHOR_DISPLAY_NAME: &str = "玩家";
pub const MAX_BROWSE_HISTORY_BATCH_SIZE: usize = 100;
pub const PROFILE_WALLET_LEDGER_LIST_LIMIT: usize = 50;
pub const PROFILE_NEW_USER_INITIAL_WALLET_POINTS: u64 = 100;
pub const PROFILE_WALLET_CONFIG_GLOBAL_ID: &str = "profile_wallet";
pub const PROFILE_REFERRAL_REWARD_POINTS: u64 = 30;
pub const PROFILE_REFERRAL_DAILY_INVITER_REWARD_LIMIT: u32 = 10;
pub const PROFILE_INVITE_CODE_METADATA_DEFAULT_JSON: &str = "{}";
@@ -643,6 +644,39 @@ pub struct RuntimeProfileDashboardGetInput {
pub user_id: String,
}
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RuntimeProfileWalletConfigSnapshot {
pub config_id: String,
pub initial_mud_points: u64,
pub created_by: String,
pub created_at_micros: i64,
pub updated_by: String,
pub updated_at_micros: i64,
}
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RuntimeProfileWalletConfigAdminGetInput {
pub admin_user_id: String,
}
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RuntimeProfileWalletConfigAdminUpsertInput {
pub admin_user_id: String,
pub initial_mud_points: u64,
pub updated_at_micros: i64,
}
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RuntimeProfileWalletConfigAdminProcedureResult {
pub ok: bool,
pub record: Option<RuntimeProfileWalletConfigSnapshot>,
pub error_message: Option<String>,
}
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum RuntimeProfileFeedbackStatus {
@@ -1682,6 +1716,18 @@ pub struct RuntimeProfileRechargeProductConfigRecord {
pub updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq)]
pub struct RuntimeProfileWalletConfigRecord {
pub config_id: String,
pub initial_mud_points: u64,
pub created_by: String,
pub created_at: String,
pub created_at_micros: i64,
pub updated_by: String,
pub updated_at: String,
pub updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq)]
pub struct RuntimeProfileMembershipBenefitRecord {
pub benefit_name: String,
@@ -46,6 +46,7 @@ pub enum RuntimeProfileFieldError {
MissingUserId,
MissingLedgerId,
InvalidWalletAmount,
InvalidInitialWalletPoints,
WalletAmountOverflow,
WalletBalanceOverflow,
InsufficientWalletBalance,
@@ -111,6 +112,9 @@ impl std::fmt::Display for RuntimeProfileFieldError {
Self::MissingUserId => f.write_str("profile.user_id 不能为空"),
Self::MissingLedgerId => f.write_str("profile.wallet_ledger_id 不能为空"),
Self::InvalidWalletAmount => f.write_str("profile.wallet_amount 必须大于 0"),
Self::InvalidInitialWalletPoints => {
f.write_str("profile_wallet_config.initial_mud_points 必须大于 0")
}
Self::WalletAmountOverflow => f.write_str("profile.wallet_amount 超出上限"),
Self::WalletBalanceOverflow => f.write_str("profile.wallet_balance 超出上限"),
Self::InsufficientWalletBalance => f.write_str("泥点余额不足"),
@@ -514,6 +514,17 @@ pub struct ProfileRechargeProductConfigAdminListResponse {
pub entries: Vec<ProfileRechargeProductConfigAdminResponse>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ProfileWalletConfigAdminResponse {
pub config_id: String,
pub initial_mud_points: u64,
pub created_by: String,
pub created_at: String,
pub updated_by: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct AnalyticsMetricQueryRequest {
@@ -577,6 +588,12 @@ pub struct AdminUpsertProfileRechargeProductRequest {
pub sort_order: Option<i32>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct AdminUpsertProfileWalletConfigRequest {
pub initial_mud_points: u64,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct AdminDisableProfileTaskConfigRequest {
+4 -2
View File
@@ -204,7 +204,7 @@ use module_runtime::{
RuntimeProfileRedeemCodeRecord, RuntimeProfileRewardCodeRedeemRecord,
RuntimeProfileSaveArchiveRecord, RuntimeProfileTaskCenterRecord, RuntimeProfileTaskClaimRecord,
RuntimeProfileTaskConfigRecord, RuntimeProfileTaskCycle as DomainRuntimeProfileTaskCycle,
RuntimeProfileTaskStatus as DomainRuntimeProfileTaskStatus,
RuntimeProfileTaskStatus as DomainRuntimeProfileTaskStatus, RuntimeProfileWalletConfigRecord,
RuntimeProfileWalletLedgerEntryRecord, RuntimeReferralInviteCenterRecord,
RuntimeReferralRedeemRecord, RuntimeSettingsRecord, RuntimeSnapshotRecord,
RuntimeTrackingScopeKind as DomainRuntimeTrackingScopeKind, build_analytics_metric_query_input,
@@ -234,7 +234,9 @@ use module_runtime::{
build_runtime_profile_task_config_admin_list_input,
build_runtime_profile_task_config_admin_upsert_input, build_runtime_profile_task_config_record,
build_runtime_profile_wallet_adjustment_input,
build_runtime_profile_wallet_ledger_entry_record,
build_runtime_profile_wallet_config_admin_get_input,
build_runtime_profile_wallet_config_admin_upsert_input,
build_runtime_profile_wallet_config_record, build_runtime_profile_wallet_ledger_entry_record,
build_runtime_profile_wallet_ledger_list_input, build_runtime_referral_invite_center_get_input,
build_runtime_referral_invite_center_record, build_runtime_referral_redeem_input,
build_runtime_referral_redeem_record, build_runtime_setting_get_input,
@@ -279,6 +279,7 @@ pub(crate) use self::runtime_profile::{
map_runtime_profile_task_config_admin_list_procedure_result,
map_runtime_profile_task_config_admin_procedure_result,
map_runtime_profile_wallet_adjustment_procedure_result,
map_runtime_profile_wallet_config_admin_procedure_result,
map_runtime_profile_wallet_ledger_procedure_result,
map_runtime_referral_invite_center_procedure_result,
map_runtime_referral_redeem_procedure_result,
@@ -18,6 +18,28 @@ impl From<module_runtime::RuntimeProfileWalletLedgerListInput>
}
}
impl From<module_runtime::RuntimeProfileWalletConfigAdminGetInput>
for RuntimeProfileWalletConfigAdminGetInput
{
fn from(input: module_runtime::RuntimeProfileWalletConfigAdminGetInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
}
}
}
impl From<module_runtime::RuntimeProfileWalletConfigAdminUpsertInput>
for RuntimeProfileWalletConfigAdminUpsertInput
{
fn from(input: module_runtime::RuntimeProfileWalletConfigAdminUpsertInput) -> Self {
Self {
admin_user_id: input.admin_user_id,
initial_mud_points: input.initial_mud_points,
updated_at_micros: input.updated_at_micros,
}
}
}
impl From<module_runtime::RuntimeProfileWalletAdjustmentInput>
for RuntimeProfileWalletAdjustmentInput
{
@@ -577,6 +599,22 @@ pub(crate) fn map_runtime_profile_task_config_admin_procedure_result(
))
}
pub(crate) fn map_runtime_profile_wallet_config_admin_procedure_result(
result: RuntimeProfileWalletConfigAdminProcedureResult,
) -> Result<RuntimeProfileWalletConfigRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::procedure_failed(result.error_message));
}
let snapshot = result
.record
.ok_or_else(|| SpacetimeClientError::missing_snapshot("profile wallet config 快照"))?;
Ok(build_runtime_profile_wallet_config_record(
map_runtime_profile_wallet_config_snapshot(snapshot),
))
}
pub(crate) fn map_runtime_profile_recharge_product_admin_list_procedure_result(
result: RuntimeProfileRechargeProductAdminListProcedureResult,
) -> Result<Vec<RuntimeProfileRechargeProductConfigRecord>, SpacetimeClientError> {
@@ -778,6 +816,19 @@ pub(crate) fn map_runtime_profile_wallet_ledger_entry_snapshot(
}
}
pub(crate) fn map_runtime_profile_wallet_config_snapshot(
snapshot: RuntimeProfileWalletConfigSnapshot,
) -> module_runtime::RuntimeProfileWalletConfigSnapshot {
module_runtime::RuntimeProfileWalletConfigSnapshot {
config_id: snapshot.config_id,
initial_mud_points: snapshot.initial_mud_points,
created_by: snapshot.created_by,
created_at_micros: snapshot.created_at_micros,
updated_by: snapshot.updated_by,
updated_at_micros: snapshot.updated_at_micros,
}
}
pub(crate) fn map_runtime_profile_recharge_center_snapshot(
snapshot: RuntimeProfileRechargeCenterSnapshot,
) -> module_runtime::RuntimeProfileRechargeCenterSnapshot {
@@ -10,6 +10,7 @@ pub mod accept_quest_reducer;
pub mod acknowledge_quest_completion_reducer;
pub mod admin_disable_profile_redeem_code_procedure;
pub mod admin_disable_profile_task_config_procedure;
pub mod admin_get_profile_wallet_config_procedure;
pub mod admin_list_profile_invite_codes_procedure;
pub mod admin_list_profile_recharge_products_procedure;
pub mod admin_list_profile_redeem_codes_procedure;
@@ -20,6 +21,7 @@ pub mod admin_upsert_profile_invite_code_procedure;
pub mod admin_upsert_profile_recharge_product_procedure;
pub mod admin_upsert_profile_redeem_code_procedure;
pub mod admin_upsert_profile_task_config_procedure;
pub mod admin_upsert_profile_wallet_config_procedure;
pub mod admin_work_visibility_list_input_type;
pub mod admin_work_visibility_list_procedure_result_type;
pub mod admin_work_visibility_procedure_result_type;
@@ -670,6 +672,8 @@ pub mod profile_task_progress_table;
pub mod profile_task_progress_type;
pub mod profile_task_reward_claim_table;
pub mod profile_task_reward_claim_type;
pub mod profile_wallet_config_table;
pub mod profile_wallet_config_type;
pub mod profile_wallet_ledger_table;
pub mod profile_wallet_ledger_type;
pub mod public_work_detail_entry_table;
@@ -975,6 +979,10 @@ pub mod runtime_profile_task_item_snapshot_type;
pub mod runtime_profile_task_status_type;
pub mod runtime_profile_wallet_adjustment_input_type;
pub mod runtime_profile_wallet_adjustment_procedure_result_type;
pub mod runtime_profile_wallet_config_admin_get_input_type;
pub mod runtime_profile_wallet_config_admin_procedure_result_type;
pub mod runtime_profile_wallet_config_admin_upsert_input_type;
pub mod runtime_profile_wallet_config_snapshot_type;
pub mod runtime_profile_wallet_ledger_entry_snapshot_type;
pub mod runtime_profile_wallet_ledger_list_input_type;
pub mod runtime_profile_wallet_ledger_procedure_result_type;
@@ -1219,6 +1227,7 @@ pub use accept_quest_reducer::accept_quest;
pub use acknowledge_quest_completion_reducer::acknowledge_quest_completion;
pub use admin_disable_profile_redeem_code_procedure::admin_disable_profile_redeem_code;
pub use admin_disable_profile_task_config_procedure::admin_disable_profile_task_config;
pub use admin_get_profile_wallet_config_procedure::admin_get_profile_wallet_config;
pub use admin_list_profile_invite_codes_procedure::admin_list_profile_invite_codes;
pub use admin_list_profile_recharge_products_procedure::admin_list_profile_recharge_products;
pub use admin_list_profile_redeem_codes_procedure::admin_list_profile_redeem_codes;
@@ -1229,6 +1238,7 @@ pub use admin_upsert_profile_invite_code_procedure::admin_upsert_profile_invite_
pub use admin_upsert_profile_recharge_product_procedure::admin_upsert_profile_recharge_product;
pub use admin_upsert_profile_redeem_code_procedure::admin_upsert_profile_redeem_code;
pub use admin_upsert_profile_task_config_procedure::admin_upsert_profile_task_config;
pub use admin_upsert_profile_wallet_config_procedure::admin_upsert_profile_wallet_config;
pub use admin_work_visibility_list_input_type::AdminWorkVisibilityListInput;
pub use admin_work_visibility_list_procedure_result_type::AdminWorkVisibilityListProcedureResult;
pub use admin_work_visibility_procedure_result_type::AdminWorkVisibilityProcedureResult;
@@ -1879,6 +1889,8 @@ pub use profile_task_progress_table::*;
pub use profile_task_progress_type::ProfileTaskProgress;
pub use profile_task_reward_claim_table::*;
pub use profile_task_reward_claim_type::ProfileTaskRewardClaim;
pub use profile_wallet_config_table::*;
pub use profile_wallet_config_type::ProfileWalletConfig;
pub use profile_wallet_ledger_table::*;
pub use profile_wallet_ledger_type::ProfileWalletLedger;
pub use public_work_detail_entry_table::*;
@@ -2184,6 +2196,10 @@ pub use runtime_profile_task_item_snapshot_type::RuntimeProfileTaskItemSnapshot;
pub use runtime_profile_task_status_type::RuntimeProfileTaskStatus;
pub use runtime_profile_wallet_adjustment_input_type::RuntimeProfileWalletAdjustmentInput;
pub use runtime_profile_wallet_adjustment_procedure_result_type::RuntimeProfileWalletAdjustmentProcedureResult;
pub use runtime_profile_wallet_config_admin_get_input_type::RuntimeProfileWalletConfigAdminGetInput;
pub use runtime_profile_wallet_config_admin_procedure_result_type::RuntimeProfileWalletConfigAdminProcedureResult;
pub use runtime_profile_wallet_config_admin_upsert_input_type::RuntimeProfileWalletConfigAdminUpsertInput;
pub use runtime_profile_wallet_config_snapshot_type::RuntimeProfileWalletConfigSnapshot;
pub use runtime_profile_wallet_ledger_entry_snapshot_type::RuntimeProfileWalletLedgerEntrySnapshot;
pub use runtime_profile_wallet_ledger_list_input_type::RuntimeProfileWalletLedgerListInput;
pub use runtime_profile_wallet_ledger_procedure_result_type::RuntimeProfileWalletLedgerProcedureResult;
@@ -2771,6 +2787,7 @@ pub struct DbUpdate {
profile_task_config: __sdk::TableUpdate<ProfileTaskConfig>,
profile_task_progress: __sdk::TableUpdate<ProfileTaskProgress>,
profile_task_reward_claim: __sdk::TableUpdate<ProfileTaskRewardClaim>,
profile_wallet_config: __sdk::TableUpdate<ProfileWalletConfig>,
profile_wallet_ledger: __sdk::TableUpdate<ProfileWalletLedger>,
public_work_detail_entry: __sdk::TableUpdate<PublicWorkDetailEntry>,
public_work_gallery_entry: __sdk::TableUpdate<PublicWorkGalleryEntry>,
@@ -3064,6 +3081,9 @@ impl TryFrom<__ws::v2::TransactionUpdate> for DbUpdate {
"profile_task_reward_claim" => db_update.profile_task_reward_claim.append(
profile_task_reward_claim_table::parse_table_update(table_update)?,
),
"profile_wallet_config" => db_update.profile_wallet_config.append(
profile_wallet_config_table::parse_table_update(table_update)?,
),
"profile_wallet_ledger" => db_update.profile_wallet_ledger.append(
profile_wallet_ledger_table::parse_table_update(table_update)?,
),
@@ -3612,6 +3632,12 @@ impl __sdk::DbUpdate for DbUpdate {
&self.profile_task_reward_claim,
)
.with_updates_by_pk(|row| &row.claim_id);
diff.profile_wallet_config = cache
.apply_diff_to_table::<ProfileWalletConfig>(
"profile_wallet_config",
&self.profile_wallet_config,
)
.with_updates_by_pk(|row| &row.config_id);
diff.profile_wallet_ledger = cache
.apply_diff_to_table::<ProfileWalletLedger>(
"profile_wallet_ledger",
@@ -4100,6 +4126,9 @@ impl __sdk::DbUpdate for DbUpdate {
"profile_task_reward_claim" => db_update
.profile_task_reward_claim
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"profile_wallet_config" => db_update
.profile_wallet_config
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"profile_wallet_ledger" => db_update
.profile_wallet_ledger
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
@@ -4488,6 +4517,9 @@ impl __sdk::DbUpdate for DbUpdate {
"profile_task_reward_claim" => db_update
.profile_task_reward_claim
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"profile_wallet_config" => db_update
.profile_wallet_config
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"profile_wallet_ledger" => db_update
.profile_wallet_ledger
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
@@ -4730,6 +4762,7 @@ pub struct AppliedDiff<'r> {
profile_task_config: __sdk::TableAppliedDiff<'r, ProfileTaskConfig>,
profile_task_progress: __sdk::TableAppliedDiff<'r, ProfileTaskProgress>,
profile_task_reward_claim: __sdk::TableAppliedDiff<'r, ProfileTaskRewardClaim>,
profile_wallet_config: __sdk::TableAppliedDiff<'r, ProfileWalletConfig>,
profile_wallet_ledger: __sdk::TableAppliedDiff<'r, ProfileWalletLedger>,
public_work_detail_entry: __sdk::TableAppliedDiff<'r, PublicWorkDetailEntry>,
public_work_gallery_entry: __sdk::TableAppliedDiff<'r, PublicWorkGalleryEntry>,
@@ -5157,6 +5190,11 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
&self.profile_task_reward_claim,
event,
);
callbacks.invoke_table_row_callbacks::<ProfileWalletConfig>(
"profile_wallet_config",
&self.profile_wallet_config,
event,
);
callbacks.invoke_table_row_callbacks::<ProfileWalletLedger>(
"profile_wallet_ledger",
&self.profile_wallet_ledger,
@@ -6134,6 +6172,7 @@ impl __sdk::SpacetimeModule for RemoteModule {
profile_task_config_table::register_table(client_cache);
profile_task_progress_table::register_table(client_cache);
profile_task_reward_claim_table::register_table(client_cache);
profile_wallet_config_table::register_table(client_cache);
profile_wallet_ledger_table::register_table(client_cache);
public_work_detail_entry_table::register_table(client_cache);
public_work_gallery_entry_table::register_table(client_cache);
@@ -6261,6 +6300,7 @@ impl __sdk::SpacetimeModule for RemoteModule {
"profile_task_config",
"profile_task_progress",
"profile_task_reward_claim",
"profile_wallet_config",
"profile_wallet_ledger",
"public_work_detail_entry",
"public_work_gallery_entry",
@@ -0,0 +1,59 @@
// 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};
use super::runtime_profile_wallet_config_admin_get_input_type::RuntimeProfileWalletConfigAdminGetInput;
use super::runtime_profile_wallet_config_admin_procedure_result_type::RuntimeProfileWalletConfigAdminProcedureResult;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
struct AdminGetProfileWalletConfigArgs {
pub input: RuntimeProfileWalletConfigAdminGetInput,
}
impl __sdk::InModule for AdminGetProfileWalletConfigArgs {
type Module = super::RemoteModule;
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the procedure `admin_get_profile_wallet_config`.
///
/// Implemented for [`super::RemoteProcedures`].
pub trait admin_get_profile_wallet_config {
fn admin_get_profile_wallet_config(&self, input: RuntimeProfileWalletConfigAdminGetInput) {
self.admin_get_profile_wallet_config_then(input, |_, _| {});
}
fn admin_get_profile_wallet_config_then(
&self,
input: RuntimeProfileWalletConfigAdminGetInput,
__callback: impl FnOnce(
&super::ProcedureEventContext,
Result<RuntimeProfileWalletConfigAdminProcedureResult, __sdk::InternalError>,
) + Send
+ 'static,
);
}
impl admin_get_profile_wallet_config for super::RemoteProcedures {
fn admin_get_profile_wallet_config_then(
&self,
input: RuntimeProfileWalletConfigAdminGetInput,
__callback: impl FnOnce(
&super::ProcedureEventContext,
Result<RuntimeProfileWalletConfigAdminProcedureResult, __sdk::InternalError>,
) + Send
+ 'static,
) {
self.imp
.invoke_procedure_with_callback::<_, RuntimeProfileWalletConfigAdminProcedureResult>(
"admin_get_profile_wallet_config",
AdminGetProfileWalletConfigArgs { input },
__callback,
);
}
}
@@ -0,0 +1,62 @@
// 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};
use super::runtime_profile_wallet_config_admin_procedure_result_type::RuntimeProfileWalletConfigAdminProcedureResult;
use super::runtime_profile_wallet_config_admin_upsert_input_type::RuntimeProfileWalletConfigAdminUpsertInput;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
struct AdminUpsertProfileWalletConfigArgs {
pub input: RuntimeProfileWalletConfigAdminUpsertInput,
}
impl __sdk::InModule for AdminUpsertProfileWalletConfigArgs {
type Module = super::RemoteModule;
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the procedure `admin_upsert_profile_wallet_config`.
///
/// Implemented for [`super::RemoteProcedures`].
pub trait admin_upsert_profile_wallet_config {
fn admin_upsert_profile_wallet_config(
&self,
input: RuntimeProfileWalletConfigAdminUpsertInput,
) {
self.admin_upsert_profile_wallet_config_then(input, |_, _| {});
}
fn admin_upsert_profile_wallet_config_then(
&self,
input: RuntimeProfileWalletConfigAdminUpsertInput,
__callback: impl FnOnce(
&super::ProcedureEventContext,
Result<RuntimeProfileWalletConfigAdminProcedureResult, __sdk::InternalError>,
) + Send
+ 'static,
);
}
impl admin_upsert_profile_wallet_config for super::RemoteProcedures {
fn admin_upsert_profile_wallet_config_then(
&self,
input: RuntimeProfileWalletConfigAdminUpsertInput,
__callback: impl FnOnce(
&super::ProcedureEventContext,
Result<RuntimeProfileWalletConfigAdminProcedureResult, __sdk::InternalError>,
) + Send
+ 'static,
) {
self.imp
.invoke_procedure_with_callback::<_, RuntimeProfileWalletConfigAdminProcedureResult>(
"admin_upsert_profile_wallet_config",
AdminUpsertProfileWalletConfigArgs { 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::profile_wallet_config_type::ProfileWalletConfig;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `profile_wallet_config`.
///
/// Obtain a handle from the [`ProfileWalletConfigTableAccess::profile_wallet_config`] method on [`super::RemoteTables`],
/// like `ctx.db.profile_wallet_config()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.profile_wallet_config().on_insert(...)`.
pub struct ProfileWalletConfigTableHandle<'ctx> {
imp: __sdk::TableHandle<ProfileWalletConfig>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `profile_wallet_config`.
///
/// Implemented for [`super::RemoteTables`].
pub trait ProfileWalletConfigTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`ProfileWalletConfigTableHandle`], which mediates access to the table `profile_wallet_config`.
fn profile_wallet_config(&self) -> ProfileWalletConfigTableHandle<'_>;
}
impl ProfileWalletConfigTableAccess for super::RemoteTables {
fn profile_wallet_config(&self) -> ProfileWalletConfigTableHandle<'_> {
ProfileWalletConfigTableHandle {
imp: self
.imp
.get_table::<ProfileWalletConfig>("profile_wallet_config"),
ctx: std::marker::PhantomData,
}
}
}
pub struct ProfileWalletConfigInsertCallbackId(__sdk::CallbackId);
pub struct ProfileWalletConfigDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for ProfileWalletConfigTableHandle<'ctx> {
type Row = ProfileWalletConfig;
type EventContext = super::EventContext;
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = ProfileWalletConfig> + '_ {
self.imp.iter()
}
type InsertCallbackId = ProfileWalletConfigInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> ProfileWalletConfigInsertCallbackId {
ProfileWalletConfigInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: ProfileWalletConfigInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = ProfileWalletConfigDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> ProfileWalletConfigDeleteCallbackId {
ProfileWalletConfigDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: ProfileWalletConfigDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
pub struct ProfileWalletConfigUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for ProfileWalletConfigTableHandle<'ctx> {
type UpdateCallbackId = ProfileWalletConfigUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> ProfileWalletConfigUpdateCallbackId {
ProfileWalletConfigUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: ProfileWalletConfigUpdateCallbackId) {
self.imp.remove_on_update(callback.0)
}
}
/// Access to the `config_id` unique index on the table `profile_wallet_config`,
/// which allows point queries on the field of the same name
/// via the [`ProfileWalletConfigConfigIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.profile_wallet_config().config_id().find(...)`.
pub struct ProfileWalletConfigConfigIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<ProfileWalletConfig, String>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> ProfileWalletConfigTableHandle<'ctx> {
/// Get a handle on the `config_id` unique index on the table `profile_wallet_config`.
pub fn config_id(&self) -> ProfileWalletConfigConfigIdUnique<'ctx> {
ProfileWalletConfigConfigIdUnique {
imp: self.imp.get_unique_constraint::<String>("config_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> ProfileWalletConfigConfigIdUnique<'ctx> {
/// Find the subscribed row whose `config_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<ProfileWalletConfig> {
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::<ProfileWalletConfig>("profile_wallet_config");
_table.add_unique_constraint::<String>("config_id", |row| &row.config_id);
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::v2::TableUpdate,
) -> __sdk::Result<__sdk::TableUpdate<ProfileWalletConfig>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse("TableUpdate<ProfileWalletConfig>", "TableUpdate")
.with_cause(e)
.into()
})
}
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `ProfileWalletConfig`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait profile_wallet_configQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `ProfileWalletConfig`.
fn profile_wallet_config(&self) -> __sdk::__query_builder::Table<ProfileWalletConfig>;
}
impl profile_wallet_configQueryTableAccess for __sdk::QueryTableAccessor {
fn profile_wallet_config(&self) -> __sdk::__query_builder::Table<ProfileWalletConfig> {
__sdk::__query_builder::Table::new("profile_wallet_config")
}
}
@@ -0,0 +1,64 @@
// 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 ProfileWalletConfig {
pub config_id: String,
pub initial_mud_points: u64,
pub created_by: String,
pub created_at: __sdk::Timestamp,
pub updated_by: String,
pub updated_at: __sdk::Timestamp,
}
impl __sdk::InModule for ProfileWalletConfig {
type Module = super::RemoteModule;
}
/// Column accessor struct for the table `ProfileWalletConfig`.
///
/// Provides typed access to columns for query building.
pub struct ProfileWalletConfigCols {
pub config_id: __sdk::__query_builder::Col<ProfileWalletConfig, String>,
pub initial_mud_points: __sdk::__query_builder::Col<ProfileWalletConfig, u64>,
pub created_by: __sdk::__query_builder::Col<ProfileWalletConfig, String>,
pub created_at: __sdk::__query_builder::Col<ProfileWalletConfig, __sdk::Timestamp>,
pub updated_by: __sdk::__query_builder::Col<ProfileWalletConfig, String>,
pub updated_at: __sdk::__query_builder::Col<ProfileWalletConfig, __sdk::Timestamp>,
}
impl __sdk::__query_builder::HasCols for ProfileWalletConfig {
type Cols = ProfileWalletConfigCols;
fn cols(table_name: &'static str) -> Self::Cols {
ProfileWalletConfigCols {
config_id: __sdk::__query_builder::Col::new(table_name, "config_id"),
initial_mud_points: __sdk::__query_builder::Col::new(table_name, "initial_mud_points"),
created_by: __sdk::__query_builder::Col::new(table_name, "created_by"),
created_at: __sdk::__query_builder::Col::new(table_name, "created_at"),
updated_by: __sdk::__query_builder::Col::new(table_name, "updated_by"),
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
}
}
}
/// Indexed column accessor struct for the table `ProfileWalletConfig`.
///
/// Provides typed access to indexed columns for query building.
pub struct ProfileWalletConfigIxCols {
pub config_id: __sdk::__query_builder::IxCol<ProfileWalletConfig, String>,
}
impl __sdk::__query_builder::HasIxCols for ProfileWalletConfig {
type IxCols = ProfileWalletConfigIxCols;
fn ix_cols(table_name: &'static str) -> Self::IxCols {
ProfileWalletConfigIxCols {
config_id: __sdk::__query_builder::IxCol::new(table_name, "config_id"),
}
}
}
impl __sdk::__query_builder::CanBeLookupTable for ProfileWalletConfig {}
@@ -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 RuntimeProfileWalletConfigAdminGetInput {
pub admin_user_id: String,
}
impl __sdk::InModule for RuntimeProfileWalletConfigAdminGetInput {
type Module = super::RemoteModule;
}
@@ -0,0 +1,19 @@
// 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};
use super::runtime_profile_wallet_config_snapshot_type::RuntimeProfileWalletConfigSnapshot;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct RuntimeProfileWalletConfigAdminProcedureResult {
pub ok: bool,
pub record: Option<RuntimeProfileWalletConfigSnapshot>,
pub error_message: Option<String>,
}
impl __sdk::InModule for RuntimeProfileWalletConfigAdminProcedureResult {
type Module = super::RemoteModule;
}

Some files were not shown because too many files have changed in this diff Show More