@mavenmachines/event-handler-lib 1.5.0-rc.9 → 1.5.1-rc.0

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 (167) hide show
  1. package/README.md +1 -368
  2. package/dist/config/default.d.ts +0 -16
  3. package/dist/config/default.js +0 -16
  4. package/dist/config/default.js.map +1 -1
  5. package/dist/package.json +1 -3
  6. package/dist/src/app.module.d.ts +2 -2
  7. package/dist/src/app.module.js +2 -2
  8. package/dist/src/app.module.js.map +1 -1
  9. package/dist/src/clients/openSearch/errors.d.ts +0 -2
  10. package/dist/src/clients/openSearch/errors.js +1 -4
  11. package/dist/src/clients/openSearch/errors.js.map +1 -1
  12. package/dist/src/clients/openSearch/mappings.d.ts +2 -6
  13. package/dist/src/clients/openSearch/mappings.js +2 -25
  14. package/dist/src/clients/openSearch/mappings.js.map +1 -1
  15. package/dist/src/clients/openSearch/openSearchClient.d.ts +3 -22
  16. package/dist/src/clients/openSearch/openSearchClient.js +60 -267
  17. package/dist/src/clients/openSearch/openSearchClient.js.map +1 -1
  18. package/dist/src/configs/inversifyConfig.d.ts +0 -2
  19. package/dist/src/configs/inversifyConfig.js +3 -30
  20. package/dist/src/configs/inversifyConfig.js.map +1 -1
  21. package/dist/src/dependencies/dependencyTypes.d.ts +0 -1
  22. package/dist/src/dependencies/dependencyTypes.js +0 -1
  23. package/dist/src/dependencies/dependencyTypes.js.map +1 -1
  24. package/dist/src/{handlers/commandHandlers → eventHandlers}/baseCommandHandler.d.ts +11 -11
  25. package/dist/src/{handlers/commandHandlers → eventHandlers}/baseCommandHandler.js +7 -7
  26. package/dist/src/eventHandlers/baseCommandHandler.js.map +1 -0
  27. package/dist/src/eventHandlers/baseEventHandler.d.ts +39 -0
  28. package/dist/src/{handlers/eventHandlers → eventHandlers}/baseEventHandler.js +3 -3
  29. package/dist/src/eventHandlers/baseEventHandler.js.map +1 -0
  30. package/dist/src/{handlers → eventHandlers}/baseHandler.d.ts +8 -7
  31. package/dist/src/{handlers → eventHandlers}/baseHandler.js +5 -2
  32. package/dist/src/eventHandlers/baseHandler.js.map +1 -0
  33. package/dist/src/{handlers/commandHandlers → eventHandlers}/commandHandlingModule.d.ts +3 -3
  34. package/dist/src/{handlers/commandHandlers → eventHandlers}/commandHandlingModule.js +3 -3
  35. package/dist/src/eventHandlers/commandHandlingModule.js.map +1 -0
  36. package/dist/src/{handlers/eventHandlers → eventHandlers}/eventHandlingModule.d.ts +7 -7
  37. package/dist/src/{handlers/eventHandlers → eventHandlers}/eventHandlingModule.js +9 -8
  38. package/dist/src/eventHandlers/eventHandlingModule.js.map +1 -0
  39. package/dist/src/{handlers/eventHandlers → eventHandlers}/syncFirestoreEvents.d.ts +4 -4
  40. package/dist/src/{handlers/eventHandlers → eventHandlers}/syncFirestoreEvents.js +3 -3
  41. package/dist/src/eventHandlers/syncFirestoreEvents.js.map +1 -0
  42. package/dist/src/exports/clients.d.ts +0 -1
  43. package/dist/src/exports/clients.js +1 -3
  44. package/dist/src/exports/clients.js.map +1 -1
  45. package/dist/src/exports/services.d.ts +2 -2
  46. package/dist/src/exports/services.js +2 -2
  47. package/dist/src/exports/services.js.map +1 -1
  48. package/dist/src/exports/sourcing.d.ts +3 -4
  49. package/dist/src/exports/sourcing.js +3 -18
  50. package/dist/src/exports/sourcing.js.map +1 -1
  51. package/dist/src/exports/utils.d.ts +0 -2
  52. package/dist/src/exports/utils.js +0 -2
  53. package/dist/src/exports/utils.js.map +1 -1
  54. package/dist/src/helpers/classConverter.d.ts +1 -0
  55. package/dist/src/helpers/classConverter.js +18 -0
  56. package/dist/src/helpers/classConverter.js.map +1 -1
  57. package/dist/src/helpers/dataStructure.helpers.d.ts +0 -2
  58. package/dist/src/helpers/dataStructure.helpers.js +0 -32
  59. package/dist/src/helpers/dataStructure.helpers.js.map +1 -1
  60. package/dist/src/initializers/logger.service.d.ts +0 -4
  61. package/dist/src/initializers/logger.service.js +0 -14
  62. package/dist/src/initializers/logger.service.js.map +1 -1
  63. package/dist/src/initializers/queue-manager.service.d.ts +1 -1
  64. package/dist/src/initializers/queue-manager.service.js +0 -1
  65. package/dist/src/initializers/queue-manager.service.js.map +1 -1
  66. package/dist/src/repositories/projectionRepository.d.ts +8 -4
  67. package/dist/src/repositories/projectionRepository.js +30 -13
  68. package/dist/src/repositories/projectionRepository.js.map +1 -1
  69. package/dist/src/rpc/rpcModule.js +1 -4
  70. package/dist/src/rpc/rpcModule.js.map +1 -1
  71. package/dist/src/testUtils/testDependencies.d.ts +2 -1
  72. package/dist/src/testUtils/testDependencies.js +13 -10
  73. package/dist/src/testUtils/testDependencies.js.map +1 -1
  74. package/dist/test/testImplementations/testCommandHandler.d.ts +1 -1
  75. package/dist/test/testImplementations/testCommandHandler.js +1 -1
  76. package/dist/test/testImplementations/testCommandHandler.js.map +1 -1
  77. package/dist/test/testImplementations/testEventHandler.d.ts +10 -3
  78. package/dist/test/testImplementations/testEventHandler.js +31 -4
  79. package/dist/test/testImplementations/testEventHandler.js.map +1 -1
  80. package/dist/test/testImplementations/testFirestoreEventSync.d.ts +1 -1
  81. package/dist/test/testImplementations/testFirestoreEventSync.js +1 -1
  82. package/dist/test/testImplementations/testFirestoreEventSync.js.map +1 -1
  83. package/dist/test/tests/clients/opensearch.client.spec.js +72 -1
  84. package/dist/test/tests/clients/opensearch.client.spec.js.map +1 -1
  85. package/dist/test/tests/common.js +5 -9
  86. package/dist/test/tests/common.js.map +1 -1
  87. package/dist/test/tests/eventHandlers/baseEventHandler.spec.js +19 -6
  88. package/dist/test/tests/eventHandlers/baseEventHandler.spec.js.map +1 -1
  89. package/dist/test/tests/eventHandlers/firestoreEventSyncHandler.spec.js +16 -6
  90. package/dist/test/tests/eventHandlers/firestoreEventSyncHandler.spec.js.map +1 -1
  91. package/dist/test/tests/helpers/classConverter.spec.js +21 -0
  92. package/dist/test/tests/helpers/classConverter.spec.js.map +1 -1
  93. package/dist/test/tests/helpers/syncOpensearch.spec.js +43 -0
  94. package/dist/test/tests/helpers/syncOpensearch.spec.js.map +1 -1
  95. package/dist/test/tests/repositories/projectionRepository.spec.js +4 -3
  96. package/dist/test/tests/repositories/projectionRepository.spec.js.map +1 -1
  97. package/package.json +2 -4
  98. package/dist/src/handlers/baseHandler.js.map +0 -1
  99. package/dist/src/handlers/commandHandlers/baseCommandHandler.js.map +0 -1
  100. package/dist/src/handlers/commandHandlers/commandHandlingModule.js.map +0 -1
  101. package/dist/src/handlers/crud/baseHandlers.d.ts +0 -26
  102. package/dist/src/handlers/crud/baseHandlers.js +0 -123
  103. package/dist/src/handlers/crud/baseHandlers.js.map +0 -1
  104. package/dist/src/handlers/crud/createProjectionHandler.d.ts +0 -10
  105. package/dist/src/handlers/crud/createProjectionHandler.js +0 -73
  106. package/dist/src/handlers/crud/createProjectionHandler.js.map +0 -1
  107. package/dist/src/handlers/crud/createUpdateProjectionHandler.d.ts +0 -10
  108. package/dist/src/handlers/crud/createUpdateProjectionHandler.js +0 -65
  109. package/dist/src/handlers/crud/createUpdateProjectionHandler.js.map +0 -1
  110. package/dist/src/handlers/crud/decorators.d.ts +0 -9
  111. package/dist/src/handlers/crud/decorators.js +0 -11
  112. package/dist/src/handlers/crud/decorators.js.map +0 -1
  113. package/dist/src/handlers/crud/deleteProjectionHandler.d.ts +0 -9
  114. package/dist/src/handlers/crud/deleteProjectionHandler.js +0 -43
  115. package/dist/src/handlers/crud/deleteProjectionHandler.js.map +0 -1
  116. package/dist/src/handlers/crud/getProjectionHandler.d.ts +0 -12
  117. package/dist/src/handlers/crud/getProjectionHandler.js +0 -58
  118. package/dist/src/handlers/crud/getProjectionHandler.js.map +0 -1
  119. package/dist/src/handlers/crud/getProjectionsHandler.d.ts +0 -11
  120. package/dist/src/handlers/crud/getProjectionsHandler.js +0 -76
  121. package/dist/src/handlers/crud/getProjectionsHandler.js.map +0 -1
  122. package/dist/src/handlers/crud/helpers.d.ts +0 -36
  123. package/dist/src/handlers/crud/helpers.js +0 -232
  124. package/dist/src/handlers/crud/helpers.js.map +0 -1
  125. package/dist/src/handlers/crud/index.d.ts +0 -33
  126. package/dist/src/handlers/crud/index.js +0 -108
  127. package/dist/src/handlers/crud/index.js.map +0 -1
  128. package/dist/src/handlers/crud/schemaHandler.d.ts +0 -23
  129. package/dist/src/handlers/crud/schemaHandler.js +0 -127
  130. package/dist/src/handlers/crud/schemaHandler.js.map +0 -1
  131. package/dist/src/handlers/crud/searchProjectionsHandler.d.ts +0 -10
  132. package/dist/src/handlers/crud/searchProjectionsHandler.js +0 -226
  133. package/dist/src/handlers/crud/searchProjectionsHandler.js.map +0 -1
  134. package/dist/src/handlers/crud/types.d.ts +0 -49
  135. package/dist/src/handlers/crud/types.js +0 -42
  136. package/dist/src/handlers/crud/types.js.map +0 -1
  137. package/dist/src/handlers/eventHandlers/baseEventHandler.d.ts +0 -39
  138. package/dist/src/handlers/eventHandlers/baseEventHandler.js.map +0 -1
  139. package/dist/src/handlers/eventHandlers/eventHandlingModule.js.map +0 -1
  140. package/dist/src/handlers/eventHandlers/syncFirestoreEvents.js.map +0 -1
  141. package/dist/src/helpers/string.helpers.d.ts +0 -3
  142. package/dist/src/helpers/string.helpers.js +0 -24
  143. package/dist/src/helpers/string.helpers.js.map +0 -1
  144. package/dist/src/helpers/typeManipulation/classValidation.d.ts +0 -7
  145. package/dist/src/helpers/typeManipulation/classValidation.js +0 -30
  146. package/dist/src/helpers/typeManipulation/classValidation.js.map +0 -1
  147. package/dist/src/helpers/typeManipulation/decorators.d.ts +0 -16
  148. package/dist/src/helpers/typeManipulation/decorators.js +0 -144
  149. package/dist/src/helpers/typeManipulation/decorators.js.map +0 -1
  150. package/dist/src/helpers/typeManipulation/dynamicClasses.d.ts +0 -7
  151. package/dist/src/helpers/typeManipulation/dynamicClasses.js +0 -54
  152. package/dist/src/helpers/typeManipulation/dynamicClasses.js.map +0 -1
  153. package/dist/src/helpers/typeManipulation/index.d.ts +0 -3
  154. package/dist/src/helpers/typeManipulation/index.js +0 -20
  155. package/dist/src/helpers/typeManipulation/index.js.map +0 -1
  156. package/dist/src/testUtils/mocks/openSearch.client.mock.d.ts +0 -102
  157. package/dist/src/testUtils/mocks/openSearch.client.mock.js +0 -405
  158. package/dist/src/testUtils/mocks/openSearch.client.mock.js.map +0 -1
  159. package/dist/test/testImplementations/testCrud.d.ts +0 -43
  160. package/dist/test/testImplementations/testCrud.js +0 -213
  161. package/dist/test/testImplementations/testCrud.js.map +0 -1
  162. package/dist/test/tests/eventHandlers/crudHandlers.spec.d.ts +0 -1
  163. package/dist/test/tests/eventHandlers/crudHandlers.spec.js +0 -627
  164. package/dist/test/tests/eventHandlers/crudHandlers.spec.js.map +0 -1
  165. package/dist/test/tests/helpers/decorators.spec.d.ts +0 -1
  166. package/dist/test/tests/helpers/decorators.spec.js +0 -109
  167. package/dist/test/tests/helpers/decorators.spec.js.map +0 -1
package/README.md CHANGED
@@ -382,7 +382,7 @@ If the document ID should not be the same as the Projection's `entityId`, you
382
382
  can overload `getDocumentId(EventSourcedProjection<PayloadT>): string` to get
383
383
  the correct subpath for the Firestore document.
384
384
 
385
- #### Partial Document Update
385
+ #### Parital Document Update
386
386
 
387
387
  If you need to make partial modifications to Firestore documents, you can use
388
388
  the `UpdateFirestoreProjection` plugin, which has an additional property,
@@ -464,373 +464,6 @@ Note that `name` can either be the instance of your class, or any string that
464
464
  you want to call it. It is only used for logging purposes in the event of a
465
465
  failure.
466
466
 
467
- ## Implementing CRUD Interfaces
468
-
469
- There are many instances where one may want to expose a Projection type to a CRUD
470
- (Create-Retrieve-Update-Delete) Interface via RPCs. Many entities are the
471
- accumulation of events, but many also begin their lives externally, needing to be
472
- created or updated via a command, and retrieved via ID or searched.
473
-
474
- ### Annotating a Projection for CRUD support.
475
-
476
- In addition to supporting `class-validator` and `class-transformer` decorators,
477
- `event-handler-lib` provides CRUD-specific decorators to allow a developer control
478
- over the behavior of their Projection in a CRUD app.
479
-
480
- Firstly, all supported projections must have the `@ProjectionType` decorator, so
481
- that the framework knows where the representation lives in Dynamo and Opensearch.
482
-
483
- To allow Update calls, fields can be marked with `@IsEditable()`. If a field is
484
- not marked with `@IsEditable()`, Update requests that provide values for that field
485
- will fail.
486
-
487
- To allow Search functionality, the OpenSearch indexes must be properly configured.
488
- Adding an `@IsSearchable()` decorator will tell the service to ensure that the
489
- Mapping is properly set for those fields. In the event of a conflict with an existing
490
- mapping, the service will fail to start.
491
-
492
- Caveats:
493
-
494
- - All `Projection` types must have an `id: string` field representing their `entityId`
495
- - Only `number` and `string` indexes are supported for now, but more will come
496
- - While the binding keys are defined by convention, the service must still provide
497
- them to `Pump` via the `bindingKeys.config.json` file.
498
- - This is the expected location for binding keys at Maven, and we do not want
499
- to hide important diagnostic information in case of emergencies.
500
-
501
- ### Example
502
-
503
- The `@ProjectionType()`, decorator will guide the names of the RabbitMQ binding keys
504
- for a given Projection. Given the following examples:
505
-
506
- ```
507
- @ProjectionType("salesProduct")
508
- export class SalesProductProjection {
509
- @IsString()
510
- id: string;
511
-
512
- @IsString()
513
- @IsSearchable()
514
- productCode: string;
515
-
516
- @IsString()
517
- @IsSearchable()
518
- upc: string
519
-
520
- @IsOptional()
521
- @IsString()
522
- @IsSearchable()
523
- @IsEditable()
524
- description: string;
525
-
526
- @ValidateNested()
527
- @Type(() => MetadataFields)
528
- metadata: MetadataFields;
529
- }
530
-
531
- export class MetadataFields {
532
- @IsOptional()
533
- @IsString()
534
- @IsSearchable()
535
- @IsEditable()
536
- owner?: string;
537
-
538
- @IsNumber()
539
- @IsSearchable()
540
- internalId: number
541
- }
542
- ```
543
-
544
- #### Create Request: `createSalesProduct`
545
-
546
- The `create` requests are similar to standard RPC requests. The `id` field is not
547
- supported, and a `companyId` must be provided.
548
-
549
- ```
550
- {
551
- companyId: 1234,
552
- productCode: "Product-ABC",
553
- upc: "00000-2334342",
554
- metadata: {
555
- owner: "this is optional",
556
- internalId: 12359
557
- }
558
- }
559
- ```
560
-
561
- The response is simply `{id: UUID}`.
562
-
563
- ##### What if I need to modify or additionally validate the creation payload?
564
-
565
- Some Create operations require additional validation or fetching data from
566
- other entities. For example, `RouteTemplates` take a `stopTemplate` and create
567
- a nested `templateStop` by interpolating values of the request into the `stopTemplate`. To faciliate this, a nested object can be validated with
568
- `CreationRequestType(TargetClass)` decorators, and they will be converted during
569
- the request.
570
-
571
- Important caveats:
572
-
573
- 1. Typescript's type system cannot analyze decorators, so creation request types
574
- will not have accurate interfaces in the server-side.
575
- 2. THIS IS NOT FOR SIDE EFFECTS. You should not create other entities, send messages,
576
- or perform any other side-effects in the `createEntity` method. This should
577
- just be used to fetch other entities for their values, or validate their
578
- existence.
579
-
580
- ```
581
- // IMPORTANT: The inversify @inject() decorator cannot be applied to method
582
- // parameters. The Inject decorator from event-handler-lib must be used.
583
- import { Inject, ProjectionType, ProjectionRepository } from "@mavenmachines/event-handler-lib";
584
-
585
- class CreateTemplateStopRequest {
586
- @IsNumber()
587
- companyId!: number;
588
-
589
- @IsString()
590
- stopTemplateId!: string;
591
-
592
- @IsNumber()
593
- companyLocationId!: number
594
-
595
- async createEntity(
596
- @Inject(ProjectionRepository) projectionRepository: ProjectionRepository,
597
- @Inject(CompanyLocationsServiceClient) companyLocationsServiceClient: CompanyLocationsServiceClient
598
- ): Promise<TemplateStop> {
599
- const stopTemplateProjection = await projectionRepository.loadItem({
600
- companyId: this.companyId,
601
- projectionType: "stopTemplate",
602
- entityId: this.stopTemplateId,
603
- });
604
- const companyLocation = await companyLocationsClient.getCompanyLocationById(this.companyid, this.companyLocationId);
605
- return {
606
- ...stopTemplateProjection.payload,
607
- companyLocationId: number;
608
- latLon: {
609
- lat: companyLocation.lat,
610
- lon: companyLocation.lon
611
- }
612
- }
613
- }
614
- }
615
-
616
- @ProjectionType("StopTemplate") {
617
- /* ... fields for template */
618
- }
619
-
620
- class LatLon {
621
- @IsNumber()
622
- lat!: number;
623
-
624
- @IsNumber()
625
- lon!: number;
626
- }
627
-
628
- @CreationRequest(CreateTemplateStopRequest)
629
- class TemplateStop extends StopTemplate {
630
- @IsNumber()
631
- companyLocationId!: number;
632
-
633
- @ValidateNested()
634
- @Type(() => LatLon)
635
- latLon!: LatLon;
636
- }
637
-
638
- @ProjectionType("RouteTemplate") {
639
- /* ... */
640
-
641
- @ValidateNested({ each: true })
642
- @IsArray()
643
- @Type(() => TemplateStop)
644
- templateStops: TemplateStop[];
645
- }
646
- ```
647
-
648
- In the Create request, the CRUD interface will convert the Type validation from
649
- a `TemplateStop` to a `CreateTemplateStopRequest`, call the `createEntity` method
650
- with the provided dependencies (marked with `@Inject`), and replace the request
651
- payload with the returned value when serializing the projection to DynamoDB.
652
-
653
- ### Update Request: `updateSalesProduct`
654
-
655
- The `update` requests are also similar, except all fields are optional to both
656
- TypeScript and `class-validator`. Unfortunately, it is impossible to remove
657
- non-editable fields from the request type at compile-time, but server-side validation
658
- will ensure they are not modified:
659
-
660
- ```
661
- {
662
- companyId: 1234,
663
- id: "XXXX-XXXXXX-XXXXX-XXXXX-XXXX",
664
- metadata: {
665
- owner: "new owner",
666
- }
667
- }
668
- ```
669
-
670
- The response is `{ modified: boolean }`, indicating whether or not the request
671
- resulted in a modification to the projection.
672
-
673
- ### Delete Request: `deleteSalesProduct`
674
-
675
- The `delete` requests simply require a `companyId` and `id`, as the `projectionType`
676
- is inherently tied to the endpoint.
677
-
678
- ```
679
- {
680
- companyId: 1234,
681
- id: "XXXX-XXXXXX-XXXXX-XXXXX-XXXX",
682
- }
683
- ```
684
-
685
- The response is empty on success, and will fail with `"errorKey": "NOT_FOUND"`
686
- if the entity does not exist.
687
-
688
- ### Get Request: `getSalesProduct`
689
-
690
- The `get` request also takes a `companyId` and `id`;
691
-
692
- ```
693
- {
694
- companyId: 1234,
695
- id: "XXXX-XXXXXX-XXXXX-XXXXX-XXXX",
696
- }
697
- ```
698
-
699
- The response will contain the projections `payload` in its `projection` field if
700
- it is found. If the entity does not exist, the `projection` field will be `undefined`:
701
-
702
- ```
703
- {
704
- projection: {
705
- id: "XXXX-XXXXXX-XXXXX-XXXXX-XXXX",
706
- productCode: "Product-ABC",
707
- upc: "0000-12312342432",
708
- metadata: {
709
- owner: "this is optional",
710
- internalId: 12359
711
- }
712
- }
713
- }
714
- ```
715
-
716
- ### Get Multiple Request: `getSalesProducts`.
717
-
718
- The framework also exposes a multi-get endpoint, where you can provide several `ids`
719
- and retrieve them all.
720
-
721
- ```
722
- {
723
- companyId: 1234,
724
- ids: ["UUID1", "UUID2", "UUID3"]
725
- }
726
- ```
727
-
728
- The response now has two array fields, `projections` holding the projections that
729
- were found, and `missing` holding the `id`s of those that were not:
730
-
731
- ```
732
- {
733
- projections: [
734
- {
735
- id: "UUID2",
736
- ...
737
- }
738
- ],
739
- missing: ["UUID1", "UUID3"]
740
- }
741
- ```
742
-
743
- If all or none of the projections are found, the arrays will still exist in the
744
- response, they will simply be empty.
745
-
746
- ### Searching Projections: `searchSalesProducts`
747
-
748
- Finally, the framework provides search functionality. Any field marked
749
- `@IsSearchable()` will have an appropriate index created. These fields can be
750
- used in the query for filtering or sorting.
751
-
752
- For example, to find fields with a matching `metadata.owner`, sorted by descending
753
- `upc`, you can provide:
754
-
755
- ```
756
- {
757
- companyId: 1234,
758
- query: {
759
- metadata: {
760
- owner: "Owner Name"
761
- }
762
- },
763
- sort: {
764
- upc: "desc"
765
- }
766
- }
767
- ```
768
-
769
- By default, the searches are limited to 10 results per query, and will return
770
- a `continuationToken`.
771
-
772
- The optional fields are:
773
-
774
- 1. `limit` to determine how many results are returned
775
- 2. `page` the 1-indexed page number. If provided, the results will start at `limit * (page - 1)`
776
- 3. The returned `continuationToken` can be sent back in another search to continue
777
- where you left off.
778
-
779
- Response:
780
-
781
- ```
782
- {
783
- results: [{
784
- id: "XXXXX",
785
- productCode: "etc",
786
- }, { ... }],
787
- continuationToken: "XXXX"
788
- }
789
- ```
790
-
791
- When paging through search results, the `continuationToken` will be valid for
792
- ten minutes, after which it will expire and queries will fail. During that time,
793
- OpenSearch maintains a point-in-time snapshot of the data, so the results will
794
- be consistent _at the time of the query_.
795
-
796
- ### Binding a CRUD handler for a Projection
797
-
798
- If you want all of the functionality, the `CrudHandlerFactory` can set it all
799
- up for you with on line of code.
800
-
801
- ```
802
- CrudHandlerFactory.bind(appContainer, SalesProductProjection)
803
- ```
804
-
805
- If you need to request an explicit subset, a list of `actions` can be provided,
806
- followed by an optional `multi: boolean = true` to determine if the multi-Get endpoint
807
- is provided.
808
-
809
- ### Client-Side
810
-
811
- The `event-handler-lib` provides utility types for clients:
812
-
813
- - `CreateRequest<T>`/`CreatedResponse`
814
- - `UpdateRequest<T>`/`ModifiedResponse`
815
- - `DeleteProjectionRequest`/`DeleteProjectionResponse`
816
- - `GetProjectionRequest`/`GetProjectionResponse<T>`
817
- - `GetProjectionsRequest`/`GetProjectionsResponse<T>`
818
- - `SearchRequest<T>`/`SearchResults<T>`
819
-
820
- If you need to create the types with validation includes, the
821
- `CrudCommandFactory` provides `createRequest`, `updateRequest`, and `searchRequest`
822
- members, all of which take the `ClassConstructor<ProjectionType>`.
823
-
824
- These are not required for `Get` and `Delete`, as `class-validator` and
825
- `class-transformer` manipulation are not required.
826
-
827
- #### Schema inference endpoints
828
-
829
- Additionally, the event handler lib will bind "Schema" endpoints that will
830
- expose the `class-validator`/`class-transformer`-annotated class types for
831
- CRUD requests for a given projection. They will be named `<action><projectionName>Schema`, and by convention should be bound to their
832
- associated actions' binding key, plus `.schema`.
833
-
834
467
  ## Testing
835
468
 
836
469
  ### Stubbing EventHandler services
@@ -10,22 +10,6 @@ declare const _default: {
10
10
  disableLogging: boolean;
11
11
  bindingKeys: {
12
12
  testRpcRequest: string;
13
- createExampleProjection: string;
14
- createExampleProjectionSchema: string;
15
- updateExampleProjection: string;
16
- updateExampleProjectionSchema: string;
17
- deleteExampleProjection: string;
18
- deleteExampleProjectionSchema: string;
19
- getExampleProjection: string;
20
- getExampleProjectionSchema: string;
21
- getExampleProjections: string;
22
- getExampleProjectionsSchema: string;
23
- searchExampleProjections: string;
24
- searchExampleProjectionsSchema: string;
25
- createCreationRequestProjectionSchema: string;
26
- createCreationRequestProjection: string;
27
- createCreationRequestProjectionEnvelope: string;
28
- createCreationRequestProjectionEnvelopeSchema: string;
29
13
  };
30
14
  routingKey: {};
31
15
  };
@@ -54,22 +54,6 @@ exports.default = {
54
54
  disableLogging: process.env.rabbitmq_disablelogging === "true",
55
55
  bindingKeys: {
56
56
  testRpcRequest: "#.eventHandlerLib.test.rpcRequest",
57
- createExampleProjection: "#.eventHandlerLib.test.exampleProjection.create",
58
- createExampleProjectionSchema: "#.eventHandlerLib.test.exampleProjection.create.schema",
59
- updateExampleProjection: "#.eventHandlerLib.test.exampleProjection.update",
60
- updateExampleProjectionSchema: "#.eventHandlerLib.test.exampleProjection.update.schema",
61
- deleteExampleProjection: "#.eventHandlerLib.test.exampleProjection.delete",
62
- deleteExampleProjectionSchema: "#.eventHandlerLib.test.exampleProjection.delete.schema",
63
- getExampleProjection: "#.eventHandlerLib.test.exampleProjection.get",
64
- getExampleProjectionSchema: "#.eventHandlerLib.test.exampleProjection.get.schema",
65
- getExampleProjections: "#.eventHandlerLib.test.get.exampleProjections",
66
- getExampleProjectionsSchema: "#.eventHandlerLib.test.get.exampleProjections.schema",
67
- searchExampleProjections: "#.eventHandlerLib.test.search.exampleProjections",
68
- searchExampleProjectionsSchema: "#.eventHandlerLib.test.search.exampleProjections.schema",
69
- createCreationRequestProjectionSchema: "#.eventHandlerLib.test.creationRequestProjection.create.schema",
70
- createCreationRequestProjection: "#.eventHandlerLib.test.creationRequestProjection.create",
71
- createCreationRequestProjectionEnvelope: "#.eventHandlerLib.test.creationRequestProjectionEnvelope.create",
72
- createCreationRequestProjectionEnvelopeSchema: "#.eventHandlerLib.test.creationRequestProjectionEnvelope.create.schema",
73
57
  },
74
58
  routingKey: {},
75
59
  },
@@ -1 +1 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../../config/default.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAAuE;AACvE,+CAA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EAAE;QACV,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe;KACjE;IACD,kBAAkB,EAAlB,uCAAkB;CACnB,CAAC"}
package/dist/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "depcruise": "npx depcruise src test",
19
19
  "build": "npm run clean && tsc",
20
20
  "clean": "rm -rf ./dist",
21
- "test": "NODE_ENV=test mocha --config config/.mocharc.json",
21
+ "test": "NODE_ENV=test nyc mocha --config config/.mocharc.json",
22
22
  "format": "npx prettier --write \"*/**/*.ts\"",
23
23
  "lint-check": "npx eslint \"src/**/*.ts\"",
24
24
  "lint": "npx eslint \"src/**/*.ts\" --fix",
@@ -71,7 +71,6 @@
71
71
  "@mavenmachines/feature-flags-client": "^1.2.0",
72
72
  "@mavenmachines/prometheus-nodejs-client": "^1.0.2",
73
73
  "@mavenmachines/pump": "^1.5.4",
74
- "@nestjs/mapped-types": "^2.1.0",
75
74
  "@opensearch-project/opensearch": "^3.5.1",
76
75
  "amqplib": "^0.10.5",
77
76
  "async-mutex": "^0.5.0",
@@ -84,7 +83,6 @@
84
83
  "dotenv": "^16.4.7",
85
84
  "express": "^4.21.2",
86
85
  "firebase-admin": "^12.1.1",
87
- "haversine-distance": "^1.2.4",
88
86
  "inversify": "^6.0.2",
89
87
  "lodash": "^4.17.21",
90
88
  "lru-cache": "^11.0.2",
@@ -1,7 +1,7 @@
1
1
  import "reflect-metadata";
2
2
  import { LoggerService } from "./initializers/logger.service";
3
- import { EventHandlingModule } from "./handlers/eventHandlers/eventHandlingModule";
4
- import { CommandHandlingModule } from "./handlers/commandHandlers/commandHandlingModule";
3
+ import { EventHandlingModule } from "./eventHandlers/eventHandlingModule";
4
+ import { CommandHandlingModule } from "./eventHandlers/commandHandlingModule";
5
5
  import { RpcModule } from "./rpc/rpcModule";
6
6
  import { QueueManagerService } from "./initializers/queue-manager.service";
7
7
  export declare class AppModule {
@@ -16,8 +16,8 @@ exports.AppModule = void 0;
16
16
  require("reflect-metadata");
17
17
  const inversify_1 = require("inversify");
18
18
  const logger_service_1 = require("./initializers/logger.service");
19
- const eventHandlingModule_1 = require("./handlers/eventHandlers/eventHandlingModule");
20
- const commandHandlingModule_1 = require("./handlers/commandHandlers/commandHandlingModule");
19
+ const eventHandlingModule_1 = require("./eventHandlers/eventHandlingModule");
20
+ const commandHandlingModule_1 = require("./eventHandlers/commandHandlingModule");
21
21
  const rpcModule_1 = require("./rpc/rpcModule");
22
22
  const dependencyTypes_1 = require("./dependencies/dependencyTypes");
23
23
  const queue_manager_service_1 = require("./initializers/queue-manager.service");
@@ -1 +1 @@
1
- {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,yCAA+C;AAC/C,kEAAsE;AACtE,sFAAmF;AACnF,4FAAyF;AACzF,+CAA4C;AAC5C,oEAAuD;AACvD,gFAA2E;AAGpE,IAAM,SAAS,GAAf,MAAM,SAAS;IAGpB,YAC8C,WAAmB,EAE9C,YAAiC,EAE1C,mBAAwC,EAExC,qBAA4C,EAC7B,aAA4B,EACf,SAAoB;QARZ,gBAAW,GAAX,WAAW,CAAQ;QAE9C,iBAAY,GAAZ,YAAY,CAAqB;QAE1C,wBAAmB,GAAnB,mBAAmB,CAAqB;QAExC,0BAAqB,GAArB,qBAAqB,CAAuB;QAEhB,cAAS,GAAT,SAAS,CAAW;QAExD,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAgD;QACzD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,iBAAiB,CAAC,CAAC;QACvD,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAClC,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK;YAC9B,SAAS,EAAE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,CAAuB;QAEhB,cAAS,GAAT,SAAS,CAAW;QAExD,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAgD;QACzD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,iBAAiB,CAAC,CAAC;QACvD,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAClC,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK;YAC9B,SAAS,EAAE,KAAK,EAAE,SAAS;SAC5B,CAAC,CAAC;QACH,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAG1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,WAAW,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AA9BY,8BAAS;oBAAT,SAAS;IADrB,IAAA,sBAAU,GAAE;IAKR,WAAA,IAAA,kBAAM,EAAC,uBAAK,CAAC,WAAW,CAAC,CAAA;IACzB,WAAA,IAAA,kBAAM,EAAC,2CAAmB,CAAC,CAAA;IAE3B,WAAA,IAAA,kBAAM,EAAC,yCAAmB,CAAC,CAAA;IAE3B,WAAA,IAAA,kBAAM,EAAC,6CAAqB,CAAC,CAAA;IAE7B,WAAA,IAAA,kBAAM,EAAC,8BAAa,CAAC,CAAA;IACrB,WAAA,IAAA,kBAAM,EAAC,qBAAS,CAAC,CAAA;6CANa,2CAAmB;QAErB,yCAAmB;QAEjB,6CAAqB;QACd,8BAAa;QACJ,qBAAS;GAZ/C,SAAS,CA8BrB"}
@@ -1,7 +1,5 @@
1
1
  export declare class OpenSearchError extends Error {
2
2
  }
3
- export declare class ExpiredPointInTime extends OpenSearchError {
4
- }
5
3
  export declare class MappingError extends OpenSearchError {
6
4
  }
7
5
  export declare class MaxRecursionSanitizationReached extends MappingError {
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MaxRecursionSanitizationReached = exports.MappingError = exports.ExpiredPointInTime = exports.OpenSearchError = void 0;
3
+ exports.MaxRecursionSanitizationReached = exports.MappingError = exports.OpenSearchError = void 0;
4
4
  class OpenSearchError extends Error {
5
5
  }
6
6
  exports.OpenSearchError = OpenSearchError;
7
- class ExpiredPointInTime extends OpenSearchError {
8
- }
9
- exports.ExpiredPointInTime = ExpiredPointInTime;
10
7
  class MappingError extends OpenSearchError {
11
8
  }
12
9
  exports.MappingError = MappingError;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/clients/openSearch/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAgB,SAAQ,KAAK;CAAG;AAA7C,0CAA6C;AAC7C,MAAa,kBAAmB,SAAQ,eAAe;CAAG;AAA1D,gDAA0D;AAC1D,MAAa,YAAa,SAAQ,eAAe;CAAG;AAApD,oCAAoD;AACpD,MAAa,+BAAgC,SAAQ,YAAY;IAC/D,YACkB,KAAa,EACb,IAAY,EACZ,IAAyB,EACzB,aAA8B;QAE9C,KAAK,CAAC,iBAAiB,KAAK,qBAAqB,IAAI,EAAE,CAAC,CAAC;QALzC,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAqB;QACzB,kBAAa,GAAb,aAAa,CAAiB;IAGhD,CAAC;CACF;AATD,0EASC"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/clients/openSearch/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAgB,SAAQ,KAAK;CAAG;AAA7C,0CAA6C;AAC7C,MAAa,YAAa,SAAQ,eAAe;CAAG;AAApD,oCAAoD;AACpD,MAAa,+BAAgC,SAAQ,YAAY;IAC/D,YACkB,KAAa,EACb,IAAY,EACZ,IAAyB,EACzB,aAA8B;QAE9C,KAAK,CAAC,iBAAiB,KAAK,qBAAqB,IAAI,EAAE,CAAC,CAAC;QALzC,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAqB;QACzB,kBAAa,GAAb,aAAa,CAAiB;IAGhD,CAAC;CACF;AATD,0EASC"}
@@ -1,10 +1,6 @@
1
- import { BooleanProperty, DateProperty, DoubleNumberProperty, GeoPointProperty, KeywordProperty, Property, TextProperty, TypeMapping } from "@opensearch-project/opensearch/api/_types/_common.mapping";
2
- export declare const KEYWORD_MAPPING: KeywordProperty;
3
- export declare const NUM_MAPPING: DoubleNumberProperty;
1
+ import { BooleanProperty, DateProperty, LongNumberProperty, TextProperty, TypeMapping } from "@opensearch-project/opensearch/api/_types/_common.mapping";
2
+ export declare const NUM_MAPPING: LongNumberProperty;
4
3
  export declare const STRING_MAPPING: TextProperty;
5
4
  export declare const DATE_MAPPING: DateProperty;
6
5
  export declare const BOOLEAN_MAPPING: BooleanProperty;
7
- export declare const GEOPOINT_MAPPING: GeoPointProperty;
8
6
  export declare const DEFAULT_MAPPING: TypeMapping;
9
- export type FieldTypeNames = "string" | "number" | "id" | "boolean" | "geopoint";
10
- export declare function getTypeMapping(type: FieldTypeNames): Property;
@@ -1,12 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_MAPPING = exports.GEOPOINT_MAPPING = exports.BOOLEAN_MAPPING = exports.DATE_MAPPING = exports.STRING_MAPPING = exports.NUM_MAPPING = exports.KEYWORD_MAPPING = void 0;
4
- exports.getTypeMapping = getTypeMapping;
5
- exports.KEYWORD_MAPPING = {
6
- type: "keyword",
7
- };
3
+ exports.DEFAULT_MAPPING = exports.BOOLEAN_MAPPING = exports.DATE_MAPPING = exports.STRING_MAPPING = exports.NUM_MAPPING = void 0;
8
4
  exports.NUM_MAPPING = {
9
- type: "double",
5
+ type: "long",
10
6
  };
11
7
  exports.STRING_MAPPING = {
12
8
  fields: {
@@ -24,9 +20,6 @@ exports.DATE_MAPPING = {
24
20
  exports.BOOLEAN_MAPPING = {
25
21
  type: "boolean",
26
22
  };
27
- exports.GEOPOINT_MAPPING = {
28
- type: "geo_point",
29
- };
30
23
  exports.DEFAULT_MAPPING = {
31
24
  dynamic: "false",
32
25
  properties: {
@@ -58,20 +51,4 @@ exports.DEFAULT_MAPPING = {
58
51
  isDeleted: exports.BOOLEAN_MAPPING,
59
52
  },
60
53
  };
61
- function getTypeMapping(type) {
62
- switch (type) {
63
- case "string":
64
- return exports.STRING_MAPPING;
65
- case "number":
66
- return exports.NUM_MAPPING;
67
- case "id":
68
- return exports.KEYWORD_MAPPING;
69
- case "boolean":
70
- return exports.BOOLEAN_MAPPING;
71
- case "geopoint":
72
- return exports.GEOPOINT_MAPPING;
73
- default:
74
- throw new Error(`Unknown field type ${type}`);
75
- }
76
- }
77
54
  //# sourceMappingURL=mappings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mappings.js","sourceRoot":"","sources":["../../../../src/clients/openSearch/mappings.ts"],"names":[],"mappings":";;;AAkFA,wCAeC;AAtFY,QAAA,eAAe,GAAoB;IAC9C,IAAI,EAAE,SAAS;CAChB,CAAC;AAEW,QAAA,WAAW,GAAyB;IAC/C,IAAI,EAAE,QAAQ;CACf,CAAC;AAEW,QAAA,cAAc,GAAiB;IAC1C,MAAM,EAAE;QACN,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,GAAG;SAClB;KACF;IACD,IAAI,EAAE,MAAM;CACb,CAAC;AAEW,QAAA,YAAY,GAAiB;IACxC,IAAI,EAAE,MAAM;IAEZ,MAAM,EAAE,WAAW;CACpB,CAAC;AAEW,QAAA,eAAe,GAAoB;IAC9C,IAAI,EAAE,SAAS;CAChB,CAAC;AAEW,QAAA,gBAAgB,GAAqB;IAChD,IAAI,EAAE,WAAW;CAClB,CAAC;AAEW,QAAA,eAAe,GAAgB;IAC1C,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE;QACV,SAAS,EAAE,mBAAW;QACtB,iCAAiC,EAAE,sBAAc;QACjD,QAAQ,EAAE,sBAAc;QACxB,YAAY,EAAE;YACZ,IAAI,EAAE,aAAa;SACpB;QACD,OAAO,EAAE,sBAAc;QACvB,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE;gBACV,OAAO,EAAE,sBAAc;gBACvB,SAAS,EAAE,sBAAc;gBACzB,QAAQ,EAAE,sBAAc;aACzB;SACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE;gBACV,SAAS,EAAE,sBAAc;gBACzB,OAAO,EAAE,sBAAc;aACxB;SACF;QACD,oBAAoB,EAAE,oBAAY;QAClC,SAAS,EAAE,uBAAe;KAC3B;CACF,CAAC;AASF,SAAgB,cAAc,CAAC,IAAoB;IACjD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,sBAAc,CAAC;QACxB,KAAK,QAAQ;YACX,OAAO,mBAAW,CAAC;QACrB,KAAK,IAAI;YACP,OAAO,uBAAe,CAAC;QACzB,KAAK,SAAS;YACZ,OAAO,uBAAe,CAAC;QACzB,KAAK,UAAU;YACb,OAAO,wBAAgB,CAAC;QAC1B;YACE,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"mappings.js","sourceRoot":"","sources":["../../../../src/clients/openSearch/mappings.ts"],"names":[],"mappings":";;;AAQa,QAAA,WAAW,GAAuB;IAC7C,IAAI,EAAE,MAAM;CACb,CAAC;AAEW,QAAA,cAAc,GAAiB;IAC1C,MAAM,EAAE;QACN,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,GAAG;SAClB;KACF;IACD,IAAI,EAAE,MAAM;CACb,CAAC;AAEW,QAAA,YAAY,GAAiB;IACxC,IAAI,EAAE,MAAM;IAEZ,MAAM,EAAE,WAAW;CACpB,CAAC;AAEW,QAAA,eAAe,GAAoB;IAC9C,IAAI,EAAE,SAAS;CAChB,CAAC;AAEW,QAAA,eAAe,GAAgB;IAC1C,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE;QACV,SAAS,EAAE,mBAAW;QACtB,iCAAiC,EAAE,sBAAc;QACjD,QAAQ,EAAE,sBAAc;QACxB,YAAY,EAAE;YACZ,IAAI,EAAE,aAAa;SACpB;QACD,OAAO,EAAE,sBAAc;QACvB,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE;gBACV,OAAO,EAAE,sBAAc;gBACvB,SAAS,EAAE,sBAAc;gBACzB,QAAQ,EAAE,sBAAc;aACzB;SACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE;gBACV,SAAS,EAAE,sBAAc;gBACzB,OAAO,EAAE,sBAAc;aACxB;SACF;QACD,oBAAoB,EAAE,oBAAY;QAClC,SAAS,EAAE,uBAAe;KAC3B;CACF,CAAC"}
@@ -2,15 +2,10 @@ import { Client } from "@opensearch-project/opensearch";
2
2
  import { EventSourcedProjection } from "../../types/eventSourcedProjection.type";
3
3
  import { Logger, LoggerService } from "../../initializers/logger.service";
4
4
  import { DistributedLocking } from "../redisClient";
5
- import { FieldTypeNames } from "./mappings";
6
- import { Sort } from "@opensearch-project/opensearch/api/_types/_common";
7
- import { TypeMapping } from "@opensearch-project/opensearch/api/_types/_common.mapping";
8
- import { DeepSearchable } from "../../handlers/crud/types";
9
5
  declare class BaseOpenSearchClient {
10
6
  protected readonly client: Client;
11
7
  protected readonly distributedLocking: DistributedLocking;
12
8
  constructor(loggerService: LoggerService, client: Client, distributedLocking: DistributedLocking);
13
- get isFakeClient(): boolean;
14
9
  readonly isConnected: boolean;
15
10
  protected readonly logger: Logger;
16
11
  }
@@ -18,12 +13,13 @@ export type AddedIndexFields = {
18
13
  openSearchUpdateTime?: string;
19
14
  };
20
15
  export type ProjectionIndex<T extends Record<string, any> = Record<string, any>> = Pick<EventSourcedProjection<T>, "projectionType" | "entityId" | "companyId" | "payload" | "referenceIds" | "version" | "traceId"> & AddedIndexFields;
16
+ export declare const MAX_OPENSEARCH_SANTIZE_RECURSION = 20;
21
17
  export declare class OpenSearchClient extends BaseOpenSearchClient {
22
18
  private readonly indexCache;
23
- indexProjection<T extends Record<string, any>>(projection: EventSourcedProjection<T> | ProjectionIndex<T>): Promise<void>;
19
+ indexProjection<T extends Record<string, any>>(projection: EventSourcedProjection<T> | ProjectionIndex<T>, maxDepth?: number): Promise<void>;
20
+ private indexSanitizedProjection;
24
21
  private getIndexName;
25
22
  private getAliasName;
26
- private getWriteIndex;
27
23
  private createAliasedIndex;
28
24
  ensureIndex(projection: {
29
25
  projectionType: string;
@@ -44,26 +40,11 @@ export declare class OpenSearchClient extends BaseOpenSearchClient {
44
40
  projectionType: string;
45
41
  entityId: string;
46
42
  }): Promise<void>;
47
- getMapping(index: string): Promise<TypeMapping>;
48
- private ensureMapping;
49
- ensureMappings(projectionType: string, fields: Record<string, FieldTypeNames>): Promise<void>;
50
- private generateFieldQuery;
51
- private zeroContinuation;
52
- private parseContinuation;
53
- private toContinuation;
54
- private doSearch;
55
- searchProjections<T extends object>(companyId: number, projectionType: string, fields: DeepSearchable<T>, sort?: Record<string, Sort>, limit?: number, page?: number, continuationToken?: string, pointInTime?: boolean): Promise<{
56
- results: EventSourcedProjection<T>[];
57
- continuation?: string;
58
- }>;
59
43
  }
60
44
  export declare class OpensearchAdminClient extends BaseOpenSearchClient {
61
45
  getIndexes(): Promise<string[]>;
62
46
  removeIndex(index: string): Promise<void>;
63
- clearIndex(index: string): Promise<void>;
64
47
  cleanAliases(): Promise<void>;
65
48
  clean(): Promise<void>;
66
- clearIndexes(): Promise<void>;
67
- expirePointInTime(pit_id: string): Promise<void>;
68
49
  }
69
50
  export {};