File tree Expand file tree Collapse file tree 6 files changed +46
-11
lines changed
playground/javascript/node
templates/javascript/clients Expand file tree Collapse file tree 6 files changed +46
-11
lines changed Original file line number Diff line number Diff line change @@ -7,17 +7,27 @@ dotenv.config({ path: '../../.env' });
7
7
const appId = process . env . ALGOLIA_APPLICATION_ID || '**** APP_ID *****' ;
8
8
const apiKey = process . env . ALGOLIA_SEARCH_KEY || '**** SEARCH_API_KEY *****' ;
9
9
10
- const searchIndex = process . env . SEARCH_INDEX || 'test_index' ;
10
+ const indexName = process . env . SEARCH_INDEX || 'test_index' ;
11
11
const searchQuery = process . env . SEARCH_QUERY || 'test_query' ;
12
12
13
13
// Init client with appId and apiKey
14
14
const client = searchClient ( appId , apiKey ) ;
15
15
16
16
client . addAlgoliaAgent ( 'Node playground' , '0.0.1' ) ;
17
17
18
+ type TObject = {
19
+ name : string ;
20
+ } ;
21
+
18
22
async function testSearch ( ) {
19
23
try {
20
- const res = await client . search < { name : string } > ( { requests : [ { indexName : searchIndex , query : searchQuery } ] } ) ;
24
+ const res = await client . search < TObject > ( {
25
+ requests : [ { indexName, query : searchQuery } ] ,
26
+ } ) ;
27
+
28
+ await client . browse ( { indexName } ) ;
29
+
30
+ await client . searchSingleIndex ( { indexName, searchParams : { } } ) ;
21
31
22
32
console . log ( `[OK]` , res . results [ 0 ] . hits ! [ 0 ] . name ) ;
23
33
} catch ( e : any ) {
Original file line number Diff line number Diff line change
1
+ { {! possible data types of a parameter } }
2
+ { {#isEnum} }
3
+ { {classname} }{ {{nameInCamelCase} }}{ {#isArray} }[]{ {/isArray} }
4
+ { {/isEnum} }
5
+ { {^isEnum} }
6
+ { {#x-propagated-generic} }
7
+ { {> client/model/types/dataTypeGeneric} }
8
+ { {/x-propagated-generic} }
9
+ { {^x-propagated-generic} }
10
+ { {#x-has-child-generic} }
11
+ { {> client/model/types/dataTypeGeneric} }
12
+ { {/x-has-child-generic} }
13
+ { {^x-has-child-generic} }
14
+ { {{dataType} }}
15
+ { {/x-has-child-generic} }
16
+ { {/x-propagated-generic} }
17
+ { {#isNullable} }
18
+ | null
19
+ { {/isNullable} }
20
+ { {/isEnum} }
Original file line number Diff line number Diff line change
1
+ { {#complexType} }{ {{.} }}<T >{ {/complexType} }{ {^complexType} }T{ {/complexType} }{ {#isArray} }[]{ {/isArray} }
Original file line number Diff line number Diff line change
1
+ { {! parameter that is generic and have a default value } }
2
+ { {#vendorExtensions.x-has-child-generic} }
3
+ <T = Record <string, any >>
4
+ { {/vendorExtensions.x-has-child-generic} }
5
+ { {#vendorExtensions.x-is-generic} }
6
+ <T = Record <string, any >>
7
+ { {/vendorExtensions.x-is-generic} }
Original file line number Diff line number Diff line change
1
+ { {! Parameter that is generic and propagates it to its child } }
2
+ { {#vendorExtensions.x-has-child-generic} }<T >{ {/vendorExtensions.x-has-child-generic} }
Original file line number Diff line number Diff line change @@ -11,25 +11,20 @@ import { {{classname}} } from '{{filename}}';
11
11
/**
12
12
* { {{description} }}
13
13
*/{ {/description} }
14
- export type { {classname} }{ {#vendorExtensions.x-has-child-generic} }<T >{ {/vendorExtensions.x-has-child-generic} } = { {#composedSchemas.oneOf} }{ {{dataType} }}{ {#vendorExtensions.x-has-child-generic} }<T >{ {/vendorExtensions.x-has-child-generic} } { {^-last} }|{ {/-last} } { {/composedSchemas.oneOf} }
15
- { {#composedSchemas.allOf} }{ {{dataType} }}{ {#vendorExtensions.x-has-child-generic} }<T >{ {/vendorExtensions.x-has-child-generic} } { {^-last} }& { {/-last} } { {/composedSchemas.allOf} };
14
+ export type { {classname} }{ {> client/model/types/isGeneric} } = { {#composedSchemas.oneOf} }{ {{dataType} }}{ {> client/model/types/propagateGeneric} } { {^-last} }|{ {/-last} } { {/composedSchemas.oneOf} }{ {#composedSchemas.allOf} }{ {{dataType} }}{ {> client/model/types/propagateGeneric} } { {^-last} }& { {/-last} } { {/composedSchemas.allOf} };
16
15
{ {/interfaces.size} }{ {^interfaces.size} }
17
16
{ {#description} }
18
17
/**
19
18
* { {{description} }}
20
19
*/{ {/description} }{ {^isEnum} }
21
- export type { {classname} }{ {#vendorExtensions.x-is-generic } }< T > { {/vendorExtensions.x-is-generic } } { {#vendorExtensions.x-has-child-generic } }< T > { {/vendorExtensions.x-has-child-generic } } = { {^vendorExtensions.x-is-generic} }{ {#parent} }{ {{.} }} & { {/parent} }{ {/vendorExtensions.x-is-generic} }{ {#vendorExtensions.x-is-generic} }T & { {/vendorExtensions.x-is-generic} } {
20
+ export type { {classname} }{ {> client/model/types/isGeneric } } = { {^vendorExtensions.x-is-generic} }{ {#parent} }{ {{.} }} & { {/parent} }{ {/vendorExtensions.x-is-generic} }{ {#vendorExtensions.x-is-generic} }T & { {/vendorExtensions.x-is-generic} } {
22
21
{{#vendorExtensions} }
23
22
{ {#vars} }{ {#description} }
24
23
/**
25
24
* { {{description} }}
26
25
*/{ {/description} }
27
- { {name} }{ {^required} }?{ {/required} }: { {#isEnum} }{ {classname} }{ {{nameInCamelCase} }}{ {#isArray} }[]{ {/isArray} }{ {/isEnum} }
28
- { {^isEnum} }{ {#x-propagated-generic} }{ {{complexType} }}<T >{ {#isArray} }[]{ {/isArray} }{ {/x-propagated-generic} }
29
- { {^x-propagated-generic} }
30
- { {#x-has-child-generic} }{ {{complexType} }}<T >{ {#isArray} }[]{ {/isArray} }{ {/x-has-child-generic} }
31
- { {^x-has-child-generic} }{ {{dataType} }}{ {/x-has-child-generic} }
32
- { {/x-propagated-generic} }{ {#isNullable} } | null{ {/isNullable} }{ {/isEnum} };{ {/vars} }
26
+ { {name} }{ {^required} }?{ {/required} }: { {> client/model/types/dataType} } ;
27
+ { {/vars} }
33
28
} { {#x-is-SearchForHitsOptions} } & { facet?: never; maxFacetHits?: never; facetQuery?: never } ; { {/x-is-SearchForHitsOptions} }
34
29
{ {/vendorExtensions} }
35
30
{ {/isEnum} }
You can’t perform that action at this time.
0 commit comments