47 lines
8.9 KiB
JavaScript
47 lines
8.9 KiB
JavaScript
// Declarative masterkeys: the form reads these definitions; domain handlers own execution.
|
|
const field=(name,label,type='text',extra={})=>({name,label,type,required:true,...extra});
|
|
export const STAFF_KEY_FIELDS=Object.freeze([{name:'ticketId',label:'Ban / support ticket ID',type:'text',required:true,maxLength:80}]);
|
|
const action=(id,label,keyType,fields,extra={})=>({id,label,keyType,fields:[...STAFF_KEY_FIELDS,...fields],version:1,...extra});
|
|
const reference=field('reference','Reason / decision reference','text',{required:false});
|
|
export const MASTER_KEY_TEMPLATES=[
|
|
{id:'clan',label:'Clan',actions:[
|
|
action('clan.clear-protected-rosters','Clear protected clan rosters','clan-administration',[reference],{webIssue:true,permission:'web.jarvis.clans.reset',effect:'Remove members and owner from Vaerkring and Veiled Concord. Preserve clans, claims, POL and Crysknife.',fixedTargets:['Vaerkring','Veiled Concord']}),
|
|
action('clan.original','Original clan charter','clan-founding',[]),
|
|
action('clan.subhouse','Subhouse founding','clan-subhouse',[field('parentClanId','Mother clan'),field('recipient','Recipient')])]},
|
|
{id:'company',label:'Company',actions:[
|
|
action('company.original','Original company charter','company-founding',[]),
|
|
action('company.subsidiary','Subsidiary founding','company-subsidiary',[field('parentCompanyId','Mother company'),field('recipient','Recipient')]),
|
|
action('company.royal','Royal company charter','staff-company-royal',[field('companyId','Company'),reference])]},
|
|
{id:'politics',label:'POL & orders',actions:[
|
|
action('politics.rebellion','Declare open rebellion','quest',[field('clanId','Attacking clan'),field('officeKey','Elected office'),field('expectedTermId','Current office deed'),field('expectedHomeBlockId','Incumbent Home Block')],{webIssue:false,domainAdapter:'rebellionQuests.declare',executionStatus:'clan-leader-decision',effect:'Start a clan quest at any time. A verified game capture key transfers only the remaining office term. Rewards are limited once per clan, office and season.'}),
|
|
action('clan.homeblock-victory','Verified rebellion Home Block victory','quest-milestone',[field('questKeyId','Declared rebellion key'),field('eventId','Verified game capture event')],{webIssue:false,recordOnly:true,domainAdapter:'rebellionQuests.recordCapture',executionStatus:'trusted-game-producer-only',effect:'Signed game evidence consumed by the existing rebellion quest. No browser victory or Minecraft producer is included.'}),
|
|
action('politics.passive-order','Protected passive Order charter','staff-parent-link',[reference],{domainAdapter:'ensureCrysknifePassiveOrder',fixedTargets:['Order of the Crysknife','Emperor'],effect:'Convert the protected honorary Order to passive POL membership, retaining fixed memorial leadership, private boards and civic records. Mother authority is limited to MOTD and account.'}),
|
|
action('politics.appoint','Political appointment','political-appointment',[field('office','Office'),field('recipient','Recipient'),field('role','Role'),field('expiresAt','Term end','datetime-local'),reference]),
|
|
action('politics.membership','Office deed membership','political-clan',[field('termId','Office term'),field('recipient','Recipient')]),
|
|
action('politics.royal','Protected office charter','staff-office-royal',[field('office','Office'),reference])]},
|
|
{id:'relations',label:'Deeds & relations',actions:[
|
|
action('relations.parent','Protected parent relation','staff-parent-link',[field('childId','Child organisation'),field('parentId','Mother organisation'),reference]),
|
|
action('relations.transfer','Entity transfer','entity-transfer',[field('entityId','Organisation'),field('kind','Organisation type'),field('version','Current deed version','number',{min:1}),field('priceMinor','Offer price in DM minor units','number',{min:1}),field('recipient','New controller','text',{required:false}),reference],{domainAdapter:'deedPurchases',executionStatus:'dedicated-deed-checkout',effect:'Publish an ordinary clan/company XFR deed offer through Patronage. Recipient remains unset until a confirmed Exchange purchase; the existing bank window applies parent-deed control and payment. Publication changes no ownership.'})]},
|
|
{id:'economy',label:'Economy',actions:[action('economy.snapshot','Sealed economic snapshot','economy-snapshot',[field('snapshotId','Verified snapshot'),reference],{recordOnly:true})]},
|
|
{id:'state',label:'Entity state',actions:[action('state.estate-freeze','Freeze estate from lore-death ESK','entity-state',[field('keyId','Verified lore-death ESK'),reference],{domainAdapter:'PostbankEstates.freeze',executionStatus:'bank-staff-consumer',effect:'Restrict existing personal accounts using a verified lore-death ESK; no balance changes.'}),action('state.estate-unlock','Unlock ESK estate','entity-state',[field('keyId','Existing ESK'),field('revision','Current bank effect revision','number',{min:1}),reference],{domainAdapter:'PostbankEstates.unlock',executionStatus:'bank-staff-consumer',effect:'Bank staff restore only the accounts held by the named ESK. Original death evidence remains unchanged.'}),action('state.record','Entity State Key','entity-state',[field('eventId','Unique source event ID'),field('action','State event'),field('targetUuid','Target entity UUID'),field('targetKind','Player or mob'),field('entityType','Entity type'),field('actorUuid','Killer / actor UUID','text',{required:false}),field('cause','Cause / reason'),field('scope','Server / lore scope'),field('world','World'),field('occurredAt','Event timestamp','number',{min:0}),reference],{recordOnly:true,domainAdapter:'entityStateKeys',executionStatus:'verified-service-record',artwork:'esk-key-v1.png',effect:'Record a verified death, respawn, ban or unban. Shared quest/contract/deed evidence with separate once-only consumer receipts. No Minecraft producer or ban migration in this batch.'})]},
|
|
{id:'progression',label:'Progression & XP',actions:[
|
|
action('xp.correct','Approved XP correction','xp-correction',[field('recipient','Recipient'),field('amountXP','XP amount','number',{min:1}),field('caseReference','Approved support case')]),
|
|
action('xp.transfer','Season XP transfer','xp-transfer',[field('recipient','Recipient'),field('fromSeason','Source season'),field('toSeason','Target season')]),
|
|
action('quest.instrument','Quest instrument','quest',[field('questId','Quest'),field('season','Season'),field('recipient','Recipient')]),
|
|
action('quest.milestone','Sealed milestone','quest-milestone',[field('questId','Milestone'),field('season','Season')],{recordOnly:true}),
|
|
action('progression.policy','Season progression policy','progression-policy',[field('season','Season'),field('policyVersion','Policy version','number',{min:1})])]},
|
|
{id:'projects',label:'Server projects',actions:[action('projects.action','Project decision','project-action',[field('projectId','Project'),field('decision','Decision'),reference])]},
|
|
{id:'news',label:'Gazette',actions:[action('news.record','Confirmed public announcement','gazette-news',[field('sourceId','Confirmed source event'),reference],{recordOnly:true})]},
|
|
{id:'accounts',label:'Accounts',actions:[
|
|
action('accounts.system-character','Provision fictional system character','system-identity',[field('characterKey','Approved character'),reference],{recordOnly:true,domainAdapter:'systemCharacters',executionStatus:'operator-service-only',effect:'Create a non-login system identity with a synthetic UUID and scoped quest capabilities. No staff, player, voting, payroll or AD visibility rights.'}),
|
|
action('accounts.test-minecraft-identity','Assign a synthetic test Minecraft UUID','account-test-identity',[field('accountName','Target account name'),reference],{webIssue:true,permission:'web.jarvis.accounts.test-identity',effect:'Generate and assign one synthetic test UUID to the named unlinked account. Never overwrites a game link or pending link challenge. This is not proof of Minecraft ownership.'})]},
|
|
{id:'items',label:'Items & kits',actions:[]},
|
|
{id:'events',label:'Events',actions:[]},
|
|
{id:'rihla',label:'Rihla',actions:[]}
|
|
];
|
|
export function masterAction(id){for(const template of MASTER_KEY_TEMPLATES){const action=template.actions.find(a=>a.id===id);if(action)return{...action,templateId:template.id};}return null;}
|
|
export function validateMasterFields(action,values){
|
|
if(!action||!values||typeof values!=='object'||Array.isArray(values))throw TypeError('Invalid masterkey fields');
|
|
const allowed=new Set(action.fields.map(f=>f.name));if(Object.keys(values).some(k=>!allowed.has(k)))throw TypeError('Unknown masterkey field');
|
|
const result={};for(const f of action.fields){let v=values[f.name];if(f.required&&(v===undefined||v===null||v===''))throw TypeError(f.label+' is required');if(v===undefined)continue;if(f.type==='number'){if(!Number.isSafeInteger(v)||v<(f.min??0))throw TypeError('Invalid '+f.label);}else if(typeof v!=='string'||v.length>(f.maxLength||240)||/[\x00-\x1f\x7f]/.test(v))throw TypeError('Invalid '+f.label);result[f.name]=typeof v==='string'?v.trim():v;if(f.required&&result[f.name]==='')throw TypeError(f.label+' is required');}return result;
|
|
}
|

Staff