gunsmith-common 2.3.27 → 2.4.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.
@@ -1,9 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, Inject, Pipe, Directive, Input, Component, EventEmitter, Output, NgModule } from '@angular/core';
2
+ import { Injectable, Inject, InjectionToken, Optional, Pipe, Directive, Input, Component, EventEmitter, Output, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/common/http';
4
4
  import { of, switchMap as switchMap$1, EMPTY, forkJoin, Subject } from 'rxjs';
5
5
  import { switchMap } from 'rxjs/operators';
6
6
  import { DateTime } from 'luxon';
7
+ import { HubConnectionState, HubConnectionBuilder } from '@microsoft/signalr';
7
8
  import * as i1$1 from '@angular/forms';
8
9
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
9
10
  import * as i2 from '@angular/common';
@@ -2078,6 +2079,71 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
2078
2079
  args: ["env"]
2079
2080
  }] }]; } });
2080
2081
 
2082
+ /**
2083
+ * Supplies a bearer token (the Cognito ID token) for the SignalR hub connection.
2084
+ * Provided by the host app so this library stays decoupled from the auth provider.
2085
+ */
2086
+ const AI_ID_TOKEN_FACTORY = new InjectionToken('AI_ID_TOKEN_FACTORY');
2087
+ /**
2088
+ * REST + SignalR client for the GunSmith.AI service. REST auth is handled by the host app's
2089
+ * HTTP interceptor; the hub uses the injected token factory via accessTokenFactory.
2090
+ */
2091
+ class AiAssistantService {
2092
+ constructor(http, env, idTokenFactory) {
2093
+ this.http = http;
2094
+ this.env = env;
2095
+ this.idTokenFactory = idTokenFactory;
2096
+ this.token$ = new Subject();
2097
+ this.toolStarted$ = new Subject();
2098
+ this.citations$ = new Subject();
2099
+ this.completed$ = new Subject();
2100
+ this.streamError$ = new Subject();
2101
+ this.apiBase = this.env.aiBaseUrl;
2102
+ }
2103
+ get connectionId() {
2104
+ return this.hub ? this.hub.connectionId : null;
2105
+ }
2106
+ async connect() {
2107
+ if (this.hub && this.hub.state === HubConnectionState.Connected) {
2108
+ return;
2109
+ }
2110
+ const builder = new HubConnectionBuilder().withUrl(this.apiBase + 'api/ai-chat-hub', this.idTokenFactory ? { accessTokenFactory: this.idTokenFactory } : {});
2111
+ this.hub = builder.withAutomaticReconnect().build();
2112
+ this.hub.on('TokenReceived', (streamId, text) => this.token$.next({ streamId, text }));
2113
+ this.hub.on('ToolStarted', (streamId, toolName) => this.toolStarted$.next({ streamId, toolName }));
2114
+ this.hub.on('CitationsReceived', (streamId, citations) => this.citations$.next({ streamId, citations }));
2115
+ this.hub.on('MessageCompleted', (streamId, messageId) => this.completed$.next({ streamId, messageId }));
2116
+ this.hub.on('StreamError', (streamId, message) => this.streamError$.next({ streamId, message }));
2117
+ await this.hub.start();
2118
+ }
2119
+ createConversation() {
2120
+ return this.http.post(this.apiBase + 'api/ai/conversations', {});
2121
+ }
2122
+ getConversations() {
2123
+ return this.http.get(this.apiBase + 'api/ai/conversations');
2124
+ }
2125
+ getConversation(id) {
2126
+ return this.http.get(this.apiBase + 'api/ai/conversations/' + id);
2127
+ }
2128
+ sendMessage(id, content, connectionId) {
2129
+ return this.http.post(this.apiBase + 'api/ai/conversations/' + id + '/messages', { content, connectionId });
2130
+ }
2131
+ }
2132
+ AiAssistantService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: AiAssistantService, deps: [{ token: i1.HttpClient }, { token: 'env' }, { token: AI_ID_TOKEN_FACTORY, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
2133
+ AiAssistantService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: AiAssistantService, providedIn: 'root' });
2134
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: AiAssistantService, decorators: [{
2135
+ type: Injectable,
2136
+ args: [{ providedIn: 'root' }]
2137
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
2138
+ type: Inject,
2139
+ args: ['env']
2140
+ }] }, { type: undefined, decorators: [{
2141
+ type: Optional
2142
+ }, {
2143
+ type: Inject,
2144
+ args: [AI_ID_TOKEN_FACTORY]
2145
+ }] }]; } });
2146
+
2081
2147
  class PhonePipe {
2082
2148
  transform(value, args) {
2083
2149
  if (value && value.length >= 10) {
@@ -2405,5 +2471,5 @@ var NotificationType;
2405
2471
  * Generated bundle index. Do not edit.
2406
2472
  */
2407
2473
 
2408
- export { Address, BaseService, BillingInfo, BundleItem, ChangeOrderPackageDetail, ChangeOrderStatus, Coating, CoatingService, CoatingValue, CoatingValueService, Configuration, ConfigurationService, Customer, CustomerService, Dealer, DealerContact, DealerCoupon, DealerService, DisableControlDirective, EnumPipe, FileNamePipe, FileUploadService, FilterOptions, FinishDateHelperService, Firearm, FirearmMillingTypeService, FirearmOptic, FirearmOpticService, FirearmService, FirearmSightService, FormErrorMessageComponent, FrameMaterial, FrameMaterialPipe, GunCaliber, GunPart, GunPartOption, GunPartService, InventoryItem, InventoryService, JFile, Material, MaterialService, MillingDetail, MillingItem, MillingType, MillingTypeAddon, MillingTypeAddonOption, MillingTypeAddonService, MillingTypeService, ModalHeaderComponent, MountType, MountTypeService, NewLinePipe, NotificationBarComponent, NotificationModule, NotificationService, NotificationType, Optic, OpticService, OpticSight, OpticStatus, Package, PackageItem, PackageOptionalItem, PackageOptionalItemService, PackageService, PackageTotal, PackageVariation, PackageVariationOption, PackageVariationService, PhonePipe, Product, ProductService, ProjectType, PurchaseOrder, PurchaseOrderRefinishItem, PurchaseOrderService, PurchaseOrderStatus, QuickbooksService, RearSightPosition, RefinishCode, RefinishCodeService, RefinishDetail, ReportMillingItem, ReportRefinishItem, SharedModule, ShieldRMSOptions, Sight, SightMaterialService, SightMaterialType, SightService, SightType, SightTypeEnum, SightTypeService, SlideAddon, SlideAddonService, State, StateService, StatusHistoryService, Total, TotalItem, TotalsService, UserService, Vendor, VendorContact, VendorService, WaitlistAction, WaitlistCustomerService, WaitlistGun, WaitlistGunPackageDetail, WaitlistGunPhoto, WaitlistHistory, WaitlistItem, WaitlistProjectService, WaitlistService, WaitlistStatus, WorkChangeOrder, WorkHoliday, WorkHolidayService, WorkOrder, WorkOrderAction, WorkOrderBillingTransaction, WorkOrderDiscount, WorkOrderDiscountService, WorkOrderHistory, WorkOrderInventoryItem, WorkOrderListItem, WorkOrderNonInventoryItem, WorkOrderNonInventoryItemService, WorkOrderPackageDetail, WorkOrderPhoto, WorkOrderRefinishItem, WorkOrderService, WorkOrderShippingItem, WorkOrderShippingItemService, WorkOrderStatus, WorkOrderTotal, WorkOrderType, coatingDescriptionValidator, coatingValueValidator, convertEnumToObjectArray, getCoatingValues, getCoatings, hasCoatingDescription, hasCoatingValues, refinishDetailsValidator, touchControls };
2474
+ export { AI_ID_TOKEN_FACTORY, Address, AiAssistantService, BaseService, BillingInfo, BundleItem, ChangeOrderPackageDetail, ChangeOrderStatus, Coating, CoatingService, CoatingValue, CoatingValueService, Configuration, ConfigurationService, Customer, CustomerService, Dealer, DealerContact, DealerCoupon, DealerService, DisableControlDirective, EnumPipe, FileNamePipe, FileUploadService, FilterOptions, FinishDateHelperService, Firearm, FirearmMillingTypeService, FirearmOptic, FirearmOpticService, FirearmService, FirearmSightService, FormErrorMessageComponent, FrameMaterial, FrameMaterialPipe, GunCaliber, GunPart, GunPartOption, GunPartService, InventoryItem, InventoryService, JFile, Material, MaterialService, MillingDetail, MillingItem, MillingType, MillingTypeAddon, MillingTypeAddonOption, MillingTypeAddonService, MillingTypeService, ModalHeaderComponent, MountType, MountTypeService, NewLinePipe, NotificationBarComponent, NotificationModule, NotificationService, NotificationType, Optic, OpticService, OpticSight, OpticStatus, Package, PackageItem, PackageOptionalItem, PackageOptionalItemService, PackageService, PackageTotal, PackageVariation, PackageVariationOption, PackageVariationService, PhonePipe, Product, ProductService, ProjectType, PurchaseOrder, PurchaseOrderRefinishItem, PurchaseOrderService, PurchaseOrderStatus, QuickbooksService, RearSightPosition, RefinishCode, RefinishCodeService, RefinishDetail, ReportMillingItem, ReportRefinishItem, SharedModule, ShieldRMSOptions, Sight, SightMaterialService, SightMaterialType, SightService, SightType, SightTypeEnum, SightTypeService, SlideAddon, SlideAddonService, State, StateService, StatusHistoryService, Total, TotalItem, TotalsService, UserService, Vendor, VendorContact, VendorService, WaitlistAction, WaitlistCustomerService, WaitlistGun, WaitlistGunPackageDetail, WaitlistGunPhoto, WaitlistHistory, WaitlistItem, WaitlistProjectService, WaitlistService, WaitlistStatus, WorkChangeOrder, WorkHoliday, WorkHolidayService, WorkOrder, WorkOrderAction, WorkOrderBillingTransaction, WorkOrderDiscount, WorkOrderDiscountService, WorkOrderHistory, WorkOrderInventoryItem, WorkOrderListItem, WorkOrderNonInventoryItem, WorkOrderNonInventoryItemService, WorkOrderPackageDetail, WorkOrderPhoto, WorkOrderRefinishItem, WorkOrderService, WorkOrderShippingItem, WorkOrderShippingItemService, WorkOrderStatus, WorkOrderTotal, WorkOrderType, coatingDescriptionValidator, coatingValueValidator, convertEnumToObjectArray, getCoatingValues, getCoatings, hasCoatingDescription, hasCoatingValues, refinishDetailsValidator, touchControls };
2409
2475
  //# sourceMappingURL=gunsmith-common.mjs.map