mm-share-lib 0.0.8 → 0.0.9

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.
Files changed (87) hide show
  1. package/dist/src/lib/index.d.ts +0 -1
  2. package/dist/src/lib/index.js +0 -1
  3. package/dist/src/lib/index.js.map +1 -1
  4. package/dist/src/lib/search-engine/index.d.ts +1 -1
  5. package/dist/src/lib/search-engine/index.js +1 -1
  6. package/dist/src/lib/search-engine/index.js.map +1 -1
  7. package/dist/src/lib/search-engine/typesense/metadata/schema.metadata.d.ts +5 -4
  8. package/dist/src/lib/search-engine/typesense/metadata/typesense.metadata-registry.d.ts +1 -1
  9. package/dist/src/lib/search-engine/typesense/metadata/typesense.metadata-registry.js.map +1 -1
  10. package/dist/src/lib/search-engine/typesense/typesense.module.test.js.map +1 -1
  11. package/dist/tsconfig.build.tsbuildinfo +1 -1
  12. package/package.json +1 -1
  13. package/src/lib/search-engine/index.ts +1 -1
  14. package/src/lib/search-engine/typesense/metadata/index.ts +2 -2
  15. package/src/lib/search-engine/typesense/metadata/schema.metadata.ts +18 -13
  16. package/src/lib/search-engine/typesense/metadata/typesense.metadata-registry.ts +28 -28
  17. package/src/lib/search-engine/typesense/service/index.ts +1 -1
  18. package/src/lib/search-engine/typesense/typesense-module.interface.ts +36 -36
  19. package/src/lib/search-engine/typesense/typesense.constants.ts +1 -1
  20. package/src/lib/search-engine/typesense/typesense.module.test.ts +92 -94
  21. package/src/lib/search-engine/typesense/typesense.module.ts +76 -76
  22. package/src/lib/search-engine/typesense/typesense.providers.ts +42 -42
  23. package/dist/src/lib/search-engine/schema/generic.schema.d.ts +0 -2
  24. package/dist/src/lib/search-engine/schema/generic.schema.js +0 -7
  25. package/dist/src/lib/search-engine/schema/generic.schema.js.map +0 -1
  26. package/dist/src/lib/search-engine/schema/index.d.ts +0 -1
  27. package/dist/src/lib/search-engine/schema/index.js +0 -18
  28. package/dist/src/lib/search-engine/schema/index.js.map +0 -1
  29. package/dist/src/lib/typesense/client/index.d.ts +0 -1
  30. package/dist/src/lib/typesense/client/index.js +0 -6
  31. package/dist/src/lib/typesense/client/index.js.map +0 -1
  32. package/dist/src/lib/typesense/collection/index.d.ts +0 -1
  33. package/dist/src/lib/typesense/collection/index.js +0 -18
  34. package/dist/src/lib/typesense/collection/index.js.map +0 -1
  35. package/dist/src/lib/typesense/collection/typesense-colletctions.creator.d.ts +0 -10
  36. package/dist/src/lib/typesense/collection/typesense-colletctions.creator.js +0 -42
  37. package/dist/src/lib/typesense/collection/typesense-colletctions.creator.js.map +0 -1
  38. package/dist/src/lib/typesense/decorator/field.decorator.d.ts +0 -9
  39. package/dist/src/lib/typesense/decorator/field.decorator.js +0 -15
  40. package/dist/src/lib/typesense/decorator/field.decorator.js.map +0 -1
  41. package/dist/src/lib/typesense/decorator/index.d.ts +0 -2
  42. package/dist/src/lib/typesense/decorator/index.js +0 -19
  43. package/dist/src/lib/typesense/decorator/index.js.map +0 -1
  44. package/dist/src/lib/typesense/decorator/schema.decorator.d.ts +0 -7
  45. package/dist/src/lib/typesense/decorator/schema.decorator.js +0 -16
  46. package/dist/src/lib/typesense/decorator/schema.decorator.js.map +0 -1
  47. package/dist/src/lib/typesense/document/base.document.d.ts +0 -3
  48. package/dist/src/lib/typesense/document/base.document.js +0 -7
  49. package/dist/src/lib/typesense/document/base.document.js.map +0 -1
  50. package/dist/src/lib/typesense/document/index.d.ts +0 -1
  51. package/dist/src/lib/typesense/document/index.js +0 -18
  52. package/dist/src/lib/typesense/document/index.js.map +0 -1
  53. package/dist/src/lib/typesense/index.d.ts +0 -4
  54. package/dist/src/lib/typesense/index.js +0 -21
  55. package/dist/src/lib/typesense/index.js.map +0 -1
  56. package/dist/src/lib/typesense/metadata/index.d.ts +0 -4
  57. package/dist/src/lib/typesense/metadata/index.js +0 -21
  58. package/dist/src/lib/typesense/metadata/index.js.map +0 -1
  59. package/dist/src/lib/typesense/metadata/schema.metadata.d.ts +0 -19
  60. package/dist/src/lib/typesense/metadata/schema.metadata.js +0 -3
  61. package/dist/src/lib/typesense/metadata/schema.metadata.js.map +0 -1
  62. package/dist/src/lib/typesense/metadata/typesense.metadata-accessor.d.ts +0 -7
  63. package/dist/src/lib/typesense/metadata/typesense.metadata-accessor.js +0 -47
  64. package/dist/src/lib/typesense/metadata/typesense.metadata-accessor.js.map +0 -1
  65. package/dist/src/lib/typesense/metadata/typesense.metadata-explorer.d.ts +0 -14
  66. package/dist/src/lib/typesense/metadata/typesense.metadata-explorer.js +0 -50
  67. package/dist/src/lib/typesense/metadata/typesense.metadata-explorer.js.map +0 -1
  68. package/dist/src/lib/typesense/metadata/typesense.metadata-registry.d.ts +0 -10
  69. package/dist/src/lib/typesense/metadata/typesense.metadata-registry.js +0 -33
  70. package/dist/src/lib/typesense/metadata/typesense.metadata-registry.js.map +0 -1
  71. package/dist/src/lib/typesense/module/index.d.ts +0 -4
  72. package/dist/src/lib/typesense/module/index.js +0 -21
  73. package/dist/src/lib/typesense/module/index.js.map +0 -1
  74. package/dist/src/lib/typesense/module/interface.module.d.ts +0 -27
  75. package/dist/src/lib/typesense/module/interface.module.js +0 -3
  76. package/dist/src/lib/typesense/module/interface.module.js.map +0 -1
  77. package/dist/src/lib/typesense/module/typesense.constant.d.ts +0 -1
  78. package/dist/src/lib/typesense/module/typesense.constant.js +0 -5
  79. package/dist/src/lib/typesense/module/typesense.constant.js.map +0 -1
  80. package/dist/src/lib/typesense/module/typesense.module.d.ts +0 -8
  81. package/dist/src/lib/typesense/module/typesense.module.js +0 -74
  82. package/dist/src/lib/typesense/module/typesense.module.js.map +0 -1
  83. package/dist/src/lib/typesense/module/typesense.provider.d.ts +0 -5
  84. package/dist/src/lib/typesense/module/typesense.provider.js +0 -48
  85. package/dist/src/lib/typesense/module/typesense.provider.js.map +0 -1
  86. package/src/lib/search-engine/schema/generic.schema.ts +0 -1
  87. package/src/lib/search-engine/schema/index.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm-share-lib",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Share the generic service, entity, dto.",
5
5
  "author": "Mesa SOT",
6
6
  "license": "MIT",
@@ -1 +1 @@
1
- export * from './typesense';
1
+ export * from './typesense';
@@ -1,2 +1,2 @@
1
- export * from './schema.metadata';
2
- export * from './typesense.metadata-registry';
1
+ export * from './schema.metadata';
2
+ export * from './typesense.metadata-registry';
@@ -1,13 +1,18 @@
1
- export interface SchemaField {
2
- name: string;
3
- type: string;
4
- facet?: boolean;
5
- index?: boolean;
6
- optional?: boolean;
7
- }
8
-
9
- export interface Schema {
10
- name: string;
11
- defaultSortingField: string;
12
- fields: Array<SchemaField>;
13
- }
1
+ import {
2
+ CollectionSchema,
3
+ CollectionFieldSchema,
4
+ } from 'typesense/lib/Typesense/Collection';
5
+
6
+ export interface SchemaField extends CollectionFieldSchema {
7
+ name: string;
8
+ facet?: boolean;
9
+ index?: boolean;
10
+ optional?: boolean;
11
+ sort?: boolean;
12
+ }
13
+
14
+ export interface Schema extends CollectionSchema {
15
+ name: string;
16
+ defaultSortingField: string;
17
+ fields: SchemaField[];
18
+ }
@@ -1,28 +1,28 @@
1
- import { Injectable, Logger } from '@nestjs/common'
2
-
3
- import { Schema } from './schema.metadata'
4
-
5
- type Constructor = new (...args: any[]) => Record<string, unknown> // {}
6
-
7
- @Injectable()
8
- export class TypesenseMetadataRegistry {
9
- private logger = new Logger(TypesenseMetadataRegistry.name)
10
-
11
- private schemas: Map<Constructor, Schema> = new Map()
12
-
13
- addSchema(target: Constructor, schema: Schema) {
14
- if (this.schemas.has(target)) {
15
- this.logger.warn(`Schema ${target} already exists`)
16
- }
17
-
18
- this.schemas.set(target, schema)
19
- }
20
-
21
- getSchemaByTarget(target: Constructor) {
22
- return this.schemas.get(target)
23
- }
24
-
25
- getTargets() {
26
- return this.schemas.keys()
27
- }
28
- }
1
+ import { Injectable, Logger } from '@nestjs/common';
2
+
3
+ import { Schema } from './schema.metadata';
4
+
5
+ type Constructor = new (...args: unknown[]) => Record<string, unknown>;
6
+
7
+ @Injectable()
8
+ export class TypesenseMetadataRegistry {
9
+ private logger = new Logger(TypesenseMetadataRegistry.name);
10
+
11
+ private schemas: Map<Constructor, Schema> = new Map();
12
+
13
+ addSchema(target: Constructor, schema: Schema) {
14
+ if (this.schemas.has(target)) {
15
+ this.logger.warn(`Schema ${target} already exists`);
16
+ }
17
+
18
+ this.schemas.set(target, schema);
19
+ }
20
+
21
+ getSchemaByTarget(target: Constructor) {
22
+ return this.schemas.get(target);
23
+ }
24
+
25
+ getTargets() {
26
+ return this.schemas.keys();
27
+ }
28
+ }
@@ -1 +1 @@
1
- export * from './client.service';
1
+ export * from './client.service';
@@ -1,36 +1,36 @@
1
- import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
2
- import { LogLevelDesc } from 'loglevel';
3
-
4
- export interface TypesenseNodeOptions {
5
- host: string;
6
- port: number;
7
- protocol: string;
8
- path?: string;
9
- url?: string;
10
- }
11
-
12
- export interface TypesenseModuleOptions {
13
- nodes?: Array<TypesenseNodeOptions>;
14
- numRetries?: number;
15
- apiKey?: string;
16
- connectionTimeoutSeconds?: number;
17
- retryIntervalSeconds?: number;
18
- healthcheckIntervalSeconds?: number;
19
- logLevel?: LogLevelDesc;
20
- }
21
-
22
- export interface TypesenseOptionsFactory {
23
- createTypesenseOptions():
24
- | Promise<TypesenseModuleOptions>
25
- | TypesenseModuleOptions;
26
- }
27
-
28
- export interface TypesenseModuleAsyncOptions
29
- extends Pick<ModuleMetadata, 'imports'> {
30
- useExisting?: Type<TypesenseOptionsFactory>;
31
- useClass?: Type<TypesenseOptionsFactory>;
32
- useFactory?: (
33
- ...args: any[]
34
- ) => Promise<TypesenseModuleOptions> | TypesenseModuleOptions;
35
- inject?: any[];
36
- }
1
+ import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
2
+ import { LogLevelDesc } from 'loglevel';
3
+
4
+ export interface TypesenseNodeOptions {
5
+ host: string;
6
+ port: number;
7
+ protocol: string;
8
+ path?: string;
9
+ url?: string;
10
+ }
11
+
12
+ export interface TypesenseModuleOptions {
13
+ nodes?: Array<TypesenseNodeOptions>;
14
+ numRetries?: number;
15
+ apiKey?: string;
16
+ connectionTimeoutSeconds?: number;
17
+ retryIntervalSeconds?: number;
18
+ healthcheckIntervalSeconds?: number;
19
+ logLevel?: LogLevelDesc;
20
+ }
21
+
22
+ export interface TypesenseOptionsFactory {
23
+ createTypesenseOptions():
24
+ | Promise<TypesenseModuleOptions>
25
+ | TypesenseModuleOptions;
26
+ }
27
+
28
+ export interface TypesenseModuleAsyncOptions
29
+ extends Pick<ModuleMetadata, 'imports'> {
30
+ useExisting?: Type<TypesenseOptionsFactory>;
31
+ useClass?: Type<TypesenseOptionsFactory>;
32
+ useFactory?: (
33
+ ...args: any[]
34
+ ) => Promise<TypesenseModuleOptions> | TypesenseModuleOptions;
35
+ inject?: any[];
36
+ }
@@ -1 +1 @@
1
- export const TYPESENSE_MODULE_OPTIONS = 'TYPESENSE_MODULE_OPTIONS';
1
+ export const TYPESENSE_MODULE_OPTIONS = 'TYPESENSE_MODULE_OPTIONS';
@@ -1,94 +1,92 @@
1
- /* eslint-disable max-classes-per-file */
2
-
3
- import { Module } from '@nestjs/common'
4
- import { Test } from '@nestjs/testing'
5
-
6
- import { TypesenseModuleOptions } from './typesense-module.interface'
7
- import { TYPESENSE_MODULE_OPTIONS } from './typesense.constants'
8
- import { TypesenseModule } from './typesense.module'
9
-
10
- describe('typesense', () => {
11
- describe('module', () => {
12
- let module
13
-
14
- afterEach(async () => {
15
- await module.close()
16
- })
17
-
18
- it(`register`, async () => {
19
- module = await Test.createTestingModule({
20
- imports: [
21
- TypesenseModule.register({
22
- apiKey: 'test',
23
- }),
24
- ],
25
- }).compile()
26
-
27
- expect(module.get(TYPESENSE_MODULE_OPTIONS)).toBeDefined()
28
- })
29
-
30
- it(`register async use factory`, async () => {
31
- module = await Test.createTestingModule({
32
- imports: [
33
- TypesenseModule.registerAsync({
34
- useFactory: () => ({
35
- apiKey: 'test',
36
- }),
37
- }),
38
- ],
39
- }).compile()
40
-
41
- expect(module.get(TYPESENSE_MODULE_OPTIONS)).toBeDefined()
42
- })
43
-
44
- it(`register async use class`, async () => {
45
- class TestTypesenseModuleOptions {
46
- createTypesenseOptions(): TypesenseModuleOptions {
47
- return {
48
- apiKey: 'test',
49
- }
50
- }
51
- }
52
-
53
- module = await Test.createTestingModule({
54
- imports: [
55
- TypesenseModule.registerAsync({
56
- useClass: TestTypesenseModuleOptions,
57
- }),
58
- ],
59
- }).compile()
60
-
61
- expect(module.get(TYPESENSE_MODULE_OPTIONS)).toBeDefined()
62
- })
63
-
64
- it(`register async use exists`, async () => {
65
- class TestTypesenseModuleOptions {
66
- createTypesenseOptions(): TypesenseModuleOptions {
67
- return {
68
- apiKey: 'test',
69
- }
70
- }
71
- }
72
-
73
- @Module({})
74
- class TestTypesenseModule {}
75
-
76
- module = await Test.createTestingModule({
77
- imports: [
78
- TypesenseModule.registerAsync({
79
- imports: [
80
- {
81
- module: TestTypesenseModule,
82
- providers: [TestTypesenseModuleOptions],
83
- exports: [TestTypesenseModuleOptions],
84
- },
85
- ],
86
- useExisting: TestTypesenseModuleOptions,
87
- }),
88
- ],
89
- }).compile()
90
-
91
- expect(module.get(TYPESENSE_MODULE_OPTIONS)).toBeDefined()
92
- })
93
- })
94
- })
1
+ import { Module } from '@nestjs/common';
2
+ import { Test } from '@nestjs/testing';
3
+
4
+ import { TypesenseModuleOptions } from './typesense-module.interface';
5
+ import { TYPESENSE_MODULE_OPTIONS } from './typesense.constants';
6
+ import { TypesenseModule } from './typesense.module';
7
+
8
+ describe('typesense', () => {
9
+ describe('module', () => {
10
+ let module;
11
+
12
+ afterEach(async () => {
13
+ await module.close();
14
+ });
15
+
16
+ it(`register`, async () => {
17
+ module = await Test.createTestingModule({
18
+ imports: [
19
+ TypesenseModule.register({
20
+ apiKey: 'test',
21
+ }),
22
+ ],
23
+ }).compile();
24
+
25
+ expect(module.get(TYPESENSE_MODULE_OPTIONS)).toBeDefined();
26
+ });
27
+
28
+ it(`register async use factory`, async () => {
29
+ module = await Test.createTestingModule({
30
+ imports: [
31
+ TypesenseModule.registerAsync({
32
+ useFactory: () => ({
33
+ apiKey: 'test',
34
+ }),
35
+ }),
36
+ ],
37
+ }).compile();
38
+
39
+ expect(module.get(TYPESENSE_MODULE_OPTIONS)).toBeDefined();
40
+ });
41
+
42
+ it(`register async use class`, async () => {
43
+ class TestTypesenseModuleOptions {
44
+ createTypesenseOptions(): TypesenseModuleOptions {
45
+ return {
46
+ apiKey: 'test',
47
+ };
48
+ }
49
+ }
50
+
51
+ module = await Test.createTestingModule({
52
+ imports: [
53
+ TypesenseModule.registerAsync({
54
+ useClass: TestTypesenseModuleOptions,
55
+ }),
56
+ ],
57
+ }).compile();
58
+
59
+ expect(module.get(TYPESENSE_MODULE_OPTIONS)).toBeDefined();
60
+ });
61
+
62
+ it(`register async use exists`, async () => {
63
+ class TestTypesenseModuleOptions {
64
+ createTypesenseOptions(): TypesenseModuleOptions {
65
+ return {
66
+ apiKey: 'test',
67
+ };
68
+ }
69
+ }
70
+
71
+ @Module({})
72
+ class TestTypesenseModule {}
73
+
74
+ module = await Test.createTestingModule({
75
+ imports: [
76
+ TypesenseModule.registerAsync({
77
+ imports: [
78
+ {
79
+ module: TestTypesenseModule,
80
+ providers: [TestTypesenseModuleOptions],
81
+ exports: [TestTypesenseModuleOptions],
82
+ },
83
+ ],
84
+ useExisting: TestTypesenseModuleOptions,
85
+ }),
86
+ ],
87
+ }).compile();
88
+
89
+ expect(module.get(TYPESENSE_MODULE_OPTIONS)).toBeDefined();
90
+ });
91
+ });
92
+ });
@@ -1,76 +1,76 @@
1
- import { DynamicModule, Module, Provider } from '@nestjs/common';
2
- import { DiscoveryModule } from '@nestjs/core';
3
- import {
4
- TypesenseModuleAsyncOptions,
5
- TypesenseOptionsFactory,
6
- TypesenseModuleOptions,
7
- } from './typesense-module.interface';
8
- import { TYPESENSE_MODULE_OPTIONS } from './typesense.constants';
9
- import {
10
- createTypesenseExportsProvider,
11
- createTypesenseOptionsProvider,
12
- } from './typesense.providers';
13
-
14
- @Module({
15
- imports: [DiscoveryModule],
16
- })
17
- export class TypesenseModule {
18
- static register(options: TypesenseModuleOptions = {}): DynamicModule {
19
- const optionsProviders = createTypesenseOptionsProvider(options);
20
- const exportsProviders = createTypesenseExportsProvider();
21
-
22
- return {
23
- global: true,
24
- module: TypesenseModule,
25
- providers: [...optionsProviders, ...exportsProviders],
26
- exports: exportsProviders,
27
- };
28
- }
29
-
30
- static registerAsync(options: TypesenseModuleAsyncOptions): DynamicModule {
31
- const exportsProviders = createTypesenseExportsProvider();
32
-
33
- return {
34
- global: true,
35
- module: TypesenseModule,
36
- imports: options.imports || [],
37
- providers: [...this.createAsyncProviders(options), ...exportsProviders],
38
- exports: exportsProviders,
39
- };
40
- }
41
-
42
- private static createAsyncProviders(
43
- options: TypesenseModuleAsyncOptions,
44
- ): Provider[] {
45
- if (options.useExisting || options.useFactory) {
46
- return [this.createAsyncOptionsProvider(options)];
47
- }
48
-
49
- return [
50
- this.createAsyncOptionsProvider(options),
51
- {
52
- provide: options?.useClass,
53
- useClass: options?.useClass,
54
- },
55
- ];
56
- }
57
-
58
- private static createAsyncOptionsProvider(
59
- options: TypesenseModuleAsyncOptions,
60
- ): Provider {
61
- if (options.useFactory) {
62
- return {
63
- provide: TYPESENSE_MODULE_OPTIONS,
64
- useFactory: options.useFactory,
65
- inject: options.inject || [],
66
- };
67
- }
68
-
69
- return {
70
- provide: TYPESENSE_MODULE_OPTIONS,
71
- useFactory: (optionsFactory: TypesenseOptionsFactory) =>
72
- optionsFactory.createTypesenseOptions(),
73
- inject: [options?.useExisting || options?.useClass],
74
- };
75
- }
76
- }
1
+ import { DynamicModule, Module, Provider } from '@nestjs/common';
2
+ import { DiscoveryModule } from '@nestjs/core';
3
+ import {
4
+ TypesenseModuleAsyncOptions,
5
+ TypesenseOptionsFactory,
6
+ TypesenseModuleOptions,
7
+ } from './typesense-module.interface';
8
+ import { TYPESENSE_MODULE_OPTIONS } from './typesense.constants';
9
+ import {
10
+ createTypesenseExportsProvider,
11
+ createTypesenseOptionsProvider,
12
+ } from './typesense.providers';
13
+
14
+ @Module({
15
+ imports: [DiscoveryModule],
16
+ })
17
+ export class TypesenseModule {
18
+ static register(options: TypesenseModuleOptions = {}): DynamicModule {
19
+ const optionsProviders = createTypesenseOptionsProvider(options);
20
+ const exportsProviders = createTypesenseExportsProvider();
21
+
22
+ return {
23
+ global: true,
24
+ module: TypesenseModule,
25
+ providers: [...optionsProviders, ...exportsProviders],
26
+ exports: exportsProviders,
27
+ };
28
+ }
29
+
30
+ static registerAsync(options: TypesenseModuleAsyncOptions): DynamicModule {
31
+ const exportsProviders = createTypesenseExportsProvider();
32
+
33
+ return {
34
+ global: true,
35
+ module: TypesenseModule,
36
+ imports: options.imports || [],
37
+ providers: [...this.createAsyncProviders(options), ...exportsProviders],
38
+ exports: exportsProviders,
39
+ };
40
+ }
41
+
42
+ private static createAsyncProviders(
43
+ options: TypesenseModuleAsyncOptions,
44
+ ): Provider[] {
45
+ if (options.useExisting || options.useFactory) {
46
+ return [this.createAsyncOptionsProvider(options)];
47
+ }
48
+
49
+ return [
50
+ this.createAsyncOptionsProvider(options),
51
+ {
52
+ provide: options?.useClass,
53
+ useClass: options?.useClass,
54
+ },
55
+ ];
56
+ }
57
+
58
+ private static createAsyncOptionsProvider(
59
+ options: TypesenseModuleAsyncOptions,
60
+ ): Provider {
61
+ if (options.useFactory) {
62
+ return {
63
+ provide: TYPESENSE_MODULE_OPTIONS,
64
+ useFactory: options.useFactory,
65
+ inject: options.inject || [],
66
+ };
67
+ }
68
+
69
+ return {
70
+ provide: TYPESENSE_MODULE_OPTIONS,
71
+ useFactory: (optionsFactory: TypesenseOptionsFactory) =>
72
+ optionsFactory.createTypesenseOptions(),
73
+ inject: [options?.useExisting || options?.useClass],
74
+ };
75
+ }
76
+ }
@@ -1,42 +1,42 @@
1
- import { Provider } from '@nestjs/common';
2
- import { Client } from 'typesense';
3
- import { TypesenseMetadataRegistry } from './metadata';
4
- import { TypesenseModuleOptions } from './typesense-module.interface';
5
- import { TYPESENSE_MODULE_OPTIONS } from './typesense.constants';
6
-
7
- export const createTypesenseOptionsProvider = (
8
- options: TypesenseModuleOptions = {},
9
- ): Provider[] => [
10
- {
11
- provide: TYPESENSE_MODULE_OPTIONS,
12
- useValue: options,
13
- },
14
- ];
15
-
16
- export const createTypesenseExportsProvider = (): Provider[] => [
17
- TypesenseMetadataRegistry,
18
- {
19
- provide: Client,
20
- useFactory: (options: TypesenseModuleOptions) =>
21
- new Client({
22
- nodes: options.nodes || [
23
- {
24
- host:
25
- process.env.TYPESENSE_HOST ||
26
- process.env.NODE_ENV === 'production'
27
- ? 'ts.typesense.svc.cluster.local'
28
- : 'localhost',
29
- port: 8108,
30
- protocol: 'http',
31
- },
32
- ],
33
- numRetries: options.numRetries || 10,
34
- apiKey: options.apiKey || process.env.TYPESENSE_API_KEY,
35
- connectionTimeoutSeconds: options.connectionTimeoutSeconds || 10,
36
- retryIntervalSeconds: options.retryIntervalSeconds || 0.1,
37
- healthcheckIntervalSeconds: options.healthcheckIntervalSeconds || 2,
38
- logLevel: options.logLevel || 'info',
39
- }),
40
- inject: [TYPESENSE_MODULE_OPTIONS],
41
- },
42
- ];
1
+ import { Provider } from '@nestjs/common';
2
+ import { Client } from 'typesense';
3
+ import { TypesenseMetadataRegistry } from './metadata';
4
+ import { TypesenseModuleOptions } from './typesense-module.interface';
5
+ import { TYPESENSE_MODULE_OPTIONS } from './typesense.constants';
6
+
7
+ export const createTypesenseOptionsProvider = (
8
+ options: TypesenseModuleOptions = {},
9
+ ): Provider[] => [
10
+ {
11
+ provide: TYPESENSE_MODULE_OPTIONS,
12
+ useValue: options,
13
+ },
14
+ ];
15
+
16
+ export const createTypesenseExportsProvider = (): Provider[] => [
17
+ TypesenseMetadataRegistry,
18
+ {
19
+ provide: Client,
20
+ useFactory: (options: TypesenseModuleOptions) =>
21
+ new Client({
22
+ nodes: options.nodes || [
23
+ {
24
+ host:
25
+ process.env.TYPESENSE_HOST ||
26
+ process.env.NODE_ENV === 'production'
27
+ ? 'ts.typesense.svc.cluster.local'
28
+ : 'localhost',
29
+ port: 8108,
30
+ protocol: 'http',
31
+ },
32
+ ],
33
+ numRetries: options.numRetries || 10,
34
+ apiKey: options.apiKey || process.env.TYPESENSE_API_KEY,
35
+ connectionTimeoutSeconds: options.connectionTimeoutSeconds || 10,
36
+ retryIntervalSeconds: options.retryIntervalSeconds || 0.1,
37
+ healthcheckIntervalSeconds: options.healthcheckIntervalSeconds || 2,
38
+ logLevel: options.logLevel || 'info',
39
+ }),
40
+ inject: [TYPESENSE_MODULE_OPTIONS],
41
+ },
42
+ ];
@@ -1,2 +0,0 @@
1
- export declare class GenericSchema {
2
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenericSchema = void 0;
4
- class GenericSchema {
5
- }
6
- exports.GenericSchema = GenericSchema;
7
- //# sourceMappingURL=generic.schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generic.schema.js","sourceRoot":"","sources":["../../../../../src/lib/search-engine/schema/generic.schema.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;CAAG;AAA7B,sCAA6B"}
@@ -1 +0,0 @@
1
- export * from './generic.schema';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./generic.schema"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/search-engine/schema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}