Forráskód Böngészése

Merge pull request #823 from Lezek123/nicaea-types-2nd-update

Nicaea types 2nd update
Mokhtar Naamani 4 éve
szülő
commit
4c5d7dcc09

+ 14 - 13
cli/src/Api.ts

@@ -12,13 +12,12 @@ import {
     AccountSummary,
     CouncilInfoObj, CouncilInfoTuple, createCouncilInfoObj,
     WorkingGroups,
-    GroupLeadWithProfile,
     GroupMember,
 } from './Types';
 import { DerivedFees, DerivedBalances } from '@polkadot/api-derive/types';
 import { CLIError } from '@oclif/errors';
 import ExitCodes from './ExitCodes';
-import { Worker, Lead as WorkerLead, WorkerId, WorkerRoleStakeProfile } from '@joystream/types/working-group';
+import { Worker, WorkerId, RoleStakeProfile } from '@joystream/types/working-group';
 import { MemberId, Profile } from '@joystream/types/members';
 import { RewardRelationship, RewardRelationshipId } from '@joystream/types/recurring-rewards';
 import { Stake, StakeId } from '@joystream/types/stake';
@@ -166,21 +165,23 @@ export default class Api {
         return profile.unwrapOr(null);
     }
 
-    async groupLead (group: WorkingGroups): Promise <GroupLeadWithProfile | null> {
-        const optLead = (await this.workingGroupApiQuery(group).currentLead()) as Option<WorkerLead>;
+    async groupLead(group: WorkingGroups): Promise<GroupMember | null> {
+        const optLeadId = (await this.workingGroupApiQuery(group).currentLead()) as Option<WorkerId>;
 
-        if (!optLead.isSome) {
-          return null;
+        if (!optLeadId.isSome) {
+            return null;
         }
 
-        const lead = optLead.unwrap();
-        const profile = await this.memberProfileById(lead.member_id);
+        const leadWorkerId = optLeadId.unwrap();
+        const leadWorker = this.singleLinkageResult<Worker>(
+            await this.workingGroupApiQuery(group).workerById(leadWorkerId) as LinkageResult
+        );
 
-        if (!profile) {
-            throw new Error(`Group lead profile not found! (member id: ${lead.member_id.toNumber()})`);
+        if (!leadWorker.is_active) {
+            return null;
         }
 
-        return { lead, profile };
+        return await this.groupMember(leadWorkerId, leadWorker);
     }
 
     protected async stakeValue (stakeId: StakeId): Promise<Balance> {
@@ -188,7 +189,7 @@ export default class Api {
         return stake.value;
     }
 
-    protected async workerStake (stakeProfile: WorkerRoleStakeProfile): Promise<Balance> {
+    protected async workerStake (stakeProfile: RoleStakeProfile): Promise<Balance> {
         return this.stakeValue(stakeProfile.stake_id);
     }
 
@@ -203,7 +204,7 @@ export default class Api {
         id: WorkerId,
         worker: Worker
       ): Promise<GroupMember> {
-        const roleAccount = worker.role_account;
+        const roleAccount = worker.role_account_id;
         const memberId = worker.member_id;
 
         const profile = await this.memberProfileById(memberId);

+ 1 - 6
cli/src/Types.ts

@@ -4,7 +4,7 @@ import { Option } from '@polkadot/types';
 import { BlockNumber, Balance, AccountId } from '@polkadot/types/interfaces';
 import { DerivedBalances } from '@polkadot/api-derive/types';
 import { KeyringPair } from '@polkadot/keyring/types';
-import { WorkerId, Lead } from '@joystream/types/working-group';
+import { WorkerId } from '@joystream/types/working-group';
 import { Profile, MemberId } from '@joystream/types/members';
 
 // KeyringPair type extended with mandatory "meta.name"
@@ -75,11 +75,6 @@ export const AvailableGroups: readonly WorkingGroups[] = [
 ] as const;
 
 // Compound working group types
-export type GroupLeadWithProfile = {
-    lead: Lead;
-    profile: Profile;
-}
-
 export type GroupMember = {
     workerId: WorkerId;
     memberId: MemberId;

+ 3 - 3
cli/src/base/WorkingGroupsCommandBase.ts

@@ -1,7 +1,7 @@
 import ExitCodes from '../ExitCodes';
 import AccountsCommandBase from './AccountsCommandBase';
 import { flags } from '@oclif/command';
-import { WorkingGroups, AvailableGroups, NamedKeyringPair, GroupLeadWithProfile, GroupMember } from '../Types';
+import { WorkingGroups, AvailableGroups, NamedKeyringPair, GroupMember } from '../Types';
 import { CLIError } from '@oclif/errors';
 import inquirer from 'inquirer';
 
@@ -25,11 +25,11 @@ export default abstract class WorkingGroupsCommandBase extends AccountsCommandBa
     };
 
     // Use when lead access is required in given command
-    async getRequiredLead(): Promise<GroupLeadWithProfile> {
+    async getRequiredLead(): Promise<GroupMember> {
         let selectedAccount: NamedKeyringPair = await this.getRequiredSelectedAccount();
         let lead = await this.getApi().groupLead(this.group);
 
-        if (!lead || lead.lead.role_account_id.toString() !== selectedAccount.address) {
+        if (!lead || lead.roleAccount.toString() !== selectedAccount.address) {
             this.error('Lead access required for this command!', { exit: ExitCodes.AccessDenied });
         }
 

+ 2 - 2
cli/src/commands/working-groups/overview.ts

@@ -16,9 +16,9 @@ export default class WorkingGroupsOverview extends WorkingGroupsCommandBase {
         displayHeader('Group lead');
         if (lead) {
             displayNameValueTable([
-                { name: 'Member id:', value: lead.lead.member_id.toString() },
+                { name: 'Member id:', value: lead.memberId.toString() },
                 { name: 'Member handle:', value: lead.profile.handle.toString() },
-                { name: 'Role account:', value: lead.lead.role_account_id.toString() },
+                { name: 'Role account:', value: lead.roleAccount.toString() },
             ]);
         }
         else {

+ 35 - 25
pioneer/packages/joy-roles/src/transport.substrate.ts

@@ -24,14 +24,13 @@ import {
 } from '@joystream/types/content-working-group';
 
 import {
-  WorkerApplication, WorkerApplicationId,
-  WorkerOpening, WorkerOpeningId,
+  Application as WGApplication,
+  Opening as WGOpening,
   Worker, WorkerId,
-  WorkerRoleStakeProfile,
-  Lead as LeadOf
+  RoleStakeProfile
 } from '@joystream/types/working-group';
 
-import { Application, Opening, OpeningId } from '@joystream/types/hiring';
+import { Application, Opening, OpeningId, ApplicationId } from '@joystream/types/hiring';
 import { Stake, StakeId } from '@joystream/types/stake';
 import { RewardRelationship, RewardRelationshipId } from '@joystream/types/recurring-rewards';
 import { ActorInRole, Profile, MemberId, Role, RoleKeys, ActorId } from '@joystream/types/members';
@@ -72,14 +71,14 @@ type WGApiMethodType =
   | 'workerById';
 type WGApiMethodsMapping = { [key in WGApiMethodType]: string };
 
-type GroupApplication = CuratorApplication | WorkerApplication;
-type GroupApplicationId = CuratorApplicationId | WorkerApplicationId;
-type GroupOpening = CuratorOpening | WorkerOpening;
-type GroupOpeningId = CuratorOpeningId | WorkerOpeningId;
+type GroupApplication = CuratorApplication | WGApplication;
+type GroupApplicationId = CuratorApplicationId | ApplicationId;
+type GroupOpening = CuratorOpening | WGOpening;
+type GroupOpeningId = CuratorOpeningId | OpeningId;
 type GroupWorker = Worker | Curator;
 type GroupWorkerId = CuratorId | WorkerId;
-type GroupWorkerStakeProfile = WorkerRoleStakeProfile | CuratorRoleStakeProfile;
-type GroupLead = Lead | LeadOf;
+type GroupWorkerStakeProfile = RoleStakeProfile | CuratorRoleStakeProfile;
+type GroupLead = Lead | Worker;
 type GroupLeadWithMemberId = {
   lead: GroupLead;
   memberId: MemberId;
@@ -99,15 +98,15 @@ const workingGroupsApiMapping: WGApiMapping = {
   [WorkingGroups.StorageProviders]: {
     module: 'storageWorkingGroup',
     methods: {
-      nextOpeningId: 'nextWorkerOpeningId',
-      openingById: 'workerOpeningById',
-      nextApplicationId: 'nextWorkerApplicationId',
-      applicationById: 'workerApplicationById',
+      nextOpeningId: 'nextOpeningId',
+      openingById: 'openingById',
+      nextApplicationId: 'nextApplicationId',
+      applicationById: 'applicationById',
       nextWorkerId: 'nextWorkerId',
       workerById: 'workerById'
     },
-    openingType: WorkerOpening,
-    applicationType: WorkerApplication,
+    openingType: WGOpening,
+    applicationType: WGApplication,
     workerType: Worker
   },
   [WorkingGroups.ContentCurators]: {
@@ -210,7 +209,7 @@ export class Transport extends TransportBase implements ITransport {
     id: GroupWorkerId,
     worker: GroupWorker
   ): Promise<GroupMember> {
-    const roleAccount = worker.role_account;
+    const roleAccount = worker.role_account_id;
     const memberId = group === WorkingGroups.ContentCurators
       ? await this.memberIdFromCuratorId(id)
       : (worker as Worker).member_id;
@@ -255,7 +254,7 @@ export class Transport extends TransportBase implements ITransport {
     );
 
     for (let i = 0; i < groupOpenings.linked_values.length; i++) {
-      const opening = await this.opening(groupOpenings.linked_values[i].opening_id.toNumber());
+      const opening = await this.opening(groupOpenings.linked_values[i].hiring_opening_id.toNumber());
       if (opening.is_active) {
         return true;
       }
@@ -291,15 +290,26 @@ export class Transport extends TransportBase implements ITransport {
   }
 
   protected async currentStorageLead (): Promise <GroupLeadWithMemberId | null> {
-    const optLead = (await this.cachedApi.query.storageWorkingGroup.currentLead()) as Option<LeadOf>;
+    const optLeadId = (await this.cachedApi.query.storageWorkingGroup.currentLead()) as Option<WorkerId>;
 
-    if (!optLead.isSome) {
+    if (!optLeadId.isSome) {
+      return null;
+    }
+
+    const leadWorkerId = optLeadId.unwrap();
+    const leadWorkerLink = new SingleLinkedMapEntry(
+      Worker,
+      await this.cachedApi.query.storageWorkingGroup.workerById(leadWorkerId)
+    );
+    const leadWorker = leadWorkerLink.value;
+
+    if (!leadWorker.is_active) {
       return null;
     }
 
     return {
-      lead: optLead.unwrap(),
-      memberId: optLead.unwrap().member_id
+      lead: leadWorker,
+      memberId: leadWorker.member_id
     };
   }
 
@@ -415,7 +425,7 @@ export class Transport extends TransportBase implements ITransport {
         await this.cachedApiMethodByGroup(group, 'applicationById')(i)
       );
 
-      if (cApplication.value.worker_opening_id.toNumber() !== groupOpeningId) {
+      if (cApplication.value.opening_id.toNumber() !== groupOpeningId) {
         continue;
       }
 
@@ -454,7 +464,7 @@ export class Transport extends TransportBase implements ITransport {
     );
 
     const opening = await this.opening(
-      groupOpening.value.opening_id.toNumber()
+      groupOpening.value.hiring_opening_id.toNumber()
     );
 
     const applications = await this.groupOpeningApplications(group, id);

+ 16 - 1
types/src/content-working-group/index.ts

@@ -245,6 +245,11 @@ export class Curator extends JoyStruct<ICurator> {
     return this.getField<GenericAccountId>('role_account')
   }
 
+  // Helper for working-group compatibility
+  get role_account_id(): GenericAccountId {
+    return this.role_account;
+  }
+
   get reward_relationship(): Option<RewardRelationshipId> {
     return this.getField<Option<RewardRelationshipId>>('reward_relationship')
   }
@@ -290,12 +295,17 @@ export class CuratorApplication extends JoyStruct<ICuratorApplication> {
     return this.getField<GenericAccountId>('role_account')
   }
 
+  // Helper for working-group compatibility
+  get role_account_id(): GenericAccountId {
+    return this.role_account;
+  }
+
   get curator_opening_id(): CuratorOpeningId {
     return this.getField<CuratorOpeningId>('curator_opening_id')
   }
 
   // Helper for working-group compatibility
-  get worker_opening_id(): CuratorOpeningId {
+  get opening_id(): CuratorOpeningId {
     return this.curator_opening_id;
   }
 
@@ -431,6 +441,11 @@ export class CuratorOpening extends JoyStruct<ICuratorOpening> {
   get opening_id(): OpeningId {
     return this.getField<OpeningId>('opening_id')
   }
+
+  // Helper for working-group compatibility
+  get hiring_opening_id(): OpeningId {
+    return this.opening_id;
+  }
 };
 
 export type IExitedLeadRole = {

+ 89 - 91
types/src/working-group/index.ts

@@ -7,60 +7,34 @@ import { RewardRelationshipId } from '../recurring-rewards';
 import { StakeId } from '../stake';
 import { ApplicationId, OpeningId, ApplicationRationingPolicy, StakingPolicy } from '../hiring';
 
-export type ILead = {
-  member_id: MemberId,
-  role_account_id: AccountId
-};
-
-// This type is also defined in /content-workig-group (and those are incosistent), but here
-// it is beeing registered as "LeadOf" (which is an alias used by the runtime working-group module),
-// so it shouldn't cause any conflicts)
-export class Lead extends JoyStruct<ILead> {
-  constructor (value?: ILead) {
-    super({
-      member_id: MemberId,
-      role_account_id: "AccountId"
-    }, value);
-  }
-
-  get member_id(): MemberId {
-    return this.getField<MemberId>('member_id')
-  }
-
-  get role_account_id(): AccountId {
-    return this.getField<AccountId>('role_account_id')
-  }
-};
-
-export class WorkerApplicationId extends ApplicationId { };
-
-export class WorkerOpeningId extends OpeningId { };
-
 export class RationaleText extends Bytes { };
 
-export type IWorkerApplication = {
-  role_account: AccountId,
-  worker_opening_id: WorkerOpeningId,
+export type IApplication = {
+  role_account_id: AccountId,
+  opening_id: OpeningId,
   member_id: MemberId,
   application_id: ApplicationId
 };
 
-export class WorkerApplication extends JoyStruct<IWorkerApplication> {
-  constructor (value?: IWorkerApplication) {
+// This type is also defined in /hiring (and those are incosistent), but here
+// it is beeing registered as "ApplicationOf" (which is an alias used by the runtime working-group module),
+// so it shouldn't cause any conflicts
+export class Application extends JoyStruct<IApplication> {
+  constructor (value?: IApplication) {
     super({
-      role_account: "AccountId",
-      worker_opening_id: WorkerOpeningId,
+      role_account_id: "AccountId",
+      opening_id: OpeningId,
       member_id: MemberId,
       application_id: ApplicationId
     }, value);
   }
 
-  get role_account(): AccountId {
-    return this.getField<AccountId>('role_account');
+  get role_account_id(): AccountId {
+    return this.getField<AccountId>('role_account_id');
   }
 
-  get worker_opening_id(): WorkerOpeningId {
-    return this.getField<WorkerOpeningId>('worker_opening_id');
+  get opening_id(): OpeningId {
+    return this.getField<OpeningId>('opening_id');
   }
 
   get member_id(): MemberId {
@@ -76,19 +50,19 @@ export class WorkerId extends ActorId { };
 
 export class StorageProviderId extends WorkerId { };
 
-export class WorkerApplicationIdSet extends BTreeSet.with(WorkerApplicationId) { };
+export class ApplicationIdSet extends BTreeSet.with(ApplicationId) { };
 
-export class WorkerApplicationIdToWorkerIdMap extends BTreeMap.with(WorkerApplicationId, WorkerId) { };
+export class ApplicationIdToWorkerIdMap extends BTreeMap.with(ApplicationId, WorkerId) { };
 
 
-export type IWorkerRoleStakeProfile = {
+export type IRoleStakeProfile = {
   stake_id: StakeId,
   termination_unstaking_period: Option<BlockNumber>,
   exit_unstaking_period: Option<BlockNumber>,
 };
 
-export class WorkerRoleStakeProfile extends JoyStruct<IWorkerRoleStakeProfile> {
-  constructor (value?: IWorkerRoleStakeProfile) {
+export class RoleStakeProfile extends JoyStruct<IRoleStakeProfile> {
+  constructor (value?: IRoleStakeProfile) {
     super({
       stake_id: StakeId,
       termination_unstaking_period: "Option<BlockNumber>",
@@ -111,18 +85,18 @@ export class WorkerRoleStakeProfile extends JoyStruct<IWorkerRoleStakeProfile> {
 
 export type IWorker = {
   member_id: MemberId,
-  role_account: AccountId,
+  role_account_id: AccountId,
   reward_relationship: Option<RewardRelationshipId>,
-  role_stake_profile: Option<WorkerRoleStakeProfile>,
+  role_stake_profile: Option<RoleStakeProfile>,
 }
 
 export class Worker extends JoyStruct<IWorker> {
   constructor (value?: IWorker) {
     super({
       member_id: MemberId,
-      role_account: "AccountId",
+      role_account_id: "AccountId",
       reward_relationship: Option.with(RewardRelationshipId),
-      role_stake_profile: Option.with(WorkerRoleStakeProfile),
+      role_stake_profile: Option.with(RoleStakeProfile),
     }, value);
   }
 
@@ -130,16 +104,16 @@ export class Worker extends JoyStruct<IWorker> {
     return this.getField<MemberId>('member_id');
   }
 
-  get role_account(): AccountId {
-    return this.getField<AccountId>('role_account');
+  get role_account_id(): AccountId {
+    return this.getField<AccountId>('role_account_id');
   }
 
   get reward_relationship(): Option<RewardRelationshipId> {
     return this.getField<Option<RewardRelationshipId>>('reward_relationship');
   }
 
-  get role_stake_profile(): Option<WorkerRoleStakeProfile> {
-    return this.getField<Option<WorkerRoleStakeProfile>>('role_stake_profile');
+  get role_stake_profile(): Option<RoleStakeProfile> {
+    return this.getField<Option<RoleStakeProfile>>('role_stake_profile');
   }
 
   get is_active(): boolean {
@@ -185,20 +159,20 @@ export type IWorkingGroupOpeningPolicyCommitment = {
   fill_opening_successful_applicant_application_stake_unstaking_period: Option<BlockNumber>,
   fill_opening_failed_applicant_application_stake_unstaking_period: Option<BlockNumber>,
   fill_opening_failed_applicant_role_stake_unstaking_period: Option<BlockNumber>,
-  terminate_worker_application_stake_unstaking_period: Option<BlockNumber>,
-  terminate_worker_role_stake_unstaking_period: Option<BlockNumber>,
-  exit_worker_role_application_stake_unstaking_period: Option<BlockNumber>,
-  exit_worker_role_stake_unstaking_period: Option<BlockNumber>,
+  terminate_application_stake_unstaking_period: Option<BlockNumber>,
+  terminate_role_stake_unstaking_period: Option<BlockNumber>,
+  exit_role_application_stake_unstaking_period: Option<BlockNumber>,
+  exit_role_stake_unstaking_period: Option<BlockNumber>,
 };
 
 // This type represents OpeningPolicyCommitment defined inside the runtime's working-grpup module.
 // The only difference between this and the one defined in /content-working-group is in the names of some fields.
 //
 // There is also a minor issue here:
-// Because api metadata still says that ie. the "commitment" argument of "storageWorkingGroup.addWorkerOpening" extrinsic
+// Because api metadata still says that ie. the "commitment" argument of "storageWorkingGroup.addOpening" extrinsic
 // is of type "OpeningPolicyCommitment" (not the "WorkingGroupOpeningPolicyCommitment" defined here), the CWG's OpeningPolicyCommitment
 // type is used when sending this extrinsic (it has "terminate_curator_role_stake_unstaking_period" field insted
-// of "terminate_worker_role_stake_unstaking_period" etc.).
+// of "terminate_role_stake_unstaking_period" etc.).
 // Since both those types are basically the same structs (only filed names are different) nothing seems to break, but it's
 // very fragile atm and any change to this type in working-group module could result in "unsolvable" inconsistencies
 // (this won't be an issue after CWG gets refactored to use the working-grpup module too)
@@ -213,10 +187,10 @@ export class WorkingGroupOpeningPolicyCommitment extends JoyStruct<IWorkingGroup
       fill_opening_successful_applicant_application_stake_unstaking_period: "Option<BlockNumber>",
       fill_opening_failed_applicant_application_stake_unstaking_period: "Option<BlockNumber>",
       fill_opening_failed_applicant_role_stake_unstaking_period: "Option<BlockNumber>",
-      terminate_worker_application_stake_unstaking_period: "Option<BlockNumber>",
-      terminate_worker_role_stake_unstaking_period: "Option<BlockNumber>",
-      exit_worker_role_application_stake_unstaking_period: "Option<BlockNumber>",
-      exit_worker_role_stake_unstaking_period: "Option<BlockNumber>",
+      terminate_application_stake_unstaking_period: "Option<BlockNumber>",
+      terminate_role_stake_unstaking_period: "Option<BlockNumber>",
+      exit_role_application_stake_unstaking_period: "Option<BlockNumber>",
+      exit_role_stake_unstaking_period: "Option<BlockNumber>",
     }, value);
   }
 
@@ -252,67 +226,91 @@ export class WorkingGroupOpeningPolicyCommitment extends JoyStruct<IWorkingGroup
     return this.getField<Option<BlockNumber>>('fill_opening_failed_applicant_role_stake_unstaking_period')
   }
 
-  get terminate_worker_application_stake_unstaking_period(): Option<BlockNumber> {
-    return this.getField<Option<BlockNumber>>('terminate_worker_application_stake_unstaking_period')
+  get terminate_application_stake_unstaking_period(): Option<BlockNumber> {
+    return this.getField<Option<BlockNumber>>('terminate_application_stake_unstaking_period')
   }
 
-  get terminate_worker_role_stake_unstaking_period(): Option<BlockNumber> {
-    return this.getField<Option<BlockNumber>>('terminate_worker_role_stake_unstaking_period')
+  get terminate_role_stake_unstaking_period(): Option<BlockNumber> {
+    return this.getField<Option<BlockNumber>>('terminate_role_stake_unstaking_period')
   }
 
-  get exit_worker_role_application_stake_unstaking_period(): Option<BlockNumber> {
-    return this.getField<Option<BlockNumber>>('exit_worker_role_application_stake_unstaking_period')
+  get exit_role_application_stake_unstaking_period(): Option<BlockNumber> {
+    return this.getField<Option<BlockNumber>>('exit_role_application_stake_unstaking_period')
   }
 
-  get exit_worker_role_stake_unstaking_period(): Option<BlockNumber> {
-    return this.getField<Option<BlockNumber>>('exit_worker_role_stake_unstaking_period')
+  get exit_role_stake_unstaking_period(): Option<BlockNumber> {
+    return this.getField<Option<BlockNumber>>('exit_role_stake_unstaking_period')
   }
 };
 
-export type IWorkerOpening = {
-  opening_id: OpeningId,
-  worker_applications: BTreeSet<WorkerApplicationId>,
+export enum OpeningTypeKeys {
+  Leader = 'Leader',
+  Worker = 'Worker'
+};
+
+export class OpeningType extends Enum {
+  constructor (value?: any, index?: number) {
+    super(
+      {
+        Leader: Null,
+        Worker: Null
+      },
+      value, index
+    );
+  }
+};
+
+export type IOpening = {
+  hiring_opening_id: OpeningId,
+  applications: BTreeSet<ApplicationId>,
   policy_commitment: WorkingGroupOpeningPolicyCommitment,
+  opening_type: OpeningType
 }
 
-export class WorkerOpening extends JoyStruct<IWorkerOpening> {
+// This type is also defined in /hiring (and those are incosistent), but here
+// it is beeing registered as "OpeningOf" (which is an alias used by the runtime working-group module),
+// so it shouldn't cause any conflicts
+export class Opening extends JoyStruct<IOpening> {
   constructor (value?: IWorker) {
     super({
-      opening_id: OpeningId,
-      worker_applications: BTreeSet.with(WorkerApplicationId),
+      hiring_opening_id: OpeningId,
+      applications: BTreeSet.with(ApplicationId),
       policy_commitment: WorkingGroupOpeningPolicyCommitment,
+      opening_type: OpeningType
     }, value);
   }
 
-  get opening_id(): OpeningId {
-    return this.getField<OpeningId>('opening_id');
+  get hiring_opening_id(): OpeningId {
+    return this.getField<OpeningId>('hiring_opening_id');
   }
 
-  get worker_applications(): BTreeSet<WorkerApplicationId> {
-    return this.getField<BTreeSet<WorkerApplicationId>>('worker_applications');
+  get applications(): BTreeSet<ApplicationId> {
+    return this.getField<BTreeSet<ApplicationId>>('applications');
   }
 
   get policy_commitment(): WorkingGroupOpeningPolicyCommitment {
     return this.getField<WorkingGroupOpeningPolicyCommitment>('policy_commitment');
   }
+
+  get opening_type(): OpeningType {
+    return this.getField<OpeningType>('opening_type');
+  }
 }
 
 export function registerWorkingGroupTypes() {
   try {
     getTypeRegistry().register({
-      // Note that it actually HAS TO be "LeadOf" in the runtime,
-      // otherwise there would be conflicts with the current content-workig-group module
-      LeadOf: Lead,
       RationaleText,
-      WorkerApplication,
-      WorkerApplicationId,
-      WorkerApplicationIdSet,
-      WorkerApplicationIdToWorkerIdMap,
+      ApplicationOf: Application,
+      ApplicationIdSet,
+      ApplicationIdToWorkerIdMap,
       WorkerId,
       WorkerOf: Worker,
-      WorkerOpening,
-      WorkerOpeningId,
-      StorageProviderId
+      OpeningOf: Opening,
+      StorageProviderId,
+      OpeningType,
+      /// Alias used by the runtime working-group module
+      HiringApplicationId: ApplicationId
     });
   } catch (err) {
     console.error('Failed to register custom types of working-group module', err);