@api-client/core 0.18.18 → 0.18.19
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/modeling/DataDomain.d.ts +35 -1
- package/build/src/modeling/DataDomain.d.ts.map +1 -1
- package/build/src/modeling/DataDomain.js +120 -0
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +10 -0
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js +26 -2
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/definitions/SKU.d.ts.map +1 -1
- package/build/src/modeling/definitions/SKU.js +2 -0
- package/build/src/modeling/definitions/SKU.js.map +1 -1
- package/build/src/modeling/helpers/Intelisense.d.ts +472 -0
- package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -0
- package/build/src/modeling/helpers/Intelisense.js +1200 -0
- package/build/src/modeling/helpers/Intelisense.js.map +1 -0
- package/build/src/modeling/templates/blog-domain.d.ts +40 -0
- package/build/src/modeling/templates/blog-domain.d.ts.map +1 -0
- package/build/src/modeling/templates/blog-domain.js +621 -0
- package/build/src/modeling/templates/blog-domain.js.map +1 -0
- package/build/src/modeling/templates/ecommerce-domain.d.ts +39 -0
- package/build/src/modeling/templates/ecommerce-domain.d.ts.map +1 -0
- package/build/src/modeling/templates/ecommerce-domain.js +663 -0
- package/build/src/modeling/templates/ecommerce-domain.js.map +1 -0
- package/build/src/modeling/types.d.ts +49 -0
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modeling/DataDomain.ts +144 -0
- package/src/modeling/DomainProperty.ts +23 -0
- package/src/modeling/definitions/SKU.ts +2 -0
- package/src/modeling/helpers/Intelisense.ts +1345 -0
- package/src/modeling/templates/blog-domain.ts +787 -0
- package/src/modeling/templates/ecommerce-domain.ts +834 -0
- package/src/modeling/types.ts +63 -0
- package/tests/unit/modeling/DataDomain.search.spec.ts +188 -0
package/src/modeling/types.ts
CHANGED
|
@@ -893,3 +893,66 @@ export interface DeserializationResult {
|
|
|
893
893
|
*/
|
|
894
894
|
success: boolean
|
|
895
895
|
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Available node types for search filtering.
|
|
899
|
+
*/
|
|
900
|
+
export type SearchableNodeType =
|
|
901
|
+
| typeof DomainNamespaceKind
|
|
902
|
+
| typeof DomainModelKind
|
|
903
|
+
| typeof DomainEntityKind
|
|
904
|
+
| typeof DomainPropertyKind
|
|
905
|
+
| typeof DomainAssociationKind
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Search criteria for filtering domain nodes.
|
|
909
|
+
*/
|
|
910
|
+
export interface DomainSearchCriteria {
|
|
911
|
+
/**
|
|
912
|
+
* Text query to search for in name, displayName, and description fields.
|
|
913
|
+
* Can be a string for exact match or RegExp for pattern matching.
|
|
914
|
+
*/
|
|
915
|
+
query?: string | RegExp
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Filter by specific node types. If not provided, all node types are included.
|
|
919
|
+
*/
|
|
920
|
+
nodeTypes?: SearchableNodeType[]
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Whether to include nodes from foreign domains in the search results.
|
|
924
|
+
* Defaults to false.
|
|
925
|
+
*/
|
|
926
|
+
includeForeignDomains?: boolean
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* Case-sensitive search when using string query.
|
|
930
|
+
* Defaults to false (case-insensitive).
|
|
931
|
+
*/
|
|
932
|
+
caseSensitive?: boolean
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* A search result containing a matching domain node and metadata.
|
|
937
|
+
*/
|
|
938
|
+
export interface DomainSearchResult {
|
|
939
|
+
/**
|
|
940
|
+
* The matching domain node.
|
|
941
|
+
*/
|
|
942
|
+
node: DomainGraphNodeType
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* The field(s) that matched the search query.
|
|
946
|
+
*/
|
|
947
|
+
matchedFields: ('name' | 'displayName' | 'description')[]
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* The key used to identify this node in the graph.
|
|
951
|
+
*/
|
|
952
|
+
key: string
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Whether this node belongs to a foreign domain.
|
|
956
|
+
*/
|
|
957
|
+
isForeign: boolean
|
|
958
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import { DataDomain } from '../../../src/modeling/DataDomain.js'
|
|
3
|
+
import { DomainEntityKind, DomainNamespaceKind, DomainPropertyKind } from '../../../src/models/kinds.js'
|
|
4
|
+
|
|
5
|
+
test.group('DataDomain Search', () => {
|
|
6
|
+
test('should return all nodes when no search criteria provided', ({ assert }) => {
|
|
7
|
+
const domain = new DataDomain({
|
|
8
|
+
key: 'test-domain',
|
|
9
|
+
info: { name: 'Test Domain' },
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const namespace = domain.addNamespace({ info: { name: 'TestNamespace' } })
|
|
13
|
+
const model = namespace.addModel({ info: { name: 'TestModel' } })
|
|
14
|
+
const entity = model.addEntity({ info: { name: 'TestEntity' } })
|
|
15
|
+
entity.addProperty({ info: { name: 'testProperty' }, type: 'string' })
|
|
16
|
+
|
|
17
|
+
const results = domain.search()
|
|
18
|
+
|
|
19
|
+
assert.isAtLeast(results.length, 4) // namespace, model, entity, property
|
|
20
|
+
assert.isTrue(results.every((result) => result.matchedFields.length === 0))
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('should search by text query in name field', ({ assert }) => {
|
|
24
|
+
const domain = new DataDomain({
|
|
25
|
+
key: 'test-domain',
|
|
26
|
+
info: { name: 'Test Domain' },
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const namespace = domain.addNamespace({ info: { name: 'UserNamespace' } })
|
|
30
|
+
const model = namespace.addModel({ info: { name: 'UserModel' } })
|
|
31
|
+
const entity = model.addEntity({ info: { name: 'User' } })
|
|
32
|
+
entity.addProperty({ info: { name: 'email' }, type: 'string' })
|
|
33
|
+
|
|
34
|
+
const results = domain.search({ query: 'User' })
|
|
35
|
+
|
|
36
|
+
assert.equal(results.length, 3) // namespace, model, entity
|
|
37
|
+
assert.isTrue(results.every((result) => result.matchedFields.includes('name')))
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('should search by text query in displayName field', ({ assert }) => {
|
|
41
|
+
const domain = new DataDomain({
|
|
42
|
+
key: 'test-domain',
|
|
43
|
+
info: { name: 'Test Domain' },
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
domain.addNamespace({ info: { name: 'TestNamespace', displayName: 'User Management' } })
|
|
47
|
+
|
|
48
|
+
const results = domain.search({ query: 'Management' })
|
|
49
|
+
|
|
50
|
+
assert.equal(results.length, 1)
|
|
51
|
+
assert.equal(results[0].node.kind, DomainNamespaceKind)
|
|
52
|
+
assert.isTrue(results[0].matchedFields.includes('displayName'))
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('should search by text query in description field', ({ assert }) => {
|
|
56
|
+
const domain = new DataDomain({
|
|
57
|
+
key: 'test-domain',
|
|
58
|
+
info: { name: 'Test Domain' },
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
domain.addNamespace({
|
|
62
|
+
info: { name: 'TestNamespace', description: 'Handles user authentication' },
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const results = domain.search({ query: 'authentication' })
|
|
66
|
+
|
|
67
|
+
assert.equal(results.length, 1)
|
|
68
|
+
assert.equal(results[0].node.kind, DomainNamespaceKind)
|
|
69
|
+
assert.isTrue(results[0].matchedFields.includes('description'))
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test('should filter by node type', ({ assert }) => {
|
|
73
|
+
const domain = new DataDomain({
|
|
74
|
+
key: 'test-domain',
|
|
75
|
+
info: { name: 'Test Domain' },
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const namespace = domain.addNamespace({ info: { name: 'UserNamespace' } })
|
|
79
|
+
const model = namespace.addModel({ info: { name: 'UserModel' } })
|
|
80
|
+
const entity = model.addEntity({ info: { name: 'User' } })
|
|
81
|
+
entity.addProperty({ info: { name: 'userId' }, type: 'string' })
|
|
82
|
+
|
|
83
|
+
const entityResults = domain.search({ nodeTypes: [DomainEntityKind] })
|
|
84
|
+
const propertyResults = domain.search({ nodeTypes: [DomainPropertyKind] })
|
|
85
|
+
|
|
86
|
+
assert.equal(entityResults.length, 1)
|
|
87
|
+
assert.equal(entityResults[0].node.kind, DomainEntityKind)
|
|
88
|
+
|
|
89
|
+
assert.equal(propertyResults.length, 1)
|
|
90
|
+
assert.equal(propertyResults[0].node.kind, DomainPropertyKind)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
test('should combine text query and node type filters', ({ assert }) => {
|
|
94
|
+
const domain = new DataDomain({
|
|
95
|
+
key: 'test-domain',
|
|
96
|
+
info: { name: 'Test Domain' },
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const namespace = domain.addNamespace({ info: { name: 'UserNamespace' } })
|
|
100
|
+
const model = namespace.addModel({ info: { name: 'UserModel' } })
|
|
101
|
+
const entity = model.addEntity({ info: { name: 'User' } })
|
|
102
|
+
entity.addProperty({ info: { name: 'userName' }, type: 'string' })
|
|
103
|
+
|
|
104
|
+
const results = domain.search({
|
|
105
|
+
query: 'User',
|
|
106
|
+
nodeTypes: [DomainEntityKind, DomainPropertyKind],
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
assert.equal(results.length, 2) // entity and property
|
|
110
|
+
assert.isTrue(
|
|
111
|
+
results.every((result) => result.node.kind === DomainEntityKind || result.node.kind === DomainPropertyKind)
|
|
112
|
+
)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test('should support case-sensitive search', ({ assert }) => {
|
|
116
|
+
const domain = new DataDomain({
|
|
117
|
+
key: 'test-domain',
|
|
118
|
+
info: { name: 'Test Domain' },
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
domain.addNamespace({ info: { name: 'user' } })
|
|
122
|
+
domain.addNamespace({ info: { name: 'User' } })
|
|
123
|
+
|
|
124
|
+
const caseSensitiveResults = domain.search({ query: 'User', caseSensitive: true })
|
|
125
|
+
const caseInsensitiveResults = domain.search({ query: 'User', caseSensitive: false })
|
|
126
|
+
|
|
127
|
+
assert.equal(caseSensitiveResults.length, 1)
|
|
128
|
+
assert.equal(caseInsensitiveResults.length, 2)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
test('should support regex queries', ({ assert }) => {
|
|
132
|
+
const domain = new DataDomain({
|
|
133
|
+
key: 'test-domain',
|
|
134
|
+
info: { name: 'Test Domain' },
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
domain.addNamespace({ info: { name: 'user1' } })
|
|
138
|
+
domain.addNamespace({ info: { name: 'user2' } })
|
|
139
|
+
domain.addNamespace({ info: { name: 'admin' } })
|
|
140
|
+
|
|
141
|
+
const results = domain.search({ query: /^user\d+$/ })
|
|
142
|
+
|
|
143
|
+
assert.equal(results.length, 2)
|
|
144
|
+
assert.isTrue(results.every((result) => /^user\d+$/.test(result.node.info.name || '')))
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
test('should identify foreign nodes correctly', ({ assert }) => {
|
|
148
|
+
const foreignDomain = new DataDomain({
|
|
149
|
+
key: 'foreign-domain',
|
|
150
|
+
info: { name: 'Foreign Domain', version: '1.0.0' },
|
|
151
|
+
})
|
|
152
|
+
foreignDomain.addNamespace({ info: { name: 'ForeignNamespace' } })
|
|
153
|
+
|
|
154
|
+
const domain = new DataDomain({
|
|
155
|
+
key: 'main-domain',
|
|
156
|
+
info: { name: 'Main Domain' },
|
|
157
|
+
})
|
|
158
|
+
domain.registerForeignDomain(foreignDomain)
|
|
159
|
+
|
|
160
|
+
const resultsWithoutForeign = domain.search({ query: 'Foreign' })
|
|
161
|
+
const resultsWithForeign = domain.search({ query: 'Foreign', includeForeignDomains: true })
|
|
162
|
+
|
|
163
|
+
assert.equal(resultsWithoutForeign.length, 0)
|
|
164
|
+
assert.equal(resultsWithForeign.length, 1)
|
|
165
|
+
assert.isTrue(resultsWithForeign[0].isForeign)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
test('should handle multiple matched fields', ({ assert }) => {
|
|
169
|
+
const domain = new DataDomain({
|
|
170
|
+
key: 'test-domain',
|
|
171
|
+
info: { name: 'Test Domain' },
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
domain.addNamespace({
|
|
175
|
+
info: {
|
|
176
|
+
name: 'TestNamespace',
|
|
177
|
+
displayName: 'Test Display',
|
|
178
|
+
description: 'Test description',
|
|
179
|
+
},
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
const results = domain.search({ query: 'Test' })
|
|
183
|
+
|
|
184
|
+
assert.equal(results.length, 1)
|
|
185
|
+
assert.equal(results[0].matchedFields.length, 3)
|
|
186
|
+
assert.includeMembers(results[0].matchedFields, ['name', 'displayName', 'description'])
|
|
187
|
+
})
|
|
188
|
+
})
|