{"version":3,"file":"index.cjs","names":[],"sources":["../../../src/core/schema/index.ts"],"sourcesContent":["import type { AccessControl } from '../types'\n/** JSON Schema (Draft 2020-12) for {@link AccessControl.IPolicy}; tighten action/resource slots via `$ref` downstream. */\nexport const POLICY_JSON_SCHEMA = {\n  $schema: 'https://json-schema.org/draft/2020-12/schema',\n  $id: 'https://gentleduck.dev/duck-iam/policy.schema.json',\n  title: 'duck-iam Policy',\n  type: 'object',\n  required: ['id', 'name', 'algorithm', 'rules'],\n  additionalProperties: false,\n  properties: {\n    id: { type: 'string', minLength: 1 },\n    name: { type: 'string', minLength: 1 },\n    description: { type: 'string' },\n    version: { type: 'number' },\n    algorithm: {\n      enum: ['deny-overrides', 'allow-overrides', 'first-match', 'highest-priority'],\n    },\n    rules: {\n      type: 'array',\n      items: { $ref: '#/$defs/rule' },\n    },\n    targets: {\n      type: 'object',\n      additionalProperties: false,\n      properties: {\n        actions: { type: 'array', items: { type: 'string' } },\n        resources: { type: 'array', items: { type: 'string' } },\n        roles: { type: 'array', items: { type: 'string' } },\n      },\n    },\n  },\n  $defs: {\n    rule: {\n      type: 'object',\n      required: ['id', 'effect', 'priority', 'actions', 'resources', 'conditions'],\n      additionalProperties: false,\n      properties: {\n        id: { type: 'string', minLength: 1 },\n        effect: { enum: ['allow', 'deny'] },\n        description: { type: 'string' },\n        priority: { type: 'number' },\n        actions: { type: 'array', minItems: 1, items: { type: 'string' } },\n        resources: { type: 'array', minItems: 1, items: { type: 'string' } },\n        conditions: { $ref: '#/$defs/conditionGroup' },\n        metadata: { type: 'object', additionalProperties: true },\n      },\n    },\n    conditionGroup: {\n      oneOf: [\n        { type: 'object', required: ['all'], properties: { all: { $ref: '#/$defs/conditionList' } } },\n        { type: 'object', required: ['any'], properties: { any: { $ref: '#/$defs/conditionList' } } },\n        { type: 'object', required: ['none'], properties: { none: { $ref: '#/$defs/conditionList' } } },\n      ],\n    },\n    conditionList: {\n      type: 'array',\n      items: {\n        oneOf: [{ $ref: '#/$defs/condition' }, { $ref: '#/$defs/conditionGroup' }],\n      },\n    },\n    condition: {\n      type: 'object',\n      required: ['field', 'operator'],\n      additionalProperties: false,\n      properties: {\n        field: { type: 'string', minLength: 1 },\n        operator: {\n          enum: [\n            'eq',\n            'neq',\n            'gt',\n            'gte',\n            'lt',\n            'lte',\n            'in',\n            'nin',\n            'contains',\n            'not_contains',\n            'starts_with',\n            'ends_with',\n            'matches',\n            'exists',\n            'not_exists',\n            'subset_of',\n            'superset_of',\n          ],\n        },\n        value: {},\n      },\n    },\n  },\n} as const\n"],"mappings":";;;;AAEA,MAAa,qBAAqB;CAChC,SAAS;CACT,KAAK;CACL,OAAO;CACP,MAAM;CACN,UAAU;EAAC;EAAM;EAAQ;EAAa;CAAO;CAC7C,sBAAsB;CACtB,YAAY;EACV,IAAI;GAAE,MAAM;GAAU,WAAW;EAAE;EACnC,MAAM;GAAE,MAAM;GAAU,WAAW;EAAE;EACrC,aAAa,EAAE,MAAM,SAAS;EAC9B,SAAS,EAAE,MAAM,SAAS;EAC1B,WAAW,EACT,MAAM;GAAC;GAAkB;GAAmB;GAAe;EAAkB,EAC/E;EACA,OAAO;GACL,MAAM;GACN,OAAO,EAAE,MAAM,eAAe;EAChC;EACA,SAAS;GACP,MAAM;GACN,sBAAsB;GACtB,YAAY;IACV,SAAS;KAAE,MAAM;KAAS,OAAO,EAAE,MAAM,SAAS;IAAE;IACpD,WAAW;KAAE,MAAM;KAAS,OAAO,EAAE,MAAM,SAAS;IAAE;IACtD,OAAO;KAAE,MAAM;KAAS,OAAO,EAAE,MAAM,SAAS;IAAE;GACpD;EACF;CACF;CACA,OAAO;EACL,MAAM;GACJ,MAAM;GACN,UAAU;IAAC;IAAM;IAAU;IAAY;IAAW;IAAa;GAAY;GAC3E,sBAAsB;GACtB,YAAY;IACV,IAAI;KAAE,MAAM;KAAU,WAAW;IAAE;IACnC,QAAQ,EAAE,MAAM,CAAC,SAAS,MAAM,EAAE;IAClC,aAAa,EAAE,MAAM,SAAS;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