@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,120 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable } from 'rxjs';
3
+ import { OauthAuthenticationConfig } from '../../models/auth-config';
4
+ import { BACKEND_SERVICE, HttpsService } from './https.service.interface';
5
+ import { ServiceProvider } from '../service-provider';
6
+ /**
7
+ * Implementation of https service that provides authorization with oauth.
8
+ */
9
+ export declare class OauthHttpsService extends HttpsService {
10
+ protected authToken: string;
11
+ protected authTokenExpiresAt: Date;
12
+ private oauthSessionService;
13
+ constructor(serviceProvider: ServiceProvider);
14
+ onCreate(): void;
15
+ /**
16
+ * Initialize the https-service for OAuth authentication.
17
+ * If the configuration contains an API-Key, directly create a
18
+ * user-session, by calling login.
19
+ *
20
+ * @param partiumApiBaseUrl: the public-api-backend base-url
21
+ * @param findBeBaseUrl: the partium-find-backend base-url
22
+ * @param dataBeBaseUrl: the partium-data-backend base-url
23
+ * @param csaBeBaseUrl: the partium-csa-backend base-url
24
+ * @param logBeBaseUrl: the partium-logs-backend base-url
25
+ * @param userDataBeBaseUrl: the partium-user-data-backend base-url
26
+ * @param ocrBeBaseUrl: the partium-ocr-backend base-url
27
+ * @param managementBeBaseUrl: the partium-management-backend base-url
28
+ * @param config the oauth auth-configuration
29
+ */
30
+ init(partiumApiBaseUrl: string, findBeBaseUrl: string, dataBeBaseUrl: string, csaBeBaseUrl: string, logBeBaseUrl: string, userDataBeBaseUrl: string, ocrBeBaseUrl: string, managementBeBaseUrl: string, config: OauthAuthenticationConfig): Observable<void>;
31
+ /**
32
+ * It is not sufficient that the token is set on init, because it can change when for example
33
+ * a refresh is required.
34
+ *
35
+ * @param authToken the auth token
36
+ * @param tokenExpiresAt token expiration timestamp
37
+ */
38
+ setToken(authToken: string, authTokenExpiresAt: Date): void;
39
+ /**
40
+ *
41
+ * Send GET request to the server with the given url and content.
42
+ *
43
+ * Wrap the parent-get into an observable that refreshes the oauth-session if it
44
+ * would expire within the next few seconds otherwise.
45
+ * We do this in order to avoid that requests fail and have to be retried after
46
+ * refresh (which would/does happen automatically)
47
+ *
48
+ * @param url the relative server url
49
+ * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
50
+ * @param beService to which backend-service should the request be sent (default FIND)
51
+ * @returns Observable that resolves with the request result
52
+ */
53
+ get(url: string, urlParams?: Array<Object>, beService?: BACKEND_SERVICE): Observable<any>;
54
+ /**
55
+ *
56
+ * Send POST request to the server with the given url and content.
57
+ *
58
+ * Wrap the parent-post into an observable that refreshes the oauth-session if it
59
+ * would expire within the next few seconds otherwise.
60
+ * We do this in order to avoid that requests fail and have to be retried after
61
+ * refresh (which would/does happen automatically)
62
+ *
63
+ * @param url the relative server url
64
+ * @param data the data to be sent with the post request
65
+ * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
66
+ * @param beService to which backend-service should the request be sent (default FIND)
67
+ * @param headers object with custom headers to send with the request
68
+ * @returns Observable that resolves with the request result
69
+ */
70
+ post(url: string, data: Object, urlParams?: Array<Object>, beService?: BACKEND_SERVICE, headers?: Object): Observable<any>;
71
+ /**
72
+ *
73
+ * Send PATCH request to the server with the given url and content.
74
+ *
75
+ * Wrap the parent-patch into an observable that refreshes the oauth-session if it
76
+ * would expire within the next few seconds otherwise.
77
+ * We do this in order to avoid that requests fail and have to be retried after
78
+ * refresh (which would/does happen automatically)
79
+ *
80
+ * @param url the relative server url
81
+ * @param data the data to be sent with the patch request
82
+ * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
83
+ * @param beService to which backend-service should the request be sent (default FIND)
84
+ * @param headers object with custom headers to send with the request
85
+ * @returns Observable that resolves with the request result
86
+ */
87
+ patch(url: string, data: Object, urlParams?: Array<Object>, beService?: BACKEND_SERVICE, headers?: Object): Observable<any>;
88
+ /**
89
+ * Called whenever a request fails to decide whether it should be
90
+ * repeated or not.
91
+ * If the request failed because the access-token expired, the session
92
+ * is refreshed and the request retried afterwards.
93
+ *
94
+ * @param errors the errors Observable given by rxjs-retryWhen
95
+ */
96
+ protected retryWhen(errors: Observable<any>): Observable<any>;
97
+ /**
98
+ * Overwrite the parent-class createHeaders to add the authentication-token
99
+ * to the request.
100
+ *
101
+ * @param options object with given header-parameters that will be extended with more parameters
102
+ * @returns the created headers object
103
+ */
104
+ protected createHeaders(options?: Object): Object;
105
+ private callOauthLogin;
106
+ /**
107
+ * Check whether the session will expire within the next few seconds.
108
+ * If so, refresh the access-token, before continuing
109
+ *
110
+ * @returns true if the session will only be valid for a few more seconds, false otherwise
111
+ */
112
+ private refreshSessionIfNeeded;
113
+ /**
114
+ * Try to refresh the current session.
115
+ * If the refresh fails, because the refresh-token is expired, try to login again.
116
+ *
117
+ * @returns Observable of the refresh/login request
118
+ */
119
+ private refreshOrLogin;
120
+ }
@@ -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 o(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.OauthHttpsService=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),https_service_interface_1=require("./https.service.interface"),error_1=require("../../models/error"),oauth_session_service_1=require("../session/oauth-session.service"),session_service_interface_1=require("../session/session.service.interface"),OauthHttpsService=function(e){function r(r){return e.call(this,r)||this}return __extends(r,e),r.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.oauthSessionService=this.serviceProvider.getService(session_service_interface_1.SessionService)},r.prototype.init=function(r,t,o,i,n,s,p,c,a){return e.prototype.init.call(this,r,t,o,i,n,s,p,c,a),a.apiKey?this.callOauthLogin():(0,rxjs_1.of)(void 0)},r.prototype.setToken=function(e,r){this.authToken=e,this.authTokenExpiresAt=r},r.prototype.get=function(r,t,o){var i=this;return this.refreshSessionIfNeeded().pipe((0,operators_1.mergeMap)((function(){return e.prototype.get.call(i,r,t,o)})))},r.prototype.post=function(r,t,o,i,n){var s=this;return this.refreshSessionIfNeeded().pipe((0,operators_1.mergeMap)((function(){return e.prototype.post.call(s,r,t,o,i,n)})))},r.prototype.patch=function(r,t,o,i,n){var s=this;return this.refreshSessionIfNeeded().pipe((0,operators_1.mergeMap)((function(){return e.prototype.patch.call(s,r,t,o,i,n)})))},r.prototype.retryWhen=function(e){var r=this;return e.pipe((0,operators_1.mergeMap)((function(e){return e.code===error_1.SDK_ERROR_CODES.TOKEN_EXPIRED?(console.log("HttpsService - Token expired, attempting refresh"),r.refreshOrLogin()):(0,rxjs_1.throwError)(e)})))},r.prototype.createHeaders=function(e){var r={"Content-Type":"application/json"};return this.authToken&&(r.Authorization="Bearer ".concat(this.authToken)),Object.assign(r,e)},r.prototype.callOauthLogin=function(){var e=this.config;return this.oauthSessionService.login(new oauth_session_service_1.OauthLoginConfig({apiKey:e.apiKey}))},r.prototype.refreshSessionIfNeeded=function(){var e=!1;this.authTokenExpiresAt?e=(Date.now()/1e3|0)>this.authTokenExpiresAt.getTime()/1e3-60:e=!0;return e?this.refreshOrLogin():(0,rxjs_1.of)(void 0)},r.prototype.refreshOrLogin=function(){var e=this;return this.oauthSessionService.refresh().pipe((0,operators_1.catchError)((function(r){return r.code===error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED||r.code===error_1.SDK_ERROR_CODES.INVALID_TOKEN||r.code===error_1.SDK_ERROR_CODES.BAD_REQUEST||r.code===error_1.SDK_ERROR_CODES.OAUTH_ERROR?e.callOauthLogin().pipe((0,operators_1.catchError)((function(e){return e.code===error_1.SDK_ERROR_CODES.INVALID_LOGIN_CONFIG?(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED,r)):(0,rxjs_1.throwError)(e)}))):(0,rxjs_1.throwError)(r)})))},r}(https_service_interface_1.HttpsService);exports.OauthHttpsService=OauthHttpsService;
@@ -0,0 +1,221 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable } from "rxjs";
3
+ import { PartiumConfig } from "../models/partium-config";
4
+ import { Organization } from "../models/organization";
5
+ import { BaseLoginInitService } from "./base-login-init.service";
6
+ export type KeyPrefixParams = {
7
+ userEmail: boolean;
8
+ organizationName: boolean;
9
+ };
10
+ /**
11
+ * Class that defines structure of a localStorage-service implementation.
12
+ * It contains functions that are required for reading and writing data
13
+ * to the devices localStorage.
14
+ *
15
+ * An implementation of this service is required and has to be configured during
16
+ * the initialization phase of Partium.
17
+ *
18
+ * This class file is called interface, even though it is not an interface,
19
+ * but we need it to be a concrete class for the serviceProvider.
20
+ */
21
+ export declare class LocalStorageService extends BaseLoginInitService {
22
+ private organizationName;
23
+ /**
24
+ * Initializes the LocalStorageService: Configures the service based on the passed Partium configuration.
25
+ *
26
+ * Note: Should be called at the start of a session
27
+ * to ensure the correct recent parts are loaded
28
+ */
29
+ init(config: PartiumConfig, userEmail: string, currentOrganization$: Observable<Organization>): Observable<void>;
30
+ /**
31
+ * Sets the value of the pair identified by key to value, creating a new
32
+ * key/value pair if none existed for key previously.
33
+ *
34
+ * Method should be overridden by child-class
35
+ *
36
+ * @param key the key to identify the pair
37
+ * @param value the value as string
38
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
39
+ * @returns promise that resolves as soon as the value is stored
40
+ */
41
+ setItem(_key: string, _value: string, _keyPrefixParams?: KeyPrefixParams): Promise<void>;
42
+ /**
43
+ * Sets the value of the pair identified by key to value, creating a new
44
+ * key/value pair if none existed for key previously.
45
+ *
46
+ * This method should not be used inside the SDK. It's purpose is only for integrators from outside.
47
+ * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
48
+ * interaction with the local storage.
49
+ *
50
+ * Method should be overridden by child-class
51
+ *
52
+ * @param key the key to identify the pair
53
+ * @param value the value as string
54
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
55
+ */
56
+ setItemSync(_key: string, _value: string, _keyPrefixParams?: KeyPrefixParams): void;
57
+ /**
58
+ * Sets a series of key-value pairs
59
+ *
60
+ * Method should be overridden by child class
61
+ *
62
+ * @param keyValuePairs the array of key-value-pairs [['k1', 'val1'], ['k2', 'val2']]
63
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
64
+ * @returns promise that resolves as soon as all pairs are stored
65
+ */
66
+ setItems(_keyValuePairs: [string, string][], _keyPrefixParams?: KeyPrefixParams): Promise<void>;
67
+ /**
68
+ * Sets a series of key-value pairs
69
+ *
70
+ * This method should not be used inside the SDK. It's purpose is only for integrators from outside.
71
+ * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
72
+ * interaction with the local storage.
73
+ *
74
+ * Method should be overridden by child class
75
+ *
76
+ * @param keyValuePairs the array of key-value-pairs [['k1', 'val1'], ['k2', 'val2']]
77
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
78
+ */
79
+ setItemsSync(_keyValuePairs: [string, string][], _keyPrefixParams?: KeyPrefixParams): void;
80
+ /**
81
+ * Returns the current value associated with the given key, or null if the given
82
+ * key does not exist in the list associated with the object.
83
+ *
84
+ * Method should be overridden by child-class
85
+ *
86
+ * @param key the key to identify the pair
87
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
88
+ * @returns string-value of the item stored by the given key, or null if not found
89
+ */
90
+ getItem(_key: string, _keyPrefixParams?: KeyPrefixParams): Promise<string | undefined>;
91
+ /**
92
+ * Returns the current value associated with the given key, or null if the given
93
+ * key does not exist in the list associated with the object.
94
+ *
95
+ * This method should not be used inside the SDK. It's purpose is only for integrators from outside.
96
+ * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
97
+ * interaction with the local storage.
98
+ *
99
+ * Method should be overridden by child-class
100
+ *
101
+ * @param key the key to identify the pair
102
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
103
+ * @returns string-value of the item stored by the given key, or null if not found
104
+ */
105
+ getItemSync(_key: string, _keyPrefixParams?: KeyPrefixParams): string | undefined;
106
+ /**
107
+ * Returns the current value for each of the given keys, or null if the given
108
+ * keys does not exist in the list associated with the object.
109
+ *
110
+ * Method should be overridden by child-class
111
+ *
112
+ * @param keys array of keys to retrieve
113
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
114
+ * @returns array of string-values of the items stored by the given keys, or null if not found
115
+ */
116
+ getItems(_keys: string[], _keyPrefixParams?: KeyPrefixParams): Promise<string[] | undefined>;
117
+ /**
118
+ * Returns the current value for each of the given keys, or null if the given
119
+ * keys does not exist in the list associated with the object.
120
+ *
121
+ * This method should not be used inside the SDK. It's purpose is only for integrators from outside.
122
+ * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
123
+ * interaction with the local storage.
124
+ *
125
+ * Method should be overridden by child-class
126
+ *
127
+ * @param keys array of keys to retrieve
128
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
129
+ * @returns array of string-values of the items stored by the given keys, or null if not found
130
+ */
131
+ getItemsSync(_keys: string[], _keyPrefixParams?: KeyPrefixParams): string[] | undefined;
132
+ /**
133
+ * Returns all key-value pairs
134
+ *
135
+ * Method should be overridden by child class
136
+ *
137
+ * @returns array of string-value of all the stored items
138
+ */
139
+ getAll(): Promise<[string, string][]>;
140
+ /**
141
+ * Returns all key-value pairs
142
+ *
143
+ * This method should not be used inside the SDK. It's purpose is only for integrators from outside.
144
+ * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
145
+ * interaction with the local storage.
146
+ *
147
+ * Method should be overridden by child class
148
+ *
149
+ * @returns array of string-value of all the stored items
150
+ */
151
+ getAllSync(): [string, string][];
152
+ /**
153
+ * Delete a key-value pair
154
+ *
155
+ * Method should be overridden by child class
156
+ *
157
+ * @param key the key to identify the pair
158
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
159
+ */
160
+ deleteItem(_key: string, _keyPrefixParams?: KeyPrefixParams): Promise<void>;
161
+ /**
162
+ * Delete a key-value pair
163
+ *
164
+ * This method should not be used inside the SDK. It's purpose is only for integrators from outside.
165
+ * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
166
+ * interaction with the local storage.
167
+ *
168
+ * Method should be overridden by child class
169
+ *
170
+ * @param key the key to identify the pair
171
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
172
+ */
173
+ deleteItemSync(_key: string, _keyPrefixParams?: KeyPrefixParams): void;
174
+ /**
175
+ * Delete a series of key-value pairs
176
+ *
177
+ * Method should be overridden by child class
178
+ *
179
+ * @param keys the keys to identify the pairs
180
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
181
+ */
182
+ deleteItems(_keys: string[], _keyPrefixParams?: KeyPrefixParams): Promise<void>;
183
+ /**
184
+ * Delete a series of key-value pairs
185
+ *
186
+ * This method should not be used inside the SDK. It's purpose is only for integrators from outside.
187
+ * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
188
+ * interaction with the local storage.
189
+ *
190
+ * Method should be overridden by child class
191
+ *
192
+ * @param keys the keys to identify the pairs
193
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
194
+ */
195
+ deleteItemsSync(_keys: string[], _keyPrefixParams?: KeyPrefixParams): void;
196
+ /**
197
+ * Returns true if an item with the given key exists, false otherwise.
198
+ *
199
+ * Method should be overridden by child-class
200
+ *
201
+ * @param key the key to identify the item
202
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
203
+ * @returns true if the item exists, false otherwise
204
+ */
205
+ hasItem(_key: string, _keyPrefixParams?: KeyPrefixParams): Promise<boolean>;
206
+ /**
207
+ * Returns true if an item with the given key exists, false otherwise.
208
+ *
209
+ * This method should not be used inside the SDK. It's purpose is only for integrators from outside.
210
+ * The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
211
+ * interaction with the local storage.
212
+ *
213
+ * Method should be overridden by child-class
214
+ *
215
+ * @param key the key to identify the item
216
+ * @param keyPrefixParams optional parameters to prefix the key with different prefix-options
217
+ * @returns true if the item exists, false otherwise
218
+ */
219
+ hasItemSync(_key: string, _keyPrefixParams?: KeyPrefixParams): boolean;
220
+ protected getPrefixedKey(key: string, keyPrefixParams?: KeyPrefixParams): string;
221
+ }
@@ -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 o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),__decorate=this&&this.__decorate||function(e,t,r,o){var n,i=arguments.length,s=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(i<3?n(s):i>3?n(t,r,s):n(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},__awaiter=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(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((o=o.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,o,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(s=0)),s;)try{if(r=1,o&&(n=2&c[0]?o.return:c[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,c[1])).done)return n;switch(o=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++,o=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],o=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.LocalStorageService=void 0;var injection_identifier_1=require("../decorators/injection-identifier"),rxjs_1=require("rxjs"),base_login_init_service_1=require("./base-login-init.service"),LocalStorageService=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.init=function(t,r,o){var n=this;return e.prototype.init.call(this,t,r,o),this.currentOrganization$.subscribe((function(e){n.organizationName=e.name})),(0,rxjs_1.of)(void 0)},t.prototype.setItem=function(e,t){return __awaiter(this,arguments,void 0,(function(e,t,r){return void 0===r&&(r={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.setItemSync=function(e,t,r){throw void 0===r&&(r={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.setItems=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.setItemsSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.getItem=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.getItemSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.getItems=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.getItemsSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.getAll=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.getAllSync=function(){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.deleteItem=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.deleteItemSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.deleteItems=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.deleteItemsSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.hasItem=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.hasItemSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.getPrefixedKey=function(e,t){void 0===t&&(t={userEmail:!0,organizationName:!0});var r="";return t.userEmail&&(r+="".concat(this.userEmail,"-")),t.organizationName&&(r+="".concat(this.organizationName,"-")),r+=e},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("LocalStorageService")],t)}(base_login_init_service_1.BaseLoginInitService);exports.LocalStorageService=LocalStorageService;
@@ -0,0 +1,48 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable, Subject } from 'rxjs';
3
+ import { HttpsService } from './http/https.service.interface';
4
+ import { EventLog, EventLogRequestBody } from '../models/log';
5
+ import { BaseLoginInitService } from './base-login-init.service';
6
+ import { PartiumConfig } from '../models/partium-config';
7
+ import { Organization } from '../models/organization';
8
+ /**
9
+ * Service to create search logs (also known as search events)
10
+ */
11
+ export interface LogService {
12
+ /**
13
+ * Sends a User-Journey-Log-Event to the backend.
14
+ * This can be used to send several logs, triggered by the users behavior
15
+ * in the app. This allows to better understand the user flow and improve
16
+ * the system over time.
17
+ *
18
+ * @param eventLog the event to log (type + extra info)
19
+ *
20
+ * @returns Observable that resolves with the sent EventLog, enriched with
21
+ * backend-timestamp and backend eventLog-id
22
+ */
23
+ logEvent(eventLog: EventLog): Observable<EventLog>;
24
+ }
25
+ export declare class LogServiceImpl extends BaseLoginInitService implements LogService {
26
+ protected httpsService: HttpsService;
27
+ /**
28
+ * An observable (and its source) over the logged eventLogs. Useful for hook
29
+ * the logging without catching the subscription. For example, on unit testing.
30
+ */
31
+ protected loggedEventSource: Subject<EventLog>;
32
+ protected externalUserId?: string;
33
+ loggedEvent$: Observable<EventLog>;
34
+ /**
35
+ * Initializes the LogService and configures it based on the passed Partium configuration.
36
+ */
37
+ init(config: PartiumConfig, userEmail: string, currentOrganization$: Observable<Organization>): Observable<void>;
38
+ onCreate(): void;
39
+ logEvent(eventLog: EventLog): Observable<EventLog>;
40
+ /**
41
+ * Create the log request body
42
+ *
43
+ * @param eventLog: EventLog
44
+ *
45
+ * @returns Promise<EventLogRequestBody>
46
+ */
47
+ protected createRequestBody(eventLog: EventLog): Promise<EventLogRequestBody>;
48
+ }
@@ -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 n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},__awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{s(n.next(e))}catch(e){i(e)}}function c(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}s((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.LogServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),injection_identifier_1=require("../decorators/injection-identifier"),https_service_interface_1=require("./http/https.service.interface"),log_1=require("../models/log"),general_helper_1=require("../utils/general-helper"),base_login_init_service_1=require("./base-login-init.service"),LogServiceImpl=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.loggedEventSource=new rxjs_1.Subject,t.loggedEvent$=t.loggedEventSource.asObservable(),t}return __extends(t,e),t.prototype.init=function(t,r,n){var o;return e.prototype.init.call(this,t,r,n),this.externalUserId=null===(o=t.authenticationConfig)||void 0===o?void 0:o.externalUserId,(0,rxjs_1.of)(void 0)},t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService)},t.prototype.logEvent=function(e){var t=this;if(e.data){var r=(0,general_helper_1.camelToSnake)(e.data);e.data=r}e.externalUserId=this.externalUserId;var n=(0,log_1.eventLogRequestResponseAdapter)(e);return(0,rxjs_1.from)(this.createRequestBody(e)).pipe((0,operators_1.mergeMap)((function(e){return t.httpsService.post("events/",e,null,https_service_interface_1.BACKEND_SERVICE.LOG)})),(0,operators_1.tap)((function(){console.log("Logged event: ",e)})),(0,operators_1.map)(n),(0,operators_1.tap)((function(e){return t.loggedEventSource.next(e)})))},t.prototype.createRequestBody=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,(0,rxjs_1.firstValueFrom)(this.currentOrganization$)];case 1:return t=r.sent().partiumId,[2,{version:e.version,organization_id:e.organizationId||t,interface:e.interface,event:e.event,external_user_id:e.externalUserId,data:e.data}]}}))}))},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("LogService")],t)}(base_login_init_service_1.BaseLoginInitService);exports.LogServiceImpl=LogServiceImpl;
@@ -0,0 +1,48 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable } from 'rxjs';
3
+ import { Organization } from '../models/organization';
4
+ import { Role } from '../models/user';
5
+ import { BaseService } from './base.service';
6
+ import { ServiceProvider } from './service-provider';
7
+ export declare class OrganizationService extends BaseService {
8
+ private httpsService;
9
+ private organizations$;
10
+ constructor(serviceProvider: ServiceProvider);
11
+ onCreate(): void;
12
+ /**
13
+ * initializes the service by requesting the backend to get the organizations, and caching them
14
+ * should be called whenever the logged-in user and his associated organization changes (i.e. on login)
15
+ */
16
+ init(): Promise<void>;
17
+ /**
18
+ * gets all organizations of the logged-in user is associated with
19
+ */
20
+ getOrganizations(): Promise<Array<Organization>>;
21
+ /**
22
+ * Gets the first organization of the organization that the logged-in user is associated with, which does not need
23
+ * additional authentication.
24
+ */
25
+ getFirstOrganization(): Promise<Organization | undefined>;
26
+ /**
27
+ * gets an organization by id
28
+ * @param string // organization id
29
+ * @param includeSubOrgs // if true, the organizations sub-orgs will also be included in the response
30
+ * @returns Promise<Organization>
31
+ */
32
+ getOrganization(organizationId: string, includeSubOrgs?: boolean): Promise<Organization | undefined>;
33
+ /**
34
+ * gets the first 100 organizations for the current user by roles
35
+ * @param string[] // roles
36
+ * @returns Promise<Organization>
37
+ * @deprecated use getOrganizationsListByRoles instead
38
+ */
39
+ getOrganizationsByRoles(roles: Role[]): Promise<Organization[]>;
40
+ /**
41
+ * gets all organizations for the current user by roles with reduced organization data. It makes multiple requests to retrieve all the organizations.
42
+ * @param string[] // roles
43
+ * @param pageSize // number
44
+ * @returns Observable<Organization>
45
+ */
46
+ getOrganizationsListByRoles(roles: Role[], pageSize?: number): Observable<Organization[]>;
47
+ private getOrganizationsRequest;
48
+ }
@@ -0,0 +1,2 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ "use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate=this&&this.__decorate||function(t,e,r,n){var i,o=arguments.length,a=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,r,a):i(e,r))||a);return o>3&&a&&Object.defineProperty(e,r,a),a},__awaiter=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},__generator=this&&this.__generator||function(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OrganizationService=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),injection_identifier_1=require("../decorators/injection-identifier"),organization_1=require("../models/organization"),base_service_1=require("./base.service"),https_service_interface_1=require("./http/https.service.interface"),OrganizationService=function(t){function e(e){var r=t.call(this,e)||this;return r.organizations$=new rxjs_1.ReplaySubject(1),r}return __extends(e,t),e.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService)},e.prototype.init=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){switch(e.label){case 0:return console.log("OrganizationService - init"),[4,this.getOrganizationsRequest()];case 1:return t=e.sent(),this.organizations$.next(t.map((function(t){return new organization_1.Organization(t)}))),console.log("..initialized organization.service (organizations: ".concat(t.length,")")),[2]}}))}))},e.prototype.getOrganizations=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.organizations$.pipe((0,operators_1.take)(1)).toPromise()]}))}))},e.prototype.getFirstOrganization=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){switch(e.label){case 0:return[4,this.getOrganizations()];case 1:return[2,(t=e.sent()).find((function(t){return!t.requiresAdditionalAuthentication}))||t[0]]}}))}))},e.prototype.getOrganization=function(t){return __awaiter(this,arguments,void 0,(function(t,e){return void 0===e&&(e=!1),__generator(this,(function(r){return[2,this.httpsService.get("organizations-ui/".concat(t),[{includeSubOrgs:e}],https_service_interface_1.BACKEND_SERVICE.DATA).pipe((0,operators_1.map)((function(t){return organization_1.Organization.fromAPIResponse(t)}))).toPromise()]}))}))},e.prototype.getOrganizationsByRoles=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.httpsService.get("organizations",[{roles:t.join(",")}],https_service_interface_1.BACKEND_SERVICE.DATA).pipe((0,operators_1.map)((function(t){return(t.results||[]).map((function(t){return organization_1.Organization.fromAPIResponse(t)}))}))).toPromise()]}))}))},e.prototype.getOrganizationsListByRoles=function(t,e){var r=this;void 0===e&&(e=1e3);var n="organizations-list";return this.httpsService.get(n,[{roles:t.join(","),page_size:e}],https_service_interface_1.BACKEND_SERVICE.DATA).pipe((0,operators_1.expand)((function(i){var o=!(!i.pagination||!i.pagination.next),a=parseInt(i.pagination.page)+1;return o?r.httpsService.get(n,[{roles:t.join(","),page_size:e,page:a}],https_service_interface_1.BACKEND_SERVICE.DATA):rxjs_1.EMPTY})),(0,operators_1.reduce)((function(t,e){return t.concat(e.results)}),[]),(0,operators_1.takeWhile)((function(t){return null!==t}),!0),(0,operators_1.map)((function(t){return(t||[]).map((function(t){return organization_1.Organization.fromAPIResponse(t)}))})))},e.prototype.getOrganizationsRequest=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.httpsService.get("organizations-ui",[{includeSubOrgs:!0}],https_service_interface_1.BACKEND_SERVICE.DATA).pipe((0,operators_1.map)((function(t){return t.map((function(t){return organization_1.Organization.fromAPIResponse(t)}))}))).toPromise()]}))}))},e=__decorate([(0,injection_identifier_1.InjectionIdentifier)("OrganizationService")],e)}(base_service_1.BaseService);exports.OrganizationService=OrganizationService;
@@ -0,0 +1,104 @@
1
+ // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
+ import { Observable } from 'rxjs';
3
+ import { APIObject } from '../models/api-object';
4
+ import { BACKEND_SERVICE, HttpsService } from './http/https.service.interface';
5
+ import { PaginatedList } from '../models/paginated-list';
6
+ /**
7
+ * Non-injectable Service that fetches data from a paginated API-endpoint.
8
+ * The service is generic and can be used for different types of data.
9
+ *
10
+ * Usage:
11
+ * 1) initialize via constructor for endpoint that it should be used for
12
+ * 2) call loadInitialPage to receive first page from server
13
+ * 3) call loadMore to load the next page from server
14
+ * 4) to access currently loaded paginated list call getLoadedPaginatedList (returns last successfully loaded list from server)
15
+ */
16
+ export interface PaginatedRequestService<T extends APIObject> {
17
+ /**
18
+ * Will trigger loading the first page of objects from the configured endpoint.
19
+ *
20
+ * @param concatResult if true, the lists returned by loadMore() will always
21
+ * contain the full concatenated list of results. If false, it will only
22
+ * contain the current page.
23
+ * @returns observable that emits with an object of type PaginatedList, which
24
+ * contains the items of the current page, the current page-index, the
25
+ * total pages, ...
26
+ */
27
+ loadInitialPage(concatResult?: boolean): Observable<PaginatedList<T>>;
28
+ /**
29
+ * @deprecated use loadInitialPage instead
30
+ *
31
+ * Will trigger loading the first page of objects from the configured endpoint.
32
+ *
33
+ * @param concatResult if true, the lists returned by loadMore() will always
34
+ * contain the full concatenated list of results. If false, it will only
35
+ * contain the current page.
36
+ * @returns observable that emits with an object of type PaginatedList, which
37
+ * contains the items of the current page, the current page-index, the
38
+ * total pages, ...
39
+ */
40
+ getPaginatedList(concatResult?: boolean): Observable<PaginatedList<T>>;
41
+ /**
42
+ * @returns the currently loaded paginated list, which was last successfully loaded from the server
43
+ */
44
+ getLoadedPaginatedList(): PaginatedList<T>;
45
+ /**
46
+ * @returns true if the initial page was loaded successfully, false otherwise
47
+ */
48
+ isInitialPageLoaded(): boolean;
49
+ /**
50
+ * @returns true if there is currently a page loading from the server, false otherwise
51
+ */
52
+ isPageLoading(): boolean;
53
+ /**
54
+ * @returns true if there are more results available to load, false otherwise
55
+ */
56
+ hasMoreResultsAvailable(): boolean;
57
+ /**
58
+ * Fetch the next page of objects from configured endpoint.
59
+ * @returns observable that emits with an object of type PaginatedList, which
60
+ * contains the items of the current page (or the whole concatenated
61
+ * list), the current page-index, the total pages, ...
62
+ */
63
+ loadMore(): Observable<PaginatedList<T>>;
64
+ /**
65
+ * Load a specific page with the given page-index from the backend.
66
+ * If loadMore is called after this function is called, the next page after
67
+ * this one will be loaded.
68
+ *
69
+ * @param pageIdx the page to load (1-indexed)
70
+ * @returns Observable that emits the PaginatedList loaded from backend
71
+ */
72
+ loadPage(pageIdx: number): Observable<PaginatedList<T>>;
73
+ }
74
+ export declare class PaginatedRequestServiceImpl<T extends APIObject> implements PaginatedRequestService<T> {
75
+ private httpsService;
76
+ private url;
77
+ private urlParams;
78
+ private backendService;
79
+ private pageSize;
80
+ private paginatedList;
81
+ private concatResult;
82
+ private initialPageLoaded;
83
+ private pageLoading;
84
+ private cursorPaginationEnabled;
85
+ private createObject;
86
+ constructor(createObject: (resObj: any) => T, httpsService: HttpsService, url: string, backendService?: BACKEND_SERVICE, urlParams?: Array<Object>, pageSize?: number, cursorPaginationEnabled?: boolean);
87
+ loadInitialPage(concatResult?: boolean): Observable<PaginatedList<T>>;
88
+ getPaginatedList(concatResult?: boolean): Observable<PaginatedList<T>>;
89
+ getLoadedPaginatedList(): PaginatedList<T>;
90
+ isInitialPageLoaded(): boolean;
91
+ isPageLoading(): boolean;
92
+ hasMoreResultsAvailable(): boolean;
93
+ loadMore(): Observable<PaginatedList<T>>;
94
+ loadPage(pageIdx: number): Observable<PaginatedList<T>>;
95
+ /**
96
+ * Fetch page of paginated list from server
97
+ *
98
+ * @param pageIdx which page to fetch
99
+ * @returns Observable that resolves with the PaginatedList object of the requested page
100
+ */
101
+ private fetchPaginatedListFromServer;
102
+ private concatenateItems;
103
+ private removeUrlParam;
104
+ }
@@ -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(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var a in e=arguments[r])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},__assign.apply(this,arguments)},__spreadArray=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var i,a=0,n=e.length;a<n;a++)!i&&a in e||(i||(i=Array.prototype.slice.call(e,0,a)),i[a]=e[a]);return t.concat(i||Array.prototype.slice.call(e))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaginatedRequestServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),error_1=require("../models/error"),https_service_interface_1=require("./http/https.service.interface"),paginated_list_1=require("../models/paginated-list"),PaginatedRequestServiceImpl=function(){function t(t,e,r,i,a,n,s){void 0===i&&(i=https_service_interface_1.BACKEND_SERVICE.DATA),void 0===a&&(a=[]),void 0===n&&(n=25),void 0===s&&(s=!1),this.pageSize=-1,this.concatResult=!0,this.initialPageLoaded=!1,this.pageLoading=!1,this.cursorPaginationEnabled=!1,this.createObject=t,this.httpsService=e,this.url=r,this.backendService=i,this.pageSize=n,this.cursorPaginationEnabled=s,this.urlParams=__spreadArray(__spreadArray([],a,!0),[{page_size:this.pageSize}],!1)}return t.prototype.loadInitialPage=function(t){var e=this;return void 0===t&&(t=!0),this.concatResult=t,this.loadPage(1).pipe((0,operators_1.tap)((function(){return e.initialPageLoaded=!0})))},t.prototype.getPaginatedList=function(t){return void 0===t&&(t=!0),this.loadInitialPage(t)},t.prototype.getLoadedPaginatedList=function(){return this.paginatedList},t.prototype.isInitialPageLoaded=function(){return this.initialPageLoaded&&this.paginatedList&&(this.paginatedList.currentPageIdx>=1||this.paginatedList.items.length>=0&&this.cursorPaginationEnabled)},t.prototype.isPageLoading=function(){return this.pageLoading},t.prototype.hasMoreResultsAvailable=function(){return this.cursorPaginationEnabled?this.paginatedList&&!!this.paginatedList.nextPage:this.paginatedList&&this.paginatedList.moreResultsAvailable()},t.prototype.loadMore=function(){if(this.cursorPaginationEnabled){var t=this.paginatedList.nextPage.split("?"),e=new URLSearchParams(t[1]);return this.urlParams=this.removeUrlParam(this.urlParams,"cursor"),this.urlParams=__spreadArray(__spreadArray([],this.urlParams,!0),[{cursor:e.get("cursor")}],!1),this.loadPage(null)}return this.isInitialPageLoaded()?this.paginatedList.currentPageIdx>=this.paginatedList.totalPages?(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_MORE_ITEMS_AVAILABLE,null,"can not load more items, last page reached")):this.loadPage(this.paginatedList.currentPageIdx+1):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INITIAL_ITEMS_NOT_YET_LOADED,null))},t.prototype.loadPage=function(t){var e=this;return(0,rxjs_1.of)(void 0).pipe((0,operators_1.tap)((function(){e.pageLoading=!0})),(0,operators_1.mergeMap)((function(){return e.fetchPaginatedListFromServer(t).pipe((0,operators_1.catchError)((function(t){return e.pageLoading=!1,console.log("Error while loading items from server.",t),(0,rxjs_1.throwError)(t)})))})),(0,operators_1.tap)((function(){e.pageLoading=!1})),(0,operators_1.map)((function(t){return e.concatResult&&e.paginatedList&&t?e.concatenateItems(e.paginatedList,t):t})),(0,operators_1.tap)((function(t){e.paginatedList=t.clone()})))},t.prototype.fetchPaginatedListFromServer=function(t){var e=this;return this.httpsService.get(this.url,__spreadArray(__spreadArray([],this.urlParams,!0),[__assign({},this.cursorPaginationEnabled?{paginator:"cursor"}:{page:t})],!1),this.backendService).pipe((0,operators_1.map)((function(r){var i=r.results.map((function(t){return e.createObject(t)}));return new paginated_list_1.PaginatedList(i,t||void 0,r.pagination.items_count||0===r.pagination.items_count?Math.ceil(r.pagination.items_count/e.pageSize):void 0,e.pageSize,r.pagination.next||void 0,r.pagination.previous||void 0,e.cursorPaginationEnabled)})))},t.prototype.concatenateItems=function(t,e){return e.items=t.items.concat(e.items),e},t.prototype.removeUrlParam=function(t,e){return t.filter((function(t){return!t[e]}))},t}();exports.PaginatedRequestServiceImpl=PaginatedRequestServiceImpl;