@api-client/core 0.19.22 → 0.19.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/build/src/modeling/ApiModel.d.ts.map +1 -1
  2. package/build/src/modeling/ApiModel.js +37 -13
  3. package/build/src/modeling/ApiModel.js.map +1 -1
  4. package/build/src/modeling/ExposedEntity.d.ts.map +1 -1
  5. package/build/src/modeling/ExposedEntity.js +54 -15
  6. package/build/src/modeling/ExposedEntity.js.map +1 -1
  7. package/build/src/modeling/actions/Action.js +2 -2
  8. package/build/src/modeling/actions/Action.js.map +1 -1
  9. package/build/src/modeling/rules/AccessRule.d.ts +5 -1
  10. package/build/src/modeling/rules/AccessRule.d.ts.map +1 -1
  11. package/build/src/modeling/rules/AccessRule.js +4 -1
  12. package/build/src/modeling/rules/AccessRule.js.map +1 -1
  13. package/build/src/modeling/rules/AllowAuthenticated.d.ts +4 -1
  14. package/build/src/modeling/rules/AllowAuthenticated.d.ts.map +1 -1
  15. package/build/src/modeling/rules/AllowAuthenticated.js +2 -2
  16. package/build/src/modeling/rules/AllowAuthenticated.js.map +1 -1
  17. package/build/src/modeling/rules/AllowPublic.d.ts +4 -1
  18. package/build/src/modeling/rules/AllowPublic.d.ts.map +1 -1
  19. package/build/src/modeling/rules/AllowPublic.js +2 -2
  20. package/build/src/modeling/rules/AllowPublic.js.map +1 -1
  21. package/build/src/modeling/rules/MatchEmailDomain.d.ts +4 -1
  22. package/build/src/modeling/rules/MatchEmailDomain.d.ts.map +1 -1
  23. package/build/src/modeling/rules/MatchEmailDomain.js +2 -2
  24. package/build/src/modeling/rules/MatchEmailDomain.js.map +1 -1
  25. package/build/src/modeling/rules/MatchResourceOwner.d.ts +4 -1
  26. package/build/src/modeling/rules/MatchResourceOwner.d.ts.map +1 -1
  27. package/build/src/modeling/rules/MatchResourceOwner.js +2 -2
  28. package/build/src/modeling/rules/MatchResourceOwner.js.map +1 -1
  29. package/build/src/modeling/rules/MatchUserProperty.d.ts +4 -1
  30. package/build/src/modeling/rules/MatchUserProperty.d.ts.map +1 -1
  31. package/build/src/modeling/rules/MatchUserProperty.js +2 -2
  32. package/build/src/modeling/rules/MatchUserProperty.js.map +1 -1
  33. package/build/src/modeling/rules/MatchUserRole.d.ts +4 -1
  34. package/build/src/modeling/rules/MatchUserRole.d.ts.map +1 -1
  35. package/build/src/modeling/rules/MatchUserRole.js +2 -2
  36. package/build/src/modeling/rules/MatchUserRole.js.map +1 -1
  37. package/build/src/modeling/rules/index.d.ts +4 -1
  38. package/build/src/modeling/rules/index.d.ts.map +1 -1
  39. package/build/src/modeling/rules/index.js +7 -7
  40. package/build/src/modeling/rules/index.js.map +1 -1
  41. package/build/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +1 -1
  43. package/src/modeling/ApiModel.ts +37 -13
  44. package/src/modeling/ExposedEntity.ts +62 -16
  45. package/src/modeling/actions/Action.ts +2 -2
  46. package/src/modeling/rules/AccessRule.ts +8 -1
  47. package/src/modeling/rules/AllowAuthenticated.ts +5 -2
  48. package/src/modeling/rules/AllowPublic.ts +5 -2
  49. package/src/modeling/rules/MatchEmailDomain.ts +5 -2
  50. package/src/modeling/rules/MatchResourceOwner.ts +5 -2
  51. package/src/modeling/rules/MatchUserProperty.ts +5 -2
  52. package/src/modeling/rules/MatchUserRole.ts +5 -2
  53. package/tests/unit/modeling/actions/Action.spec.ts +13 -10
  54. package/tests/unit/modeling/actions/CreateAction.spec.ts +7 -6
  55. package/tests/unit/modeling/actions/DeleteAction.spec.ts +7 -6
  56. package/tests/unit/modeling/actions/ListAction.spec.ts +5 -4
  57. package/tests/unit/modeling/actions/ReadAction.spec.ts +9 -8
  58. package/tests/unit/modeling/actions/SearchAction.spec.ts +5 -4
  59. package/tests/unit/modeling/actions/UpdateAction.spec.ts +7 -6
  60. package/tests/unit/modeling/actions/helpers.ts +7 -0
  61. package/tests/unit/modeling/api_model.spec.ts +3 -1
  62. package/tests/unit/modeling/api_model_expose_entity.spec.ts +5 -17
  63. package/tests/unit/modeling/exposed_entity.spec.ts +6 -2
  64. package/tests/unit/modeling/exposed_entity_actions.spec.ts +0 -4
  65. package/tests/unit/modeling/rules/AccessRule.spec.ts +6 -5
  66. package/tests/unit/modeling/rules/AllowAuthenticated.spec.ts +4 -3
  67. package/tests/unit/modeling/rules/AllowPublic.spec.ts +4 -3
  68. package/tests/unit/modeling/rules/MatchEmailDomain.spec.ts +6 -5
  69. package/tests/unit/modeling/rules/MatchResourceOwner.spec.ts +7 -6
  70. package/tests/unit/modeling/rules/MatchUserProperty.spec.ts +6 -5
  71. package/tests/unit/modeling/rules/MatchUserRole.spec.ts +6 -5
  72. package/tests/unit/modeling/rules/restoring_rules.spec.ts +19 -21
@@ -1 +1 @@
1
- {"version":3,"file":"ExposedEntity.js","sourceRoot":"","sources":["../../../src/modeling/ExposedEntity.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAwB,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAExE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAE5E,OAAO,EAAsB,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAShF;;;;;;;;;;;;;GAaG;IACU,aAAa;sBAAS,WAAW;;;;;;;;;;;;;;;;;;;;;;iBAAjC,aAAc,SAAQ,WAAW;;;kCAe3C,QAAQ,EAAE;0CAeV,QAAQ,EAAE;wCAMV,QAAQ,EAAE;mCA4BV,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;sCAKxB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CA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BACxB,gBAAgB,EAAE,EAAE;oBACpB,gBAAgB,EAAE,EAAE;oBACpB,cAAc,EAAE,EAAE;iBACnB,CAAA;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,GAAG,EAAE,CAAA;gBAC7C,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,GAAG,EAAE,CAAA;gBAC7C,IAAI,CAAC,kBAAkB,CAAC,cAAc,GAAG,EAAE,CAAA;YAC7C,CAAC;YACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACrC,qEAAqE;gBACrE,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACf,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;oBACvD,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACvD,CAAC;gBACD,iEAAiE;gBACjE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;oBAChB,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACzD,CAAC;YACH,CAAC;QACH,CAAC;;;SAheU,aAAa","sourcesContent":["import { observed, toRaw } from '../decorators/observed.js'\nimport { ExposedEntityKind } from '../models/kinds.js'\nimport { nanoid } from '../nanoid.js'\nimport { Action } from './actions/Action.js'\nimport { type ApiActionSchema, restoreAction } from './actions/index.js'\nimport type { ApiModel } from './ApiModel.js'\nimport { ensureLeadingSlash, joinPaths } from './helpers/endpointHelpers.js'\nimport { AccessRule } from './rules/AccessRule.js'\nimport { type RateLimitRule, restoreAccessRule } from './rules/index.js'\nimport { RateLimitingConfiguration } from './rules/RateLimitingConfiguration.js'\nimport type {\n AssociationTarget,\n ExposeOptions,\n ExposeParentRef,\n ExposedEntitySchema,\n PaginationContract,\n} from './types.js'\n\n/**\n * A class that specializes in representing an exposed Data Entity within an API Model.\n *\n * ## Design Note\n * This class enforces strict path constraints (e.g., single-segment collection paths like `/users`,\n * two-segment resource paths like `/users/{id}`).\n * This is an intentional design choice to support a UI paradigm for non-technical users, ensuring that\n * path segments are configured individually at each level of the exposure hierarchy.\n *\n * Flexibility is achieved by chaining exposed entities (parent/child relationships), where the final\n * absolute path is composed of all ancestral paths. See `getAbsoluteResourcePath()` and `getAbsoluteCollectionPath()`.\n *\n * @fires change - Emitted when the exposed entity has changed.\n */\nexport class ExposedEntity extends EventTarget {\n /**\n * The exposed entity kind recognizable by the ecosystem.\n */\n kind: typeof ExposedEntityKind\n\n /**\n * The unique key of the exposed entity.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n\n /**\n * A pointer to a Data Entity from the Data Domain.\n */\n @observed() accessor entity: AssociationTarget\n\n /**\n * Indicates whether this exposure has a collection endpoint.\n * A collection endpoint is optional for nested exposures where the association is 1:1\n * and the schema is embedded directly under the parent resource.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n hasCollection: boolean\n\n /**\n * Path to the collection endpoint for this exposure.\n * Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.\n */\n @observed() accessor collectionPath: string | undefined\n\n /**\n * Path to the resource endpoint for this exposure.\n * Starts with '/'. For 1:1 nested exposures the resource path typically does not include an id segment.\n */\n @observed() accessor resourcePath: string\n\n /**\n * Whether this exposure is a root exposure (top-level collection).\n * If this is set then the `parent` reference must be populated.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n isRoot?: boolean\n\n /**\n * Parent reference when this exposure was created via following an association.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n parent?: ExposeParentRef\n\n /**\n * Expose-time config used to create this exposure (persisted for auditing/UI).\n * This is only populated for the root exposure. All children exposures inherit this config.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n exposeOptions?: ExposeOptions\n\n /**\n * The list of enabled API actions for this exposure (List/Read/Create/etc.)\n */\n @observed({ deep: true }) accessor actions: Action[]\n\n /**\n * Optional array of access rules that define the access control policies for this exposure.\n */\n @observed({ deep: true }) accessor accessRule: AccessRule[] | undefined\n\n /**\n * Optional configuration for rate limiting for this exposure.\n */\n @observed() accessor rateLimiting: RateLimitingConfiguration | undefined\n\n /**\n * Pagination contract for this exposure.\n * Defines a list of fields that can be used for filtering, sorting, and searching.\n * The pagination contract is only valid for that specific exposure. It cannot be inherited\n * by other exposures.\n */\n @observed({ deep: true }) accessor paginationContract: PaginationContract | undefined\n\n /**\n * When true, generation for this exposure hit configured limits\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n truncated?: boolean\n\n /**\n * When the notifying flag is set to true,\n * the domain is pending a notification.\n * No other notifications will be sent until\n * the current notification is sent.\n */\n #notifying = false\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\n /**\n * A reference to the parent API Model instance.\n */\n api: ApiModel\n\n static createSchema(input: Partial<ExposedEntitySchema> = {}): ExposedEntitySchema {\n const {\n key = nanoid(),\n entity = { key: '' },\n collectionPath,\n resourcePath = '/',\n hasCollection = true,\n isRoot,\n parent,\n exposeOptions,\n actions = [],\n accessRule,\n rateLimiting,\n truncated,\n paginationContract,\n } = input\n const result: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key,\n entity: { ...entity },\n hasCollection,\n resourcePath,\n actions: actions.map((a) => ({ ...a })),\n }\n if (collectionPath !== undefined) {\n result.collectionPath = collectionPath\n }\n if (isRoot !== undefined) {\n result.isRoot = isRoot\n }\n if (parent !== undefined) {\n result.parent = { ...parent }\n }\n if (exposeOptions !== undefined) {\n result.exposeOptions = { ...exposeOptions }\n }\n if (Array.isArray(accessRule)) {\n result.accessRule = accessRule.map((ar) => ({ ...ar }))\n }\n if (rateLimiting !== undefined) {\n result.rateLimiting = { ...rateLimiting }\n }\n if (truncated !== undefined) {\n result.truncated = truncated\n }\n if (paginationContract !== undefined) {\n result.paginationContract = structuredClone(paginationContract)\n }\n return result\n }\n\n constructor(model: ApiModel, state?: Partial<ExposedEntitySchema>) {\n super()\n this.api = model\n const init = ExposedEntity.createSchema(state)\n this.kind = init.kind\n this.key = init.key\n this.entity = init.entity\n this.hasCollection = init.hasCollection\n this.collectionPath = init.collectionPath\n this.resourcePath = init.resourcePath\n this.isRoot = init.isRoot\n this.parent = init.parent\n this.exposeOptions = init.exposeOptions\n this.actions = init.actions ? init.actions.map((a) => restoreAction(this, a)) : []\n this.accessRule = init.accessRule ? init.accessRule.map((ar) => restoreAccessRule(ar)) : []\n if (init.rateLimiting) {\n this.rateLimiting = new RateLimitingConfiguration(init.rateLimiting)\n }\n this.truncated = init.truncated\n if (init.paginationContract) {\n this.paginationContract = structuredClone(init.paginationContract)\n }\n this.#initializing = false\n }\n\n notifyChange() {\n if (this.#notifying || this.#initializing) {\n return\n }\n this.#notifying = true\n queueMicrotask(() => {\n this.#notifying = false\n const event = new Event('change')\n this.dispatchEvent(event)\n })\n }\n\n toJSON(): ExposedEntitySchema {\n const result: ExposedEntitySchema = {\n kind: this.kind,\n key: this.key,\n entity: { ...this.entity },\n resourcePath: this.resourcePath,\n actions: this.actions.map((a) => a.toJSON()),\n hasCollection: this.hasCollection,\n }\n if (this.collectionPath !== undefined) {\n result.collectionPath = this.collectionPath\n }\n if (this.isRoot !== undefined) {\n result.isRoot = this.isRoot\n }\n if (this.parent !== undefined) {\n result.parent = { ...this.parent }\n }\n if (this.exposeOptions !== undefined) {\n result.exposeOptions = { ...this.exposeOptions }\n }\n if (Array.isArray(this.accessRule) && this.accessRule.length > 0) {\n result.accessRule = this.accessRule.map((ar) => ar.toJSON())\n }\n if (this.rateLimiting !== undefined) {\n result.rateLimiting = this.rateLimiting.toJSON()\n }\n if (this.truncated !== undefined) {\n result.truncated = this.truncated\n }\n if (this.paginationContract) {\n result.paginationContract = structuredClone(toRaw(this, this.paginationContract))\n }\n return result\n }\n\n /**\n * Sets a new collection path for this exposed entity.\n *\n * It:\n * - updates the collectionPath property\n * - updates the absoluteCollectionPath property accordingly\n * - updates the resourcePath accordingly.\n * @param path The new path to set.\n */\n setCollectionPath(path: string) {\n if (!this.hasCollection) {\n throw new Error(`Cannot set collection path on an exposure that does not have a collection`)\n }\n const cleaned = ensureLeadingSlash(path)\n // Ensure exactly one non-empty segment\n const segments = cleaned.split('/').filter(Boolean)\n if (segments.length !== 1) {\n throw new Error(`Collection path must contain exactly one segment. Received: \"${path}\"`)\n }\n const normalizedCollection = `/${segments[0]}`\n\n // Check for collision if this is a root entity\n if (this.isRoot) {\n const collision = this.api.findCollectionPathCollision(normalizedCollection, this.key)\n if (collision) {\n throw new Error(`Collection path \"${normalizedCollection}\" is already in use by another root entity.`)\n }\n }\n\n // Preserve current parameter name if present, otherwise default to {id}\n let param = '{id}'\n if (this.resourcePath) {\n const curSegments = this.resourcePath.split('/').filter(Boolean)\n const maybeParam = curSegments[1]\n if (maybeParam && /^\\{[A-Za-z_][A-Za-z0-9_]*\\}$/.test(maybeParam)) {\n param = maybeParam\n }\n }\n const nextResource = `${normalizedCollection}/${param}`\n this.collectionPath = normalizedCollection\n this.resourcePath = nextResource\n // rely on ApiModel.exposes deep observation to notify on property sets\n }\n\n /**\n * Sets a new resource path for this exposed entity.\n *\n * Rules:\n * - Must start with '/'.\n * - If this exposure has a collection, the path must be exactly the collection path plus a single\n * parameter segment (e.g. `/products/{productId}`) and only the parameter name may vary.\n * - If this exposure does NOT have a collection, the path can be any two segments (e.g. `/profile/{id}` or `/a/b`).\n */\n setResourcePath(path: string) {\n const cleaned = ensureLeadingSlash(path)\n const segments = cleaned.split('/').filter(Boolean)\n\n if (this.hasCollection) {\n if (!this.collectionPath) {\n throw new Error('Cannot set resource path: missing collection path for this exposure')\n }\n const colSegments = this.collectionPath.split('/').filter(Boolean)\n if (colSegments.length !== 1) {\n throw new Error(`Invalid stored collection path \"${this.collectionPath}\"`)\n }\n if (segments.length !== 2) {\n throw new Error(`Resource path must be exactly two segments (collection + parameter). Received: \"${cleaned}\"`)\n }\n const [s1, s2] = segments\n if (s1 !== colSegments[0]) {\n throw new Error(`Resource path must start with the collection segment \"${colSegments[0]}\". Received: \"${s1}\"`)\n }\n // s2 must be a parameter segment {name}\n if (!/^\\{[A-Za-z_][A-Za-z0-9_]*\\}$/.test(s2)) {\n throw new Error(`The second segment must be a parameter in braces, e.g. {id}. Received: \"${s2}\"`)\n }\n if (this.resourcePath !== cleaned) {\n this.resourcePath = `/${s1}/${s2}`\n }\n return\n }\n\n // No collection: allow exactly one segment\n if (segments.length !== 1) {\n throw new Error(\n `Resource path must contain exactly one segment when no collection is present. Received: \"${cleaned}\"`\n )\n }\n // Check for collision if this is a root entity (singleton case)\n if (this.isRoot) {\n const collision = this.api.findResourcePathCollision(cleaned, this.key)\n if (collision) {\n throw new Error(`Resource path \"${cleaned}\" is already in use by another root entity.`)\n }\n }\n\n if (this.resourcePath !== cleaned) {\n this.resourcePath = `/${segments[0]}`\n }\n }\n\n /**\n * Computes the absolute path for this exposure's resource endpoint by\n * walking up the exposure tree using `parent.key` until reaching a root exposure.\n * The absolute path is composed by concatenating each ancestor's resource path\n * with this exposure's resource path.\n */\n getAbsoluteResourcePath(): string {\n let absolute = ensureLeadingSlash(this.resourcePath)\n // Traverse parents, always joining with the parent's resource path\n let parentKey = this.parent?.key\n while (parentKey) {\n const parent = this.api.exposes.get(parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.resourcePath)\n absolute = joinPaths(parentResource, absolute)\n parentKey = parent.parent?.key\n }\n return absolute\n }\n\n /**\n * Computes the absolute path for this exposure's collection endpoint (if any)\n * by walking up the exposure tree using `parent.key` until reaching a root exposure.\n * The absolute path is composed by concatenating each ancestor's resource path\n * with this exposure's collection path.\n * Returns undefined if this exposure has no collection.\n */\n getAbsoluteCollectionPath(): string | undefined {\n if (!this.hasCollection || !this.collectionPath) return undefined\n let absolute = ensureLeadingSlash(this.collectionPath)\n // Traverse parents, always joining with the parent's resource path\n let parentKey = this.parent?.key\n while (parentKey) {\n const parent = this.api.exposes.get(parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.resourcePath)\n absolute = joinPaths(parentResource, absolute)\n parentKey = parent.parent?.key\n }\n return absolute\n }\n\n /**\n * Returns all access rules for this exposure, including the ones from all the parents up to the API.\n */\n getAllRules(): AccessRule[] {\n const rules: AccessRule[] = []\n this.api.accessRule.forEach((rule) => rules.push(rule))\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.accessRule) {\n rules.push(...current.accessRule)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rules\n }\n\n /**\n * Returns all rate limiters for this exposure, including the ones from all the parents up to the API.\n */\n getAllRateLimiters(): RateLimitingConfiguration[] {\n const rateLimiters: RateLimitingConfiguration[] = []\n if (this.api.rateLimiting) {\n rateLimiters.push(this.api.rateLimiting)\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.rateLimiting) {\n rateLimiters.push(current.rateLimiting)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rateLimiters\n }\n\n /**\n * Returns all rate limiter rules for this exposure, including the ones from all the parents up to the API.\n * Similar to the getAllRules() method, but it flattens the rate limiters into a single list of rules.\n */\n getAllRateLimiterRules(): RateLimitRule[] {\n const rules: RateLimitRule[] = []\n if (this.api.rateLimiting) {\n rules.push(...this.api.rateLimiting.rules)\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.rateLimiting) {\n rules.push(...current.rateLimiting.rules)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rules\n }\n\n /**\n * Adds an action to the exposure.\n * @param schema The schema of the action to add.\n * @returns The added action.\n */\n addAction(schema: ApiActionSchema): Action {\n if (this.actions.some((action) => action.kind === schema.kind)) {\n throw new Error(`Action of kind \"${schema.kind}\" already exists for this exposure`)\n }\n const action = restoreAction(this, schema)\n this.actions.push(action)\n return action\n }\n\n /**\n * Scans for the indexed and search properties in the `DomainEntity`\n * and recreates the `paginationContract` with all indexed/searched fields.\n *\n * Note, this is a destructive action designed as a helper function when creating\n * an exposed entity to fill up default values. Should not be used if the user\n * didn't request that.\n */\n createPaginationContract(): void {\n const entity = this.api.domain?.findEntity(this.entity.key, this.entity.domain)\n if (!entity) {\n throw new Error(`Entity \"${this.entity.key}\" not found\"`)\n }\n if (!this.paginationContract) {\n this.paginationContract = {\n filterableFields: [],\n searchableFields: [],\n sortableFields: [],\n }\n } else {\n this.paginationContract.filterableFields = []\n this.paginationContract.searchableFields = []\n this.paginationContract.sortableFields = []\n }\n for (const prop of entity.properties) {\n // indexed properties allow sorting and filtering in the List action.\n if (prop.index) {\n this.paginationContract.filterableFields.push(prop.key)\n this.paginationContract.sortableFields.push(prop.key)\n }\n // search properties allow full-text search in the Search action.\n if (prop.search) {\n this.paginationContract.searchableFields.push(prop.key)\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ExposedEntity.js","sourceRoot":"","sources":["../../../src/modeling/ExposedEntity.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAwB,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAExE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAE5E,OAAO,EAAsB,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAShF;;;;;;;;;;;;;GAaG;IACU,aAAa;sBAAS,WAAW;;;;;;;;;;;;;;;;;;;;;;iBAA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C,gBAAgB,GAAG,EAAE,CAAA;gBAC7C,IAAI,CAAC,kBAAkB,CAAC,cAAc,GAAG,EAAE,CAAA;YAC7C,CAAC;YACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACrC,qEAAqE;gBACrE,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACf,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;oBACvD,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACvD,CAAC;gBACD,iEAAiE;gBACjE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;oBAChB,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACzD,CAAC;YACH,CAAC;QACH,CAAC;;;SA7gBU,aAAa","sourcesContent":["import { observed, toRaw } from '../decorators/observed.js'\nimport { Exception } from '../exceptions/exception.js'\nimport { ExposedEntityKind } from '../models/kinds.js'\nimport { nanoid } from '../nanoid.js'\nimport { Action } from './actions/Action.js'\nimport { type ApiActionSchema, restoreAction } from './actions/index.js'\nimport type { ApiModel } from './ApiModel.js'\nimport { ensureLeadingSlash, joinPaths } from './helpers/endpointHelpers.js'\nimport { AccessRule } from './rules/AccessRule.js'\nimport { type RateLimitRule, restoreAccessRule } from './rules/index.js'\nimport { RateLimitingConfiguration } from './rules/RateLimitingConfiguration.js'\nimport type {\n AssociationTarget,\n ExposeOptions,\n ExposeParentRef,\n ExposedEntitySchema,\n PaginationContract,\n} from './types.js'\n\n/**\n * A class that specializes in representing an exposed Data Entity within an API Model.\n *\n * ## Design Note\n * This class enforces strict path constraints (e.g., single-segment collection paths like `/users`,\n * two-segment resource paths like `/users/{id}`).\n * This is an intentional design choice to support a UI paradigm for non-technical users, ensuring that\n * path segments are configured individually at each level of the exposure hierarchy.\n *\n * Flexibility is achieved by chaining exposed entities (parent/child relationships), where the final\n * absolute path is composed of all ancestral paths. See `getAbsoluteResourcePath()` and `getAbsoluteCollectionPath()`.\n *\n * @fires change - Emitted when the exposed entity has changed.\n */\nexport class ExposedEntity extends EventTarget {\n /**\n * The exposed entity kind recognizable by the ecosystem.\n */\n kind: typeof ExposedEntityKind\n\n /**\n * The unique key of the exposed entity.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n\n /**\n * A pointer to a Data Entity from the Data Domain.\n */\n @observed() accessor entity: AssociationTarget\n\n /**\n * Indicates whether this exposure has a collection endpoint.\n * A collection endpoint is optional for nested exposures where the association is 1:1\n * and the schema is embedded directly under the parent resource.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n hasCollection: boolean\n\n /**\n * Path to the collection endpoint for this exposure.\n * Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.\n */\n @observed() accessor collectionPath: string | undefined\n\n /**\n * Path to the resource endpoint for this exposure.\n * Starts with '/'. For 1:1 nested exposures the resource path typically does not include an id segment.\n */\n @observed() accessor resourcePath: string\n\n /**\n * Whether this exposure is a root exposure (top-level collection).\n * If this is set then the `parent` reference must be populated.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n isRoot?: boolean\n\n /**\n * Parent reference when this exposure was created via following an association.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n parent?: ExposeParentRef\n\n /**\n * Expose-time config used to create this exposure (persisted for auditing/UI).\n * This is only populated for the root exposure. All children exposures inherit this config.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n exposeOptions?: ExposeOptions\n\n /**\n * The list of enabled API actions for this exposure (List/Read/Create/etc.)\n */\n @observed() accessor actions: Action[]\n\n /**\n * Optional array of access rules that define the access control policies for this exposure.\n */\n @observed() accessor accessRule: AccessRule[] | undefined\n\n /**\n * Optional configuration for rate limiting for this exposure.\n */\n @observed() accessor rateLimiting: RateLimitingConfiguration | undefined\n\n /**\n * Pagination contract for this exposure.\n * Defines a list of fields that can be used for filtering, sorting, and searching.\n * The pagination contract is only valid for that specific exposure. It cannot be inherited\n * by other exposures.\n */\n @observed({ deep: true }) accessor paginationContract: PaginationContract | undefined\n\n /**\n * When true, generation for this exposure hit configured limits\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n truncated?: boolean\n\n /**\n * When the notifying flag is set to true,\n * the domain is pending a notification.\n * No other notifications will be sent until\n * the current notification is sent.\n */\n #notifying = false\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\n /**\n * A reference to the parent API Model instance.\n */\n api: ApiModel\n\n static createSchema(input: Partial<ExposedEntitySchema> = {}): ExposedEntitySchema {\n const {\n key = nanoid(),\n entity = { key: '' },\n collectionPath,\n resourcePath = '/',\n hasCollection = true,\n isRoot,\n parent,\n exposeOptions,\n actions = [],\n accessRule,\n rateLimiting,\n truncated,\n paginationContract,\n } = input\n const result: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key,\n entity: { ...entity },\n hasCollection,\n resourcePath,\n actions: actions.map((a) => ({ ...a })),\n }\n if (collectionPath !== undefined) {\n result.collectionPath = collectionPath\n }\n if (isRoot !== undefined) {\n result.isRoot = isRoot\n }\n if (parent !== undefined) {\n result.parent = { ...parent }\n }\n if (exposeOptions !== undefined) {\n result.exposeOptions = { ...exposeOptions }\n }\n if (Array.isArray(accessRule)) {\n result.accessRule = accessRule.map((ar) => ({ ...ar }))\n }\n if (rateLimiting !== undefined) {\n result.rateLimiting = { ...rateLimiting }\n }\n if (truncated !== undefined) {\n result.truncated = truncated\n }\n if (paginationContract !== undefined) {\n result.paginationContract = structuredClone(paginationContract)\n }\n return result\n }\n\n constructor(model: ApiModel, state?: Partial<ExposedEntitySchema>) {\n super()\n this.api = model\n const init = ExposedEntity.createSchema(state)\n this.kind = init.kind\n this.key = init.key\n this.entity = init.entity\n this.hasCollection = init.hasCollection\n this.collectionPath = init.collectionPath\n this.resourcePath = init.resourcePath\n this.isRoot = init.isRoot\n this.parent = init.parent\n this.exposeOptions = init.exposeOptions\n this.actions = init.actions ? init.actions.map((a) => restoreAction(this, a)) : []\n this.accessRule = init.accessRule ? init.accessRule.map((ar) => restoreAccessRule(this, ar)) : []\n if (init.rateLimiting) {\n this.rateLimiting = new RateLimitingConfiguration(init.rateLimiting)\n }\n this.truncated = init.truncated\n if (init.paginationContract) {\n this.paginationContract = structuredClone(init.paginationContract)\n }\n this.#initializing = false\n }\n\n notifyChange() {\n if (this.#notifying || this.#initializing) {\n return\n }\n this.#notifying = true\n queueMicrotask(() => {\n this.#notifying = false\n const event = new Event('change')\n this.dispatchEvent(event)\n this.api.notifyChange()\n })\n }\n\n toJSON(): ExposedEntitySchema {\n const result: ExposedEntitySchema = {\n kind: this.kind,\n key: this.key,\n entity: { ...this.entity },\n resourcePath: this.resourcePath,\n actions: this.actions.map((a) => a.toJSON()),\n hasCollection: this.hasCollection,\n }\n if (this.collectionPath !== undefined) {\n result.collectionPath = this.collectionPath\n }\n if (this.isRoot !== undefined) {\n result.isRoot = this.isRoot\n }\n if (this.parent !== undefined) {\n result.parent = { ...this.parent }\n }\n if (this.exposeOptions !== undefined) {\n result.exposeOptions = { ...this.exposeOptions }\n }\n if (Array.isArray(this.accessRule) && this.accessRule.length > 0) {\n result.accessRule = this.accessRule.map((ar) => ar.toJSON())\n }\n if (this.rateLimiting !== undefined) {\n result.rateLimiting = this.rateLimiting.toJSON()\n }\n if (this.truncated !== undefined) {\n result.truncated = this.truncated\n }\n if (this.paginationContract) {\n result.paginationContract = structuredClone(toRaw(this, this.paginationContract))\n }\n return result\n }\n\n /**\n * Sets a new collection path for this exposed entity.\n *\n * It:\n * - updates the collectionPath property\n * - updates the absoluteCollectionPath property accordingly\n * - updates the resourcePath accordingly.\n * @param path The new path to set.\n */\n setCollectionPath(path: string) {\n if (!this.hasCollection) {\n throw new Exception(`Cannot set collection path on an exposure that does not have a collection`, {\n code: 'E_PATH_MISSING',\n help: 'The exposed entity you are trying to set a collection path for does not have a collection.',\n })\n }\n const cleaned = ensureLeadingSlash(path)\n // Ensure exactly one non-empty segment\n const segments = cleaned.split('/').filter(Boolean)\n if (segments.length !== 1) {\n throw new Exception(`Collection path must contain exactly one segment. Received: \"${path}\"`, {\n code: 'E_PATH_SEGMENT_SIZE',\n help: 'The set path must have a single path segment (e.g., `/products`)',\n })\n }\n const normalizedCollection = `/${segments[0]}`\n\n // Check for collision if this is a root entity\n if (this.isRoot) {\n const collision = this.api.findCollectionPathCollision(normalizedCollection, this.key)\n if (collision) {\n throw new Exception(`Collection path \"${normalizedCollection}\" is already in use by another root entity.`, {\n code: 'E_PATH_INUSE',\n help: 'The set path is already in use by another root entity.',\n })\n }\n }\n\n // Preserve current parameter name if present, otherwise default to {id}\n let param = '{id}'\n if (this.resourcePath) {\n const curSegments = this.resourcePath.split('/').filter(Boolean)\n const maybeParam = curSegments[1]\n if (maybeParam && /^\\{[A-Za-z_][A-Za-z0-9_]*\\}$/.test(maybeParam)) {\n param = maybeParam\n }\n }\n const nextResource = `${normalizedCollection}/${param}`\n this.collectionPath = normalizedCollection\n this.resourcePath = nextResource\n // rely on ApiModel.exposes deep observation to notify on property sets\n }\n\n /**\n * Sets a new resource path for this exposed entity.\n *\n * Rules:\n * - Must start with '/'.\n * - If this exposure has a collection, the path must be exactly the collection path plus a single\n * parameter segment (e.g. `/products/{productId}`) and only the parameter name may vary.\n * - If this exposure does NOT have a collection, the path can be any two segments (e.g. `/profile/{id}` or `/a/b`).\n */\n setResourcePath(path: string) {\n const cleaned = ensureLeadingSlash(path)\n const segments = cleaned.split('/').filter(Boolean)\n\n if (this.hasCollection) {\n if (!this.collectionPath) {\n // Why do we throw this error? We should just create it from the resource path...\n throw new Exception('Cannot set resource path: missing collection path for this exposure', {\n code: 'E_PATH_MISSING',\n help: 'Set the collection path on the exposed entity first.',\n })\n }\n const colSegments = this.collectionPath.split('/').filter(Boolean)\n if (colSegments.length !== 1) {\n throw new Exception(`Invalid stored collection path \"${this.collectionPath}\"`, {\n code: 'E_PATH_SEGMENT_SIZE',\n help: 'The set collection path must have a single path segment (e.g., `/products`)',\n })\n }\n if (segments.length !== 2) {\n throw new Exception(\n `Resource path must be exactly two segments (collection + parameter). Received: \"${cleaned}\"`,\n {\n code: 'E_PATH_SEGMENT_SIZE',\n help: 'The set resource path must have exactly two segments (collection + parameter).',\n }\n )\n }\n const [s1, s2] = segments\n if (s1 !== colSegments[0]) {\n throw new Exception(\n `Resource path must start with the collection segment \"${colSegments[0]}\". Received: \"${s1}\"`,\n {\n code: 'E_PATH_MISMATCH',\n help: 'Set the resource path to the same value as the collection path + the parameter value.',\n }\n )\n }\n // s2 must be a parameter segment {name}\n if (!/^\\{[A-Za-z_][A-Za-z0-9_]*\\}$/.test(s2)) {\n throw new Exception(`The second segment must be a parameter in braces, e.g. {id}. Received: \"${s2}\"`, {\n code: 'E_PARAMETER_INVALID',\n help: 'Use the braces to surround the parameter name, e.g., {productId}.',\n })\n }\n if (this.resourcePath !== cleaned) {\n this.resourcePath = `/${s1}/${s2}`\n }\n return\n }\n\n // No collection: allow exactly one segment\n if (segments.length !== 1) {\n throw new Exception(\n `Resource path must contain exactly one segment when no collection is present. Received: \"${cleaned}\"`,\n {\n code: 'E_PATH_SEGMENT_SIZE',\n help: 'The set resource path must have exactly one segment.',\n }\n )\n }\n // Check for collision if this is a root entity (singleton case)\n if (this.isRoot) {\n const collision = this.api.findResourcePathCollision(cleaned, this.key)\n if (collision) {\n throw new Exception(`Resource path \"${cleaned}\" is already in use by another root entity.`, {\n code: 'E_PATH_INUSE',\n help: 'The set path is already in use by another root entity.',\n })\n }\n }\n\n if (this.resourcePath !== cleaned) {\n this.resourcePath = `/${segments[0]}`\n }\n }\n\n /**\n * Computes the absolute path for this exposure's resource endpoint by\n * walking up the exposure tree using `parent.key` until reaching a root exposure.\n * The absolute path is composed by concatenating each ancestor's resource path\n * with this exposure's resource path.\n */\n getAbsoluteResourcePath(): string {\n let absolute = ensureLeadingSlash(this.resourcePath)\n // Traverse parents, always joining with the parent's resource path\n let parentKey = this.parent?.key\n while (parentKey) {\n const parent = this.api.exposes.get(parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.resourcePath)\n absolute = joinPaths(parentResource, absolute)\n parentKey = parent.parent?.key\n }\n return absolute\n }\n\n /**\n * Computes the absolute path for this exposure's collection endpoint (if any)\n * by walking up the exposure tree using `parent.key` until reaching a root exposure.\n * The absolute path is composed by concatenating each ancestor's resource path\n * with this exposure's collection path.\n * Returns undefined if this exposure has no collection.\n */\n getAbsoluteCollectionPath(): string | undefined {\n if (!this.hasCollection || !this.collectionPath) return undefined\n let absolute = ensureLeadingSlash(this.collectionPath)\n // Traverse parents, always joining with the parent's resource path\n let parentKey = this.parent?.key\n while (parentKey) {\n const parent = this.api.exposes.get(parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.resourcePath)\n absolute = joinPaths(parentResource, absolute)\n parentKey = parent.parent?.key\n }\n return absolute\n }\n\n /**\n * Returns all access rules for this exposure, including the ones from all the parents up to the API.\n */\n getAllRules(): AccessRule[] {\n const rules: AccessRule[] = []\n this.api.accessRule.forEach((rule) => rules.push(rule))\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.accessRule) {\n rules.push(...current.accessRule)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rules\n }\n\n /**\n * Returns all rate limiters for this exposure, including the ones from all the parents up to the API.\n */\n getAllRateLimiters(): RateLimitingConfiguration[] {\n const rateLimiters: RateLimitingConfiguration[] = []\n if (this.api.rateLimiting) {\n rateLimiters.push(this.api.rateLimiting)\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.rateLimiting) {\n rateLimiters.push(current.rateLimiting)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rateLimiters\n }\n\n /**\n * Returns all rate limiter rules for this exposure, including the ones from all the parents up to the API.\n * Similar to the getAllRules() method, but it flattens the rate limiters into a single list of rules.\n */\n getAllRateLimiterRules(): RateLimitRule[] {\n const rules: RateLimitRule[] = []\n if (this.api.rateLimiting) {\n rules.push(...this.api.rateLimiting.rules)\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.rateLimiting) {\n rules.push(...current.rateLimiting.rules)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rules\n }\n\n /**\n * Adds an action to the exposure.\n * @param schema The schema of the action to add.\n * @returns The added action.\n */\n addAction(schema: ApiActionSchema): Action {\n if (this.actions.some((action) => action.kind === schema.kind)) {\n throw new Exception(`Action of kind \"${schema.kind}\" already exists for this exposure`, {\n code: 'E_ACTION_USED',\n help: \"There's no need to add an API action again.\",\n })\n }\n const action = restoreAction(this, schema)\n this.actions.push(action)\n return action\n }\n\n /**\n * Scans for the indexed and search properties in the `DomainEntity`\n * and recreates the `paginationContract` with all indexed/searched fields.\n *\n * Note, this is a destructive action designed as a helper function when creating\n * an exposed entity to fill up default values. Should not be used if the user\n * didn't request that.\n */\n createPaginationContract(): void {\n const entity = this.api.domain?.findEntity(this.entity.key, this.entity.domain)\n if (!entity) {\n throw new Exception(`Entity \"${this.entity.key}\" not found\"`, {\n code: 'E_ENTITY_NOT_FOUND',\n help: 'The set entity does not exist.',\n })\n }\n if (!this.paginationContract) {\n this.paginationContract = {\n filterableFields: [],\n searchableFields: [],\n sortableFields: [],\n }\n } else {\n this.paginationContract.filterableFields = []\n this.paginationContract.searchableFields = []\n this.paginationContract.sortableFields = []\n }\n for (const prop of entity.properties) {\n // indexed properties allow sorting and filtering in the List action.\n if (prop.index) {\n this.paginationContract.filterableFields.push(prop.key)\n this.paginationContract.sortableFields.push(prop.key)\n }\n // search properties allow full-text search in the Search action.\n if (prop.search) {\n this.paginationContract.searchableFields.push(prop.key)\n }\n }\n }\n}\n"]}
@@ -41,12 +41,12 @@ let Action = (() => {
41
41
  super();
42
42
  this.parent = parent;
43
43
  this.kind = state.kind || '';
44
- this.accessRule = state.accessRule ? state.accessRule.map((rule) => restoreAccessRule(rule)) : [];
44
+ this.accessRule = state.accessRule ? state.accessRule.map((rule) => restoreAccessRule(this, rule)) : [];
45
45
  this.rateLimiting = state.rateLimiting ? new RateLimitingConfiguration(state.rateLimiting) : undefined;
46
46
  }
47
47
  notifyChange() {
48
48
  this.dispatchEvent(new Event('change'));
49
- // this.parent.api.notifyChange()
49
+ this.parent.notifyChange();
50
50
  }
51
51
  toJSON() {
52
52
  const result = {
@@ -1 +1 @@
1
- {"version":3,"file":"Action.js","sourceRoot":"","sources":["../../../../src/modeling/actions/Action.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,yBAAyB,EAAmC,MAAM,uCAAuC,CAAA;AAClH,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AA+BrD;;GAEG;IACU,MAAM;sBAAS,WAAW;;;;;;;;;;iBAA1B,MAAO,SAAQ,WAAW;;;gCACpC,QAAQ,EAAE;sCACV,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;wCACxB,QAAQ,EAAE;YAFC,iKAAS,IAAI,6BAAJ,IAAI,mFAAQ;YACP,mLAAS,UAAU,6BAAV,UAAU,+FAAc;YAC/C,yLAAS,YAAY,6BAAZ,YAAY,mGAAuC;;;QAF5D,6EAAqB;QAArB,IAAS,IAAI,0CAAQ;QAArB,IAAS,IAAI,gDAAQ;QACP,6IAAiC;QAAjC,IAAS,UAAU,gDAAc;QAAjC,IAAS,UAAU,sDAAc;QAC/C,uJAA4D;QAA5D,IAAS,YAAY,kDAAuC;QAA5D,IAAS,YAAY,wDAAuC;QAE9D,MAAM,4DAAe;QAE/B,YAAY,MAAqB,EAAE,QAA+B,EAAE;YAClE,KAAK,EAAE,CAAA;YACP,IAAI,CAAC,MAAM,GAA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kBAAkB,EAAE,CAAA;YACrD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YACtC,CAAC;YACD,OAAO,YAAY,CAAA;QACrB,CAAC;;;SAlDU,MAAM","sourcesContent":["import { AccessRule, AccessRuleSchema } from '../rules/AccessRule.js'\nimport { RateLimitingConfiguration, RateLimitingConfigurationSchema } from '../rules/RateLimitingConfiguration.js'\nimport { observed } from '../../decorators/observed.js'\nimport { restoreAccessRule } from '../rules/index.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\n\n/**\n * A base interface for common properties across all actions.\n */\nexport interface ActionSchema {\n /**\n * The specific kind of action (e.g., 'List', 'Read', etc.)\n */\n kind: string\n /**\n * Access control rules defining who can perform this action. It is only applied if the\n * authorization strategy is set to 'RBAC'.\n * If no rules grant access, it's denied by default making it essentially private.\n *\n * Note, the API can defined top level access rules that apply to all actions. If this property is set,\n * it overrides the top level access rules for this specific action.\n *\n * It is an ordered list, meaning the first rule that matches the user will be applied.\n * If multiple rules match, the first one in the list takes precedence.\n * If no rules match, the action is denied.\n */\n accessRule?: AccessRuleSchema[]\n /**\n * Optional configuration for action-wide rate limiting and throttling.\n * Defines rules to protect the action from overuse.\n */\n rateLimiting?: RateLimitingConfigurationSchema\n}\n\n/**\n * A base class for common properties across all actions.\n */\nexport class Action extends EventTarget implements ActionSchema {\n @observed() accessor kind: string\n @observed({ deep: true }) accessor accessRule: AccessRule[]\n @observed() accessor rateLimiting: RateLimitingConfiguration | undefined\n\n protected parent: ExposedEntity\n\n constructor(parent: ExposedEntity, state: Partial<ActionSchema> = {}) {\n super()\n this.parent = parent\n this.kind = state.kind || ''\n this.accessRule = state.accessRule ? state.accessRule.map((rule) => restoreAccessRule(rule)) : []\n this.rateLimiting = state.rateLimiting ? new RateLimitingConfiguration(state.rateLimiting) : undefined\n }\n\n notifyChange() {\n this.dispatchEvent(new Event('change'))\n // this.parent.api.notifyChange()\n }\n\n toJSON(): ActionSchema {\n const result: ActionSchema = {\n kind: this.kind,\n }\n if (this.accessRule.length) {\n result.accessRule = this.accessRule.map((rule) => rule.toJSON())\n }\n if (this.rateLimiting) {\n result.rateLimiting = this.rateLimiting.toJSON()\n }\n return result\n }\n\n /**\n * Returns all access rules for this action, including the ones from all the parents up to the API.\n */\n getAllRules(): AccessRule[] {\n const rules: AccessRule[] = [...this.parent.getAllRules(), ...this.accessRule]\n return rules\n }\n\n /**\n * Returns all rate limiters for this action, including the ones from all the parents up to the API.\n */\n getAllRateLimiters(): RateLimitingConfiguration[] {\n const rateLimiters = this.parent.getAllRateLimiters()\n if (this.rateLimiting) {\n rateLimiters.push(this.rateLimiting)\n }\n return rateLimiters\n }\n}\n"]}
1
+ {"version":3,"file":"Action.js","sourceRoot":"","sources":["../../../../src/modeling/actions/Action.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,yBAAyB,EAAmC,MAAM,uCAAuC,CAAA;AAClH,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AA+BrD;;GAEG;IACU,MAAM;sBAAS,WAAW;;;;;;;;;;iBAA1B,MAAO,SAAQ,WAAW;;;gCACpC,QAAQ,EAAE;sCACV,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;wCACxB,QAAQ,EAAE;YAFC,iKAAS,IAAI,6BAAJ,IAAI,mFAAQ;YACP,mLAAS,UAAU,6BAAV,UAAU,+FAAc;YAC/C,yLAAS,YAAY,6BAAZ,YAAY,mGAAuC;;;QAF5D,6EAAqB;QAArB,IAAS,IAAI,0CAAQ;QAArB,IAAS,IAAI,gDAAQ;QACP,6IAAiC;QAAjC,IAAS,UAAU,gDAAc;QAAjC,IAAS,UAAU,sDAAc;QAC/C,uJAA4D;QAA5D,IAAS,YAAY,kDAAuC;QAA5D,IAAS,YAAY,wDAAuC;QAE9D,MAAM,4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AG,IAAI,CAAC,UAAU,CAAC,CAAA;YAC9E,OAAO,KAAK,CAAA;QACd,CAAC;QAED;;WAEG;QACH,kBAAkB;YAChB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAA;YACrD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YACtC,CAAC;YACD,OAAO,YAAY,CAAA;QACrB,CAAC;;;SAlDU,MAAM","sourcesContent":["import { AccessRule, AccessRuleSchema } from '../rules/AccessRule.js'\nimport { RateLimitingConfiguration, RateLimitingConfigurationSchema } from '../rules/RateLimitingConfiguration.js'\nimport { observed } from '../../decorators/observed.js'\nimport { restoreAccessRule } from '../rules/index.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\n\n/**\n * A base interface for common properties across all actions.\n */\nexport interface ActionSchema {\n /**\n * The specific kind of action (e.g., 'List', 'Read', etc.)\n */\n kind: string\n /**\n * Access control rules defining who can perform this action. It is only applied if the\n * authorization strategy is set to 'RBAC'.\n * If no rules grant access, it's denied by default making it essentially private.\n *\n * Note, the API can defined top level access rules that apply to all actions. If this property is set,\n * it overrides the top level access rules for this specific action.\n *\n * It is an ordered list, meaning the first rule that matches the user will be applied.\n * If multiple rules match, the first one in the list takes precedence.\n * If no rules match, the action is denied.\n */\n accessRule?: AccessRuleSchema[]\n /**\n * Optional configuration for action-wide rate limiting and throttling.\n * Defines rules to protect the action from overuse.\n */\n rateLimiting?: RateLimitingConfigurationSchema\n}\n\n/**\n * A base class for common properties across all actions.\n */\nexport class Action extends EventTarget implements ActionSchema {\n @observed() accessor kind: string\n @observed({ deep: true }) accessor accessRule: AccessRule[]\n @observed() accessor rateLimiting: RateLimitingConfiguration | undefined\n\n protected parent: ExposedEntity\n\n constructor(parent: ExposedEntity, state: Partial<ActionSchema> = {}) {\n super()\n this.parent = parent\n this.kind = state.kind || ''\n this.accessRule = state.accessRule ? state.accessRule.map((rule) => restoreAccessRule(this, rule)) : []\n this.rateLimiting = state.rateLimiting ? new RateLimitingConfiguration(state.rateLimiting) : undefined\n }\n\n notifyChange() {\n this.dispatchEvent(new Event('change'))\n this.parent.notifyChange()\n }\n\n toJSON(): ActionSchema {\n const result: ActionSchema = {\n kind: this.kind,\n }\n if (this.accessRule.length) {\n result.accessRule = this.accessRule.map((rule) => rule.toJSON())\n }\n if (this.rateLimiting) {\n result.rateLimiting = this.rateLimiting.toJSON()\n }\n return result\n }\n\n /**\n * Returns all access rules for this action, including the ones from all the parents up to the API.\n */\n getAllRules(): AccessRule[] {\n const rules: AccessRule[] = [...this.parent.getAllRules(), ...this.accessRule]\n return rules\n }\n\n /**\n * Returns all rate limiters for this action, including the ones from all the parents up to the API.\n */\n getAllRateLimiters(): RateLimitingConfiguration[] {\n const rateLimiters = this.parent.getAllRateLimiters()\n if (this.rateLimiting) {\n rateLimiters.push(this.rateLimiting)\n }\n return rateLimiters\n }\n}\n"]}
@@ -1,3 +1,6 @@
1
+ import type { Action } from '../actions/Action.js';
2
+ import type { ApiModel } from '../ApiModel.js';
3
+ import type { ExposedEntity } from '../ExposedEntity.js';
1
4
  export interface AccessRuleSchema {
2
5
  /**
3
6
  * The unique identifier for the access rule.
@@ -10,7 +13,8 @@ export interface AccessRuleSchema {
10
13
  */
11
14
  export declare class AccessRule extends EventTarget implements AccessRuleSchema {
12
15
  readonly type: string;
13
- constructor(state?: Partial<AccessRuleSchema>);
16
+ readonly parent: ExposedEntity | ApiModel | Action;
17
+ constructor(parent: ExposedEntity | ApiModel | Action, state?: Partial<AccessRuleSchema>);
14
18
  toJSON(): AccessRuleSchema;
15
19
  notifyChange(): void;
16
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AccessRule.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/AccessRule.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,WAAY,YAAW,gBAAgB;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;gBAET,KAAK,GAAE,OAAO,CAAC,gBAAgB,CAAM;IAKjD,MAAM,IAAI,gBAAgB;IAM1B,YAAY;CAGb"}
1
+ {"version":3,"file":"AccessRule.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/AccessRule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,WAAY,YAAW,gBAAgB;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,QAAQ,GAAG,MAAM,CAAA;gBAEtC,MAAM,EAAE,aAAa,GAAG,QAAQ,GAAG,MAAM,EAAE,KAAK,GAAE,OAAO,CAAC,gBAAgB,CAAM;IAM5F,MAAM,IAAI,gBAAgB;IAM1B,YAAY;CAIb"}
@@ -3,8 +3,10 @@
3
3
  */
4
4
  export class AccessRule extends EventTarget {
5
5
  type;
6
- constructor(state = {}) {
6
+ parent;
7
+ constructor(parent, state = {}) {
7
8
  super();
9
+ this.parent = parent;
8
10
  this.type = state.type ?? '';
9
11
  }
10
12
  toJSON() {
@@ -14,6 +16,7 @@ export class AccessRule extends EventTarget {
14
16
  }
15
17
  notifyChange() {
16
18
  this.dispatchEvent(new Event('change'));
19
+ this.parent.notifyChange();
17
20
  }
18
21
  }
19
22
  //# sourceMappingURL=AccessRule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccessRule.js","sourceRoot":"","sources":["../../../../src/modeling/rules/AccessRule.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IAChC,IAAI,CAAQ;IAErB,YAAY,QAAmC,EAAE;QAC/C,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAA;IAC9B,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAA;IACH,CAAC;IAED,YAAY;QACV,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzC,CAAC;CACF","sourcesContent":["export interface AccessRuleSchema {\n /**\n * The unique identifier for the access rule.\n * This is used to reference the rule in the API configuration.\n */\n type: string\n}\n\n/**\n * Base class for all access rules.\n */\nexport class AccessRule extends EventTarget implements AccessRuleSchema {\n readonly type: string\n\n constructor(state: Partial<AccessRuleSchema> = {}) {\n super()\n this.type = state.type ?? ''\n }\n\n toJSON(): AccessRuleSchema {\n return {\n type: this.type,\n }\n }\n\n notifyChange() {\n this.dispatchEvent(new Event('change'))\n }\n}\n"]}
1
+ {"version":3,"file":"AccessRule.js","sourceRoot":"","sources":["../../../../src/modeling/rules/AccessRule.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IAChC,IAAI,CAAQ;IACZ,MAAM,CAAmC;IAElD,YAAY,MAAyC,EAAE,QAAmC,EAAE;QAC1F,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAA;IAC9B,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAA;IACH,CAAC;IAED,YAAY;QACV,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;QACvC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import type { Action } from '../actions/Action.js'\nimport type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\n\nexport interface AccessRuleSchema {\n /**\n * The unique identifier for the access rule.\n * This is used to reference the rule in the API configuration.\n */\n type: string\n}\n\n/**\n * Base class for all access rules.\n */\nexport class AccessRule extends EventTarget implements AccessRuleSchema {\n readonly type: string\n readonly parent: ExposedEntity | ApiModel | Action\n\n constructor(parent: ExposedEntity | ApiModel | Action, state: Partial<AccessRuleSchema> = {}) {\n super()\n this.parent = parent\n this.type = state.type ?? ''\n }\n\n toJSON(): AccessRuleSchema {\n return {\n type: this.type,\n }\n }\n\n notifyChange() {\n this.dispatchEvent(new Event('change'))\n this.parent.notifyChange()\n }\n}\n"]}
@@ -1,3 +1,6 @@
1
+ import type { Action } from '../actions/Action.js';
2
+ import type { ApiModel } from '../ApiModel.js';
3
+ import type { ExposedEntity } from '../ExposedEntity.js';
1
4
  import { AccessRule, type AccessRuleSchema } from './AccessRule.js';
2
5
  /**
3
6
  * The action is allowed for any authenticated user.
@@ -14,6 +17,6 @@ export interface AllowAuthenticatedAccessRuleSchema extends AccessRuleSchema {
14
17
  */
15
18
  export declare class AllowAuthenticatedAccessRule extends AccessRule implements AllowAuthenticatedAccessRuleSchema {
16
19
  readonly type: 'allowAuthenticated';
17
- constructor(state?: Partial<AllowAuthenticatedAccessRuleSchema>);
20
+ constructor(parent: ExposedEntity | ApiModel | Action, state?: Partial<AllowAuthenticatedAccessRuleSchema>);
18
21
  }
19
22
  //# sourceMappingURL=AllowAuthenticated.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AllowAuthenticated.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/AllowAuthenticated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEnE;;;;GAIG;AACH,MAAM,WAAW,kCAAmC,SAAQ,gBAAgB;IAC1E,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AAED;;;;GAIG;AACH,qBAAa,4BAA6B,SAAQ,UAAW,YAAW,kCAAkC;IACxG,SAAkB,IAAI,EAAE,oBAAoB,CAAA;gBAEhC,KAAK,GAAE,OAAO,CAAC,kCAAkC,CAAM;CAIpE"}
1
+ {"version":3,"file":"AllowAuthenticated.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/AllowAuthenticated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEnE;;;;GAIG;AACH,MAAM,WAAW,kCAAmC,SAAQ,gBAAgB;IAC1E,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AAED;;;;GAIG;AACH,qBAAa,4BAA6B,SAAQ,UAAW,YAAW,kCAAkC;IACxG,SAAkB,IAAI,EAAE,oBAAoB,CAAA;gBAEhC,MAAM,EAAE,aAAa,GAAG,QAAQ,GAAG,MAAM,EAAE,KAAK,GAAE,OAAO,CAAC,kCAAkC,CAAM;CAI/G"}
@@ -6,8 +6,8 @@ import { AccessRule } from './AccessRule.js';
6
6
  */
7
7
  export class AllowAuthenticatedAccessRule extends AccessRule {
8
8
  type;
9
- constructor(state = {}) {
10
- super(state);
9
+ constructor(parent, state = {}) {
10
+ super(parent, state);
11
11
  this.type = 'allowAuthenticated';
12
12
  }
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AllowAuthenticated.js","sourceRoot":"","sources":["../../../../src/modeling/rules/AllowAuthenticated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AAWnE;;;;GAIG;AACH,MAAM,OAAO,4BAA6B,SAAQ,UAAU;IACxC,IAAI,CAAsB;IAE5C,YAAY,QAAqD,EAAE;QACjE,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF","sourcesContent":["import { AccessRule, type AccessRuleSchema } from './AccessRule.js'\n\n/**\n * The action is allowed for any authenticated user.\n * This rule does not impose any additional restrictions based on user properties or resource ownership.\n * It is used for resources that should be accessible to all logged-in users.\n */\nexport interface AllowAuthenticatedAccessRuleSchema extends AccessRuleSchema {\n type: 'allowAuthenticated'\n}\n\n/**\n * The action is allowed for any authenticated user.\n * This rule does not impose any additional restrictions based on user properties or resource ownership.\n * It is used for resources that should be accessible to all logged-in users.\n */\nexport class AllowAuthenticatedAccessRule extends AccessRule implements AllowAuthenticatedAccessRuleSchema {\n override readonly type: 'allowAuthenticated'\n\n constructor(state: Partial<AllowAuthenticatedAccessRuleSchema> = {}) {\n super(state)\n this.type = 'allowAuthenticated'\n }\n}\n"]}
1
+ {"version":3,"file":"AllowAuthenticated.js","sourceRoot":"","sources":["../../../../src/modeling/rules/AllowAuthenticated.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AAWnE;;;;GAIG;AACH,MAAM,OAAO,4BAA6B,SAAQ,UAAU;IACxC,IAAI,CAAsB;IAE5C,YAAY,MAAyC,EAAE,QAAqD,EAAE;QAC5G,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF","sourcesContent":["import type { Action } from '../actions/Action.js'\nimport type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\nimport { AccessRule, type AccessRuleSchema } from './AccessRule.js'\n\n/**\n * The action is allowed for any authenticated user.\n * This rule does not impose any additional restrictions based on user properties or resource ownership.\n * It is used for resources that should be accessible to all logged-in users.\n */\nexport interface AllowAuthenticatedAccessRuleSchema extends AccessRuleSchema {\n type: 'allowAuthenticated'\n}\n\n/**\n * The action is allowed for any authenticated user.\n * This rule does not impose any additional restrictions based on user properties or resource ownership.\n * It is used for resources that should be accessible to all logged-in users.\n */\nexport class AllowAuthenticatedAccessRule extends AccessRule implements AllowAuthenticatedAccessRuleSchema {\n override readonly type: 'allowAuthenticated'\n\n constructor(parent: ExposedEntity | ApiModel | Action, state: Partial<AllowAuthenticatedAccessRuleSchema> = {}) {\n super(parent, state)\n this.type = 'allowAuthenticated'\n }\n}\n"]}
@@ -1,3 +1,6 @@
1
+ import type { Action } from '../actions/Action.js';
2
+ import type { ApiModel } from '../ApiModel.js';
3
+ import type { ExposedEntity } from '../ExposedEntity.js';
1
4
  import { AccessRule, type AccessRuleSchema } from './AccessRule.js';
2
5
  /**
3
6
  * The action is allowed for all users, including unauthenticated ones.
@@ -14,6 +17,6 @@ export interface AllowPublicAccessRuleSchema extends AccessRuleSchema {
14
17
  */
15
18
  export declare class AllowPublicAccessRule extends AccessRule implements AllowPublicAccessRuleSchema {
16
19
  readonly type: 'allowPublic';
17
- constructor(state?: Partial<AllowPublicAccessRuleSchema>);
20
+ constructor(parent: ExposedEntity | ApiModel | Action, state?: Partial<AllowPublicAccessRuleSchema>);
18
21
  }
19
22
  //# sourceMappingURL=AllowPublic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AllowPublic.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/AllowPublic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEnE;;;;GAIG;AACH,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE,IAAI,EAAE,aAAa,CAAA;CACpB;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,UAAW,YAAW,2BAA2B;IAC1F,SAAkB,IAAI,EAAE,aAAa,CAAA;gBAEzB,KAAK,GAAE,OAAO,CAAC,2BAA2B,CAAM;CAI7D"}
1
+ {"version":3,"file":"AllowPublic.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/AllowPublic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEnE;;;;GAIG;AACH,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE,IAAI,EAAE,aAAa,CAAA;CACpB;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,UAAW,YAAW,2BAA2B;IAC1F,SAAkB,IAAI,EAAE,aAAa,CAAA;gBAEzB,MAAM,EAAE,aAAa,GAAG,QAAQ,GAAG,MAAM,EAAE,KAAK,GAAE,OAAO,CAAC,2BAA2B,CAAM;CAIxG"}
@@ -6,8 +6,8 @@ import { AccessRule } from './AccessRule.js';
6
6
  */
7
7
  export class AllowPublicAccessRule extends AccessRule {
8
8
  type;
9
- constructor(state = {}) {
10
- super(state);
9
+ constructor(parent, state = {}) {
10
+ super(parent, state);
11
11
  this.type = 'allowPublic';
12
12
  }
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AllowPublic.js","sourceRoot":"","sources":["../../../../src/modeling/rules/AllowPublic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AAWnE;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,UAAU;IACjC,IAAI,CAAe;IAErC,YAAY,QAA8C,EAAE;QAC1D,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;IAC3B,CAAC;CACF","sourcesContent":["import { AccessRule, type AccessRuleSchema } from './AccessRule.js'\n\n/**\n * The action is allowed for all users, including unauthenticated ones.\n * This is typically used for public APIs or resources that do not require authentication.\n * It is the most permissive rule and should be used with caution.\n */\nexport interface AllowPublicAccessRuleSchema extends AccessRuleSchema {\n type: 'allowPublic'\n}\n\n/**\n * The action is allowed for all users, including unauthenticated ones.\n * This is typically used for public APIs or resources that do not require authentication.\n * It is the most permissive rule and should be used with caution.\n */\nexport class AllowPublicAccessRule extends AccessRule implements AllowPublicAccessRuleSchema {\n override readonly type: 'allowPublic'\n\n constructor(state: Partial<AllowPublicAccessRuleSchema> = {}) {\n super(state)\n this.type = 'allowPublic'\n }\n}\n"]}
1
+ {"version":3,"file":"AllowPublic.js","sourceRoot":"","sources":["../../../../src/modeling/rules/AllowPublic.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AAWnE;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,UAAU;IACjC,IAAI,CAAe;IAErC,YAAY,MAAyC,EAAE,QAA8C,EAAE;QACrG,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;IAC3B,CAAC;CACF","sourcesContent":["import type { Action } from '../actions/Action.js'\nimport type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\nimport { AccessRule, type AccessRuleSchema } from './AccessRule.js'\n\n/**\n * The action is allowed for all users, including unauthenticated ones.\n * This is typically used for public APIs or resources that do not require authentication.\n * It is the most permissive rule and should be used with caution.\n */\nexport interface AllowPublicAccessRuleSchema extends AccessRuleSchema {\n type: 'allowPublic'\n}\n\n/**\n * The action is allowed for all users, including unauthenticated ones.\n * This is typically used for public APIs or resources that do not require authentication.\n * It is the most permissive rule and should be used with caution.\n */\nexport class AllowPublicAccessRule extends AccessRule implements AllowPublicAccessRuleSchema {\n override readonly type: 'allowPublic'\n\n constructor(parent: ExposedEntity | ApiModel | Action, state: Partial<AllowPublicAccessRuleSchema> = {}) {\n super(parent, state)\n this.type = 'allowPublic'\n }\n}\n"]}
@@ -1,3 +1,6 @@
1
+ import type { Action } from '../actions/Action.js';
2
+ import type { ApiModel } from '../ApiModel.js';
3
+ import type { ExposedEntity } from '../ExposedEntity.js';
1
4
  import { AccessRule, type AccessRuleSchema } from './AccessRule.js';
2
5
  /**
3
6
  * The action is allowed if the authenticated user's email domain matches a specific domain.
@@ -19,7 +22,7 @@ export interface MatchEmailDomainAccessRuleSchema extends AccessRuleSchema {
19
22
  export declare class MatchEmailDomainAccessRule extends AccessRule implements MatchEmailDomainAccessRuleSchema {
20
23
  readonly type: 'matchEmailDomain';
21
24
  accessor domains: string[];
22
- constructor(state?: Partial<MatchEmailDomainAccessRuleSchema>);
25
+ constructor(parent: ExposedEntity | ApiModel | Action, state?: Partial<MatchEmailDomainAccessRuleSchema>);
23
26
  toJSON(): MatchEmailDomainAccessRuleSchema;
24
27
  }
25
28
  //# sourceMappingURL=MatchEmailDomain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MatchEmailDomain.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchEmailDomain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGnE;;;;GAIG;AACH,MAAM,WAAW,gCAAiC,SAAQ,gBAAgB;IACxE,IAAI,EAAE,kBAAkB,CAAA;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED;;;;GAIG;AACH,qBAAa,0BAA2B,SAAQ,UAAW,YAAW,gCAAgC;IACpG,SAAkB,IAAI,EAAE,kBAAkB,CAAA;IAEhB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAA;gBAExC,KAAK,GAAE,OAAO,CAAC,gCAAgC,CAAM;IAMxD,MAAM,IAAI,gCAAgC;CAMpD"}
1
+ {"version":3,"file":"MatchEmailDomain.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchEmailDomain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGnE;;;;GAIG;AACH,MAAM,WAAW,gCAAiC,SAAQ,gBAAgB;IACxE,IAAI,EAAE,kBAAkB,CAAA;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED;;;;GAIG;AACH,qBAAa,0BAA2B,SAAQ,UAAW,YAAW,gCAAgC;IACpG,SAAkB,IAAI,EAAE,kBAAkB,CAAA;IAEhB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAA;gBAExC,MAAM,EAAE,aAAa,GAAG,QAAQ,GAAG,MAAM,EAAE,KAAK,GAAE,OAAO,CAAC,gCAAgC,CAAM;IAMnG,MAAM,IAAI,gCAAgC;CAMpD"}
@@ -22,8 +22,8 @@ let MatchEmailDomainAccessRule = (() => {
22
22
  #domains_accessor_storage = __runInitializers(this, _domains_initializers, void 0);
23
23
  get domains() { return this.#domains_accessor_storage; }
24
24
  set domains(value) { this.#domains_accessor_storage = value; }
25
- constructor(state = {}) {
26
- super(state);
25
+ constructor(parent, state = {}) {
26
+ super(parent, state);
27
27
  __runInitializers(this, _domains_extraInitializers);
28
28
  this.type = 'matchEmailDomain';
29
29
  this.domains = state.domains ? [...state.domains] : [];
@@ -1 +1 @@
1
- {"version":3,"file":"MatchEmailDomain.js","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchEmailDomain.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAe9D;;;;GAIG;IACU,0BAA0B;sBAAS,UAAU;;;;iBAA7C,0BAA2B,SAAQ,WAAU;;;mCAGvD,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAAC,0KAAS,OAAO,6BAAP,OAAO,yFAAU;;;QAFlC,IAAI,CAAoB;QAEhB,mFAA0B;QAA1B,IAAS,OAAO,6CAAU;QAA1B,IAAS,OAAO,mDAAU;QAEpD,YAAY,QAAmD,EAAE;YAC/D,KAAK,CAAC,KAAK,CAAC,CAAA;;YACZ,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAA;YAC9B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;SACvD;QAEQ,MAAM;YACb,OAAO;gBACL,GAAI,KAAK,CAAC,MAAM,EAAuC;gBACvD,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAa;aAChE,CAAA;QACH,CAAC;;;SAhBU,0BAA0B","sourcesContent":["import { AccessRule, type AccessRuleSchema } from './AccessRule.js'\nimport { observed, toRaw } from '../../decorators/observed.js'\n\n/**\n * The action is allowed if the authenticated user's email domain matches a specific domain.\n * This is used to restrict access based on the user's email address.\n * For example, only users with an email address from \"my-company.com\" can access certain resources.\n */\nexport interface MatchEmailDomainAccessRuleSchema extends AccessRuleSchema {\n type: 'matchEmailDomain'\n /**\n * The email domains that the authenticated user's email must match.\n */\n domains: string[]\n}\n\n/**\n * The action is allowed if the authenticated user's email domain matches a specific domain.\n * This is used to restrict access based on the user's email address.\n * For example, only users with an email address from \"my-company.com\" can access certain resources.\n */\nexport class MatchEmailDomainAccessRule extends AccessRule implements MatchEmailDomainAccessRuleSchema {\n override readonly type: 'matchEmailDomain'\n\n @observed({ deep: true }) accessor domains: string[]\n\n constructor(state: Partial<MatchEmailDomainAccessRuleSchema> = {}) {\n super(state)\n this.type = 'matchEmailDomain'\n this.domains = state.domains ? [...state.domains] : []\n }\n\n override toJSON(): MatchEmailDomainAccessRuleSchema {\n return {\n ...(super.toJSON() as MatchEmailDomainAccessRuleSchema),\n domains: structuredClone(toRaw(this, this.domains)) as string[],\n }\n }\n}\n"]}
1
+ {"version":3,"file":"MatchEmailDomain.js","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchEmailDomain.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAe9D;;;;GAIG;IACU,0BAA0B;sBAAS,UAAU;;;;iBAA7C,0BAA2B,SAAQ,WAAU;;;mCAGvD,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAAC,0KAAS,OAAO,6BAAP,OAAO,yFAAU;;;QAFlC,IAAI,CAAoB;QAEhB,mFAA0B;QAA1B,IAAS,OAAO,6CAAU;QAA1B,IAAS,OAAO,mDAAU;QAEpD,YAAY,MAAyC,EAAE,QAAmD,EAAE;YAC1G,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;;YACpB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAA;YAC9B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;SACvD;QAEQ,MAAM;YACb,OAAO;gBACL,GAAI,KAAK,CAAC,MAAM,EAAuC;gBACvD,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAa;aAChE,CAAA;QACH,CAAC;;;SAhBU,0BAA0B","sourcesContent":["import type { Action } from '../actions/Action.js'\nimport type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\nimport { AccessRule, type AccessRuleSchema } from './AccessRule.js'\nimport { observed, toRaw } from '../../decorators/observed.js'\n\n/**\n * The action is allowed if the authenticated user's email domain matches a specific domain.\n * This is used to restrict access based on the user's email address.\n * For example, only users with an email address from \"my-company.com\" can access certain resources.\n */\nexport interface MatchEmailDomainAccessRuleSchema extends AccessRuleSchema {\n type: 'matchEmailDomain'\n /**\n * The email domains that the authenticated user's email must match.\n */\n domains: string[]\n}\n\n/**\n * The action is allowed if the authenticated user's email domain matches a specific domain.\n * This is used to restrict access based on the user's email address.\n * For example, only users with an email address from \"my-company.com\" can access certain resources.\n */\nexport class MatchEmailDomainAccessRule extends AccessRule implements MatchEmailDomainAccessRuleSchema {\n override readonly type: 'matchEmailDomain'\n\n @observed({ deep: true }) accessor domains: string[]\n\n constructor(parent: ExposedEntity | ApiModel | Action, state: Partial<MatchEmailDomainAccessRuleSchema> = {}) {\n super(parent, state)\n this.type = 'matchEmailDomain'\n this.domains = state.domains ? [...state.domains] : []\n }\n\n override toJSON(): MatchEmailDomainAccessRuleSchema {\n return {\n ...(super.toJSON() as MatchEmailDomainAccessRuleSchema),\n domains: structuredClone(toRaw(this, this.domains)) as string[],\n }\n }\n}\n"]}
@@ -1,3 +1,6 @@
1
+ import type { Action } from '../actions/Action.js';
2
+ import type { ApiModel } from '../ApiModel.js';
3
+ import type { ExposedEntity } from '../ExposedEntity.js';
1
4
  import { AccessRule, type AccessRuleSchema } from './AccessRule.js';
2
5
  /**
3
6
  * The action is allowed if the authenticated user's ID matches a specific property on the resource.
@@ -32,7 +35,7 @@ export declare class MatchResourceOwnerAccessRule extends AccessRule implements
32
35
  readonly type: 'matchResourceOwner';
33
36
  accessor property: string | undefined;
34
37
  accessor target: 'property' | 'user-entity';
35
- constructor(state?: Partial<MatchResourceOwnerAccessRuleSchema>);
38
+ constructor(parent: ExposedEntity | ApiModel | Action, state?: Partial<MatchResourceOwnerAccessRuleSchema>);
36
39
  toJSON(): MatchResourceOwnerAccessRuleSchema;
37
40
  }
38
41
  //# sourceMappingURL=MatchResourceOwner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MatchResourceOwner.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchResourceOwner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGnE;;;;GAIG;AACH,MAAM,WAAW,kCAAmC,SAAQ,gBAAgB;IAC1E,IAAI,EAAE,oBAAoB,CAAA;IAC1B;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,aAAa,CAAA;CACpC;AAED;;;;GAIG;AACH,qBAAa,4BAA6B,SAAQ,UAAW,YAAW,kCAAkC;IACxG,SAAkB,IAAI,EAAE,oBAAoB,CAAA;IAEhC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,CAAA;gBAE3C,KAAK,GAAE,OAAO,CAAC,kCAAkC,CAAM;IAO1D,MAAM,IAAI,kCAAkC;CAUtD"}
1
+ {"version":3,"file":"MatchResourceOwner.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchResourceOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGnE;;;;GAIG;AACH,MAAM,WAAW,kCAAmC,SAAQ,gBAAgB;IAC1E,IAAI,EAAE,oBAAoB,CAAA;IAC1B;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,aAAa,CAAA;CACpC;AAED;;;;GAIG;AACH,qBAAa,4BAA6B,SAAQ,UAAW,YAAW,kCAAkC;IACxG,SAAkB,IAAI,EAAE,oBAAoB,CAAA;IAEhC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,CAAA;gBAE3C,MAAM,EAAE,aAAa,GAAG,QAAQ,GAAG,MAAM,EAAE,KAAK,GAAE,OAAO,CAAC,kCAAkC,CAAM;IAOrG,MAAM,IAAI,kCAAkC;CAUtD"}
@@ -30,8 +30,8 @@ let MatchResourceOwnerAccessRule = (() => {
30
30
  #target_accessor_storage = (__runInitializers(this, _property_extraInitializers), __runInitializers(this, _target_initializers, void 0));
31
31
  get target() { return this.#target_accessor_storage; }
32
32
  set target(value) { this.#target_accessor_storage = value; }
33
- constructor(state = {}) {
34
- super(state);
33
+ constructor(parent, state = {}) {
34
+ super(parent, state);
35
35
  __runInitializers(this, _target_extraInitializers);
36
36
  this.type = 'matchResourceOwner';
37
37
  this.property = state.property;
@@ -1 +1 @@
1
- {"version":3,"file":"MatchResourceOwner.js","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchResourceOwner.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AA4BvD;;;;GAIG;IACU,4BAA4B;sBAAS,UAAU;;;;;;;iBAA/C,4BAA6B,SAAQ,WAAU;;;oCAGzD,QAAQ,EAAE;kCACV,QAAQ,EAAE;YADC,6KAAS,QAAQ,6BAAR,QAAQ,2FAAoB;YACrC,uKAAS,MAAM,6BAAN,MAAM,uFAA4B;;;QAHrC,IAAI,CAAsB;QAEhC,qFAAqC;QAArC,IAAS,QAAQ,8CAAoB;QAArC,IAAS,QAAQ,oDAAoB;QACrC,yIAA2C;QAA3C,IAAS,MAAM,4CAA4B;QAA3C,IAAS,MAAM,kDAA4B;QAEvD,YAAY,QAAqD,EAAE;YACjE,KAAK,CAAC,KAAK,CAAC,CAAA;;YACZ,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;YAChC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAA;YAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,UAAU,CAAA;SACzC;QAEQ,MAAM;YACb,MAAM,IAAI,GAAuC;gBAC/C,GAAI,KAAK,CAAC,MAAM,EAAyC;gBACzD,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAA;YACD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;YAC/B,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;;;SAtBU,4BAA4B","sourcesContent":["import { AccessRule, type AccessRuleSchema } from './AccessRule.js'\nimport { observed } from '../../decorators/observed.js'\n\n/**\n * The action is allowed if the authenticated user's ID matches a specific property on the resource.\n * This is typically used to restrict access to resources owned by the user.\n * For example, a user can only access their own profile or documents.\n */\nexport interface MatchResourceOwnerAccessRuleSchema extends AccessRuleSchema {\n type: 'matchResourceOwner'\n /**\n * The property on the resource that references the user's ID (the key in the semantically annotated `User` entity).\n *\n * When the current exposed entity has a property annotated with the \"ResourceOwnerIdentifier\" semantic,\n * this property should be used. It directly references the user's key.\n *\n * The domain model should annotate this property with the \"ResourceOwnerIdentifier\" semantic\n * to indicate that it is used for ownership checks.\n */\n property?: string\n\n /**\n * The target for the ownership check.\n * - `property`: The check is performed against a specific property on the resource (default).\n * - `user-entity`: The check is performed against the entity itself (used when the entity represents the user).\n */\n target?: 'property' | 'user-entity'\n}\n\n/**\n * The action is allowed if the authenticated user's ID matches a specific property on the resource.\n * This is typically used to restrict access to resources owned by the user.\n * For example, a user can only access their own profile or documents.\n */\nexport class MatchResourceOwnerAccessRule extends AccessRule implements MatchResourceOwnerAccessRuleSchema {\n override readonly type: 'matchResourceOwner'\n\n @observed() accessor property: string | undefined\n @observed() accessor target: 'property' | 'user-entity'\n\n constructor(state: Partial<MatchResourceOwnerAccessRuleSchema> = {}) {\n super(state)\n this.type = 'matchResourceOwner'\n this.property = state.property\n this.target = state.target ?? 'property'\n }\n\n override toJSON(): MatchResourceOwnerAccessRuleSchema {\n const json: MatchResourceOwnerAccessRuleSchema = {\n ...(super.toJSON() as MatchResourceOwnerAccessRuleSchema),\n target: this.target,\n }\n if (this.property) {\n json.property = this.property\n }\n return json\n }\n}\n"]}
1
+ {"version":3,"file":"MatchResourceOwner.js","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchResourceOwner.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AA4BvD;;;;GAIG;IACU,4BAA4B;sBAAS,UAAU;;;;;;;iBAA/C,4BAA6B,SAAQ,WAAU;;;oCAGzD,QAAQ,EAAE;kCACV,QAAQ,EAAE;YADC,6KAAS,QAAQ,6BAAR,QAAQ,2FAAoB;YACrC,uKAAS,MAAM,6BAAN,MAAM,uFAA4B;;;QAHrC,IAAI,CAAsB;QAEhC,qFAAqC;QAArC,IAAS,QAAQ,8CAAoB;QAArC,IAAS,QAAQ,oDAAoB;QACrC,yIAA2C;QAA3C,IAAS,MAAM,4CAA4B;QAA3C,IAAS,MAAM,kDAA4B;QAEvD,YAAY,MAAyC,EAAE,QAAqD,EAAE;YAC5G,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;;YACpB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;YAChC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAA;YAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,UAAU,CAAA;SACzC;QAEQ,MAAM;YACb,MAAM,IAAI,GAAuC;gBAC/C,GAAI,KAAK,CAAC,MAAM,EAAyC;gBACzD,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAA;YACD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;YAC/B,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;;;SAtBU,4BAA4B","sourcesContent":["import type { Action } from '../actions/Action.js'\nimport type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\nimport { AccessRule, type AccessRuleSchema } from './AccessRule.js'\nimport { observed } from '../../decorators/observed.js'\n\n/**\n * The action is allowed if the authenticated user's ID matches a specific property on the resource.\n * This is typically used to restrict access to resources owned by the user.\n * For example, a user can only access their own profile or documents.\n */\nexport interface MatchResourceOwnerAccessRuleSchema extends AccessRuleSchema {\n type: 'matchResourceOwner'\n /**\n * The property on the resource that references the user's ID (the key in the semantically annotated `User` entity).\n *\n * When the current exposed entity has a property annotated with the \"ResourceOwnerIdentifier\" semantic,\n * this property should be used. It directly references the user's key.\n *\n * The domain model should annotate this property with the \"ResourceOwnerIdentifier\" semantic\n * to indicate that it is used for ownership checks.\n */\n property?: string\n\n /**\n * The target for the ownership check.\n * - `property`: The check is performed against a specific property on the resource (default).\n * - `user-entity`: The check is performed against the entity itself (used when the entity represents the user).\n */\n target?: 'property' | 'user-entity'\n}\n\n/**\n * The action is allowed if the authenticated user's ID matches a specific property on the resource.\n * This is typically used to restrict access to resources owned by the user.\n * For example, a user can only access their own profile or documents.\n */\nexport class MatchResourceOwnerAccessRule extends AccessRule implements MatchResourceOwnerAccessRuleSchema {\n override readonly type: 'matchResourceOwner'\n\n @observed() accessor property: string | undefined\n @observed() accessor target: 'property' | 'user-entity'\n\n constructor(parent: ExposedEntity | ApiModel | Action, state: Partial<MatchResourceOwnerAccessRuleSchema> = {}) {\n super(parent, state)\n this.type = 'matchResourceOwner'\n this.property = state.property\n this.target = state.target ?? 'property'\n }\n\n override toJSON(): MatchResourceOwnerAccessRuleSchema {\n const json: MatchResourceOwnerAccessRuleSchema = {\n ...(super.toJSON() as MatchResourceOwnerAccessRuleSchema),\n target: this.target,\n }\n if (this.property) {\n json.property = this.property\n }\n return json\n }\n}\n"]}
@@ -1,3 +1,6 @@
1
+ import type { Action } from '../actions/Action.js';
2
+ import type { ApiModel } from '../ApiModel.js';
3
+ import type { ExposedEntity } from '../ExposedEntity.js';
1
4
  import { AccessRule, type AccessRuleSchema } from './AccessRule.js';
2
5
  /**
3
6
  * The action is allowed if a specific property on the authenticated user matches an expected value.
@@ -22,7 +25,7 @@ export declare class MatchUserPropertyAccessRule extends AccessRule implements M
22
25
  readonly type: 'matchUserProperty';
23
26
  accessor property: string;
24
27
  accessor value: string;
25
- constructor(state?: Partial<MatchUserPropertyAccessRuleSchema>);
28
+ constructor(parent: ExposedEntity | ApiModel | Action, state?: Partial<MatchUserPropertyAccessRuleSchema>);
26
29
  toJSON(): MatchUserPropertyAccessRuleSchema;
27
30
  }
28
31
  //# sourceMappingURL=MatchUserProperty.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MatchUserProperty.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchUserProperty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGnE;;;GAGG;AACH,MAAM,WAAW,iCAAkC,SAAQ,gBAAgB;IACzE,IAAI,EAAE,mBAAmB,CAAA;IACzB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,UAAW,YAAW,iCAAiC;IACtG,SAAkB,IAAI,EAAE,mBAAmB,CAAA;IAE/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;gBAEtB,KAAK,GAAE,OAAO,CAAC,iCAAiC,CAAM;IAOzD,MAAM,IAAI,iCAAiC;CAOrD"}
1
+ {"version":3,"file":"MatchUserProperty.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchUserProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGnE;;;GAGG;AACH,MAAM,WAAW,iCAAkC,SAAQ,gBAAgB;IACzE,IAAI,EAAE,mBAAmB,CAAA;IACzB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,UAAW,YAAW,iCAAiC;IACtG,SAAkB,IAAI,EAAE,mBAAmB,CAAA;IAE/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;gBAEtB,MAAM,EAAE,aAAa,GAAG,QAAQ,GAAG,MAAM,EAAE,KAAK,GAAE,OAAO,CAAC,iCAAiC,CAAM;IAOpG,MAAM,IAAI,iCAAiC;CAOrD"}
@@ -29,8 +29,8 @@ let MatchUserPropertyAccessRule = (() => {
29
29
  #value_accessor_storage = (__runInitializers(this, _property_extraInitializers), __runInitializers(this, _value_initializers, void 0));
30
30
  get value() { return this.#value_accessor_storage; }
31
31
  set value(value) { this.#value_accessor_storage = value; }
32
- constructor(state = {}) {
33
- super(state);
32
+ constructor(parent, state = {}) {
33
+ super(parent, state);
34
34
  __runInitializers(this, _value_extraInitializers);
35
35
  this.type = 'matchUserProperty';
36
36
  this.property = state.property ?? '';
@@ -1 +1 @@
1
- {"version":3,"file":"MatchUserProperty.js","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchUserProperty.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAkBvD;;;GAGG;IACU,2BAA2B;sBAAS,UAAU;;;;;;;iBAA9C,2BAA4B,SAAQ,WAAU;;;oCAGxD,QAAQ,EAAE;iCACV,QAAQ,EAAE;YADC,6KAAS,QAAQ,6BAAR,QAAQ,2FAAQ;YACzB,oKAAS,KAAK,6BAAL,KAAK,qFAAQ;;;QAHhB,IAAI,CAAqB;QAE/B,qFAAyB;QAAzB,IAAS,QAAQ,8CAAQ;QAAzB,IAAS,QAAQ,oDAAQ;QACzB,uIAAsB;QAAtB,IAAS,KAAK,2CAAQ;QAAtB,IAAS,KAAK,iDAAQ;QAElC,YAAY,QAAoD,EAAE;YAChE,KAAK,CAAC,KAAK,CAAC,CAAA;;YACZ,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;YAC/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAA;YACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAA;SAC/B;QAEQ,MAAM;YACb,OAAO;gBACL,GAAI,KAAK,CAAC,MAAM,EAAwC;gBACxD,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAA;QACH,CAAC;;;SAnBU,2BAA2B","sourcesContent":["import { AccessRule, type AccessRuleSchema } from './AccessRule.js'\nimport { observed } from '../../decorators/observed.js'\n\n/**\n * The action is allowed if a specific property on the authenticated user matches an expected value.\n * This is used to enforce other user-specific restrictions.\n */\nexport interface MatchUserPropertyAccessRuleSchema extends AccessRuleSchema {\n type: 'matchUserProperty'\n /**\n * The property on the authenticated user that should match the expected value.\n */\n property: string\n /**\n * The expected value for the user property.\n */\n value: string\n}\n\n/**\n * The action is allowed if a specific property on the authenticated user matches an expected value.\n * This is used to enforce other user-specific restrictions.\n */\nexport class MatchUserPropertyAccessRule extends AccessRule implements MatchUserPropertyAccessRuleSchema {\n override readonly type: 'matchUserProperty'\n\n @observed() accessor property: string\n @observed() accessor value: string\n\n constructor(state: Partial<MatchUserPropertyAccessRuleSchema> = {}) {\n super(state)\n this.type = 'matchUserProperty'\n this.property = state.property ?? ''\n this.value = state.value ?? ''\n }\n\n override toJSON(): MatchUserPropertyAccessRuleSchema {\n return {\n ...(super.toJSON() as MatchUserPropertyAccessRuleSchema),\n property: this.property,\n value: this.value,\n }\n }\n}\n"]}
1
+ {"version":3,"file":"MatchUserProperty.js","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchUserProperty.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAkBvD;;;GAGG;IACU,2BAA2B;sBAAS,UAAU;;;;;;;iBAA9C,2BAA4B,SAAQ,WAAU;;;oCAGxD,QAAQ,EAAE;iCACV,QAAQ,EAAE;YADC,6KAAS,QAAQ,6BAAR,QAAQ,2FAAQ;YACzB,oKAAS,KAAK,6BAAL,KAAK,qFAAQ;;;QAHhB,IAAI,CAAqB;QAE/B,qFAAyB;QAAzB,IAAS,QAAQ,8CAAQ;QAAzB,IAAS,QAAQ,oDAAQ;QACzB,uIAAsB;QAAtB,IAAS,KAAK,2CAAQ;QAAtB,IAAS,KAAK,iDAAQ;QAElC,YAAY,MAAyC,EAAE,QAAoD,EAAE;YAC3G,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;;YACpB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;YAC/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAA;YACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAA;SAC/B;QAEQ,MAAM;YACb,OAAO;gBACL,GAAI,KAAK,CAAC,MAAM,EAAwC;gBACxD,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAA;QACH,CAAC;;;SAnBU,2BAA2B","sourcesContent":["import type { Action } from '../actions/Action.js'\nimport type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\nimport { AccessRule, type AccessRuleSchema } from './AccessRule.js'\nimport { observed } from '../../decorators/observed.js'\n\n/**\n * The action is allowed if a specific property on the authenticated user matches an expected value.\n * This is used to enforce other user-specific restrictions.\n */\nexport interface MatchUserPropertyAccessRuleSchema extends AccessRuleSchema {\n type: 'matchUserProperty'\n /**\n * The property on the authenticated user that should match the expected value.\n */\n property: string\n /**\n * The expected value for the user property.\n */\n value: string\n}\n\n/**\n * The action is allowed if a specific property on the authenticated user matches an expected value.\n * This is used to enforce other user-specific restrictions.\n */\nexport class MatchUserPropertyAccessRule extends AccessRule implements MatchUserPropertyAccessRuleSchema {\n override readonly type: 'matchUserProperty'\n\n @observed() accessor property: string\n @observed() accessor value: string\n\n constructor(parent: ExposedEntity | ApiModel | Action, state: Partial<MatchUserPropertyAccessRuleSchema> = {}) {\n super(parent, state)\n this.type = 'matchUserProperty'\n this.property = state.property ?? ''\n this.value = state.value ?? ''\n }\n\n override toJSON(): MatchUserPropertyAccessRuleSchema {\n return {\n ...(super.toJSON() as MatchUserPropertyAccessRuleSchema),\n property: this.property,\n value: this.value,\n }\n }\n}\n"]}
@@ -1,3 +1,6 @@
1
+ import type { Action } from '../actions/Action.js';
2
+ import type { ApiModel } from '../ApiModel.js';
3
+ import type { ExposedEntity } from '../ExposedEntity.js';
1
4
  import { AccessRule, type AccessRuleSchema } from './AccessRule.js';
2
5
  /**
3
6
  * The action is allowed if the authenticated user has a specific role.
@@ -23,7 +26,7 @@ export interface MatchUserRoleAccessRuleSchema extends AccessRuleSchema {
23
26
  export declare class MatchUserRoleAccessRule extends AccessRule implements MatchUserRoleAccessRuleSchema {
24
27
  readonly type: 'matchUserRole';
25
28
  accessor role: string[];
26
- constructor(state?: Partial<MatchUserRoleAccessRuleSchema>);
29
+ constructor(parent: ExposedEntity | ApiModel | Action, state?: Partial<MatchUserRoleAccessRuleSchema>);
27
30
  toJSON(): MatchUserRoleAccessRuleSchema;
28
31
  }
29
32
  //# sourceMappingURL=MatchUserRole.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MatchUserRole.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchUserRole.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGnE;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,gBAAgB;IACrE,IAAI,EAAE,eAAe,CAAA;IACrB;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,EAAE,CAAA;CACf;AAED;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,UAAW,YAAW,6BAA6B;IAC9F,SAAkB,IAAI,EAAE,eAAe,CAAA;IAEb,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;gBAErC,KAAK,GAAE,OAAO,CAAC,6BAA6B,CAAM;IAMrD,MAAM,IAAI,6BAA6B;CAMjD"}
1
+ {"version":3,"file":"MatchUserRole.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchUserRole.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGnE;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,gBAAgB;IACrE,IAAI,EAAE,eAAe,CAAA;IACrB;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,EAAE,CAAA;CACf;AAED;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,UAAW,YAAW,6BAA6B;IAC9F,SAAkB,IAAI,EAAE,eAAe,CAAA;IAEb,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;gBAErC,MAAM,EAAE,aAAa,GAAG,QAAQ,GAAG,MAAM,EAAE,KAAK,GAAE,OAAO,CAAC,6BAA6B,CAAM;IAMhG,MAAM,IAAI,6BAA6B;CAMjD"}
@@ -22,8 +22,8 @@ let MatchUserRoleAccessRule = (() => {
22
22
  #role_accessor_storage = __runInitializers(this, _role_initializers, void 0);
23
23
  get role() { return this.#role_accessor_storage; }
24
24
  set role(value) { this.#role_accessor_storage = value; }
25
- constructor(state = {}) {
26
- super(state);
25
+ constructor(parent, state = {}) {
26
+ super(parent, state);
27
27
  __runInitializers(this, _role_extraInitializers);
28
28
  this.type = 'matchUserRole';
29
29
  this.role = state.role ? [...state.role] : [];
@@ -1 +1 @@
1
- {"version":3,"file":"MatchUserRole.js","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchUserRole.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAmB9D;;;;GAIG;IACU,uBAAuB;sBAAS,UAAU;;;;iBAA1C,uBAAwB,SAAQ,WAAU;;;gCAGpD,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAAC,iKAAS,IAAI,6BAAJ,IAAI,mFAAU;;;QAF/B,IAAI,CAAiB;QAEb,6EAAuB;QAAvB,IAAS,IAAI,0CAAU;QAAvB,IAAS,IAAI,gDAAU;QAEjD,YAAY,QAAgD,EAAE;YAC5D,KAAK,CAAC,KAAK,CAAC,CAAA;;YACZ,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;YAC3B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;SAC9C;QAEQ,MAAM;YACb,OAAO;gBACL,GAAI,KAAK,CAAC,MAAM,EAAoC;gBACpD,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAa;aAC1D,CAAA;QACH,CAAC;;;SAhBU,uBAAuB","sourcesContent":["import { AccessRule, type AccessRuleSchema } from './AccessRule.js'\nimport { observed, toRaw } from '../../decorators/observed.js'\n\n/**\n * The action is allowed if the authenticated user has a specific role.\n * This is used to enforce role-based access control (RBAC).\n * For example, only users with the \"admin\" role can perform certain actions.\n */\nexport interface MatchUserRoleAccessRuleSchema extends AccessRuleSchema {\n type: 'matchUserRole'\n /**\n * The role that the authenticated user must have to access the resource.\n * This is typically a property on the user entity that defines their role.\n *\n * The domain model should annotate this property with the \"UserRole\" semantic\n * to indicate that it is used for role-based access control.\n */\n role: string[]\n}\n\n/**\n * The action is allowed if the authenticated user has a specific role.\n * This is used to enforce role-based access control (RBAC).\n * For example, only users with the \"admin\" role can perform certain actions.\n */\nexport class MatchUserRoleAccessRule extends AccessRule implements MatchUserRoleAccessRuleSchema {\n override readonly type: 'matchUserRole'\n\n @observed({ deep: true }) accessor role: string[]\n\n constructor(state: Partial<MatchUserRoleAccessRuleSchema> = {}) {\n super(state)\n this.type = 'matchUserRole'\n this.role = state.role ? [...state.role] : []\n }\n\n override toJSON(): MatchUserRoleAccessRuleSchema {\n return {\n ...(super.toJSON() as MatchUserRoleAccessRuleSchema),\n role: structuredClone(toRaw(this, this.role)) as string[],\n }\n }\n}\n"]}
1
+ {"version":3,"file":"MatchUserRole.js","sourceRoot":"","sources":["../../../../src/modeling/rules/MatchUserRole.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAmB9D;;;;GAIG;IACU,uBAAuB;sBAAS,UAAU;;;;iBAA1C,uBAAwB,SAAQ,WAAU;;;gCAGpD,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAAC,iKAAS,IAAI,6BAAJ,IAAI,mFAAU;;;QAF/B,IAAI,CAAiB;QAEb,6EAAuB;QAAvB,IAAS,IAAI,0CAAU;QAAvB,IAAS,IAAI,gDAAU;QAEjD,YAAY,MAAyC,EAAE,QAAgD,EAAE;YACvG,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;;YACpB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;YAC3B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;SAC9C;QAEQ,MAAM;YACb,OAAO;gBACL,GAAI,KAAK,CAAC,MAAM,EAAoC;gBACpD,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAa;aAC1D,CAAA;QACH,CAAC;;;SAhBU,uBAAuB","sourcesContent":["import type { Action } from '../actions/Action.js'\nimport type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\nimport { AccessRule, type AccessRuleSchema } from './AccessRule.js'\nimport { observed, toRaw } from '../../decorators/observed.js'\n\n/**\n * The action is allowed if the authenticated user has a specific role.\n * This is used to enforce role-based access control (RBAC).\n * For example, only users with the \"admin\" role can perform certain actions.\n */\nexport interface MatchUserRoleAccessRuleSchema extends AccessRuleSchema {\n type: 'matchUserRole'\n /**\n * The role that the authenticated user must have to access the resource.\n * This is typically a property on the user entity that defines their role.\n *\n * The domain model should annotate this property with the \"UserRole\" semantic\n * to indicate that it is used for role-based access control.\n */\n role: string[]\n}\n\n/**\n * The action is allowed if the authenticated user has a specific role.\n * This is used to enforce role-based access control (RBAC).\n * For example, only users with the \"admin\" role can perform certain actions.\n */\nexport class MatchUserRoleAccessRule extends AccessRule implements MatchUserRoleAccessRuleSchema {\n override readonly type: 'matchUserRole'\n\n @observed({ deep: true }) accessor role: string[]\n\n constructor(parent: ExposedEntity | ApiModel | Action, state: Partial<MatchUserRoleAccessRuleSchema> = {}) {\n super(parent, state)\n this.type = 'matchUserRole'\n this.role = state.role ? [...state.role] : []\n }\n\n override toJSON(): MatchUserRoleAccessRuleSchema {\n return {\n ...(super.toJSON() as MatchUserRoleAccessRuleSchema),\n role: structuredClone(toRaw(this, this.role)) as string[],\n }\n }\n}\n"]}
@@ -1,5 +1,8 @@
1
1
  export { AccessRule, type AccessRuleSchema } from './AccessRule.js';
2
2
  export { RateLimitingConfiguration, type RateLimitingConfigurationSchema } from './RateLimitingConfiguration.js';
3
+ import type { Action } from '../actions/Action.js';
4
+ import type { ApiModel } from '../ApiModel.js';
5
+ import type { ExposedEntity } from '../ExposedEntity.js';
3
6
  import { AccessRuleSchema } from './AccessRule.js';
4
7
  import { AllowAuthenticatedAccessRule, type AllowAuthenticatedAccessRuleSchema } from './AllowAuthenticated.js';
5
8
  import { AllowPublicAccessRule, type AllowPublicAccessRuleSchema } from './AllowPublic.js';
@@ -21,5 +24,5 @@ export type RuleType = 'allowAuthenticated' | 'allowPublic' | 'matchEmailDomain'
21
24
  * @param schema The schema to restore the access rule from.
22
25
  * @returns The restored access rule.
23
26
  */
24
- export declare function restoreAccessRule(schema: AccessRuleSchema): ApiAccessRule;
27
+ export declare function restoreAccessRule(parent: ExposedEntity | ApiModel | Action, schema: AccessRuleSchema): ApiAccessRule;
25
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modeling/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,yBAAyB,EAAE,KAAK,+BAA+B,EAAE,MAAM,gCAAgC,CAAA;AAEhH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,4BAA4B,EAAE,KAAK,kCAAkC,EAAE,MAAM,yBAAyB,CAAA;AAC/G,OAAO,EAAE,qBAAqB,EAAE,KAAK,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAC1F,OAAO,EAAE,0BAA0B,EAAE,KAAK,gCAAgC,EAAE,MAAM,uBAAuB,CAAA;AACzG,OAAO,EAAE,4BAA4B,EAAE,KAAK,kCAAkC,EAAE,MAAM,yBAAyB,CAAA;AAC/G,OAAO,EAAE,2BAA2B,EAAE,KAAK,iCAAiC,EAAE,MAAM,wBAAwB,CAAA;AAC5G,OAAO,EAAE,uBAAuB,EAAE,KAAK,6BAA6B,EAAE,MAAM,oBAAoB,CAAA;AAChG,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,GACd,CAAA;AACD,YAAY,EACV,kCAAkC,EAClC,2BAA2B,EAC3B,gCAAgC,EAChC,kCAAkC,EAClC,iCAAiC,EACjC,6BAA6B,EAC7B,mBAAmB,GACpB,CAAA;AAED,MAAM,MAAM,aAAa,GACrB,4BAA4B,GAC5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