@ atcute/ 分区
臭氧 (tools.ozone.*) 计划定义
npm install @atcute/ozone
使用量
import { is, type $type } from '@atcute/lexicons';
import { ToolsOzoneModerationDefs } from '@atcute/ozone';
type LabelEvent = $type.enforce<ToolsOzoneModerationDefs.ModEventLabel>;
const evt: LabelEvent = {
$type: 'tools.ozone.moderation.defs#modEventLabel',
createLabelVals: ['awesome'],
negateLabelVals: [],
};
is(ToolsOzoneModerationDefs.modEventLabelSchema, evt);
// -> true
与 @atcute/client
选择这3个选项之一来登记环境声明
// tsconfig.json
{
"compilerOptions": {
"types": ["@atcute/ozone"],
},
}
// env.d.ts
/// <reference types="@atcute/ozone" />
// index.ts
import type {} from '@atcute/ozone';
现在所有 XRPC 操作都应该在客户端可见
import { Client, simpleFetchHandler } from '@atcute/client';
const client = new Client({
handler: simpleFetchHandler({ service: 'https://mod.example.com' }),
});
const response = await client.post('tools.ozone.moderation.emitEvent', {
input: {
createdBy: 'did:plc:ia76kvnndjutgedggx2ibrem',
subject: {
$type: 'com.atproto.repo.strongRef',
uri: 'at://did:plc:ia76kvnndjutgedggx2ibrem/app.bsky.feed.post/3l6uo5yecnsu7',
cid: 'bafyreibluyqpqno2ixrhdkztquyarpug7k6t4en6ug7g3sw6fonzzmakbq',
},
event: {
$type: 'tools.ozone.moderation.defs#modEventLabel',
createLabelVals: ['awesome'],
negateLabelVals: [],
},
},
});
// ...
与 @atcute/lex-cli
创建参考臭氧类型的词汇表时,请配置 lex-cli 从此导入 软件包 :
// file: lex.config.js
import { defineLexiconConfig } from '@atcute/lex-cli';
export default defineLexiconConfig({
files: ['lexicons/**/*.json'],
outdir: 'src/lexicons/',
imports: ['@atcute/ozone'],
});