@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.
- package/build/src/modeling/ApiModel.d.ts.map +1 -1
- package/build/src/modeling/ApiModel.js +37 -13
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/ExposedEntity.d.ts.map +1 -1
- package/build/src/modeling/ExposedEntity.js +54 -15
- package/build/src/modeling/ExposedEntity.js.map +1 -1
- package/build/src/modeling/actions/Action.js +2 -2
- package/build/src/modeling/actions/Action.js.map +1 -1
- package/build/src/modeling/rules/AccessRule.d.ts +5 -1
- package/build/src/modeling/rules/AccessRule.d.ts.map +1 -1
- package/build/src/modeling/rules/AccessRule.js +4 -1
- package/build/src/modeling/rules/AccessRule.js.map +1 -1
- package/build/src/modeling/rules/AllowAuthenticated.d.ts +4 -1
- package/build/src/modeling/rules/AllowAuthenticated.d.ts.map +1 -1
- package/build/src/modeling/rules/AllowAuthenticated.js +2 -2
- package/build/src/modeling/rules/AllowAuthenticated.js.map +1 -1
- package/build/src/modeling/rules/AllowPublic.d.ts +4 -1
- package/build/src/modeling/rules/AllowPublic.d.ts.map +1 -1
- package/build/src/modeling/rules/AllowPublic.js +2 -2
- package/build/src/modeling/rules/AllowPublic.js.map +1 -1
- package/build/src/modeling/rules/MatchEmailDomain.d.ts +4 -1
- package/build/src/modeling/rules/MatchEmailDomain.d.ts.map +1 -1
- package/build/src/modeling/rules/MatchEmailDomain.js +2 -2
- package/build/src/modeling/rules/MatchEmailDomain.js.map +1 -1
- package/build/src/modeling/rules/MatchResourceOwner.d.ts +4 -1
- package/build/src/modeling/rules/MatchResourceOwner.d.ts.map +1 -1
- package/build/src/modeling/rules/MatchResourceOwner.js +2 -2
- package/build/src/modeling/rules/MatchResourceOwner.js.map +1 -1
- package/build/src/modeling/rules/MatchUserProperty.d.ts +4 -1
- package/build/src/modeling/rules/MatchUserProperty.d.ts.map +1 -1
- package/build/src/modeling/rules/MatchUserProperty.js +2 -2
- package/build/src/modeling/rules/MatchUserProperty.js.map +1 -1
- package/build/src/modeling/rules/MatchUserRole.d.ts +4 -1
- package/build/src/modeling/rules/MatchUserRole.d.ts.map +1 -1
- package/build/src/modeling/rules/MatchUserRole.js +2 -2
- package/build/src/modeling/rules/MatchUserRole.js.map +1 -1
- package/build/src/modeling/rules/index.d.ts +4 -1
- package/build/src/modeling/rules/index.d.ts.map +1 -1
- package/build/src/modeling/rules/index.js +7 -7
- package/build/src/modeling/rules/index.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modeling/ApiModel.ts +37 -13
- package/src/modeling/ExposedEntity.ts +62 -16
- package/src/modeling/actions/Action.ts +2 -2
- package/src/modeling/rules/AccessRule.ts +8 -1
- package/src/modeling/rules/AllowAuthenticated.ts +5 -2
- package/src/modeling/rules/AllowPublic.ts +5 -2
- package/src/modeling/rules/MatchEmailDomain.ts +5 -2
- package/src/modeling/rules/MatchResourceOwner.ts +5 -2
- package/src/modeling/rules/MatchUserProperty.ts +5 -2
- package/src/modeling/rules/MatchUserRole.ts +5 -2
- package/tests/unit/modeling/actions/Action.spec.ts +13 -10
- package/tests/unit/modeling/actions/CreateAction.spec.ts +7 -6
- package/tests/unit/modeling/actions/DeleteAction.spec.ts +7 -6
- package/tests/unit/modeling/actions/ListAction.spec.ts +5 -4
- package/tests/unit/modeling/actions/ReadAction.spec.ts +9 -8
- package/tests/unit/modeling/actions/SearchAction.spec.ts +5 -4
- package/tests/unit/modeling/actions/UpdateAction.spec.ts +7 -6
- package/tests/unit/modeling/actions/helpers.ts +7 -0
- package/tests/unit/modeling/api_model.spec.ts +3 -1
- package/tests/unit/modeling/api_model_expose_entity.spec.ts +5 -17
- package/tests/unit/modeling/exposed_entity.spec.ts +6 -2
- package/tests/unit/modeling/exposed_entity_actions.spec.ts +0 -4
- package/tests/unit/modeling/rules/AccessRule.spec.ts +6 -5
- package/tests/unit/modeling/rules/AllowAuthenticated.spec.ts +4 -3
- package/tests/unit/modeling/rules/AllowPublic.spec.ts +4 -3
- package/tests/unit/modeling/rules/MatchEmailDomain.spec.ts +6 -5
- package/tests/unit/modeling/rules/MatchResourceOwner.spec.ts +7 -6
- package/tests/unit/modeling/rules/MatchUserProperty.spec.ts +6 -5
- package/tests/unit/modeling/rules/MatchUserRole.spec.ts +6 -5
- package/tests/unit/modeling/rules/restoring_rules.spec.ts +19 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiModel.d.ts","sourceRoot":"","sources":["../../../src/modeling/ApiModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAqC,MAAM,oBAAoB,CAAA;AACpF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EAEnB,oBAAoB,EAEpB,aAAa,EACb,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAItG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAA;
|
|
1
|
+
{"version":3,"file":"ApiModel.d.ts","sourceRoot":"","sources":["../../../src/modeling/ApiModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAqC,MAAM,oBAAoB,CAAA;AACpF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,KAAK,EACV,iBAAiB,EAC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GAAG,SAAS,CAMnC;IAED,MAAM,CAAC,YAAY,CAAC,KAAK,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,cAAc;gBA2C5D,KAAK,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,EAAE,gBAAgB;IAsEtE,MAAM,IAAI,cAAc;IAyCxB;;;;OAIG;IACH,YAAY;IAYZ;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa;IAqE/E;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAmHhC;;;;;OAKG;IACH,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAUtC,OAAO,CAAC,kBAAkB;IAqB1B;;;;OAIG;IACH,oBAAoB,IAAI,IAAI;IAkB5B;;;;;;OAMG;IACH,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAc1C;;;;;;;OAOG;IACH,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAYnF;;;;;;;OAOG;IACH,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;CAWtF"}
|
|
@@ -10,6 +10,7 @@ import { createDomainKey } from './helpers/keying.js';
|
|
|
10
10
|
import { ExposedEntity } from './ExposedEntity.js';
|
|
11
11
|
import { RateLimitingConfiguration } from './rules/RateLimitingConfiguration.js';
|
|
12
12
|
import { restoreAccessRule } from './rules/index.js';
|
|
13
|
+
import { Exception } from '../exceptions/exception.js';
|
|
13
14
|
let ApiModel = (() => {
|
|
14
15
|
let _classSuper = DependentModel;
|
|
15
16
|
let _exposes_decorators;
|
|
@@ -36,8 +37,8 @@ let ApiModel = (() => {
|
|
|
36
37
|
return class ApiModel extends _classSuper {
|
|
37
38
|
static {
|
|
38
39
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
39
|
-
_exposes_decorators = [observed(
|
|
40
|
-
_accessRule_decorators = [observed(
|
|
40
|
+
_exposes_decorators = [observed()];
|
|
41
|
+
_accessRule_decorators = [observed()];
|
|
41
42
|
_rateLimiting_decorators = [observed()];
|
|
42
43
|
_termsOfService_decorators = [observed()];
|
|
43
44
|
_contact_decorators = [observed({ deep: true })];
|
|
@@ -218,7 +219,10 @@ let ApiModel = (() => {
|
|
|
218
219
|
instances.push(new DataDomain(domain));
|
|
219
220
|
}
|
|
220
221
|
else if (domain) {
|
|
221
|
-
throw new
|
|
222
|
+
throw new Exception(`Invalid domain provided. Expected a DataDomain instance or schema.`, {
|
|
223
|
+
code: 'E_DOMAIN_INVALID',
|
|
224
|
+
help: 'It looks like the provided data domain is not a valid instance or domain schema.',
|
|
225
|
+
});
|
|
222
226
|
}
|
|
223
227
|
// Note that since we're using the `DependentModel` class, but the API Model can have only one dependency,
|
|
224
228
|
// we keep the reference to the data domain under the `dependencyList` property.
|
|
@@ -226,7 +230,11 @@ let ApiModel = (() => {
|
|
|
226
230
|
// process when the API model is loaded from the API.
|
|
227
231
|
if (domain) {
|
|
228
232
|
if (!domain.info.version) {
|
|
229
|
-
throw new
|
|
233
|
+
throw new Exception(`Domain ${domain.key} must have a version.`, {
|
|
234
|
+
code: 'E_DOMAIN_NO_VERSION',
|
|
235
|
+
// eslint-disable-next-line max-len
|
|
236
|
+
help: 'Before attaching the data domain, give it a version name. Only versioned domains can be attached to an API model.',
|
|
237
|
+
});
|
|
230
238
|
}
|
|
231
239
|
init.dependencyList = [{ key: domain.key, version: domain.info.version }];
|
|
232
240
|
}
|
|
@@ -252,7 +260,7 @@ let ApiModel = (() => {
|
|
|
252
260
|
this.exposes = new Map();
|
|
253
261
|
}
|
|
254
262
|
if (Array.isArray(init.accessRule)) {
|
|
255
|
-
this.accessRule = init.accessRule.map((rule) => restoreAccessRule(rule));
|
|
263
|
+
this.accessRule = init.accessRule.map((rule) => restoreAccessRule(this, rule));
|
|
256
264
|
}
|
|
257
265
|
else {
|
|
258
266
|
this.accessRule = [];
|
|
@@ -345,7 +353,10 @@ let ApiModel = (() => {
|
|
|
345
353
|
exposeEntity(entity, options) {
|
|
346
354
|
const domain = this.domain;
|
|
347
355
|
if (!domain) {
|
|
348
|
-
throw new
|
|
356
|
+
throw new Exception(`No domain attached to API model`, {
|
|
357
|
+
code: 'E_NO_DOMAIN',
|
|
358
|
+
help: 'Attach a data domain to the API model before exposing entities.',
|
|
359
|
+
});
|
|
349
360
|
}
|
|
350
361
|
// checks whether the entity is already exposed as a root exposure.
|
|
351
362
|
let existing;
|
|
@@ -356,13 +367,17 @@ let ApiModel = (() => {
|
|
|
356
367
|
}
|
|
357
368
|
}
|
|
358
369
|
if (existing) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
370
|
+
throw new Exception(`Entity ${entity.key} is already exposed.`, {
|
|
371
|
+
code: 'E_ENTITY_ALREADY_EXPOSED',
|
|
372
|
+
help: 'Do not try to expose already exposed entity.',
|
|
373
|
+
});
|
|
362
374
|
}
|
|
363
375
|
const domainEntity = domain.findEntity(entity.key, entity.domain);
|
|
364
376
|
if (!domainEntity) {
|
|
365
|
-
throw new
|
|
377
|
+
throw new Exception(`Entity not found in domain: ${entity.key}`, {
|
|
378
|
+
code: 'E_NO_ENTITY',
|
|
379
|
+
help: 'Make sure the entity you are trying to expose exists in the data domain.',
|
|
380
|
+
});
|
|
366
381
|
}
|
|
367
382
|
const name = domainEntity.info.name || '';
|
|
368
383
|
const segment = pluralize(name.toLocaleLowerCase());
|
|
@@ -410,7 +425,9 @@ let ApiModel = (() => {
|
|
|
410
425
|
followEntityAssociations(parentExposure, options) {
|
|
411
426
|
const domain = this.domain;
|
|
412
427
|
if (!domain) {
|
|
413
|
-
|
|
428
|
+
throw new Exception(`No domain attached to API model`, {
|
|
429
|
+
code: 'E_NO_DOMAIN',
|
|
430
|
+
});
|
|
414
431
|
}
|
|
415
432
|
const maxDepth = options.maxDepth ?? 6;
|
|
416
433
|
const follow = (currentEntity, parentKey, depth, currentPath) => {
|
|
@@ -520,7 +537,10 @@ let ApiModel = (() => {
|
|
|
520
537
|
*/
|
|
521
538
|
removeExposedEntity(key) {
|
|
522
539
|
if (!this.exposes.has(key)) {
|
|
523
|
-
throw new
|
|
540
|
+
throw new Exception(`Exposed entity with key "${key}" not found.`, {
|
|
541
|
+
code: 'E_NO_EXPOSURE',
|
|
542
|
+
help: 'The exposed entity you are trying to remove does not exist.',
|
|
543
|
+
});
|
|
524
544
|
}
|
|
525
545
|
this.removeWithChildren(key);
|
|
526
546
|
}
|
|
@@ -575,7 +595,11 @@ let ApiModel = (() => {
|
|
|
575
595
|
*/
|
|
576
596
|
attachDataDomain(domain) {
|
|
577
597
|
if (!domain.info.version) {
|
|
578
|
-
throw new
|
|
598
|
+
throw new Exception(`Cannot attach DataDomain without a version. Please set the version in the domain info.`, {
|
|
599
|
+
code: 'E_DOMAIN_NO_VERSION',
|
|
600
|
+
// eslint-disable-next-line max-len
|
|
601
|
+
help: 'Before attaching the data domain, give it a version name. Only versioned domains can be attached to an API model.',
|
|
602
|
+
});
|
|
579
603
|
}
|
|
580
604
|
this.cleanForDomainChange();
|
|
581
605
|
this.dependencies.set(domain.key, domain);
|
|
@@ -1 +1 @@
|
|
|
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,EAAoB,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAa5D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAoD,MAAM,qBAAqB,CAAA;AACtG,OAAO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;oBAC/B,SAAQ;gBACV,CAAC;gBACD,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;oBAC7D,OAAO,CAAC,CAAA;gBACV,CAAC;YACH,CAAC;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;;;SAnkBU,QAAQ","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { ApiModelKind, DataDomainKind, ExposedEntityKind } from '../models/kinds.js'\nimport { type ThingSchema, Thing } from '../models/Thing.js'\nimport type {\n AssociationTarget,\n AuthenticationStrategy,\n AuthorizationStrategy,\n ExposedEntitySchema,\n RolesBasedAccessControl,\n SessionConfiguration,\n UsernamePasswordConfiguration,\n ExposeOptions,\n OffsetPaginationStrategy,\n CursorPaginationStrategy,\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'\nimport { AccessRule, AccessRuleSchema } from './rules/AccessRule.js'\nimport { RateLimitingConfiguration, RateLimitingConfigurationSchema } from './rules/RateLimitingConfiguration.js'\nimport { restoreAccessRule } from './rules/index.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: ThingSchema\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?: AuthenticationStrategy\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?: AuthorizationStrategy\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?: AccessRuleSchema[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n rateLimiting?: RateLimitingConfigurationSchema\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 * The pagination strategy used by all endpoints in this API. The configuration\n * is shared across all endpoints to ensure consistency and security.\n * This defines how the results are paginated when retrieving a collection of resources.\n */\n pagination: CursorPaginationStrategy | OffsetPaginationStrategy\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?: AuthenticationStrategy\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?: AuthorizationStrategy\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 * The `key` is the key of the exposed entity. Using a Map to allow for quick lookups.\n */\n @observed({ deep: true }) accessor exposes: Map<string, 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 @observed({ deep: true }) accessor accessRule: AccessRule[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n @observed() accessor rateLimiting: RateLimitingConfiguration | undefined\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 * The pagination strategy used by all endpoints in this API.\n * This defines how the results are paginated when retrieving a collection of resources.\n */\n @observed({ deep: true }) accessor pagination: CursorPaginationStrategy | OffsetPaginationStrategy\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 = [], pagination } = 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 pagination: pagination ? structuredClone(pagination) : { kind: 'cursor' },\n }\n if (input.user) {\n result.user = structuredClone(input.user)\n }\n if (input.dependencyList) {\n result.dependencyList = structuredClone(input.dependencyList)\n }\n if (input.authentication) {\n result.authentication = structuredClone(input.authentication)\n }\n if (input.authorization) {\n result.authorization = structuredClone(input.authorization)\n }\n if (input.session) {\n result.session = structuredClone(input.session)\n }\n if (Array.isArray(input.accessRule)) {\n result.accessRule = structuredClone(input.accessRule)\n }\n if (input.rateLimiting) {\n result.rateLimiting = structuredClone(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 // Note that since we're using the `DependentModel` class, but the API Model can have only one dependency,\n // we keep the reference to the data domain under the `dependencyList` property.\n // It is all handled by the parent class `DependentModel`. This way we simplify the dependency management (loading)\n // process when the API model is loaded from the API.\n if (domain) {\n if (!domain.info.version) {\n throw new Error(`Domain ${domain.key} must have a version.`)\n }\n init.dependencyList = [{ key: domain.key, version: domain.info.version }]\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 this.pagination = init.pagination ? structuredClone(init.pagination) : { kind: 'cursor' }\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 = new Map(init.exposes.map((e) => [e.key, new ExposedEntity(this, e)]))\n } else {\n this.exposes = new Map()\n }\n if (Array.isArray(init.accessRule)) {\n this.accessRule = init.accessRule.map((rule) => restoreAccessRule(rule))\n } else {\n this.accessRule = []\n }\n if (init.rateLimiting) {\n this.rateLimiting = new RateLimitingConfiguration(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: Array.from(this.exposes.values()).map((e) => e.toJSON()),\n pagination: structuredClone(toRaw(this, this.pagination)) as CursorPaginationStrategy | OffsetPaginationStrategy,\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 (Array.isArray(this.accessRule) && this.accessRule.length > 0) {\n result.accessRule = this.accessRule.map((rule) => rule.toJSON())\n }\n if (this.rateLimiting) {\n result.rateLimiting = this.rateLimiting.toJSON()\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 *\n * The logic regarding exposing an entity:\n * - If the entity is already exposed as a root entity, it returns the existing one.\n * - If the entity has an association, we expose that entity as a nested entity (by setting the parent property).\n * - If the associated entity is already exposed as a root entity, we do not follow the association.\n *\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 let existing: ExposedEntity | undefined\n for (const exp of this.exposes.values()) {\n if (exp.isRoot && exp.entity.key === entity.key) {\n existing = exp\n break\n }\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 let relativeCollectionPath = `/${segment}`\n let relativeResourcePath = `/${segment}/{id}`\n\n // Check for root path collision and resolve by appending a number\n let counter = 1\n const originalCollectionPath = relativeCollectionPath\n while (this.findCollectionPathCollision(relativeCollectionPath)) {\n relativeCollectionPath = `${originalCollectionPath}-${counter}`\n relativeResourcePath = `${relativeCollectionPath}/{id}`\n counter++\n }\n\n const newEntity: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key: nanoid(),\n entity: { ...entity },\n actions: [],\n isRoot: true,\n collectionPath: relativeCollectionPath,\n resourcePath: relativeResourcePath,\n hasCollection: true,\n }\n if (options) {\n newEntity.exposeOptions = { ...options }\n }\n const created = new ExposedEntity(this, newEntity)\n this.exposes.set(created.key, 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 follow = (currentEntity: AssociationTarget, parentKey: string, depth: number, currentPath: string[]) => {\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 const targetKeys = createDomainKey(target)\n // Circular dependency check: if this entity is already in our *current* traversal path\n if (currentPath.includes(targetKeys)) {\n continue\n }\n\n // Check if this entity is ALREADY exposed anywhere in the model\n let existingExposure: ExposedEntity | undefined\n for (const exp of this.exposes.values()) {\n if (exp.entity.key === target.key) {\n existingExposure = exp\n break\n }\n }\n\n if (existingExposure) {\n // If it's already exposed and NOT root (i.e., it's currently a nested child of someone else),\n // promote it to ROOT to avoid duplicating it or deeply nesting it in multiple places.\n if (!existingExposure.isRoot) {\n // 1. Calculate new root paths (handling collisions)\n const targetDomEntity = domain.findEntity(target.key, target.domain)\n if (targetDomEntity) {\n const name = targetDomEntity.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n let relativeCollectionPath = `/${segment}`\n let relativeResourcePath = `/${segment}/{id}`\n\n let counter = 1\n const originalCollectionPath = relativeCollectionPath\n while (this.findResourcePathCollision(relativeCollectionPath)) {\n relativeCollectionPath = `${originalCollectionPath}-${counter}`\n relativeResourcePath = `${relativeCollectionPath}/{id}`\n counter++\n }\n\n // 2. Update properties to make it root\n existingExposure.isRoot = true\n existingExposure.parent = undefined\n existingExposure.collectionPath = relativeCollectionPath\n existingExposure.resourcePath = relativeResourcePath\n existingExposure.hasCollection = true\n }\n }\n // Whether it was already root or we just promoted it, we stop following here.\n continue\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 collectionPath: relativeCollectionPath,\n resourcePath: 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 const inst = new ExposedEntity(this, nestedExposure)\n this.exposes.set(inst.key, inst)\n if (depth + 1 >= maxDepth) {\n nestedExposure.truncated = true\n } else {\n // Recursively follow associations\n follow(target, nestedExposure.key, depth + 1, [...currentPath, targetKeys])\n }\n }\n }\n }\n\n // Start following from the root exposure\n // Initial path contains the root entity itself\n const rootKey = createDomainKey(parentExposure.entity)\n follow(parentExposure.entity, parentExposure.key, 0, [rootKey])\n }\n\n /**\n * Removes an exposed entity from the API model.\n * This also removes any nested exposed entities that are children of the removed entity.\n *\n * @param key The key of the exposed entity to remove.\n */\n removeExposedEntity(key: string): void {\n if (!this.exposes.has(key)) {\n throw new Error(`Exposed entity with key \"${key}\" not found.`)\n }\n this.removeWithChildren(key)\n }\n\n private removeWithChildren(key: string): void {\n if (!this.exposes.has(key)) {\n return\n }\n // Remove the parent itself\n this.exposes.delete(key)\n // Remove all children recursively\n const removeChildren = (parentKey: string) => {\n // Find all exposures whose parent.key matches parentKey\n for (const child of this.exposes.values()) {\n if (child.parent?.key === parentKey) {\n removeChildren(child.key)\n this.exposes.delete(child.key)\n }\n }\n }\n // Then also remove children\n removeChildren(key)\n this.notifyChange()\n }\n\n /**\n * Clears the API model for a new data domain change.\n * This method resets the dependencies, exposes, user,\n * authentication, authorization, and session properties.\n */\n cleanForDomainChange(): void {\n this.dependencies.clear()\n this.dependencyList = []\n this.exposes = new Map()\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.cleanForDomainChange()\n this.dependencies.set(domain.key, domain)\n this.dependencyList = [{ key: domain.key, version: domain.info.version }]\n this.notifyChange()\n }\n\n /**\n * Finds an existing root exposed entity that has the given resource path.\n * Useful for detecting path collisions when adding or updating an exposed entity.\n *\n * @param path The resource path to check for collisions.\n * @param ignore Optional key of an exposed entity to ignore during the check (usually the entity being updated).\n * @returns The colliding `ExposedEntity` if found, otherwise `undefined`.\n */\n findResourcePathCollision(path: string, ignore?: string): ExposedEntity | undefined {\n for (const e of this.exposes.values()) {\n if (ignore && e.key === ignore) {\n continue\n }\n if (e.isRoot && e.resourcePath === path) {\n return e\n }\n }\n return undefined\n }\n\n /**\n * Finds an existing root exposed entity that has the given collection path.\n * Useful for detecting path collisions when adding or updating an exposed entity.\n *\n * @param path The collection path to check for collisions.\n * @param ignore Optional key of an exposed entity to ignore during the check (usually the entity being updated).\n * @returns The colliding `ExposedEntity` if found, otherwise `undefined`.\n */\n findCollectionPathCollision(path: string, ignore?: string): ExposedEntity | undefined {\n for (const e of this.exposes.values()) {\n if (ignore && e.key === ignore) {\n continue\n }\n if (e.isRoot && e.hasCollection && e.collectionPath === path) {\n return e\n }\n }\n return undefined\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,EAAoB,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAa5D,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,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,yBAAyB,EAAmC,MAAM,sCAAsC,CAAA;AACjH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;IAiHzC,QAAQ;sBAAS,cAAc;;;;;;;;;;;;;;;;;;;;;;iBAA/B,QAAS,SAAQ,WAAc;;;mCA8CzC,QAAQ,EAAE;sCASV,QAAQ,EAAE;wCAKV,QAAQ,EAAE;0CAIV,QAAQ,EAAE;mCAIV,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;mCAIxB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;sCAKxB,QAAQ,CAAC,EAAE,I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CAAC,aAAa,IAAI,CAAC,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;oBAC7D,OAAO,CAAC,CAAA;gBACV,CAAC;YACH,CAAC;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;;;SA1lBU,QAAQ","sourcesContent":["import { nanoid } from '../nanoid.js'\nimport { ApiModelKind, DataDomainKind, ExposedEntityKind } from '../models/kinds.js'\nimport { type ThingSchema, Thing } from '../models/Thing.js'\nimport type {\n AssociationTarget,\n AuthenticationStrategy,\n AuthorizationStrategy,\n ExposedEntitySchema,\n RolesBasedAccessControl,\n SessionConfiguration,\n UsernamePasswordConfiguration,\n ExposeOptions,\n OffsetPaginationStrategy,\n CursorPaginationStrategy,\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'\nimport { AccessRule, AccessRuleSchema } from './rules/AccessRule.js'\nimport { RateLimitingConfiguration, RateLimitingConfigurationSchema } from './rules/RateLimitingConfiguration.js'\nimport { restoreAccessRule } from './rules/index.js'\nimport { Exception } from '../exceptions/exception.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: ThingSchema\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?: AuthenticationStrategy\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?: AuthorizationStrategy\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?: AccessRuleSchema[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n rateLimiting?: RateLimitingConfigurationSchema\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 * The pagination strategy used by all endpoints in this API. The configuration\n * is shared across all endpoints to ensure consistency and security.\n * This defines how the results are paginated when retrieving a collection of resources.\n */\n pagination: CursorPaginationStrategy | OffsetPaginationStrategy\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?: AuthenticationStrategy\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?: AuthorizationStrategy\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 * The `key` is the key of the exposed entity. Using a Map to allow for quick lookups.\n */\n @observed() accessor exposes: Map<string, 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 @observed() accessor accessRule: AccessRule[]\n /**\n * Optional configuration for API-wide rate limiting and throttling.\n * Defines rules to protect the API from overuse.\n */\n @observed() accessor rateLimiting: RateLimitingConfiguration | undefined\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 * The pagination strategy used by all endpoints in this API.\n * This defines how the results are paginated when retrieving a collection of resources.\n */\n @observed({ deep: true }) accessor pagination: CursorPaginationStrategy | OffsetPaginationStrategy\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 = [], pagination } = 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 pagination: pagination ? structuredClone(pagination) : { kind: 'cursor' },\n }\n if (input.user) {\n result.user = structuredClone(input.user)\n }\n if (input.dependencyList) {\n result.dependencyList = structuredClone(input.dependencyList)\n }\n if (input.authentication) {\n result.authentication = structuredClone(input.authentication)\n }\n if (input.authorization) {\n result.authorization = structuredClone(input.authorization)\n }\n if (input.session) {\n result.session = structuredClone(input.session)\n }\n if (Array.isArray(input.accessRule)) {\n result.accessRule = structuredClone(input.accessRule)\n }\n if (input.rateLimiting) {\n result.rateLimiting = structuredClone(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 Exception(`Invalid domain provided. Expected a DataDomain instance or schema.`, {\n code: 'E_DOMAIN_INVALID',\n help: 'It looks like the provided data domain is not a valid instance or domain schema.',\n })\n }\n // Note that since we're using the `DependentModel` class, but the API Model can have only one dependency,\n // we keep the reference to the data domain under the `dependencyList` property.\n // It is all handled by the parent class `DependentModel`. This way we simplify the dependency management (loading)\n // process when the API model is loaded from the API.\n if (domain) {\n if (!domain.info.version) {\n throw new Exception(`Domain ${domain.key} must have a version.`, {\n code: 'E_DOMAIN_NO_VERSION',\n // eslint-disable-next-line max-len\n help: 'Before attaching the data domain, give it a version name. Only versioned domains can be attached to an API model.',\n })\n }\n init.dependencyList = [{ key: domain.key, version: domain.info.version }]\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 this.pagination = init.pagination ? structuredClone(init.pagination) : { kind: 'cursor' }\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 = new Map(init.exposes.map((e) => [e.key, new ExposedEntity(this, e)]))\n } else {\n this.exposes = new Map()\n }\n if (Array.isArray(init.accessRule)) {\n this.accessRule = init.accessRule.map((rule) => restoreAccessRule(this, rule))\n } else {\n this.accessRule = []\n }\n if (init.rateLimiting) {\n this.rateLimiting = new RateLimitingConfiguration(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: Array.from(this.exposes.values()).map((e) => e.toJSON()),\n pagination: structuredClone(toRaw(this, this.pagination)) as CursorPaginationStrategy | OffsetPaginationStrategy,\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 (Array.isArray(this.accessRule) && this.accessRule.length > 0) {\n result.accessRule = this.accessRule.map((rule) => rule.toJSON())\n }\n if (this.rateLimiting) {\n result.rateLimiting = this.rateLimiting.toJSON()\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 *\n * The logic regarding exposing an entity:\n * - If the entity is already exposed as a root entity, it returns the existing one.\n * - If the entity has an association, we expose that entity as a nested entity (by setting the parent property).\n * - If the associated entity is already exposed as a root entity, we do not follow the association.\n *\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 Exception(`No domain attached to API model`, {\n code: 'E_NO_DOMAIN',\n help: 'Attach a data domain to the API model before exposing entities.',\n })\n }\n // checks whether the entity is already exposed as a root exposure.\n let existing: ExposedEntity | undefined\n for (const exp of this.exposes.values()) {\n if (exp.isRoot && exp.entity.key === entity.key) {\n existing = exp\n break\n }\n }\n if (existing) {\n throw new Exception(`Entity ${entity.key} is already exposed.`, {\n code: 'E_ENTITY_ALREADY_EXPOSED',\n help: 'Do not try to expose already exposed entity.',\n })\n }\n const domainEntity = domain.findEntity(entity.key, entity.domain)\n if (!domainEntity) {\n throw new Exception(`Entity not found in domain: ${entity.key}`, {\n code: 'E_NO_ENTITY',\n help: 'Make sure the entity you are trying to expose exists in the data domain.',\n })\n }\n const name = domainEntity.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n let relativeCollectionPath = `/${segment}`\n let relativeResourcePath = `/${segment}/{id}`\n\n // Check for root path collision and resolve by appending a number\n let counter = 1\n const originalCollectionPath = relativeCollectionPath\n while (this.findCollectionPathCollision(relativeCollectionPath)) {\n relativeCollectionPath = `${originalCollectionPath}-${counter}`\n relativeResourcePath = `${relativeCollectionPath}/{id}`\n counter++\n }\n\n const newEntity: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key: nanoid(),\n entity: { ...entity },\n actions: [],\n isRoot: true,\n collectionPath: relativeCollectionPath,\n resourcePath: relativeResourcePath,\n hasCollection: true,\n }\n if (options) {\n newEntity.exposeOptions = { ...options }\n }\n const created = new ExposedEntity(this, newEntity)\n this.exposes.set(created.key, 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 throw new Exception(`No domain attached to API model`, {\n code: 'E_NO_DOMAIN',\n })\n }\n const maxDepth = options.maxDepth ?? 6\n const follow = (currentEntity: AssociationTarget, parentKey: string, depth: number, currentPath: string[]) => {\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 const targetKeys = createDomainKey(target)\n // Circular dependency check: if this entity is already in our *current* traversal path\n if (currentPath.includes(targetKeys)) {\n continue\n }\n\n // Check if this entity is ALREADY exposed anywhere in the model\n let existingExposure: ExposedEntity | undefined\n for (const exp of this.exposes.values()) {\n if (exp.entity.key === target.key) {\n existingExposure = exp\n break\n }\n }\n\n if (existingExposure) {\n // If it's already exposed and NOT root (i.e., it's currently a nested child of someone else),\n // promote it to ROOT to avoid duplicating it or deeply nesting it in multiple places.\n if (!existingExposure.isRoot) {\n // 1. Calculate new root paths (handling collisions)\n const targetDomEntity = domain.findEntity(target.key, target.domain)\n if (targetDomEntity) {\n const name = targetDomEntity.info.name || ''\n const segment = pluralize(name.toLocaleLowerCase())\n let relativeCollectionPath = `/${segment}`\n let relativeResourcePath = `/${segment}/{id}`\n\n let counter = 1\n const originalCollectionPath = relativeCollectionPath\n while (this.findResourcePathCollision(relativeCollectionPath)) {\n relativeCollectionPath = `${originalCollectionPath}-${counter}`\n relativeResourcePath = `${relativeCollectionPath}/{id}`\n counter++\n }\n\n // 2. Update properties to make it root\n existingExposure.isRoot = true\n existingExposure.parent = undefined\n existingExposure.collectionPath = relativeCollectionPath\n existingExposure.resourcePath = relativeResourcePath\n existingExposure.hasCollection = true\n }\n }\n // Whether it was already root or we just promoted it, we stop following here.\n continue\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 collectionPath: relativeCollectionPath,\n resourcePath: 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 const inst = new ExposedEntity(this, nestedExposure)\n this.exposes.set(inst.key, inst)\n if (depth + 1 >= maxDepth) {\n nestedExposure.truncated = true\n } else {\n // Recursively follow associations\n follow(target, nestedExposure.key, depth + 1, [...currentPath, targetKeys])\n }\n }\n }\n }\n\n // Start following from the root exposure\n // Initial path contains the root entity itself\n const rootKey = createDomainKey(parentExposure.entity)\n follow(parentExposure.entity, parentExposure.key, 0, [rootKey])\n }\n\n /**\n * Removes an exposed entity from the API model.\n * This also removes any nested exposed entities that are children of the removed entity.\n *\n * @param key The key of the exposed entity to remove.\n */\n removeExposedEntity(key: string): void {\n if (!this.exposes.has(key)) {\n throw new Exception(`Exposed entity with key \"${key}\" not found.`, {\n code: 'E_NO_EXPOSURE',\n help: 'The exposed entity you are trying to remove does not exist.',\n })\n }\n this.removeWithChildren(key)\n }\n\n private removeWithChildren(key: string): void {\n if (!this.exposes.has(key)) {\n return\n }\n // Remove the parent itself\n this.exposes.delete(key)\n // Remove all children recursively\n const removeChildren = (parentKey: string) => {\n // Find all exposures whose parent.key matches parentKey\n for (const child of this.exposes.values()) {\n if (child.parent?.key === parentKey) {\n removeChildren(child.key)\n this.exposes.delete(child.key)\n }\n }\n }\n // Then also remove children\n removeChildren(key)\n this.notifyChange()\n }\n\n /**\n * Clears the API model for a new data domain change.\n * This method resets the dependencies, exposes, user,\n * authentication, authorization, and session properties.\n */\n cleanForDomainChange(): void {\n this.dependencies.clear()\n this.dependencyList = []\n this.exposes = new Map()\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 Exception(`Cannot attach DataDomain without a version. Please set the version in the domain info.`, {\n code: 'E_DOMAIN_NO_VERSION',\n // eslint-disable-next-line max-len\n help: 'Before attaching the data domain, give it a version name. Only versioned domains can be attached to an API model.',\n })\n }\n this.cleanForDomainChange()\n this.dependencies.set(domain.key, domain)\n this.dependencyList = [{ key: domain.key, version: domain.info.version }]\n this.notifyChange()\n }\n\n /**\n * Finds an existing root exposed entity that has the given resource path.\n * Useful for detecting path collisions when adding or updating an exposed entity.\n *\n * @param path The resource path to check for collisions.\n * @param ignore Optional key of an exposed entity to ignore during the check (usually the entity being updated).\n * @returns The colliding `ExposedEntity` if found, otherwise `undefined`.\n */\n findResourcePathCollision(path: string, ignore?: string): ExposedEntity | undefined {\n for (const e of this.exposes.values()) {\n if (ignore && e.key === ignore) {\n continue\n }\n if (e.isRoot && e.resourcePath === path) {\n return e\n }\n }\n return undefined\n }\n\n /**\n * Finds an existing root exposed entity that has the given collection path.\n * Useful for detecting path collisions when adding or updating an exposed entity.\n *\n * @param path The collection path to check for collisions.\n * @param ignore Optional key of an exposed entity to ignore during the check (usually the entity being updated).\n * @returns The colliding `ExposedEntity` if found, otherwise `undefined`.\n */\n findCollectionPathCollision(path: string, ignore?: string): ExposedEntity | undefined {\n for (const e of this.exposes.values()) {\n if (ignore && e.key === ignore) {\n continue\n }\n if (e.isRoot && e.hasCollection && e.collectionPath === path) {\n return e\n }\n }\n return undefined\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExposedEntity.d.ts","sourceRoot":"","sources":["../../../src/modeling/ExposedEntity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExposedEntity.d.ts","sourceRoot":"","sources":["../../../src/modeling/ExposedEntity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,oBAAoB,CAAA;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,KAAK,aAAa,EAAqB,MAAM,kBAAkB,CAAA;AACxE,OAAO,E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C;IAyBjE,YAAY;IAaZ,MAAM,IAAI,mBAAmB;IAoC7B;;;;;;;;OAQG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM;IA4C9B;;;;;;;;OAQG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM;IA6E5B;;;;;OAKG;IACH,uBAAuB,IAAI,MAAM;IAcjC;;;;;;OAMG;IACH,yBAAyB,IAAI,MAAM,GAAG,SAAS;IAe/C;;OAEG;IACH,WAAW,IAAI,UAAU,EAAE;IAc3B;;OAEG;IACH,kBAAkB,IAAI,yBAAyB,EAAE;IAgBjD;;;OAGG;IACH,sBAAsB,IAAI,aAAa,EAAE;IAgBzC;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM;IAY1C;;;;;;;OAOG;IACH,wBAAwB,IAAI,IAAI;CA+BjC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
2
|
import { observed, toRaw } from '../decorators/observed.js';
|
|
3
|
+
import { Exception } from '../exceptions/exception.js';
|
|
3
4
|
import { ExposedEntityKind } from '../models/kinds.js';
|
|
4
5
|
import { nanoid } from '../nanoid.js';
|
|
5
6
|
import { restoreAction } from './actions/index.js';
|
|
@@ -49,8 +50,8 @@ let ExposedEntity = (() => {
|
|
|
49
50
|
_entity_decorators = [observed()];
|
|
50
51
|
_collectionPath_decorators = [observed()];
|
|
51
52
|
_resourcePath_decorators = [observed()];
|
|
52
|
-
_actions_decorators = [observed(
|
|
53
|
-
_accessRule_decorators = [observed(
|
|
53
|
+
_actions_decorators = [observed()];
|
|
54
|
+
_accessRule_decorators = [observed()];
|
|
54
55
|
_rateLimiting_decorators = [observed()];
|
|
55
56
|
_paginationContract_decorators = [observed({ deep: true })];
|
|
56
57
|
__esDecorate(this, null, _entity_decorators, { kind: "accessor", name: "entity", static: false, private: false, access: { has: obj => "entity" in obj, get: obj => obj.entity, set: (obj, value) => { obj.entity = value; } }, metadata: _metadata }, _entity_initializers, _entity_extraInitializers);
|
|
@@ -218,7 +219,7 @@ let ExposedEntity = (() => {
|
|
|
218
219
|
this.parent = init.parent;
|
|
219
220
|
this.exposeOptions = init.exposeOptions;
|
|
220
221
|
this.actions = init.actions ? init.actions.map((a) => restoreAction(this, a)) : [];
|
|
221
|
-
this.accessRule = init.accessRule ? init.accessRule.map((ar) => restoreAccessRule(ar)) : [];
|
|
222
|
+
this.accessRule = init.accessRule ? init.accessRule.map((ar) => restoreAccessRule(this, ar)) : [];
|
|
222
223
|
if (init.rateLimiting) {
|
|
223
224
|
this.rateLimiting = new RateLimitingConfiguration(init.rateLimiting);
|
|
224
225
|
}
|
|
@@ -237,6 +238,7 @@ let ExposedEntity = (() => {
|
|
|
237
238
|
this.#notifying = false;
|
|
238
239
|
const event = new Event('change');
|
|
239
240
|
this.dispatchEvent(event);
|
|
241
|
+
this.api.notifyChange();
|
|
240
242
|
});
|
|
241
243
|
}
|
|
242
244
|
toJSON() {
|
|
@@ -285,20 +287,29 @@ let ExposedEntity = (() => {
|
|
|
285
287
|
*/
|
|
286
288
|
setCollectionPath(path) {
|
|
287
289
|
if (!this.hasCollection) {
|
|
288
|
-
throw new
|
|
290
|
+
throw new Exception(`Cannot set collection path on an exposure that does not have a collection`, {
|
|
291
|
+
code: 'E_PATH_MISSING',
|
|
292
|
+
help: 'The exposed entity you are trying to set a collection path for does not have a collection.',
|
|
293
|
+
});
|
|
289
294
|
}
|
|
290
295
|
const cleaned = ensureLeadingSlash(path);
|
|
291
296
|
// Ensure exactly one non-empty segment
|
|
292
297
|
const segments = cleaned.split('/').filter(Boolean);
|
|
293
298
|
if (segments.length !== 1) {
|
|
294
|
-
throw new
|
|
299
|
+
throw new Exception(`Collection path must contain exactly one segment. Received: "${path}"`, {
|
|
300
|
+
code: 'E_PATH_SEGMENT_SIZE',
|
|
301
|
+
help: 'The set path must have a single path segment (e.g., `/products`)',
|
|
302
|
+
});
|
|
295
303
|
}
|
|
296
304
|
const normalizedCollection = `/${segments[0]}`;
|
|
297
305
|
// Check for collision if this is a root entity
|
|
298
306
|
if (this.isRoot) {
|
|
299
307
|
const collision = this.api.findCollectionPathCollision(normalizedCollection, this.key);
|
|
300
308
|
if (collision) {
|
|
301
|
-
throw new
|
|
309
|
+
throw new Exception(`Collection path "${normalizedCollection}" is already in use by another root entity.`, {
|
|
310
|
+
code: 'E_PATH_INUSE',
|
|
311
|
+
help: 'The set path is already in use by another root entity.',
|
|
312
|
+
});
|
|
302
313
|
}
|
|
303
314
|
}
|
|
304
315
|
// Preserve current parameter name if present, otherwise default to {id}
|
|
@@ -329,22 +340,38 @@ let ExposedEntity = (() => {
|
|
|
329
340
|
const segments = cleaned.split('/').filter(Boolean);
|
|
330
341
|
if (this.hasCollection) {
|
|
331
342
|
if (!this.collectionPath) {
|
|
332
|
-
throw
|
|
343
|
+
// Why do we throw this error? We should just create it from the resource path...
|
|
344
|
+
throw new Exception('Cannot set resource path: missing collection path for this exposure', {
|
|
345
|
+
code: 'E_PATH_MISSING',
|
|
346
|
+
help: 'Set the collection path on the exposed entity first.',
|
|
347
|
+
});
|
|
333
348
|
}
|
|
334
349
|
const colSegments = this.collectionPath.split('/').filter(Boolean);
|
|
335
350
|
if (colSegments.length !== 1) {
|
|
336
|
-
throw new
|
|
351
|
+
throw new Exception(`Invalid stored collection path "${this.collectionPath}"`, {
|
|
352
|
+
code: 'E_PATH_SEGMENT_SIZE',
|
|
353
|
+
help: 'The set collection path must have a single path segment (e.g., `/products`)',
|
|
354
|
+
});
|
|
337
355
|
}
|
|
338
356
|
if (segments.length !== 2) {
|
|
339
|
-
throw new
|
|
357
|
+
throw new Exception(`Resource path must be exactly two segments (collection + parameter). Received: "${cleaned}"`, {
|
|
358
|
+
code: 'E_PATH_SEGMENT_SIZE',
|
|
359
|
+
help: 'The set resource path must have exactly two segments (collection + parameter).',
|
|
360
|
+
});
|
|
340
361
|
}
|
|
341
362
|
const [s1, s2] = segments;
|
|
342
363
|
if (s1 !== colSegments[0]) {
|
|
343
|
-
throw new
|
|
364
|
+
throw new Exception(`Resource path must start with the collection segment "${colSegments[0]}". Received: "${s1}"`, {
|
|
365
|
+
code: 'E_PATH_MISMATCH',
|
|
366
|
+
help: 'Set the resource path to the same value as the collection path + the parameter value.',
|
|
367
|
+
});
|
|
344
368
|
}
|
|
345
369
|
// s2 must be a parameter segment {name}
|
|
346
370
|
if (!/^\{[A-Za-z_][A-Za-z0-9_]*\}$/.test(s2)) {
|
|
347
|
-
throw new
|
|
371
|
+
throw new Exception(`The second segment must be a parameter in braces, e.g. {id}. Received: "${s2}"`, {
|
|
372
|
+
code: 'E_PARAMETER_INVALID',
|
|
373
|
+
help: 'Use the braces to surround the parameter name, e.g., {productId}.',
|
|
374
|
+
});
|
|
348
375
|
}
|
|
349
376
|
if (this.resourcePath !== cleaned) {
|
|
350
377
|
this.resourcePath = `/${s1}/${s2}`;
|
|
@@ -353,13 +380,19 @@ let ExposedEntity = (() => {
|
|
|
353
380
|
}
|
|
354
381
|
// No collection: allow exactly one segment
|
|
355
382
|
if (segments.length !== 1) {
|
|
356
|
-
throw new
|
|
383
|
+
throw new Exception(`Resource path must contain exactly one segment when no collection is present. Received: "${cleaned}"`, {
|
|
384
|
+
code: 'E_PATH_SEGMENT_SIZE',
|
|
385
|
+
help: 'The set resource path must have exactly one segment.',
|
|
386
|
+
});
|
|
357
387
|
}
|
|
358
388
|
// Check for collision if this is a root entity (singleton case)
|
|
359
389
|
if (this.isRoot) {
|
|
360
390
|
const collision = this.api.findResourcePathCollision(cleaned, this.key);
|
|
361
391
|
if (collision) {
|
|
362
|
-
throw new
|
|
392
|
+
throw new Exception(`Resource path "${cleaned}" is already in use by another root entity.`, {
|
|
393
|
+
code: 'E_PATH_INUSE',
|
|
394
|
+
help: 'The set path is already in use by another root entity.',
|
|
395
|
+
});
|
|
363
396
|
}
|
|
364
397
|
}
|
|
365
398
|
if (this.resourcePath !== cleaned) {
|
|
@@ -469,7 +502,10 @@ let ExposedEntity = (() => {
|
|
|
469
502
|
*/
|
|
470
503
|
addAction(schema) {
|
|
471
504
|
if (this.actions.some((action) => action.kind === schema.kind)) {
|
|
472
|
-
throw new
|
|
505
|
+
throw new Exception(`Action of kind "${schema.kind}" already exists for this exposure`, {
|
|
506
|
+
code: 'E_ACTION_USED',
|
|
507
|
+
help: "There's no need to add an API action again.",
|
|
508
|
+
});
|
|
473
509
|
}
|
|
474
510
|
const action = restoreAction(this, schema);
|
|
475
511
|
this.actions.push(action);
|
|
@@ -486,7 +522,10 @@ let ExposedEntity = (() => {
|
|
|
486
522
|
createPaginationContract() {
|
|
487
523
|
const entity = this.api.domain?.findEntity(this.entity.key, this.entity.domain);
|
|
488
524
|
if (!entity) {
|
|
489
|
-
throw new
|
|
525
|
+
throw new Exception(`Entity "${this.entity.key}" not found"`, {
|
|
526
|
+
code: 'E_ENTITY_NOT_FOUND',
|
|
527
|
+
help: 'The set entity does not exist.',
|
|
528
|
+
});
|
|
490
529
|
}
|
|
491
530
|
if (!this.paginationContract) {
|
|
492
531
|
this.paginationContract = {
|