@salesforce/b2c-tooling-sdk / safety / SafetyRule
Interface: SafetyRule
Defined in: packages/b2c-tooling-sdk/src/safety/types.ts:47
A safety rule that matches operations and specifies an action.
Rules support these matchers, all using glob patterns (via minimatch):
method+path: Matches HTTP requests by method and URL pathoperationId/api: Match SCAPI requests made throughcreateScapiRequest(code mode) by the schema operation ID (e.g.getProduct) or API ID (e.g.product/products/v1)readOnlySearch: Matches the search POSTs thatREAD_ONLYallows (seeREAD_ONLY_SEARCH_PATHS)job: Matches job execution by job ID (extracted from SCAPI or OCAPI URLs)command: Matches CLI commands by oclif command ID (e.g., "sandbox:delete")
job and command rules match on that field alone. The other matchers can be combined; every matcher a rule sets must match.
Example
{ "job": "sfcc-site-archive-export", "action": "allow" }
{ "command": "ecdn:cache:purge", "action": "confirm" }
{ "method": "DELETE", "path": "/code_versions/*", "action": "block" }
{ "method": "GET", "api": "product/**", "action": "allow" }
{ "operationId": "updateProduct", "action": "confirm" }
{ "readOnlySearch": true, "action": "allow" }
{ "path": "**", "action": "block" }Properties
action
action:
SafetyAction
Defined in: packages/b2c-tooling-sdk/src/safety/types.ts:74
Action to take when this rule matches.
api?
optionalapi:string
Defined in: packages/b2c-tooling-sdk/src/safety/types.ts:66
SCAPI API ID glob, <family>/<name>/<version> (e.g. "product/products/v1", "product/products/*", or "product/**" for a whole family; * does not cross /). Matches only requests that carry an API ID, which createScapiRequest sets.
command?
optionalcommand:string
Defined in: packages/b2c-tooling-sdk/src/safety/types.ts:55
CLI command ID glob pattern (e.g., "sandbox:*", "ecdn:cache:purge").
job?
optionaljob:string
Defined in: packages/b2c-tooling-sdk/src/safety/types.ts:53
Job ID glob pattern. Matches SCAPI and OCAPI job execution URLs by job ID.
method?
optionalmethod:string
Defined in: packages/b2c-tooling-sdk/src/safety/types.ts:49
HTTP method pattern (e.g., "POST", "DELETE"). Omit to match any method.
operationId?
optionaloperationId:string
Defined in: packages/b2c-tooling-sdk/src/safety/types.ts:60
SCAPI schema operation ID glob (e.g. "getProduct", "Product"). Matches only requests that carry an operation ID, which createScapiRequest sets.
path?
optionalpath:string
Defined in: packages/b2c-tooling-sdk/src/safety/types.ts:51
URL path glob pattern (e.g., "/jobs/*/executions"). Matched with minimatch.
readOnlySearch?
optionalreadOnlySearch:boolean
Defined in: packages/b2c-tooling-sdk/src/safety/types.ts:72
When true, matches only the search POSTs that READ_ONLY treats as reads (see READ_ONLY_SEARCH_PATHS). Use {readOnlySearch: true, action: 'allow'} ahead of a catch-all block rule to keep searches working.