@api-client/core 0.11.11 → 0.12.1
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/Testing.md +1 -1
- package/bin/plugins/events/EventPlugin.ts +61 -0
- package/bin/plugins/events/assert.ts +193 -0
- package/bin/plugins/events/types.ts +6 -0
- package/bin/test.ts +8 -1
- package/build/src/amf/AmfShapeGenerator.d.ts +6 -3
- package/build/src/amf/AmfShapeGenerator.d.ts.map +1 -1
- package/build/src/amf/AmfShapeGenerator.js +7 -4
- package/build/src/amf/AmfShapeGenerator.js.map +1 -1
- package/build/src/amf/AmfTypes.d.ts +2 -2
- package/build/src/amf/AmfTypes.d.ts.map +1 -1
- package/build/src/amf/AmfTypes.js.map +1 -1
- package/build/src/amf/DataValueGenerator.d.ts +15 -15
- package/build/src/amf/DataValueGenerator.d.ts.map +1 -1
- package/build/src/amf/DataValueGenerator.js +17 -16
- package/build/src/amf/DataValueGenerator.js.map +1 -1
- package/build/src/amf/models/AmfDataNode.d.ts.map +1 -1
- package/build/src/amf/models/AmfDataNode.js +2 -2
- package/build/src/amf/models/AmfDataNode.js.map +1 -1
- package/build/src/browser.d.ts +12 -9
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +11 -8
- package/build/src/browser.js.map +1 -1
- package/build/src/exceptions/attach_exception.d.ts +11 -0
- package/build/src/exceptions/attach_exception.d.ts.map +1 -0
- package/build/src/exceptions/attach_exception.js +11 -0
- package/build/src/exceptions/attach_exception.js.map +1 -0
- package/build/src/exceptions/detach_exception.d.ts +11 -0
- package/build/src/exceptions/detach_exception.d.ts.map +1 -0
- package/build/src/exceptions/detach_exception.js +11 -0
- package/build/src/exceptions/detach_exception.js.map +1 -0
- package/build/src/exceptions/remove_model_exception.d.ts +8 -0
- package/build/src/exceptions/remove_model_exception.d.ts.map +1 -0
- package/build/src/exceptions/remove_model_exception.js +8 -0
- package/build/src/exceptions/remove_model_exception.js.map +1 -0
- package/build/src/exceptions/remove_namespace_exception.d.ts +8 -0
- package/build/src/exceptions/remove_namespace_exception.d.ts.map +1 -0
- package/build/src/exceptions/remove_namespace_exception.js +8 -0
- package/build/src/exceptions/remove_namespace_exception.js.map +1 -0
- package/build/src/index.d.ts +12 -9
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +11 -8
- package/build/src/index.js.map +1 -1
- package/build/src/legacy.d.ts +8 -0
- package/build/src/legacy.d.ts.map +1 -1
- package/build/src/legacy.js +9 -0
- package/build/src/legacy.js.map +1 -1
- package/build/src/lib/uuid.d.ts +1 -1
- package/build/src/lib/uuid.js +1 -1
- package/build/src/lib/uuid.js.map +1 -1
- package/build/src/mocking/lib/History.js +8 -8
- package/build/src/mocking/lib/History.js.map +1 -1
- package/build/src/mocking/lib/HostRules.js +1 -1
- package/build/src/mocking/lib/HostRules.js.map +1 -1
- package/build/src/mocking/lib/User.js +2 -2
- package/build/src/mocking/lib/User.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +2 -2
- package/build/src/modeling/Bindings.d.ts.map +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DataDomain.d.ts +601 -0
- package/build/src/modeling/DataDomain.d.ts.map +1 -0
- package/build/src/modeling/DataDomain.js +1141 -0
- package/build/src/modeling/DataDomain.js.map +1 -0
- package/build/src/modeling/DataFormat.d.ts +42 -41
- package/build/src/modeling/DataFormat.d.ts.map +1 -1
- package/build/src/modeling/DataFormat.js +30 -131
- package/build/src/modeling/DataFormat.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +281 -0
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -0
- package/build/src/modeling/DomainAssociation.js +440 -0
- package/build/src/modeling/DomainAssociation.js.map +1 -0
- package/build/src/modeling/DomainElement.d.ts +33 -0
- package/build/src/modeling/DomainElement.d.ts.map +1 -0
- package/build/src/modeling/DomainElement.js +32 -0
- package/build/src/modeling/DomainElement.js.map +1 -0
- package/build/src/modeling/DomainEntity.d.ts +383 -0
- package/build/src/modeling/DomainEntity.d.ts.map +1 -0
- package/build/src/modeling/DomainEntity.js +718 -0
- package/build/src/modeling/DomainEntity.js.map +1 -0
- package/build/src/modeling/DomainFile.d.ts +25 -0
- package/build/src/modeling/DomainFile.d.ts.map +1 -0
- package/build/src/modeling/DomainFile.js +86 -0
- package/build/src/modeling/DomainFile.js.map +1 -0
- package/build/src/modeling/DomainImpactAnalysis.d.ts +60 -47
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +201 -132
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +226 -0
- package/build/src/modeling/DomainModel.d.ts.map +1 -0
- package/build/src/modeling/DomainModel.js +401 -0
- package/build/src/modeling/DomainModel.js.map +1 -0
- package/build/src/modeling/DomainNamespace.d.ts +268 -0
- package/build/src/modeling/DomainNamespace.d.ts.map +1 -0
- package/build/src/modeling/DomainNamespace.js +512 -0
- package/build/src/modeling/DomainNamespace.js.map +1 -0
- package/build/src/modeling/DomainProperty.d.ts +281 -0
- package/build/src/modeling/DomainProperty.d.ts.map +1 -0
- package/build/src/modeling/DomainProperty.js +560 -0
- package/build/src/modeling/DomainProperty.js.map +1 -0
- package/build/src/modeling/DomainSerialization.d.ts +40 -0
- package/build/src/modeling/DomainSerialization.d.ts.map +1 -0
- package/build/src/modeling/DomainSerialization.js +288 -0
- package/build/src/modeling/DomainSerialization.js.map +1 -0
- package/build/src/modeling/DomainVersioning.d.ts +17 -0
- package/build/src/modeling/DomainVersioning.d.ts.map +1 -0
- package/build/src/modeling/DomainVersioning.js +124 -0
- package/build/src/modeling/DomainVersioning.js.map +1 -0
- package/build/src/modeling/GraphUtils.d.ts +8 -0
- package/build/src/modeling/GraphUtils.d.ts.map +1 -0
- package/build/src/modeling/GraphUtils.js +26 -0
- package/build/src/modeling/GraphUtils.js.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts +164 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.js +492 -0
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -0
- package/build/src/modeling/{DataAssociation.d.ts → legacy/DataAssociation.d.ts} +10 -5
- package/build/src/modeling/legacy/DataAssociation.d.ts.map +1 -0
- package/build/src/modeling/{DataAssociation.js → legacy/DataAssociation.js} +11 -8
- package/build/src/modeling/legacy/DataAssociation.js.map +1 -0
- package/build/src/modeling/{DataEntity.d.ts → legacy/DataEntity.d.ts} +12 -7
- package/build/src/modeling/legacy/DataEntity.d.ts.map +1 -0
- package/build/src/modeling/{DataEntity.js → legacy/DataEntity.js} +21 -20
- package/build/src/modeling/legacy/DataEntity.js.map +1 -0
- package/build/src/modeling/{DataEntityBuilder.d.ts → legacy/DataEntityBuilder.d.ts} +3 -2
- package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +1 -0
- package/build/src/modeling/{DataEntityBuilder.js → legacy/DataEntityBuilder.js} +4 -3
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +298 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +1 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.js +441 -0
- package/build/src/modeling/legacy/DataImpactAnalysis.js.map +1 -0
- package/build/src/modeling/{DataModel.d.ts → legacy/DataModel.d.ts} +6 -4
- package/build/src/modeling/legacy/DataModel.d.ts.map +1 -0
- package/build/src/modeling/{DataModel.js → legacy/DataModel.js} +9 -8
- package/build/src/modeling/legacy/DataModel.js.map +1 -0
- package/build/src/modeling/{DataNamespace.d.ts → legacy/DataNamespace.d.ts} +22 -3
- package/build/src/modeling/legacy/DataNamespace.d.ts.map +1 -0
- package/build/src/modeling/{DataNamespace.js → legacy/DataNamespace.js} +9 -5
- package/build/src/modeling/legacy/DataNamespace.js.map +1 -0
- package/build/src/modeling/{DataProperty.d.ts → legacy/DataProperty.d.ts} +13 -5
- package/build/src/modeling/legacy/DataProperty.d.ts.map +1 -0
- package/build/src/modeling/{DataProperty.js → legacy/DataProperty.js} +10 -7
- package/build/src/modeling/legacy/DataProperty.js.map +1 -0
- package/build/src/modeling/observed.d.ts +67 -0
- package/build/src/modeling/observed.d.ts.map +1 -0
- package/build/src/modeling/observed.js +230 -0
- package/build/src/modeling/observed.js.map +1 -0
- package/build/src/modeling/types.d.ts +165 -1
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/models/AuthorizationData.js +3 -3
- package/build/src/models/AuthorizationData.js.map +1 -1
- package/build/src/models/CertificateFile.js +2 -2
- package/build/src/models/CertificateFile.js.map +1 -1
- package/build/src/models/ClientCertificate.js +5 -5
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/Environment.js +6 -6
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/Folder.js +2 -2
- package/build/src/models/Folder.js.map +1 -1
- package/build/src/models/HostRule.js +4 -4
- package/build/src/models/HostRule.js.map +1 -1
- package/build/src/models/HttpProject.js +12 -12
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/Project.d.ts.map +1 -1
- package/build/src/models/Project.js +2 -2
- package/build/src/models/Project.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts.map +1 -1
- package/build/src/models/ProjectFolder.js +6 -6
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectRequest.d.ts.map +1 -1
- package/build/src/models/ProjectRequest.js +8 -8
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/ProjectSchema.js +6 -6
- package/build/src/models/ProjectSchema.js.map +1 -1
- package/build/src/models/Thing.d.ts +26 -5
- package/build/src/models/Thing.d.ts.map +1 -1
- package/build/src/models/Thing.js +193 -91
- package/build/src/models/Thing.js.map +1 -1
- package/build/src/models/kinds.d.ts +31 -6
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +31 -6
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/models/store/DataFile.d.ts +3 -1
- package/build/src/models/store/DataFile.d.ts.map +1 -1
- package/build/src/models/store/DataFile.js +4 -2
- package/build/src/models/store/DataFile.js.map +1 -1
- package/build/src/models/store/File.d.ts.map +1 -1
- package/build/src/models/store/File.js +3 -3
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/Organization.js +3 -3
- package/build/src/models/store/Organization.js.map +1 -1
- package/build/src/models/store/Permission.js +7 -7
- package/build/src/models/store/Permission.js.map +1 -1
- package/build/src/models/store/UserIdentity.js +3 -3
- package/build/src/models/store/UserIdentity.js.map +1 -1
- package/build/src/models/transformers/ArcDexieTransformer.js +4 -4
- package/build/src/models/transformers/ArcDexieTransformer.js.map +1 -1
- package/build/src/models/transformers/ArcLegacyTransformer.js +3 -3
- package/build/src/models/transformers/ArcLegacyTransformer.js.map +1 -1
- package/build/src/models/transformers/ArcPouchTransformer.js +2 -2
- package/build/src/models/transformers/ArcPouchTransformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV21Transformer.js +2 -2
- package/build/src/models/transformers/PostmanV21Transformer.js.map +1 -1
- package/build/src/models/transformers/PostmanV2Transformer.js +2 -2
- package/build/src/models/transformers/PostmanV2Transformer.js.map +1 -1
- package/build/src/models/types.d.ts +12 -0
- package/build/src/models/types.d.ts.map +1 -0
- package/build/src/models/types.js +2 -0
- package/build/src/models/types.js.map +1 -0
- package/build/src/patch/PatchClient.js +2 -2
- package/build/src/patch/PatchClient.js.map +1 -1
- package/build/src/runtime/store/FilesSdk.d.ts +2 -2
- package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
- package/build/src/runtime/store/FilesSdk.js +3 -3
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/data/models/example-generator-api.json +8 -8
- package/package.json +20 -6
- package/readme.md +1 -1
- package/src/amf/AmfShapeGenerator.ts +10 -7
- package/src/amf/AmfTypes.ts +2 -2
- package/src/amf/DataValueGenerator.ts +24 -23
- package/src/amf/models/AmfDataNode.ts +2 -2
- package/src/exceptions/attach_exception.ts +11 -0
- package/src/exceptions/detach_exception.ts +11 -0
- package/src/exceptions/remove_model_exception.ts +8 -0
- package/src/exceptions/remove_namespace_exception.ts +8 -0
- package/src/lib/uuid.ts +1 -1
- package/src/mocking/lib/History.ts +8 -8
- package/src/mocking/lib/HostRules.ts +1 -1
- package/src/mocking/lib/User.ts +2 -2
- package/src/modeling/Bindings.ts +2 -2
- package/src/modeling/DataDomain.ts +1220 -0
- package/src/modeling/DataFormat.ts +54 -163
- package/src/modeling/DomainAssociation.ts +476 -0
- package/src/modeling/DomainElement.ts +50 -0
- package/src/modeling/DomainEntity.ts +769 -0
- package/src/modeling/DomainFile.ts +94 -0
- package/src/modeling/DomainImpactAnalysis.ts +218 -144
- package/src/modeling/DomainModel.ts +421 -0
- package/src/modeling/DomainNamespace.ts +537 -0
- package/src/modeling/DomainProperty.ts +548 -0
- package/src/modeling/DomainSerialization.ts +312 -0
- package/src/modeling/DomainVersioning.ts +144 -0
- package/src/modeling/GraphUtils.ts +28 -0
- package/src/modeling/amf/ShapeGenerator.ts +552 -0
- package/src/modeling/graph.md +115 -0
- package/src/modeling/{DataAssociation.ts → legacy/DataAssociation.ts} +15 -10
- package/src/modeling/{DataEntity.ts → legacy/DataEntity.ts} +30 -25
- package/src/modeling/{DataEntityBuilder.ts → legacy/DataEntityBuilder.ts} +5 -4
- package/src/modeling/legacy/DataImpactAnalysis.ts +530 -0
- package/src/modeling/{DataModel.ts → legacy/DataModel.ts} +12 -10
- package/src/modeling/{DataNamespace.ts → legacy/DataNamespace.ts} +25 -7
- package/src/modeling/{DataProperty.ts → legacy/DataProperty.ts} +17 -9
- package/src/modeling/observed.ts +267 -0
- package/src/modeling/types.ts +174 -1
- package/src/models/AuthorizationData.ts +3 -3
- package/src/models/CertificateFile.ts +2 -2
- package/src/models/ClientCertificate.ts +5 -5
- package/src/models/Environment.ts +6 -6
- package/src/models/Folder.ts +2 -2
- package/src/models/HostRule.ts +4 -4
- package/src/models/HttpProject.ts +12 -12
- package/src/models/Project.ts +2 -2
- package/src/models/ProjectFolder.ts +6 -6
- package/src/models/ProjectRequest.ts +8 -8
- package/src/models/ProjectSchema.ts +6 -6
- package/src/models/Thing.ts +70 -5
- package/src/models/kinds.ts +32 -6
- package/src/models/store/DataFile.ts +5 -3
- package/src/models/store/File.ts +3 -3
- package/src/models/store/Organization.ts +3 -3
- package/src/models/store/Permission.ts +7 -7
- package/src/models/store/UserIdentity.ts +3 -3
- package/src/models/transformers/ArcDexieTransformer.ts +4 -4
- package/src/models/transformers/ArcLegacyTransformer.ts +3 -3
- package/src/models/transformers/ArcPouchTransformer.ts +2 -2
- package/src/models/transformers/PostmanV21Transformer.ts +2 -2
- package/src/models/transformers/PostmanV2Transformer.ts +2 -2
- package/src/models/types.ts +11 -0
- package/src/patch/PatchClient.ts +2 -2
- package/src/runtime/store/FilesSdk.ts +5 -5
- package/tests/unit/amf/data_value_generator.spec.ts +15 -15
- package/tests/unit/legacy-transformers/ARC-legacy-import.spec.ts +1 -1
- package/tests/unit/modeling/amf/shape_generator.spec.ts +1174 -0
- package/tests/unit/modeling/data_domain.spec.ts +444 -0
- package/tests/unit/modeling/data_domain_associations.spec.ts +279 -0
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +681 -0
- package/tests/unit/modeling/data_domain_entities.spec.ts +449 -0
- package/tests/unit/modeling/data_domain_foreign.spec.ts +355 -0
- package/tests/unit/modeling/data_domain_models.spec.ts +658 -0
- package/tests/unit/modeling/data_domain_namespaces.spec.ts +668 -0
- package/tests/unit/modeling/data_domain_property.spec.ts +264 -0
- package/tests/unit/modeling/data_domain_serialization.spec.ts +294 -0
- package/tests/unit/modeling/domain.property.spec.ts +822 -0
- package/tests/unit/modeling/domain_asociation.spec.ts +643 -0
- package/tests/unit/modeling/domain_asociation_targets.spec.ts +350 -0
- package/tests/unit/modeling/domain_entity.spec.ts +730 -0
- package/tests/unit/modeling/domain_entity_associations.spec.ts +330 -0
- package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +988 -0
- package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +1451 -0
- package/tests/unit/modeling/domain_entity_fields.spec.ts +113 -0
- package/tests/unit/modeling/domain_entity_generators.spec.ts +20 -0
- package/tests/unit/modeling/domain_entity_parents.spec.ts +291 -0
- package/tests/unit/modeling/domain_entity_properties.spec.ts +305 -0
- package/tests/unit/modeling/{data_file.spec.ts → domain_file.spec.ts} +29 -85
- package/tests/unit/modeling/domain_impact_analysis.spec.ts +452 -0
- package/tests/unit/modeling/domain_model.spec.ts +568 -0
- package/tests/unit/modeling/domain_model_entities.spec.ts +408 -0
- package/tests/unit/modeling/domain_namespace.spec.ts +514 -0
- package/tests/unit/modeling/domain_namespace_models.spec.ts +324 -0
- package/tests/unit/modeling/domain_namespace_namespaces.spec.ts +404 -0
- package/tests/unit/modeling/domain_versioning.spec.ts +140 -0
- package/tests/unit/{amf → modeling/legacy}/amf_shape_generator.spec.ts +11 -11
- package/tests/unit/modeling/{data_association.spec.ts → legacy/data_association.spec.ts} +3 -11
- package/tests/unit/modeling/{data_entity.spec.ts → legacy/data_entity.spec.ts} +10 -8
- package/tests/unit/modeling/{data_entity_generator_json.spec.ts → legacy/data_entity_generator_json.spec.ts} +1 -1
- package/tests/unit/modeling/{data_entity_generator_xml.spec.ts → legacy/data_entity_generator_xml.spec.ts} +1 -1
- package/tests/unit/modeling/{data_model.spec.ts → legacy/data_model.spec.ts} +3 -3
- package/tests/unit/modeling/{data_namespace.spec.ts → legacy/data_namespace.spec.ts} +3 -10
- package/tests/unit/modeling/{data_property.spec.ts → legacy/data_property.spec.ts} +3 -6
- package/tests/unit/modeling/{impact_analysis.spec.ts → legacy/impact_analysis.spec.ts} +9 -9
- package/tests/unit/models/File/new.spec.ts +1 -1
- package/tests/unit/models/HttpProject.spec.ts +3 -3
- package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +8 -8
- package/tsconfig.node.json +35 -0
- package/build/src/modeling/DataAssociation.d.ts.map +0 -1
- package/build/src/modeling/DataAssociation.js.map +0 -1
- package/build/src/modeling/DataEntity.d.ts.map +0 -1
- package/build/src/modeling/DataEntity.js.map +0 -1
- package/build/src/modeling/DataEntityBuilder.d.ts.map +0 -1
- package/build/src/modeling/DataEntityBuilder.js.map +0 -1
- package/build/src/modeling/DataModel.d.ts.map +0 -1
- package/build/src/modeling/DataModel.js.map +0 -1
- package/build/src/modeling/DataNamespace.d.ts.map +0 -1
- package/build/src/modeling/DataNamespace.js.map +0 -1
- package/build/src/modeling/DataProperty.d.ts.map +0 -1
- package/build/src/modeling/DataProperty.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Json } from '@api-client/json'
|
|
2
|
-
import { IThing, Thing } from '
|
|
3
|
-
import
|
|
2
|
+
import { IThing, Thing } from '../../models/Thing.js'
|
|
3
|
+
import { nanoid } from 'nanoid'
|
|
4
4
|
import { DataNamespace } from './DataNamespace.js'
|
|
5
|
-
import { IApiPropertyShape } from '
|
|
6
|
-
import { AmfShapeGenerator } from '
|
|
7
|
-
import { PropertyBinding, PropertyBindings, PropertyWebBindings } from '
|
|
8
|
-
import { DataPropertyKind } from '
|
|
5
|
+
import { IApiPropertyShape } from '../../amf/definitions/Shapes.js'
|
|
6
|
+
import { AmfShapeGenerator } from '../../amf/AmfShapeGenerator.js'
|
|
7
|
+
import { PropertyBinding, PropertyBindings, PropertyWebBindings } from '../Bindings.js'
|
|
8
|
+
import { DataPropertyKind } from '../../models/kinds.js'
|
|
9
9
|
import {
|
|
10
10
|
type BinaryFormat,
|
|
11
11
|
BinaryFormats,
|
|
@@ -17,11 +17,12 @@ import {
|
|
|
17
17
|
DataPropertyTypes,
|
|
18
18
|
type NumberFormat,
|
|
19
19
|
NumberFormats,
|
|
20
|
-
} from '
|
|
20
|
+
} from '../DataFormat.js'
|
|
21
21
|
import type { DataEntity } from './DataEntity.js'
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Describes the default value set on a property schema.
|
|
25
|
+
* @deprecated
|
|
25
26
|
*/
|
|
26
27
|
export interface SchemaDefaultValue {
|
|
27
28
|
/**
|
|
@@ -41,6 +42,7 @@ export interface SchemaDefaultValue {
|
|
|
41
42
|
/**
|
|
42
43
|
* A general schema definition for a property.
|
|
43
44
|
* This is propagated to all bindings (when they support these properties).
|
|
45
|
+
* @deprecated
|
|
44
46
|
*/
|
|
45
47
|
export interface DataPropertySchema {
|
|
46
48
|
/**
|
|
@@ -109,6 +111,9 @@ export interface DataPropertySchema {
|
|
|
109
111
|
examples?: string[]
|
|
110
112
|
}
|
|
111
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @deprecated
|
|
116
|
+
*/
|
|
112
117
|
export interface IDataProperty {
|
|
113
118
|
kind: typeof DataPropertyKind
|
|
114
119
|
/**
|
|
@@ -180,6 +185,9 @@ export interface IDataProperty {
|
|
|
180
185
|
bindings?: PropertyBinding[]
|
|
181
186
|
}
|
|
182
187
|
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated
|
|
190
|
+
*/
|
|
183
191
|
export class DataProperty {
|
|
184
192
|
kind = DataPropertyKind
|
|
185
193
|
|
|
@@ -296,7 +304,7 @@ export class DataProperty {
|
|
|
296
304
|
} else {
|
|
297
305
|
init = {
|
|
298
306
|
kind: DataPropertyKind,
|
|
299
|
-
key:
|
|
307
|
+
key: nanoid(),
|
|
300
308
|
info: Thing.fromName('').toJSON(),
|
|
301
309
|
type: 'string',
|
|
302
310
|
}
|
|
@@ -310,7 +318,7 @@ export class DataProperty {
|
|
|
310
318
|
}
|
|
311
319
|
const {
|
|
312
320
|
info,
|
|
313
|
-
key =
|
|
321
|
+
key = nanoid(),
|
|
314
322
|
kind = DataPropertyKind,
|
|
315
323
|
multiple,
|
|
316
324
|
required,
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
const reactiveSymbol = Symbol('reactive')
|
|
3
|
+
const proxySymbol = Symbol('proxy')
|
|
4
|
+
|
|
5
|
+
interface DomainInstance {
|
|
6
|
+
domain?: { notifyChange(): void }
|
|
7
|
+
notifyChange?: () => void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface PropertyDecorator {
|
|
11
|
+
// accessor decorator signature
|
|
12
|
+
<C extends DomainInstance, V>(
|
|
13
|
+
target: ClassAccessorDecoratorTarget<C, V>,
|
|
14
|
+
context: ClassAccessorDecoratorContext<C, V>
|
|
15
|
+
): ClassAccessorDecoratorResult<C, V>
|
|
16
|
+
// setter decorator signature
|
|
17
|
+
<C extends DomainInstance, V>(
|
|
18
|
+
target: (value: V) => void,
|
|
19
|
+
context: ClassSetterDecoratorContext<C, V>
|
|
20
|
+
): (this: C, value: V) => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type StandardPropertyContext<C, V> = ClassAccessorDecoratorContext<C, V> | ClassSetterDecoratorContext<C, V>
|
|
24
|
+
type StandardPropertyTarget<C, V> = ClassAccessorDecoratorTarget<C, V> | ((value: V) => void)
|
|
25
|
+
|
|
26
|
+
export interface ObserveConfig {
|
|
27
|
+
/**
|
|
28
|
+
* To be used when observing an object and not a primitive.
|
|
29
|
+
* It creates a proxy that observes changes in the object.
|
|
30
|
+
*/
|
|
31
|
+
deep?: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Reads the raw value of the object, that is, not proxied object.
|
|
36
|
+
* @param source The source object that contains the object
|
|
37
|
+
* @param target The target object set on the source object
|
|
38
|
+
* @returns The not proxied object or undefined
|
|
39
|
+
*/
|
|
40
|
+
export function toRaw<T extends object = object>(source: object, target: T): T | undefined {
|
|
41
|
+
const proxies = Reflect.get(source, proxySymbol) as Map<object, object>
|
|
42
|
+
if (!proxies) {
|
|
43
|
+
return undefined
|
|
44
|
+
}
|
|
45
|
+
for (const [key, value] of proxies.entries()) {
|
|
46
|
+
if (value === target) {
|
|
47
|
+
return key as T
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Turns a class property or a setter into an observed property
|
|
54
|
+
* that notifies the root domain when changed.
|
|
55
|
+
*
|
|
56
|
+
* A property has to be declared with the `accessor` type to be
|
|
57
|
+
* observed.
|
|
58
|
+
*
|
|
59
|
+
* ```typescript
|
|
60
|
+
* @observed() accessor name: string | undefined
|
|
61
|
+
*
|
|
62
|
+
* @observed()
|
|
63
|
+
* set height(value: number) {
|
|
64
|
+
* this.#height = value
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
67
|
+
* get height(): number {
|
|
68
|
+
* return this.#height
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* The decorator can be used in the following ways:
|
|
73
|
+
* - As a class property decorator
|
|
74
|
+
* - As a class setter decorator
|
|
75
|
+
*
|
|
76
|
+
* The property class either has to have a `root` property
|
|
77
|
+
* or a `notifyChange` method. The decorator will call the
|
|
78
|
+
* `notifyChange` method if it exists. Otherwise, it will
|
|
79
|
+
* call the `notifyChange` method of the root domain.
|
|
80
|
+
*/
|
|
81
|
+
export function observed(config: ObserveConfig = {}): PropertyDecorator {
|
|
82
|
+
return <C extends DomainInstance, V>(
|
|
83
|
+
target: StandardPropertyTarget<C, V>,
|
|
84
|
+
context: StandardPropertyContext<C, V>
|
|
85
|
+
): any => {
|
|
86
|
+
const { kind } = context
|
|
87
|
+
const { deep } = config
|
|
88
|
+
|
|
89
|
+
function createDeepProxy(this: DomainInstance, obj: unknown, notifyChange: () => void): any {
|
|
90
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
91
|
+
return obj
|
|
92
|
+
}
|
|
93
|
+
// instead of using the target object to store the proxy info, we
|
|
94
|
+
// reflect the proxy info to the object itself. This way we can
|
|
95
|
+
// keep the stored values clean, which helps with testing (deep equal would include symbols)
|
|
96
|
+
// Keys are original objects, values are proxies
|
|
97
|
+
let proxies = Reflect.get(this, proxySymbol) as Map<object, object>
|
|
98
|
+
if (!proxies) {
|
|
99
|
+
proxies = new Map()
|
|
100
|
+
Reflect.set(this, proxySymbol, proxies)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (proxies.has(obj)) {
|
|
104
|
+
return obj
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
108
|
+
const targetObject = this
|
|
109
|
+
|
|
110
|
+
const proxy = new Proxy(obj, {
|
|
111
|
+
get(target, prop) {
|
|
112
|
+
const value = Reflect.get(target, prop)
|
|
113
|
+
return createDeepProxy.bind(targetObject)(value, notifyChange)
|
|
114
|
+
},
|
|
115
|
+
set(target, prop, value) {
|
|
116
|
+
const oldValue = Reflect.get(target, prop)
|
|
117
|
+
if (oldValue !== value) {
|
|
118
|
+
Reflect.set(target, prop, value)
|
|
119
|
+
notifyChange()
|
|
120
|
+
}
|
|
121
|
+
return true
|
|
122
|
+
},
|
|
123
|
+
deleteProperty(target, prop) {
|
|
124
|
+
Reflect.deleteProperty(target, prop)
|
|
125
|
+
notifyChange()
|
|
126
|
+
return true
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
proxies.set(obj, proxy)
|
|
130
|
+
return proxy
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (kind === 'accessor') {
|
|
134
|
+
return {
|
|
135
|
+
set(this: DomainInstance, value: V): void {
|
|
136
|
+
let map = Reflect.get(this, reactiveSymbol)
|
|
137
|
+
if (!map) {
|
|
138
|
+
map = {}
|
|
139
|
+
Reflect.set(this, reactiveSymbol, map)
|
|
140
|
+
}
|
|
141
|
+
if (map[context.name] === context.name) {
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
const notify = () => {
|
|
145
|
+
if (this.domain) {
|
|
146
|
+
this.domain.notifyChange()
|
|
147
|
+
} else if (this.notifyChange) {
|
|
148
|
+
this.notifyChange()
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (deep) {
|
|
152
|
+
value = createDeepProxy.bind(this)(value, notify)
|
|
153
|
+
}
|
|
154
|
+
if (value === undefined) {
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
156
|
+
delete map[context.name]
|
|
157
|
+
} else {
|
|
158
|
+
map[context.name] = value
|
|
159
|
+
}
|
|
160
|
+
notify()
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
get(): V {
|
|
164
|
+
const map = Reflect.get(this, reactiveSymbol) || {}
|
|
165
|
+
return map[context.name]
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
} else if (kind === 'setter') {
|
|
169
|
+
const { name } = context
|
|
170
|
+
return function (this: DomainInstance, value: V): void {
|
|
171
|
+
const oldValue = this[name as keyof DomainInstance]
|
|
172
|
+
if (value === oldValue) {
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
const notify = () => {
|
|
176
|
+
if (this.domain) {
|
|
177
|
+
this.domain.notifyChange()
|
|
178
|
+
} else if (this.notifyChange) {
|
|
179
|
+
this.notifyChange()
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
;(target as (value: V) => void).call(this, value)
|
|
183
|
+
notify()
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
throw new Error(`Unsupported decorator location: ${kind}`)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* A decorator that can be used to retarget the change event
|
|
192
|
+
* of a property to the root domain.
|
|
193
|
+
*
|
|
194
|
+
* This decorator should not be used with the `observed` decorator.
|
|
195
|
+
* It does the same thing. It will notify about a change to the
|
|
196
|
+
* property itself.
|
|
197
|
+
*/
|
|
198
|
+
export function retargetChange() {
|
|
199
|
+
return <C extends DomainInstance, V extends EventTarget>(
|
|
200
|
+
target: StandardPropertyTarget<C, V>,
|
|
201
|
+
context: StandardPropertyContext<C, V>
|
|
202
|
+
): any => {
|
|
203
|
+
const { kind } = context
|
|
204
|
+
function observer(this: DomainInstance) {
|
|
205
|
+
if (this.domain) {
|
|
206
|
+
this.domain.notifyChange()
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
let binding: ((this: DomainInstance) => void) | undefined
|
|
210
|
+
if (kind === 'accessor') {
|
|
211
|
+
return {
|
|
212
|
+
set(this: DomainInstance, value: V): void {
|
|
213
|
+
let map = Reflect.get(this, reactiveSymbol)
|
|
214
|
+
if (!map) {
|
|
215
|
+
map = {}
|
|
216
|
+
Reflect.set(this, reactiveSymbol, map)
|
|
217
|
+
}
|
|
218
|
+
if (map[context.name] === context.name) {
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
const oldValue = map[context.name]
|
|
222
|
+
if (oldValue === value) {
|
|
223
|
+
return
|
|
224
|
+
}
|
|
225
|
+
if (value === undefined) {
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
227
|
+
delete map[context.name]
|
|
228
|
+
} else {
|
|
229
|
+
map[context.name] = value
|
|
230
|
+
}
|
|
231
|
+
if (oldValue && binding) {
|
|
232
|
+
oldValue.removeEventListener('change', binding)
|
|
233
|
+
}
|
|
234
|
+
if (value) {
|
|
235
|
+
binding = observer.bind(this)
|
|
236
|
+
value.addEventListener('change', binding)
|
|
237
|
+
}
|
|
238
|
+
if (this.domain) {
|
|
239
|
+
this.domain.notifyChange()
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
get(): V {
|
|
244
|
+
const map = Reflect.get(this, reactiveSymbol) || {}
|
|
245
|
+
return map[context.name]
|
|
246
|
+
},
|
|
247
|
+
}
|
|
248
|
+
} else if (kind === 'setter') {
|
|
249
|
+
const { name } = context
|
|
250
|
+
return function (this: DomainInstance, value: V): void {
|
|
251
|
+
const oldValue = this[name as keyof DomainInstance] as unknown as V
|
|
252
|
+
if (value === oldValue) {
|
|
253
|
+
return
|
|
254
|
+
}
|
|
255
|
+
;(target as (value: V) => void).call(this, value)
|
|
256
|
+
if (oldValue && binding) {
|
|
257
|
+
oldValue.removeEventListener('change', binding)
|
|
258
|
+
}
|
|
259
|
+
if (value) {
|
|
260
|
+
binding = observer.bind(this)
|
|
261
|
+
value.addEventListener('change', binding)
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
throw new Error(`Unsupported decorator location: ${kind}`)
|
|
266
|
+
}
|
|
267
|
+
}
|
package/src/modeling/types.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import type { Graph, GraphJson } from '@api-client/graph'
|
|
2
|
+
import type { DomainAssociation } from './DomainAssociation.js'
|
|
3
|
+
import type { DomainEntity } from './DomainEntity.js'
|
|
4
|
+
import type { DomainModel } from './DomainModel.js'
|
|
5
|
+
import type { DomainNamespace } from './DomainNamespace.js'
|
|
6
|
+
import type { DomainProperty } from './DomainProperty.js'
|
|
7
|
+
|
|
1
8
|
export interface DataDomainRemoveOptions {
|
|
2
9
|
/**
|
|
3
|
-
* When true, the object will be
|
|
10
|
+
* When true, the object will be forcibly removed.
|
|
4
11
|
* The resolution defined in the `ImpactResolution` class will be applied.
|
|
5
12
|
*
|
|
6
13
|
* For example, when removing an entity that is a parent to another entity, it will
|
|
@@ -11,3 +18,169 @@ export interface DataDomainRemoveOptions {
|
|
|
11
18
|
*/
|
|
12
19
|
force?: boolean
|
|
13
20
|
}
|
|
21
|
+
|
|
22
|
+
export interface AssociationAddOptions {
|
|
23
|
+
/**
|
|
24
|
+
* When set, it is the the association target's origin data domain.
|
|
25
|
+
* The key of the target data domain where this target entity is defined.
|
|
26
|
+
* Only used when `key` is specified.
|
|
27
|
+
*/
|
|
28
|
+
domain?: string
|
|
29
|
+
/**
|
|
30
|
+
* The key of the association target, if known.
|
|
31
|
+
* If the target of the association is not specified, and the association has no other targets,
|
|
32
|
+
* the association is ignored in the namespace while processing.
|
|
33
|
+
*/
|
|
34
|
+
key?: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface DomainGraphEdge {
|
|
38
|
+
/**
|
|
39
|
+
* Indicates that the edge is to or from a foreign domain.
|
|
40
|
+
*/
|
|
41
|
+
foreign?: boolean
|
|
42
|
+
/**
|
|
43
|
+
* The key of the foreign domain. Always set with the `foreign` property.
|
|
44
|
+
*/
|
|
45
|
+
domain?: string
|
|
46
|
+
/**
|
|
47
|
+
* The type of the edge.
|
|
48
|
+
* - `association` The edge is to an association object.
|
|
49
|
+
* - When coming **from** an entiry (the `v` property), that entity owns the association.
|
|
50
|
+
* - When coming **to** an entity (the `w` property), that entity is the target of the association.
|
|
51
|
+
* An association can have multiple targets.
|
|
52
|
+
* - `property` The edge is to a property object. Can only be created between an entity and a property.
|
|
53
|
+
* - The **from** (`v`) is the entity.
|
|
54
|
+
* - The **to** (`w`) is the property.
|
|
55
|
+
* - `parent` The edge is to a parent object.
|
|
56
|
+
* - The **from** (`v`) is the child entity.
|
|
57
|
+
* - The **to** (`w`) is the parent entity.
|
|
58
|
+
*/
|
|
59
|
+
type: 'association' | 'property' | 'parent'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type DomainGraphNodeType = DomainNamespace | DomainModel | DomainEntity | DomainProperty | DomainAssociation
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* An interface that describes the data domain dependency.
|
|
66
|
+
*/
|
|
67
|
+
export interface ForeignDomainDependency {
|
|
68
|
+
/**
|
|
69
|
+
* The system registered key of the foreign domain.
|
|
70
|
+
*/
|
|
71
|
+
key: string
|
|
72
|
+
/**
|
|
73
|
+
* The version of the foreign domain used in this domain.
|
|
74
|
+
*/
|
|
75
|
+
version: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface AssociationTarget {
|
|
79
|
+
/**
|
|
80
|
+
* The key of the target entity.
|
|
81
|
+
*/
|
|
82
|
+
key: string
|
|
83
|
+
/**
|
|
84
|
+
* The key of the target data domain.
|
|
85
|
+
* This is only set when the target is in a different data domain.
|
|
86
|
+
*/
|
|
87
|
+
domain?: string
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Describes the default value set on a property schema.
|
|
92
|
+
*/
|
|
93
|
+
export interface SchemaDefaultValue {
|
|
94
|
+
/**
|
|
95
|
+
* The type of the default value.
|
|
96
|
+
*
|
|
97
|
+
* - `literal` The `value` should be used as-is.
|
|
98
|
+
* - `function` The value represents the name of the function to be used.
|
|
99
|
+
*/
|
|
100
|
+
type: 'literal' | 'function'
|
|
101
|
+
/**
|
|
102
|
+
* The actual value type depends on the `type`.
|
|
103
|
+
* It is always a string and it has to be casted to the property's data type.
|
|
104
|
+
*/
|
|
105
|
+
value: string
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A general schema definition for a property.
|
|
110
|
+
* This is propagated to all bindings (when they support these properties).
|
|
111
|
+
*/
|
|
112
|
+
export interface PropertySchema {
|
|
113
|
+
/**
|
|
114
|
+
* The minimum value of the property.
|
|
115
|
+
*
|
|
116
|
+
* By default it is inclusive value. Use the `exclusiveMinimum` property to make it exclusive.
|
|
117
|
+
*
|
|
118
|
+
* Used with:
|
|
119
|
+
* - string
|
|
120
|
+
* - number
|
|
121
|
+
* - date
|
|
122
|
+
* - time
|
|
123
|
+
* - datetime
|
|
124
|
+
*/
|
|
125
|
+
minimum?: number
|
|
126
|
+
/**
|
|
127
|
+
* The maximum value of the property.
|
|
128
|
+
*
|
|
129
|
+
* By default it is inclusive value. Use the `exclusiveMaximum` property to make it exclusive.
|
|
130
|
+
*
|
|
131
|
+
* Used with:
|
|
132
|
+
* - string
|
|
133
|
+
* - number
|
|
134
|
+
* - date
|
|
135
|
+
* - time
|
|
136
|
+
* - datetime
|
|
137
|
+
*/
|
|
138
|
+
maximum?: number
|
|
139
|
+
/**
|
|
140
|
+
* When set, the minimum value is exclusive.
|
|
141
|
+
*
|
|
142
|
+
* - When `false`: value ≥ minimum.
|
|
143
|
+
* - When `true`: value > minimum.
|
|
144
|
+
*/
|
|
145
|
+
exclusiveMinimum?: boolean
|
|
146
|
+
/**
|
|
147
|
+
* When set, the exclusiveMaximum value is exclusive.
|
|
148
|
+
*
|
|
149
|
+
* - When `false`: value ≤ maximum.
|
|
150
|
+
* - When `true`: value < minimum.
|
|
151
|
+
*/
|
|
152
|
+
exclusiveMaximum?: boolean
|
|
153
|
+
/**
|
|
154
|
+
* The multiplier value for a number scalar.
|
|
155
|
+
*
|
|
156
|
+
* Examples:
|
|
157
|
+
* - if `1` then every integer is allowed
|
|
158
|
+
* - if `2` than every even number is allowed
|
|
159
|
+
* - if `0.5` than every number dividable by `0.5` is allowed
|
|
160
|
+
*/
|
|
161
|
+
multipleOf?: number
|
|
162
|
+
/**
|
|
163
|
+
* The enum values for the property.
|
|
164
|
+
* They are always encoded as strings. The actual type is defined in the `dataType` property.
|
|
165
|
+
*/
|
|
166
|
+
enum?: string[]
|
|
167
|
+
/**
|
|
168
|
+
* The default value for the property.
|
|
169
|
+
* This is always encoded as a string. The actual type is defined in the `dataType` property.
|
|
170
|
+
*/
|
|
171
|
+
defaultValue?: SchemaDefaultValue
|
|
172
|
+
/**
|
|
173
|
+
* The example values for the property.
|
|
174
|
+
* They are always encoded as strings. The actual type is defined in the `dataType` property.
|
|
175
|
+
*/
|
|
176
|
+
examples?: string[]
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The shortcut type for the data domain graph.
|
|
181
|
+
*/
|
|
182
|
+
export type DataDomainGraph = Graph<unknown, DomainGraphNodeType, DomainGraphEdge>
|
|
183
|
+
/**
|
|
184
|
+
* The serialized version of the data domain graph.
|
|
185
|
+
*/
|
|
186
|
+
export type SerializedGraph = GraphJson<unknown, object, DomainGraphEdge>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { nanoid } from 'nanoid'
|
|
2
2
|
|
|
3
3
|
export interface IAuthorizationData {
|
|
4
4
|
key: string
|
|
@@ -30,7 +30,7 @@ export class AuthorizationData {
|
|
|
30
30
|
init = input
|
|
31
31
|
} else {
|
|
32
32
|
init = {
|
|
33
|
-
key:
|
|
33
|
+
key: nanoid(),
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
this.new(init)
|
|
@@ -42,7 +42,7 @@ export class AuthorizationData {
|
|
|
42
42
|
* Note, this throws an error when the provider is not an API Client provider object.
|
|
43
43
|
*/
|
|
44
44
|
new(init: IAuthorizationData): void {
|
|
45
|
-
const { username, password, domain, key =
|
|
45
|
+
const { username, password, domain, key = nanoid() } = init
|
|
46
46
|
this.username = username
|
|
47
47
|
this.password = password
|
|
48
48
|
this.domain = domain
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { nanoid } from 'nanoid'
|
|
2
2
|
import { Certificate, ICertificate } from './ClientCertificate.js'
|
|
3
3
|
import { CertificateFileKind } from './kinds.js'
|
|
4
4
|
import { IFile, File } from './store/File.js'
|
|
@@ -48,7 +48,7 @@ export class CertificateFile extends File {
|
|
|
48
48
|
} else {
|
|
49
49
|
init = {
|
|
50
50
|
kind: CertificateFileKind,
|
|
51
|
-
key:
|
|
51
|
+
key: nanoid(),
|
|
52
52
|
organization: '',
|
|
53
53
|
info: Thing.fromName('').toJSON(),
|
|
54
54
|
parents: [],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { base64ToBuffer, bufferToBase64 } from '../lib/Buffer.js'
|
|
2
|
-
import
|
|
2
|
+
import { nanoid } from 'nanoid'
|
|
3
3
|
import {
|
|
4
4
|
Certificate as LegacyCertificate,
|
|
5
5
|
ARCCertificateIndex,
|
|
@@ -177,7 +177,7 @@ export class Certificate {
|
|
|
177
177
|
certKey: {
|
|
178
178
|
data: key,
|
|
179
179
|
},
|
|
180
|
-
key:
|
|
180
|
+
key: nanoid(),
|
|
181
181
|
name,
|
|
182
182
|
type: 'pem',
|
|
183
183
|
created: Date.now(),
|
|
@@ -201,7 +201,7 @@ export class Certificate {
|
|
|
201
201
|
cert: {
|
|
202
202
|
data: cert,
|
|
203
203
|
},
|
|
204
|
-
key:
|
|
204
|
+
key: nanoid(),
|
|
205
205
|
name,
|
|
206
206
|
type: 'p12',
|
|
207
207
|
created: Date.now(),
|
|
@@ -220,7 +220,7 @@ export class Certificate {
|
|
|
220
220
|
* to its original format.
|
|
221
221
|
*/
|
|
222
222
|
static fromLegacy(index: ARCCertificateIndex, cert: RequestCertificate): Certificate {
|
|
223
|
-
const { name = '', type, created = Date.now(), _id =
|
|
223
|
+
const { name = '', type, created = Date.now(), _id = nanoid() } = index
|
|
224
224
|
if (type === 'pem') {
|
|
225
225
|
const data = Array.isArray(cert.cert) ? cert.cert[0] : cert.cert
|
|
226
226
|
const key = Array.isArray(cert.key) ? cert.key[0] : (cert.key as LegacyCertificate)
|
|
@@ -253,7 +253,7 @@ export class Certificate {
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
constructor(certificate: HttpCertificate) {
|
|
256
|
-
const { type, cert, key =
|
|
256
|
+
const { type, cert, key = nanoid(), name = '', created = Date.now() } = certificate
|
|
257
257
|
this.key = key
|
|
258
258
|
this.name = name
|
|
259
259
|
this.type = type
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Property, IProperty } from './Property.js'
|
|
2
2
|
import { Server, IServer } from './Server.js'
|
|
3
3
|
import { IThing, Thing } from './Thing.js'
|
|
4
|
-
import
|
|
4
|
+
import { nanoid } from 'nanoid'
|
|
5
5
|
import { ARCVariable } from './legacy/models/Variable.js'
|
|
6
6
|
import { IRequestAuthorization, RequestAuthorization } from './RequestAuthorization.js'
|
|
7
7
|
|
|
@@ -91,7 +91,7 @@ export class Environment {
|
|
|
91
91
|
* @param name The name to set.
|
|
92
92
|
*/
|
|
93
93
|
static fromName(name: string): Environment {
|
|
94
|
-
const key =
|
|
94
|
+
const key = nanoid()
|
|
95
95
|
const info = Thing.fromName(name)
|
|
96
96
|
const definition = new Environment({
|
|
97
97
|
key,
|
|
@@ -103,7 +103,7 @@ export class Environment {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
static fromLegacyVariables(name: string, variables: ARCVariable[]): Environment {
|
|
106
|
-
const key =
|
|
106
|
+
const key = nanoid()
|
|
107
107
|
const info = Thing.fromName(name)
|
|
108
108
|
const definition = new Environment({
|
|
109
109
|
key,
|
|
@@ -132,7 +132,7 @@ export class Environment {
|
|
|
132
132
|
} else {
|
|
133
133
|
init = {
|
|
134
134
|
kind: Kind,
|
|
135
|
-
key:
|
|
135
|
+
key: nanoid(),
|
|
136
136
|
info: Thing.fromName('').toJSON(),
|
|
137
137
|
variables: [],
|
|
138
138
|
}
|
|
@@ -149,7 +149,7 @@ export class Environment {
|
|
|
149
149
|
if (!Environment.isEnvironment(init)) {
|
|
150
150
|
throw new Error(`Not an environment.`)
|
|
151
151
|
}
|
|
152
|
-
const { key =
|
|
152
|
+
const { key = nanoid(), variables, info, server, encapsulated = false, authorization } = init
|
|
153
153
|
this.kind = Kind
|
|
154
154
|
this.key = key
|
|
155
155
|
this.encapsulated = encapsulated
|
|
@@ -262,7 +262,7 @@ export class Environment {
|
|
|
262
262
|
clone(opts: IEnvironmentCloneOptions = {}): Environment {
|
|
263
263
|
const copy = new Environment(this.toJSON())
|
|
264
264
|
if (!opts.withoutRevalidate) {
|
|
265
|
-
copy.key =
|
|
265
|
+
copy.key = nanoid()
|
|
266
266
|
}
|
|
267
267
|
return copy
|
|
268
268
|
}
|
package/src/models/Folder.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFile, File } from './store/File.js'
|
|
2
|
-
import
|
|
2
|
+
import { nanoid } from 'nanoid'
|
|
3
3
|
import { Thing } from './Thing.js'
|
|
4
4
|
import { FolderKind } from './kinds.js'
|
|
5
5
|
|
|
@@ -39,7 +39,7 @@ export class Folder extends File {
|
|
|
39
39
|
} else {
|
|
40
40
|
init = {
|
|
41
41
|
kind: FolderKind,
|
|
42
|
-
key:
|
|
42
|
+
key: nanoid(),
|
|
43
43
|
organization: '',
|
|
44
44
|
info: Thing.fromName('').toJSON(),
|
|
45
45
|
parents: [],
|