Skip to content

Commit 448aad7

Browse files
e-krebsshortcuts
andauthored
feat(specs): update composition specs according to upcoming API changes (#4234)
Co-authored-by: shortcuts <[email protected]>
1 parent 9002538 commit 448aad7

File tree

8 files changed

+143
-53
lines changed

8 files changed

+143
-53
lines changed

playground/javascript/node/composition.ts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,35 @@ const client = compositionClient(appId, apiKey);
99

1010
async function testComposition() {
1111
try {
12+
console.log(appId, apiKey)
1213
// create a new composition
13-
/*
14-
const res = await client.multipleBatch({
15-
requests: [
16-
{
17-
action: 'upsert',
18-
body: {
19-
objectID: 'id1',
20-
description: 'the first ever composition from the client',
21-
behavior: {
22-
injection: {
23-
main: {
24-
source: {
25-
search: {
26-
index: 'cts_e2e_small',
27-
},
28-
},
29-
},
30-
},
31-
},
32-
},
33-
},
34-
],
35-
});
36-
console.log(`[OK]`, res);
37-
*/
14+
// const res = await client.multipleBatch({
15+
// requests: [
16+
// {
17+
// action: 'upsert',
18+
// body: {
19+
// objectID: 'id1',
20+
// name: 'my first composition',
21+
// description: 'the first ever composition from the client',
22+
// behavior: {
23+
// injection: {
24+
// main: {
25+
// source: {
26+
// search: {
27+
// index: 'cts_e2e_small',
28+
// },
29+
// },
30+
// },
31+
// },
32+
// },
33+
// },
34+
// },
35+
// ],
36+
// });
37+
// console.log(`[OK]`, res);
3838

39-
const compos = await client.listCompositions();
39+
console.log(await client.listCompositions())
4040

41-
console.log(`[OK]`, compos);
4241
} catch (e) {
4342
if (e instanceof ApiError) {
4443
return console.log(`[${e.status}] ${e.message}`, e.stackTrace, e);

specs/composition/common/schemas/Hit.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ compositionRankingInfo:
3232
composed:
3333
title: composedRankingInfo
3434
type: object
35-
additionalProperties: false
36-
properties:
37-
index:
38-
type: string
39-
inset:
40-
type: string
41-
required:
42-
- index
43-
- inset
35+
additionalProperties:
36+
title: compositionIdRankingInfo
37+
type: object
38+
properties:
39+
index:
40+
type: string
41+
injectedItemKey:
42+
type: string
43+
required:
44+
- index
45+
- injectedItemKey

specs/composition/common/schemas/SearchParams.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ mainInjectionQueryParameters:
657657
x-categories:
658658
- Filtering
659659

660-
InsetsQueryParameters:
661-
title: Composition Insets Query parameters as object
660+
injectedItemsQueryParameters:
661+
title: Composition injectedItems Query parameters as object
662662
type: object
663663
additionalProperties: false
664664
properties:

specs/composition/common/schemas/SearchResponse.yml

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
searchResponse:
22
additionalProperties: true
33
allOf:
4-
- $ref: '../../../common/schemas/SearchResponse.yml#/baseSearchResponse'
4+
- $ref: '#/compositionBaseSearchResponse'
55
- $ref: '#/searchResults'
66

77
searchResults:
@@ -16,8 +16,10 @@ searchResults:
1616

1717
searchResultsItem:
1818
allOf:
19-
- $ref: '#/searchHits'
19+
- $ref: '../../../common/schemas/SearchResponse.yml#/baseSearchResponse'
2020
- $ref: '../../../common/schemas/SearchResponse.yml#/SearchPagination'
21+
- $ref: '#/searchHits'
22+
- $ref: '#/resultsCompositionsResponse'
2123

2224
searchHits:
2325
type: object
@@ -33,3 +35,82 @@ searchHits:
3335
$ref: 'Hit.yml#/hit'
3436
required:
3537
- hits
38+
39+
resultsCompositionsResponse:
40+
type: object
41+
additionalProperties: true
42+
properties:
43+
compositions:
44+
title: resultsCompositionsInfoResponse
45+
type: object
46+
additionalProperties:
47+
title: resultsCompositionInfoResponse
48+
type: object
49+
properties:
50+
injectedItems:
51+
type: array
52+
items:
53+
$ref: '#/resultsInjectedItemInfoResponse'
54+
required:
55+
- injectedItems
56+
required:
57+
- compositions
58+
59+
resultsInjectedItemInfoResponse:
60+
type: object
61+
additionalProperties: true
62+
properties:
63+
key:
64+
type: string
65+
appliedRules:
66+
type: array
67+
items:
68+
title: resultsInjectedItemAppliedRulesInfoResponse
69+
type: object
70+
properties:
71+
objectID:
72+
$ref: '../../../common/parameters.yml#/objectID'
73+
required:
74+
- objectID
75+
required:
76+
- key
77+
78+
# copy of specs/common/schemas/SearchResponse.yml/#baseSearchResponse without appliedRules
79+
compositionBaseSearchResponse:
80+
type: object
81+
additionalProperties: true
82+
required:
83+
- processingTimeMS
84+
properties:
85+
compositions:
86+
$ref: '#/compositionsSearchResponse'
87+
88+
compositionsSearchResponse:
89+
type: object
90+
additionalProperties: true
91+
properties:
92+
run:
93+
type: array
94+
items:
95+
$ref: '#/compositionRunSearchResponse'
96+
required:
97+
- run
98+
99+
compositionRunSearchResponse:
100+
type: object
101+
additionalProperties: true
102+
properties:
103+
objectID:
104+
$ref: '../../../common/parameters.yml#/objectID'
105+
appliedRules:
106+
type: array
107+
items:
108+
title: compositionRunAppliedRules
109+
type: object
110+
properties:
111+
objectID:
112+
$ref: '../../../common/parameters.yml#/objectID'
113+
required:
114+
- objectID
115+
required:
116+
- objectID

specs/composition/common/schemas/compositionBehavior.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,32 @@ compositionBehavior:
3434
- search
3535
required:
3636
- source
37-
insets:
37+
injectedItems:
3838
type: array
39-
description: list of insets of the current Composition.
39+
description: list of injected items of the current Composition.
4040
minItems: 0
4141
maxItems: 2
4242
items:
43-
$ref: '#/compositionInset'
43+
$ref: '#/injectedItem'
4444
required:
4545
- main
4646
required:
4747
- injection
4848

49-
compositionInset:
49+
injectedItem:
5050
type: object
5151
additionalProperties: false
5252
properties:
53-
name:
53+
key:
5454
type: string
55-
description: Inset name.
55+
description: injected Item unique identifier.
5656
source:
57-
title: compositionInsetSource
57+
title: injectedItemSource
5858
type: object
5959
additionalProperties: false
6060
properties:
6161
search:
62-
title: compositionInsetSourceSearch
62+
title: injectedItemSourceSearch
6363
type: object
6464
additionalProperties: false
6565
properties:
@@ -68,7 +68,7 @@ compositionInset:
6868
description: Composition Main Index name.
6969
example: Products
7070
params:
71-
$ref: './SearchParams.yml#/InsetsQueryParameters'
71+
$ref: './SearchParams.yml#/injectedItemsQueryParameters'
7272
required:
7373
- index
7474
required:
@@ -82,7 +82,7 @@ compositionInset:
8282
minimum: 0
8383
maximum: 20
8484
required:
85-
- name
85+
- key
8686
- source
8787
- position
8888
- length

specs/composition/common/schemas/listCompositionsResponse.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ composition:
2121
properties:
2222
objectID:
2323
$ref: '../../../common/parameters.yml#/objectID'
24-
description:
24+
name:
2525
type: string
2626
description: Composition name.
2727
example: 'my lovely crafted composition'
28+
description:
29+
type: string
30+
description: Composition description.
31+
example: 'my lovely crafted composition that is used for X purpose'
2832
behavior:
2933
$ref: './compositionBehavior.yml#/compositionBehavior'
3034
required:
3135
- objectID
3236
- behavior
37+
- name

tests/CTS/requests/composition/listCompositions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"items": [
1919
{
2020
"objectID": "id1",
21+
"name": "my first composition",
2122
"description": "the first ever composition from the client",
2223
"behavior": {
2324
"injection": {

tests/CTS/requests/composition/multipleBatch.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"action": "upsert",
77
"body": {
88
"objectID": "foo",
9+
"name": "my first composition",
910
"behavior": {
1011
"injection": {
1112
"main": {
@@ -15,7 +16,7 @@
1516
}
1617
}
1718
},
18-
"insets": []
19+
"injectedItems": []
1920
}
2021
}
2122
}
@@ -38,7 +39,7 @@
3839
"body": {
3940
"behavior": {
4041
"injection": {
41-
"insets": [],
42+
"injectedItems": [],
4243
"main": {
4344
"source": {
4445
"search": {
@@ -48,6 +49,7 @@
4849
}
4950
}
5051
},
52+
"name": "my first composition",
5153
"objectID": "foo"
5254
}
5355
},

0 commit comments

Comments
 (0)