Skip to content

Commit

Permalink
Migrate XSU policy definition to PZSchema
Browse files Browse the repository at this point in the history
Summary:
Finally, the big kahuna. This diff migrates our third PZ2 policy definition to PZSchema - for schema `PZXSUSchema`.

To do this, we:

1/ Configure the policy on `PZXSUSchema`, in line with its configuration in `PZ2XSUPolicy`.

```
<<__Override>>
  protected function configure(this::TConfig $config)[write_props]: void {
    $config->metadata()
      ->policyKindID(PZPolicyKindID::XSU);

    $config->policy()
      ->pz2()
      ->graphWithUnion()
      ->outputClosure()
      ->withManualTrait()
      ->states(self::getPolicyStates())
      ->flows(self::getPolicyFlows());
  }

  private static function getPolicyStates()[]: dict<string, int> {
    return dict[
      'NONE' => 0,
      'ALL' => 1,
      'FACEBOOK' => 2,
      'INSTAGRAM' => 3,
      'WHATSAPP' => 4,
      'UNKNOWN' => 6,
      'THREADS' => 16,
      'MIXED' => 18,
      'DELIVERY' => 19,
      'MEASUREMENT' => 20,
    ];
  }

  private static function getPolicyFlows()[]: dict<string, keyset<string>> {
    return dict[
      'NONE' => keyset[
        'DELIVERY',
        'FACEBOOK',
        'INSTAGRAM',
        'THREADS',
        'WHATSAPP',
        'UNKNOWN',
      ],
      'FACEBOOK' => keyset['MIXED'],
      'INSTAGRAM' => keyset['MIXED'],
      'THREADS' => keyset['MIXED'],
      'WHATSAPP' => keyset['MIXED'],
      'UNKNOWN' => keyset['ALL'],
      'MIXED' => keyset['ALL'],
      'DELIVERY' => keyset['MEASUREMENT'],
      'MEASUREMENT' => keyset['ALL'],
    ];
  }
```

2/ Run codegen: `pz`.
3/ Find-and-replace:

```
s/PZ2XSUPolicy/PZXSUPolicy/g
s/PZ2XSUStates/PZXSUPolicyState/g
```

4/ Move manual code from `PZ2XSUPolicy` into `PZXSUPolicyManualSection`.

4/ Delete the now defunct manual policy + state code.

Differential Revision: D68216513

fbshipit-source-id: a772e9b7772a977b6026a81d19361593fb0160cf
  • Loading branch information
Andrew Vaslas authored and facebook-github-bot committed Jan 17, 2025
1 parent 3356369 commit cf43955
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ classname<IThriftClient> $thrift_service_name,
private async function genInitPZ2(): Awaitable<void> {
await MockPZ2::genInitRequest(
PZ2CodeAnnotationStatic::get()->withPolicy(
PZ2XSUPolicy::create(PZ2XSUStates::FACEBOOK),
PZXSUPolicy::create(PZXSUPolicyState::FACEBOOK),
),
);
}
Expand Down

0 comments on commit cf43955

Please sign in to comment.