@api-client/core 0.18.2 → 0.18.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.18.2",
4
+ "version": "0.18.3",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -3,6 +3,7 @@ import { ApiModelKind, DataDomainKind } from '../models/kinds.js'
3
3
  import { type IThing, Thing } from '../models/Thing.js'
4
4
  import type {
5
5
  AccessRule,
6
+ AssociationTarget,
6
7
  AuthenticationConfiguration,
7
8
  AuthorizationConfiguration,
8
9
  ExposedEntity,
@@ -64,11 +65,11 @@ export interface ApiModelSchema extends DependentModelSchema {
64
65
 
65
66
  /**
66
67
  * The designated Data Entity that represents a "User".
67
- * This entity must be marked with the "User" semantic in the Data Modeler.
68
+ * This entity should be marked with the "User" semantic in the Data Modeler.
68
69
  *
69
70
  * This property is required to publish the API.
70
71
  */
71
- userKey?: string
72
+ user?: AssociationTarget
72
73
 
73
74
  /**
74
75
  * Configuration for how users prove their identity.
@@ -142,7 +143,7 @@ export class ApiModel extends DependentModel {
142
143
  *
143
144
  * This property is required to publish the API.
144
145
  */
145
- userKey?: string
146
+ user?: AssociationTarget
146
147
 
147
148
  /**
148
149
  * Configuration for how users prove their identity.
@@ -232,8 +233,8 @@ export class ApiModel extends DependentModel {
232
233
  info,
233
234
  exposes,
234
235
  }
235
- if (input.userKey) {
236
- result.userKey = input.userKey
236
+ if (input.user) {
237
+ result.user = { ...input.user }
237
238
  }
238
239
  if (input.dependencyList) {
239
240
  result.dependencyList = structuredClone(input.dependencyList)
@@ -279,7 +280,7 @@ export class ApiModel extends DependentModel {
279
280
  this.kind = init.kind
280
281
  this.key = init.key
281
282
  this.info = new Thing(init.info)
282
- this.userKey = init.userKey
283
+ this.user = init.user
283
284
  if (init.authentication) {
284
285
  this.authentication = structuredClone(init.authentication)
285
286
  }
@@ -322,8 +323,8 @@ export class ApiModel extends DependentModel {
322
323
  info: this.info.toJSON(),
323
324
  exposes: structuredClone(this.exposes),
324
325
  }
325
- if (this.userKey) {
326
- result.userKey = this.userKey
326
+ if (this.user) {
327
+ result.user = { ...this.user }
327
328
  }
328
329
  if (this.dependencyList.length > 0) {
329
330
  result.dependencyList = structuredClone(this.dependencyList)
@@ -414,14 +415,14 @@ export class ApiModel extends DependentModel {
414
415
 
415
416
  /**
416
417
  * Clears the API model for a new entity change.
417
- * This method resets the dependencies, exposes, userKey,
418
+ * This method resets the dependencies, exposes, user,
418
419
  * authentication, authorization, and session properties.
419
420
  */
420
421
  cleanForEntityChange(): void {
421
422
  this.dependencies.clear()
422
423
  this.dependencyList = []
423
424
  this.exposes = []
424
- this.userKey = undefined
425
+ this.user = undefined
425
426
  if (this.session) {
426
427
  this.session.properties = []
427
428
  }
@@ -21,7 +21,7 @@ test.group('ApiModel.createSchema()', (g) => {
21
21
  assert.isNotEmpty(schema.key)
22
22
  assert.deepInclude(schema.info, { name: 'Unnamed API' })
23
23
  assert.deepEqual(schema.exposes, [])
24
- assert.isUndefined(schema.userKey)
24
+ assert.isUndefined(schema.user)
25
25
  assert.isUndefined(schema.dependencyList)
26
26
  assert.isUndefined(schema.authentication)
27
27
  assert.isUndefined(schema.authorization)
@@ -38,7 +38,7 @@ test.group('ApiModel.createSchema()', (g) => {
38
38
  key: 'test-api',
39
39
  info: { name: 'Test API', description: 'A test API' },
40
40
  exposes: [{ key: 'entity1', actions: [] }],
41
- userKey: 'user-entity',
41
+ user: { key: 'user-entity' },
42
42
  dependencyList: [{ key: 'domain1', version: '1.0.0' }],
43
43
  authentication: { strategy: 'UsernamePassword' },
44
44
  authorization: { strategy: 'RBAC', roleKey: 'role' } as RolesBasedAccessControl,
@@ -55,7 +55,7 @@ test.group('ApiModel.createSchema()', (g) => {
55
55
  assert.equal(schema.key, 'test-api')
56
56
  assert.deepInclude(schema.info, { name: 'Test API', description: 'A test API' })
57
57
  assert.deepEqual(schema.exposes, [{ key: 'entity1', actions: [] }])
58
- assert.equal(schema.userKey, 'user-entity')
58
+ assert.deepEqual(schema.user, { key: 'user-entity' })
59
59
  assert.deepEqual(schema.dependencyList, [{ key: 'domain1', version: '1.0.0' }])
60
60
  assert.deepEqual(schema.authentication, { strategy: 'UsernamePassword' })
61
61
  assert.deepEqual(schema.authorization, { strategy: 'RBAC', roleKey: 'role' })
@@ -90,7 +90,7 @@ test.group('ApiModel.constructor()', (g) => {
90
90
  assert.isNotEmpty(model.key)
91
91
  assert.equal(model.info.name, 'Unnamed API')
92
92
  assert.deepEqual(model.exposes, [])
93
- assert.isUndefined(model.userKey)
93
+ assert.isUndefined(model.user)
94
94
  assert.isUndefined(model.authentication)
95
95
  assert.isUndefined(model.authorization)
96
96
  assert.isUndefined(model.session)
@@ -108,7 +108,7 @@ test.group('ApiModel.constructor()', (g) => {
108
108
  key: 'test-api',
109
109
  info: { name: 'Test API', description: 'A test API' },
110
110
  exposes: [{ key: 'entity1', actions: [] }],
111
- userKey: 'user-entity',
111
+ user: { key: 'user-entity' },
112
112
  dependencyList: [{ key: 'domain1', version: '1.0.0' }],
113
113
  authentication: { strategy: 'UsernamePassword' },
114
114
  authorization: { strategy: 'RBAC', roleKey: 'role' } as RolesBasedAccessControl,
@@ -124,7 +124,7 @@ test.group('ApiModel.constructor()', (g) => {
124
124
  assert.equal(model.key, 'test-api')
125
125
  assert.equal(model.info.name, 'Test API')
126
126
  assert.deepEqual(model.exposes, [{ key: 'entity1', actions: [] }])
127
- assert.equal(model.userKey, 'user-entity')
127
+ assert.deepEqual(model.user, { key: 'user-entity' })
128
128
  assert.deepEqual(model.dependencyList, [{ key: 'domain1', version: '1.0.0' }])
129
129
  assert.deepEqual(model.authentication, { strategy: 'UsernamePassword' })
130
130
  assert.deepEqual(model.authorization, { strategy: 'RBAC', roleKey: 'role' })
@@ -172,7 +172,7 @@ test.group('ApiModel.toJSON()', (g) => {
172
172
  assert.equal(json.key, model.key)
173
173
  assert.deepInclude(json.info, { name: 'Unnamed API' })
174
174
  assert.deepEqual(json.exposes, [])
175
- assert.isUndefined(json.userKey)
175
+ assert.isUndefined(json.user)
176
176
  assert.isUndefined(json.dependencyList)
177
177
  assert.isUndefined(json.authentication)
178
178
  assert.isUndefined(json.authorization)
@@ -190,7 +190,7 @@ test.group('ApiModel.toJSON()', (g) => {
190
190
  key: 'test-api',
191
191
  info: { name: 'Test API', description: 'A test API' },
192
192
  exposes: [{ key: 'entity1', actions: [] }],
193
- userKey: 'user-entity',
193
+ user: { key: 'user-entity' },
194
194
  dependencyList: [{ key: 'domain1', version: '1.0.0' }],
195
195
  authentication: { strategy: 'UsernamePassword' },
196
196
  authorization: { strategy: 'RBAC', roleKey: 'role' } as RolesBasedAccessControl,
@@ -207,7 +207,7 @@ test.group('ApiModel.toJSON()', (g) => {
207
207
  assert.equal(json.key, 'test-api')
208
208
  assert.deepInclude(json.info, { name: 'Test API', description: 'A test API' })
209
209
  assert.deepEqual(json.exposes, [{ key: 'entity1', actions: [] }])
210
- assert.equal(json.userKey, 'user-entity')
210
+ assert.deepEqual(json.user, { key: 'user-entity' })
211
211
  assert.deepEqual(json.dependencyList, [{ key: 'domain1', version: '1.0.0' }])
212
212
  assert.deepEqual(json.authentication, { strategy: 'UsernamePassword' })
213
213
  assert.deepEqual(json.authorization, { strategy: 'RBAC', roleKey: 'role' })