@api-client/core 0.19.31 → 0.19.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/build/src/authorization/index.d.ts +10 -0
  2. package/build/src/authorization/index.d.ts.map +1 -0
  3. package/build/src/authorization/index.js +10 -0
  4. package/build/src/authorization/index.js.map +1 -0
  5. package/build/src/browser.d.ts +13 -143
  6. package/build/src/browser.d.ts.map +1 -1
  7. package/build/src/browser.js +10 -144
  8. package/build/src/browser.js.map +1 -1
  9. package/build/src/data/DataExtractor.d.ts +1 -2
  10. package/build/src/data/DataExtractor.d.ts.map +1 -1
  11. package/build/src/data/DataExtractor.js.map +1 -1
  12. package/build/src/data/index.d.ts +10 -0
  13. package/build/src/data/index.d.ts.map +1 -0
  14. package/build/src/data/index.js +10 -0
  15. package/build/src/data/index.js.map +1 -0
  16. package/build/src/events/Events.d.ts +3 -3
  17. package/build/src/events/index.d.ts +11 -0
  18. package/build/src/events/index.d.ts.map +1 -0
  19. package/build/src/events/index.js +4 -0
  20. package/build/src/events/index.js.map +1 -0
  21. package/build/src/exceptions/index.d.ts +8 -0
  22. package/build/src/exceptions/index.d.ts.map +1 -0
  23. package/build/src/exceptions/index.js +8 -0
  24. package/build/src/exceptions/index.js.map +1 -0
  25. package/build/src/index.d.ts +10 -138
  26. package/build/src/index.d.ts.map +1 -1
  27. package/build/src/index.js +11 -142
  28. package/build/src/index.js.map +1 -1
  29. package/build/src/mocking/lib/User.d.ts.map +1 -1
  30. package/build/src/mocking/lib/User.js +1 -1
  31. package/build/src/mocking/lib/User.js.map +1 -1
  32. package/build/src/modeling/ApiModel.d.ts.map +1 -1
  33. package/build/src/modeling/ApiModel.js +0 -8
  34. package/build/src/modeling/ApiModel.js.map +1 -1
  35. package/build/src/modeling/RuntimeApiModel.d.ts +16 -0
  36. package/build/src/modeling/RuntimeApiModel.d.ts.map +1 -1
  37. package/build/src/modeling/RuntimeApiModel.js +31 -0
  38. package/build/src/modeling/RuntimeApiModel.js.map +1 -1
  39. package/build/src/modeling/ai/DataDomainDelta.d.ts +3 -3
  40. package/build/src/modeling/ai/DataDomainDelta.d.ts.map +1 -1
  41. package/build/src/modeling/ai/DataDomainDelta.js +3 -3
  42. package/build/src/modeling/ai/DataDomainDelta.js.map +1 -1
  43. package/build/src/modeling/amf/index.d.ts +4 -0
  44. package/build/src/modeling/amf/index.d.ts.map +1 -0
  45. package/build/src/modeling/amf/index.js +4 -0
  46. package/build/src/modeling/amf/index.js.map +1 -0
  47. package/build/src/modeling/index.d.ts +18 -1
  48. package/build/src/modeling/index.d.ts.map +1 -1
  49. package/build/src/modeling/index.js +14 -1
  50. package/build/src/modeling/index.js.map +1 -1
  51. package/build/src/modeling/types.d.ts +0 -15
  52. package/build/src/modeling/types.d.ts.map +1 -1
  53. package/build/src/modeling/types.js.map +1 -1
  54. package/build/src/modeling/validation/api_model_rules.d.ts.map +1 -1
  55. package/build/src/modeling/validation/api_model_rules.js +49 -46
  56. package/build/src/modeling/validation/api_model_rules.js.map +1 -1
  57. package/build/src/models/index.d.ts +64 -0
  58. package/build/src/models/index.d.ts.map +1 -0
  59. package/build/src/models/index.js +68 -0
  60. package/build/src/models/index.js.map +1 -0
  61. package/build/src/models/store/CustomDomain.d.ts +1 -1
  62. package/build/src/models/store/CustomDomain.d.ts.map +1 -1
  63. package/build/src/models/store/CustomDomain.js +2 -2
  64. package/build/src/models/store/CustomDomain.js.map +1 -1
  65. package/build/src/models/store/{data_catalog.d.ts → DataCatalog.d.ts} +1 -1
  66. package/build/src/models/store/DataCatalog.d.ts.map +1 -0
  67. package/build/src/models/store/DataCatalog.js +2 -0
  68. package/build/src/models/store/DataCatalog.js.map +1 -0
  69. package/build/src/models/store/DeploymentCustomDomain.d.ts +1 -1
  70. package/build/src/models/store/DeploymentCustomDomain.d.ts.map +1 -1
  71. package/build/src/models/store/DeploymentCustomDomain.js +2 -2
  72. package/build/src/models/store/DeploymentCustomDomain.js.map +1 -1
  73. package/build/src/models/store/File.d.ts.map +1 -1
  74. package/build/src/models/store/File.js +1 -2
  75. package/build/src/models/store/File.js.map +1 -1
  76. package/build/src/models/store/User.d.ts +3 -3
  77. package/build/src/models/store/User.d.ts.map +1 -1
  78. package/build/src/models/store/User.js +1 -1
  79. package/build/src/models/store/User.js.map +1 -1
  80. package/build/src/models/store/index.d.ts +17 -0
  81. package/build/src/models/store/index.d.ts.map +1 -0
  82. package/build/src/models/store/index.js +10 -0
  83. package/build/src/models/store/index.js.map +1 -0
  84. package/build/src/patch/index.d.ts +3 -0
  85. package/build/src/patch/index.d.ts.map +1 -0
  86. package/build/src/patch/index.js +2 -0
  87. package/build/src/patch/index.js.map +1 -0
  88. package/build/src/sdk/GroupsSdk.d.ts +1 -1
  89. package/build/src/sdk/GroupsSdk.d.ts.map +1 -1
  90. package/build/src/sdk/GroupsSdk.js.map +1 -1
  91. package/build/src/sdk/StoreSdkNode.d.ts +0 -4
  92. package/build/src/sdk/StoreSdkNode.d.ts.map +1 -1
  93. package/build/src/sdk/StoreSdkNode.js.map +1 -1
  94. package/build/src/sdk/StoreSdkWeb.d.ts +1 -5
  95. package/build/src/sdk/StoreSdkWeb.d.ts.map +1 -1
  96. package/build/src/sdk/StoreSdkWeb.js +1 -1
  97. package/build/src/sdk/StoreSdkWeb.js.map +1 -1
  98. package/build/src/sdk/index.d.ts +8 -0
  99. package/build/src/sdk/index.d.ts.map +1 -0
  100. package/build/src/sdk/index.js +3 -0
  101. package/build/src/sdk/index.js.map +1 -0
  102. package/build/tsconfig.tsbuildinfo +1 -1
  103. package/package.json +1 -1
  104. package/src/data/DataExtractor.ts +1 -1
  105. package/src/mocking/lib/User.ts +2 -1
  106. package/src/modeling/ApiModel.ts +0 -10
  107. package/src/modeling/RuntimeApiModel.ts +46 -0
  108. package/src/modeling/ai/DataDomainDelta.ts +5 -11
  109. package/src/modeling/readme.md +2 -2
  110. package/src/modeling/types.ts +0 -15
  111. package/src/modeling/validation/api_model_rules.ts +50 -48
  112. package/src/modeling/validation/api_model_validation_rules.md +2 -2
  113. package/src/models/store/CustomDomain.ts +2 -2
  114. package/src/models/store/DeploymentCustomDomain.ts +2 -2
  115. package/src/models/store/File.ts +2 -2
  116. package/src/models/store/User.ts +3 -4
  117. package/src/sdk/GroupsSdk.ts +1 -1
  118. package/src/sdk/StoreSdkNode.ts +0 -11
  119. package/src/sdk/StoreSdkWeb.ts +1 -12
  120. package/tests/unit/authorization/SecurityProcessor.spec.ts +2 -1
  121. package/tests/unit/data/JmesparthReader.spec.ts +1 -1
  122. package/tests/unit/data/JsonReader.spec.ts +1 -1
  123. package/tests/unit/data/PayloadPointer.spec.ts +1 -1
  124. package/tests/unit/data/RequestDataExtractor.spec.ts +9 -13
  125. package/tests/unit/data/UrlEncodedReader.spec.ts +1 -1
  126. package/tests/unit/data/XmlReader.spec.ts +1 -1
  127. package/tests/unit/mocking/current/Certificates.spec.ts +1 -1
  128. package/tests/unit/mocking/current/HostRules.spec.ts +1 -1
  129. package/tests/unit/mocking/current/Urls.spec.ts +1 -1
  130. package/tests/unit/mocking/current/User.spec.ts +2 -2
  131. package/tests/unit/modeling/RuntimeApiModel.spec.ts +31 -0
  132. package/tests/unit/modeling/ai/DataDomainDelta.spec.ts +1 -1
  133. package/tests/unit/modeling/ai/DomainSerialization.spec.ts +1 -1
  134. package/tests/unit/modeling/ai/tools/DataDomain.tools.spec.ts +1 -1
  135. package/tests/unit/modeling/amf/shape_generator.spec.ts +1 -1
  136. package/tests/unit/modeling/api_model.spec.ts +8 -9
  137. package/tests/unit/modeling/api_model_expose_entity.spec.ts +1 -1
  138. package/tests/unit/modeling/api_model_remove_entity.spec.ts +1 -1
  139. package/tests/unit/modeling/data_domain.spec.ts +2 -1
  140. package/tests/unit/modeling/data_domain_change_observers.spec.ts +1 -1
  141. package/tests/unit/modeling/data_domain_serialization.spec.ts +2 -2
  142. package/tests/unit/modeling/definitions/phone.spec.ts +1 -1
  143. package/tests/unit/modeling/domain_asociation.spec.ts +34 -34
  144. package/tests/unit/modeling/domain_asociation_targets.spec.ts +1 -1
  145. package/tests/unit/modeling/domain_entity.spec.ts +3 -9
  146. package/tests/unit/modeling/domain_entity_associations.spec.ts +1 -1
  147. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +1 -1
  148. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +1 -1
  149. package/tests/unit/modeling/domain_entity_fields.spec.ts +1 -1
  150. package/tests/unit/modeling/domain_entity_generators.spec.ts +1 -1
  151. package/tests/unit/modeling/domain_entity_parents.spec.ts +1 -1
  152. package/tests/unit/modeling/domain_entity_properties.spec.ts +2 -1
  153. package/tests/unit/modeling/domain_file.spec.ts +2 -1
  154. package/tests/unit/modeling/domain_impact_analysis.spec.ts +5 -3
  155. package/tests/unit/modeling/domain_model.spec.ts +3 -8
  156. package/tests/unit/modeling/domain_model_entities.spec.ts +2 -1
  157. package/tests/unit/modeling/domain_namespace.spec.ts +3 -9
  158. package/tests/unit/modeling/domain_namespace_models.spec.ts +1 -1
  159. package/tests/unit/modeling/domain_namespace_namespaces.spec.ts +1 -1
  160. package/tests/unit/modeling/domain_property.spec.ts +3 -1
  161. package/tests/unit/modeling/domain_validation.spec.ts +1 -1
  162. package/tests/unit/modeling/domain_versioning.spec.ts +1 -1
  163. package/tests/unit/modeling/exposed_entity.spec.ts +1 -1
  164. package/tests/unit/modeling/exposed_entity_setter_validation.spec.ts +1 -1
  165. package/tests/unit/modeling/generators/OasGenerator.spec.ts +1 -3
  166. package/tests/unit/modeling/helpers/intellisense.spec.ts +1 -1
  167. package/tests/unit/modeling/importers/json_schema_importer.spec.ts +1 -1
  168. package/tests/unit/modeling/validation/api_model_rules.spec.ts +12 -12
  169. package/tests/unit/modeling/validation/association_validation.spec.ts +1 -1
  170. package/tests/unit/modeling/validation/entity_validation.spec.ts +1 -1
  171. package/tests/unit/modeling/validation/property_validation.spec.ts +1 -1
  172. package/tests/unit/models/Certificate/from_name.spec.ts +2 -1
  173. package/tests/unit/models/File/addLabel.spec.ts +1 -1
  174. package/tests/unit/models/File/constructor.spec.ts +2 -1
  175. package/tests/unit/models/File/createFileCapabilities.spec.ts +1 -1
  176. package/tests/unit/models/File/new.spec.ts +2 -1
  177. package/tests/unit/models/File/setDeleted.spec.ts +1 -1
  178. package/tests/unit/models/File/setLastModified.spec.ts +1 -1
  179. package/tests/unit/models/File/shortcutTo.spec.ts +1 -1
  180. package/tests/unit/models/File/toJSON.spec.ts +2 -1
  181. package/tests/unit/models/File/updateByMeMeta.spec.ts +1 -1
  182. package/tests/unit/models/Folder/consume.spec.ts +2 -1
  183. package/tests/unit/models/Folder/create.spec.ts +2 -1
  184. package/tests/unit/models/Permission/all.spec.ts +1 -1
  185. package/tests/unit/models/Project/consume.spec.ts +1 -1
  186. package/tests/unit/models/Project/create.spec.ts +1 -1
  187. package/tests/unit/models/certificate.spec.ts +2 -7
  188. package/tests/unit/models/host_rule.spec.ts +1 -1
  189. package/tests/unit/models/http_project.spec.ts +1 -1
  190. package/tests/unit/models/http_request.spec.ts +2 -9
  191. package/tests/unit/models/http_response.spec.ts +2 -1
  192. package/tests/unit/models/license.spec.ts +1 -1
  193. package/tests/unit/models/response.spec.ts +2 -2
  194. package/tests/unit/models/store/CustomDomain.spec.ts +8 -8
  195. package/tests/unit/models/store/DeploymentCustomDomain.spec.ts +9 -9
  196. package/tests/unit/models/store/Invitation.spec.ts +1 -1
  197. package/tests/unit/runtime/http-engine/abort.spec.ts +2 -8
  198. package/tests/unit/runtime/http-engine/auth.spec.ts +2 -1
  199. package/tests/unit/runtime/http-engine/certificates.spec.ts +2 -1
  200. package/tests/unit/runtime/http-engine/cleanup.spec.ts +2 -1
  201. package/tests/unit/runtime/http-engine/compression.spec.ts +2 -1
  202. package/tests/unit/runtime/http-engine/core_engine.spec.ts +7 -11
  203. package/tests/unit/runtime/http-engine/events.spec.ts +2 -1
  204. package/tests/unit/runtime/http-engine/headers.spec.ts +2 -9
  205. package/tests/unit/runtime/http-engine/hosts.spec.ts +2 -1
  206. package/tests/unit/runtime/http-engine/http-get.spec.ts +2 -1
  207. package/tests/unit/runtime/http-engine/http-post.spec.ts +2 -9
  208. package/tests/unit/runtime/http-engine/logger.spec.ts +2 -1
  209. package/tests/unit/runtime/http-engine/message.spec.ts +2 -8
  210. package/tests/unit/runtime/http-engine/params.spec.ts +2 -10
  211. package/tests/unit/runtime/http-engine/proxy.spec.ts +2 -10
  212. package/tests/unit/runtime/http-engine/redirects.spec.ts +4 -6
  213. package/tests/unit/runtime/http-engine/request_utils.spec.ts +2 -1
  214. package/tests/unit/runtime/http-engine/responses.spec.ts +2 -10
  215. package/tests/unit/runtime/http-engine/timeout.spec.ts +2 -8
  216. package/tests/unit/runtime/http-engine/timings.spec.ts +2 -1
  217. package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +3 -8
  218. package/tests/unit/runtime/proxy/RequestProxy.spec.ts +6 -7
  219. package/tests/unit/runtime/reporters/project_run_cli_reporter.spec.ts +2 -7
  220. package/tests/unit/runtime/runners/http_assertion_runner.spec.ts +2 -2
  221. package/tests/unit/runtime/runners/http_flow_runner.spec.ts +2 -2
  222. package/tests/unit/runtime/runners/parallel_runner.spec.ts +2 -2
  223. package/tests/unit/runtime/runners/project_runner.spec.ts +2 -5
  224. package/tests/unit/runtime/runners/request_runner.spec.ts +2 -5
  225. package/tests/unit/runtime/runners/serial_runner.spec.ts +2 -3
  226. package/tests/unit/runtime/variables/variables_processor.spec.ts +2 -1
  227. package/tsconfig.browser.json +3 -4
  228. package/tsconfig.node.json +1 -3
  229. package/build/src/models/store/data_catalog.d.ts.map +0 -1
  230. package/build/src/models/store/data_catalog.js +0 -2
  231. package/build/src/models/store/data_catalog.js.map +0 -1
  232. /package/src/models/store/{data_catalog.ts → DataCatalog.ts} +0 -0
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.19.31",
4
+ "version": "0.19.33",
5
5
  "license": "UNLICENSED",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -9,7 +9,7 @@ import { XmlReader } from './XmlReader.js'
9
9
  import { UrlEncodedReader } from './UrlEncodedReader.js'
10
10
  import { CookieParser } from '../cookies/CookieParser.js'
11
11
 
12
- type DataInput =
12
+ export type DataInput =
13
13
  | HttpRequest
14
14
  | SentRequest
15
15
  | IHttpRequest
@@ -1,6 +1,7 @@
1
1
  import { faker } from '@faker-js/faker'
2
2
  import { nanoid } from '../../nanoid.js'
3
- import { UserSchema, Kind as UserKind } from '../../models/store/User.js'
3
+ import { UserSchema } from '../../models/store/User.js'
4
+ import { UserKind } from '../../models/kinds.js'
4
5
 
5
6
  export interface UserInitSchema {
6
7
  noEmail?: boolean
@@ -6,9 +6,7 @@ import type {
6
6
  AuthenticationStrategy,
7
7
  AuthorizationStrategy,
8
8
  ExposedEntitySchema,
9
- RolesBasedAccessControl,
10
9
  SessionConfiguration,
11
- UsernamePasswordConfiguration,
12
10
  ExposeOptions,
13
11
  OffsetPaginationStrategy,
14
12
  CursorPaginationStrategy,
@@ -668,14 +666,6 @@ export class ApiModel extends DependentModel {
668
666
  if (this.session) {
669
667
  this.session.properties = []
670
668
  }
671
- if (this.authentication && this.authentication.strategy === 'UsernamePassword') {
672
- const typed = this.authentication as UsernamePasswordConfiguration
673
- typed.passwordKey = undefined
674
- }
675
- if (this.authorization && this.authorization.strategy == 'RBAC') {
676
- const typed = this.authorization as RolesBasedAccessControl
677
- typed.roleKey = ''
678
- }
679
669
  }
680
670
 
681
671
  /**
@@ -4,6 +4,9 @@ import type { DataDomainSchema } from './DataDomain.js'
4
4
  import type { ActionKind } from './actions/index.js'
5
5
  import type { ExposedEntity } from './ExposedEntity.js'
6
6
  import type { Action } from './actions/Action.js'
7
+ import { SemanticType } from './Semantics.js'
8
+ import type { DomainEntity } from './DomainEntity.js'
9
+ import type { DomainProperty } from './DomainProperty.js'
7
10
 
8
11
  /**
9
12
  * Identifies a specific exposed entity and its action kind.
@@ -55,12 +58,55 @@ export class RuntimeApiModel extends ApiModel {
55
58
  */
56
59
  #definitions = new WeakMap<RouteToken[], RouteDefinition>()
57
60
 
61
+ /**
62
+ * Cached references to commonly used entities for fast runtime lookup.
63
+ */
64
+ cachedEntities: {
65
+ user?: DomainEntity
66
+ } = {}
67
+
68
+ /**
69
+ * Cached references to commonly used properties for fast runtime lookup.
70
+ */
71
+ cachedProperties: {
72
+ username?: DomainProperty
73
+ password?: DomainProperty
74
+ role?: DomainProperty
75
+ } = {}
76
+
58
77
  constructor(schema: RuntimeApiModelSchema, domainSchema: DataDomainSchema) {
59
78
  super(schema, domainSchema)
60
79
 
61
80
  if (schema.routingMap) {
62
81
  this.#initializeRouter(schema.routingMap)
63
82
  }
83
+
84
+ this.#cacheEntitiesAndProperties()
85
+ }
86
+
87
+ #cacheEntitiesAndProperties() {
88
+ if (!this.user || !this.domain) {
89
+ return
90
+ }
91
+
92
+ const userEntity = this.domain.findEntity(this.user.key, this.user.domain)
93
+ if (!userEntity) {
94
+ return
95
+ }
96
+
97
+ this.cachedEntities.user = userEntity
98
+
99
+ for (const prop of userEntity.properties) {
100
+ if (prop.hasSemantic(SemanticType.Username)) {
101
+ this.cachedProperties.username = prop
102
+ }
103
+ if (prop.hasSemantic(SemanticType.Password)) {
104
+ this.cachedProperties.password = prop
105
+ }
106
+ if (prop.hasSemantic(SemanticType.UserRole)) {
107
+ this.cachedProperties.role = prop
108
+ }
109
+ }
64
110
  }
65
111
 
66
112
  #initializeRouter(routingMap: RoutingMap) {
@@ -1,4 +1,4 @@
1
- import type { DataDomain } from '@api-client/core/modeling/DataDomain.js'
1
+ import type { DataDomain } from '../DataDomain.js'
2
2
  import type {
3
3
  AiDataModelSchema,
4
4
  AiDomainAssociation,
@@ -10,16 +10,10 @@ import type {
10
10
  AiDomainPropertyDelta,
11
11
  AiDomainSemantic,
12
12
  } from './types.js'
13
- import type {
14
- DomainAssociation,
15
- DomainEntity,
16
- DomainEntitySchema,
17
- DomainModel,
18
- DomainProperty,
19
- } from '@api-client/core/modeling/index.js'
20
- import { nanoid } from '@api-client/core/nanoid.js'
21
- import { type SemanticType, SemanticScope, DataSemantics } from '@api-client/core/modeling/Semantics.js'
22
- import { DomainEntityKind, DomainPropertyKind, DomainAssociationKind } from '@api-client/core/models/kinds.js'
13
+ import type { DomainAssociation, DomainEntity, DomainEntitySchema, DomainModel, DomainProperty } from '../index.js'
14
+ import { nanoid } from '../../nanoid.js'
15
+ import { type SemanticType, SemanticScope, DataSemantics } from '../Semantics.js'
16
+ import { DomainEntityKind, DomainPropertyKind, DomainAssociationKind } from '../../models/kinds.js'
23
17
 
24
18
  /**
25
19
  * Normalizes the delta by removing duplicates. For example, when the model
@@ -187,8 +187,8 @@ apiModel.attachDataDomain(domain)
187
187
 
188
188
  // 4. Configure security
189
189
  apiModel.user = { key: userEntity.key }
190
- apiModel.authentication = { strategy: 'UsernamePassword', passwordKey: 'password' }
191
- apiModel.authorization = { strategy: 'RBAC', roleKey: 'role' }
190
+ apiModel.authentication = { strategy: 'UsernamePassword' }
191
+ apiModel.authorization = { strategy: 'RBAC' }
192
192
  apiModel.session = {
193
193
  secret: 'your-secure-secret',
194
194
  properties: ['email', 'role'],
@@ -393,14 +393,6 @@ export interface AuthorizationConfiguration {
393
393
 
394
394
  export interface RolesBasedAccessControl extends AuthorizationConfiguration {
395
395
  strategy: 'RBAC'
396
- /**
397
- * The property within the designated "User" entity that defines the user's role.
398
- * This field is used in access rules to grant permissions.
399
- *
400
- * This property must be marked with the "Role" data semantic in the Data Modeler.
401
- * It is required to publish the API.
402
- */
403
- roleKey: string
404
396
  }
405
397
 
406
398
  export type AuthorizationStrategy = RolesBasedAccessControl
@@ -424,13 +416,6 @@ export interface AuthenticationConfiguration {
424
416
  */
425
417
  export interface UsernamePasswordConfiguration extends AuthenticationConfiguration {
426
418
  strategy: 'UsernamePassword'
427
- /**
428
- * The specific property within the User entity that holds the password.
429
- * This property must be marked with the "Password" data semantic in the Data Modeler.
430
- *
431
- * This property is required to publish the API.
432
- */
433
- passwordKey?: string
434
419
  }
435
420
 
436
421
  export type AuthenticationStrategy = UsernamePasswordConfiguration
@@ -5,10 +5,10 @@ import { ListAction } from '../actions/ListAction.js'
5
5
  import { DeleteAction } from '../actions/DeleteAction.js'
6
6
  import { UpdateAction } from '../actions/UpdateAction.js'
7
7
  import { SearchAction } from '../actions/SearchAction.js'
8
- import type { RolesBasedAccessControl, UsernamePasswordConfiguration } from '../types.js'
9
8
  import type { ApiModelValidationItem, ApiModelValidationContext } from '../types.js'
10
9
  import { ApiModelKind, ExposedEntityKind } from '../../models/kinds.js'
11
10
  import { SemanticType } from '../Semantics.js'
11
+ import { DomainProperty } from '../DomainProperty.js'
12
12
 
13
13
  /**
14
14
  * Creates a unique validation code.
@@ -127,35 +127,32 @@ export function validateApiModelSecurity(model: ApiModel): ApiModelValidationIte
127
127
  context: { ...context, property: 'authentication' },
128
128
  })
129
129
  } else if (model.authentication.strategy === 'UsernamePassword') {
130
- const auth = model.authentication as UsernamePasswordConfiguration
131
- if (!auth.passwordKey) {
132
- issues.push({
133
- code: createCode('API', 'MISSING_PASSWORD_KEY'),
134
- message: 'Username & Password authentication requires a specific field for the password.',
135
- suggestion:
136
- 'Select which field in your user profile should store the password. ' +
137
- 'The data domain model should have a password data semantic on that property.',
138
- severity: 'error',
139
- context: { ...context, property: 'authentication.passwordKey' },
140
- })
141
- } else if (userEntity) {
142
- const passwordProp = Array.from(userEntity.properties).find((p) => p.key === auth.passwordKey)
143
- if (passwordProp && !passwordProp.hasSemantic(SemanticType.Password)) {
130
+ if (userEntity) {
131
+ let passwordProp: DomainProperty | undefined
132
+ for (const prop of userEntity.properties) {
133
+ if (prop.hasSemantic(SemanticType.Password)) {
134
+ passwordProp = prop
135
+ break
136
+ }
137
+ }
138
+ if (!passwordProp) {
144
139
  issues.push({
145
140
  code: createCode('API', 'MISSING_PASSWORD_SEMANTIC'),
146
- message: 'The selected password field is missing the Password data semantic.',
147
- suggestion: 'Go to the Data Modeler and add the "Password" semantic to this property.',
141
+ message: 'The selected user model requires a property with the Password data semantic for authentication.',
142
+ suggestion: 'Go to the Data Modeler and add the "Password" semantic to the password property.',
148
143
  severity: 'error',
149
- context: { ...context, property: 'authentication.passwordKey' },
144
+ context: { ...context, property: 'user' },
150
145
  })
151
146
  }
152
- }
153
147
 
154
- if (userEntity) {
155
- const hasUsernameSemantic = Array.from(userEntity.properties).some(
156
- (p) => typeof p.hasSemantic === 'function' && p.hasSemantic(SemanticType.Username)
157
- )
158
- if (!hasUsernameSemantic) {
148
+ let usernameProp: DomainProperty | undefined
149
+ for (const prop of userEntity.properties) {
150
+ if (prop.hasSemantic(SemanticType.Username)) {
151
+ usernameProp = prop
152
+ break
153
+ }
154
+ }
155
+ if (!usernameProp) {
159
156
  issues.push({
160
157
  code: createCode('API', 'MISSING_USERNAME_SEMANTIC'),
161
158
  message: 'Username & Password authentication requires a field with the Username data semantic.',
@@ -177,24 +174,21 @@ export function validateApiModelSecurity(model: ApiModel): ApiModelValidationIte
177
174
  context: { ...context, property: 'authorization' },
178
175
  })
179
176
  } else if (model.authorization.strategy === 'RBAC') {
180
- const rbac = model.authorization as RolesBasedAccessControl
181
- if (!rbac.roleKey) {
182
- issues.push({
183
- code: createCode('API', 'MISSING_ROLE_KEY'),
184
- message: 'Role-based access control is selected but no role field has been defined.',
185
- suggestion: "Select which field in your user profile determines the user's role.",
186
- severity: 'error',
187
- context: { ...context, property: 'authorization.roleKey' },
188
- })
189
- } else if (userEntity) {
190
- const roleProp = Array.from(userEntity.properties).find((p) => p.key === rbac.roleKey)
191
- if (roleProp && !roleProp.hasSemantic(SemanticType.UserRole)) {
177
+ if (userEntity) {
178
+ let roleProp: DomainProperty | undefined
179
+ for (const prop of userEntity.properties) {
180
+ if (prop.hasSemantic(SemanticType.UserRole)) {
181
+ roleProp = prop
182
+ break
183
+ }
184
+ }
185
+ if (!roleProp) {
192
186
  issues.push({
193
187
  code: createCode('API', 'MISSING_ROLE_SEMANTIC'),
194
- message: 'The selected role field is missing the User Role data semantic.',
195
- suggestion: 'Go to the Data Modeler and add the "User Role" semantic to this property.',
188
+ message: 'Role-based access control requires a property with the User Role data semantic on the user model.',
189
+ suggestion: 'Go to the Data Modeler and add the "User Role" semantic to the property used for roles.',
196
190
  severity: 'error',
197
- context: { ...context, property: 'authorization.roleKey' },
191
+ context: { ...context, property: 'user' },
198
192
  })
199
193
  }
200
194
  }
@@ -229,15 +223,23 @@ export function validateApiModelSecurity(model: ApiModel): ApiModelValidationIte
229
223
  context: { ...context, property: 'session.properties' },
230
224
  })
231
225
  } else if (model.authorization && model.authorization.strategy === 'RBAC') {
232
- const rbac = model.authorization as RolesBasedAccessControl
233
- if (rbac.roleKey && !model.session.properties.includes(rbac.roleKey)) {
234
- issues.push({
235
- code: createCode('API', 'MISSING_RBAC_SESSION_PROPERTY'),
236
- message: 'The user role must be included in the session data for permissions to work.',
237
- suggestion: 'Make sure your selected role field is checked in the session settings.',
238
- severity: 'error',
239
- context: { ...context, property: 'session.properties' },
240
- })
226
+ if (userEntity) {
227
+ let roleProp: DomainProperty | undefined
228
+ for (const prop of userEntity.properties) {
229
+ if (prop.hasSemantic(SemanticType.UserRole)) {
230
+ roleProp = prop
231
+ break
232
+ }
233
+ }
234
+ if (roleProp && !model.session.properties.includes(roleProp.key)) {
235
+ issues.push({
236
+ code: createCode('API', 'MISSING_RBAC_SESSION_PROPERTY'),
237
+ message: 'The user role must be included in the session data for permissions to work.',
238
+ suggestion: 'Make sure your selected role property is checked in the session settings.',
239
+ severity: 'error',
240
+ context: { ...context, property: 'session.properties' },
241
+ })
242
+ }
241
243
  }
242
244
  }
243
245
 
@@ -23,9 +23,9 @@ Validations are evaluated with one of three severity levels:
23
23
  ## 3. Security & Access Control
24
24
 
25
25
  - **Authentication** [Error]: The `authentication` configuration is required.
26
- - If the strategy is `UsernamePassword`, the `passwordKey` must be defined.
26
+ - If the strategy is `UsernamePassword`, the user entity must contain a property with the `Username` semantic.
27
27
  - **Authorization** [Error]: The `authorization` configuration is required.
28
- - If the strategy is `RBAC`, the `roleKey` must be defined.
28
+ - If the strategy is `RBAC`, the user entity must contain a property with the `UserRole` semantic.
29
29
  - **Session Configuration** [Error]: The `session` configuration is required and must meet the following criteria:
30
30
  - **Secret**: A session encryption token (`secret`) is required.
31
31
  - **Properties**: The `session.properties` array must have at least one property set (e.g. to identify the User ID).
@@ -36,7 +36,7 @@ export interface CustomDomainSchema {
36
36
  updatedAt: number
37
37
  }
38
38
 
39
- export class CustomDomainModel implements CustomDomainSchema {
39
+ export class CustomDomain implements CustomDomainSchema {
40
40
  id: string
41
41
  orgId: string
42
42
  domain: string
@@ -64,7 +64,7 @@ export class CustomDomainModel implements CustomDomainSchema {
64
64
  }
65
65
 
66
66
  constructor(state?: Partial<CustomDomainSchema>) {
67
- const init = CustomDomainModel.createSchema(state)
67
+ const init = CustomDomain.createSchema(state)
68
68
  this.id = init.id
69
69
  this.orgId = init.orgId
70
70
  this.domain = init.domain
@@ -40,7 +40,7 @@ export interface DeploymentCustomDomainSchema {
40
40
  updatedAt: number
41
41
  }
42
42
 
43
- export class DeploymentCustomDomainModel implements DeploymentCustomDomainSchema {
43
+ export class DeploymentCustomDomain implements DeploymentCustomDomainSchema {
44
44
  id: string
45
45
  deploymentId: string
46
46
  customDomainId: string
@@ -63,7 +63,7 @@ export class DeploymentCustomDomainModel implements DeploymentCustomDomainSchema
63
63
  }
64
64
 
65
65
  constructor(state?: Partial<DeploymentCustomDomainSchema>) {
66
- const init = DeploymentCustomDomainModel.createSchema(state)
66
+ const init = DeploymentCustomDomain.createSchema(state)
67
67
  this.id = init.id
68
68
  this.deploymentId = init.deploymentId
69
69
  this.customDomainId = init.customDomainId
@@ -2,10 +2,10 @@ import { nanoid } from '../../nanoid.js'
2
2
  import { PermissionSchema, Permission, PermissionRole } from './Permission.js'
3
3
  import { ModificationSchema } from './Modification.js'
4
4
  import { DeletionSchema } from './Deletion.js'
5
- import { UserSchema, Kind as UserKind } from './User.js'
5
+ import { UserSchema } from './User.js'
6
6
  import { ThingSchema, Thing } from '../Thing.js'
7
7
  import { CapabilitiesSchema } from './Capabilities.js'
8
- import { FolderKind } from '../kinds.js'
8
+ import { FolderKind, UserKind } from '../kinds.js'
9
9
  // this causes error
10
10
  // import { Kind as FolderKind } from '../Folder.js';
11
11
 
@@ -1,5 +1,6 @@
1
1
  import type { DeletionSchema } from './Deletion.js'
2
2
  import type { UserOrganizationGrantType } from './Organization.js'
3
+ import { UserKind } from '../kinds.js'
3
4
 
4
5
  export interface EmailSchema {
5
6
  /**
@@ -34,8 +35,6 @@ export interface UserPictureSchema {
34
35
  */
35
36
  export type IUserPicture = UserPictureSchema
36
37
 
37
- export const Kind = 'Core#User'
38
-
39
38
  export type UserStatus = 'active' | 'deleted' | 'suspended' | 'pending'
40
39
 
41
40
  /**
@@ -47,7 +46,7 @@ export type UserStatus = 'active' | 'deleted' | 'suspended' | 'pending'
47
46
  * identity providers. However, this is not exposed to the user through the API.
48
47
  */
49
48
  export interface UserSchema {
50
- kind: typeof Kind
49
+ kind: typeof UserKind
51
50
  /**
52
51
  * The data store key of the user.
53
52
  */
@@ -59,7 +58,7 @@ export interface UserSchema {
59
58
  /**
60
59
  * When available the email of the user.
61
60
  */
62
- email: IEmail[]
61
+ email: EmailSchema[]
63
62
  /**
64
63
  * The user picture to render.
65
64
  */
@@ -1,4 +1,4 @@
1
- import { ContextListOptions, ContextListResult } from '../browser.js'
1
+ import type { ContextListOptions, ContextListResult } from '../events/BaseEvents.js'
2
2
  import { Exception } from '../exceptions/exception.js'
3
3
  import type { GroupSchema } from '../models/store/Group.js'
4
4
  import { RouteBuilder } from './RouteBuilder.js'
@@ -4,17 +4,6 @@ import { Sdk } from './Sdk.js'
4
4
  import { Http } from './Http.js'
5
5
  import { WsClient } from './WsClient.js'
6
6
 
7
- export type { IStoreResponse, IStoreRequestOptions } from './SdkBase.js'
8
- export type { IMetaCreateOptions, IMediaCreateOptions, IFileCreateOptions, ListFileKind } from './FilesSdk.js'
9
- export type {
10
- IJwtInfo,
11
- IJwtUser,
12
- RegistrationInfoSchema,
13
- OrganizationRegistrationInfoSchema,
14
- OrganizationAddUserInfoSchema,
15
- } from './UsersSdk.js'
16
- export type { DataCatalogListOptions } from './DataCatalogSdk.js'
17
-
18
7
  /**
19
8
  * NodeJS API for API Client's net-store module.
20
9
  */
@@ -4,19 +4,8 @@ import { Sdk } from './Sdk.js'
4
4
  import { Http } from './Http.js'
5
5
  import { WsClient } from './WsClient.js'
6
6
 
7
- export type { IStoreResponse, IStoreRequestOptions } from './SdkBase.js'
8
- export type { IMetaCreateOptions, IMediaCreateOptions, IFileCreateOptions, ListFileKind } from './FilesSdk.js'
9
- export type {
10
- IJwtInfo,
11
- IJwtUser,
12
- RegistrationInfoSchema,
13
- OrganizationRegistrationInfoSchema,
14
- OrganizationAddUserInfoSchema,
15
- } from './UsersSdk.js'
16
- export type { DataCatalogListOptions } from './DataCatalogSdk.js'
17
-
18
7
  /**
19
- * NodeJS API for API Client's net-store module.
8
+ * API Client's web store module.
20
9
  */
21
10
  export class StoreSdk extends Sdk {
22
11
  http: Http = new HttpWeb(this)
@@ -1,5 +1,6 @@
1
1
  import { test } from '@japa/runner'
2
- import { SecurityProcessor, IOidcTokenInfo, HttpRequest, IHttpRequest, Property } from '../../../src/index.js'
2
+ import { SecurityProcessor } from '../../../src/authorization/index.js'
3
+ import { IOidcTokenInfo, HttpRequest, IHttpRequest, Property } from '../../../src/models/index.js'
3
4
 
4
5
  test.group('applyBasicAuth()', (group) => {
5
6
  let request: IHttpRequest
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { JmespathReader } from '../../../src/index.js'
2
+ import { JmespathReader } from '../../../src/data/index.js'
3
3
 
4
4
  test.group('JmespathReader', () => {
5
5
  test('returns a value for a simple path', async ({ assert }) => {
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { JsonReader } from '../../../src/index.js'
2
+ import { JsonReader } from '../../../src/data/index.js'
3
3
 
4
4
  test.group('JsonReader', () => {
5
5
  test('returns a value for a simple path', async ({ assert }) => {
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { PayloadPointer } from '../../../src/index.js'
2
+ import { PayloadPointer } from '../../../src/data/index.js'
3
3
 
4
4
  test.group('PayloadPointer', () => {
5
5
  test('returns a value for a json - exact match', async ({ assert }) => {
@@ -1,12 +1,8 @@
1
1
  import { test } from '@japa/runner'
2
- import {
3
- RequestDataExtractor,
4
- HttpRequestKind,
5
- IHttpRequest,
6
- HttpResponseKind,
7
- IHttpResponse,
8
- HttpResponse,
9
- } from '../../../src/index.js'
2
+ import { RequestDataExtractor } from '../../../src/data/index.js'
3
+ import { HttpRequestKind, IHttpRequest, IHttpResponse, HttpResponse } from '../../../src/models/index.js'
4
+ import { Kinds } from '../../../src/index.js'
5
+
10
6
  import { FlowSourceEnum, FlowRequestDataEnum, FlowResponseDataEnum } from '../../../src/models/http-flows/HttpFlows.js'
11
7
 
12
8
  test.group('constructor()', () => {
@@ -34,13 +30,13 @@ test.group('constructor()', () => {
34
30
  method: 'GET',
35
31
  },
36
32
  {
37
- kind: HttpResponseKind,
33
+ kind: Kinds.HttpResponseKind,
38
34
  status: 200,
39
35
  }
40
36
  )
41
37
  assert.typeOf(instance.response, 'object', 'has the object')
42
38
  const response = instance.response as HttpResponse
43
- assert.equal(response.kind, HttpResponseKind, 'has the HttpResponse instance')
39
+ assert.equal(response.kind, Kinds.HttpResponseKind, 'has the HttpResponse instance')
44
40
  })
45
41
  })
46
42
 
@@ -190,7 +186,7 @@ test.group('response headers', (group) => {
190
186
  }
191
187
  response = {
192
188
  status: 200,
193
- kind: HttpResponseKind,
189
+ kind: Kinds.HttpResponseKind,
194
190
  headers: 'x-t1: true\naccept: text/plain',
195
191
  }
196
192
  })
@@ -238,7 +234,7 @@ test.group('status extraction', (group) => {
238
234
  }
239
235
  response = {
240
236
  status: 200,
241
- kind: HttpResponseKind,
237
+ kind: Kinds.HttpResponseKind,
242
238
  }
243
239
  })
244
240
 
@@ -282,7 +278,7 @@ test.group('data source selection', (group) => {
282
278
  }
283
279
  response = {
284
280
  status: 200,
285
- kind: HttpResponseKind,
281
+ kind: Kinds.HttpResponseKind,
286
282
  payload: 'response-payload',
287
283
  }
288
284
  })
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { UrlEncodedReader } from '../../../src/index.js'
2
+ import { UrlEncodedReader } from '../../../src/data/index.js'
3
3
 
4
4
  test.group('UrlEncodedReader', () => {
5
5
  test('returns a value for a simple path', async ({ assert }) => {
@@ -1,5 +1,5 @@
1
1
  import { test } from '@japa/runner'
2
- import { XmlReader } from '../../../src/index.js'
2
+ import { XmlReader } from '../../../src/data/index.js'
3
3
 
4
4
  test.group('XmlReader', () => {
5
5
  const cities = `
@@ -2,7 +2,7 @@ import { test } from '@japa/runner'
2
2
  import sinon from 'sinon'
3
3
  import { Certificates } from '../../../../src/mocking/lib/Certificates.js'
4
4
  import { Certificate, IPemCertificate } from '../../../../src/models/ClientCertificate.js'
5
- import type { HttpCertificate } from '../../../../src/index.js'
5
+ import { HttpCertificate } from '../../../../src/models/index.js'
6
6
 
7
7
  test.group('certificate()', (group) => {
8
8
  let certs: Certificates
@@ -1,7 +1,7 @@
1
1
  import { test } from '@japa/runner'
2
2
  import sinon from 'sinon'
3
3
  import { HostRules } from '../../../../src/mocking/lib/HostRules.js'
4
- import type { IHostRule } from '../../../../src/index.js'
4
+ import { IHostRule } from '../../../../src/models/index.js'
5
5
 
6
6
  test.group('rule()', (group) => {
7
7
  let rules: HostRules
@@ -1,7 +1,7 @@
1
1
  import { test } from '@japa/runner'
2
2
  import sinon from 'sinon'
3
3
  import { Url } from '../../../../src/mocking/lib/Url.js'
4
- import type { IUrl } from '../../../../src/index.js'
4
+ import type { IUrl } from '../../../../src/models/index.js'
5
5
 
6
6
  test.group('url()', (group) => {
7
7
  let urls: Url
@@ -1,7 +1,7 @@
1
1
  import { test } from '@japa/runner'
2
2
  import { User } from '../../../../src/mocking/lib/User.js'
3
- import { Kind as UserKind } from '../../../../src/models/store/User.js'
4
- import type { UserSchema } from '../../../../src/index.js'
3
+ import { UserKind } from '../../../../src/models/kinds.js'
4
+ import type { UserSchema } from '../../../../src/models/index.js'
5
5
 
6
6
  test.group('user()', (group) => {
7
7
  let user: User