Skip to content

Commit 5b3620b

Browse files
test(javascript): update compositions testcases for metadata and external injected items (#5331) (generated) [skip ci]
Co-authored-by: Ben Kalmus <[email protected]>
1 parent 67a3abd commit 5b3620b

File tree

7 files changed

+1224
-41
lines changed

7 files changed

+1224
-41
lines changed

clients/algoliasearch-client-javascript/packages/client-composition/model/compositionRule.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ export type CompositionRule = {
3131
* Time periods when the rule is active.
3232
*/
3333
validity?: Array<TimeRange> | undefined;
34+
35+
/**
36+
* A list of tags.
37+
*/
38+
tags?: Array<string> | undefined;
3439
};

docs/bundled/composition-full-snippets.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@
5252
"listCompositions": "const response = await client.listCompositions();"
5353
},
5454
"multipleBatch": {
55-
"default": "const response = await client.multipleBatch({\n requests: [\n {\n action: 'upsert',\n body: {\n objectID: 'foo',\n name: 'my first composition',\n behavior: { injection: { main: { source: { search: { index: 'bar' } } }, injectedItems: [] } },\n },\n },\n { action: 'delete', body: { objectID: 'baz' } },\n ],\n});"
55+
"multipleBatch": "const response = await client.multipleBatch({\n requests: [\n {\n action: 'upsert',\n body: {\n objectID: 'my-metadata-compo',\n name: 'my composition',\n behavior: {\n injection: {\n main: { source: { search: { index: 'foo', params: { filters: 'brand:adidas' } } } },\n injectedItems: [\n {\n key: 'injectedItem1',\n source: { search: { index: 'foo', params: { filters: 'brand:adidas' } } },\n position: 2,\n length: 1,\n metadata: {\n hits: {\n addItemKey: true,\n extra: {\n 'my-string': 'string',\n 'my-bool': true,\n 'my-number': 42,\n 'my-object': { 'sub-key': 'sub-value' },\n 'my-array': [1, 2, 3],\n 'my-empty-object': {},\n },\n },\n },\n },\n {\n key: 'externalItem',\n source: { search: { index: 'foo', params: { filters: 'brand:puma' } } },\n position: 5,\n length: 5,\n metadata: {\n hits: {\n addItemKey: true,\n extra: {\n 'my-string': 'string',\n 'my-bool': true,\n 'my-number': 42,\n 'my-object': { 'sub-key': 'sub-value' },\n 'my-array': [1, 2, 3],\n 'my-empty-object': {},\n },\n },\n },\n },\n ],\n },\n },\n },\n },\n ],\n});"
5656
},
5757
"putComposition": {
58-
"putComposition": "const response = await client.putComposition({\n compositionID: 'my-external-injection-compo',\n composition: {\n objectID: 'my-external-injection-compo',\n name: 'my first composition',\n behavior: {\n injection: {\n main: { source: { search: { index: 'foo' } } },\n injectedItems: [\n {\n key: 'injectedItem1',\n source: { external: { index: 'foo', ordering: 'userDefined', params: { filters: 'brand:adidas' } } },\n position: 2,\n length: 1,\n },\n ],\n },\n },\n },\n});"
58+
"putComposition": "const response = await client.putComposition({\n compositionID: 'my-metadata-compo',\n composition: {\n objectID: 'my-metadata-compo',\n name: 'my composition',\n behavior: {\n injection: {\n main: { source: { search: { index: 'foo', params: { filters: 'brand:adidas' } } } },\n injectedItems: [\n {\n key: 'injectedItem1',\n source: { search: { index: 'foo', params: { filters: 'brand:adidas' } } },\n position: 2,\n length: 1,\n metadata: {\n hits: {\n addItemKey: true,\n extra: {\n 'my-string': 'string',\n 'my-bool': true,\n 'my-number': 42,\n 'my-object': { 'sub-key': 'sub-value' },\n 'my-array': [1, 2, 3],\n 'my-empty-object': {},\n },\n },\n },\n },\n {\n key: 'externalItem',\n source: { search: { index: 'foo', params: { filters: 'brand:puma' } } },\n position: 5,\n length: 5,\n metadata: {\n hits: {\n addItemKey: true,\n extra: {\n 'my-string': 'string',\n 'my-bool': true,\n 'my-number': 42,\n 'my-object': { 'sub-key': 'sub-value' },\n 'my-array': [1, 2, 3],\n 'my-empty-object': {},\n },\n },\n },\n },\n ],\n },\n },\n },\n});"
5959
},
6060
"putCompositionRule": {
61-
"default": "const response = await client.putCompositionRule({\n compositionID: '1234',\n objectID: '5678',\n compositionRule: {\n objectID: '5678',\n conditions: [{ anchoring: 'is', pattern: 'test' }],\n consequence: {\n behavior: {\n injection: {\n main: { source: { search: { index: 'foo' } } },\n injectedItems: [{ key: 'injectedItem1', source: { search: { index: 'foo' } }, position: 2, length: 1 }],\n },\n },\n },\n },\n});"
61+
"putCompositionRule": "const response = await client.putCompositionRule({\n compositionID: 'compositionID',\n objectID: 'rule-with-exernal-source',\n compositionRule: {\n objectID: 'rule-with-exernal-source',\n description: 'my description',\n tags: ['tag1', 'tag2'],\n enabled: true,\n validity: [{ from: 1704063600, until: 1704083600 }],\n conditions: [\n { anchoring: 'contains', pattern: 'harry' },\n { anchoring: 'contains', pattern: 'potter' },\n ],\n consequence: {\n behavior: {\n injection: {\n main: { source: { search: { index: 'my-index', params: { filters: 'brand:adidas' } } } },\n injectedItems: [\n {\n key: 'injectedItem',\n source: {\n external: { index: 'my-index', params: { filters: 'brand:adidas' }, ordering: 'userDefined' },\n },\n position: 0,\n length: 3,\n },\n ],\n },\n },\n },\n },\n});"
6262
},
6363
"saveRules": {
64-
"default": "const response = await client.saveRules({\n compositionID: 'foo',\n rules: {\n requests: [\n {\n action: 'upsert',\n body: {\n objectID: '123',\n conditions: [{ pattern: 'a' }],\n consequence: { behavior: { injection: { main: { source: { search: { index: '<YOUR_INDEX_NAME>' } } } } } },\n },\n },\n ],\n },\n});"
64+
"saveRules": "const response = await client.saveRules({\n compositionID: 'rule-with-exernal-source',\n rules: {\n requests: [\n {\n action: 'upsert',\n body: {\n objectID: 'rule-with-exernal-source',\n description: 'my description',\n tags: ['tag1', 'tag2'],\n enabled: true,\n validity: [{ from: 1704063600, until: 1704083600 }],\n conditions: [\n { anchoring: 'contains', pattern: 'harry' },\n { anchoring: 'contains', pattern: 'potter' },\n ],\n consequence: {\n behavior: {\n injection: {\n main: { source: { search: { index: 'my-index', params: { filters: 'brand:adidas' } } } },\n injectedItems: [\n {\n key: 'injectedItem',\n source: {\n external: { index: 'my-index', params: { filters: 'brand:adidas' }, ordering: 'userDefined' },\n },\n position: 0,\n length: 3,\n },\n ],\n },\n },\n },\n },\n },\n ],\n },\n});"
6565
},
6666
"search": {
67-
"search": "const response = await client.search({\n compositionID: 'foo',\n requestBody: {\n params: {\n query: 'batman',\n injectedItems: {\n injectedItem1: {\n items: [{ objectID: 'my-object-1' }, { objectID: 'my-object-2', metadata: { 'my-key': 'my-value' } }],\n },\n },\n },\n },\n});"
67+
"search": "const response = await client.search({\n compositionID: 'foo',\n requestBody: {\n params: {\n query: 'batman',\n injectedItems: {\n injectedItem1: {\n items: [\n { objectID: 'my-object-1' },\n {\n objectID: 'my-object-2',\n metadata: {\n 'my-string': 'string',\n 'my-bool': true,\n 'my-number': 42,\n 'my-object': { 'sub-key': 'sub-value' },\n 'my-array': [1, 2, 3],\n 'my-empty-object': {},\n },\n },\n ],\n },\n },\n },\n },\n});"
6868
},
6969
"searchCompositionRules": {
7070
"default": "const response = await client.searchCompositionRules({\n compositionID: 'foo',\n searchCompositionRulesParams: { query: 'batman' },\n});"

docs/bundled/composition-full.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4028,6 +4028,16 @@
40284028
"items": {
40294029
"$ref": "#/components/schemas/timeRange"
40304030
}
4031+
},
4032+
"tags": {
4033+
"type": "array",
4034+
"description": "A list of tags.",
4035+
"items": {
4036+
"type": "string"
4037+
},
4038+
"example": [
4039+
"conditional"
4040+
]
40314041
}
40324042
},
40334043
"required": [

0 commit comments

Comments
 (0)