Skip to content

This page is for integrators and platform engineers who create, read or delete modules through the API, build navigation from the sidebar endpoint, or need the exact authorization and deletion rules.

All module APIs live in the data-service, mounted under /v1/data-module (plus the sidebar under /v2/side-bar). Every endpoint requires authentication via the OSOS Auth2 strategy.

A module is a lightweight grouping object. It does not embed its entities; instead, each DataEntity carries a module reference pointing back to the module that contains it. Deleting a module is therefore blocked while any entity still points at it.

Two kinds of modules exist:

  • Regular modules — created by developers, fully editable and deletable. Each groups a set of related functions into an integrated unit (for example, a module dedicated to task management, or one for human resources).
  • Implicit modules (isImplicit: true) — system-managed containers that cannot be edited or deleted through the API. The core/system module (00000000-0000-0000-0000-000000000000) is treated as a restricted module and is excluded from normal listings unless explicitly requested.

When a new module is created, OSOS automatically provisions a default dashboard and a default landing page for it. A module also carries a sharing level (Private/Public/Shared) and an order that determines its position in the sidebar.

The normalized name is uniquely indexed and pattern-validated. The portal sends the stored normalized name on every edit, so it cannot be changed there after creation; PATCH /v1/data-module/{id} does persist a new normalizedName (see Update by id), which risks a duplicate-name conflict and breaks anything that binds to the old name — change it only deliberately.

A module is an independent, self-contained unit that executes its functions without depending directly on other modules. Where cross-module interaction is needed, modules communicate through a virtual (proxy) entity rather than a direct dependency.

The core module is a default, system-provisioned module that holds the essential entities OSOS needs to set up its environment. It is created automatically, and users cannot modify its information or create entities under it the way they can with other modules. Internally it is the restricted module id 00000000-0000-0000-0000-000000000000, filtered out of listings by default and protected by the restricted-module authorization path.

DataModule extends Identified<UUID> (giving it a string id) and implements IName and ISpecificationVersion<1>.

FieldTypeRequiredNotes
idUUID (string)assignedUUID v4; generated server-side on create if omitted.
specificationVersion1yesFixed literal 1, defaults to 1.
normalizedNamestringyesMachine name; unique index. Validated against NormalizedNameValidation (min/max length + pattern).
nameLocalizedValueyesLocalized display name (per-language strings).
descriptionNullableLocalizedValuenoLocalized, nullable.
iconIconyesObject with a required, non-empty name string.
isImplicitbooleanyesMarks a system-managed module.
creationInfoActionInfono*Stamped server-side on create (who/when, plus optional delegatee).
updateInfoActionInfono*Re-stamped server-side on every update.
sharingApplicationSharingyesControls cross-space visibility (see Sharing).

* creationInfo and updateInfo are declared required: false on the model but are always populated by the service; they are excluded from request bodies.

Icon is a small embedded object (idInjection: false, nullable at the schema level) with a single required name: string. The controller additionally rejects an empty or whitespace-only icon name at write time.

On create, the service builds an ActionInfo with doneAt (server time), doneBy (a ReferenceProperty to the USER entity with the acting user’s id), and an optional delegatee reference when the request is made on behalf of another user (user.delegatee.dataEntry). Both creationInfo and updateInfo are set to this value at creation; updateModule overwrites updateInfo with a fresh stamp (no delegatee) on each update.

sharing is an ApplicationSharing object:

FieldTypeNotes
levelCategoryComponentEntryValue<ApplicationSharingLevelEnum>The sharing level.
spacesReferenceProperty[]Spaces the module is shared with (used for PRIVATE/SHARED).

ApplicationSharingLevelEnum (from @osos/shared):

ValueMeaning
PUBLICVisible to all spaces.
PRIVATEVisible only to the listed spaces.
SHAREDVisible to the owning space and the listed spaces.

DataModuleService.getSpaceModules(spaceId) resolves the modules visible to a space using exactly these rules: any PUBLIC module, plus PRIVATE or SHARED modules whose sharing.spaces.dataEntry includes the space id.

Long-standing — per-module sharing (module/entity sharing) predates the 1.2 line and is baseline for all supported versions; no availability badge is shown.

Extends DataModule and adds two write-only helpers used by the create request:

FieldTypeNotes
entitiesUUID[]Optional, defaults to [].
permissionsPermission[]Optional. Stripped from the module document and stored separately as access rights (see below).

Trimmed projections used by navigation payloads: id, specificationVersion, name, icon — and, for LiteModuleWithViews, an array of LiteDataViews. SidebarDto (v1) is composed of these plus system views and a service-status block.

ExportingDataModuleDto / ExportingDataModulesDto

Section titled “ExportingDataModuleDto / ExportingDataModulesDto”

Packaging DTOs used when exporting a module for sharing across spaces: a module reduces to its id plus an array of ExportingEntityDto (dataEntities); ExportingDataModulesDto wraps a list of them. A ForbiddenToExportModule exception guards the export path.

Base path: /v1/data-module. All routes are authenticated. Roles and voters are noted per route.

Method & pathPurposeAuthorization
POST /v1/data-moduleCreate a moduleRole SystemDeveloper
GET /v1/data-module/countCount modulesRole SystemViewer or Restricted
GET /v1/data-moduleList modulesRole SystemViewer or Restricted
GET /v1/data-module/{id}Get one modulemoduleVoterFactory(0)
PATCH /v1/data-module/{id}Update a modulemoduleVoterFactory(0)
DELETE /v1/data-module/{id}Delete a modulemoduleVoterFactory(0)
DELETE /v1/data-module/{id}/permanentDelete a module and everything in it (Since 1.10, background job)Role SystemAdmin (license must include administration)

Request body is a DataModuleCreateDto with id, creationInfo, and updateInfo excluded (they are server-assigned).

Flow (create → moduleChecker → DataModuleService.createModule):

  1. Validation (moduleChecker), in order:
    • languagesService.validateName(name) — may throw NameEnIsRequired, NameEnIsShort, NameEnIsLong.
    • checkIcon — throws DataModuleIconIsRequired if icon.name is empty.
    • checkDuplicateNormalizedName — throws ModuleDuplicateException if another module already uses the same normalizedName.
    • checkDuplicateNamesFromDatabase — throws ModelWithGivenNameExistException if a localized name collides.
  2. permissions is pulled off the DTO and passed separately (not stored on the module document).
  3. The service assigns id (UUID v4 if absent), sets specificationVersion: 1, stamps creationInfo/updateInfo, and persists via DataModuleRepository.
  4. Publishes DataModuleCreatedEvent on the service bus.
  5. If permissions were provided, stores them as access rights (EntitlementEnum.Module, keyed by the new module id). A failure here is logged and re-thrown.

Returns the created DataModule.

POST /v1/data-module
Content-Type: application/json
{
"normalizedName": "hr_module",
"name": { "en": "Human Resources", "ar": "الموارد البشرية" },
"description": { "en": "HR entities and views" },
"icon": { "name": "users" },
"isImplicit": false,
"sharing": {
"level": { "id": "PUBLIC", "name": { "en": "Public" } },
"spaces": []
},
"permissions": []
}

Query params:

  • where — standard LoopBack where filter on DataModule.
  • includeCoreModule (boolean) — when falsy (default), the core module id 00000000-0000-0000-0000-000000000000 is excluded via neq('id', ...).

Counting goes through countWithAccessRight, which scopes the result to what the caller can actually see (see Access-right scoping).

Query params:

  • filter — standard LoopBack filter on DataModule.
  • includeCoreModule (boolean) — same core-module exclusion as count.

Results come from findWithAccessRightInSpace, using an English collation ({collation: {locale: 'en'}}) for ordering. As with count, results are scoped to the caller’s access rights.

getModule applies the caller’s sharing-level filter (spaceService.getFilterBySharingLevel) on top of the id match and reads via findOneInSpace. If nothing matches, it throws EntityNotFoundError (404). Any supplied filter excludes where.

Partial body (DataModule, partial: true) with id, creationInfo, and updateInfo excluded. Flow:

  1. getModule(id) — 404 if not visible.
  2. moduleChecker(..., id) — same validation as create, but duplicate checks ignore the module’s own id (neq: selfId).
  3. DataModuleService.updateModule writes name, description, normalizedName, icon, sharing, and a fresh updateInfo, then re-reads the document.
  4. Publishes DataModuleUpdatedEvent, carrying a changes diff. The diff is computed by identifyChanges, which currently tracks only sharing changes (old/new values).

Returns the updated DataModule.

The service persists normalizedName on update, but it remains the module’s stable key. The portal presents it as fixed after creation, and renaming it at the API level risks a duplicate conflict — change it only deliberately.

Delete by id (DELETE /v1/data-module/{id})

Section titled “Delete by id (DELETE /v1/data-module/{id})”

Guards, in order:

  1. getModule(id) — 404 if not visible.
  2. If isImplicit, throw ImplicitModuleException — implicit modules can’t be modified or deleted.
  3. If any DataEntity still references the module (findInSpace where module == id), throw ModuleHasEntities — move or delete its entities first.
  4. DataModuleService.deleteModule deletes the document and publishes DataModuleDeletedEvent.

Returns 204 (no content). To delete a module that still holds content, use the permanent delete below.

Permanent delete (DELETE /v1/data-module/{id}/permanent) Since 1.10

Section titled “Permanent delete (DELETE /v1/data-module/{id}/permanent) Since 1.10”

The route above only removes an empty module. The permanent delete removes a module and everything in it, as a background job. It is system-admin only (allowedRoles: [SystemAdmin]; the license must include administration).

Guards, in code order (ModulePurgeService.assertPurgeable):

CheckRefusal
The module is visible to the caller404
It is not the core module and not implicit400 MODULE_PURGE_NOT_ALLOWED
No delete is already running (a failed or stalled run is resumed instead)409 MODULE_BEING_DELETED
Every entity in it can be purged by the entity permanent delete400 MODULE_PURGE_NOT_ALLOWED with details.entityIds
Neither the module nor any entity or page in it was installed from a package403
No entity in it is locked by another user409 LOCKED_OBJECT
Nothing outside the module still references the module or anything in it (dependency-service GET /v1/external-dependents/DataModule/{id})409 MODULE_HAS_DEPENDENTS (details.count), or 503 DEPENDENCY_CHECK_UNAVAILABLE when the check cannot answer

The last check is the “unlink first” rule: the portal dialog lists those references, each with an Open link, and enables Delete only when none remain.

Response. The route answers before the work is done, with 200 {success: true, result: null} (the OpenAPI document declares 202). It marks the module with purgeInfo and purgeStatus: {step: 'queued'} through a conditional write (409 UPDATE_CONFLICT if another request marked it first), archives the module’s sidebar link and the links under it, sends PurgeDataModuleCommand and publishes DataModulePurgeStateChangedEvent (deleting). It publishes no DataModuleUpdatedEvent.

The job. ModulePurgeService.run claims the module with a fresh run id and performs idempotent steps, recording each in purgeStatus.step:

flowchart LR
  A[entities] --> B[pages] --> C[dashboard] --> D[functions] --> E[counters] --> F[grants]
  F --> G[system-objects] --> H[links] --> I[verify] --> J[event] --> K[module]
  • entities purges every entity of the module (archived ones and those in any space included) through the entity permanent delete, counting down entitiesLeft.
  • functions archives the module’s functions, so the functions service deprovisions them; grants removes the module grants and the sensitive-field rights under the module’s name, then refreshes the permission and profile epochs.
  • verify counts what is left and fails with MODULE_PURGE_INCOMPLETE if something was added meanwhile; event publishes DataModuleDeletedEvent carrying the ids it deleted; module deletes the document.
  • A failed step is recorded as purgeStatus.error {step, code, message} and announced as failed. The module stays marked, and calling Delete again resumes it (Delete also resumes a run whose status has not moved for 10 minutes). There is no cancel.

While a module is being deleted data-service refuses to edit it, create an entity or virtual entity in it, move an entity into it, or create a page in it (409 MODULE_BEING_DELETED); purgeInfo and purgeStatus are not accepted in create/update bodies. The portal polls GET /v1/data-module/{id} every 3 s (a 404 means the delete is done), and the web-socket service pushes modules/delete-state {moduleId, state} to every open session of the tenant, so module pages show Deleting… or Delete failed live.

Known limit: the purge runs inside a bus handler, and data-service consumes one bus message at a time by default, so a long purge holds up that pod’s other bus work.

Sorting the Modules and Entities lists Since 1.10

Section titled “Sorting the Modules and Entities lists Since 1.10”

The admin Modules page, the System Entities page and each module’s Entities tab have the same multi-level Sort control as an entity’s Queries tab. The sort fields are Newest created, Last modified and Name A–Z; the default is newest created first, and Reset restores it.

Both lists page on the server, so the chosen sort is sent to the existing list routes as a LoopBack order with an id tie-break — there is no new endpoint. Each list remembers its own sort (the Modules page, the System Entities page and every module’s Entities tab separately) for the browser session: it survives a refresh, is cleared on sign-out, and is reset when you navigate into the list. Changing the sort keeps the applied filter and returns to page 1.

create requires SystemDeveloper. count/find require SystemViewer or Restricted. The item-level routes (findById, updateById, deleteById) use the module voter instead of a fixed role.

moduleVoterFactory(moduleParamIndex = 0, bodyParamKey?, ignoreRestricted?) builds an authorizer for a route:

  • Internal service calls are allowed outright; if a view is already in context, the voter abstains.
  • It reads the module id from the argument at moduleParamIndex (or from bodyParamKey within an object body). If the id is missing/null, it abstains and lets the default provider decide.
  • If the id is a restricted module (the core module), decisions route through canViewRestrictedModule / canEditRestrictedModule (unless ignoreRestricted).
  • Otherwise, view is granted via canViewModuleIncludingEntityGrants(moduleId) and edit via canEditModule(moduleId). Read access is intentionally broader than edit: a user who only holds a grant on an entity inside the module can view the module as a navigation container, but editing still requires a real module grant.

Since 1.8 — allowing an entity-only grant to open its parent module (canViewModuleIncludingEntityGrants and the entityParentModuleIds plumbing) first shipped in the 1.8 line.

Both the list and count paths delegate to DefaultCrudWithSharingAndAccessRightRepository (used only by the module and entity repositories), which composes two orthogonal filters into the Mongo where:

1. Space/sharing filter (getWhereSharing) — a row is visible only if sharing.level == Public, or its level is Private/Shared and sharing.spaces.dataEntry includes the current spaceId. This is the list/count-time counterpart of the per-item getFilterBySharingLevel check applied by the get-by-id route.

2. Access-scope filter — the repository calls accessRightsService.getAllModuleIdsUserCanView() and branches:

  • AdminAccess → no filtering (full space, ordered _id DESC on list).
  • EditAccess / DeveloperAccess / ViewAccess → everything except restricted modules (nin('id', restrictedModuleIds)).
  • Resource-scoped result {moduleIds, entityIds, entityParentModuleIds} → for modules, restrict to moduleIds ∪ entityParentModuleIds (granted modules plus the parent modules of granted entities, so those parents appear as navigation containers; sibling entities stay hidden). This scope where is imposed on the filter so resource-scoped users (for example Restricted) only receive what they were granted.

The service publishes to the service bus (@node-ts/bus-core) on every mutation, with correlationId set to the request trace id and sticky attributes carrying userId and spaceId:

EventPublished byPayload
DataModuleCreatedEventcreateModuleCreated module + acting user id.
DataModuleUpdatedEventupdateModuleUpdated module + user id + changes (sharing diff).
DataModuleDeletedEventdeleteModuleDeleted module + user id.

These events are consumed elsewhere to synchronize the navigation links (a link entity is maintained for each module, page, view, and report).

Modules are the backbone of portal navigation. The sidebar endpoint returns the links the user can see, grouped so that each module acts as a container for its views and pages.

SideBarController.getViewsForSidebarV2 (authorization is skipped at the route; scoping happens inside the services). Inputs:

  • Header x-domain-id, header x-space-id.
  • Query include (SidebarIncludeDataEnum, default All):
ValueNameReturns
0Alllinks + serviceViewsStatus.
1Linkslinks only (serviceViewsStatus: null).
2OnlyServiceserviceViewsStatus only (links: []).

Response is a SidebarDtoV2:

FieldTypeNotes
linksGenericLink[]Navigation links (modules and their children).
serviceViewsStatusSidebarServiceStatus | nullService-catalog / requests / inbox status + counters.
isRestrictedbooleanWhether the caller holds the system-level Restricted floor.
restrictedAccess{hasModuleAccess, hasEntityAccess}Only meaningful when isRestricted; drives the restricted UI.

restrictedAccess is computed from the user’s module/entity permissions, each flag true when at least one grant is >= ViewAccess.

Since 1.4 — the v2 sidebar include options and the service-status model first shipped in the 1.4 line. The v1 SidebarDto / LiteModuleWithViews shape and the links machinery predate the 1.2 line and are baseline.

Booleans hasServiceCatalog, hasRequests, hasInbox, hasObserverRequests and counters onGoingRequests, onGoingInbox, onGoingObserverRequests.

DataViewsController.findModulesForEndUser closes a real gap. Every other listing that touches modules or views answers an authoring question and is gated accordingly: GET /v1/data-module (above) needs role SystemViewer or Restricted, and the data-service views-by-module endpoint needs a grant on the module or entity and still returns every published view in that module, whether or not the caller can actually open it. A user holding nothing but view grants — no module or entity grant at all — could not discover their own views through any of these, which made a module-first view picker effectively admin-only.

This endpoint asks the end-user question instead — which views may I actually open, and which module is each one in — and returns LiteModuleWithViews[] (see LiteModule / LiteModuleWithViews above): the modules containing at least one view the caller can open, each with those views. It is also the first endpoint that actually serves this shape over HTTP — the v1 SidebarDto embeds it too, but no v1 sidebar route is mounted any more; only GET /v2/side-bar is live (see above).

Authorization is @authorize({skip: true}) on purpose: the filtering inside DataViewService.getModulesWithAccessibleViews is the authorization, and it fails closed — an anonymous caller only gets views with anonymous access enabled. It mirrors the same end-user accessibility check the single-view endpoint uses (anonymous, then authenticated, then an explicit view grant or system-developer-or-above for a restricted view), with one deliberate difference: a view with neither access mode enabled is excluded here rather than falling through and still being returned, since listing a view no configured flow can open would be misleading in a picker.

Candidates are scoped to published, non-implicit views in the requesting space, grouped under the module resolved through the view’s entity (not the view’s own, possibly stale, module snapshot), and sorted by name for a stable picker order.

ExceptionError codeWhen
DataModuleIconIsRequiredDATA_MODULE_ICON_REQUIREDIcon name empty on create/update.
ModuleDuplicateExceptionMODULE_DUPLICATEnormalizedName already used.
ModuleHasEntitiesMODULE_HAS_ENTITIESDelete attempted while entities reference the module.
ImplicitModuleExceptionMODULE_IS_IMPLICITModify/delete attempted on an implicit module.
InvalidModuleIdINVALID_MODULE_IDProvided module id is not valid (404).
EntitiesNotFoundENTITY_NOT_FOUNDOne or more referenced entities do not exist.
ForbiddenToExportModuleCANNOT_EXPORT_MODULEExport not permitted (403).
ModulePurgeNotAllowedExceptionMODULE_PURGE_NOT_ALLOWEDSince 1.10. Permanent delete of the core or an implicit module, or of one holding an entity the entity purge refuses (400, details.entityIds).
ModuleHasDependentsExceptionMODULE_HAS_DEPENDENTSSince 1.10. Permanent delete while items outside the module reference it (409, details.count).
ModuleBeingDeletedExceptionMODULE_BEING_DELETEDSince 1.10. Edit, create-in, move-into or permanent delete of a module whose delete is running (409).
DependencyCheckUnavailableExceptionDEPENDENCY_CHECK_UNAVAILABLESince 1.10. The dependency check could not answer (503, not retried).

Name-validation errors (NameEnIsRequired, NameEnIsShort, NameEnIsLong, ModelWithGivenNameExistException) are raised by LanguagesService during moduleChecker.

  • Create requires SystemDeveloper. Viewing and listing need only SystemViewer/Restricted, but results are always access-scoped.
  • The normalized name is your stable key — it is uniquely indexed and pattern-validated; pick it deliberately, since renaming risks a duplicate conflict.
  • Empty the module before deleting — or delete it permanently. The plain delete route rejects a non-empty module with ModuleHasEntities; Since 1.10 a system administrator can instead delete it permanently with everything in it, after unlinking every reference from outside the module.
  • Don’t touch implicit/core modules — the core module id 00000000-0000-0000-0000-000000000000 is filtered out of listings by default and protected by the restricted-module voter path; implicit modules reject edit and delete outright.
  • Update diffs are sharing-only — the changes payload on DataModuleUpdatedEvent currently reflects sharing changes only, even though other fields are persisted.
  • Switching modules while browsing a module’s Entities tab used to carry over the previously viewed module’s filter; the list now scopes to the module you switched to.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27