✅ Product validators
Product routes compose these shared validator factories. Each consumes injected route payload/context before the route pipeline runs.
Inventory
Details
isAuthenticated()
Implementation
Signature: isAuthenticated(): Validator. Invoked as isAuthenticated(), this calls context.authenticate(payload) and defaults to getBearerTokenInfo when no adapter is injected. Product service injects bearer authentication for omitted authMode or 'bearer', and cookie authentication for 'cookie'; cookie mode requires host cookie parsing. Invalid or missing authentication is reported as 401.
Consumers: createProductRoute, createProductBatchRoute, updateProductBatchRoute, deleteProductBatchRoute, updateProductRoute, deleteProductRoute, copyProductRoute, copyProductBatchRoute, getProductImageUploadUrlRoute, createProductImageRoute, deleteProductImageRoute, createProductVariantRoute, getProductVariantRoute, updateProductVariantRoute, deleteProductVariantRoute, createProductVariantBulkRoute, updateProductVariantBulkRoute, deleteProductVariantBulkRoute, findProductsByOrganizationIdRoute, getProductLikersRoute.
checkIdentityType(['admin'])
Implementation
Signature: checkIdentityType(['admin']): Validator. Every Product consumer invokes checkIdentityType(['admin']). It requires context.db.identities and configuration.identity.typeIds, authenticates the payload, loads the token identity, and compares its typeId with configuration.identity.typeIds.admin. It throws 500 for missing dependencies, 401 for an invalid user access token, and 403 for identity lookup, missing type, or authorization failure.
Consumers: createProductRoute, createProductBatchRoute, updateProductBatchRoute, deleteProductBatchRoute, updateProductRoute, deleteProductRoute, copyProductRoute, copyProductBatchRoute, getProductImageUploadUrlRoute, createProductImageRoute, deleteProductImageRoute, createProductVariantRoute, updateProductVariantRoute, deleteProductVariantRoute, createProductVariantBulkRoute, updateProductVariantBulkRoute, deleteProductVariantBulkRoute, getProductLikersRoute.
hasOrgRole
Implementation
The Product route invokes hasOrgRole(['owner', 'admin', 'member'], ['params', 'requestParams', 'organizationId']). It authenticates the payload, loads that organization, and compares the caller membership role with configuration.organization.roles. It follows isAuthenticated() in the route, not checkIdentityType. It throws 500 for missing database/configuration, 401 for an invalid token, 400 for a missing organization ID, and 403 for lookup, membership, or role failure.
Consumers: findProductsByOrganizationIdRoute.