@api-client/core 0.18.30 → 0.18.32
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.
- package/build/src/browser.d.ts +1 -0
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +1 -0
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +1 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/ApiModel.d.ts +3 -2
- package/build/src/modeling/ApiModel.d.ts.map +1 -1
- package/build/src/modeling/ApiModel.js +23 -8
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/ExposedEntity.d.ts +114 -0
- package/build/src/modeling/ExposedEntity.d.ts.map +1 -0
- package/build/src/modeling/ExposedEntity.js +300 -0
- package/build/src/modeling/ExposedEntity.js.map +1 -0
- package/build/src/modeling/helpers/endpointHelpers.d.ts +11 -0
- package/build/src/modeling/helpers/endpointHelpers.d.ts.map +1 -1
- package/build/src/modeling/helpers/endpointHelpers.js +21 -0
- package/build/src/modeling/helpers/endpointHelpers.js.map +1 -1
- package/build/src/modeling/types.d.ts +17 -4
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/models/kinds.d.ts +1 -0
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +1 -0
- package/build/src/models/kinds.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modeling/ApiModel.ts +28 -13
- package/src/modeling/ExposedEntity.ts +344 -0
- package/src/modeling/helpers/endpointHelpers.ts +22 -0
- package/src/modeling/types.ts +18 -3
- package/src/models/kinds.ts +1 -0
- package/tests/unit/modeling/api_model.spec.ts +49 -10
- package/tests/unit/modeling/api_model_expose_entity.spec.ts +1 -1
- package/tests/unit/modeling/exposed_entity.spec.ts +100 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{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cAAc,GAAG,EAAE,CAAA;YACxB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;YACjB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAA;YACrB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAA;YAC9B,CAAC;YACD,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,KAAK,kBAAkB,EAAE,CAAC;gBAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,cAA+C,CAAA;gBAClE,KAAK,CAAC,WAAW,GAAG,SAAS,CAAA;YAC/B,CAAC;YACD,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,IAAI,MAAM,EAAE,CAAC;gBAChE,MAAM,KAAK,GAAG,IAAI,CAAC,aAAwC,CAAA;gBAC3D,KAAK,CAAC,OAAO,GAAG,EAAE,CAAA;YACpB,CAAC;QACH,CAAC;QAED;;;;;;WAMG;QACH,gBAAgB,CAAC,MAAkB;YACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAA;YAC3G,CAAC;YACD,IAAI,CAAC,oBAAoB,EAAE,CAAA;YAC3B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YACzC,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;YACzE,IAAI,CAAC,YAAY,EAAE,CAAA;QACrB,CAAC;;;SAtdU,QAAQ","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { ApiModelKind, DataDomainKind } from '../models/kinds.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport type {\n AccessRule,\n AssociationTarget,\n AuthenticationConfiguration,\n AuthorizationConfiguration,\n ExposedEntity,\n RateLimitingConfiguration,\n RolesBasedAccessControl,\n SessionConfiguration,\n UsernamePasswordConfiguration,\n ExposeOptions,\n} from './types.js'\nimport { DataDomain } from './DataDomain.js'\nimport { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js'\nimport { observed, toRaw } from '../decorators/observed.js'\nimport pluralize from '@jarrodek/pluralize'\nimport { createDomainKey } from './helpers/keying.js'\n\n/**\n * Contact information for the exposed API.\n */\nexport interface ApiContact {\n /**\n * The identifying name of the contact person/organization.\n */\n name?: string\n /**\n * The URL pointing to the contact information. MUST be in the format of a URL.\n */\n url?: string\n /**\n * The email address of the contact person/organization. MUST be in the format of an email address.\n */\n email?: string\n}\n\n/**\n * License information for the exposed API.\n */\nexport interface ApiLicense {\n /**\n * The license name used for the API. It is recommended to be an SPDX license identifier.\n */\n name: string\n /**\n * A URL to the license used for the API. MUST be in the format of a URL.\n */\n url?: string\n}\n\nexport interface ApiModelSchema extends DependentModelSchema {\n /**\n * The data domain kind recognizable by the ecosystem.\n */\n kind: typeof ApiModelKind\n /**\n * The unique key of the API model schema.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n /**\n * Contains the name, display name, description, and the version of the API model schema.\n */\n info: IThing\n\n /**\n * The designated Data Entity that represents a \"User\".\n * This entity should be marked with the \"User\" semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n user?: AssociationTarget\n\n /**\n * Configuration for how users prove their identity.\n * The API model is invalid if this is not set.\n */\n authentication?: AuthenticationConfiguration\n\n /**\n * Configuration for what authenticated users are allowed to do.\n * The API model is invalid if this is not set.\n */\n authorization?: AuthorizationConfiguration\n\n /**\n * Configuration for the transport and payload of the user session.\n * The API model is invalid if this is not set.\n */\n session?: SessionConfiguration\n /**\n * The specific subset of Data Entities to be exposed by this API.\n * These are the entities that are included in the data domain schema.\n */\n exposes: ExposedEntity[]\n\n /**\n * Optional array of access rules that define the access control policies\n * for the API. These rules are used to enforce security and permissions\n * on the exposed entities.\n *\n * These rules apply to all exposed entities and actions. An API action\n * can declare its own access rules, which will override these.\n */\n accessRule?: AccessRule[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n /**\n * A URL to the Terms of Service for the API.\n */\n termsOfService?: string\n /**\n * The contact information for the exposed API.\n */\n contact?: ApiContact\n /**\n * The license information for the API.\n */\n license?: ApiLicense\n}\n\nexport class ApiModel extends DependentModel {\n /**\n * The data domain kind recognizable by the ecosystem.\n */\n kind: typeof ApiModelKind\n /**\n * The unique key of the data domain schema.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n\n /**\n * The description of the domain property.\n */\n info: Thing\n /**\n * The designated Data Entity that represents a \"User\".\n * This entity must be marked with the \"User\" semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n user?: AssociationTarget\n\n /**\n * Configuration for how users prove their identity.\n * The API model is invalid if this is not set.\n */\n authentication?: AuthenticationConfiguration\n\n /**\n * Configuration for what authenticated users are allowed to do.\n * The API model is invalid if this is not set.\n */\n authorization?: AuthorizationConfiguration\n\n /**\n * Configuration for the transport and payload of the user session.\n * The API model is invalid if this is not set.\n */\n session?: SessionConfiguration\n /**\n * The specific subset of Data Entities to be exposed by this API.\n * These are the entities that are included in the data domain schema.\n */\n exposes: ExposedEntity[]\n /**\n * Optional array of access rules that define the access control policies\n * for the API. These rules are used to enforce security and permissions\n * on the exposed entities.\n *\n * These rules apply to all exposed entities and actions. An API action\n * can declare its own access rules, which will override these.\n */\n accessRule?: AccessRule[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n /**\n * A URL to the Terms of Service for the API.\n */\n @observed() accessor termsOfService: string | undefined\n /**\n * The contact information for the exposed API.\n */\n @observed({ deep: true }) accessor contact: ApiContact | undefined\n /**\n * The license information for the API.\n */\n @observed({ deep: true }) accessor license: ApiLicense | undefined\n\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\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 /**\n * A convenience getter that returns the DataDomain associated with this API model.\n * Since the API model can have only one DataDomain,\n * this getter returns the first dependency in the list.\n *\n * The parent interface `DependentModel` allows for multiple dependencies,\n * to unify the dependency management across different models.\n */\n get domain(): DataDomain | undefined {\n if (this.dependencyList.length === 0) {\n return undefined\n }\n const domain = this.dependencyList[0]\n return this.dependencies.get(domain.key)\n }\n\n static createSchema(input: Partial<ApiModelSchema> = {}): ApiModelSchema {\n const { key = nanoid(), exposes = [] } = input\n const info = Thing.fromJSON(input.info, { name: 'Unnamed API' }).toJSON()\n const result: ApiModelSchema = {\n kind: ApiModelKind,\n key,\n info,\n exposes,\n }\n if (input.user) {\n result.user = { ...input.user }\n }\n if (input.dependencyList) {\n result.dependencyList = structuredClone(input.dependencyList)\n }\n if (input.authentication) {\n result.authentication = input.authentication\n }\n if (input.authorization) {\n result.authorization = input.authorization\n }\n if (input.session) {\n result.session = input.session\n }\n if (input.accessRule) {\n result.accessRule = input.accessRule\n }\n if (input.rateLimiting) {\n result.rateLimiting = input.rateLimiting\n }\n if (input.termsOfService) {\n result.termsOfService = input.termsOfService\n }\n if (input.contact) {\n result.contact = structuredClone(input.contact)\n }\n if (input.license) {\n result.license = structuredClone(input.license)\n }\n return result\n }\n\n constructor(state?: Partial<ApiModelSchema>, domain?: DomainDependency) {\n const init = ApiModel.createSchema(state)\n const instances: DataDomain[] = []\n if (domain instanceof DataDomain) {\n instances.push(domain)\n } else if (typeof domain === 'object' && domain.kind === DataDomainKind) {\n instances.push(new DataDomain(domain))\n } else if (domain) {\n throw new Error(`Invalid domain provided. Expected a DataDomain instance or schema.`)\n }\n super(init.dependencyList, instances)\n this.kind = init.kind\n this.key = init.key\n this.info = new Thing(init.info)\n this.user = init.user\n if (init.authentication) {\n this.authentication = structuredClone(init.authentication)\n }\n if (init.authorization) {\n this.authorization = structuredClone(init.authorization)\n }\n if (init.session) {\n this.session = structuredClone(init.session)\n }\n if (Array.isArray(init.exposes)) {\n this.exposes = structuredClone(init.exposes)\n } else {\n this.exposes = []\n }\n if (init.accessRule) {\n this.accessRule = structuredClone(init.accessRule)\n }\n if (init.rateLimiting) {\n this.rateLimiting = structuredClone(init.rateLimiting)\n }\n if (init.termsOfService) {\n this.termsOfService = init.termsOfService\n }\n if (init.contact) {\n this.contact = init.contact\n }\n if (init.license) {\n this.license = init.license\n }\n this.#initializing = false\n this.info.addEventListener('change', () => {\n this.notifyChange()\n })\n }\n\n toJSON(): ApiModelSchema {\n const result: ApiModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n exposes: structuredClone(this.exposes),\n }\n if (this.user) {\n result.user = { ...this.user }\n }\n if (this.dependencyList.length > 0) {\n result.dependencyList = structuredClone(this.dependencyList)\n }\n if (this.authentication) {\n result.authentication = structuredClone(this.authentication)\n }\n if (this.authorization) {\n result.authorization = structuredClone(this.authorization)\n }\n if (this.session) {\n result.session = structuredClone(this.session)\n }\n if (this.accessRule) {\n result.accessRule = structuredClone(this.accessRule)\n }\n if (this.rateLimiting) {\n result.rateLimiting = structuredClone(this.rateLimiting)\n }\n if (this.termsOfService) {\n result.termsOfService = this.termsOfService\n }\n if (this.contact) {\n result.contact = structuredClone(toRaw(this, this.contact))\n }\n if (this.license) {\n result.license = structuredClone(toRaw(this, this.license))\n }\n return result\n }\n\n /**\n * This function is used internally by all domain elements to notify that something has changed.\n * Since we want to notify listeners after the operation commits, we use microtask\n * to ensure that the event is dispatched after the current operation.\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 /**\n * Exposes a new entity in the API model.\n * If the entity already exists, it returns the existing one.\n * @param entity The entity key and domain to expose.\n * @returns The exposed entity.\n */\n exposeEntity(entity: AssociationTarget, options?: ExposeOptions): ExposedEntity {\n const domain = this.domain\n if (!domain) {\n throw new Error(`No domain attached to API model`)\n }\n // checks whether the entity is already exposed as a root exposure.\n const existing = this.exposes.find(\n (e) => e.isRoot && e.entity.key === entity.key && e.entity.domain === entity.domain\n )\n if (existing) {\n // quietly return the existing exposure\n // TBD: should we throw an error here?\n return existing\n }\n const domainEntity = domain.findEntity(entity.key, entity.domain)\n if (!domainEntity) {\n throw new Error(`Entity not found in domain: ${entity.key}`)\n }\n const name = domainEntity.info.name || ''\n const newEntity: ExposedEntity = {\n key: nanoid(),\n entity: { ...entity },\n actions: [],\n isRoot: true,\n path: pluralize(name.toLocaleLowerCase()),\n }\n if (options) {\n newEntity.exposeOptions = { ...options }\n }\n this.exposes.push(newEntity)\n\n // Follow associations if requested\n if (options?.followAssociations) {\n if (options?.maxDepth === undefined || options.maxDepth > 0) {\n this.followEntityAssociations(newEntity, options)\n }\n }\n this.notifyChange()\n return newEntity\n }\n\n /**\n * Follows associations for a newly exposed entity if configured to do so.\n * This creates nested exposures based on the entity's associations.\n *\n * @param parentExposure The root exposure to follow associations from\n * @param options The expose options containing follow configuration\n */\n private followEntityAssociations(parentExposure: ExposedEntity, options: ExposeOptions): void {\n const domain = this.domain\n if (!domain) {\n return\n }\n const maxDepth = options.maxDepth ?? 6\n const visited = new Set<string>()\n // Add parent entity's key to the visited set so we won't skip it when traversing\n // associations.\n visited.add(createDomainKey(parentExposure.entity))\n\n const follow = (currentEntity: AssociationTarget, parentKey: string, depth: number) => {\n // Find the domain entity\n const domainEntity = domain.findEntity(currentEntity.key, currentEntity.domain)\n if (!domainEntity) return\n\n // Iterate through associations\n for (const association of domainEntity.listAssociations()) {\n for (const target of association.targets) {\n // Skip self-referencing associations\n if (target.key === currentEntity.key && target.domain === currentEntity.domain) {\n continue\n }\n\n // Create unique identifier for circular detection\n const visitKey = createDomainKey(target)\n if (visited.has(visitKey)) {\n continue // Skip circular references\n }\n visited.add(visitKey)\n\n // Check if this nested exposure already exists\n const existingNested = this.exposes.find(\n (e) =>\n !e.isRoot &&\n e.entity.key === target.key &&\n e.entity.domain === target.domain &&\n e.parent?.key === parentKey\n )\n\n if (existingNested) {\n continue // Already exposed under this parent\n }\n\n // Find the target domain entity for path generation\n const targetDomainEntity = domain.findEntity(target.key, target.domain)\n if (!targetDomainEntity) continue\n\n const name = association.info.name || ''\n // Create nested exposure\n const nestedExposure: ExposedEntity = {\n key: nanoid(),\n entity: { ...target },\n actions: [],\n isRoot: false,\n path: pluralize(name.toLocaleLowerCase()),\n parent: {\n key: parentKey,\n association: {\n key: association.key,\n domain: currentEntity.domain,\n },\n depth: depth + 1,\n },\n }\n\n this.exposes.push(nestedExposure)\n if (depth + 1 >= maxDepth) {\n nestedExposure.truncated = true\n } else {\n // Recursively follow associations\n follow(target, nestedExposure.key, depth + 1)\n }\n }\n }\n }\n\n // Start following from the root exposure\n follow(parentExposure.entity, parentExposure.key, 0)\n }\n\n /**\n * Removes an exposed entity from the API model.\n * @param entity The entity to remove.\n */\n removeEntity(entity: AssociationTarget): void {\n const current = this.exposes.find((e) => e.entity.key === entity.key && e.entity.domain === entity.domain)\n if (!current) {\n return\n }\n this.removeWithChildren(current.key)\n this.notifyChange()\n }\n\n private removeWithChildren(key: string): void {\n const index = this.exposes.findIndex((e) => e.key === key)\n if (index < 0) {\n return\n }\n // Remove the parent itself\n this.exposes.splice(index, 1)\n // Remove all children recursively\n const removeChildren = (parentKey: string) => {\n // Find all exposures whose parent.key matches parentKey\n const children = this.exposes.filter((e) => e.parent?.key === parentKey)\n for (const child of children) {\n removeChildren(child.key)\n const childIndex = this.exposes.findIndex((e) => e.key === child.key)\n if (childIndex >= 0) {\n this.exposes.splice(childIndex, 1)\n }\n }\n }\n // Then also remove children\n removeChildren(key)\n this.notifyChange()\n }\n\n /**\n * Returns the exposed entity by its key.\n * @param entityKey The key of the entity to find.\n * @returns The exposed entity or undefined if not found.\n */\n getExposedEntity(entity: AssociationTarget): ExposedEntity | undefined {\n return this.exposes.find((e) => e.entity.key === entity.key && e.entity.domain === entity.domain)\n }\n\n /**\n * Clears the API model for a new entity change.\n * This method resets the dependencies, exposes, user,\n * authentication, authorization, and session properties.\n */\n cleanForEntityChange(): void {\n this.dependencies.clear()\n this.dependencyList = []\n this.exposes = []\n this.user = undefined\n if (this.session) {\n this.session.properties = []\n }\n if (this.authentication && this.authentication.strategy === 'UsernamePassword') {\n const typed = this.authentication as UsernamePasswordConfiguration\n typed.passwordKey = undefined\n }\n if (this.authorization && this.authorization.strategy == 'RBAC') {\n const typed = this.authorization as RolesBasedAccessControl\n typed.roleKey = ''\n }\n }\n\n /**\n * Attaches a DataDomain to this API model.\n * This method clears any existing dependencies and sets the new domain.\n *\n * @param domain The DataDomain to attach to this API model.\n * @throws Error if the domain does not have a version set in its info.\n */\n attachDataDomain(domain: DataDomain): void {\n if (!domain.info.version) {\n throw new Error(`Cannot attach DataDomain without a version. Please set the version in the domain info.`)\n }\n this.cleanForEntityChange()\n this.dependencies.set(domain.key, domain)\n this.dependencyList = [{ key: domain.key, version: domain.info.version }]\n this.notifyChange()\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ApiModel.js","sourceRoot":"","sources":["../../../src/modeling/ApiModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACpF,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAavD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAoD,MAAM,qBAAqB,CAAA;AACtG,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAC3C,O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C,oBAAoB,EAAE,CAAA;YAC3B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YACzC,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;YACzE,IAAI,CAAC,YAAY,EAAE,CAAA;QACrB,CAAC;;;SApeU,QAAQ","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { ApiModelKind, DataDomainKind, ExposedEntityKind } from '../models/kinds.js'\nimport { type IThing, Thing } from '../models/Thing.js'\nimport type {\n AccessRule,\n AssociationTarget,\n AuthenticationConfiguration,\n AuthorizationConfiguration,\n ExposedEntitySchema,\n RateLimitingConfiguration,\n RolesBasedAccessControl,\n SessionConfiguration,\n UsernamePasswordConfiguration,\n ExposeOptions,\n} from './types.js'\nimport { DataDomain } from './DataDomain.js'\nimport { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js'\nimport { observed, toRaw } from '../decorators/observed.js'\nimport pluralize from '@jarrodek/pluralize'\nimport { createDomainKey } from './helpers/keying.js'\nimport { ExposedEntity } from './ExposedEntity.js'\n\n/**\n * Contact information for the exposed API.\n */\nexport interface ApiContact {\n /**\n * The identifying name of the contact person/organization.\n */\n name?: string\n /**\n * The URL pointing to the contact information. MUST be in the format of a URL.\n */\n url?: string\n /**\n * The email address of the contact person/organization. MUST be in the format of an email address.\n */\n email?: string\n}\n\n/**\n * License information for the exposed API.\n */\nexport interface ApiLicense {\n /**\n * The license name used for the API. It is recommended to be an SPDX license identifier.\n */\n name: string\n /**\n * A URL to the license used for the API. MUST be in the format of a URL.\n */\n url?: string\n}\n\nexport interface ApiModelSchema extends DependentModelSchema {\n /**\n * The data domain kind recognizable by the ecosystem.\n */\n kind: typeof ApiModelKind\n /**\n * The unique key of the API model schema.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n /**\n * Contains the name, display name, description, and the version of the API model schema.\n */\n info: IThing\n\n /**\n * The designated Data Entity that represents a \"User\".\n * This entity should be marked with the \"User\" semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n user?: AssociationTarget\n\n /**\n * Configuration for how users prove their identity.\n * The API model is invalid if this is not set.\n */\n authentication?: AuthenticationConfiguration\n\n /**\n * Configuration for what authenticated users are allowed to do.\n * The API model is invalid if this is not set.\n */\n authorization?: AuthorizationConfiguration\n\n /**\n * Configuration for the transport and payload of the user session.\n * The API model is invalid if this is not set.\n */\n session?: SessionConfiguration\n /**\n * The specific subset of Data Entities to be exposed by this API.\n * These are the entities that are included in the data domain schema.\n */\n exposes: ExposedEntitySchema[]\n\n /**\n * Optional array of access rules that define the access control policies\n * for the API. These rules are used to enforce security and permissions\n * on the exposed entities.\n *\n * These rules apply to all exposed entities and actions. An API action\n * can declare its own access rules, which will override these.\n */\n accessRule?: AccessRule[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n /**\n * A URL to the Terms of Service for the API.\n */\n termsOfService?: string\n /**\n * The contact information for the exposed API.\n */\n contact?: ApiContact\n /**\n * The license information for the API.\n */\n license?: ApiLicense\n}\n\nexport class ApiModel extends DependentModel {\n /**\n * The data domain kind recognizable by the ecosystem.\n */\n kind: typeof ApiModelKind\n /**\n * The unique key of the data domain schema.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n\n /**\n * The description of the domain property.\n */\n info: Thing\n /**\n * The designated Data Entity that represents a \"User\".\n * This entity must be marked with the \"User\" semantic in the Data Modeler.\n *\n * This property is required to publish the API.\n */\n user?: AssociationTarget\n\n /**\n * Configuration for how users prove their identity.\n * The API model is invalid if this is not set.\n */\n authentication?: AuthenticationConfiguration\n\n /**\n * Configuration for what authenticated users are allowed to do.\n * The API model is invalid if this is not set.\n */\n authorization?: AuthorizationConfiguration\n\n /**\n * Configuration for the transport and payload of the user session.\n * The API model is invalid if this is not set.\n */\n session?: SessionConfiguration\n /**\n * The specific subset of Data Entities to be exposed by this API.\n * These are the entities that are included in the data domain schema.\n */\n exposes: ExposedEntity[]\n /**\n * Optional array of access rules that define the access control policies\n * for the API. These rules are used to enforce security and permissions\n * on the exposed entities.\n *\n * These rules apply to all exposed entities and actions. An API action\n * can declare its own access rules, which will override these.\n */\n accessRule?: AccessRule[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n rateLimiting?: RateLimitingConfiguration\n /**\n * A URL to the Terms of Service for the API.\n */\n @observed() accessor termsOfService: string | undefined\n /**\n * The contact information for the exposed API.\n */\n @observed({ deep: true }) accessor contact: ApiContact | undefined\n /**\n * The license information for the API.\n */\n @observed({ deep: true }) accessor license: ApiLicense | undefined\n\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\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 /**\n * A convenience getter that returns the DataDomain associated with this API model.\n * Since the API model can have only one DataDomain,\n * this getter returns the first dependency in the list.\n *\n * The parent interface `DependentModel` allows for multiple dependencies,\n * to unify the dependency management across different models.\n */\n get domain(): DataDomain | undefined {\n if (this.dependencyList.length === 0) {\n return undefined\n }\n const domain = this.dependencyList[0]\n return this.dependencies.get(domain.key)\n }\n\n static createSchema(input: Partial<ApiModelSchema> = {}): ApiModelSchema {\n const { key = nanoid(), exposes = [] } = input\n const info = Thing.fromJSON(input.info, { name: 'Unnamed API' }).toJSON()\n const result: ApiModelSchema = {\n kind: ApiModelKind,\n key,\n info,\n exposes,\n }\n if (input.user) {\n result.user = { ...input.user }\n }\n if (input.dependencyList) {\n result.dependencyList = structuredClone(input.dependencyList)\n }\n if (input.authentication) {\n result.authentication = input.authentication\n }\n if (input.authorization) {\n result.authorization = input.authorization\n }\n if (input.session) {\n result.session = input.session\n }\n if (input.accessRule) {\n result.accessRule = input.accessRule\n }\n if (input.rateLimiting) {\n result.rateLimiting = input.rateLimiting\n }\n if (input.termsOfService) {\n result.termsOfService = input.termsOfService\n }\n if (input.contact) {\n result.contact = structuredClone(input.contact)\n }\n if (input.license) {\n result.license = structuredClone(input.license)\n }\n return result\n }\n\n constructor(state?: Partial<ApiModelSchema>, domain?: DomainDependency) {\n const init = ApiModel.createSchema(state)\n const instances: DataDomain[] = []\n if (domain instanceof DataDomain) {\n instances.push(domain)\n } else if (typeof domain === 'object' && domain.kind === DataDomainKind) {\n instances.push(new DataDomain(domain))\n } else if (domain) {\n throw new Error(`Invalid domain provided. Expected a DataDomain instance or schema.`)\n }\n super(init.dependencyList, instances)\n this.kind = init.kind\n this.key = init.key\n this.info = new Thing(init.info)\n this.user = init.user\n if (init.authentication) {\n this.authentication = structuredClone(init.authentication)\n }\n if (init.authorization) {\n this.authorization = structuredClone(init.authorization)\n }\n if (init.session) {\n this.session = structuredClone(init.session)\n }\n if (Array.isArray(init.exposes)) {\n this.exposes = init.exposes.map((e) => new ExposedEntity(this, e))\n } else {\n this.exposes = []\n }\n if (init.accessRule) {\n this.accessRule = structuredClone(init.accessRule)\n }\n if (init.rateLimiting) {\n this.rateLimiting = structuredClone(init.rateLimiting)\n }\n if (init.termsOfService) {\n this.termsOfService = init.termsOfService\n }\n if (init.contact) {\n this.contact = init.contact\n }\n if (init.license) {\n this.license = init.license\n }\n this.#initializing = false\n this.info.addEventListener('change', () => {\n this.notifyChange()\n })\n }\n\n toJSON(): ApiModelSchema {\n const result: ApiModelSchema = {\n kind: this.kind,\n key: this.key,\n info: this.info.toJSON(),\n exposes: this.exposes.map((e) => e.toJSON()),\n }\n if (this.user) {\n result.user = { ...this.user }\n }\n if (this.dependencyList.length > 0) {\n result.dependencyList = structuredClone(this.dependencyList)\n }\n if (this.authentication) {\n result.authentication = structuredClone(this.authentication)\n }\n if (this.authorization) {\n result.authorization = structuredClone(this.authorization)\n }\n if (this.session) {\n result.session = structuredClone(this.session)\n }\n if (this.accessRule) {\n result.accessRule = structuredClone(this.accessRule)\n }\n if (this.rateLimiting) {\n result.rateLimiting = structuredClone(this.rateLimiting)\n }\n if (this.termsOfService) {\n result.termsOfService = this.termsOfService\n }\n if (this.contact) {\n result.contact = structuredClone(toRaw(this, this.contact))\n }\n if (this.license) {\n result.license = structuredClone(toRaw(this, this.license))\n }\n return result\n }\n\n /**\n * This function is used internally by all domain elements to notify that something has changed.\n * Since we want to notify listeners after the operation commits, we use microtask\n * to ensure that the event is dispatched after the current operation.\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 /**\n * Exposes a new entity in the API model.\n * If the entity already exists, it returns the existing one.\n * @param entity The entity key and domain to expose.\n * @returns The exposed entity.\n */\n exposeEntity(entity: AssociationTarget, options?: ExposeOptions): ExposedEntity {\n const domain = this.domain\n if (!domain) {\n throw new Error(`No domain attached to API model`)\n }\n // checks whether the entity is already exposed as a root exposure.\n const existing = this.exposes.find(\n (e) => e.isRoot && e.entity.key === entity.key && e.entity.domain === entity.domain\n )\n if (existing) {\n // quietly return the existing exposure\n // TBD: should we throw an error here?\n return existing\n }\n const domainEntity = domain.findEntity(entity.key, entity.domain)\n if (!domainEntity) {\n throw new Error(`Entity not found in domain: ${entity.key}`)\n }\n const name = domainEntity.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n const relativeCollectionPath = `/${segment}`\n const relativeResourcePath = `/${segment}/{id}`\n const newEntity: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key: nanoid(),\n entity: { ...entity },\n actions: [],\n isRoot: true,\n relativeCollectionPath,\n relativeResourcePath,\n hasCollection: true,\n }\n if (options) {\n newEntity.exposeOptions = { ...options }\n }\n const created = new ExposedEntity(this, newEntity)\n this.exposes.push(created)\n\n // Follow associations if requested\n if (options?.followAssociations) {\n if (options?.maxDepth === undefined || options.maxDepth > 0) {\n this.followEntityAssociations(newEntity, options)\n }\n }\n this.notifyChange()\n return created\n }\n\n /**\n * Follows associations for a newly exposed entity if configured to do so.\n * This creates nested exposures based on the entity's associations.\n *\n * @param parentExposure The root exposure to follow associations from\n * @param options The expose options containing follow configuration\n */\n private followEntityAssociations(parentExposure: ExposedEntitySchema, options: ExposeOptions): void {\n const domain = this.domain\n if (!domain) {\n return\n }\n const maxDepth = options.maxDepth ?? 6\n const visited = new Set<string>()\n // Add parent entity's key to the visited set so we won't skip it when traversing\n // associations.\n visited.add(createDomainKey(parentExposure.entity))\n\n const follow = (currentEntity: AssociationTarget, parentKey: string, depth: number) => {\n // Find the domain entity\n const domainEntity = domain.findEntity(currentEntity.key, currentEntity.domain)\n if (!domainEntity) return\n\n // Iterate through associations\n for (const association of domainEntity.listAssociations()) {\n for (const target of association.targets) {\n // Skip self-referencing associations\n if (target.key === currentEntity.key && target.domain === currentEntity.domain) {\n continue\n }\n\n // Create unique identifier for circular detection\n const visitKey = createDomainKey(target)\n if (visited.has(visitKey)) {\n continue // Skip circular references\n }\n visited.add(visitKey)\n\n // Check if this nested exposure already exists\n const existingNested = this.exposes.find(\n (e) =>\n !e.isRoot &&\n e.entity.key === target.key &&\n e.entity.domain === target.domain &&\n e.parent?.key === parentKey\n )\n\n if (existingNested) {\n continue // Already exposed under this parent\n }\n\n // Find the target domain entity for path generation\n const targetDomainEntity = domain.findEntity(target.key, target.domain)\n if (!targetDomainEntity) continue\n\n const name = association.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n const isCollection = association.multiple !== false\n const relativeCollectionPath = isCollection ? `/${segment}` : undefined\n const relativeResourcePath = isCollection ? `/${segment}/{id}` : `/${segment}`\n // Create nested exposure\n const nestedExposure: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key: nanoid(),\n entity: { ...target },\n actions: [],\n isRoot: false,\n relativeCollectionPath,\n relativeResourcePath,\n hasCollection: isCollection,\n parent: {\n key: parentKey,\n association: {\n key: association.key,\n domain: currentEntity.domain,\n },\n depth: depth + 1,\n },\n }\n\n this.exposes.push(new ExposedEntity(this, nestedExposure))\n if (depth + 1 >= maxDepth) {\n nestedExposure.truncated = true\n } else {\n // Recursively follow associations\n follow(target, nestedExposure.key, depth + 1)\n }\n }\n }\n }\n\n // Start following from the root exposure\n follow(parentExposure.entity, parentExposure.key, 0)\n }\n\n /**\n * Removes an exposed entity from the API model.\n * @param entity The entity to remove.\n */\n removeEntity(entity: AssociationTarget): void {\n const current = this.exposes.find((e) => e.entity.key === entity.key && e.entity.domain === entity.domain)\n if (!current) {\n return\n }\n this.removeWithChildren(current.key)\n this.notifyChange()\n }\n\n private removeWithChildren(key: string): void {\n const index = this.exposes.findIndex((e) => e.key === key)\n if (index < 0) {\n return\n }\n // Remove the parent itself\n this.exposes.splice(index, 1)\n // Remove all children recursively\n const removeChildren = (parentKey: string) => {\n // Find all exposures whose parent.key matches parentKey\n const children = this.exposes.filter((e) => e.parent?.key === parentKey)\n for (const child of children) {\n removeChildren(child.key)\n const childIndex = this.exposes.findIndex((e) => e.key === child.key)\n if (childIndex >= 0) {\n this.exposes.splice(childIndex, 1)\n }\n }\n }\n // Then also remove children\n removeChildren(key)\n this.notifyChange()\n }\n\n /**\n * Returns the exposed entity by its key.\n * @param entityKey The key of the entity to find.\n * @returns The exposed entity or undefined if not found.\n */\n getExposedEntity(entity: AssociationTarget): ExposedEntity | undefined {\n return this.exposes.find((e) => e.entity.key === entity.key && e.entity.domain === entity.domain)\n }\n\n /**\n * Clears the API model for a new entity change.\n * This method resets the dependencies, exposes, user,\n * authentication, authorization, and session properties.\n */\n cleanForEntityChange(): void {\n this.dependencies.clear()\n this.dependencyList = []\n this.exposes = []\n this.user = undefined\n if (this.session) {\n this.session.properties = []\n }\n if (this.authentication && this.authentication.strategy === 'UsernamePassword') {\n const typed = this.authentication as UsernamePasswordConfiguration\n typed.passwordKey = undefined\n }\n if (this.authorization && this.authorization.strategy == 'RBAC') {\n const typed = this.authorization as RolesBasedAccessControl\n typed.roleKey = ''\n }\n }\n\n /**\n * Attaches a DataDomain to this API model.\n * This method clears any existing dependencies and sets the new domain.\n *\n * @param domain The DataDomain to attach to this API model.\n * @throws Error if the domain does not have a version set in its info.\n */\n attachDataDomain(domain: DataDomain): void {\n if (!domain.info.version) {\n throw new Error(`Cannot attach DataDomain without a version. Please set the version in the domain info.`)\n }\n this.cleanForEntityChange()\n this.dependencies.set(domain.key, domain)\n this.dependencyList = [{ key: domain.key, version: domain.info.version }]\n this.notifyChange()\n }\n}\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { ExposedEntityKind } from '../models/kinds.js';
|
|
2
|
+
import type { ApiModel } from './ApiModel.js';
|
|
3
|
+
import type { AccessRule, ApiAction, AssociationTarget, ExposeOptions, ExposeParentRef, RateLimitingConfiguration, ExposedEntitySchema } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* A class that specializes in representing an exposed Data Entity within an API Model.
|
|
6
|
+
*
|
|
7
|
+
* @fires change - Emitted when the exposed entity has changed.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ExposedEntity extends EventTarget {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* The exposed entity kind recognizable by the ecosystem.
|
|
13
|
+
*/
|
|
14
|
+
kind: typeof ExposedEntityKind;
|
|
15
|
+
/**
|
|
16
|
+
* The unique key of the exposed entity.
|
|
17
|
+
* This is a stable identifier that does not change across versions.
|
|
18
|
+
*/
|
|
19
|
+
key: string;
|
|
20
|
+
/**
|
|
21
|
+
* A pointer to a Data Entity from the Data Domain.
|
|
22
|
+
*/
|
|
23
|
+
entity: AssociationTarget;
|
|
24
|
+
/**
|
|
25
|
+
* Indicates whether this exposure has a collection endpoint.
|
|
26
|
+
* A collection endpoint is optional for nested exposures where the association is 1:1
|
|
27
|
+
* and the schema is embedded directly under the parent resource.
|
|
28
|
+
*/
|
|
29
|
+
hasCollection: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Relative path to the collection endpoint for this exposure.
|
|
32
|
+
* Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.
|
|
33
|
+
*/
|
|
34
|
+
relativeCollectionPath?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Relative path to the resource endpoint for this exposure.
|
|
37
|
+
* Starts with '/'. For 1:1 nested exposures the resource path typically does not include an id segment.
|
|
38
|
+
*/
|
|
39
|
+
relativeResourcePath: string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether this exposure is a root exposure (top-level collection).
|
|
42
|
+
* If this is set then the `parent` reference must be populated.
|
|
43
|
+
*/
|
|
44
|
+
isRoot?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Parent reference when this exposure was created via following an association.
|
|
47
|
+
*/
|
|
48
|
+
parent?: ExposeParentRef;
|
|
49
|
+
/**
|
|
50
|
+
* Expose-time config used to create this exposure (persisted for auditing/UI).
|
|
51
|
+
* This is only populated for the root exposure. All children exposures inherit this config.
|
|
52
|
+
*/
|
|
53
|
+
exposeOptions?: ExposeOptions;
|
|
54
|
+
/**
|
|
55
|
+
* The list of enabled API actions for this exposure (List/Read/Create/etc.)
|
|
56
|
+
*/
|
|
57
|
+
actions: ApiAction[];
|
|
58
|
+
/**
|
|
59
|
+
* Optional array of access rules that define the access control policies for this exposure.
|
|
60
|
+
*/
|
|
61
|
+
accessRule?: AccessRule[];
|
|
62
|
+
/**
|
|
63
|
+
* Optional configuration for rate limiting for this exposure.
|
|
64
|
+
*/
|
|
65
|
+
rateLimiting?: RateLimitingConfiguration;
|
|
66
|
+
/**
|
|
67
|
+
* When true, generation for this exposure hit configured limits
|
|
68
|
+
*/
|
|
69
|
+
truncated?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* A reference to the parent API Model instance.
|
|
72
|
+
*/
|
|
73
|
+
api: ApiModel;
|
|
74
|
+
static createSchema(input?: Partial<ExposedEntitySchema>): ExposedEntitySchema;
|
|
75
|
+
constructor(model: ApiModel, state?: Partial<ExposedEntitySchema>);
|
|
76
|
+
notifyChange(): void;
|
|
77
|
+
toJSON(): ExposedEntitySchema;
|
|
78
|
+
/**
|
|
79
|
+
* Sets a new relative collection path for this exposed entity.
|
|
80
|
+
*
|
|
81
|
+
* It:
|
|
82
|
+
* - updates the relativeCollectionPath property
|
|
83
|
+
* - updates the absoluteCollectionPath property accordingly
|
|
84
|
+
* - updates the relativeResourcePath and absoluteResourcePath accordingly.
|
|
85
|
+
* @param path The new path to set.
|
|
86
|
+
*/
|
|
87
|
+
setRelativeCollectionPath(path: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Sets a new relative resource path for this exposed entity.
|
|
90
|
+
*
|
|
91
|
+
* Rules:
|
|
92
|
+
* - Must start with '/'.
|
|
93
|
+
* - If this exposure has a collection, the path must be exactly the collection path plus a single
|
|
94
|
+
* parameter segment (e.g. `/products/{productId}`) and only the parameter name may vary.
|
|
95
|
+
* - If this exposure does NOT have a collection, the path can be any two segments (e.g. `/profile/{id}` or `/a/b`).
|
|
96
|
+
*/
|
|
97
|
+
setRelativeResourcePath(path: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Computes the absolute path for this exposure's resource endpoint by
|
|
100
|
+
* walking up the exposure tree using `parent.key` until reaching a root exposure.
|
|
101
|
+
* The absolute path is composed by concatenating each ancestor's resource path
|
|
102
|
+
* with this exposure's relative resource path.
|
|
103
|
+
*/
|
|
104
|
+
getAbsoluteResourcePath(): string;
|
|
105
|
+
/**
|
|
106
|
+
* Computes the absolute path for this exposure's collection endpoint (if any)
|
|
107
|
+
* by walking up the exposure tree using `parent.key` until reaching a root exposure.
|
|
108
|
+
* The absolute path is composed by concatenating each ancestor's resource path
|
|
109
|
+
* with this exposure's relative collection path.
|
|
110
|
+
* Returns undefined if this exposure has no collection.
|
|
111
|
+
*/
|
|
112
|
+
getAbsoluteCollectionPath(): string | undefined;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=ExposedEntity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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IAAI,mBAAmB;IAiC7B;;;;;;;;OAQG;IACH,yBAAyB,CAAC,IAAI,EAAE,MAAM;IA2BtC;;;;;;;;OAQG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM;IA0CpC;;;;;OAKG;IACH,uBAAuB,IAAI,MAAM;IAcjC;;;;;;OAMG;IACH,yBAAyB,IAAI,MAAM,GAAG,SAAS;CAchD"}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { ExposedEntityKind } from '../models/kinds.js';
|
|
2
|
+
import { nanoid } from '../nanoid.js';
|
|
3
|
+
import { ensureLeadingSlash, joinPaths } from './helpers/endpointHelpers.js';
|
|
4
|
+
/**
|
|
5
|
+
* A class that specializes in representing an exposed Data Entity within an API Model.
|
|
6
|
+
*
|
|
7
|
+
* @fires change - Emitted when the exposed entity has changed.
|
|
8
|
+
*/
|
|
9
|
+
export class ExposedEntity extends EventTarget {
|
|
10
|
+
/**
|
|
11
|
+
* The exposed entity kind recognizable by the ecosystem.
|
|
12
|
+
*/
|
|
13
|
+
kind;
|
|
14
|
+
/**
|
|
15
|
+
* The unique key of the exposed entity.
|
|
16
|
+
* This is a stable identifier that does not change across versions.
|
|
17
|
+
*/
|
|
18
|
+
key;
|
|
19
|
+
/**
|
|
20
|
+
* A pointer to a Data Entity from the Data Domain.
|
|
21
|
+
*/
|
|
22
|
+
entity;
|
|
23
|
+
/**
|
|
24
|
+
* Indicates whether this exposure has a collection endpoint.
|
|
25
|
+
* A collection endpoint is optional for nested exposures where the association is 1:1
|
|
26
|
+
* and the schema is embedded directly under the parent resource.
|
|
27
|
+
*/
|
|
28
|
+
hasCollection;
|
|
29
|
+
/**
|
|
30
|
+
* Relative path to the collection endpoint for this exposure.
|
|
31
|
+
* Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.
|
|
32
|
+
*/
|
|
33
|
+
relativeCollectionPath;
|
|
34
|
+
/**
|
|
35
|
+
* Relative path to the resource endpoint for this exposure.
|
|
36
|
+
* Starts with '/'. For 1:1 nested exposures the resource path typically does not include an id segment.
|
|
37
|
+
*/
|
|
38
|
+
relativeResourcePath;
|
|
39
|
+
/**
|
|
40
|
+
* Whether this exposure is a root exposure (top-level collection).
|
|
41
|
+
* If this is set then the `parent` reference must be populated.
|
|
42
|
+
*/
|
|
43
|
+
isRoot;
|
|
44
|
+
/**
|
|
45
|
+
* Parent reference when this exposure was created via following an association.
|
|
46
|
+
*/
|
|
47
|
+
parent;
|
|
48
|
+
/**
|
|
49
|
+
* Expose-time config used to create this exposure (persisted for auditing/UI).
|
|
50
|
+
* This is only populated for the root exposure. All children exposures inherit this config.
|
|
51
|
+
*/
|
|
52
|
+
exposeOptions;
|
|
53
|
+
/**
|
|
54
|
+
* The list of enabled API actions for this exposure (List/Read/Create/etc.)
|
|
55
|
+
*/
|
|
56
|
+
actions;
|
|
57
|
+
/**
|
|
58
|
+
* Optional array of access rules that define the access control policies for this exposure.
|
|
59
|
+
*/
|
|
60
|
+
accessRule;
|
|
61
|
+
/**
|
|
62
|
+
* Optional configuration for rate limiting for this exposure.
|
|
63
|
+
*/
|
|
64
|
+
rateLimiting;
|
|
65
|
+
/**
|
|
66
|
+
* When true, generation for this exposure hit configured limits
|
|
67
|
+
*/
|
|
68
|
+
truncated;
|
|
69
|
+
/**
|
|
70
|
+
* When the notifying flag is set to true,
|
|
71
|
+
* the domain is pending a notification.
|
|
72
|
+
* No other notifications will be sent until
|
|
73
|
+
* the current notification is sent.
|
|
74
|
+
*/
|
|
75
|
+
#notifying = false;
|
|
76
|
+
/**
|
|
77
|
+
* A reference to the parent API Model instance.
|
|
78
|
+
*/
|
|
79
|
+
api;
|
|
80
|
+
static createSchema(input = {}) {
|
|
81
|
+
const { key = nanoid(), entity = { key: '' }, relativeCollectionPath, relativeResourcePath = '/', hasCollection = true, isRoot, parent, exposeOptions, actions = [], accessRule, rateLimiting, truncated, } = input;
|
|
82
|
+
const result = {
|
|
83
|
+
kind: ExposedEntityKind,
|
|
84
|
+
key,
|
|
85
|
+
entity: { ...entity },
|
|
86
|
+
hasCollection,
|
|
87
|
+
relativeResourcePath,
|
|
88
|
+
actions: actions.map((a) => ({ ...a })),
|
|
89
|
+
};
|
|
90
|
+
if (relativeCollectionPath !== undefined) {
|
|
91
|
+
result.relativeCollectionPath = relativeCollectionPath;
|
|
92
|
+
}
|
|
93
|
+
if (isRoot !== undefined) {
|
|
94
|
+
result.isRoot = isRoot;
|
|
95
|
+
}
|
|
96
|
+
if (parent !== undefined) {
|
|
97
|
+
result.parent = { ...parent };
|
|
98
|
+
}
|
|
99
|
+
if (exposeOptions !== undefined) {
|
|
100
|
+
result.exposeOptions = { ...exposeOptions };
|
|
101
|
+
}
|
|
102
|
+
if (accessRule !== undefined) {
|
|
103
|
+
result.accessRule = accessRule.map((ar) => ({ ...ar }));
|
|
104
|
+
}
|
|
105
|
+
if (rateLimiting !== undefined) {
|
|
106
|
+
result.rateLimiting = { ...rateLimiting };
|
|
107
|
+
}
|
|
108
|
+
if (truncated !== undefined) {
|
|
109
|
+
result.truncated = truncated;
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
constructor(model, state) {
|
|
114
|
+
super();
|
|
115
|
+
this.api = model;
|
|
116
|
+
const init = ExposedEntity.createSchema(state);
|
|
117
|
+
this.kind = init.kind;
|
|
118
|
+
this.key = init.key;
|
|
119
|
+
this.entity = init.entity;
|
|
120
|
+
this.hasCollection = init.hasCollection;
|
|
121
|
+
this.relativeCollectionPath = init.relativeCollectionPath;
|
|
122
|
+
this.relativeResourcePath = init.relativeResourcePath;
|
|
123
|
+
this.isRoot = init.isRoot;
|
|
124
|
+
this.parent = init.parent;
|
|
125
|
+
this.exposeOptions = init.exposeOptions;
|
|
126
|
+
this.actions = init.actions;
|
|
127
|
+
this.accessRule = init.accessRule;
|
|
128
|
+
this.rateLimiting = init.rateLimiting;
|
|
129
|
+
this.truncated = init.truncated;
|
|
130
|
+
}
|
|
131
|
+
notifyChange() {
|
|
132
|
+
if (this.#notifying) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.#notifying = true;
|
|
136
|
+
queueMicrotask(() => {
|
|
137
|
+
this.#notifying = false;
|
|
138
|
+
const event = new Event('change');
|
|
139
|
+
this.dispatchEvent(event);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
toJSON() {
|
|
143
|
+
const result = {
|
|
144
|
+
kind: this.kind,
|
|
145
|
+
key: this.key,
|
|
146
|
+
entity: { ...this.entity },
|
|
147
|
+
relativeResourcePath: this.relativeResourcePath,
|
|
148
|
+
actions: this.actions.map((a) => ({ ...a })),
|
|
149
|
+
hasCollection: this.hasCollection,
|
|
150
|
+
};
|
|
151
|
+
if (this.relativeCollectionPath !== undefined) {
|
|
152
|
+
result.relativeCollectionPath = this.relativeCollectionPath;
|
|
153
|
+
}
|
|
154
|
+
if (this.isRoot !== undefined) {
|
|
155
|
+
result.isRoot = this.isRoot;
|
|
156
|
+
}
|
|
157
|
+
if (this.parent !== undefined) {
|
|
158
|
+
result.parent = { ...this.parent };
|
|
159
|
+
}
|
|
160
|
+
if (this.exposeOptions !== undefined) {
|
|
161
|
+
result.exposeOptions = { ...this.exposeOptions };
|
|
162
|
+
}
|
|
163
|
+
if (this.accessRule !== undefined) {
|
|
164
|
+
result.accessRule = this.accessRule.map((ar) => ({ ...ar }));
|
|
165
|
+
}
|
|
166
|
+
if (this.rateLimiting !== undefined) {
|
|
167
|
+
result.rateLimiting = { ...this.rateLimiting };
|
|
168
|
+
}
|
|
169
|
+
if (this.truncated !== undefined) {
|
|
170
|
+
result.truncated = this.truncated;
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Sets a new relative collection path for this exposed entity.
|
|
176
|
+
*
|
|
177
|
+
* It:
|
|
178
|
+
* - updates the relativeCollectionPath property
|
|
179
|
+
* - updates the absoluteCollectionPath property accordingly
|
|
180
|
+
* - updates the relativeResourcePath and absoluteResourcePath accordingly.
|
|
181
|
+
* @param path The new path to set.
|
|
182
|
+
*/
|
|
183
|
+
setRelativeCollectionPath(path) {
|
|
184
|
+
if (!this.hasCollection) {
|
|
185
|
+
throw new Error(`Cannot set collection path on an exposure that does not have a collection`);
|
|
186
|
+
}
|
|
187
|
+
const cleaned = ensureLeadingSlash(path);
|
|
188
|
+
// Ensure exactly one non-empty segment
|
|
189
|
+
const segments = cleaned.split('/').filter(Boolean);
|
|
190
|
+
if (segments.length !== 1) {
|
|
191
|
+
throw new Error(`Collection path must contain exactly one segment. Received: "${path}"`);
|
|
192
|
+
}
|
|
193
|
+
const normalizedCollection = `/${segments[0]}`;
|
|
194
|
+
// Preserve current parameter name if present, otherwise default to {id}
|
|
195
|
+
let param = '{id}';
|
|
196
|
+
if (this.relativeResourcePath) {
|
|
197
|
+
const curSegments = this.relativeResourcePath.split('/').filter(Boolean);
|
|
198
|
+
const maybeParam = curSegments[1];
|
|
199
|
+
if (maybeParam && /^\{[A-Za-z_][A-Za-z0-9_]*\}$/.test(maybeParam)) {
|
|
200
|
+
param = maybeParam;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const nextResource = `${normalizedCollection}/${param}`;
|
|
204
|
+
const changed = this.relativeCollectionPath !== normalizedCollection || this.relativeResourcePath !== nextResource;
|
|
205
|
+
this.relativeCollectionPath = normalizedCollection;
|
|
206
|
+
this.relativeResourcePath = nextResource;
|
|
207
|
+
if (changed)
|
|
208
|
+
this.notifyChange();
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Sets a new relative resource path for this exposed entity.
|
|
212
|
+
*
|
|
213
|
+
* Rules:
|
|
214
|
+
* - Must start with '/'.
|
|
215
|
+
* - If this exposure has a collection, the path must be exactly the collection path plus a single
|
|
216
|
+
* parameter segment (e.g. `/products/{productId}`) and only the parameter name may vary.
|
|
217
|
+
* - If this exposure does NOT have a collection, the path can be any two segments (e.g. `/profile/{id}` or `/a/b`).
|
|
218
|
+
*/
|
|
219
|
+
setRelativeResourcePath(path) {
|
|
220
|
+
const cleaned = ensureLeadingSlash(path);
|
|
221
|
+
const segments = cleaned.split('/').filter(Boolean);
|
|
222
|
+
if (this.hasCollection) {
|
|
223
|
+
if (!this.relativeCollectionPath) {
|
|
224
|
+
throw new Error('Cannot set resource path: missing collection path for this exposure');
|
|
225
|
+
}
|
|
226
|
+
const colSegments = this.relativeCollectionPath.split('/').filter(Boolean);
|
|
227
|
+
if (colSegments.length !== 1) {
|
|
228
|
+
throw new Error(`Invalid stored collection path "${this.relativeCollectionPath}"`);
|
|
229
|
+
}
|
|
230
|
+
if (segments.length !== 2) {
|
|
231
|
+
throw new Error(`Resource path must be exactly two segments (collection + parameter). Received: "${cleaned}"`);
|
|
232
|
+
}
|
|
233
|
+
const [s1, s2] = segments;
|
|
234
|
+
if (s1 !== colSegments[0]) {
|
|
235
|
+
throw new Error(`Resource path must start with the collection segment "${colSegments[0]}". Received: "${s1}"`);
|
|
236
|
+
}
|
|
237
|
+
// s2 must be a parameter segment {name}
|
|
238
|
+
if (!/^\{[A-Za-z_][A-Za-z0-9_]*\}$/.test(s2)) {
|
|
239
|
+
throw new Error(`The second segment must be a parameter in braces, e.g. {id}. Received: "${s2}"`);
|
|
240
|
+
}
|
|
241
|
+
if (this.relativeResourcePath !== cleaned) {
|
|
242
|
+
this.relativeResourcePath = `/${s1}/${s2}`;
|
|
243
|
+
this.notifyChange();
|
|
244
|
+
}
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
// No collection: allow any two segments
|
|
248
|
+
if (segments.length !== 2) {
|
|
249
|
+
throw new Error(`Resource path must contain exactly two segments when no collection is present. Received: "${cleaned}"`);
|
|
250
|
+
}
|
|
251
|
+
if (this.relativeResourcePath !== cleaned) {
|
|
252
|
+
this.relativeResourcePath = `/${segments[0]}/${segments[1]}`;
|
|
253
|
+
this.notifyChange();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Computes the absolute path for this exposure's resource endpoint by
|
|
258
|
+
* walking up the exposure tree using `parent.key` until reaching a root exposure.
|
|
259
|
+
* The absolute path is composed by concatenating each ancestor's resource path
|
|
260
|
+
* with this exposure's relative resource path.
|
|
261
|
+
*/
|
|
262
|
+
getAbsoluteResourcePath() {
|
|
263
|
+
let absolute = ensureLeadingSlash(this.relativeResourcePath);
|
|
264
|
+
// Traverse parents, always joining with the parent's resource path
|
|
265
|
+
let parentKey = this.parent?.key;
|
|
266
|
+
while (parentKey) {
|
|
267
|
+
const parent = this.api.exposes.find((e) => e.key === parentKey);
|
|
268
|
+
if (!parent)
|
|
269
|
+
break;
|
|
270
|
+
const parentResource = ensureLeadingSlash(parent.relativeResourcePath);
|
|
271
|
+
absolute = joinPaths(parentResource, absolute);
|
|
272
|
+
parentKey = parent.parent?.key;
|
|
273
|
+
}
|
|
274
|
+
return absolute;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Computes the absolute path for this exposure's collection endpoint (if any)
|
|
278
|
+
* by walking up the exposure tree using `parent.key` until reaching a root exposure.
|
|
279
|
+
* The absolute path is composed by concatenating each ancestor's resource path
|
|
280
|
+
* with this exposure's relative collection path.
|
|
281
|
+
* Returns undefined if this exposure has no collection.
|
|
282
|
+
*/
|
|
283
|
+
getAbsoluteCollectionPath() {
|
|
284
|
+
if (!this.hasCollection || !this.relativeCollectionPath)
|
|
285
|
+
return undefined;
|
|
286
|
+
let absolute = ensureLeadingSlash(this.relativeCollectionPath);
|
|
287
|
+
// Traverse parents, always joining with the parent's resource path
|
|
288
|
+
let parentKey = this.parent?.key;
|
|
289
|
+
while (parentKey) {
|
|
290
|
+
const parent = this.api.exposes.find((e) => e.key === parentKey);
|
|
291
|
+
if (!parent)
|
|
292
|
+
break;
|
|
293
|
+
const parentResource = ensureLeadingSlash(parent.relativeResourcePath);
|
|
294
|
+
absolute = joinPaths(parentResource, absolute);
|
|
295
|
+
parentKey = parent.parent?.key;
|
|
296
|
+
}
|
|
297
|
+
return absolute;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=ExposedEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExposedEntity.js","sourceRoot":"","sources":["../../../src/modeling/ExposedEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAW5E;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C;;OAEG;IACH,IAAI,CAA0B;IAE9B;;;OAGG;IACH,GAAG,CAAQ;IAEX;;OAEG;IACH,MAAM,CAAmB;IAEzB;;;;OAIG;IACH,aAAa,CAAS;IAEtB;;;OAGG;IACH,sBAAsB,CAAS;IAE/B;;;OAGG;IACH,oBAAoB,CAAQ;IAE5B;;;OAGG;IACH,MAAM,CAAU;IAEhB;;OAEG;IACH,MAAM,CAAkB;IAExB;;;OAGG;IACH,aAAa,CAAgB;IAE7B;;OAEG;IACH,OAAO,CAAa;IAEpB;;OAEG;IACH,UAAU,CAAe;IAEzB;;OAEG;IACH,YAAY,CAA4B;IAExC;;OAEG;IACH,SAAS,CAAU;IAEnB;;;;;OAKG;IACH,UAAU,GAAG,KAAK,CAAA;IAClB;;OAEG;IACH,GAAG,CAAU;IAEb,MAAM,CAAC,YAAY,CAAC,QAAsC,EAAE;QAC1D,MAAM,EACJ,GAAG,GAAG,MAAM,EAAE,EACd,MAAM,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EACpB,sBAAsB,EACtB,oBAAoB,GAAG,GAAG,EAC1B,aAAa,GAAG,IAAI,EACpB,MAAM,EACN,MAAM,EACN,aAAa,EACb,OAAO,GAAG,EAAE,EACZ,UAAU,EACV,YAAY,EACZ,SAAS,GACV,GAAG,KAAK,CAAA;QACT,MAAM,MAAM,GAAwB;YAClC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CAAA;QACzE,IAAI,QAAQ,GAAG,kBAAkB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;QAC9D,mEAAmE;QACnE,IAAI,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAA;QAChC,OAAO,SAAS,EAAE,CAAC;YACjB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC,CAAA;YAChE,IAAI,CAAC,MAAM;gBAAE,MAAK;YAClB,MAAM,cAAc,GAAG,kBAAkB,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;YACtE,QAAQ,GAAG,SAAS,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;YAC9C,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAA;QAChC,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF","sourcesContent":["import { ExposedEntityKind } from '../models/kinds.js'\nimport { nanoid } from '../nanoid.js'\nimport type { ApiModel } from './ApiModel.js'\nimport { ensureLeadingSlash, joinPaths } from './helpers/endpointHelpers.js'\nimport type {\n AccessRule,\n ApiAction,\n AssociationTarget,\n ExposeOptions,\n ExposeParentRef,\n RateLimitingConfiguration,\n ExposedEntitySchema,\n} from './types.js'\n\n/**\n * A class that specializes in representing an exposed Data Entity within an API Model.\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 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 hasCollection: boolean\n\n /**\n * Relative 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 relativeCollectionPath?: string\n\n /**\n * Relative 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 relativeResourcePath: 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 isRoot?: boolean\n\n /**\n * Parent reference when this exposure was created via following an association.\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 exposeOptions?: ExposeOptions\n\n /**\n * The list of enabled API actions for this exposure (List/Read/Create/etc.)\n */\n actions: ApiAction[]\n\n /**\n * Optional array of access rules that define the access control policies for this exposure.\n */\n accessRule?: AccessRule[]\n\n /**\n * Optional configuration for rate limiting for this exposure.\n */\n rateLimiting?: RateLimitingConfiguration\n\n /**\n * When true, generation for this exposure hit configured limits\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 * 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 relativeCollectionPath,\n relativeResourcePath = '/',\n hasCollection = true,\n isRoot,\n parent,\n exposeOptions,\n actions = [],\n accessRule,\n rateLimiting,\n truncated,\n } = input\n const result: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key,\n entity: { ...entity },\n hasCollection,\n relativeResourcePath,\n actions: actions.map((a) => ({ ...a })),\n }\n if (relativeCollectionPath !== undefined) {\n result.relativeCollectionPath = relativeCollectionPath\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 (accessRule !== undefined) {\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 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.relativeCollectionPath = init.relativeCollectionPath\n this.relativeResourcePath = init.relativeResourcePath\n this.isRoot = init.isRoot\n this.parent = init.parent\n this.exposeOptions = init.exposeOptions\n this.actions = init.actions\n this.accessRule = init.accessRule\n this.rateLimiting = init.rateLimiting\n this.truncated = init.truncated\n }\n\n notifyChange() {\n if (this.#notifying) {\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 relativeResourcePath: this.relativeResourcePath,\n actions: this.actions.map((a) => ({ ...a })),\n hasCollection: this.hasCollection,\n }\n if (this.relativeCollectionPath !== undefined) {\n result.relativeCollectionPath = this.relativeCollectionPath\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 (this.accessRule !== undefined) {\n result.accessRule = this.accessRule.map((ar) => ({ ...ar }))\n }\n if (this.rateLimiting !== undefined) {\n result.rateLimiting = { ...this.rateLimiting }\n }\n if (this.truncated !== undefined) {\n result.truncated = this.truncated\n }\n return result\n }\n\n /**\n * Sets a new relative collection path for this exposed entity.\n *\n * It:\n * - updates the relativeCollectionPath property\n * - updates the absoluteCollectionPath property accordingly\n * - updates the relativeResourcePath and absoluteResourcePath accordingly.\n * @param path The new path to set.\n */\n setRelativeCollectionPath(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 // Preserve current parameter name if present, otherwise default to {id}\n let param = '{id}'\n if (this.relativeResourcePath) {\n const curSegments = this.relativeResourcePath.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 const changed = this.relativeCollectionPath !== normalizedCollection || this.relativeResourcePath !== nextResource\n this.relativeCollectionPath = normalizedCollection\n this.relativeResourcePath = nextResource\n if (changed) this.notifyChange()\n }\n\n /**\n * Sets a new relative 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 setRelativeResourcePath(path: string) {\n const cleaned = ensureLeadingSlash(path)\n const segments = cleaned.split('/').filter(Boolean)\n\n if (this.hasCollection) {\n if (!this.relativeCollectionPath) {\n throw new Error('Cannot set resource path: missing collection path for this exposure')\n }\n const colSegments = this.relativeCollectionPath.split('/').filter(Boolean)\n if (colSegments.length !== 1) {\n throw new Error(`Invalid stored collection path \"${this.relativeCollectionPath}\"`)\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.relativeResourcePath !== cleaned) {\n this.relativeResourcePath = `/${s1}/${s2}`\n this.notifyChange()\n }\n return\n }\n\n // No collection: allow any two segments\n if (segments.length !== 2) {\n throw new Error(\n `Resource path must contain exactly two segments when no collection is present. Received: \"${cleaned}\"`\n )\n }\n if (this.relativeResourcePath !== cleaned) {\n this.relativeResourcePath = `/${segments[0]}/${segments[1]}`\n this.notifyChange()\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 relative resource path.\n */\n getAbsoluteResourcePath(): string {\n let absolute = ensureLeadingSlash(this.relativeResourcePath)\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.find((e) => e.key === parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.relativeResourcePath)\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 relative collection path.\n * Returns undefined if this exposure has no collection.\n */\n getAbsoluteCollectionPath(): string | undefined {\n if (!this.hasCollection || !this.relativeCollectionPath) return undefined\n let absolute = ensureLeadingSlash(this.relativeCollectionPath)\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.find((e) => e.key === parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.relativeResourcePath)\n absolute = joinPaths(parentResource, absolute)\n parentKey = parent.parent?.key\n }\n return absolute\n }\n}\n"]}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
export declare function paramNameFor(entityKeyLocal: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Ensures the path starts with a single leading slash and has no trailing slash (except root '/')
|
|
4
|
+
* @param path The path fragment to normalize
|
|
5
|
+
*/
|
|
6
|
+
export declare function ensureLeadingSlash(path: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Joins two absolute-like fragments ensuring single slashes between segments
|
|
9
|
+
* @param left The left path fragment
|
|
10
|
+
* @param right The right path fragment
|
|
11
|
+
*/
|
|
12
|
+
export declare function joinPaths(left: string, right: string): string;
|
|
2
13
|
//# sourceMappingURL=endpointHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointHelpers.d.ts","sourceRoot":"","sources":["../../../../src/modeling/helpers/endpointHelpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAI3D"}
|
|
1
|
+
{"version":3,"file":"endpointHelpers.d.ts","sourceRoot":"","sources":["../../../../src/modeling/helpers/endpointHelpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAI3D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI7D"}
|