@naniteninja/profile-comparison-lib 1.0.2 → 1.0.4

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.
package/index.d.ts CHANGED
@@ -1,11 +1,39 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, OnInit, AfterViewInit, OnChanges, EventEmitter, ElementRef, Renderer2, ChangeDetectorRef, SimpleChanges } from '@angular/core';
3
3
  import { Observable, BehaviorSubject } from 'rxjs';
4
+ import * as i2 from '@angular/common';
4
5
  import * as i3 from '@angular/common/http';
5
6
  import { HttpClient } from '@angular/common/http';
6
- import * as i2 from '@angular/common';
7
7
  import * as i4 from '@angular/forms';
8
8
 
9
+ /** Backend mode for the profile comparison component. */
10
+ declare enum BackendMode {
11
+ /** Use the real deployed backend (default). */
12
+ Real = 0,
13
+ /** Use a local mock server at localhost:3000. */
14
+ Mock = 1
15
+ }
16
+ declare const BACKEND_MODE_URLS: Record<BackendMode, string>;
17
+ /** Either a static base URL or a getter that returns the current base URL (for runtime toggle). */
18
+ type ProfileComparisonApiBaseUrl = string | (() => string | null);
19
+ /**
20
+ * Legacy injection token for the backend base URL.
21
+ * Prefer using the [backendMode] or [backendUrl] @Input on the component instead.
22
+ * Kept for backward compatibility — lowest priority when resolving the URL.
23
+ */
24
+ declare const PROFILE_COMPARISON_API_BASE_URL: InjectionToken<ProfileComparisonApiBaseUrl | null>;
25
+ /** Optional getter: when true, lib and backend service log steps to console for diagnosis. */
26
+ declare const PROFILE_COMPARISON_VERBOSE_LOGGING: InjectionToken<() => boolean>;
27
+ /**
28
+ * Resolves the active backend URL from inputs, with fallback to injection token.
29
+ *
30
+ * Priority:
31
+ * 1. Explicit backendUrl (custom URL string)
32
+ * 2. BackendMode enum (Real or Mock)
33
+ * 3. Legacy PROFILE_COMPARISON_API_BASE_URL token
34
+ */
35
+ declare function resolveBackendUrl(backendUrl: string | null | undefined, backendMode: BackendMode, legacyTokenUrl: string | null | undefined): string | null;
36
+
9
37
  interface IProfileConfig {
10
38
  person1Interests: string[];
11
39
  person2Interests: string[];
@@ -204,53 +232,6 @@ declare class CachePersistenceService {
204
232
  static ɵprov: i0.ɵɵInjectableDeclaration<CachePersistenceService>;
205
233
  }
206
234
 
207
- declare class EmbeddingService {
208
- private model$;
209
- getEmbedding(text: string): Observable<Float32Array>;
210
- /**
211
- * Group-align two lists based on semantic similarity, allowing one-to-many relationships.
212
- *
213
- * Design goals:
214
- * - Semantic relevance takes priority over original order or spacing.
215
- * - Each term in listB is assigned to the single most similar anchor in listA (if above threshold).
216
- * - For an anchor in listA with multiple highly related listB terms, they are emitted as consecutive rows:
217
- * [A, B1], ['-', B2], ['-', B3], ... so they render adjacently and remain visually connected.
218
- * - Low-similarity/unassigned terms from either side are appended at the end and never break groups.
219
- */
220
- groupAlignLists(listA: string[], listB: string[], threshold?: number, preserveLeftOrder?: boolean, exclusivityMargin?: number, leftCohesion?: number): Observable<IAlignmentRow[]>;
221
- cosineSimilarity(a: Float32Array, b: Float32Array): number;
222
- /**
223
- * Align words in listA with their most semantically similar words in listB
224
- *
225
- * Algorithm:
226
- * 1. Generate embeddings for all words in both lists using Universal Sentence Encoder
227
- * 2. For each word in listA, compare its embedding with all words in listB
228
- * 3. Find the word in listB with highest cosine similarity score
229
- * 4. Return alignment results with similarity scores
230
- *
231
- * @param listA - Source list of words to align
232
- * @param listB - Target list of words to find matches in
233
- * @returns Observable of alignment results with word, alignedWith, score, and index
234
- */
235
- alignLists(listA: string[], listB: string[]): Observable<IWordAlignment[]>;
236
- /**
237
- * Find best matching pairs between two lists above a similarity threshold
238
- *
239
- * @param listA - Source list of words
240
- * @param listB - Target list of words to match against
241
- * @param threshold - Minimum similarity score (0-1, default: 0.15)
242
- * @returns Observable of word pairs with similarity scores
243
- */
244
- findBestMatchingPairs(listA: string[], listB: string[], threshold?: number): Observable<IWordPair[]>;
245
- calculateSimilarity(primaryText: string, comparisonText: string): Observable<number>;
246
- testWordSimilarity(word1: string, word2: string): Observable<void>;
247
- private domainCompatibilityCap;
248
- private computeLexicalBoost;
249
- private loadModel;
250
- static ɵfac: i0.ɵɵFactoryDeclaration<EmbeddingService, never>;
251
- static ɵprov: i0.ɵɵInjectableDeclaration<EmbeddingService>;
252
- }
253
-
254
235
  declare class FileConversionService {
255
236
  private static readonly MIME_TYPE_JPEG;
256
237
  private static readonly MIME_TYPE_PNG;
@@ -281,18 +262,6 @@ declare class ImageCompressionService {
281
262
  static ɵprov: i0.ɵɵInjectableDeclaration<ImageCompressionService>;
282
263
  }
283
264
 
284
- /** Either a static base URL or a getter that returns the current base URL (for runtime toggle). */
285
- type ProfileComparisonApiBaseUrl = string | (() => string | null);
286
- /**
287
- * When provided, ProfileService and OpenAIEmbeddingService call this backend base URL
288
- * (e.g. 'http://localhost:3000/api') for all profile/embedding endpoints instead of
289
- * calling external APIs directly with keys. Can be a string or a getter function for runtime toggle.
290
- * When not provided or getter returns null, the lib uses the direct path with keys.
291
- */
292
- declare const PROFILE_COMPARISON_API_BASE_URL: InjectionToken<ProfileComparisonApiBaseUrl | null>;
293
- /** Optional getter: when true, lib and backend service log steps to console for diagnosis. */
294
- declare const PROFILE_COMPARISON_VERBOSE_LOGGING: InjectionToken<() => boolean>;
295
-
296
265
  /**
297
266
  * OpenAI Alignment Service
298
267
  * Uses OpenAI Chat Completions API to align two lists of text in a single request.
@@ -417,12 +386,16 @@ declare class ProfileService {
417
386
  declare class ProfileComparisonBackendService {
418
387
  private http;
419
388
  private apiBaseUrl;
420
- private getVerboseLogging?;
421
- constructor(http: HttpClient, apiBaseUrl: ProfileComparisonApiBaseUrl | null, getVerboseLogging?: (() => boolean) | undefined);
389
+ private getVerboseLogging;
390
+ constructor();
391
+ static extractErrorMessage(err: unknown): string;
422
392
  private log;
393
+ /** Returns the legacy token URL (for backward compat fallback). */
394
+ getLegacyTokenUrl(): string | null;
395
+ /** @deprecated Use getLegacyTokenUrl(). Kept for backward compat. */
423
396
  getBaseUrl(): string | null;
424
- getComparison(config: IProfileConfig): Observable<IComparisonPayload>;
425
- static ɵfac: i0.ɵɵFactoryDeclaration<ProfileComparisonBackendService, [null, { optional: true; }, { optional: true; }]>;
397
+ getComparison(config: IProfileConfig, baseUrl?: string | null): Observable<IComparisonPayload>;
398
+ static ɵfac: i0.ɵɵFactoryDeclaration<ProfileComparisonBackendService, never>;
426
399
  static ɵprov: i0.ɵɵInjectableDeclaration<ProfileComparisonBackendService>;
427
400
  }
428
401
 
@@ -465,6 +438,8 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
465
438
  private static readonly TRANSFORM_RESET;
466
439
  private static readonly TRANSITION_RESET_DELAY_MS;
467
440
  config: IProfileConfig;
441
+ backendMode: BackendMode;
442
+ backendUrl: string | null;
468
443
  fadeAllEdges: boolean;
469
444
  matrixDataChange: EventEmitter<IMatrixData>;
470
445
  rawLLMOutputChange: EventEmitter<string>;
@@ -522,6 +497,8 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
522
497
  matrixData: IMatrixData | null;
523
498
  /** When false, backend URL is not provided — show "Configure backend". */
524
499
  backendConfigured: boolean;
500
+ /** The resolved backend URL computed from inputs and legacy token. */
501
+ private resolvedBackendUrl;
525
502
  compressionConfig: IImageCompressionConfig;
526
503
  private computeSub?;
527
504
  /** Incremented on each fetchComparison(); used to ignore stale success/error from an older request. */
@@ -582,7 +559,7 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
582
559
  applyDefaultAlignment(): void;
583
560
  isValidFaceData(face: IBoundingBox): boolean;
584
561
  static ɵfac: i0.ɵɵFactoryDeclaration<ProfileComparisonLibComponent, [null, null, null, null, null, { optional: true; }]>;
585
- static ɵcmp: i0.ɵɵComponentDeclaration<ProfileComparisonLibComponent, "lib-profile-comparison", never, { "config": { "alias": "config"; "required": false; }; "fadeAllEdges": { "alias": "fadeAllEdges"; "required": false; }; }, { "matrixDataChange": "matrixDataChange"; "rawLLMOutputChange": "rawLLMOutputChange"; "viewProfileClick": "viewProfileClick"; }, never, never, false, never>;
562
+ static ɵcmp: i0.ɵɵComponentDeclaration<ProfileComparisonLibComponent, "lib-profile-comparison", never, { "config": { "alias": "config"; "required": false; }; "backendMode": { "alias": "backendMode"; "required": false; }; "backendUrl": { "alias": "backendUrl"; "required": false; }; "fadeAllEdges": { "alias": "fadeAllEdges"; "required": false; }; }, { "matrixDataChange": "matrixDataChange"; "rawLLMOutputChange": "rawLLMOutputChange"; "viewProfileClick": "viewProfileClick"; }, never, never, false, never>;
586
563
  }
587
564
 
588
565
  declare class ProfileComparisonLibModule {
@@ -591,5 +568,5 @@ declare class ProfileComparisonLibModule {
591
568
  static ɵinj: i0.ɵɵInjectorDeclaration<ProfileComparisonLibModule>;
592
569
  }
593
570
 
594
- export { CachePersistenceService, EmbeddingService, FileConversionService, ImageCompressionService, OpenAIEmbeddingService, PROFILE_COMPARISON_API_BASE_URL, PROFILE_COMPARISON_VERBOSE_LOGGING, ProfileComparisonBackendService, ProfileComparisonLibComponent, ProfileComparisonLibModule, ProfileComparisonLibService, ProfileService };
571
+ export { BACKEND_MODE_URLS, BackendMode, CachePersistenceService, FileConversionService, ImageCompressionService, OpenAIEmbeddingService, PROFILE_COMPARISON_API_BASE_URL, PROFILE_COMPARISON_VERBOSE_LOGGING, ProfileComparisonBackendService, ProfileComparisonLibComponent, ProfileComparisonLibModule, ProfileComparisonLibService, ProfileService, resolveBackendUrl };
595
572
  export type { CacheStoreName, FaceDetectionData, FaceDetectionResponse, FileInputEvent, IAlignmentRow, IBoundingBox, IComparisonPayload, IComparisonResult, IEnvironment, IFaceBoxWithLandmarks, IFaceDetectionResult, IFaceLandmarks, IFacePlusPlusFace, IFacePlusPlusResponse, IFaceRectangle, IImageCompressionConfig, IMatrixData, IMatrixLegendItem, IMatrixRow, IOpenAIEmbeddingItem, IOpenAIResponse, IPoint, IProfileConfig, ISimilarityResponse, ISimilarityThreshold, IWordAlignment, IWordPair };
package/package.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
2
  "name": "@naniteninja/profile-comparison-lib",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20.0.0",
6
- "@angular/core": "^20.0.0",
7
- "@tensorflow-models/universal-sentence-encoder": "^1.3.3",
8
- "@tensorflow/tfjs": "^4.22.0"
6
+ "@angular/core": "^20.0.0"
9
7
  },
10
8
  "dependencies": {
11
9
  "tslib": "^2.3.0"