@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.
- package/build/src/authorization/index.d.ts +10 -0
- package/build/src/authorization/index.d.ts.map +1 -0
- package/build/src/authorization/index.js +10 -0
- package/build/src/authorization/index.js.map +1 -0
- package/build/src/browser.d.ts +13 -143
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +10 -144
- package/build/src/browser.js.map +1 -1
- package/build/src/data/DataExtractor.d.ts +1 -2
- package/build/src/data/DataExtractor.d.ts.map +1 -1
- package/build/src/data/DataExtractor.js.map +1 -1
- package/build/src/data/index.d.ts +10 -0
- package/build/src/data/index.d.ts.map +1 -0
- package/build/src/data/index.js +10 -0
- package/build/src/data/index.js.map +1 -0
- package/build/src/events/Events.d.ts +3 -3
- package/build/src/events/index.d.ts +11 -0
- package/build/src/events/index.d.ts.map +1 -0
- package/build/src/events/index.js +4 -0
- package/build/src/events/index.js.map +1 -0
- package/build/src/exceptions/index.d.ts +8 -0
- package/build/src/exceptions/index.d.ts.map +1 -0
- package/build/src/exceptions/index.js +8 -0
- package/build/src/exceptions/index.js.map +1 -0
- package/build/src/index.d.ts +10 -138
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +11 -142
- package/build/src/index.js.map +1 -1
- package/build/src/mocking/lib/User.d.ts.map +1 -1
- package/build/src/mocking/lib/User.js +1 -1
- package/build/src/mocking/lib/User.js.map +1 -1
- package/build/src/modeling/ApiModel.d.ts.map +1 -1
- package/build/src/modeling/ApiModel.js +0 -8
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/RuntimeApiModel.d.ts +16 -0
- package/build/src/modeling/RuntimeApiModel.d.ts.map +1 -1
- package/build/src/modeling/RuntimeApiModel.js +31 -0
- package/build/src/modeling/RuntimeApiModel.js.map +1 -1
- package/build/src/modeling/ai/DataDomainDelta.d.ts +3 -3
- package/build/src/modeling/ai/DataDomainDelta.d.ts.map +1 -1
- package/build/src/modeling/ai/DataDomainDelta.js +3 -3
- package/build/src/modeling/ai/DataDomainDelta.js.map +1 -1
- package/build/src/modeling/amf/index.d.ts +4 -0
- package/build/src/modeling/amf/index.d.ts.map +1 -0
- package/build/src/modeling/amf/index.js +4 -0
- package/build/src/modeling/amf/index.js.map +1 -0
- package/build/src/modeling/index.d.ts +18 -1
- package/build/src/modeling/index.d.ts.map +1 -1
- package/build/src/modeling/index.js +14 -1
- package/build/src/modeling/index.js.map +1 -1
- package/build/src/modeling/types.d.ts +0 -15
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/modeling/validation/api_model_rules.d.ts.map +1 -1
- package/build/src/modeling/validation/api_model_rules.js +49 -46
- package/build/src/modeling/validation/api_model_rules.js.map +1 -1
- package/build/src/models/index.d.ts +64 -0
- package/build/src/models/index.d.ts.map +1 -0
- package/build/src/models/index.js +68 -0
- package/build/src/models/index.js.map +1 -0
- package/build/src/models/store/CustomDomain.d.ts +1 -1
- package/build/src/models/store/CustomDomain.d.ts.map +1 -1
- package/build/src/models/store/CustomDomain.js +2 -2
- package/build/src/models/store/CustomDomain.js.map +1 -1
- package/build/src/models/store/{data_catalog.d.ts → DataCatalog.d.ts} +1 -1
- package/build/src/models/store/DataCatalog.d.ts.map +1 -0
- package/build/src/models/store/DataCatalog.js +2 -0
- package/build/src/models/store/DataCatalog.js.map +1 -0
- package/build/src/models/store/DeploymentCustomDomain.d.ts +1 -1
- package/build/src/models/store/DeploymentCustomDomain.d.ts.map +1 -1
- package/build/src/models/store/DeploymentCustomDomain.js +2 -2
- package/build/src/models/store/DeploymentCustomDomain.js.map +1 -1
- package/build/src/models/store/File.d.ts.map +1 -1
- package/build/src/models/store/File.js +1 -2
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/User.d.ts +3 -3
- package/build/src/models/store/User.d.ts.map +1 -1
- package/build/src/models/store/User.js +1 -1
- package/build/src/models/store/User.js.map +1 -1
- package/build/src/models/store/index.d.ts +17 -0
- package/build/src/models/store/index.d.ts.map +1 -0
- package/build/src/models/store/index.js +10 -0
- package/build/src/models/store/index.js.map +1 -0
- package/build/src/patch/index.d.ts +3 -0
- package/build/src/patch/index.d.ts.map +1 -0
- package/build/src/patch/index.js +2 -0
- package/build/src/patch/index.js.map +1 -0
- package/build/src/sdk/GroupsSdk.d.ts +1 -1
- package/build/src/sdk/GroupsSdk.d.ts.map +1 -1
- package/build/src/sdk/GroupsSdk.js.map +1 -1
- package/build/src/sdk/StoreSdkNode.d.ts +0 -4
- package/build/src/sdk/StoreSdkNode.d.ts.map +1 -1
- package/build/src/sdk/StoreSdkNode.js.map +1 -1
- package/build/src/sdk/StoreSdkWeb.d.ts +1 -5
- package/build/src/sdk/StoreSdkWeb.d.ts.map +1 -1
- package/build/src/sdk/StoreSdkWeb.js +1 -1
- package/build/src/sdk/StoreSdkWeb.js.map +1 -1
- package/build/src/sdk/index.d.ts +8 -0
- package/build/src/sdk/index.d.ts.map +1 -0
- package/build/src/sdk/index.js +3 -0
- package/build/src/sdk/index.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/data/DataExtractor.ts +1 -1
- package/src/mocking/lib/User.ts +2 -1
- package/src/modeling/ApiModel.ts +0 -10
- package/src/modeling/RuntimeApiModel.ts +46 -0
- package/src/modeling/ai/DataDomainDelta.ts +5 -11
- package/src/modeling/readme.md +2 -2
- package/src/modeling/types.ts +0 -15
- package/src/modeling/validation/api_model_rules.ts +50 -48
- package/src/modeling/validation/api_model_validation_rules.md +2 -2
- package/src/models/store/CustomDomain.ts +2 -2
- package/src/models/store/DeploymentCustomDomain.ts +2 -2
- package/src/models/store/File.ts +2 -2
- package/src/models/store/User.ts +3 -4
- package/src/sdk/GroupsSdk.ts +1 -1
- package/src/sdk/StoreSdkNode.ts +0 -11
- package/src/sdk/StoreSdkWeb.ts +1 -12
- package/tests/unit/authorization/SecurityProcessor.spec.ts +2 -1
- package/tests/unit/data/JmesparthReader.spec.ts +1 -1
- package/tests/unit/data/JsonReader.spec.ts +1 -1
- package/tests/unit/data/PayloadPointer.spec.ts +1 -1
- package/tests/unit/data/RequestDataExtractor.spec.ts +9 -13
- package/tests/unit/data/UrlEncodedReader.spec.ts +1 -1
- package/tests/unit/data/XmlReader.spec.ts +1 -1
- package/tests/unit/mocking/current/Certificates.spec.ts +1 -1
- package/tests/unit/mocking/current/HostRules.spec.ts +1 -1
- package/tests/unit/mocking/current/Urls.spec.ts +1 -1
- package/tests/unit/mocking/current/User.spec.ts +2 -2
- package/tests/unit/modeling/RuntimeApiModel.spec.ts +31 -0
- package/tests/unit/modeling/ai/DataDomainDelta.spec.ts +1 -1
- package/tests/unit/modeling/ai/DomainSerialization.spec.ts +1 -1
- package/tests/unit/modeling/ai/tools/DataDomain.tools.spec.ts +1 -1
- package/tests/unit/modeling/amf/shape_generator.spec.ts +1 -1
- package/tests/unit/modeling/api_model.spec.ts +8 -9
- package/tests/unit/modeling/api_model_expose_entity.spec.ts +1 -1
- package/tests/unit/modeling/api_model_remove_entity.spec.ts +1 -1
- package/tests/unit/modeling/data_domain.spec.ts +2 -1
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +1 -1
- package/tests/unit/modeling/data_domain_serialization.spec.ts +2 -2
- package/tests/unit/modeling/definitions/phone.spec.ts +1 -1
- package/tests/unit/modeling/domain_asociation.spec.ts +34 -34
- package/tests/unit/modeling/domain_asociation_targets.spec.ts +1 -1
- package/tests/unit/modeling/domain_entity.spec.ts +3 -9
- package/tests/unit/modeling/domain_entity_associations.spec.ts +1 -1
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +1 -1
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +1 -1
- package/tests/unit/modeling/domain_entity_fields.spec.ts +1 -1
- package/tests/unit/modeling/domain_entity_generators.spec.ts +1 -1
- package/tests/unit/modeling/domain_entity_parents.spec.ts +1 -1
- package/tests/unit/modeling/domain_entity_properties.spec.ts +2 -1
- package/tests/unit/modeling/domain_file.spec.ts +2 -1
- package/tests/unit/modeling/domain_impact_analysis.spec.ts +5 -3
- package/tests/unit/modeling/domain_model.spec.ts +3 -8
- package/tests/unit/modeling/domain_model_entities.spec.ts +2 -1
- package/tests/unit/modeling/domain_namespace.spec.ts +3 -9
- package/tests/unit/modeling/domain_namespace_models.spec.ts +1 -1
- package/tests/unit/modeling/domain_namespace_namespaces.spec.ts +1 -1
- package/tests/unit/modeling/domain_property.spec.ts +3 -1
- package/tests/unit/modeling/domain_validation.spec.ts +1 -1
- package/tests/unit/modeling/domain_versioning.spec.ts +1 -1
- package/tests/unit/modeling/exposed_entity.spec.ts +1 -1
- package/tests/unit/modeling/exposed_entity_setter_validation.spec.ts +1 -1
- package/tests/unit/modeling/generators/OasGenerator.spec.ts +1 -3
- package/tests/unit/modeling/helpers/intellisense.spec.ts +1 -1
- package/tests/unit/modeling/importers/json_schema_importer.spec.ts +1 -1
- package/tests/unit/modeling/validation/api_model_rules.spec.ts +12 -12
- package/tests/unit/modeling/validation/association_validation.spec.ts +1 -1
- package/tests/unit/modeling/validation/entity_validation.spec.ts +1 -1
- package/tests/unit/modeling/validation/property_validation.spec.ts +1 -1
- package/tests/unit/models/Certificate/from_name.spec.ts +2 -1
- package/tests/unit/models/File/addLabel.spec.ts +1 -1
- package/tests/unit/models/File/constructor.spec.ts +2 -1
- package/tests/unit/models/File/createFileCapabilities.spec.ts +1 -1
- package/tests/unit/models/File/new.spec.ts +2 -1
- package/tests/unit/models/File/setDeleted.spec.ts +1 -1
- package/tests/unit/models/File/setLastModified.spec.ts +1 -1
- package/tests/unit/models/File/shortcutTo.spec.ts +1 -1
- package/tests/unit/models/File/toJSON.spec.ts +2 -1
- package/tests/unit/models/File/updateByMeMeta.spec.ts +1 -1
- package/tests/unit/models/Folder/consume.spec.ts +2 -1
- package/tests/unit/models/Folder/create.spec.ts +2 -1
- package/tests/unit/models/Permission/all.spec.ts +1 -1
- package/tests/unit/models/Project/consume.spec.ts +1 -1
- package/tests/unit/models/Project/create.spec.ts +1 -1
- package/tests/unit/models/certificate.spec.ts +2 -7
- package/tests/unit/models/host_rule.spec.ts +1 -1
- package/tests/unit/models/http_project.spec.ts +1 -1
- package/tests/unit/models/http_request.spec.ts +2 -9
- package/tests/unit/models/http_response.spec.ts +2 -1
- package/tests/unit/models/license.spec.ts +1 -1
- package/tests/unit/models/response.spec.ts +2 -2
- package/tests/unit/models/store/CustomDomain.spec.ts +8 -8
- package/tests/unit/models/store/DeploymentCustomDomain.spec.ts +9 -9
- package/tests/unit/models/store/Invitation.spec.ts +1 -1
- package/tests/unit/runtime/http-engine/abort.spec.ts +2 -8
- package/tests/unit/runtime/http-engine/auth.spec.ts +2 -1
- package/tests/unit/runtime/http-engine/certificates.spec.ts +2 -1
- package/tests/unit/runtime/http-engine/cleanup.spec.ts +2 -1
- package/tests/unit/runtime/http-engine/compression.spec.ts +2 -1
- package/tests/unit/runtime/http-engine/core_engine.spec.ts +7 -11
- package/tests/unit/runtime/http-engine/events.spec.ts +2 -1
- package/tests/unit/runtime/http-engine/headers.spec.ts +2 -9
- package/tests/unit/runtime/http-engine/hosts.spec.ts +2 -1
- package/tests/unit/runtime/http-engine/http-get.spec.ts +2 -1
- package/tests/unit/runtime/http-engine/http-post.spec.ts +2 -9
- package/tests/unit/runtime/http-engine/logger.spec.ts +2 -1
- package/tests/unit/runtime/http-engine/message.spec.ts +2 -8
- package/tests/unit/runtime/http-engine/params.spec.ts +2 -10
- package/tests/unit/runtime/http-engine/proxy.spec.ts +2 -10
- package/tests/unit/runtime/http-engine/redirects.spec.ts +4 -6
- package/tests/unit/runtime/http-engine/request_utils.spec.ts +2 -1
- package/tests/unit/runtime/http-engine/responses.spec.ts +2 -10
- package/tests/unit/runtime/http-engine/timeout.spec.ts +2 -8
- package/tests/unit/runtime/http-engine/timings.spec.ts +2 -1
- package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +3 -8
- package/tests/unit/runtime/proxy/RequestProxy.spec.ts +6 -7
- package/tests/unit/runtime/reporters/project_run_cli_reporter.spec.ts +2 -7
- package/tests/unit/runtime/runners/http_assertion_runner.spec.ts +2 -2
- package/tests/unit/runtime/runners/http_flow_runner.spec.ts +2 -2
- package/tests/unit/runtime/runners/parallel_runner.spec.ts +2 -2
- package/tests/unit/runtime/runners/project_runner.spec.ts +2 -5
- package/tests/unit/runtime/runners/request_runner.spec.ts +2 -5
- package/tests/unit/runtime/runners/serial_runner.spec.ts +2 -3
- package/tests/unit/runtime/variables/variables_processor.spec.ts +2 -1
- package/tsconfig.browser.json +3 -4
- package/tsconfig.node.json +1 -3
- package/build/src/models/store/data_catalog.d.ts.map +0 -1
- package/build/src/models/store/data_catalog.js +0 -2
- package/build/src/models/store/data_catalog.js.map +0 -1
- /package/src/models/store/{data_catalog.ts → DataCatalog.ts} +0 -0
package/package.json
CHANGED
|
@@ -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
|
package/src/mocking/lib/User.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { faker } from '@faker-js/faker'
|
|
2
2
|
import { nanoid } from '../../nanoid.js'
|
|
3
|
-
import { UserSchema
|
|
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
|
package/src/modeling/ApiModel.ts
CHANGED
|
@@ -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 '
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
package/src/modeling/readme.md
CHANGED
|
@@ -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'
|
|
191
|
-
apiModel.authorization = { strategy: 'RBAC'
|
|
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'],
|
package/src/modeling/types.ts
CHANGED
|
@@ -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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
|
147
|
-
suggestion: 'Go to the Data Modeler and add the "Password" semantic to
|
|
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: '
|
|
144
|
+
context: { ...context, property: 'user' },
|
|
150
145
|
})
|
|
151
146
|
}
|
|
152
|
-
}
|
|
153
147
|
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
(
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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: '
|
|
195
|
-
suggestion: 'Go to the Data Modeler and add the "User Role" semantic to
|
|
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: '
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
66
|
+
const init = DeploymentCustomDomain.createSchema(state)
|
|
67
67
|
this.id = init.id
|
|
68
68
|
this.deploymentId = init.deploymentId
|
|
69
69
|
this.customDomainId = init.customDomainId
|
package/src/models/store/File.ts
CHANGED
|
@@ -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
|
|
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
|
|
package/src/models/store/User.ts
CHANGED
|
@@ -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
|
|
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:
|
|
61
|
+
email: EmailSchema[]
|
|
63
62
|
/**
|
|
64
63
|
* The user picture to render.
|
|
65
64
|
*/
|
package/src/sdk/GroupsSdk.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextListOptions, ContextListResult } from '../
|
|
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'
|
package/src/sdk/StoreSdkNode.ts
CHANGED
|
@@ -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
|
*/
|
package/src/sdk/StoreSdkWeb.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
|
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 { 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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
})
|
|
@@ -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
|
|
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
|
|
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 {
|
|
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
|