@partium/js-sdk 15.14.0 → 15.16.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.
- package/core/integration-defaults/session/js-oauth-web-cookie-session.service.d.ts +12 -0
- package/core/integration-defaults/session/js-oauth-web-cookie-session.service.js +1 -1
- package/core/models/error.d.ts +1 -0
- package/core/models/error.js +1 -1
- package/core/utils/general-helper.d.ts +8 -0
- package/core/utils/general-helper.js +1 -1
- package/data/services/data.service.d.ts +31 -5
- package/data/services/data.service.js +1 -1
- package/datacuration/services/image-submission.service.d.ts +0 -1
- package/datacuration/services/image-submission.service.js +1 -1
- package/enrichment/services/data-enrichment.service.d.ts +0 -1
- package/enrichment/services/data-enrichment.service.js +1 -1
- package/gen/sdk-version.d.ts +1 -1
- package/gen/sdk-version.js +1 -1
- package/package.json +1 -1
|
@@ -163,6 +163,18 @@ export declare class JSOauthWebCookieSessionService extends OauthSessionService
|
|
|
163
163
|
* Create a fallback OAuth error when an upstream failure does not already use SdkError.
|
|
164
164
|
*/
|
|
165
165
|
private createSdkError;
|
|
166
|
+
private hasSessionToRevoke;
|
|
167
|
+
private createPkceCodeVerifier;
|
|
168
|
+
private createPkceCodeChallenge;
|
|
169
|
+
private getBrowserCrypto;
|
|
170
|
+
private storePkceCodeVerifier;
|
|
171
|
+
private getPkceCodeVerifier;
|
|
172
|
+
private clearPkceCodeVerifier;
|
|
173
|
+
private markActiveCookieSession;
|
|
174
|
+
private hasActiveCookieSession;
|
|
175
|
+
private clearActiveCookieSession;
|
|
176
|
+
private getBrowserSessionStorage;
|
|
177
|
+
private base64UrlEncode;
|
|
166
178
|
private getNumericClaim;
|
|
167
179
|
private getStringArrayClaim;
|
|
168
180
|
private asRefreshValidationErrorDetail;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])},r(e,t)};return function(e,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=e}r(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}(),__awaiter=this&&this.__awaiter||function(r,e,t,o){return new(t||(t=Promise))((function(n,i){function s(r){try{u(o.next(r))}catch(r){i(r)}}function a(r){try{u(o.throw(r))}catch(r){i(r)}}function u(r){var e;r.done?n(r.value):(e=r.value,e instanceof t?e:new t((function(r){r(e)}))).then(s,a)}u((o=o.apply(r,e||[])).next())}))},__generator=this&&this.__generator||function(r,e){var t,o,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(t=1,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(r,s)}catch(r){a=[6,r],o=0}finally{t=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSOauthWebCookieSessionService=exports.JSOauthWebCookieLoginConfig=exports.JSOauthWebCookieAuthenticationConfig=exports.JSOauthWebCookieStatus=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),auth_config_1=require("../../models/auth-config"),error_1=require("../../models/error"),user_token_1=require("../../models/user-token"),user_1=require("../../models/user"),https_client_service_interface_1=require("../../services/http/https-client/https-client.service.interface"),oauth_session_service_1=require("../../services/session/oauth-session.service"),COOKIE_REQUEST_OPTIONS={withCredentials:!0},MISSING_REFRESH_TOKEN_ERROR_MESSAGE="Refresh token not provided in cookie or request body.",JSOauthWebCookieStatus=function(r){function e(){return null!==r&&r.apply(this,arguments)||this}return __extends(e,r),e}(oauth_session_service_1.OauthStatus);exports.JSOauthWebCookieStatus=JSOauthWebCookieStatus;var JSOauthWebCookieAuthenticationConfig=function(r){function e(e){var t=r.call(this,e)||this;return t.partiumApiBaseUrl="https://api.partium.io",t.oauthSessionService=JSOauthWebCookieSessionService,Object.assign(t,e),t}return __extends(e,r),e}(auth_config_1.OauthAuthenticationConfig);exports.JSOauthWebCookieAuthenticationConfig=JSOauthWebCookieAuthenticationConfig;var JSOauthWebCookieLoginConfig=function(r){function e(e){var t=r.call(this)||this;return Object.assign(t,e),t}return __extends(e,r),e}(oauth_session_service_1.OauthLoginConfig);exports.JSOauthWebCookieLoginConfig=JSOauthWebCookieLoginConfig;var JSOauthWebCookieSessionService=function(r){function e(e){var t=r.call(this,e)||this;return t.status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0,user:void 0,featureFlags:void 0},t.status$=new rxjs_1.BehaviorSubject(t.status),t}return __extends(e,r),e.prototype.onCreate=function(){r.prototype.onCreate.call(this),this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},e.prototype.getStatus=function(){return this.status$.asObservable()},e.prototype.login=function(r){var e=this,t=r,o=this.authenticationConfig,n=t.apiKey||o.apiKey,i=this.getUrlQueryParam("code"),s=this.getOauthErrorFromUrl();if(n)return this.loginWithApiKey(n).pipe((0,operators_1.mergeMap)((function(){return e.sessionSetup(t.loginEventContext)})));if(s)return(0,rxjs_1.throwError)((function(){return e.createSdkError(null,s)}));var a=o.authorizationCode||i;if(a){var u=void 0;try{u=this.getRedirectUrl(t)}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.exchangeCodeForToken(a,u).pipe((0,operators_1.tap)((function(){return e.clearAuthCallbackParamsFromUrl()})),(0,operators_1.mergeMap)((function(){return e.sessionSetup(t.loginEventContext)})))}return this.refreshWithCookie().pipe((0,operators_1.mergeMap)((function(){return e.sessionSetup(t.loginEventContext)})),(0,operators_1.catchError)((function(){return e.redirectToLoginPage(t)})))},e.prototype.refresh=function(){var r=this;return this.refreshWithCookie().pipe((0,operators_1.map)((function(e){return r.updateTokenFromResponse(e)})),(0,operators_1.catchError)((function(e){return r.handleRefreshError(e)})))},e.prototype.logout=function(r){return void 0!==(null==r?void 0:r.postLogoutRedirectUri)?this.logoutThroughBrowser(r.postLogoutRedirectUri):this.revokeSession()},e.prototype.logoutThroughBrowser=function(r){if("string"!=typeof r||!r.trim())return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,{postLogoutRedirectUri:r},"Missing postLogoutRedirectUri for browser logout.")}));if("undefined"==typeof window)return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,{postLogoutRedirectUri:r},"Cannot redirect to the logout page outside of a browser context.")}));var e;try{e=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}var t=new URL("".concat(e,"/auth/logout"));return t.searchParams.set("post_logout_redirect_uri",r),this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0).pipe((0,operators_1.tap)((function(){return window.location.assign(t.toString())})))},e.prototype.revokeSession=function(){var r,e=this;try{r=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.httpsClientService.post("".concat(r,"/auth/revoke"),{access_token:this.status.accessToken||null,refresh_token:null},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(){e.resetToken(),e.sessionEnded()})),(0,operators_1.catchError)((function(r){return e.resetToken(),e.sessionEnded(),e.handleError(r)})))},e.prototype.exchangeCodeForToken=function(r,e){var t,o=this;try{t=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.httpsClientService.post("".concat(t,"/auth"),{grant_type:"authorization_code",code:r,redirect_uri:e},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(r){return o.updateTokenFromResponse(r)})),(0,operators_1.catchError)((function(r){return o.handleError(r)})))},e.prototype.loginWithApiKey=function(r){var e,t=this;try{e=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.httpsClientService.post("".concat(e,"/auth"),{},void 0,{Authorization:"Bearer ".concat(r)},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(r){return t.updateTokenFromResponse(r)})),(0,operators_1.catchError)((function(r){return t.handleError(r)})))},e.prototype.refreshWithCookie=function(){var r;try{r=this.getPartiumApiBaseUrl()}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return this.httpsClientService.post("".concat(r,"/auth/refresh"),{refresh_token:null},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS)},e.prototype.redirectToLoginPage=function(r){if("undefined"==typeof window)return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Cannot redirect to OAuth login page outside of a browser context.")}));var e;try{e=this.getRedirectUrl(r)}catch(r){return(0,rxjs_1.throwError)((function(){return r}))}return(0,rxjs_1.from)(this.buildOauthAuthorizationUrl(e)).pipe((0,operators_1.tap)((function(r){window.location.href=r})),(0,operators_1.mergeMap)((function(){return rxjs_1.NEVER})))},e.prototype.buildOauthAuthorizationUrl=function(r){return __awaiter(this,void 0,void 0,(function(){var e,t,o,n,i,s,a;return __generator(this,(function(u){if(e=this.authenticationConfig,t=e.baseUrl,o=e.realm,n=e.clientId,!t||!o||!n)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,e,"OAuth auth configuration is incomplete. Required: baseUrl, realm, clientId.");return i="".concat(t,"/auth/realms/").concat(o,"/protocol/openid-connect/auth"),s=new URLSearchParams({client_id:n,redirect_uri:r,response_type:"code",response_mode:"query",scope:"openid"}),(a=this.getUrlQueryParam("kc_idp_hint"))&&s.set("kc_idp_hint",a),[2,"".concat(i,"?").concat(s.toString())]}))}))},e.prototype.getRedirectUrl=function(r){var e=r.redirectUrl||this.authenticationConfig.redirectUrl;if(!e)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing redirectUrl in OAuth authentication configuration.");return e},e.prototype.getPartiumApiBaseUrl=function(){var r=this.authenticationConfig.partiumApiBaseUrl;if(!r)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing partiumApiBaseUrl in OAuth authentication configuration.");return r},e.prototype.getUrlQueryParam=function(r){var e;return"undefined"!=typeof window&&(null===(e=window.location)||void 0===e?void 0:e.search)?new URLSearchParams(window.location.search).get(r):null},e.prototype.getOauthErrorFromUrl=function(){var r=this.getUrlQueryParam("error"),e=this.getUrlQueryParam("error_description");if(r||e)return[r,e].filter((function(r){return!!r})).join(" - ")},e.prototype.clearAuthCallbackParamsFromUrl=function(){if("undefined"!=typeof window){var r=new URL(window.location.href);r.searchParams.delete("code"),r.searchParams.delete("session_state"),r.searchParams.delete("iss"),r.searchParams.delete("error"),r.searchParams.delete("error_description");var e="".concat(r.pathname).concat(r.search).concat(r.hash);window.history.replaceState(window.history.state,"",e)}},e.prototype.updateTokenFromResponse=function(r){this.updateToken(r.token)},e.prototype.updateToken=function(r){if(r){var e=(0,user_token_1.createUserToken)(r),t=this.getNumericClaim(e.exp),o=this.getNumericClaim(e.iat),n=void 0!==t?new Date(1e3*t):new Date,i=void 0!==o?new Date(1e3*o):new Date,s=user_1.User.createFromToken(e),a=this.getStringArrayClaim(e.features);this.tokenUpdated(r,n),this.setUser(s),this.status={accessToken:r,accessTokenCreateDate:i,accessTokenExpiration:n,refreshToken:void 0,authenticated:!0,user:s,featureFlags:a},this.status$.next(this.status)}else this.resetToken()},e.prototype.resetToken=function(){this.tokenUpdated(null,null),this.setUser(null),this.status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0,user:void 0,featureFlags:void 0},this.status$.next(this.status)},e.prototype.handleRefreshError=function(r){return r instanceof error_1.SdkError&&this.isExpiredOrMissingRefreshError(r)?(this.resetToken(),this.sessionEnded(),(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED,r.detail,"Refresh token expired or missing.")}))):this.handleError(r)},e.prototype.isExpiredOrMissingRefreshError=function(r){return r.code===error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED||r.code===error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY&&this.getRefreshValidationMessages(r.detail).includes(MISSING_REFRESH_TOKEN_ERROR_MESSAGE)},e.prototype.getRefreshValidationMessages=function(r){var e,t,o=this,n=this.asRefreshValidationErrorDetail(r);if(!n)return[];if("string"==typeof n.message)return[n.message];var i=null===(t=null===(e=n.response)||void 0===e?void 0:e.data)||void 0===t?void 0:t.detail;return"string"==typeof i?[i]:Array.isArray(i)?i.map((function(r){return o.getRefreshValidationMessage(r)})).filter((function(r){return void 0!==r})):[]},e.prototype.handleError=function(r){var e=this;return r instanceof error_1.SdkError?(0,rxjs_1.throwError)((function(){return r})):(0,rxjs_1.throwError)((function(){return e.createSdkError(r)}))},e.prototype.createSdkError=function(r,e){return new error_1.SdkError(error_1.SDK_ERROR_CODES.OAUTH_ERROR,r,e)},e.prototype.getNumericClaim=function(r){return"number"==typeof r?r:void 0},e.prototype.getStringArrayClaim=function(r){return Array.isArray(r)&&r.every((function(r){return"string"==typeof r}))?r:void 0},e.prototype.asRefreshValidationErrorDetail=function(r){return this.isObjectRecord(r)?r:void 0},e.prototype.getRefreshValidationMessage=function(r){if(this.isObjectRecord(r))return"string"==typeof r.msg?r.msg:void 0},e.prototype.isObjectRecord=function(r){return"object"==typeof r&&null!==r},e}(oauth_session_service_1.OauthSessionService);exports.JSOauthWebCookieSessionService=JSOauthWebCookieSessionService;
|
|
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)}}(),__awaiter=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,a)}u((o=o.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var t,o,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(t=1,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=r.call(e,s)}catch(e){a=[6,e],o=0}finally{t=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSOauthWebCookieSessionService=exports.JSOauthWebCookieLoginConfig=exports.JSOauthWebCookieAuthenticationConfig=exports.JSOauthWebCookieStatus=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),auth_config_1=require("../../models/auth-config"),error_1=require("../../models/error"),user_token_1=require("../../models/user-token"),user_1=require("../../models/user"),https_client_service_interface_1=require("../../services/http/https-client/https-client.service.interface"),oauth_session_service_1=require("../../services/session/oauth-session.service"),COOKIE_REQUEST_OPTIONS={withCredentials:!0},MISSING_REFRESH_TOKEN_ERROR_MESSAGE="Refresh token not provided in cookie or request body.",PKCE_CODE_VERIFIER_STORAGE_KEY="partium.oauth.web_cookie.pkce_code_verifier",COOKIE_SESSION_STORAGE_KEY="partium.oauth.web_cookie.has_active_session",COOKIE_SESSION_STORAGE_VALUE="true",PKCE_CODE_CHALLENGE_METHOD="S256",JSOauthWebCookieStatus=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return __extends(r,e),r}(oauth_session_service_1.OauthStatus);exports.JSOauthWebCookieStatus=JSOauthWebCookieStatus;var JSOauthWebCookieAuthenticationConfig=function(e){function r(r){var t=e.call(this,r)||this;return t.partiumApiBaseUrl="https://api.partium.io",t.oauthSessionService=JSOauthWebCookieSessionService,Object.assign(t,r),t}return __extends(r,e),r}(auth_config_1.OauthAuthenticationConfig);exports.JSOauthWebCookieAuthenticationConfig=JSOauthWebCookieAuthenticationConfig;var JSOauthWebCookieLoginConfig=function(e){function r(r){var t=e.call(this)||this;return Object.assign(t,r),t}return __extends(r,e),r}(oauth_session_service_1.OauthLoginConfig);exports.JSOauthWebCookieLoginConfig=JSOauthWebCookieLoginConfig;var JSOauthWebCookieSessionService=function(e){function r(r){var t=e.call(this,r)||this;return t.status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0,user:void 0,featureFlags:void 0},t.status$=new rxjs_1.BehaviorSubject(t.status),t}return __extends(r,e),r.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},r.prototype.getStatus=function(){return this.status$.asObservable()},r.prototype.login=function(e){var r=this,t=e,o=this.authenticationConfig,n=t.apiKey||o.apiKey,i=this.getUrlQueryParam("code"),s=this.getOauthErrorFromUrl();if(n)return this.loginWithApiKey(n).pipe((0,operators_1.mergeMap)((function(){return r.sessionSetup(t.loginEventContext)})));if(s)return this.clearPkceCodeVerifier(),(0,rxjs_1.throwError)((function(){return r.createSdkError(null,s)}));var a=o.authorizationCode||i;if(a){var u=void 0;try{u=this.getRedirectUrl(t)}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.exchangeCodeForToken(a,u).pipe((0,operators_1.tap)((function(){return r.clearAuthCallbackParamsFromUrl()})),(0,operators_1.mergeMap)((function(){return r.sessionSetup(t.loginEventContext)})))}return this.refreshWithCookie().pipe((0,operators_1.map)((function(e){return r.updateTokenFromResponse(e)})),(0,operators_1.mergeMap)((function(){return r.sessionSetup(t.loginEventContext)})),(0,operators_1.catchError)((function(){return r.redirectToLoginPage(t)})))},r.prototype.refresh=function(){var e=this;return this.refreshWithCookie().pipe((0,operators_1.map)((function(r){return e.updateTokenFromResponse(r)})),(0,operators_1.catchError)((function(r){return e.handleRefreshError(r)})))},r.prototype.logout=function(e){return void 0!==(null==e?void 0:e.postLogoutRedirectUri)?this.logoutThroughBrowser(e.postLogoutRedirectUri):this.revokeSession()},r.prototype.logoutThroughBrowser=function(e){if("string"!=typeof e||!e.trim())return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,{postLogoutRedirectUri:e},"Missing postLogoutRedirectUri for browser logout.")}));if("undefined"==typeof window)return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,{postLogoutRedirectUri:e},"Cannot redirect to the logout page outside of a browser context.")}));var r;try{r=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}var t=new URL("".concat(r,"/auth/logout"));return t.searchParams.set("post_logout_redirect_uri",e),this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0).pipe((0,operators_1.tap)((function(){return window.location.assign(t.toString())})))},r.prototype.revokeSession=function(){var e,r=this;if(!this.hasSessionToRevoke())return this.resetToken(),this.sessionEnded(),(0,rxjs_1.of)(void 0);try{e=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(e,"/auth/revoke"),{access_token:this.status.accessToken||null,refresh_token:null},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(){r.resetToken(),r.sessionEnded()})),(0,operators_1.catchError)((function(e){return r.resetToken(),r.sessionEnded(),r.handleError(e)})))},r.prototype.exchangeCodeForToken=function(e,r){var t,o,n=this;try{t=this.getPartiumApiBaseUrl(),o=this.getPkceCodeVerifier()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(t,"/auth"),{grant_type:"authorization_code",code:e,redirect_uri:r,code_verifier:o},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(e){n.clearPkceCodeVerifier(),n.updateTokenFromResponse(e)})),(0,operators_1.catchError)((function(e){return n.handleError(e)})))},r.prototype.loginWithApiKey=function(e){var r,t=this;try{r=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(r,"/auth"),{},void 0,{Authorization:"Bearer ".concat(e)},COOKIE_REQUEST_OPTIONS).pipe((0,operators_1.map)((function(e){return t.updateTokenFromResponse(e)})),(0,operators_1.catchError)((function(e){return t.handleError(e)})))},r.prototype.refreshWithCookie=function(){var e;try{e=this.getPartiumApiBaseUrl()}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return this.httpsClientService.post("".concat(e,"/auth/refresh"),{refresh_token:null},void 0,{"Content-Type":"application/json"},COOKIE_REQUEST_OPTIONS)},r.prototype.redirectToLoginPage=function(e){if("undefined"==typeof window)return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Cannot redirect to OAuth login page outside of a browser context.")}));var r;try{r=this.getRedirectUrl(e)}catch(e){return(0,rxjs_1.throwError)((function(){return e}))}return(0,rxjs_1.from)(this.buildOauthAuthorizationUrl(r)).pipe((0,operators_1.tap)((function(e){window.location.href=e})),(0,operators_1.mergeMap)((function(){return rxjs_1.NEVER})))},r.prototype.buildOauthAuthorizationUrl=function(e){return __awaiter(this,void 0,void 0,(function(){var r,t,o,n,i,s,a,u,c;return __generator(this,(function(h){switch(h.label){case 0:if(r=this.authenticationConfig,t=r.baseUrl,o=r.realm,n=r.clientId,!t||!o||!n)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,r,"OAuth auth configuration is incomplete. Required: baseUrl, realm, clientId.");return i="".concat(t,"/auth/realms/").concat(o,"/protocol/openid-connect/auth"),s=new URLSearchParams({client_id:n,redirect_uri:e,response_type:"code",response_mode:"query",scope:"openid"}),a=this.createPkceCodeVerifier(),[4,this.createPkceCodeChallenge(a)];case 1:return u=h.sent(),this.storePkceCodeVerifier(a),s.set("code_challenge",u),s.set("code_challenge_method",PKCE_CODE_CHALLENGE_METHOD),(c=this.getUrlQueryParam("kc_idp_hint"))&&s.set("kc_idp_hint",c),[2,"".concat(i,"?").concat(s.toString())]}}))}))},r.prototype.getRedirectUrl=function(e){var r=e.redirectUrl||this.authenticationConfig.redirectUrl;if(!r)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing redirectUrl in OAuth authentication configuration.");return r},r.prototype.getPartiumApiBaseUrl=function(){var e=this.authenticationConfig.partiumApiBaseUrl;if(!e)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_AUTH_CONFIG,this.authenticationConfig,"Missing partiumApiBaseUrl in OAuth authentication configuration.");return e},r.prototype.getUrlQueryParam=function(e){var r;return"undefined"!=typeof window&&(null===(r=window.location)||void 0===r?void 0:r.search)?new URLSearchParams(window.location.search).get(e):null},r.prototype.getOauthErrorFromUrl=function(){var e=this.getUrlQueryParam("error"),r=this.getUrlQueryParam("error_description");if(e||r)return[e,r].filter((function(e){return!!e})).join(" - ")},r.prototype.clearAuthCallbackParamsFromUrl=function(){if("undefined"!=typeof window){var e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("session_state"),e.searchParams.delete("iss"),e.searchParams.delete("error"),e.searchParams.delete("error_description");var r="".concat(e.pathname).concat(e.search).concat(e.hash);window.history.replaceState(window.history.state,"",r)}},r.prototype.updateTokenFromResponse=function(e){this.updateToken(e.token),e.token&&this.markActiveCookieSession()},r.prototype.updateToken=function(e){if(e){var r=(0,user_token_1.createUserToken)(e),t=this.getNumericClaim(r.exp),o=this.getNumericClaim(r.iat),n=void 0!==t?new Date(1e3*t):new Date,i=void 0!==o?new Date(1e3*o):new Date,s=user_1.User.createFromToken(r),a=this.getStringArrayClaim(r.features);this.tokenUpdated(e,n),this.setUser(s),this.status={accessToken:e,accessTokenCreateDate:i,accessTokenExpiration:n,refreshToken:void 0,authenticated:!0,user:s,featureFlags:a},this.status$.next(this.status)}else this.resetToken()},r.prototype.resetToken=function(){this.tokenUpdated(null,null),this.setUser(null),this.clearActiveCookieSession(),this.status={accessToken:void 0,accessTokenExpiration:void 0,accessTokenCreateDate:void 0,authenticated:!1,refreshToken:void 0,user:void 0,featureFlags:void 0},this.status$.next(this.status)},r.prototype.handleRefreshError=function(e){return e instanceof error_1.SdkError&&this.isExpiredOrMissingRefreshError(e)?(this.resetToken(),this.sessionEnded(),(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED,e.detail,"Refresh token expired or missing.")}))):this.handleError(e)},r.prototype.isExpiredOrMissingRefreshError=function(e){return e.code===error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED||e.code===error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY&&this.getRefreshValidationMessages(e.detail).includes(MISSING_REFRESH_TOKEN_ERROR_MESSAGE)},r.prototype.getRefreshValidationMessages=function(e){var r,t,o=this,n=this.asRefreshValidationErrorDetail(e);if(!n)return[];if("string"==typeof n.message)return[n.message];var i=null===(t=null===(r=n.response)||void 0===r?void 0:r.data)||void 0===t?void 0:t.detail;return"string"==typeof i?[i]:Array.isArray(i)?i.map((function(e){return o.getRefreshValidationMessage(e)})).filter((function(e){return void 0!==e})):[]},r.prototype.handleError=function(e){var r=this;return e instanceof error_1.SdkError?(0,rxjs_1.throwError)((function(){return e})):(0,rxjs_1.throwError)((function(){return r.createSdkError(e)}))},r.prototype.createSdkError=function(e,r){return new error_1.SdkError(error_1.SDK_ERROR_CODES.OAUTH_ERROR,e,r)},r.prototype.hasSessionToRevoke=function(){return Boolean(this.status.accessToken)||this.hasActiveCookieSession()},r.prototype.createPkceCodeVerifier=function(){var e=new Uint8Array(32);return this.getBrowserCrypto().getRandomValues(e),this.base64UrlEncode(e)},r.prototype.createPkceCodeChallenge=function(e){return __awaiter(this,void 0,void 0,(function(){var r,t;return __generator(this,(function(o){switch(o.label){case 0:if("undefined"==typeof TextEncoder)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"TextEncoder is required for PKCE OAuth login.");return r=(new TextEncoder).encode(e),[4,this.getBrowserCrypto().subtle.digest("SHA-256",r)];case 1:return t=o.sent(),[2,this.base64UrlEncode(new Uint8Array(t))]}}))}))},r.prototype.getBrowserCrypto=function(){var e;if("function"!=typeof(null===(e=globalThis.crypto)||void 0===e?void 0:e.getRandomValues)||!globalThis.crypto.subtle)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Web Crypto API is required for PKCE OAuth login.");return globalThis.crypto},r.prototype.storePkceCodeVerifier=function(e){this.getBrowserSessionStorage().setItem(PKCE_CODE_VERIFIER_STORAGE_KEY,e)},r.prototype.getPkceCodeVerifier=function(){var e=this.getBrowserSessionStorage().getItem(PKCE_CODE_VERIFIER_STORAGE_KEY);if(!e)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Missing PKCE code verifier for OAuth callback.");return e},r.prototype.clearPkceCodeVerifier=function(){"undefined"!=typeof window&&window.sessionStorage.removeItem(PKCE_CODE_VERIFIER_STORAGE_KEY)},r.prototype.markActiveCookieSession=function(){this.getBrowserSessionStorage().setItem(COOKIE_SESSION_STORAGE_KEY,COOKIE_SESSION_STORAGE_VALUE)},r.prototype.hasActiveCookieSession=function(){return"undefined"!=typeof window&&window.sessionStorage.getItem(COOKIE_SESSION_STORAGE_KEY)===COOKIE_SESSION_STORAGE_VALUE},r.prototype.clearActiveCookieSession=function(){"undefined"!=typeof window&&window.sessionStorage.removeItem(COOKIE_SESSION_STORAGE_KEY)},r.prototype.getBrowserSessionStorage=function(){if("undefined"==typeof window)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INTEGRATION_ERROR,null,"Browser sessionStorage is required for the web-cookie OAuth flow.");return window.sessionStorage},r.prototype.base64UrlEncode=function(e){var r=Array.from(e,(function(e){return String.fromCharCode(e)})).join("");return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},r.prototype.getNumericClaim=function(e){return"number"==typeof e?e:void 0},r.prototype.getStringArrayClaim=function(e){return Array.isArray(e)&&e.every((function(e){return"string"==typeof e}))?e:void 0},r.prototype.asRefreshValidationErrorDetail=function(e){return this.isObjectRecord(e)?e:void 0},r.prototype.getRefreshValidationMessage=function(e){if(this.isObjectRecord(e))return"string"==typeof e.msg?e.msg:void 0},r.prototype.isObjectRecord=function(e){return"object"==typeof e&&null!==e},r}(oauth_session_service_1.OauthSessionService);exports.JSOauthWebCookieSessionService=JSOauthWebCookieSessionService;
|
package/core/models/error.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare enum SDK_ERROR_CODES {
|
|
|
40
40
|
INITIAL_ITEMS_NOT_YET_LOADED = "INITIAL_ITEMS_NOT_YET_LOADED",// the request for the first page of items has not yet finished
|
|
41
41
|
NO_MORE_ITEMS_AVAILABLE = "NO_MORE_ITEMS_AVAILABLE",// can't load more items, because the end of the list is reached
|
|
42
42
|
NO_PAGINATION_CURSOR_AVAILABLE = "NO_PAGINATION_CURSOR_AVAILABLE",// can't load more items, because there is no cursor available
|
|
43
|
+
INVALID_PAGINATION_CURSOR_URL = "INVALID_PAGINATION_CURSOR_URL",// backend returned an invalid next page URL
|
|
43
44
|
UNEXPECTED_API_VERSION = "UNEXPECTED_API_VERSION",// the function that was called can not be executed with the selected Backend-API version,
|
|
44
45
|
UNEXPECTED_SEARCH_VERSION = "UNEXPECTED_SEARCH_VERSION",// the search-function that was called can not be executed with the selected Backend-API version,
|
|
45
46
|
SSO_USER_CERT = "SSO_USER_CERT",
|
package/core/models/error.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var SDK_ERROR_CODES;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SdkError=exports.SDK_ERROR_CODES=void 0,function(E){E.NO_INTERNET="NO_INTERNET",E.COULD_NOT_REACH_SERVER="COULD_NOT_REACH_SERVER",E.UNKNOWN_HOST_ERROR="UNKNOWN_HOST_ERROR",E.BAD_REQUEST="BAD_REQUEST",E.FORBIDDEN="FORBIDDEN",E.NOT_FOUND="NOT_FOUND",E.UNPROCESSABLE_ENTITY="UNPROCESSABLE_ENTITY",E.INTERNAL_SERVER_ERROR="INTERNAL_SERVER_ERROR",E.NOT_IMPLEMENTED="NOT_IMPLEMENTED",E.BAD_GATEWAY="BAD_GATEWAY",E.SERVICE_UNAVAILABLE="SERVICE_UNAVAILABLE",E.GATEWAY_TIMEOUT="GATEWAY_TIMEOUT",E.INVALID_AUTH_CONFIG="INVALID_AUTH_CONFIG",E.USER_UNAUTHORIZED="USER_UNAUTHORIZED",E.INVALID_API_KEY_FORMAT="INVALID_API_KEY_FORMAT",E.API_KEY_MISSING="API_KEY_MISSING",E.WRONG_AUTH_TYPE="wrongAuthType",E.NO_AUTHENTICATION_CONFIG_FOUND="NO_AUTHENTICATION_CONFIG_FOUND",E.INVALID_AUTHENTICATION="INVALID_AUTHENTICATION",E.VALIDATION_ERROR="VALIDATION_ERROR",E.INVALID_LOGIN_CONFIG="INVALID_LOGIN_CONFIG",E.UNKNOWN_ERROR="UNKNOWN_ERROR",E.NO_SEARCH_SESSION_ACTIVE="NO_SEARCH_SESSION_ACTIVE",E.RESULT_UNDEFINED="RESULT_UNDEFINED",E.INVALID_SEARCH_MODALITY_CONFIG="INVALID_SEARCH_MODALITY_CONFIG",E.INVALID_MULTIPLE_IMAGE_SEARCHES="INVALID_MULTIPLE_IMAGE_SEARCHES",E.INVALID_SEARCH_LANGUAGE="INVALID_SEARCH_LANGUAGE",E.GENERAL_SEARCH_ERROR="GENERAL_SEARCH_ERROR",E.INVALID_ASSET_STATUS="INVALID_ASSET_STATUS",E.FILE_NOT_FOUND="FILE_NOT_FOUND",E.CAPTURE_IMAGE_FAILED="CAPTURE_IMAGE_FAILED",E.LOADING_FROM_GALLERY_FAILED="LOADING_FROM_GALLERY_FAILED",E.IMAGE_SEARCH_ERROR="IMAGE_SEARCH_ERROR",E.PICK_IMAGE_ABORTED_BY_USER="PICK_IMAGE_ABORTED_BY_USER",E.SEARCH_RESULT_TIMEOUT="SEARCH_RESULT_TIMEOUT",E.TIMEOUT_ERROR="TIMEOUT_ERROR",E.INTEGRATION_ERROR="INTEGRATION_ERROR",E.INITIAL_ITEMS_NOT_YET_LOADED="INITIAL_ITEMS_NOT_YET_LOADED",E.NO_MORE_ITEMS_AVAILABLE="NO_MORE_ITEMS_AVAILABLE",E.NO_PAGINATION_CURSOR_AVAILABLE="NO_PAGINATION_CURSOR_AVAILABLE",E.UNEXPECTED_API_VERSION="UNEXPECTED_API_VERSION",E.UNEXPECTED_SEARCH_VERSION="UNEXPECTED_SEARCH_VERSION",E.SSO_USER_CERT="SSO_USER_CERT",E.SSO_TOKEN_REFRESH="SSO_TOKEN_REFRESH",E.TOKEN_EXPIRED="TOKEN_EXPIRED",E.INVALID_TOKEN="INVALID_TOKEN",E.REFRESH_TOKEN_EXPIRED="REFRESH_TOKEN_EXPIRED",E.OAUTH_ERROR="OAUTH_ERROR",E.LOGIN_CANCELLED="LOGIN_CANCELLED",E.LOGIN_ALREADY_IN_PROGRESS="LOGIN_ALREADY_IN_PROGRESS",E.MISSING_STORAGE_ACCESS_PERMISSION="MISSING_STORAGE_ACCESS_PERMISSION",E.SDK_OUTDATED="SDK_OUTDATED",E.BACKEND_DOWN="BACKEND_DOWN",E.STATUS_BACKEND_DOWN="STATUS_BACKEND_DOWN",E.INVALID_FILE_TYPE="INVALID_FILE_TYPE",E.INVALID_CROP_AREA="INVALID_CROP_AREA",E.ORGANIZATION_NOT_FOUND="ORGANIZATION_NOT_FOUND",E.NO_UPIS_FOUND="NO_UPIS_FOUND"}(SDK_ERROR_CODES||(exports.SDK_ERROR_CODES=SDK_ERROR_CODES={}));var SdkError=function(){function E(E,_,I){this.errorString="".concat(E," - ");try{this.errorString+=I||JSON.stringify(_)}catch(E){_.toString&&(this.errorString+=_.toString())}this.code=E,this.detail=_}return E.prototype.toString=function(){return this.errorString},E}();exports.SdkError=SdkError;
|
|
2
|
+
"use strict";var SDK_ERROR_CODES;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SdkError=exports.SDK_ERROR_CODES=void 0,function(E){E.NO_INTERNET="NO_INTERNET",E.COULD_NOT_REACH_SERVER="COULD_NOT_REACH_SERVER",E.UNKNOWN_HOST_ERROR="UNKNOWN_HOST_ERROR",E.BAD_REQUEST="BAD_REQUEST",E.FORBIDDEN="FORBIDDEN",E.NOT_FOUND="NOT_FOUND",E.UNPROCESSABLE_ENTITY="UNPROCESSABLE_ENTITY",E.INTERNAL_SERVER_ERROR="INTERNAL_SERVER_ERROR",E.NOT_IMPLEMENTED="NOT_IMPLEMENTED",E.BAD_GATEWAY="BAD_GATEWAY",E.SERVICE_UNAVAILABLE="SERVICE_UNAVAILABLE",E.GATEWAY_TIMEOUT="GATEWAY_TIMEOUT",E.INVALID_AUTH_CONFIG="INVALID_AUTH_CONFIG",E.USER_UNAUTHORIZED="USER_UNAUTHORIZED",E.INVALID_API_KEY_FORMAT="INVALID_API_KEY_FORMAT",E.API_KEY_MISSING="API_KEY_MISSING",E.WRONG_AUTH_TYPE="wrongAuthType",E.NO_AUTHENTICATION_CONFIG_FOUND="NO_AUTHENTICATION_CONFIG_FOUND",E.INVALID_AUTHENTICATION="INVALID_AUTHENTICATION",E.VALIDATION_ERROR="VALIDATION_ERROR",E.INVALID_LOGIN_CONFIG="INVALID_LOGIN_CONFIG",E.UNKNOWN_ERROR="UNKNOWN_ERROR",E.NO_SEARCH_SESSION_ACTIVE="NO_SEARCH_SESSION_ACTIVE",E.RESULT_UNDEFINED="RESULT_UNDEFINED",E.INVALID_SEARCH_MODALITY_CONFIG="INVALID_SEARCH_MODALITY_CONFIG",E.INVALID_MULTIPLE_IMAGE_SEARCHES="INVALID_MULTIPLE_IMAGE_SEARCHES",E.INVALID_SEARCH_LANGUAGE="INVALID_SEARCH_LANGUAGE",E.GENERAL_SEARCH_ERROR="GENERAL_SEARCH_ERROR",E.INVALID_ASSET_STATUS="INVALID_ASSET_STATUS",E.FILE_NOT_FOUND="FILE_NOT_FOUND",E.CAPTURE_IMAGE_FAILED="CAPTURE_IMAGE_FAILED",E.LOADING_FROM_GALLERY_FAILED="LOADING_FROM_GALLERY_FAILED",E.IMAGE_SEARCH_ERROR="IMAGE_SEARCH_ERROR",E.PICK_IMAGE_ABORTED_BY_USER="PICK_IMAGE_ABORTED_BY_USER",E.SEARCH_RESULT_TIMEOUT="SEARCH_RESULT_TIMEOUT",E.TIMEOUT_ERROR="TIMEOUT_ERROR",E.INTEGRATION_ERROR="INTEGRATION_ERROR",E.INITIAL_ITEMS_NOT_YET_LOADED="INITIAL_ITEMS_NOT_YET_LOADED",E.NO_MORE_ITEMS_AVAILABLE="NO_MORE_ITEMS_AVAILABLE",E.NO_PAGINATION_CURSOR_AVAILABLE="NO_PAGINATION_CURSOR_AVAILABLE",E.INVALID_PAGINATION_CURSOR_URL="INVALID_PAGINATION_CURSOR_URL",E.UNEXPECTED_API_VERSION="UNEXPECTED_API_VERSION",E.UNEXPECTED_SEARCH_VERSION="UNEXPECTED_SEARCH_VERSION",E.SSO_USER_CERT="SSO_USER_CERT",E.SSO_TOKEN_REFRESH="SSO_TOKEN_REFRESH",E.TOKEN_EXPIRED="TOKEN_EXPIRED",E.INVALID_TOKEN="INVALID_TOKEN",E.REFRESH_TOKEN_EXPIRED="REFRESH_TOKEN_EXPIRED",E.OAUTH_ERROR="OAUTH_ERROR",E.LOGIN_CANCELLED="LOGIN_CANCELLED",E.LOGIN_ALREADY_IN_PROGRESS="LOGIN_ALREADY_IN_PROGRESS",E.MISSING_STORAGE_ACCESS_PERMISSION="MISSING_STORAGE_ACCESS_PERMISSION",E.SDK_OUTDATED="SDK_OUTDATED",E.BACKEND_DOWN="BACKEND_DOWN",E.STATUS_BACKEND_DOWN="STATUS_BACKEND_DOWN",E.INVALID_FILE_TYPE="INVALID_FILE_TYPE",E.INVALID_CROP_AREA="INVALID_CROP_AREA",E.ORGANIZATION_NOT_FOUND="ORGANIZATION_NOT_FOUND",E.NO_UPIS_FOUND="NO_UPIS_FOUND"}(SDK_ERROR_CODES||(exports.SDK_ERROR_CODES=SDK_ERROR_CODES={}));var SdkError=function(){function E(E,_,I){this.errorString="".concat(E," - ");try{this.errorString+=I||JSON.stringify(_)}catch(E){_.toString&&(this.errorString+=_.toString())}this.code=E,this.detail=_}return E.prototype.toString=function(){return this.errorString},E}();exports.SdkError=SdkError;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
+
import { BasePaginatedResponse } from '../models/base-paginated-response';
|
|
2
3
|
/**
|
|
3
4
|
* Converts camel case to snake case
|
|
4
5
|
*
|
|
@@ -40,3 +41,10 @@ export declare const addUrlParameter: (url: string, paramObject: Object) => stri
|
|
|
40
41
|
* @returns query param objects consumable by HttpsService
|
|
41
42
|
*/
|
|
42
43
|
export declare const toQueryParams: (params: object) => Array<Object>;
|
|
44
|
+
/**
|
|
45
|
+
* Extracts the cursor query parameter from a paginated response next URL.
|
|
46
|
+
*
|
|
47
|
+
* @param response paginated response with optional next URL
|
|
48
|
+
* @returns cursor value if present
|
|
49
|
+
*/
|
|
50
|
+
export declare const extractNextCursor: <T>(response: BasePaginatedResponse<T>) => string | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __spreadArray=this&&this.__spreadArray||function(r,e,a){if(a||2===arguments.length)for(var t,n=0,o=e.length;n<o;n++)!t&&n in e||(t||(t=Array.prototype.slice.call(e,0,n)),t[n]=e[n]);return r.concat(t||Array.prototype.slice.call(e))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.toQueryParams=exports.addUrlParameter=exports.addUrlParameters=exports.snakeToCamelCase=exports.camelToSnake=void 0;var camelToSnake=function(r){var e={};return Object.keys(r).forEach((function(a){var t=a.replace(/[A-Z]/g,(function(r){return"_".concat(r.toLowerCase())}));if(e[t]=r[a],Array.isArray(r[t])){var n=r[t];n=n.map((function(r){return r&&"object"==typeof r&&r.constructor===Object?(0,exports.camelToSnake)(r):r})),e[t]=n}})),e};exports.camelToSnake=camelToSnake;var snakeToCamelCase=function(r){var e={};return Object.keys(r).forEach((function(a){var t=a.toLowerCase().replace(/([-_][a-z])/g,(function(r){return r.toUpperCase().replace("-","").replace("_","")}));if(e[t]=r[a],Array.isArray(r[t])){var n=r[t];n=n.map((function(r){return r&&"object"==typeof r&&r.constructor===Object?(0,exports.snakeToCamelCase)(r):r})),e[t]=n}})),e};exports.snakeToCamelCase=snakeToCamelCase;var addUrlParameters=function(r,e){if(!e||e.length<1)return r;for(var a=0,t=e;a<t.length;a++){var n=t[a];r=(0,exports.addUrlParameter)(r,n)}return r};exports.addUrlParameters=addUrlParameters;var addUrlParameter=function(r,e){if(!e)return r;var a=r.split("?"),t=a[0],n=[];a.length>1&&(n=a[1].split("&").map((function(r){return r.split("=")})));for(var o=0,s=Object.keys(e);o<s.length;o++){var c=s[o],
|
|
2
|
+
"use strict";var __spreadArray=this&&this.__spreadArray||function(r,e,a){if(a||2===arguments.length)for(var t,n=0,o=e.length;n<o;n++)!t&&n in e||(t||(t=Array.prototype.slice.call(e,0,n)),t[n]=e[n]);return r.concat(t||Array.prototype.slice.call(e))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.extractNextCursor=exports.toQueryParams=exports.addUrlParameter=exports.addUrlParameters=exports.snakeToCamelCase=exports.camelToSnake=void 0;var error_1=require("../models/error"),camelToSnake=function(r){var e={};return Object.keys(r).forEach((function(a){var t=a.replace(/[A-Z]/g,(function(r){return"_".concat(r.toLowerCase())}));if(e[t]=r[a],Array.isArray(r[t])){var n=r[t];n=n.map((function(r){return r&&"object"==typeof r&&r.constructor===Object?(0,exports.camelToSnake)(r):r})),e[t]=n}})),e};exports.camelToSnake=camelToSnake;var snakeToCamelCase=function(r){var e={};return Object.keys(r).forEach((function(a){var t=a.toLowerCase().replace(/([-_][a-z])/g,(function(r){return r.toUpperCase().replace("-","").replace("_","")}));if(e[t]=r[a],Array.isArray(r[t])){var n=r[t];n=n.map((function(r){return r&&"object"==typeof r&&r.constructor===Object?(0,exports.snakeToCamelCase)(r):r})),e[t]=n}})),e};exports.snakeToCamelCase=snakeToCamelCase;var addUrlParameters=function(r,e){if(!e||e.length<1)return r;for(var a=0,t=e;a<t.length;a++){var n=t[a];r=(0,exports.addUrlParameter)(r,n)}return r};exports.addUrlParameters=addUrlParameters;var addUrlParameter=function(r,e){if(!e)return r;var a=r.split("?"),t=a[0],n=[];a.length>1&&(n=a[1].split("&").map((function(r){return r.split("=")})));for(var o=0,s=Object.keys(e);o<s.length;o++){var c=s[o],u=e[c];null!=u&&(c=encodeURIComponent(c),u=encodeURIComponent(u),n.push([c,u]))}var i=n.map((function(r){return r.join("=")}));return i.length>0?"".concat(t,"?").concat(i.join("&")):t};exports.addUrlParameter=addUrlParameter;var toQueryParams=function(r){return Object.entries(r).reduce((function(r,e){var a,t=e[0],n=e[1];return null==n?r:Array.isArray(n)?__spreadArray(__spreadArray([],r,!0),n.map((function(r){var e;return(e={})[t]=r,e})),!0):__spreadArray(__spreadArray([],r,!0),[(a={},a[t]=n,a)],!1)}),[])};exports.toQueryParams=toQueryParams;var extractNextCursor=function(r){if(r.next)try{return new URL(r.next).searchParams.get("cursor")||void 0}catch(e){throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_PAGINATION_CURSOR_URL,{next:r.next,reason:e instanceof Error?e.message:String(e)},"Invalid pagination next URL.")}};exports.extractNextCursor=extractNextCursor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { BaseService, ServiceProvider } from '../../core';
|
|
3
|
+
import { BaseService, DefaultGetPaginatedRequestPaginationContext, ServiceProvider } from '../../core';
|
|
4
4
|
import { GetPartDataRequest } from '../models/get-part-data-request';
|
|
5
5
|
import { GetPartDataResponse } from '../models/get-part-data-response';
|
|
6
6
|
import { GetSelectableAttributesRequest } from '../models/get-selectable-attributes-request';
|
|
@@ -14,17 +14,43 @@ export interface DataService {
|
|
|
14
14
|
*/
|
|
15
15
|
getPart(request: GetPartDataRequest): Observable<GetPartDataResponse>;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Loads the first page of selectable attribute definitions with pagination context.
|
|
18
18
|
*
|
|
19
19
|
* @param request - The request object.
|
|
20
|
-
* @returns The
|
|
20
|
+
* @returns The first page and pagination context for loading additional pages.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
loadSelectableAttributes(request?: GetSelectableAttributesRequest): Observable<{
|
|
23
|
+
response: GetSelectableAttributesResponse;
|
|
24
|
+
paginationContext: DefaultGetPaginatedRequestPaginationContext;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Loads the next page of selectable attribute definitions.
|
|
28
|
+
*
|
|
29
|
+
* @param paginationContext - The pagination context returned by previous selectable-attribute calls.
|
|
30
|
+
* @returns The next page and updated pagination context.
|
|
31
|
+
*/
|
|
32
|
+
loadMoreSelectableAttributes(paginationContext: DefaultGetPaginatedRequestPaginationContext): Observable<{
|
|
33
|
+
response: GetSelectableAttributesResponse;
|
|
34
|
+
paginationContext: DefaultGetPaginatedRequestPaginationContext;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns true when another selectable-attribute page can be loaded.
|
|
38
|
+
*/
|
|
39
|
+
hasMoreSelectableAttributesAvailable(paginationContext: DefaultGetPaginatedRequestPaginationContext): boolean;
|
|
23
40
|
}
|
|
24
41
|
export declare class DataServiceImpl extends BaseService implements DataService {
|
|
25
42
|
private httpsService;
|
|
26
43
|
constructor(serviceProvider: ServiceProvider);
|
|
27
44
|
onCreate(): void;
|
|
28
45
|
getPart(request?: GetPartDataRequest): Observable<GetPartDataResponse>;
|
|
29
|
-
|
|
46
|
+
loadSelectableAttributes(request?: GetSelectableAttributesRequest): Observable<{
|
|
47
|
+
response: GetSelectableAttributesResponse;
|
|
48
|
+
paginationContext: DefaultGetPaginatedRequestPaginationContext;
|
|
49
|
+
}>;
|
|
50
|
+
loadMoreSelectableAttributes(paginationContext: DefaultGetPaginatedRequestPaginationContext): Observable<{
|
|
51
|
+
response: GetSelectableAttributesResponse;
|
|
52
|
+
paginationContext: DefaultGetPaginatedRequestPaginationContext;
|
|
53
|
+
}>;
|
|
54
|
+
hasMoreSelectableAttributesAvailable(paginationContext: DefaultGetPaginatedRequestPaginationContext): boolean;
|
|
55
|
+
private fetchSelectableAttributesPage;
|
|
30
56
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var
|
|
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)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;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,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 a=e.length-1;a>=0;a--)(n=e[a])&&(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},__rest=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataServiceImpl=void 0;var rxjs_1=require("rxjs"),core_1=require("../../core"),DataServiceImpl=function(e){function t(t){return e.call(this,t)||this}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(core_1.HttpsService)},t.prototype.getPart=function(e){void 0===e&&(e={projection:["partiumId"]});var t=e.projection,r=e.fallbackLanguages,o=__rest(e,["projection","fallbackLanguages"]),n=Array.from(new Set(t)).join(","),i=(null==r?void 0:r.length)?Array.from(new Set(r)).join(","):void 0,s=Object.entries(__assign(__assign({},o),{projection:n,fallbackLanguages:i})).filter((function(e){return null!=e[1]})).map((function(e){var t,r=e[0],o=e[1];return(t={})[r]=o,t}));return this.httpsService.get("part",s,core_1.BACKEND_SERVICE.DATA_V2)},t.prototype.loadSelectableAttributes=function(e){return void 0===e&&(e={}),this.fetchSelectableAttributesPage(e).pipe((0,rxjs_1.map)((function(t){return{response:t,paginationContext:{initialRequest:__assign({},e),nextCursor:(0,core_1.extractNextCursor)(t)}}})))},t.prototype.loadMoreSelectableAttributes=function(e){if(!e.nextCursor)return(0,rxjs_1.throwError)((function(){return new core_1.SdkError(core_1.SDK_ERROR_CODES.NO_PAGINATION_CURSOR_AVAILABLE,null,"No cursor available")}));var t=__assign(__assign({},e.initialRequest),{cursor:e.nextCursor});return this.fetchSelectableAttributesPage(t).pipe((0,rxjs_1.map)((function(t){return{response:t,paginationContext:__assign(__assign({},e),{nextCursor:(0,core_1.extractNextCursor)(t)})}})))},t.prototype.hasMoreSelectableAttributesAvailable=function(e){return!!e.nextCursor},t.prototype.fetchSelectableAttributesPage=function(e){return this.httpsService.get("attributes",(0,core_1.toQueryParams)(e),core_1.BACKEND_SERVICE.DATA_V2)},t=__decorate([(0,core_1.InjectionIdentifier)("DataService")],t)}(core_1.BaseService);exports.DataServiceImpl=DataServiceImpl;
|
|
@@ -93,5 +93,4 @@ export declare class ImageSubmissionServiceImpl extends BaseService implements I
|
|
|
93
93
|
update(request: UpdateImageSubmissionRequest): Observable<UpdateImageSubmissionResponse>;
|
|
94
94
|
hasMoreResultsAvailable(paginationContext: DefaultGetPaginatedRequestPaginationContext): boolean;
|
|
95
95
|
private fetchSubmissionsPage;
|
|
96
|
-
private extractNextCursor;
|
|
97
96
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])},r(e,t)};return function(e,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=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(r,e,t,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImageSubmissionServiceImpl=void 0;var rxjs_1=require("rxjs"),core_1=require("../../core"),ImageSubmissionServiceImpl=function(r){function e(){return null!==r&&r.apply(this,arguments)||this}return __extends(e,r),e.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(core_1.HttpsService)},e.prototype.submit=function(r){var e=new FormData;return r.organization?r.images.length?r.files.length?(e.append("images",JSON.stringify({organization:r.organization,images:r.images})),r.files.forEach((function(r){e.append("files",r,r.name)})),this.httpsService.post("submissions/images/upload",e,void 0,core_1.BACKEND_SERVICE.DATACURATION,{"Content-Type":"multipart/form-data"})):(0,rxjs_1.throwError)((function(){return new Error("Files are required")})):(0,rxjs_1.throwError)((function(){return new Error("Images are required")})):(0,rxjs_1.throwError)((function(){return new Error("Organization is required")}))},e.prototype.loadInitialSubmissions=function(r){
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])},r(e,t)};return function(e,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=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(r,e,t,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImageSubmissionServiceImpl=void 0;var rxjs_1=require("rxjs"),core_1=require("../../core"),ImageSubmissionServiceImpl=function(r){function e(){return null!==r&&r.apply(this,arguments)||this}return __extends(e,r),e.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(core_1.HttpsService)},e.prototype.submit=function(r){var e=new FormData;return r.organization?r.images.length?r.files.length?(e.append("images",JSON.stringify({organization:r.organization,images:r.images})),r.files.forEach((function(r){e.append("files",r,r.name)})),this.httpsService.post("submissions/images/upload",e,void 0,core_1.BACKEND_SERVICE.DATACURATION,{"Content-Type":"multipart/form-data"})):(0,rxjs_1.throwError)((function(){return new Error("Files are required")})):(0,rxjs_1.throwError)((function(){return new Error("Images are required")})):(0,rxjs_1.throwError)((function(){return new Error("Organization is required")}))},e.prototype.loadInitialSubmissions=function(r){return this.fetchSubmissionsPage(r).pipe((0,rxjs_1.map)((function(e){return{response:e,paginationContext:{initialRequest:__assign({},r),nextCursor:(0,core_1.extractNextCursor)(e)}}})))},e.prototype.loadMoreSubmissions=function(r){if(!r.nextCursor)return(0,rxjs_1.throwError)((function(){return new Error("No more pages available")}));var e=__assign(__assign({},r.initialRequest),{cursor:r.nextCursor});return this.fetchSubmissionsPage(e).pipe((0,rxjs_1.map)((function(e){return{response:e,paginationContext:__assign(__assign({},r),{nextCursor:(0,core_1.extractNextCursor)(e)})}})))},e.prototype.approve=function(r){return r.organization?r.imageIds.length?this.httpsService.post("submissions/images/approve",r,void 0,core_1.BACKEND_SERVICE.DATACURATION):(0,rxjs_1.throwError)((function(){return new Error("Image IDs are required")})):(0,rxjs_1.throwError)((function(){return new Error("Organization is required")}))},e.prototype.reject=function(r){return r.organization?r.imageIds.length?this.httpsService.post("submissions/images/reject",r,void 0,core_1.BACKEND_SERVICE.DATACURATION):(0,rxjs_1.throwError)((function(){return new Error("Image IDs are required")})):(0,rxjs_1.throwError)((function(){return new Error("Organization is required")}))},e.prototype.update=function(r){return r.organization?r.images.length?this.httpsService.patch("submissions/images/update",r,void 0,core_1.BACKEND_SERVICE.DATACURATION):(0,rxjs_1.throwError)((function(){return new Error("Images are required")})):(0,rxjs_1.throwError)((function(){return new Error("Organization is required")}))},e.prototype.hasMoreResultsAvailable=function(r){return!!r.nextCursor},e.prototype.fetchSubmissionsPage=function(r){if(!r.language)return(0,rxjs_1.throwError)((function(){return new Error("Language is required")}));var e=Object.entries(r).map((function(r){var e,t=r[0],n=r[1];return(e={})[t]=n,e}));return this.httpsService.get("submissions/images",e,core_1.BACKEND_SERVICE.DATACURATION)},e=__decorate([(0,core_1.InjectionIdentifier)("ImageSubmissionService")],e)}(core_1.BaseService);exports.ImageSubmissionServiceImpl=ImageSubmissionServiceImpl;
|
|
@@ -130,5 +130,4 @@ export declare class DataEnrichmentServiceImpl extends BaseService implements Da
|
|
|
130
130
|
triggerEnrichmentJob(request: TriggerEnrichmentJobRequest): Observable<TriggerEnrichmentJobResponse>;
|
|
131
131
|
private fetchEnrichmentJobsPage;
|
|
132
132
|
private fetchEnrichmentJobPartsPage;
|
|
133
|
-
private extractNextCursor;
|
|
134
133
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])},r(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(r){for(var t,e=1,n=arguments.length;e<n;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o]);return r},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(r,t,e,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(r,t,e,n);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(i<3?o(s):i>3?o(t,e,s):o(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s},__rest=this&&this.__rest||function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(r);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(r,n[o])&&(e[n[o]]=r[n[o]])}return e},__spreadArray=this&&this.__spreadArray||function(r,t,e){if(e||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return r.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataEnrichmentServiceImpl=void 0;var rxjs_1=require("rxjs"),core_1=require("../../core"),enrichment_job_1=require("../models/enrichment-job"),enrichment_job_part_1=require("../models/enrichment-job-part"),DataEnrichmentServiceImpl=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return __extends(t,r),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(core_1.HttpsService)},t.prototype.loadEnrichmentJobs=function(r){return this.fetchEnrichmentJobsPage(r).pipe((0,rxjs_1.map)((function(t){var e=t.jobs,n=t.nextCursor;return{jobs:e,paginationContext:{initialRequest:r,nextCursor:n}}})))},t.prototype.loadMoreEnrichmentJobs=function(r){if(!r.nextCursor)return(0,rxjs_1.throwError)((function(){return new core_1.SdkError(core_1.SDK_ERROR_CODES.NO_PAGINATION_CURSOR_AVAILABLE,null,"No cursor available")}));var t=__assign(__assign({},r.initialRequest),{cursor:r.nextCursor});return this.fetchEnrichmentJobsPage(t).pipe((0,rxjs_1.map)((function(t){var e=t.jobs,n=t.nextCursor;return{jobs:e,paginationContext:__assign(__assign({},r),{nextCursor:n})}})))},t.prototype.hasMoreEnrichmentJobsAvailable=function(r){return!!r.nextCursor},t.prototype.getEnrichmentJob=function(r){var t=r.jobId,e=__rest(r,["jobId"]);return this.httpsService.get("jobs/".concat(t),(0,core_1.toQueryParams)(e),core_1.BACKEND_SERVICE.DATA_ENRICHMENT).pipe((0,rxjs_1.map)((function(r){return(0,enrichment_job_1.enrichmentJobDetailFromAPIResponse)(r)})))},t.prototype.loadEnrichmentJobParts=function(r){return this.fetchEnrichmentJobPartsPage(r).pipe((0,rxjs_1.map)((function(t){var e=t.parts,n=t.partsSummary,o=t.nextCursor;return{parts:e,partsSummary:n,paginationContext:{initialRequest:r,nextCursor:o}}})))},t.prototype.loadMoreEnrichmentJobParts=function(r){if(!r.nextCursor)return(0,rxjs_1.throwError)((function(){return new core_1.SdkError(core_1.SDK_ERROR_CODES.NO_PAGINATION_CURSOR_AVAILABLE,null,"No cursor available")}));var t=__assign(__assign({},r.initialRequest),{cursor:r.nextCursor});return this.fetchEnrichmentJobPartsPage(t).pipe((0,rxjs_1.map)((function(t){var e=t.parts,n=t.partsSummary,o=t.nextCursor;return{parts:e,partsSummary:n,paginationContext:__assign(__assign({},r),{nextCursor:o})}})))},t.prototype.hasMoreEnrichmentJobPartsAvailable=function(r){return!!r.nextCursor},t.prototype.createEnrichmentJob=function(r){var t=new FormData;t.append("file",r.csvFile);var e=__spreadArray(__spreadArray([],r.jobType?[{jobType:r.jobType}]:[],!0),void 0!==r.organization?[{organization:r.organization}]:[],!0);return this.httpsService.post("jobs/upload",t,e,core_1.BACKEND_SERVICE.DATA_ENRICHMENT,{"Content-Type":"multipart/form-data"})},t.prototype.createEnrichmentJobWithSearchSession=function(r){var t=__spreadArray(__spreadArray([],r.jobType?[{jobType:r.jobType}]:[],!0),void 0!==r.organization?[{organization:r.organization}]:[],!0);return this.httpsService.post("jobs",r,t,core_1.BACKEND_SERVICE.DATA_ENRICHMENT)},t.prototype.submitEnrichmentJob=function(r){return this.httpsService.post("jobs/".concat(r.jobId,"/submit"),r,[],core_1.BACKEND_SERVICE.DATA_ENRICHMENT)},t.prototype.triggerEnrichmentJob=function(r){var t,e=__assign(__assign({type:r.type,partIds:r.partIds,visible:null!==(t=r.visible)&&void 0!==t&&t},void 0!==r.attributeIds?{attributeIds:r.attributeIds}:{}),void 0!==r.organization?{organization:r.organization}:{});return this.httpsService.post("jobs/trigger",e,[],core_1.BACKEND_SERVICE.DATA_ENRICHMENT)},t.prototype.fetchEnrichmentJobsPage=function(r){var t=
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])},r(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(r){for(var t,e=1,n=arguments.length;e<n;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o]);return r},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(r,t,e,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(r,t,e,n);else for(var a=r.length-1;a>=0;a--)(o=r[a])&&(s=(i<3?o(s):i>3?o(t,e,s):o(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s},__rest=this&&this.__rest||function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(r);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(r,n[o])&&(e[n[o]]=r[n[o]])}return e},__spreadArray=this&&this.__spreadArray||function(r,t,e){if(e||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return r.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataEnrichmentServiceImpl=void 0;var rxjs_1=require("rxjs"),core_1=require("../../core"),enrichment_job_1=require("../models/enrichment-job"),enrichment_job_part_1=require("../models/enrichment-job-part"),DataEnrichmentServiceImpl=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return __extends(t,r),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(core_1.HttpsService)},t.prototype.loadEnrichmentJobs=function(r){return this.fetchEnrichmentJobsPage(r).pipe((0,rxjs_1.map)((function(t){var e=t.jobs,n=t.nextCursor;return{jobs:e,paginationContext:{initialRequest:r,nextCursor:n}}})))},t.prototype.loadMoreEnrichmentJobs=function(r){if(!r.nextCursor)return(0,rxjs_1.throwError)((function(){return new core_1.SdkError(core_1.SDK_ERROR_CODES.NO_PAGINATION_CURSOR_AVAILABLE,null,"No cursor available")}));var t=__assign(__assign({},r.initialRequest),{cursor:r.nextCursor});return this.fetchEnrichmentJobsPage(t).pipe((0,rxjs_1.map)((function(t){var e=t.jobs,n=t.nextCursor;return{jobs:e,paginationContext:__assign(__assign({},r),{nextCursor:n})}})))},t.prototype.hasMoreEnrichmentJobsAvailable=function(r){return!!r.nextCursor},t.prototype.getEnrichmentJob=function(r){var t=r.jobId,e=__rest(r,["jobId"]);return this.httpsService.get("jobs/".concat(t),(0,core_1.toQueryParams)(e),core_1.BACKEND_SERVICE.DATA_ENRICHMENT).pipe((0,rxjs_1.map)((function(r){return(0,enrichment_job_1.enrichmentJobDetailFromAPIResponse)(r)})))},t.prototype.loadEnrichmentJobParts=function(r){return this.fetchEnrichmentJobPartsPage(r).pipe((0,rxjs_1.map)((function(t){var e=t.parts,n=t.partsSummary,o=t.nextCursor;return{parts:e,partsSummary:n,paginationContext:{initialRequest:r,nextCursor:o}}})))},t.prototype.loadMoreEnrichmentJobParts=function(r){if(!r.nextCursor)return(0,rxjs_1.throwError)((function(){return new core_1.SdkError(core_1.SDK_ERROR_CODES.NO_PAGINATION_CURSOR_AVAILABLE,null,"No cursor available")}));var t=__assign(__assign({},r.initialRequest),{cursor:r.nextCursor});return this.fetchEnrichmentJobPartsPage(t).pipe((0,rxjs_1.map)((function(t){var e=t.parts,n=t.partsSummary,o=t.nextCursor;return{parts:e,partsSummary:n,paginationContext:__assign(__assign({},r),{nextCursor:o})}})))},t.prototype.hasMoreEnrichmentJobPartsAvailable=function(r){return!!r.nextCursor},t.prototype.createEnrichmentJob=function(r){var t=new FormData;t.append("file",r.csvFile);var e=__spreadArray(__spreadArray([],r.jobType?[{jobType:r.jobType}]:[],!0),void 0!==r.organization?[{organization:r.organization}]:[],!0);return this.httpsService.post("jobs/upload",t,e,core_1.BACKEND_SERVICE.DATA_ENRICHMENT,{"Content-Type":"multipart/form-data"})},t.prototype.createEnrichmentJobWithSearchSession=function(r){var t=__spreadArray(__spreadArray([],r.jobType?[{jobType:r.jobType}]:[],!0),void 0!==r.organization?[{organization:r.organization}]:[],!0);return this.httpsService.post("jobs",r,t,core_1.BACKEND_SERVICE.DATA_ENRICHMENT)},t.prototype.submitEnrichmentJob=function(r){return this.httpsService.post("jobs/".concat(r.jobId,"/submit"),r,[],core_1.BACKEND_SERVICE.DATA_ENRICHMENT)},t.prototype.triggerEnrichmentJob=function(r){var t,e=__assign(__assign({type:r.type,partIds:r.partIds,visible:null!==(t=r.visible)&&void 0!==t&&t},void 0!==r.attributeIds?{attributeIds:r.attributeIds}:{}),void 0!==r.organization?{organization:r.organization}:{});return this.httpsService.post("jobs/trigger",e,[],core_1.BACKEND_SERVICE.DATA_ENRICHMENT)},t.prototype.fetchEnrichmentJobsPage=function(r){var t=(0,core_1.toQueryParams)(r);return this.httpsService.get("jobs",t,core_1.BACKEND_SERVICE.DATA_ENRICHMENT).pipe((0,rxjs_1.map)((function(r){var t,e;return{jobs:null!==(e=null===(t=r.results)||void 0===t?void 0:t.map((function(r){return(0,enrichment_job_1.enrichmentJobFromAPIResponse)(r)})))&&void 0!==e?e:[],nextCursor:(0,core_1.extractNextCursor)(r)}})))},t.prototype.fetchEnrichmentJobPartsPage=function(r){var t=r.jobId,e=__rest(r,["jobId"]),n=(0,core_1.toQueryParams)(e);return this.httpsService.get("jobs/".concat(t,"/parts"),n,core_1.BACKEND_SERVICE.DATA_ENRICHMENT).pipe((0,rxjs_1.map)((function(r){var t,e;return{parts:null!==(e=null===(t=r.results)||void 0===t?void 0:t.map((function(r){return(0,enrichment_job_part_1.enrichmentJobPartFromAPIResponse)(r)})))&&void 0!==e?e:[],partsSummary:r.partsSummary,nextCursor:(0,core_1.extractNextCursor)(r)}})))},t=__decorate([(0,core_1.InjectionIdentifier)("DataEnrichmentService")],t)}(core_1.BaseService);exports.DataEnrichmentServiceImpl=DataEnrichmentServiceImpl;
|
package/gen/sdk-version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
export declare const SDK_VERSION_NUMBER = "15.
|
|
2
|
+
export declare const SDK_VERSION_NUMBER = "15.16.0";
|
package/gen/sdk-version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.16.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@partium/js-sdk",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.16.0",
|
|
4
4
|
"author": "Partium Inc.",
|
|
5
5
|
"license": "See LICENSE.txt",
|
|
6
6
|
"description": "The Partium Find SDK enables integration of Partium’s parts and materials search capabilities into JavaScript-based applications.",
|