@partium/js-sdk 13.0.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 (269) hide show
  1. package/LICENSE.txt +100 -0
  2. package/README.md +18 -0
  3. package/core/constants/constants.d.ts +12 -0
  4. package/core/constants/constants.js +2 -0
  5. package/core/decorators/injection-identifier.d.ts +10 -0
  6. package/core/decorators/injection-identifier.js +2 -0
  7. package/core/factories/paginated-request-service.factory.d.ts +22 -0
  8. package/core/factories/paginated-request-service.factory.js +2 -0
  9. package/core/index.d.ts +47 -0
  10. package/core/index.js +2 -0
  11. package/core/integration-defaults/http/fetch-api-http-error-helper.d.ts +16 -0
  12. package/core/integration-defaults/http/fetch-api-http-error-helper.js +2 -0
  13. package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.d.ts +35 -0
  14. package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.js +2 -0
  15. package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.d.ts +47 -0
  16. package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.js +2 -0
  17. package/core/integration-defaults/http/handle-axios-error-helper.d.ts +17 -0
  18. package/core/integration-defaults/http/handle-axios-error-helper.js +2 -0
  19. package/core/integration-defaults/http/https-client/axios-https-client.service.d.ts +83 -0
  20. package/core/integration-defaults/http/https-client/axios-https-client.service.js +2 -0
  21. package/core/integration-defaults/http/https-client/fetch-api-https-client.service.d.ts +85 -0
  22. package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +2 -0
  23. package/core/integration-defaults/http/js-oauth-keycloak-https.service.d.ts +8 -0
  24. package/core/integration-defaults/http/js-oauth-keycloak-https.service.js +2 -0
  25. package/core/integration-defaults/js-p-file.d.ts +8 -0
  26. package/core/integration-defaults/js-p-file.js +2 -0
  27. package/core/integration-defaults/session/js-oauth-api-key-session.service.d.ts +76 -0
  28. package/core/integration-defaults/session/js-oauth-api-key-session.service.js +2 -0
  29. package/core/integration-defaults/session/js-oauth-keycloak-auth-config.d.ts +28 -0
  30. package/core/integration-defaults/session/js-oauth-keycloak-auth-config.js +2 -0
  31. package/core/integration-defaults/session/js-oauth-keycloak-session.service.d.ts +82 -0
  32. package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +2 -0
  33. package/core/integration-defaults/web-device-status.service.d.ts +24 -0
  34. package/core/integration-defaults/web-device-status.service.js +2 -0
  35. package/core/integration-defaults/web-file.service.d.ts +9 -0
  36. package/core/integration-defaults/web-file.service.js +2 -0
  37. package/core/integration-defaults/web-indexeddb.service.d.ts +19 -0
  38. package/core/integration-defaults/web-indexeddb.service.js +2 -0
  39. package/core/integration-defaults/web-local-storage.service.d.ts +157 -0
  40. package/core/integration-defaults/web-local-storage.service.js +2 -0
  41. package/core/models/api-object.d.ts +7 -0
  42. package/core/models/api-object.js +2 -0
  43. package/core/models/auth-config.d.ts +38 -0
  44. package/core/models/auth-config.js +2 -0
  45. package/core/models/device-info.d.ts +62 -0
  46. package/core/models/device-info.js +2 -0
  47. package/core/models/error.d.ts +70 -0
  48. package/core/models/error.js +2 -0
  49. package/core/models/formatted-string.d.ts +9 -0
  50. package/core/models/formatted-string.js +2 -0
  51. package/core/models/i18n-map.d.ts +34 -0
  52. package/core/models/i18n-map.js +2 -0
  53. package/core/models/i18n-string.d.ts +8 -0
  54. package/core/models/i18n-string.js +2 -0
  55. package/core/models/log.d.ts +130 -0
  56. package/core/models/log.js +2 -0
  57. package/core/models/organization.d.ts +121 -0
  58. package/core/models/organization.js +2 -0
  59. package/core/models/p-file.d.ts +17 -0
  60. package/core/models/p-file.js +2 -0
  61. package/core/models/paginated-list.d.ts +23 -0
  62. package/core/models/paginated-list.js +2 -0
  63. package/core/models/partium-config.d.ts +31 -0
  64. package/core/models/partium-config.js +2 -0
  65. package/core/models/user-token.d.ts +16 -0
  66. package/core/models/user-token.js +2 -0
  67. package/core/models/user.d.ts +48 -0
  68. package/core/models/user.js +2 -0
  69. package/core/services/backend-status.service.d.ts +46 -0
  70. package/core/services/backend-status.service.js +2 -0
  71. package/core/services/base-login-init.service.d.ts +32 -0
  72. package/core/services/base-login-init.service.js +2 -0
  73. package/core/services/base.service.d.ts +31 -0
  74. package/core/services/base.service.js +2 -0
  75. package/core/services/device-status.service.interface.d.ts +36 -0
  76. package/core/services/device-status.service.interface.js +2 -0
  77. package/core/services/file.service.interface.d.ts +24 -0
  78. package/core/services/file.service.interface.js +2 -0
  79. package/core/services/http/file-transfer/file-transfer.service.interface.d.ts +57 -0
  80. package/core/services/http/file-transfer/file-transfer.service.interface.js +2 -0
  81. package/core/services/http/https-client/https-client.service.interface.d.ts +96 -0
  82. package/core/services/http/https-client/https-client.service.interface.js +2 -0
  83. package/core/services/http/https.service.interface.d.ts +164 -0
  84. package/core/services/http/https.service.interface.js +2 -0
  85. package/core/services/http/oauth-https.service.d.ts +120 -0
  86. package/core/services/http/oauth-https.service.js +2 -0
  87. package/core/services/local-storage.service.interface.d.ts +221 -0
  88. package/core/services/local-storage.service.interface.js +2 -0
  89. package/core/services/log.service.d.ts +48 -0
  90. package/core/services/log.service.js +2 -0
  91. package/core/services/organization.service.d.ts +48 -0
  92. package/core/services/organization.service.js +2 -0
  93. package/core/services/paginated-request.service.d.ts +104 -0
  94. package/core/services/paginated-request.service.js +2 -0
  95. package/core/services/recent-parts.service.d.ts +59 -0
  96. package/core/services/recent-parts.service.js +2 -0
  97. package/core/services/service-provider.d.ts +58 -0
  98. package/core/services/service-provider.js +2 -0
  99. package/core/services/session/oauth-session.service.d.ts +76 -0
  100. package/core/services/session/oauth-session.service.js +2 -0
  101. package/core/services/session/session.service.interface.d.ts +138 -0
  102. package/core/services/session/session.service.interface.js +2 -0
  103. package/core/utils/general-helper.d.ts +35 -0
  104. package/core/utils/general-helper.js +2 -0
  105. package/data/index.d.ts +28 -0
  106. package/data/index.js +2 -0
  107. package/data/models/announcement.d.ts +30 -0
  108. package/data/models/announcement.js +2 -0
  109. package/data/models/assembly-hierarchy-node-breadcrumb.d.ts +10 -0
  110. package/data/models/assembly-hierarchy-node-breadcrumb.js +2 -0
  111. package/data/models/assembly-hierarchy-node.d.ts +16 -0
  112. package/data/models/assembly-hierarchy-node.js +2 -0
  113. package/data/models/attribute.d.ts +46 -0
  114. package/data/models/attribute.js +2 -0
  115. package/data/models/csa-request-search.d.ts +18 -0
  116. package/data/models/csa-request-search.js +2 -0
  117. package/data/models/csa-request-status.d.ts +16 -0
  118. package/data/models/csa-request-status.js +2 -0
  119. package/data/models/csa-request.d.ts +41 -0
  120. package/data/models/csa-request.js +2 -0
  121. package/data/models/document.d.ts +12 -0
  122. package/data/models/document.js +2 -0
  123. package/data/models/filter-key.d.ts +12 -0
  124. package/data/models/filter-key.js +2 -0
  125. package/data/models/filter-option-value.d.ts +18 -0
  126. package/data/models/filter-option-value.js +2 -0
  127. package/data/models/image.d.ts +36 -0
  128. package/data/models/image.js +2 -0
  129. package/data/models/inquiry.d.ts +32 -0
  130. package/data/models/inquiry.js +2 -0
  131. package/data/models/mounting-location.d.ts +32 -0
  132. package/data/models/mounting-location.js +2 -0
  133. package/data/models/multiple-expert-searches.d.ts +9 -0
  134. package/data/models/multiple-expert-searches.js +2 -0
  135. package/data/models/part-enrichment-data.d.ts +24 -0
  136. package/data/models/part-enrichment-data.js +2 -0
  137. package/data/models/part.d.ts +168 -0
  138. package/data/models/part.js +2 -0
  139. package/data/models/shopping-cart.d.ts +43 -0
  140. package/data/models/shopping-cart.js +2 -0
  141. package/data/services/announcement.service.d.ts +68 -0
  142. package/data/services/announcement.service.js +2 -0
  143. package/data/services/assembly-hierarchy-nodes.service.d.ts +113 -0
  144. package/data/services/assembly-hierarchy-nodes.service.js +2 -0
  145. package/data/services/csa-helper.service.d.ts +32 -0
  146. package/data/services/csa-helper.service.js +2 -0
  147. package/data/services/customer-service-assistance.service.d.ts +181 -0
  148. package/data/services/customer-service-assistance.service.js +2 -0
  149. package/data/services/filter.service.d.ts +97 -0
  150. package/data/services/filter.service.js +2 -0
  151. package/data/services/inquiry.service.d.ts +54 -0
  152. package/data/services/inquiry.service.js +2 -0
  153. package/data/services/part-attribute.service.d.ts +42 -0
  154. package/data/services/part-attribute.service.js +2 -0
  155. package/data/services/part-enrichment.service.d.ts +32 -0
  156. package/data/services/part-enrichment.service.js +2 -0
  157. package/data/services/part.service.d.ts +121 -0
  158. package/data/services/part.service.js +2 -0
  159. package/data/services/related-parts.service.d.ts +75 -0
  160. package/data/services/related-parts.service.js +2 -0
  161. package/data/services/shopping-cart.service.d.ts +150 -0
  162. package/data/services/shopping-cart.service.js +2 -0
  163. package/find/index.d.ts +35 -0
  164. package/find/index.js +2 -0
  165. package/find/models/assets/asset.d.ts +24 -0
  166. package/find/models/assets/asset.js +2 -0
  167. package/find/models/search-filter.d.ts +87 -0
  168. package/find/models/search-filter.js +2 -0
  169. package/find/models/search-input.d.ts +39 -0
  170. package/find/models/search-input.js +2 -0
  171. package/find/models/search-output.d.ts +10 -0
  172. package/find/models/search-output.js +2 -0
  173. package/find/models/search-result-status.d.ts +33 -0
  174. package/find/models/search-result-status.js +2 -0
  175. package/find/models/search-session-log-object.d.ts +16 -0
  176. package/find/models/search-session-log-object.js +2 -0
  177. package/find/models/search-status/cv-search-status.d.ts +20 -0
  178. package/find/models/search-status/cv-search-status.js +2 -0
  179. package/find/models/search-status/search-filter-status.d.ts +33 -0
  180. package/find/models/search-status/search-filter-status.js +2 -0
  181. package/find/models/search-status/search-status.d.ts +34 -0
  182. package/find/models/search-status/search-status.js +2 -0
  183. package/find/models/search-status/tag-search-status.d.ts +16 -0
  184. package/find/models/search-status/tag-search-status.js +2 -0
  185. package/find/models/search-status/text-search-status.d.ts +15 -0
  186. package/find/models/search-status/text-search-status.js +2 -0
  187. package/find/models/search-tag.d.ts +12 -0
  188. package/find/models/search-tag.js +2 -0
  189. package/find/models/smart-filter.d.ts +25 -0
  190. package/find/models/smart-filter.js +2 -0
  191. package/find/models/tagable/i18n-tagable.d.ts +10 -0
  192. package/find/models/tagable/i18n-tagable.js +2 -0
  193. package/find/models/tagable/tagable-base.d.ts +11 -0
  194. package/find/models/tagable/tagable-base.js +2 -0
  195. package/find/models/tagable/tagable.d.ts +10 -0
  196. package/find/models/tagable/tagable.js +2 -0
  197. package/find/models/text-search-config.d.ts +57 -0
  198. package/find/models/text-search-config.js +2 -0
  199. package/find/models/text-search-manipulator.d.ts +46 -0
  200. package/find/models/text-search-manipulator.js +2 -0
  201. package/find/models/text-search-result-item/text-search-error.d.ts +7 -0
  202. package/find/models/text-search-result-item/text-search-error.js +2 -0
  203. package/find/models/text-search-result-item/text-search-result-item-document.d.ts +10 -0
  204. package/find/models/text-search-result-item/text-search-result-item-document.js +2 -0
  205. package/find/models/text-search-result-item/text-search-result-item-part.d.ts +12 -0
  206. package/find/models/text-search-result-item/text-search-result-item-part.js +2 -0
  207. package/find/models/text-search-result-item/text-search-result-item-recent-query.d.ts +10 -0
  208. package/find/models/text-search-result-item/text-search-result-item-recent-query.js +2 -0
  209. package/find/models/text-search-result-item/text-search-result-item-unknown.d.ts +12 -0
  210. package/find/models/text-search-result-item/text-search-result-item-unknown.js +2 -0
  211. package/find/models/text-search-result-item/text-search-result-item.d.ts +16 -0
  212. package/find/models/text-search-result-item/text-search-result-item.js +2 -0
  213. package/find/services/asset.service.d.ts +160 -0
  214. package/find/services/asset.service.js +2 -0
  215. package/find/services/filter-uploaders/filter-uploader.d.ts +13 -0
  216. package/find/services/filter-uploaders/filter-uploader.js +2 -0
  217. package/find/services/filter-uploaders/update-filters-uploader.d.ts +17 -0
  218. package/find/services/filter-uploaders/update-filters-uploader.js +2 -0
  219. package/find/services/filter-uploaders/update-filters.model.d.ts +19 -0
  220. package/find/services/filter-uploaders/update-filters.model.js +2 -0
  221. package/find/services/search/cv-search.service.d.ts +103 -0
  222. package/find/services/search/cv-search.service.js +2 -0
  223. package/find/services/search/recent-text-search-queries.service.d.ts +89 -0
  224. package/find/services/search/recent-text-search-queries.service.js +2 -0
  225. package/find/services/search/search-result.service.d.ts +142 -0
  226. package/find/services/search/search-result.service.js +2 -0
  227. package/find/services/search/search.service.d.ts +291 -0
  228. package/find/services/search/search.service.js +2 -0
  229. package/find/services/search/tag-search.service.d.ts +66 -0
  230. package/find/services/search/tag-search.service.js +2 -0
  231. package/find/services/search/text-search.service.d.ts +116 -0
  232. package/find/services/search/text-search.service.js +2 -0
  233. package/find/services/search-filter.service.d.ts +223 -0
  234. package/find/services/search-filter.service.js +2 -0
  235. package/find/utils/search-helper.d.ts +14 -0
  236. package/find/utils/search-helper.js +2 -0
  237. package/gen/sdk-version.d.ts +2 -0
  238. package/gen/sdk-version.js +2 -0
  239. package/index.d.ts +121 -0
  240. package/index.js +2 -0
  241. package/management/index.d.ts +5 -0
  242. package/management/index.js +2 -0
  243. package/management/models/api-key-list-response.d.ts +10 -0
  244. package/management/models/api-key-list-response.js +2 -0
  245. package/management/models/api-key-type.d.ts +5 -0
  246. package/management/models/api-key-type.js +2 -0
  247. package/management/models/api-key.d.ts +4 -0
  248. package/management/models/api-key.js +2 -0
  249. package/management/services/api-key.service.d.ts +39 -0
  250. package/management/services/api-key.service.js +2 -0
  251. package/ocr/index.d.ts +4 -0
  252. package/ocr/index.js +2 -0
  253. package/ocr/models/detect-response.d.ts +5 -0
  254. package/ocr/models/detect-response.js +2 -0
  255. package/ocr/models/detected-text-entry.d.ts +5 -0
  256. package/ocr/models/detected-text-entry.js +2 -0
  257. package/ocr/services/ocr.service.d.ts +36 -0
  258. package/ocr/services/ocr.service.js +2 -0
  259. package/package.json +45 -0
  260. package/user-data/index.d.ts +5 -0
  261. package/user-data/index.js +2 -0
  262. package/user-data/models/part-with-nullable.d.ts +5 -0
  263. package/user-data/models/part-with-nullable.js +2 -0
  264. package/user-data/models/request-list/request-list.d.ts +16 -0
  265. package/user-data/models/request-list/request-list.js +2 -0
  266. package/user-data/services/favorite/favorite.service.d.ts +45 -0
  267. package/user-data/services/favorite/favorite.service.js +2 -0
  268. package/user-data/services/request-list/request-list.service.d.ts +97 -0
  269. package/user-data/services/request-list/request-list.service.js +2 -0
@@ -0,0 +1,160 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable } from 'rxjs';
3
+ import { PFile } from '../../core/models/p-file';
4
+ import { PartiumConfig } from '../../core/models/partium-config';
5
+ import { BaseLoginInitService } from '../../core/services/base-login-init.service';
6
+ import { DownloadStatus } from '../../core/services/http/file-transfer/file-transfer.service.interface';
7
+ import { BACKEND_SERVICE } from '../../core/services/http/https.service.interface';
8
+ import { ServiceProvider } from '../../core/services/service-provider';
9
+ import { Asset } from '../models/assets/asset';
10
+ import { EventContext, Organization } from '../../core';
11
+ export interface AssetEventContext extends EventContext {
12
+ searchSessionId?: string;
13
+ }
14
+ /**
15
+ * Service for creating and uploading assets of different types.
16
+ *
17
+ * Process:
18
+ * When a new asset should be created
19
+ * - a request is sent to the backend to request a new upload
20
+ * - the BE returns with an upload url
21
+ * - after the upload is finished the App notifies the BE about the finished upload
22
+ * - and the final asset will be created in the BE
23
+ */
24
+ export interface AssetService {
25
+ /**
26
+ * Create a new asset from a file and upload it to the Partium backend.
27
+ * Will throw an error if the file-type is not an image.
28
+ * Will throw an error if the image dimensions exceed the valid ones.
29
+ *
30
+ * @param searchDomainId Search domain to upload the asset to.
31
+ * @param data The underlying data for the asset, type can depend on platform
32
+ * @param assetEventContext (optional) SearchEventContext object to add the missing data that will be logged using the log format V2
33
+ * @returns Observable that resolves with an object containing the asset-object
34
+ * and the current upload progress
35
+ */
36
+ generateAsset(searchDomainId: string, pFile: PFile, assetEventContext?: AssetEventContext): Observable<{
37
+ asset: Asset;
38
+ progress: number;
39
+ }>;
40
+ /**
41
+ * Download an image by its assetId and preferred size.
42
+ *
43
+ * @param assetId the assetId of the image that should be downloaded
44
+ * @param size the names of the sizes this image is available in eg: "original", "thumbnail", "medium"
45
+ * @returns an Observable that resolves with the DownloadStatus of the download, which contains
46
+ * the progress and the PFile as soon as it is finished
47
+ */
48
+ downloadImage(assetId: string, size?: string, origin?: BACKEND_SERVICE): Observable<DownloadStatus>;
49
+ /**
50
+ * -- Temporary solution, until all assets are handled in one place --
51
+ * Download an image from Find BE
52
+ *
53
+ * @param assetId asset-id of the image to download
54
+ */
55
+ getImageUrlFromFind(assetId: string): Observable<{
56
+ url: string;
57
+ assetId: string;
58
+ }>;
59
+ /**
60
+ * Download an document by its assetId.
61
+ *
62
+ * @param assetId the assetId of the document that should be downloaded
63
+ * @returns an Observable that resolves with the DownloadStatus of the download, which contains
64
+ * the progress and the PFile as soon as it is finished
65
+ *
66
+ * @deprecated This function will not be supported anymore in the future. No replacement is planned.
67
+ */
68
+ downloadDocument(assetId: string): Observable<DownloadStatus>;
69
+ }
70
+ export declare class AssetServiceImpl extends BaseLoginInitService implements AssetService {
71
+ private httpsService;
72
+ private fileTransferService;
73
+ private fileService;
74
+ private logService;
75
+ private MAX_UPLOAD_IMAGE_WIDTH;
76
+ private MAX_UPLOAD_IMAGE_HEIGHT;
77
+ constructor(serviceProvider: ServiceProvider);
78
+ onCreate(): void;
79
+ /**
80
+ * Called on login
81
+ */
82
+ init(config: PartiumConfig, userEmail: string, currentOrganization$: Observable<Organization>): Observable<void>;
83
+ generateAsset(searchDomainId: string, pFile: PFile, assetEventContext?: AssetEventContext): Observable<{
84
+ asset: Asset;
85
+ progress: number;
86
+ }>;
87
+ /**
88
+ * Check if the asset is an image and, in that case, log its dimensions.
89
+ *
90
+ * @param file PFile
91
+ * @return Promise<boolean>
92
+ */
93
+ private getFileDimensions;
94
+ /**
95
+ * Check if the provided dimensions are supported.
96
+ *
97
+ * @param width number
98
+ * @param height number
99
+ * @return boolean
100
+ */
101
+ private validateDimensions;
102
+ /**
103
+ * Log image dimensions to BE-Log service.
104
+ *
105
+ * @param width number
106
+ * @param height number
107
+ * @param searchDomainId string
108
+ * @param assetEventContext AssetEventContext
109
+ * @return Promise<void>
110
+ */
111
+ private logImageDimensions;
112
+ downloadImage(assetId: string, size?: string, origin?: BACKEND_SERVICE): Observable<DownloadStatus>;
113
+ /**
114
+ * Get the temporary download url of an image by its assetId and preferred size
115
+ *
116
+ * @param assetId the assetId of image
117
+ * @param size the names of the sizes this image is available in eg: "original", "thumbnail", "medium"
118
+ * @returns Observable that resolves with an object containing the temporary url, where the image
119
+ * can be downloaded and the assetId of the asset
120
+ */
121
+ private getImageUrl;
122
+ getImageUrlFromFind(assetId: string): Observable<{
123
+ url: string;
124
+ assetId: string;
125
+ }>;
126
+ downloadDocument(assetId: string): Observable<DownloadStatus>;
127
+ /**
128
+ * Get the temporary download url of a document by its assetId
129
+ *
130
+ * @param assetId the assetId of the document
131
+ * @returns Observable that resolves with an object containing the temporary url, where the document
132
+ * can be downloaded and the assetId of the asset
133
+ */
134
+ private getDocumentUrl;
135
+ /**
136
+ * Upload a newly created asset to the BE.
137
+ *
138
+ * @param searchDomainId Search domain to upload the asset to.
139
+ * @param asset the asset to upload
140
+ * @returns Observable that resolves with an object containing the asset-object
141
+ * and the current upload progress
142
+ */
143
+ private uploadAsset;
144
+ /**
145
+ * Send a request to the backend to create a new asset and retrieve the uploadUrl and
146
+ * Reference id. This data is then applied to the given asset object.
147
+ *
148
+ * @param searchDomainId Search domain to upload the asset to.
149
+ * @param asset the asset object to prepare for upload
150
+ * @returns Observable that resolves when the prepare-asset is finished successfully
151
+ */
152
+ private prepareAssetUpload;
153
+ /**
154
+ * Sends a request to the backend to verify an uploaded asset.
155
+ *
156
+ * @param asset the asset to verify
157
+ * @returns Observable that resolves when the verify-asset is finished successfully
158
+ */
159
+ private verifyAsset;
160
+ }
@@ -0,0 +1,2 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ "use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,r,t,n){var i,o=arguments.length,s=o<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,r,t,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(r,t,s):i(r,t))||s);return o>3&&s&&Object.defineProperty(r,t,s),s},__awaiter=this&&this.__awaiter||function(e,r,t,n){return new(t||(t=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?i(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,a)}c((n=n.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var t,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(t=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],n=0}finally{t=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AssetServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),injection_identifier_1=require("../../core/decorators/injection-identifier"),error_1=require("../../core/models/error"),p_file_1=require("../../core/models/p-file"),base_login_init_service_1=require("../../core/services/base-login-init.service"),file_service_interface_1=require("../../core/services/file.service.interface"),file_transfer_service_interface_1=require("../../core/services/http/file-transfer/file-transfer.service.interface"),https_service_interface_1=require("../../core/services/http/https.service.interface"),log_service_1=require("../../core/services/log.service"),asset_1=require("../models/assets/asset"),core_1=require("../../core"),AssetServiceImpl=function(e){function r(r){var t=e.call(this,r)||this;return t.MAX_UPLOAD_IMAGE_WIDTH=960,t.MAX_UPLOAD_IMAGE_HEIGHT=960,t}return __extends(r,e),r.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.fileTransferService=this.serviceProvider.getService(file_transfer_service_interface_1.FileTransferService),this.fileService=this.serviceProvider.getService(file_service_interface_1.FileService),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl)},r.prototype.init=function(r,t,n){return e.prototype.init.call(this,r,t,n),(0,rxjs_1.of)(void 0)},r.prototype.generateAsset=function(e,r,t){var n=this;return(0,rxjs_1.from)(this.getFileDimensions(r)).pipe((0,operators_1.mergeMap)((function(i){var o=i[0],s=i[1],a=new asset_1.Asset(r);return(0,rxjs_1.defer)((function(){return a.setStatus(asset_1.ASSET_STATUS.NEW),(0,rxjs_1.from)(n.logImageDimensions(o,s,e,t)).pipe((0,operators_1.mergeMap)((function(){return n.uploadAsset(e,a)})))})).pipe((0,operators_1.catchError)((function(e){return a.setStatus(asset_1.ASSET_STATUS.ERROR),(0,rxjs_1.throwError)(e)})))})))},r.prototype.getFileDimensions=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4,this.fileService.getFileType(e)];case 1:if(r.sent()!==p_file_1.PFileType.IMAGE)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_FILE_TYPE,{},"Wrong file type provided. Type IMAGE required.");return[4,this.fileService.getImageDimensions(e)];case 2:return[2,r.sent()]}}))}))},r.prototype.validateDimensions=function(e,r){return e<=this.MAX_UPLOAD_IMAGE_WIDTH||r<=this.MAX_UPLOAD_IMAGE_HEIGHT},r.prototype.logImageDimensions=function(e,r,t,n){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){return this.logService.logEvent(new core_1.EventLog({version:core_1.EVENTLOG_VERSIONS.V_2_0_0,organizationId:t,interface:(null==n?void 0:n.eventInterface)||core_1.INTERFACE.API_ACCESS,event:core_1.EVENT.ATTEMPT_UPLOAD_IMAGE_DIMENSIONS,data:__assign(__assign({},(null==n?void 0:n.searchSessionId)&&{searchSessionId:null==n?void 0:n.searchSessionId}),{width:e,height:r})})).subscribe((function(){}),(function(e){console.log("Error while sending log event ".concat(core_1.EVENT.ATTEMPT_UPLOAD_IMAGE_DIMENSIONS,": "),e)})),[2]}))}))},r.prototype.downloadImage=function(e,r,t){var n=this;return void 0===r&&(r="original"),void 0===t&&(t=https_service_interface_1.BACKEND_SERVICE.DATA),(t===https_service_interface_1.BACKEND_SERVICE.DATA?this.getImageUrl(e,r):this.getImageUrlFromFind(e)).pipe((0,operators_1.mergeMap)((function(e){return n.fileTransferService.downloadFile(e.url)})))},r.prototype.getImageUrl=function(e,r){return this.httpsService.get("images/".concat(e),null,https_service_interface_1.BACKEND_SERVICE.DATA).pipe((0,operators_1.map)((function(t){if(t.urls&&t.urls[r])return{url:t.urls[r],assetId:e};throw new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_FOUND,null,"Could not find image with id: ".concat(e," in size: ").concat(r))})))},r.prototype.getImageUrlFromFind=function(e){return this.httpsService.get("assets/".concat(e),null,https_service_interface_1.BACKEND_SERVICE.FIND).pipe((0,operators_1.map)((function(r){if(r&&r.url)return{url:r.url,assetId:e};throw new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_FOUND,null,"Could not find image with id: ".concat(e))})))},r.prototype.downloadDocument=function(e){var r=this;return this.getDocumentUrl(e).pipe((0,operators_1.mergeMap)((function(e){return r.fileTransferService.downloadFile(e.url)})))},r.prototype.getDocumentUrl=function(e){return this.httpsService.get("documents/".concat(e),null,https_service_interface_1.BACKEND_SERVICE.DATA).pipe((0,operators_1.map)((function(r){if(r.url)return{url:r.url,assetId:e};new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_FOUND,null,"Could not find document with id: ".concat(e))})))},r.prototype.uploadAsset=function(e,r){var t=this;return new rxjs_1.Observable((function(n){if(r.getStatus()!==asset_1.ASSET_STATUS.NEW){var i='Cannot upload asset, since the asset status is not "NEW".';console.log(i),n.error(new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_ASSET_STATUS,null,i))}t.prepareAssetUpload(e,r).pipe((0,operators_1.mergeMap)((function(e){return r.setStatus(asset_1.ASSET_STATUS.UPLOADING),t.fileTransferService.uploadFile(r.file,r.uploadUrl)})),(0,operators_1.tap)((function(e){n.next({asset:r,progress:e.progress})})),(0,operators_1.mergeMap)((function(e){return e.status===file_transfer_service_interface_1.TRANSFER_STATUS.TRANSFER_FINISHED&&r.getStatus()===asset_1.ASSET_STATUS.UPLOADING?(r.setStatus(asset_1.ASSET_STATUS.UPLOADED),t.verifyAsset(r)):(0,rxjs_1.of)()})),(0,operators_1.catchError)((function(e){return r.setStatus(asset_1.ASSET_STATUS.ERROR),n.error(e),(0,rxjs_1.of)(e)}))).subscribe((function(){r.getStatus()===asset_1.ASSET_STATUS.VERIFIED&&(n.next({asset:r,progress:100}),n.complete())}))}))},r.prototype.prepareAssetUpload=function(e,r){if(r.getStatus()!==asset_1.ASSET_STATUS.NEW){var t='ERROR: Cannot prepare upload, status not "NEW".';return console.log(t),(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_ASSET_STATUS,null,t))}return r.setStatus(asset_1.ASSET_STATUS.PREPARING),this.httpsService.post("assets",{domainId:e}).pipe((0,operators_1.tap)((function(e){r.referenceId=e.assetId,r.uploadUrl=e.url,r.setStatus(asset_1.ASSET_STATUS.PREPARED)})))},r.prototype.verifyAsset=function(e){if(e.getStatus()!==asset_1.ASSET_STATUS.UPLOADED){var r='ERROR: Cannot verify asset, status not "UPLOADED".';return console.log(r),(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_ASSET_STATUS,null,r))}return e.setStatus(asset_1.ASSET_STATUS.VERIFYING),this.httpsService.post("assets/".concat(e.referenceId,"/verify"),{}).pipe((0,operators_1.tap)((function(){return e.setStatus(asset_1.ASSET_STATUS.VERIFIED)})))},r=__decorate([(0,injection_identifier_1.InjectionIdentifier)("AssetService")],r)}(base_login_init_service_1.BaseLoginInitService);exports.AssetServiceImpl=AssetServiceImpl;
@@ -0,0 +1,13 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable } from "rxjs";
3
+ import { SearchFilter } from "../../models/search-filter";
4
+ /**
5
+ * Interface that defines uploaders for different kind of filters that can be handled by the search-filter.service
6
+ * Implementing classes should implement the upload behavior for the respective type of filter.
7
+ */
8
+ export interface FilterUploader {
9
+ reset(): any;
10
+ uploadFilters(filters: {
11
+ [filterKey: string]: SearchFilter;
12
+ }, searchSessionId: string): Observable<void>;
13
+ }
@@ -0,0 +1,2 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,17 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable } from 'rxjs';
3
+ import { HttpsService } from '../../../core';
4
+ import { SearchFilter } from '../../models/search-filter';
5
+ import { FilterUploader } from './filter-uploader';
6
+ /**
7
+ * Implementation of the FilterUploader to update the search filters on the backend
8
+ */
9
+ export declare class UpdateFiltersUploader implements FilterUploader {
10
+ private httpsService;
11
+ constructor(httpsService: HttpsService);
12
+ reset(): void;
13
+ uploadFilters(filters: {
14
+ [filterKey: string]: SearchFilter;
15
+ }, searchSessionId: string): Observable<void>;
16
+ private createUpdateFiltersOptions;
17
+ }
@@ -0,0 +1,2 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ "use strict";var __assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var l in r=arguments[t])Object.prototype.hasOwnProperty.call(r,l)&&(e[l]=r[l]);return e},__assign.apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.UpdateFiltersUploader=void 0;var core_1=require("../../../core"),search_filter_1=require("../../models/search-filter"),update_filters_model_1=require("./update-filters.model"),UpdateFiltersUploader=function(){function e(e){this.httpsService=e}return e.prototype.reset=function(){},e.prototype.uploadFilters=function(e,r){console.log("UpdateFiltersUploader.uploadFilters() searchSessionId: ".concat(r,", filters: "),e);var t=this.createUpdateFiltersOptions(e);return this.httpsService.patch("search/".concat(r),{method:"updateFilters",options:{updateFilters:__assign({},t)}})},e.prototype.createUpdateFiltersOptions=function(e){for(var r={},t=0,a=Object.entries(e);t<a.length;t++){var l=a[t],s=l[0],i=l[1];switch(i.type){case search_filter_1.SearchFilterType.KvpHardFilter:r[update_filters_model_1.KVP_HARD_FILTERS_KEY]||(r[update_filters_model_1.KVP_HARD_FILTERS_KEY]=[]);var o=i;r[update_filters_model_1.KVP_HARD_FILTERS_KEY].push({label:o.label,values:o.values});break;case search_filter_1.SearchFilterType.IncludeExcludeFilter:var c=i;r[s]={include:c.include,exclude:c.exclude};break;case search_filter_1.SearchFilterType.CategoryFilter:var p=i;r[s]={value:Array.isArray(p.value)?p.value:[p.value]};break;default:throw new core_1.SdkError(core_1.SDK_ERROR_CODES.UNKNOWN_ERROR,null,"Can not upload search filter - unsupported SearchFilterType: ".concat(i.type," (key: ").concat(i.key,")"))}}return r},e}();exports.UpdateFiltersUploader=UpdateFiltersUploader;
@@ -0,0 +1,19 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { HierarchyPartiumIdFilter } from "../../models/search-filter";
3
+ export type CategoryFilterToAPI = {
4
+ value: string[];
5
+ };
6
+ export type IncludeExcludeFilterToAPI = {
7
+ include: string[];
8
+ exclude: string[];
9
+ };
10
+ export declare const KVP_HARD_FILTERS_KEY = "hard-filters";
11
+ export type KvpHardFilterToAPI = {
12
+ label: string;
13
+ values: string[];
14
+ };
15
+ export type UpdateFiltersOptionsToAPI = {
16
+ [HierarchyPartiumIdFilter.KEY]?: IncludeExcludeFilterToAPI;
17
+ [KVP_HARD_FILTERS_KEY]?: KvpHardFilterToAPI[];
18
+ [filterKey: string]: CategoryFilterToAPI | IncludeExcludeFilterToAPI | KvpHardFilterToAPI[];
19
+ };
@@ -0,0 +1,2 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KVP_HARD_FILTERS_KEY=void 0;var search_filter_1=require("../../models/search-filter");exports.KVP_HARD_FILTERS_KEY="hard-filters";
@@ -0,0 +1,103 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { SearchStatus } from '../../models/search-status/search-status';
3
+ import { ImageCropArea } from '../../models/search-status/cv-search-status';
4
+ import { Observable } from 'rxjs';
5
+ import { Asset } from '../../models/assets/asset';
6
+ import { PFile } from '../../../core/models/p-file';
7
+ import { BaseService } from '../../../core/services/base.service';
8
+ import { ServiceProvider } from '../../../core/services/service-provider';
9
+ /**
10
+ * Service for creating CV-searches.
11
+ *
12
+ * @deprecated use SearchService.performSearch instead
13
+ */
14
+ export interface CvSearchService {
15
+ /**
16
+ * Performs image recognition with the given ImageAsset
17
+ *
18
+ * @param imageAsset Asset of the image that should be used for image search (the image needs
19
+ * to be uploaded as Asset already beforehand)
20
+ * @param cropArea (optional) Crop area of the image that should be used to highlight the area of interest of the image (defined by user)
21
+ * x1/y1 defines the top left point of the crop-rectangle, x2/y2 the bottom right one (values in percent [0,1])
22
+ *
23
+ * The crop area parameter is optional to allow performing a partial image search that uses the whole image as input.
24
+ * Certain parts in the image search require a crop area to work, so depending on the organization configuration without the crop area it only returns search tags rather than search results.
25
+ * It is possible to call this method again at a later time to update the search with the crop area to receive search results.
26
+ *
27
+ * @returns promise that resolves when the image was successfully added to the search
28
+ *
29
+ * @deprecated use SearchService.performSearch instead
30
+ */
31
+ performCV(imageAsset: Asset, cropArea?: ImageCropArea): Promise<void>;
32
+ /**
33
+ * @deprecated use SearchService.performSearch instead
34
+ */
35
+ performCVObs(imageAsset: Asset, cropArea?: ImageCropArea): Observable<void>;
36
+ /**
37
+ * Get a subscription for always getting the current CV-Image
38
+ *
39
+ * @returns Observable that emits the current CV image whenever it changes
40
+ *
41
+ * @deprecated use SearchService.performSearch instead
42
+ */
43
+ getCvImage(): Observable<PFile>;
44
+ /**
45
+ * Get an Observable that always resolves with the latest CV-Image value
46
+ * when a search is performed.
47
+ *
48
+ * @returns Observable that always resolves with the latest CV-Image value whenever changed
49
+ *
50
+ * @deprecated use SearchService.performSearch instead
51
+ */
52
+ getCvImageValue(): Observable<PFile>;
53
+ }
54
+ export declare class CvSearchServiceImpl extends BaseService implements CvSearchService {
55
+ private httpsService;
56
+ private searchResultService;
57
+ private assetService;
58
+ private searchStatus;
59
+ private cvStatus;
60
+ private cvImage$;
61
+ constructor(serviceProvider: ServiceProvider);
62
+ onCreate(): void;
63
+ /**
64
+ * Reset the CV search status.
65
+ * Is called on Creation of a new search
66
+ */
67
+ reset(searchStatus: SearchStatus): void;
68
+ /**
69
+ * Set the cv-search-status to a certain status.
70
+ * This can happen if an old search-session is loaded or a change of the search-input
71
+ * was initiated on the backend-side.
72
+ *
73
+ * Will set the assetId and crop area, but not download the asset itself. It has to
74
+ * be downloaded separately if needed.
75
+ *
76
+ * @param searchStatus the search-status object
77
+ * @param assetId id of the search-image
78
+ * @param searchConfig the search-config of the old session (if null => use default)
79
+ */
80
+ setStatusExternal(searchStatus: SearchStatus, assetId: string, cropArea: ImageCropArea): void;
81
+ performCV(imageAsset: Asset, cropArea?: ImageCropArea): Promise<void>;
82
+ performCVObs(imageAsset: Asset, cropArea?: ImageCropArea): Observable<void>;
83
+ /**
84
+ * Always get the latest CV-image, whenever it changes. If the image is
85
+ * not there, but an assetId is available (eg: after reloading an old
86
+ * search-session), download the image in the given size and provide it.
87
+ * Else return undefined.
88
+ *
89
+ * @param size desired size of the image (will only take effect if the image
90
+ * is not already present, which will be the case if the image was taken
91
+ * during the current search-session)
92
+ * @returns Observable that emits the current CV image whenever it changes
93
+ * or the downloaded one, if none was present
94
+ */
95
+ getCvImage(size?: string): Observable<PFile>;
96
+ getCvImageValue(): Observable<PFile>;
97
+ /**
98
+ * Check if the crop area is valid and throw error if not.
99
+ *
100
+ * @param cropArea the crop area to check
101
+ */
102
+ private ensureCropAreaIsValid;
103
+ }
@@ -0,0 +1,2 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ "use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},__awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function c(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,c)}a((i=i.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,i,n,s,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function c(c){return function(a){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&c[0]?i.return:c[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,c[1])).done)return n;switch(i=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,i=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]<n[3])){o.label=c[1];break}if(6===c[0]&&o.label<n[1]){o.label=n[1],n=c;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(c);break}n[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],i=0}finally{r=n=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CvSearchServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),search_result_service_1=require("./search-result.service"),asset_service_1=require("../asset.service"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),base_service_1=require("../../../core/services/base.service"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),file_transfer_service_interface_1=require("../../../core/services/http/file-transfer/file-transfer.service.interface"),core_1=require("../../../core"),CvSearchServiceImpl=function(e){function t(t){var r=e.call(this,t)||this;return r.cvImage$=new rxjs_1.BehaviorSubject(null),r}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.searchResultService=this.serviceProvider.getService(search_result_service_1.SearchResultService),this.assetService=this.serviceProvider.getService(asset_service_1.AssetServiceImpl)},t.prototype.reset=function(e){this.searchStatus=e,this.cvStatus=e.cvSearchStatus,this.cvImage$.next(null)},t.prototype.setStatusExternal=function(e,t,r){var i=t!==this.cvStatus.assetId;this.searchStatus=e,this.cvStatus=e.cvSearchStatus,this.cvStatus.assetId=t,this.cvStatus.cropArea=r,i&&this.cvImage$.next(null)},t.prototype.performCV=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,this.performCVObs(e,t).toPromise()]}))}))},t.prototype.performCVObs=function(e,t){var r=this;return t&&this.ensureCropAreaIsValid(t),this.cvStatus.setImage(e),this.cvStatus.cropArea=t,this.cvImage$.next(e.file),this.httpsService.patch("search/".concat(this.searchStatus.searchSessionID),{method:"imageSearch",options:{imageSearch:__assign({assetId:e.referenceId},t?{cropArea:t}:null)}}).pipe((0,operators_1.tap)((function(){r.searchResultService.startPollingForResults()})))},t.prototype.getCvImage=function(e){var t=this;return void 0===e&&(e="original"),this.cvImage$.pipe((0,operators_1.mergeMap)((function(r){var i;return r?(0,rxjs_1.of)(r):(null===(i=t.cvStatus)||void 0===i?void 0:i.assetId)?t.assetService.downloadImage(t.cvStatus.assetId,e,https_service_interface_1.BACKEND_SERVICE.FIND).pipe((0,operators_1.filter)((function(e){return e.status===file_transfer_service_interface_1.TRANSFER_STATUS.TRANSFER_FINISHED})),(0,operators_1.map)((function(e){return e.file}))):(0,rxjs_1.of)(void 0)})))},t.prototype.getCvImageValue=function(){return this.cvImage$.asObservable()},t.prototype.ensureCropAreaIsValid=function(e){if(e.x1<0||e.x1>1||e.x2<0||e.x2>1||e.y1<0||e.y1>1||e.y2<0||e.y2>1)throw new core_1.SdkError(core_1.SDK_ERROR_CODES.INVALID_CROP_AREA,null,"All values of the crop-area must be in the range [0;1].");if(e.x1>e.x2||e.y1>e.y2)throw new core_1.SdkError(core_1.SDK_ERROR_CODES.INVALID_CROP_AREA,null,"The point x1/y1 must be on the top left of x2/y2.");if(e.x1===e.x2||e.y1===e.y2)throw new core_1.SdkError(core_1.SDK_ERROR_CODES.INVALID_CROP_AREA,null,"The width and height of the crop area must be greater than 0.")},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("CvSearchService")],t)}(base_service_1.BaseService);exports.CvSearchServiceImpl=CvSearchServiceImpl;
@@ -0,0 +1,89 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable } from 'rxjs';
3
+ import { ServiceProvider } from '../../../core/services/service-provider';
4
+ import { PartiumConfig } from '../../../core/models/partium-config';
5
+ import { BaseLoginInitService } from '../../../core/services/base-login-init.service';
6
+ import { Organization } from '../../../core';
7
+ /**
8
+ * Service that provides functions for maintaining the recent text searches.
9
+ * Recent search queries can be managed in a stack and will be stored
10
+ * in local storage for later sessions.
11
+ */
12
+ export interface RecentTextSearchQueriesService {
13
+ /**
14
+ * Add new query to the recent queries
15
+ * @param query the query to add
16
+ */
17
+ addQuery(query: string): void;
18
+ /**
19
+ * Add new query to the recent queries
20
+ * The query will be added as semantic query
21
+ * @param query the query to add
22
+ * @deprecated use addQuery instead
23
+ */
24
+ addSemanticTextQuery(query: string): void;
25
+ /**
26
+ * Add new query to the recent queries
27
+ * The query will be added as exact query
28
+ * @param query the query to add
29
+ * @deprecated use addQuery instead
30
+ */
31
+ addExactTextQuery(query: string): void;
32
+ /**
33
+ * Get the recent text search queries as observable, but only after init is finished.
34
+ * @returns Observable that emits every time the recent search query changes
35
+ */
36
+ getQueries(): Observable<string[]>;
37
+ /**
38
+ * Get the recent semantic text search queries as observable, but only after init is finished.
39
+ * @returns Observable that emits every time the recent search query changes
40
+ * @deprecated use getQueries instead
41
+ */
42
+ getSemanticTextQueries$(): Observable<string[]>;
43
+ /**
44
+ * Get the recent exact text search queries as observable, but only after init is finished.
45
+ * @returns Observable that emits every time the recent search query changes
46
+ * @deprecated use getQueries instead
47
+ */
48
+ getExactTextQueries$(): Observable<string[]>;
49
+ /**
50
+ * Reset the service
51
+ * Called on logout
52
+ */
53
+ reset(): void;
54
+ }
55
+ export declare class RecentTextSearchQueriesServiceImpl extends BaseLoginInitService implements RecentTextSearchQueriesService {
56
+ private RECENT_QUERIES_STORE_COUNT;
57
+ private localStorageService;
58
+ private readonly recentSearchQueries$;
59
+ private readonly recentSemanticTextQueries$;
60
+ private readonly recentExactTextQueries$;
61
+ private initFinished$;
62
+ private initFinishedResolve;
63
+ constructor(serviceProvider: ServiceProvider);
64
+ onCreate(): void;
65
+ /**
66
+ * Called on login
67
+ */
68
+ init(config: PartiumConfig, userEmail: string, currentOrganization$: Observable<Organization>): Observable<void>;
69
+ addQuery(query: string): Promise<void>;
70
+ addSemanticTextQuery(query: string): Promise<void>;
71
+ addExactTextQuery(query: string): Promise<void>;
72
+ getQueries(): Observable<string[]>;
73
+ getSemanticTextQueries$(): Observable<string[]>;
74
+ getExactTextQueries$(): Observable<string[]>;
75
+ reset(): void;
76
+ private addQueryToLocalStorage;
77
+ /**
78
+ * Loads the recent parts from local storage and returns them.
79
+ *
80
+ * @return array that contains the ids of the recent parts loaded from the localstorage
81
+ */
82
+ private loadRecentQueries;
83
+ /**
84
+ * Loads the recent queries from local storage and returns them.
85
+ *
86
+ * @return array that contains the loaded recent text-search queries
87
+ */
88
+ private getQueriesFromLocalStorage;
89
+ }
@@ -0,0 +1,2 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ "use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),__decorate=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},__awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,o){function s(e){try{a(i.next(e))}catch(e){o(e)}}function c(e){try{a(i.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,c)}a((i=i.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(a){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(s=0)),s;)try{if(r=1,i&&(n=2&c[0]?i.return:c[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,c[1])).done)return n;switch(i=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,i=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]<n[3])){s.label=c[1];break}if(6===c[0]&&s.label<n[1]){s.label=n[1],n=c;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(c);break}n[2]&&s.ops.pop(),s.trys.pop();continue}c=t.call(e,s)}catch(e){c=[6,e],i=0}finally{r=n=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RecentTextSearchQueriesServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),local_storage_service_interface_1=require("../../../core/services/local-storage.service.interface"),session_service_interface_1=require("../../../core/services/session/session.service.interface"),base_login_init_service_1=require("../../../core/services/base-login-init.service"),RecentTextSearchQueriesServiceImpl=function(e){function t(t){var r=e.call(this,t)||this;return r.RECENT_QUERIES_STORE_COUNT=10,r.recentSearchQueries$=new rxjs_1.BehaviorSubject([]),r.recentSemanticTextQueries$=new rxjs_1.BehaviorSubject([]),r.recentExactTextQueries$=new rxjs_1.BehaviorSubject([]),r.reset(),r}return __extends(t,e),t.prototype.onCreate=function(){var e=this;this.localStorageService=this.serviceProvider.getService(local_storage_service_interface_1.LocalStorageService),this.serviceProvider.getService(session_service_interface_1.SessionService).getSessionStatusEvents().subscribe((function(t){t===session_service_interface_1.SESSION_STATUS_EVENT.SESSION_ENDED&&e.reset()}))},t.prototype.init=function(t,r,i){var n=this;return e.prototype.init.call(this,t,r,i),this.currentOrganization$.pipe((0,operators_1.filter)((function(e){return!!e})),(0,operators_1.skip)(1),(0,operators_1.distinctUntilChanged)()).subscribe((function(){n.loadRecentQueries()})),this.loadRecentQueries().then((function(){n.initFinishedResolve&&n.initFinishedResolve()})),(0,rxjs_1.of)(void 0)},t.prototype.addQuery=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.addQueryToLocalStorage(e,"RECENT_SEARCH_QUERIES")];case 1:return t=r.sent(),this.recentSearchQueries$.next(t),[2]}}))}))},t.prototype.addSemanticTextQuery=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.addQueryToLocalStorage(e,"RECENT_SEMANTIC_SEARCH_QUERIES")];case 1:return t=r.sent(),this.recentSemanticTextQueries$.next(t),[2]}}))}))},t.prototype.addExactTextQuery=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.addQueryToLocalStorage(e,"RECENT_EXACT_SEARCH_QUERIES")];case 1:return t=r.sent(),this.recentExactTextQueries$.next(t),[2]}}))}))},t.prototype.getQueries=function(){var e=this;return(0,rxjs_1.from)(this.initFinished$).pipe((0,operators_1.mergeMap)((function(){return e.recentSearchQueries$.asObservable()})))},t.prototype.getSemanticTextQueries$=function(){var e=this;return(0,rxjs_1.from)(this.initFinished$).pipe((0,operators_1.mergeMap)((function(){return e.recentSemanticTextQueries$.asObservable()})))},t.prototype.getExactTextQueries$=function(){var e=this;return(0,rxjs_1.from)(this.initFinished$).pipe((0,operators_1.mergeMap)((function(){return e.recentExactTextQueries$.asObservable()})))},t.prototype.reset=function(){var e=this;this.recentSearchQueries$.next([]),this.recentSemanticTextQueries$.next([]),this.recentExactTextQueries$.next([]),this.initFinished$=new Promise((function(t,r){e.initFinishedResolve=t}))},t.prototype.addQueryToLocalStorage=function(e,t){return __awaiter(this,void 0,void 0,(function(){var r,i;return __generator(this,(function(n){switch(n.label){case 0:return[4,this.localStorageService.getItem(t)];case 1:return r=n.sent(),i=(i=r?JSON.parse(r):[]).filter((function(t){return t!==e})),i=(i=__spreadArray([e],i,!0)).slice(0,this.RECENT_QUERIES_STORE_COUNT),this.localStorageService.setItem(t,JSON.stringify(i)),[2,i]}}))}))},t.prototype.loadRecentQueries=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,r,i;return __generator(this,(function(n){switch(n.label){case 0:return[4,Promise.all([this.getQueriesFromLocalStorage("RECENT_SEARCH_QUERIES"),this.getQueriesFromLocalStorage("RECENT_SEMANTIC_SEARCH_QUERIES"),this.getQueriesFromLocalStorage("RECENT_EXACT_SEARCH_QUERIES")])];case 1:return e=n.sent(),t=e[0],r=e[1],i=e[2],this.recentSearchQueries$.next(t),this.recentSemanticTextQueries$.next(r),this.recentExactTextQueries$.next(i),[2]}}))}))},t.prototype.getQueriesFromLocalStorage=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(i){switch(i.label){case 0:return[4,this.localStorageService.getItem(e)];case 1:return(t=i.sent())?!(r=JSON.parse(t))||r.length<1?[2,[]]:(console.log("".concat(e," - amount of stored recent text-queries in local storage: ").concat(r.length)),[2,r]):[2,[]]}}))}))},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("RecentTextSearchQueriesService")],t)}(base_login_init_service_1.BaseLoginInitService);exports.RecentTextSearchQueriesServiceImpl=RecentTextSearchQueriesServiceImpl;
@@ -0,0 +1,142 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable } from 'rxjs';
3
+ import { SearchStatus } from '../../models/search-status/search-status';
4
+ import { SearchResultStatus } from '../../models/search-result-status';
5
+ import { Part } from '../../../data/models/part';
6
+ import { BaseService } from '../../../core/services/base.service';
7
+ import { SdkError } from '../../../core/models/error';
8
+ import { ServiceProvider } from '../../../core/services/service-provider';
9
+ import { SmartFilter } from '../../models/smart-filter';
10
+ export type CurResultList = {
11
+ results: Part[];
12
+ moreResultsAvailable: boolean;
13
+ };
14
+ /**
15
+ * Service that is responsible for polling for Search-Results, as well as
16
+ * Tags and provide both to listeners.
17
+ *
18
+ * @deprecated use SearchService.performSearch instead
19
+ */
20
+ export declare class SearchResultService extends BaseService {
21
+ private httpsService;
22
+ private partService;
23
+ private tagSearchService;
24
+ private filterService;
25
+ private cvSearchService;
26
+ private textSearchService;
27
+ private searchFilterService;
28
+ private searchStatus;
29
+ private curResultList$;
30
+ private curSmartFilters$;
31
+ private pollingSubscription;
32
+ private loadMoreResultsSubscription;
33
+ private POLLING_INTERVAL;
34
+ private MAX_REQUEST_TIMEOUT;
35
+ private MAX_POLLING_TIMEOUT;
36
+ private prevSearchResultTimestamp;
37
+ private prevProposedTagsUpdatedTimestamp;
38
+ private prevSmartFiltersUpdateTimestamp;
39
+ private searchErrors;
40
+ private RESULT_LIST_LIMIT;
41
+ private resultListSkip;
42
+ private searchResultStatus$;
43
+ private filterKeys;
44
+ constructor(serviceProvider: ServiceProvider);
45
+ onCreate(): void;
46
+ /**
47
+ * Called when new search-session is started
48
+ *
49
+ * @param searchStatus a new search-status
50
+ */
51
+ reset(searchStatus: SearchStatus): void;
52
+ /**
53
+ * Start poll for results of the current search.
54
+ * Polling will be continued until it is cancelled again.
55
+ */
56
+ startPollingForResults(): void;
57
+ /**
58
+ * Stop polling.
59
+ */
60
+ stopPollingForResults(): void;
61
+ /**
62
+ * Get an observable that always emits the current result list (paginated) every
63
+ * time it changes.
64
+ *
65
+ * If an error happens during the search-process in the backend, those errors will also be emitted
66
+ * via this Observable. An error does not necessarily mean, that the whole search failed, search-
67
+ * results might still be emitted. More information can be drawn out of the thrown error.
68
+ *
69
+ * @returns Observable that emits an Object of type CurResultList, every
70
+ * time the results change. CurResults contains the paginated list of
71
+ * results, as well as a boolean, whether more results can be loaded,
72
+ * or the last page was already reached.
73
+ * Emits an SdkError when an error happens during
74
+ * processing of the search result on the backend side.
75
+
76
+ */
77
+ getCurResultList(): Observable<CurResultList | SdkError>;
78
+ getSearchResultStatus(): Observable<SearchResultStatus>;
79
+ getCurResultListLength(): number;
80
+ getCurResultListValue(): Array<Part>;
81
+ getSmartFilters(): Observable<SmartFilter[]>;
82
+ /**
83
+ * Check the response to identify if the proposed search-tags have
84
+ * changed, to emit new ones if necessary
85
+ *
86
+ * @param response the response of a polling request
87
+ * @param newTagsAreAsyncTags true if the newly received tags are async
88
+ */
89
+ private updateProposedTags;
90
+ /**
91
+ * Check the response to identify if it contains new search-results
92
+ * that have not been emitted before.
93
+ *
94
+ * @param response the response of a polling request
95
+ */
96
+ private updateSearchResults;
97
+ /**
98
+ * Update the current search-input status to the values provided from the BE
99
+ * search-session. This can be used to load an older search-session and even
100
+ * allows to continue it.
101
+ *
102
+ * TODO This function is currently only used to load the search-results of an
103
+ * older search-session. Loading of the search-inputs is not fully working yet
104
+ * and should therefore not yet be used.
105
+ *
106
+ * @param response response of the GET search-session request to find
107
+ *
108
+ * @beta
109
+ */
110
+ private updateSearchInput;
111
+ /**
112
+ * Check the response to identify if the smart filters have
113
+ * changed, to emit new ones if necessary
114
+ *
115
+ * @param response the response of a polling request
116
+ */
117
+ private updateSmartFilters;
118
+ private updateFilters;
119
+ private checkIfFiltersChanged;
120
+ private setMappedFilters;
121
+ private mapSelectedFilters;
122
+ /**
123
+ * Check the response to identify new errors that have not been emitted before.
124
+ *
125
+ * @param response the response of a polling request
126
+ */
127
+ private updateErrors;
128
+ private updateCurResultList;
129
+ /**
130
+ * Process raw search results to format as a list of parts with confidences
131
+ *
132
+ * @param results The raw response of a search result request
133
+ * @returns The processed part with confidences list
134
+ */
135
+ private processSearchResults;
136
+ /**
137
+ * Load more results of the current result list, based on RESULT_LIST_LIMIT and resultListSkip values
138
+ * The newly loaded results will emit via the getCurResultList-Observable,
139
+ * along with the already known results.
140
+ */
141
+ loadMoreResults(): void;
142
+ }