@api-client/core 0.18.26 → 0.18.28
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 +18 -9
- package/build/src/modeling/ApiModel.d.ts.map +1 -1
- package/build/src/modeling/ApiModel.js +141 -13
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/Semantics.d.ts +7 -0
- package/build/src/modeling/Semantics.d.ts.map +1 -1
- package/build/src/modeling/Semantics.js +23 -0
- package/build/src/modeling/Semantics.js.map +1 -1
- package/build/src/modeling/helpers/endpointHelpers.d.ts +2 -0
- package/build/src/modeling/helpers/endpointHelpers.d.ts.map +1 -0
- package/build/src/modeling/helpers/endpointHelpers.js +6 -0
- package/build/src/modeling/helpers/endpointHelpers.js.map +1 -0
- package/build/src/modeling/helpers/keying.d.ts +9 -0
- package/build/src/modeling/helpers/keying.d.ts.map +1 -0
- package/build/src/modeling/helpers/keying.js +10 -0
- package/build/src/modeling/helpers/keying.js.map +1 -0
- package/build/src/modeling/templates/meta/blog-publishing-platform.json +1 -1
- package/build/src/modeling/templates/meta/financial-services-platform.json +1 -1
- package/build/src/modeling/templates/meta/index.d.ts +1 -1
- package/build/src/modeling/templates/meta/index.js +1 -1
- package/build/src/modeling/templates/meta/index.js.map +1 -1
- package/build/src/modeling/templates/verticals/business-services/financial-services-domain.d.ts.map +1 -1
- package/build/src/modeling/templates/verticals/business-services/financial-services-domain.js +1 -0
- package/build/src/modeling/templates/verticals/business-services/financial-services-domain.js.map +1 -1
- package/build/src/modeling/templates/verticals/technology-media/blog-domain.d.ts.map +1 -1
- package/build/src/modeling/templates/verticals/technology-media/blog-domain.js +12 -4
- package/build/src/modeling/templates/verticals/technology-media/blog-domain.js.map +1 -1
- package/build/src/modeling/types.d.ts +77 -8
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +6 -6
- package/package.json +2 -1
- package/src/modeling/ApiModel.ts +159 -15
- package/src/modeling/Semantics.ts +23 -0
- package/src/modeling/helpers/endpointHelpers.ts +5 -0
- package/src/modeling/helpers/keying.ts +11 -0
- package/src/modeling/readme.md +153 -7
- package/src/modeling/templates/meta/blog-publishing-platform.json +1 -1
- package/src/modeling/templates/meta/financial-services-platform.json +1 -1
- package/src/modeling/templates/verticals/business-services/financial-services-domain.ts +1 -0
- package/src/modeling/templates/verticals/technology-media/blog-domain.ts +12 -4
- package/src/modeling/types.ts +84 -8
- package/tests/unit/modeling/api_model.spec.ts +25 -137
- package/tests/unit/modeling/api_model_expose_entity.spec.ts +190 -0
- package/tests/unit/modeling/api_model_remove_entity.spec.ts +82 -0
- package/tests/unit/modeling/helpers/endpointHelpers.spec.ts +10 -0
- package/tests/unit/modeling/username_semantic.spec.ts +81 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiModelKind } from '../models/kinds.js';
|
|
2
2
|
import { type IThing, Thing } from '../models/Thing.js';
|
|
3
|
-
import type { AccessRule, AssociationTarget, AuthenticationConfiguration, AuthorizationConfiguration, ExposedEntity, RateLimitingConfiguration, SessionConfiguration } from './types.js';
|
|
3
|
+
import type { AccessRule, AssociationTarget, AuthenticationConfiguration, AuthorizationConfiguration, ExposedEntity, RateLimitingConfiguration, SessionConfiguration, ExposeOptions } from './types.js';
|
|
4
4
|
import { DataDomain } from './DataDomain.js';
|
|
5
5
|
import { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js';
|
|
6
6
|
/**
|
|
@@ -39,12 +39,12 @@ export interface ApiModelSchema extends DependentModelSchema {
|
|
|
39
39
|
*/
|
|
40
40
|
kind: typeof ApiModelKind;
|
|
41
41
|
/**
|
|
42
|
-
* The unique key of the
|
|
42
|
+
* The unique key of the API model schema.
|
|
43
43
|
* This is a stable identifier that does not change across versions.
|
|
44
44
|
*/
|
|
45
45
|
key: string;
|
|
46
46
|
/**
|
|
47
|
-
* Contains the name, display name, description, and the version of the
|
|
47
|
+
* Contains the name, display name, description, and the version of the API model schema.
|
|
48
48
|
*/
|
|
49
49
|
info: IThing;
|
|
50
50
|
/**
|
|
@@ -190,21 +190,30 @@ export declare class ApiModel extends DependentModel {
|
|
|
190
190
|
/**
|
|
191
191
|
* Exposes a new entity in the API model.
|
|
192
192
|
* If the entity already exists, it returns the existing one.
|
|
193
|
-
* @param
|
|
193
|
+
* @param entity The entity key and domain to expose.
|
|
194
194
|
* @returns The exposed entity.
|
|
195
195
|
*/
|
|
196
|
-
exposeEntity(
|
|
196
|
+
exposeEntity(entity: AssociationTarget, options?: ExposeOptions): ExposedEntity;
|
|
197
|
+
/**
|
|
198
|
+
* Follows associations for a newly exposed entity if configured to do so.
|
|
199
|
+
* This creates nested exposures based on the entity's associations.
|
|
200
|
+
*
|
|
201
|
+
* @param parentExposure The root exposure to follow associations from
|
|
202
|
+
* @param options The expose options containing follow configuration
|
|
203
|
+
*/
|
|
204
|
+
private followEntityAssociations;
|
|
197
205
|
/**
|
|
198
|
-
* Removes an entity from the API model.
|
|
199
|
-
* @param
|
|
206
|
+
* Removes an exposed entity from the API model.
|
|
207
|
+
* @param entity The entity to remove.
|
|
200
208
|
*/
|
|
201
|
-
removeEntity(
|
|
209
|
+
removeEntity(entity: AssociationTarget): void;
|
|
210
|
+
private removeWithChildren;
|
|
202
211
|
/**
|
|
203
212
|
* Returns the exposed entity by its key.
|
|
204
213
|
* @param entityKey The key of the entity to find.
|
|
205
214
|
* @returns The exposed entity or undefined if not found.
|
|
206
215
|
*/
|
|
207
|
-
getExposedEntity(
|
|
216
|
+
getExposedEntity(entity: AssociationTarget): ExposedEntity | undefined;
|
|
208
217
|
/**
|
|
209
218
|
* Clears the API model for a new entity change.
|
|
210
219
|
* This method resets the dependencies, exposes, user,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiModel.d.ts","sourceRoot":"","sources":["../../../src/modeling/ApiModel.ts"],"names":[],"mapp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AO,EAAE,UAAU,GAAG,SAAS,CAAA;IAgBlE;;;;;;;OAOG;IACH,IAAI,MAAM,IAAI,UAAU,GAAG,SAAS,CAMnC;IAED,MAAM,CAAC,YAAY,CAAC,KAAK,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,cAAc;gBA0C5D,KAAK,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,EAAE,gBAAgB;IAkDtE,MAAM,IAAI,cAAc;IAwCxB;;;;OAIG;IACH,YAAY;IAYZ;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa;IAyC/E;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAiFhC;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAS7C,OAAO,CAAC,kBAAkB;IAwB1B;;;;OAIG;IACH,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,GAAG,SAAS;IAItE;;;;OAIG;IACH,oBAAoB,IAAI,IAAI;IAkB5B;;;;;;OAMG;IACH,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CAS3C"}
|
|
@@ -5,6 +5,8 @@ import { Thing } from '../models/Thing.js';
|
|
|
5
5
|
import { DataDomain } from './DataDomain.js';
|
|
6
6
|
import { DependentModel } from './DependentModel.js';
|
|
7
7
|
import { observed, toRaw } from '../decorators/observed.js';
|
|
8
|
+
import pluralize from '@jarrodek/pluralize';
|
|
9
|
+
import { createDomainKey } from './helpers/keying.js';
|
|
8
10
|
let ApiModel = (() => {
|
|
9
11
|
let _classSuper = DependentModel;
|
|
10
12
|
let _termsOfService_decorators;
|
|
@@ -277,40 +279,166 @@ let ApiModel = (() => {
|
|
|
277
279
|
/**
|
|
278
280
|
* Exposes a new entity in the API model.
|
|
279
281
|
* If the entity already exists, it returns the existing one.
|
|
280
|
-
* @param
|
|
282
|
+
* @param entity The entity key and domain to expose.
|
|
281
283
|
* @returns The exposed entity.
|
|
282
284
|
*/
|
|
283
|
-
exposeEntity(
|
|
284
|
-
const
|
|
285
|
+
exposeEntity(entity, options) {
|
|
286
|
+
const domain = this.domain;
|
|
287
|
+
if (!domain) {
|
|
288
|
+
throw new Error(`No domain attached to API model`);
|
|
289
|
+
}
|
|
290
|
+
// checks whether the entity is already exposed as a root exposure.
|
|
291
|
+
const existing = this.exposes.find((e) => e.isRoot && e.entity.key === entity.key && e.entity.domain === entity.domain);
|
|
285
292
|
if (existing) {
|
|
293
|
+
// quietly return the existing exposure
|
|
294
|
+
// TBD: should we throw an error here?
|
|
286
295
|
return existing;
|
|
287
296
|
}
|
|
297
|
+
const domainEntity = domain.findEntity(entity.key, entity.domain);
|
|
298
|
+
if (!domainEntity) {
|
|
299
|
+
throw new Error(`Entity not found in domain: ${entity.key}`);
|
|
300
|
+
}
|
|
301
|
+
const name = domainEntity.info.name || '';
|
|
288
302
|
const newEntity = {
|
|
289
|
-
key:
|
|
303
|
+
key: nanoid(),
|
|
304
|
+
entity: { ...entity },
|
|
290
305
|
actions: [],
|
|
306
|
+
isRoot: true,
|
|
307
|
+
path: pluralize(name.toLocaleLowerCase()),
|
|
291
308
|
};
|
|
309
|
+
if (options) {
|
|
310
|
+
newEntity.exposeOptions = { ...options };
|
|
311
|
+
}
|
|
292
312
|
this.exposes.push(newEntity);
|
|
313
|
+
// Follow associations if requested
|
|
314
|
+
if (options?.followAssociations) {
|
|
315
|
+
if (options?.maxDepth === undefined || options.maxDepth > 0) {
|
|
316
|
+
this.followEntityAssociations(newEntity, options);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
293
319
|
this.notifyChange();
|
|
294
320
|
return newEntity;
|
|
295
321
|
}
|
|
296
322
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
323
|
+
* Follows associations for a newly exposed entity if configured to do so.
|
|
324
|
+
* This creates nested exposures based on the entity's associations.
|
|
325
|
+
*
|
|
326
|
+
* @param parentExposure The root exposure to follow associations from
|
|
327
|
+
* @param options The expose options containing follow configuration
|
|
299
328
|
*/
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
this.notifyChange();
|
|
329
|
+
followEntityAssociations(parentExposure, options) {
|
|
330
|
+
const domain = this.domain;
|
|
331
|
+
if (!domain) {
|
|
332
|
+
return;
|
|
305
333
|
}
|
|
334
|
+
const maxDepth = options.maxDepth ?? 6;
|
|
335
|
+
const visited = new Set();
|
|
336
|
+
// Add parent entity's key to the visited set so we won't skip it when traversing
|
|
337
|
+
// associations.
|
|
338
|
+
visited.add(createDomainKey(parentExposure.entity));
|
|
339
|
+
const follow = (currentEntity, parentKey, depth) => {
|
|
340
|
+
// Find the domain entity
|
|
341
|
+
const domainEntity = domain.findEntity(currentEntity.key, currentEntity.domain);
|
|
342
|
+
if (!domainEntity)
|
|
343
|
+
return;
|
|
344
|
+
// Iterate through associations
|
|
345
|
+
for (const association of domainEntity.listAssociations()) {
|
|
346
|
+
for (const target of association.targets) {
|
|
347
|
+
// Skip self-referencing associations
|
|
348
|
+
if (target.key === currentEntity.key && target.domain === currentEntity.domain) {
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
// Create unique identifier for circular detection
|
|
352
|
+
const visitKey = createDomainKey(target);
|
|
353
|
+
if (visited.has(visitKey)) {
|
|
354
|
+
continue; // Skip circular references
|
|
355
|
+
}
|
|
356
|
+
visited.add(visitKey);
|
|
357
|
+
// Check if this nested exposure already exists
|
|
358
|
+
const existingNested = this.exposes.find((e) => !e.isRoot &&
|
|
359
|
+
e.entity.key === target.key &&
|
|
360
|
+
e.entity.domain === target.domain &&
|
|
361
|
+
e.parent?.key === parentKey);
|
|
362
|
+
if (existingNested) {
|
|
363
|
+
continue; // Already exposed under this parent
|
|
364
|
+
}
|
|
365
|
+
// Find the target domain entity for path generation
|
|
366
|
+
const targetDomainEntity = domain.findEntity(target.key, target.domain);
|
|
367
|
+
if (!targetDomainEntity)
|
|
368
|
+
continue;
|
|
369
|
+
const name = association.info.name || '';
|
|
370
|
+
// Create nested exposure
|
|
371
|
+
const nestedExposure = {
|
|
372
|
+
key: nanoid(),
|
|
373
|
+
entity: { ...target },
|
|
374
|
+
actions: [],
|
|
375
|
+
isRoot: false,
|
|
376
|
+
path: pluralize(name.toLocaleLowerCase()),
|
|
377
|
+
parent: {
|
|
378
|
+
key: parentKey,
|
|
379
|
+
association: {
|
|
380
|
+
key: association.key,
|
|
381
|
+
domain: currentEntity.domain,
|
|
382
|
+
},
|
|
383
|
+
depth: depth + 1,
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
this.exposes.push(nestedExposure);
|
|
387
|
+
if (depth + 1 >= maxDepth) {
|
|
388
|
+
nestedExposure.truncated = true;
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
// Recursively follow associations
|
|
392
|
+
follow(target, nestedExposure.key, depth + 1);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
// Start following from the root exposure
|
|
398
|
+
follow(parentExposure.entity, parentExposure.key, 0);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Removes an exposed entity from the API model.
|
|
402
|
+
* @param entity The entity to remove.
|
|
403
|
+
*/
|
|
404
|
+
removeEntity(entity) {
|
|
405
|
+
const current = this.exposes.find((e) => e.entity.key === entity.key && e.entity.domain === entity.domain);
|
|
406
|
+
if (!current) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
this.removeWithChildren(current.key);
|
|
410
|
+
this.notifyChange();
|
|
411
|
+
}
|
|
412
|
+
removeWithChildren(key) {
|
|
413
|
+
const index = this.exposes.findIndex((e) => e.key === key);
|
|
414
|
+
if (index < 0) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
// Remove the parent itself
|
|
418
|
+
this.exposes.splice(index, 1);
|
|
419
|
+
// Remove all children recursively
|
|
420
|
+
const removeChildren = (parentKey) => {
|
|
421
|
+
// Find all exposures whose parent.key matches parentKey
|
|
422
|
+
const children = this.exposes.filter((e) => e.parent?.key === parentKey);
|
|
423
|
+
for (const child of children) {
|
|
424
|
+
removeChildren(child.key);
|
|
425
|
+
const childIndex = this.exposes.findIndex((e) => e.key === child.key);
|
|
426
|
+
if (childIndex >= 0) {
|
|
427
|
+
this.exposes.splice(childIndex, 1);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
// Then also remove children
|
|
432
|
+
removeChildren(key);
|
|
433
|
+
this.notifyChange();
|
|
306
434
|
}
|
|
307
435
|
/**
|
|
308
436
|
* Returns the exposed entity by its key.
|
|
309
437
|
* @param entityKey The key of the entity to find.
|
|
310
438
|
* @returns The exposed entity or undefined if not found.
|
|
311
439
|
*/
|
|
312
|
-
getExposedEntity(
|
|
313
|
-
return this.exposes.find((e) => e.key ===
|
|
440
|
+
getExposedEntity(entity) {
|
|
441
|
+
return this.exposes.find((e) => e.entity.key === entity.key && e.entity.domain === entity.domain);
|
|
314
442
|
}
|
|
315
443
|
/**
|
|
316
444
|
* Clears the API model for a new entity change.
|
|
@@ -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,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAYvD,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;IA4G9C,QAAQ;sBAAS,cAAc;;;;;;;;;;iBAA/B,QAAS,SAAQ,WAAc;;;0CA8DzC,QAAQ,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AA;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;;;SAzUU,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} from './types.js'\nimport { DataDomain } from './DataDomain.js'\nimport { DependentModel, type DependentModelSchema, type DomainDependency } from './DependentModel.js'\nimport { observed, toRaw } from '../decorators/observed.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 data domain 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 data domain 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 entityKey The key of the entity to expose.\n * @returns The exposed entity.\n */\n exposeEntity(entityKey: string): ExposedEntity {\n const existing = this.exposes.find((e) => e.key === entityKey)\n if (existing) {\n return existing\n }\n const newEntity: ExposedEntity = {\n key: entityKey,\n actions: [],\n }\n this.exposes.push(newEntity)\n this.notifyChange()\n return newEntity\n }\n\n /**\n * Removes an entity from the API model.\n * @param entityKey The key of the entity to remove.\n */\n removeEntity(entityKey: string): void {\n const index = this.exposes.findIndex((e) => e.key === entityKey)\n if (index !== -1) {\n this.exposes.splice(index, 1)\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(entityKey: string): ExposedEntity | undefined {\n return this.exposes.find((e) => e.key === entityKey)\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,MAAM,oBAAoB,CAAA;AACjE,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,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;IA4GxC,QAAQ;sBAAS,cAAc;;;;;;;;;;iBAA/B,QAAS,SAAQ,WAAc;;;0CA8DzC,QAAQ,EAAE;mCAIV,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;mCAIxB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YARb,+LAAS,cAAc,6BAAd,cAAc,uGA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ACzB,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"]}
|
|
@@ -14,6 +14,13 @@ export declare enum SemanticType {
|
|
|
14
14
|
* ensuring it is encrypted and not exposed in API responses.
|
|
15
15
|
*/
|
|
16
16
|
Password = "Semantic#Password",
|
|
17
|
+
/**
|
|
18
|
+
* Annotates the field as the username for user authentication.
|
|
19
|
+
* This identifies which field should be used for login purposes.
|
|
20
|
+
* Can be applied to dedicated username fields or email fields that serve as usernames.
|
|
21
|
+
* The runtime uses this for authentication, password reset, and user lookup operations.
|
|
22
|
+
*/
|
|
23
|
+
Username = "Semantic#Username",
|
|
17
24
|
/**
|
|
18
25
|
* Designates a Data Property as the `createdAt` timestamp of an entity.
|
|
19
26
|
* This is used to track when the entity was first created.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Semantics.d.ts","sourceRoot":"","sources":["../../../src/modeling/Semantics.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEzD;;;GAGG;AACH,oBAAY,YAAY;IAKtB;;OAEG;IACH,IAAI,kBAAkB;IAMtB;;;;OAIG;IACH,QAAQ,sBAAsB;IAC9B;;;OAGG;IACH,gBAAgB,8BAA8B;IAC9C;;;OAGG;IACH,gBAAgB,8BAA8B;IAC9C;;;;;OAKG;IACH,gBAAgB,8BAA8B;IAC9C;;;;OAIG;IACH,WAAW,yBAAyB;IACpC;;;;;;;OAOG;IACH,gBAAgB,8BAA8B;IAC9C;;;;OAIG;IACH,KAAK,mBAAmB;IACxB;;;;;;OAMG;IACH,QAAQ,sBAAsB;IAC9B;;;;;;;;;OASG;IACH,MAAM,oBAAoB;IAE1B;;;;OAIG;IACH,OAAO,qBAAqB;IAE5B;;;OAGG;IACH,QAAQ,sBAAsB;IAE9B;;;OAGG;IACH,OAAO,qBAAqB;IAE5B;;;;;;OAMG;IACH,QAAQ,sBAAsB;IAE9B;;;;;;OAMG;IACH,IAAI,kBAAkB;IAEtB;;;;;;;;;;;;;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A;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,EAAE,EAAE,YAAY,CAAA;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACjC"}
|
|
@@ -20,6 +20,13 @@ export var SemanticType;
|
|
|
20
20
|
* ensuring it is encrypted and not exposed in API responses.
|
|
21
21
|
*/
|
|
22
22
|
SemanticType["Password"] = "Semantic#Password";
|
|
23
|
+
/**
|
|
24
|
+
* Annotates the field as the username for user authentication.
|
|
25
|
+
* This identifies which field should be used for login purposes.
|
|
26
|
+
* Can be applied to dedicated username fields or email fields that serve as usernames.
|
|
27
|
+
* The runtime uses this for authentication, password reset, and user lookup operations.
|
|
28
|
+
*/
|
|
29
|
+
SemanticType["Username"] = "Semantic#Username";
|
|
23
30
|
/**
|
|
24
31
|
* Designates a Data Property as the `createdAt` timestamp of an entity.
|
|
25
32
|
* This is used to track when the entity was first created.
|
|
@@ -408,6 +415,22 @@ export const DataSemantics = {
|
|
|
408
415
|
],
|
|
409
416
|
},
|
|
410
417
|
},
|
|
418
|
+
[SemanticType.Username]: {
|
|
419
|
+
id: SemanticType.Username,
|
|
420
|
+
displayName: 'Username',
|
|
421
|
+
scope: SemanticScope.Property,
|
|
422
|
+
description: 'User authentication identifier',
|
|
423
|
+
category: SemanticCategory.Identity,
|
|
424
|
+
applicableDataTypes: ['string'],
|
|
425
|
+
hasConfig: false,
|
|
426
|
+
runtime: {
|
|
427
|
+
timing: SemanticTiming.Before,
|
|
428
|
+
operations: [SemanticOperation.Create, SemanticOperation.Update, SemanticOperation.Read],
|
|
429
|
+
priority: 15, // High priority for authentication
|
|
430
|
+
canDisable: false, // Security semantics cannot be disabled
|
|
431
|
+
timeoutMs: 100, // Fast operation
|
|
432
|
+
},
|
|
433
|
+
},
|
|
411
434
|
[SemanticType.UserRole]: {
|
|
412
435
|
id: SemanticType.UserRole,
|
|
413
436
|
displayName: 'User Role Field',
|