@api-client/core 0.12.0 → 0.12.2
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/bin/plugins/sinon/assert.ts +29 -0
- package/bin/test.ts +2 -0
- package/build/src/amf/AmfShapeGenerator.js +3 -3
- package/build/src/amf/AmfShapeGenerator.js.map +1 -1
- package/build/src/amf/DataValueGenerator.d.ts.map +1 -1
- package/build/src/amf/DataValueGenerator.js +3 -2
- 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 +4 -0
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +3 -0
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +4 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +3 -0
- package/build/src/index.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/DataDomain.d.ts +4 -0
- package/build/src/modeling/DataDomain.d.ts.map +1 -1
- package/build/src/modeling/DataDomain.js +13 -3
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainAssociation.js +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +46 -0
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +71 -0
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.js +2 -2
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts +31 -8
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +118 -46
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainProperty.js +1 -1
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/legacy/DataAssociation.js +3 -3
- package/build/src/modeling/legacy/DataAssociation.js.map +1 -1
- package/build/src/modeling/legacy/DataEntity.js +3 -3
- package/build/src/modeling/legacy/DataEntity.js.map +1 -1
- package/build/src/modeling/legacy/DataEntityBuilder.js +2 -2
- package/build/src/modeling/legacy/DataEntityBuilder.js.map +1 -1
- package/build/src/modeling/legacy/DataModel.js +3 -3
- package/build/src/modeling/legacy/DataModel.js.map +1 -1
- package/build/src/modeling/legacy/DataNamespace.js +3 -3
- package/build/src/modeling/legacy/DataNamespace.js.map +1 -1
- package/build/src/modeling/legacy/DataProperty.js +3 -3
- package/build/src/modeling/legacy/DataProperty.js.map +1 -1
- package/build/src/modeling/validation/association_validation.d.ts +38 -0
- package/build/src/modeling/validation/association_validation.d.ts.map +1 -0
- package/build/src/modeling/validation/association_validation.js +108 -0
- package/build/src/modeling/validation/association_validation.js.map +1 -0
- package/build/src/modeling/validation/entity_validation.d.ts +52 -0
- package/build/src/modeling/validation/entity_validation.d.ts.map +1 -0
- package/build/src/modeling/validation/entity_validation.js +241 -0
- package/build/src/modeling/validation/entity_validation.js.map +1 -0
- package/build/src/modeling/validation/postgresql.d.ts +2 -0
- package/build/src/modeling/validation/postgresql.d.ts.map +1 -0
- package/build/src/modeling/validation/postgresql.js +58 -0
- package/build/src/modeling/validation/postgresql.js.map +1 -0
- package/build/src/modeling/validation/property_validation.d.ts +29 -0
- package/build/src/modeling/validation/property_validation.d.ts.map +1 -0
- package/build/src/modeling/validation/property_validation.js +58 -0
- package/build/src/modeling/validation/property_validation.js.map +1 -0
- package/build/src/modeling/validation/rules.d.ts +55 -0
- package/build/src/modeling/validation/rules.d.ts.map +1 -0
- package/build/src/modeling/validation/rules.js +110 -0
- package/build/src/modeling/validation/rules.js.map +1 -0
- 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/store/DataFile.js +2 -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/patch/PatchClient.js +2 -2
- package/build/src/patch/PatchClient.js.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 +20 -20
- package/package.json +1 -1
- package/src/amf/AmfShapeGenerator.ts +3 -3
- package/src/amf/DataValueGenerator.ts +3 -2
- package/src/amf/models/AmfDataNode.ts +2 -2
- 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/DataDomain.ts +14 -3
- package/src/modeling/DomainAssociation.ts +1 -1
- package/src/modeling/DomainEntity.ts +75 -0
- package/src/modeling/DomainFile.ts +2 -2
- package/src/modeling/DomainImpactAnalysis.ts +144 -54
- package/src/modeling/DomainProperty.ts +1 -1
- package/src/modeling/legacy/DataAssociation.ts +3 -3
- package/src/modeling/legacy/DataEntity.ts +3 -3
- package/src/modeling/legacy/DataEntityBuilder.ts +2 -2
- package/src/modeling/legacy/DataModel.ts +3 -3
- package/src/modeling/legacy/DataNamespace.ts +3 -3
- package/src/modeling/legacy/DataProperty.ts +3 -3
- package/src/modeling/validation/association_validation.ts +109 -0
- package/src/modeling/validation/entity_validation.ts +246 -0
- package/src/modeling/validation/postgresql.ts +57 -0
- package/src/modeling/validation/property_validation.ts +58 -0
- package/src/modeling/validation/rules.ts +152 -0
- 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/store/DataFile.ts +2 -2
- 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/patch/PatchClient.ts +2 -2
- package/src/runtime/store/FilesSdk.ts +3 -3
- package/tests/unit/modeling/data_domain_associations.spec.ts +1 -1
- package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
- package/tests/unit/modeling/domain.property.spec.ts +7 -7
- package/tests/unit/modeling/domain_asociation.spec.ts +3 -3
- package/tests/unit/modeling/domain_entity_associations.spec.ts +1 -1
- package/tests/unit/modeling/domain_entity_properties.spec.ts +2 -2
- package/tests/unit/modeling/domain_impact_analysis.spec.ts +138 -29
- package/tests/unit/modeling/validation/association_validation.spec.ts +140 -0
- package/tests/unit/modeling/validation/entity_validation.spec.ts +192 -0
- package/tests/unit/modeling/validation/property_validation.spec.ts +125 -0
- package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +8 -8
|
@@ -41728,13 +41728,13 @@
|
|
|
41728
41728
|
"@id": "#194"
|
|
41729
41729
|
},
|
|
41730
41730
|
{
|
|
41731
|
-
"@id": "#
|
|
41731
|
+
"@id": "#200"
|
|
41732
41732
|
},
|
|
41733
41733
|
{
|
|
41734
|
-
"@id": "#
|
|
41734
|
+
"@id": "#197"
|
|
41735
41735
|
},
|
|
41736
41736
|
{
|
|
41737
|
-
"@id": "#
|
|
41737
|
+
"@id": "#203"
|
|
41738
41738
|
},
|
|
41739
41739
|
{
|
|
41740
41740
|
"@id": "#206"
|
|
@@ -42470,16 +42470,16 @@
|
|
|
42470
42470
|
"@id": "#219"
|
|
42471
42471
|
},
|
|
42472
42472
|
{
|
|
42473
|
-
"@id": "#
|
|
42473
|
+
"@id": "#210"
|
|
42474
42474
|
},
|
|
42475
42475
|
{
|
|
42476
|
-
"@id": "#
|
|
42476
|
+
"@id": "#213"
|
|
42477
42477
|
},
|
|
42478
42478
|
{
|
|
42479
|
-
"@id": "#
|
|
42479
|
+
"@id": "#216"
|
|
42480
42480
|
},
|
|
42481
42481
|
{
|
|
42482
|
-
"@id": "#
|
|
42482
|
+
"@id": "#219"
|
|
42483
42483
|
}
|
|
42484
42484
|
],
|
|
42485
42485
|
"doc:root": false,
|
|
@@ -43138,7 +43138,7 @@
|
|
|
43138
43138
|
"doc:ExternalDomainElement",
|
|
43139
43139
|
"doc:DomainElement"
|
|
43140
43140
|
],
|
|
43141
|
-
"doc:raw": "
|
|
43141
|
+
"doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
|
|
43142
43142
|
"core:mediaType": "application/yaml",
|
|
43143
43143
|
"sourcemaps:sources": [
|
|
43144
43144
|
{
|
|
@@ -43159,7 +43159,7 @@
|
|
|
43159
43159
|
"doc:ExternalDomainElement",
|
|
43160
43160
|
"doc:DomainElement"
|
|
43161
43161
|
],
|
|
43162
|
-
"doc:raw": "code: '
|
|
43162
|
+
"doc:raw": "code: '5'\ndescription: 'Limited company'\n",
|
|
43163
43163
|
"core:mediaType": "application/yaml",
|
|
43164
43164
|
"sourcemaps:sources": [
|
|
43165
43165
|
{
|
|
@@ -43180,7 +43180,7 @@
|
|
|
43180
43180
|
"doc:ExternalDomainElement",
|
|
43181
43181
|
"doc:DomainElement"
|
|
43182
43182
|
],
|
|
43183
|
-
"doc:raw": "
|
|
43183
|
+
"doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
|
|
43184
43184
|
"core:mediaType": "application/yaml",
|
|
43185
43185
|
"sourcemaps:sources": [
|
|
43186
43186
|
{
|
|
@@ -43892,7 +43892,7 @@
|
|
|
43892
43892
|
"doc:ExternalDomainElement",
|
|
43893
43893
|
"doc:DomainElement"
|
|
43894
43894
|
],
|
|
43895
|
-
"doc:raw": "
|
|
43895
|
+
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '22'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)22 000000'\n",
|
|
43896
43896
|
"core:mediaType": "application/yaml",
|
|
43897
43897
|
"sourcemaps:sources": [
|
|
43898
43898
|
{
|
|
@@ -43913,7 +43913,7 @@
|
|
|
43913
43913
|
"doc:ExternalDomainElement",
|
|
43914
43914
|
"doc:DomainElement"
|
|
43915
43915
|
],
|
|
43916
|
-
"doc:raw": "type:
|
|
43916
|
+
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
|
|
43917
43917
|
"core:mediaType": "application/yaml",
|
|
43918
43918
|
"sourcemaps:sources": [
|
|
43919
43919
|
{
|
|
@@ -43934,7 +43934,7 @@
|
|
|
43934
43934
|
"doc:ExternalDomainElement",
|
|
43935
43935
|
"doc:DomainElement"
|
|
43936
43936
|
],
|
|
43937
|
-
"doc:raw": "type: 'GENERAL'\
|
|
43937
|
+
"doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
|
|
43938
43938
|
"core:mediaType": "application/yaml",
|
|
43939
43939
|
"sourcemaps:sources": [
|
|
43940
43940
|
{
|
|
@@ -43955,7 +43955,7 @@
|
|
|
43955
43955
|
"doc:ExternalDomainElement",
|
|
43956
43956
|
"doc:DomainElement"
|
|
43957
43957
|
],
|
|
43958
|
-
"doc:raw": "type:
|
|
43958
|
+
"doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
|
|
43959
43959
|
"core:mediaType": "application/yaml",
|
|
43960
43960
|
"sourcemaps:sources": [
|
|
43961
43961
|
{
|
|
@@ -44426,7 +44426,7 @@
|
|
|
44426
44426
|
{
|
|
44427
44427
|
"@id": "#199/source-map/lexical/element_0",
|
|
44428
44428
|
"sourcemaps:element": "amf://id#199",
|
|
44429
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44429
|
+
"sourcemaps:value": "[(1,0)-(5,0)]"
|
|
44430
44430
|
},
|
|
44431
44431
|
{
|
|
44432
44432
|
"@id": "#202/source-map/lexical/element_0",
|
|
@@ -44436,7 +44436,7 @@
|
|
|
44436
44436
|
{
|
|
44437
44437
|
"@id": "#205/source-map/lexical/element_0",
|
|
44438
44438
|
"sourcemaps:element": "amf://id#205",
|
|
44439
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44439
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44440
44440
|
},
|
|
44441
44441
|
{
|
|
44442
44442
|
"@id": "#208/source-map/lexical/element_0",
|
|
@@ -44776,22 +44776,22 @@
|
|
|
44776
44776
|
{
|
|
44777
44777
|
"@id": "#212/source-map/lexical/element_0",
|
|
44778
44778
|
"sourcemaps:element": "amf://id#212",
|
|
44779
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44779
|
+
"sourcemaps:value": "[(1,0)-(6,0)]"
|
|
44780
44780
|
},
|
|
44781
44781
|
{
|
|
44782
44782
|
"@id": "#215/source-map/lexical/element_0",
|
|
44783
44783
|
"sourcemaps:element": "amf://id#215",
|
|
44784
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44784
|
+
"sourcemaps:value": "[(1,0)-(6,0)]"
|
|
44785
44785
|
},
|
|
44786
44786
|
{
|
|
44787
44787
|
"@id": "#218/source-map/lexical/element_0",
|
|
44788
44788
|
"sourcemaps:element": "amf://id#218",
|
|
44789
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44789
|
+
"sourcemaps:value": "[(1,0)-(7,0)]"
|
|
44790
44790
|
},
|
|
44791
44791
|
{
|
|
44792
44792
|
"@id": "#221/source-map/lexical/element_0",
|
|
44793
44793
|
"sourcemaps:element": "amf://id#221",
|
|
44794
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44794
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44795
44795
|
},
|
|
44796
44796
|
{
|
|
44797
44797
|
"@id": "#338/source-map/synthesized-field/element_1",
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
unionShape,
|
|
26
26
|
} from './definitions/Shapes.js'
|
|
27
27
|
import { AmfDataNode } from './models/AmfDataNode.js'
|
|
28
|
-
import
|
|
28
|
+
import { nanoid } from 'nanoid'
|
|
29
29
|
import { DataEntityKind, DataPropertyKind } from '../models/kinds.js'
|
|
30
30
|
import { DataValueGenerator } from './DataValueGenerator.js'
|
|
31
31
|
|
|
@@ -318,7 +318,7 @@ export class AmfShapeGenerator {
|
|
|
318
318
|
return examples.map((current) => {
|
|
319
319
|
const value = AmfDataNode.scalar(current, type).toJSON()
|
|
320
320
|
const item: IApiDataExample = {
|
|
321
|
-
id:
|
|
321
|
+
id: nanoid(),
|
|
322
322
|
customDomainProperties: [],
|
|
323
323
|
strict: true,
|
|
324
324
|
types: IAmfExampleTypes,
|
|
@@ -330,7 +330,7 @@ export class AmfShapeGenerator {
|
|
|
330
330
|
|
|
331
331
|
protected _generateArrayExamples(examples: string[], type: string): IApiDataExample[] {
|
|
332
332
|
const item: IApiDataExample = {
|
|
333
|
-
id:
|
|
333
|
+
id: nanoid(),
|
|
334
334
|
customDomainProperties: [],
|
|
335
335
|
strict: true,
|
|
336
336
|
types: IAmfExampleTypes,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid'
|
|
1
2
|
import uuidV4 from '../lib/uuid.js'
|
|
2
|
-
import { randomString } from '../lib/math/Random.js'
|
|
3
3
|
import { DomainPropertyType } from '../modeling/DataFormat.js'
|
|
4
4
|
|
|
5
5
|
export const noValue = Symbol('noValue')
|
|
@@ -53,7 +53,8 @@ export class DataValueGenerator {
|
|
|
53
53
|
protected generateString(fn: string): string | typeof noValue {
|
|
54
54
|
switch (fn) {
|
|
55
55
|
case 'random':
|
|
56
|
-
|
|
56
|
+
// TODO: we need more settings controlling the random string generation.
|
|
57
|
+
return nanoid(8)
|
|
57
58
|
case 'uuid-v4':
|
|
58
59
|
return uuidV4()
|
|
59
60
|
default:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { nanoid } from 'nanoid'
|
|
2
2
|
import { IAmfArrayNodeTypes, IAmfObjectNodeTypes, IAmfScalarNodeTypes } from '../AmfTypes.js'
|
|
3
3
|
import { IApiCustomDomainProperty } from '../definitions/Base.js'
|
|
4
4
|
import { AmfNamespace } from '../definitions/Namespace.js'
|
|
@@ -16,7 +16,7 @@ export type IDataNodeInit = 'scalar' | 'object' | 'array'
|
|
|
16
16
|
* A class that manipulates the AMF's DataNode node.
|
|
17
17
|
*/
|
|
18
18
|
export class AmfDataNode {
|
|
19
|
-
id =
|
|
19
|
+
id = nanoid()
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* AMF domain types.
|
package/src/lib/uuid.ts
CHANGED
|
@@ -8,7 +8,7 @@ for (let i = 0; i < 256; i++) {
|
|
|
8
8
|
*
|
|
9
9
|
* @see http://stackoverflow.com/a/21963136/1127848
|
|
10
10
|
* @example "92329D39-6F5C-4520-ABFC-AAB64544E172"
|
|
11
|
-
* @return
|
|
11
|
+
* @return Generated value
|
|
12
12
|
*/
|
|
13
13
|
export default function v4(): string {
|
|
14
14
|
const d0 = (Math.random() * 0xffffffff) | 0
|
|
@@ -106,7 +106,7 @@ export class History {
|
|
|
106
106
|
} else if (Array.isArray(init.user)) {
|
|
107
107
|
result.user = this.random.pickOne(init.user)
|
|
108
108
|
} else {
|
|
109
|
-
result.user = this.types.
|
|
109
|
+
result.user = this.types.string(21)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
if (typeof init.project === 'string') {
|
|
@@ -114,7 +114,7 @@ export class History {
|
|
|
114
114
|
} else if (Array.isArray(init.project)) {
|
|
115
115
|
result.project = this.random.pickOne(init.project)
|
|
116
116
|
} else if (init.project) {
|
|
117
|
-
result.project = this.types.
|
|
117
|
+
result.project = this.types.string(21)
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
if (typeof init.request === 'string') {
|
|
@@ -122,7 +122,7 @@ export class History {
|
|
|
122
122
|
} else if (Array.isArray(init.request)) {
|
|
123
123
|
result.request = this.random.pickOne(init.request)
|
|
124
124
|
} else if (init.request) {
|
|
125
|
-
result.request = this.types.
|
|
125
|
+
result.request = this.types.string(21)
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
if (typeof init.app === 'string') {
|
|
@@ -130,7 +130,7 @@ export class History {
|
|
|
130
130
|
} else if (Array.isArray(init.app)) {
|
|
131
131
|
result.app = this.random.pickOne(init.app)
|
|
132
132
|
} else if (init.app) {
|
|
133
|
-
result.app = this.types.
|
|
133
|
+
result.app = this.types.string(21)
|
|
134
134
|
}
|
|
135
135
|
return result
|
|
136
136
|
}
|
|
@@ -141,7 +141,7 @@ export class History {
|
|
|
141
141
|
if (usersSize && typeof init.user === 'undefined') {
|
|
142
142
|
const users: string[] = []
|
|
143
143
|
for (let i = 0; i < usersSize; i++) {
|
|
144
|
-
users.push(this.types.
|
|
144
|
+
users.push(this.types.string(21))
|
|
145
145
|
}
|
|
146
146
|
copy.user = users
|
|
147
147
|
}
|
|
@@ -155,21 +155,21 @@ export class History {
|
|
|
155
155
|
if (projectsSize && typeof init.project === 'undefined') {
|
|
156
156
|
const project: string[] = []
|
|
157
157
|
for (let i = 0; i < projectsSize; i++) {
|
|
158
|
-
project.push(this.types.
|
|
158
|
+
project.push(this.types.string(21))
|
|
159
159
|
}
|
|
160
160
|
copy.project = project
|
|
161
161
|
}
|
|
162
162
|
if (requestsSize && typeof init.request === 'undefined') {
|
|
163
163
|
const requests: string[] = []
|
|
164
164
|
for (let i = 0; i < requestsSize; i++) {
|
|
165
|
-
requests.push(this.types.
|
|
165
|
+
requests.push(this.types.string(21))
|
|
166
166
|
}
|
|
167
167
|
copy.request = requests
|
|
168
168
|
}
|
|
169
169
|
if (appsSize && typeof init.app === 'undefined') {
|
|
170
170
|
const apps: string[] = []
|
|
171
171
|
for (let i = 0; i < appsSize; i++) {
|
|
172
|
-
apps.push(this.types.
|
|
172
|
+
apps.push(this.types.string(21))
|
|
173
173
|
}
|
|
174
174
|
copy.app = apps
|
|
175
175
|
}
|
package/src/mocking/lib/User.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class User {
|
|
|
23
23
|
user(init: IUserInit = {}): IUser {
|
|
24
24
|
const result: IUser = {
|
|
25
25
|
kind: UserKind,
|
|
26
|
-
key: this.types.
|
|
26
|
+
key: this.types.string(21),
|
|
27
27
|
name: this.person.name(),
|
|
28
28
|
}
|
|
29
29
|
if (!init.noEmail) {
|
|
@@ -41,7 +41,7 @@ export class User {
|
|
|
41
41
|
}
|
|
42
42
|
if (!init.noProvider) {
|
|
43
43
|
result.provider = {
|
|
44
|
-
refreshToken: this.types.
|
|
44
|
+
refreshToken: this.types.string(21),
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
return result
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { nanoid } from 'nanoid'
|
|
2
2
|
import { Graph } from '@api-client/graph'
|
|
3
3
|
import {
|
|
4
4
|
DomainAssociationKind,
|
|
@@ -165,8 +165,7 @@ export class DataDomain extends EventTarget {
|
|
|
165
165
|
accessor fields: NamespaceOrderedItem[]
|
|
166
166
|
|
|
167
167
|
static createSchema(input: Partial<DataDomainSchema> = {}): DataDomainSchema {
|
|
168
|
-
|
|
169
|
-
const { key = v4(), fields } = input
|
|
168
|
+
const { key = nanoid(), fields } = input
|
|
170
169
|
const info = Thing.fromJSON(input.info, { name: 'Unnamed domain' }).toJSON()
|
|
171
170
|
const result: DataDomainSchema = {
|
|
172
171
|
kind: DataDomainKind,
|
|
@@ -869,6 +868,18 @@ export class DataDomain extends EventTarget {
|
|
|
869
868
|
}
|
|
870
869
|
}
|
|
871
870
|
|
|
871
|
+
/**
|
|
872
|
+
* Lists all entities in the graph that are not part of this domain.
|
|
873
|
+
*/
|
|
874
|
+
*listForeignEntities(): Generator<DomainEntity> {
|
|
875
|
+
for (const node of this.graph.nodes()) {
|
|
876
|
+
const value = this.graph.node(node) as DomainGraphNodeType
|
|
877
|
+
if (value.kind === DomainEntityKind && value.domain.key !== this.key) {
|
|
878
|
+
yield value
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
872
883
|
/**
|
|
873
884
|
* Finds an entity by its key.
|
|
874
885
|
*
|
|
@@ -150,7 +150,7 @@ export class DomainAssociation extends DomainElement {
|
|
|
150
150
|
*/
|
|
151
151
|
static createSchema(input: Partial<DomainAssociationSchema> = {}): DomainAssociationSchema {
|
|
152
152
|
const { key = nanoid() } = input
|
|
153
|
-
const info = Thing.fromJSON(input.info, { name: '
|
|
153
|
+
const info = Thing.fromJSON(input.info, { name: 'new_association' }).toJSON()
|
|
154
154
|
const result: DomainAssociationSchema = {
|
|
155
155
|
kind: DomainAssociationKind,
|
|
156
156
|
key,
|
|
@@ -92,6 +92,35 @@ export interface DomainEntitySchema extends DomainElementSchema {
|
|
|
92
92
|
* const userModel = dataDomain.addModel({ key: 'userModel' });
|
|
93
93
|
* const userEntity = userModel.addEntity({ key: 'user' });
|
|
94
94
|
* ```
|
|
95
|
+
*
|
|
96
|
+
* Entity Validation Rules:
|
|
97
|
+
*
|
|
98
|
+
* - **Primary Key:** An entity must have a primary key selected. This can come from a parent
|
|
99
|
+
* entity or be defined in the current entity.
|
|
100
|
+
* - **Parent Entity:** The parent entity must exist in the graph.
|
|
101
|
+
* - **Circular Dependency:** Adding a parent entity that creates a circular dependency is not allowed.
|
|
102
|
+
* - **Unique Parent:** An entity cannot have the same parent more than once.
|
|
103
|
+
* - **Property Shadowing:** A property can shadow a parent property. This means that if a property
|
|
104
|
+
* with the same key exists in both the parent and child entity, the child property will take precedence.
|
|
105
|
+
* - **Association Shadowing:** An association can shadow a parent association. This means that if an
|
|
106
|
+
* association with the same key exists in both the parent and child entity,
|
|
107
|
+
* the child association will take precedence.
|
|
108
|
+
* - **Property Resolution:** When the same property exists more than one parent and the child entity,
|
|
109
|
+
* doesn't explicitly define the property, then:
|
|
110
|
+
* - The last parent entity (iterating from the first entity to the last) that has the property
|
|
111
|
+
* will be used as the source of the property.
|
|
112
|
+
* - **Association Resolution:** When the same association exists more than one parent and the child entity,
|
|
113
|
+
* doesn't explicitly define the association, then:
|
|
114
|
+
* - The last parent entity (iterating from the first entity to the last) that has the association
|
|
115
|
+
* will be used as the source of the association.
|
|
116
|
+
* - **Minimum Required Properties:** An entity must have at least one property defined. Entities without properties
|
|
117
|
+
* are ignored in the system.
|
|
118
|
+
* - **Entity Name**:
|
|
119
|
+
* - An entity must have a name defined.
|
|
120
|
+
* - The name has to follow the same rules as the names in a SQL database. This means that the name must be unique
|
|
121
|
+
* within the data domain and cannot contain special characters.
|
|
122
|
+
* - **Association Targets:** An association must have a target entity defined.
|
|
123
|
+
* This means that the association must point to at least one entity.
|
|
95
124
|
*/
|
|
96
125
|
export class DomainEntity extends DomainElement {
|
|
97
126
|
/**
|
|
@@ -291,6 +320,13 @@ export class DomainEntity extends DomainElement {
|
|
|
291
320
|
this.root.notifyChange()
|
|
292
321
|
}
|
|
293
322
|
|
|
323
|
+
/**
|
|
324
|
+
* A shortcut to `listProperties()`.
|
|
325
|
+
*/
|
|
326
|
+
get properties(): Generator<DomainProperty> {
|
|
327
|
+
return this.listProperties()
|
|
328
|
+
}
|
|
329
|
+
|
|
294
330
|
/**
|
|
295
331
|
* Lists all properties of this entity.
|
|
296
332
|
*
|
|
@@ -333,6 +369,13 @@ export class DomainEntity extends DomainElement {
|
|
|
333
369
|
return this.fields.some((item) => item.type === 'property')
|
|
334
370
|
}
|
|
335
371
|
|
|
372
|
+
/**
|
|
373
|
+
* A shortcut to `listParents()`.
|
|
374
|
+
*/
|
|
375
|
+
get parents(): Generator<DomainEntity> {
|
|
376
|
+
return this.listParents()
|
|
377
|
+
}
|
|
378
|
+
|
|
336
379
|
/**
|
|
337
380
|
* Lists all parent entities of this entity.
|
|
338
381
|
*
|
|
@@ -622,6 +665,13 @@ export class DomainEntity extends DomainElement {
|
|
|
622
665
|
this.root.notifyChange()
|
|
623
666
|
}
|
|
624
667
|
|
|
668
|
+
/**
|
|
669
|
+
* A shortcut to `listAssociations()`.
|
|
670
|
+
*/
|
|
671
|
+
get associations(): Generator<DomainAssociation> {
|
|
672
|
+
return this.listAssociations()
|
|
673
|
+
}
|
|
674
|
+
|
|
625
675
|
/**
|
|
626
676
|
* Lists all associations of this entity.
|
|
627
677
|
*
|
|
@@ -766,4 +816,29 @@ export class DomainEntity extends DomainElement {
|
|
|
766
816
|
}
|
|
767
817
|
return parent.isChildOf(key)
|
|
768
818
|
}
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Finds the primary key property of this entity.
|
|
822
|
+
* @returns The primary key property of this entity or undefined if not found.
|
|
823
|
+
*/
|
|
824
|
+
primaryKey(): DomainProperty | undefined {
|
|
825
|
+
for (const property of this.properties) {
|
|
826
|
+
if (property.primary) {
|
|
827
|
+
return property
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
let property: DomainProperty | undefined
|
|
831
|
+
for (const parent of this.listParents()) {
|
|
832
|
+
const prop = parent.primaryKey()
|
|
833
|
+
if (prop) {
|
|
834
|
+
// According to the validation rules, the last parent
|
|
835
|
+
// that has the property will be used as the source of
|
|
836
|
+
// the property.
|
|
837
|
+
// In the future, we may add a schema definition to the entity that
|
|
838
|
+
// will explicitly define which property to use.
|
|
839
|
+
property = prop
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return property
|
|
843
|
+
}
|
|
769
844
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { nanoid } from 'nanoid'
|
|
2
2
|
import { File, type IFile } from '../models/store/File.js'
|
|
3
3
|
import { Thing } from '../models/Thing.js'
|
|
4
4
|
import type { DataDomain, DataDomainSchema } from './DataDomain.js'
|
|
@@ -55,7 +55,7 @@ export class DomainFile extends File {
|
|
|
55
55
|
} else {
|
|
56
56
|
init = {
|
|
57
57
|
kind: DomainFileKind,
|
|
58
|
-
key:
|
|
58
|
+
key: nanoid(),
|
|
59
59
|
organization: '',
|
|
60
60
|
info: Thing.fromName('').toJSON(),
|
|
61
61
|
parents: [],
|