@@ -79,6 +79,7 @@ import {
7979 convertFiltersToAST ,
8080 emulateBatchTransaction ,
8181 normalizeSchemaReferenceKeys ,
82+ isApiAccessDeniedError ,
8283 type DatasetDrillRange ,
8384} from '@object-ui/core' ;
8485import { MetadataCache } from './cache/MetadataCache' ;
@@ -1017,48 +1018,11 @@ export function is404Error(error: unknown): boolean {
10171018 return errorCodeIsAnyOf ( { code } , [ 'OBJECT_NOT_FOUND' , 'RECORD_NOT_FOUND' ] ) ;
10181019}
10191020
1020- /**
1021- * The two denials the server derives from an object's `enable` block —
1022- * `apiAccessDenialFromEnable` (objectstack `packages/rest/src/rest-server.ts`).
1023- *
1024- * - `OBJECT_API_DISABLED` (404) — `enable.apiEnabled: false`; the object is
1025- * not exposed over the data API at all.
1026- * - `OBJECT_API_METHOD_NOT_ALLOWED` (405) — the operation is absent from the
1027- * `enable.apiMethods` whitelist.
1028- *
1029- * Both are **pure functions of the object's metadata**: no user, no permission,
1030- * no context, no request body. So neither is transient and neither is
1031- * per-user — when one happens it is a permanent property of that object, and
1032- * every retry of every persona gets the identical answer.
1033- *
1034- * That is exactly why they must not be degraded into "no data". A 404 from a
1035- * missing collection means *this backend doesn't have that table*, which the
1036- * optional-collection probes below legitimately read as "feature unavailable";
1037- * a 404 from `OBJECT_API_DISABLED` means *this page can never work*. Answering
1038- * the second with an empty result set renders "you have no records" over a
1039- * surface that is not allowed to have any (objectui#4408 — it also hid the
1040- * upstream defect objectstack#7544 for its entire life, because a merely
1041- * unpopulated page invites nobody to click through).
1042- */
1043- export const API_ACCESS_DENIED_CODES = [
1044- 'OBJECT_API_DISABLED' ,
1045- 'OBJECT_API_METHOD_NOT_ALLOWED' ,
1046- ] as const ;
1047-
1048- /**
1049- * True when `error` is an `enable`-block API denial (see
1050- * {@link API_ACCESS_DENIED_CODES}).
1051- *
1052- * Discriminates on the ADR-0112 `code`, never on the status: 404 alone cannot
1053- * separate a disabled object from a missing collection, and 405 alone cannot
1054- * separate a withheld method from any other method rejection. The code survives
1055- * the transport — `@objectstack/client`'s fetch wrapper stamps `error.code`
1056- * from the response envelope, and both spellings are declared members of the
1057- * spec's `StandardErrorCode` — so no heuristic on status is needed or wanted.
1058- */
1059- export function isApiAccessDeniedError ( error : unknown ) : boolean {
1060- return errorCodeIsAnyOf ( error , API_ACCESS_DENIED_CODES ) ;
1061- }
1021+ // `API_ACCESS_DENIED_CODES` / `isApiAccessDeniedError` live in
1022+ // `@object-ui/core` (`utils/api-access-denied.ts`) so that `@object-ui/react`
1023+ // can classify the denial without depending on this adapter. Re-exported here
1024+ // unchanged: this package's published face keeps both names.
1025+ export { API_ACCESS_DENIED_CODES , isApiAccessDeniedError } from '@object-ui/core' ;
10621026
10631027/**
10641028 * What the by-name meta app route said about THIS session's access to an app
0 commit comments