|
52 | 52 | "listCompositions": "const response = await client.listCompositions();" |
53 | 53 | }, |
54 | 54 | "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});" |
56 | 56 | }, |
57 | 57 | "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});" |
59 | 59 | }, |
60 | 60 | "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});" |
62 | 62 | }, |
63 | 63 | "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});" |
65 | 65 | }, |
66 | 66 | "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});" |
68 | 68 | }, |
69 | 69 | "searchCompositionRules": { |
70 | 70 | "default": "const response = await client.searchCompositionRules({\n compositionID: 'foo',\n searchCompositionRulesParams: { query: 'batman' },\n});" |
|
0 commit comments