Search by

hryvinskyi / magento2-gdpr-api

hryvinskyi

Published contracts of the data-subject rights (GDPR) suite: the request, subject and journal data types, the services that export, erase and anonymise a shopper's personal data, and the extension points other modules contribute entities, field anonymisers, export formats, guest ownership checks and

Package info

github.com/hryvinskyi/magento2-gdpr-api

Type:magento2-module

pkg:composer/hryvinskyi/magento2-gdpr-api

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-11-30 18:52 UTC

This package is auto-updated.

Last update: 2026-11-30 20:06:48 UTC


README

The published contracts of the data-subject rights suite: the request, subject and journal data types, the services that export, erase and anonymise a shopper's personal data, and the extension points other modules contribute entities, field anonymisers, export formats, guest ownership checks and inactivity sources to. The package holds interfaces, enums and exceptions only. The engine that implements them is hryvinskyi/magento2-gdpr.

What it does for a store

Nothing on its own. A module that adds a kind of personal data (a provider), calls a request service from a storefront page, a command or an API, or shows requests in a screen depends on this package and on nothing in the engine. The engine, the admin screens, the storefront pages and the GraphQL schema depend on it in turn, so none of them depends on another.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.8 or 2.4.9, PHP 8.3 to 8.5.
  • magento/framework.

Installation

Run from the Magento root.

composer require hryvinskyi/magento2-gdpr-api
bin/magento module:enable Hryvinskyi_GdprApi
bin/magento setup:upgrade
bin/magento setup:di:compile  # production mode only
bin/magento cache:flush

A store installs hryvinskyi/magento2-gdpr-pack instead, which brings the engine and the screens. This package alone is for a module that only needs the contracts.

Configuration

None. The settings of the suite are described in the README of hryvinskyi/magento2-gdpr.

The contracts

Every interface and enum is @api. The names are the ones the engine, the screens and the providers share.

Data types (Api\Data\)

Type What it is
RequestType (enum) export, erase, anonymise. isDestructive() is true for the last two.
RequestStatus (enum) pending_confirmation, scheduled, running, completed, failed, cancelled, expired. isTerminal(), isOpen(), isConfirmableBySubject() (only while it waits for confirmation), isCancellableBySubject() (while it waits for confirmation or for its run) and isCancellableByOperator() (also once it failed).
RequestOrigin (enum) customer, guest, admin, cli, automatic. actorType() is the actor journaled as making a request of that origin: the same name, and cron for automatic.
ActorType (enum) Who acted, as the privacy action log stores it: admin, customer, guest, cli, cron, integration, runner, subject. The set is closed and a case is only ever added.
SubjectKind (enum) customer, guest.
ErasureMethod (enum) delete, anonymise.
JournalAction (enum) The codes of the privacy action log. The set is closed and a case is only ever added, because the values are stored for good.
SubjectInterface The person a request is about: kind, customer id (non-null exactly for a customer), e-mail (trimmed, lower-case), website id.
SubjectReferenceInterface How an operator names a subject: a customer id, or an e-mail with its website, with an optional subject kind. Kind guest keeps an address with its website the guest's even when an account holds it there; kind customer asks for an account.
GuestClaimInterface What a guest gives to prove an order is theirs: order number, e-mail, and the billing lastname or postcode.
RequestInterface, RequestSearchResultsInterface A request as every API shows it, read only. The search takes its criteria as searchCriteria.
PlannedStepInterface One entity of a request's plan: entity code, label, method, and how many of the subject's records it would touch.
ArchiveFileInterface An export archive opened for download: its path and the name the person receives.
ActionLogEntryInterface One row of the privacy action log.

Interfaces that REST or GraphQL fills or reads (GuestClaimInterface, SubjectReferenceInterface, RequestInterface) carry getters, and setters with scalar types where they are input, because Magento's web API serializer needs them.

Services

Interface For
CustomerRequestManagementInterface A signed-in customer's own requests: create (a destructive type needs the account's password; a locked account is refused with Exception\AccountLockedException), list, cancel, and issue a download link.
CustomerPrivacyAvailabilityInterface Whether a signed-in customer is offered the privacy features, answered by the store the account belongs to: the question every page, link and action that shows them asks.
GuestRequestManagementInterface A shopper without an account: submit a claim (always answers true; the confirmation e-mail of a match is sent by cron within minutes), confirm and cancel with the e-mailed token, which keep working while the store has the features off.
GuestRequestLookupInterface Read the request a guest's e-mailed link was sent for, changing nothing.
AdminRequestManagementInterface Operators: create by subject reference, get, search, cancel, retry.
AdminExportRequestInterface, AdminEraseRequestInterface, AdminAnonymiseRequestInterface One create method per type, so a web API route has one permission each.
AdminRequestActionsInterface Cancel and retry for the admin API: the actor is the authenticated API user, never one the caller sends.
RequestPlanInterface What a request would do to a subject's data, without making it.
RequestRunnerInterface Run the scheduled requests that are due, or one request now.
ArchiveAccessInterface Open an export archive with its download token, for the signed-in customer whose export it is, or as an admin user.
RequestTimingsInterface The delay before a subject's erase or anonymise request may run, as requests are scheduled with it (0 to 10080 minutes).
ActionLogInterface, ActionLogEntryFactoryInterface Append to the privacy action log, which is append-only. The factory takes the actor as an ActorType.
SubjectFactoryInterface, SubjectResolverInterface Create a subject, and find the subject behind a customer id or an e-mail address.
SubjectLinksInterface The storefront addresses e-mails point to (privacy page, guest confirm and cancel, download). Null means the store has no such page.

Extension points

Interface A module implements it to
Entity\EntityProviderInterface with EntityDescriptionInterface, SubjectExporterInterface, SubjectDeleterInterface, SubjectAnonymiserInterface, AgedRecordAnonymiserInterface Contribute a kind of personal data. A part that is null is not supported, and the engine never asks for it. Every entity but the customer account sorts below EntityDescriptionInterface::ACCOUNT_SORT_ORDER (1000), so the account runs last.
Anonymisation\FieldAnonymiserInterface Add a field type: the strategy that replaces a value of that type.
Export\ExportRendererInterface Add an export format.
Guest\GuestOwnershipVerifierInterface Prove a guest's claim to an order against a module's own records.
Inactivity\InactiveSubjectSourceInterface, Inactivity\SubjectActivityInterface Propose subjects that may be inactive, a page at a time from an offset in one stable order, and tell when a subject was last active.

Two services help a provider read and judge its rows:

Interface For
Anonymisation\AnonymisedAddressInterface Tell an anonymised e-mail address (one in the reserved .invalid top-level domain, in any case) from a live one, and the SQL LIKE pattern of those addresses.
Entity\RowValuesInterface Read a fetched row's column as text, a whole number or a decimal, each also as optional; a missing column or a value of another type throws \UnexpectedValueException naming the column.

How each one is registered is in the README of hryvinskyi/magento2-gdpr, under Extension points.

Exceptions (Api\Exception\)

OpenRequestExistsException (a subject already has an open request of that kind), TooManyAttemptsException (a guest submission over its limit) and InvalidRequestException (what the caller sent is incomplete or malformed). All three extend Magento\Framework\Exception\LocalizedException.

Limits

  • The package has no implementation. Without hryvinskyi/magento2-gdpr, a service interface has no preference and cannot be resolved.
  • The package follows Semantic Versioning, and JournalAction only ever gains cases: a value stored in the privacy action log never changes.

Registrations

None: the package registers no preference, route, command, cron job or event.

Tests

  • Unit: vendor/bin/phpunit -c app/code/Hryvinskyi/GdprApi/phpunit.xml.dist, run from the Magento root.
  • Static analysis: PHPStan 2.x at level 10 with the package's phpstan.neon.dist (phpstan analyse -c app/code/Hryvinskyi/GdprApi/phpstan.neon.dist --level=10), and vendor/bin/phpcs --standard=app/code/Hryvinskyi/GdprApi/phpcs.xml.dist app/code/Hryvinskyi/GdprApi.

Translations

The package holds no user-facing text of its own.