@localazy/generic-connector-client
Advanced tools
Comparing version 0.2.3 to 0.3.0
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LocalazyCDN={})}(this,(function(e){"use strict";var t=Object.defineProperty,a=(e,a,n)=>(((e,a,n)=>{a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n})(e,"symbol"!=typeof a?a+"":a,n),n); | ||
/* @localazy/generic-connector-client@0.2.3 | ||
/* @localazy/generic-connector-client@0.3.0 | ||
* (c) 2024 Localazy <team@localazy.com> | ||
* @license MIT */ | ||
class n{constructor(e){a(this,"genericConnectorUrl"),a(this,"pluginId"),this.genericConnectorUrl=e.genericConnectorUrl||"https://plugins.localazy.com/generic-connector",this.pluginId=e.pluginId}async get(e,t){return this.makeRequest("GET",e,t)}async post(e,t,a){return this.makeRequest("POST",e,a,t)}async put(e,t,a){return this.makeRequest("PUT",e,a,t)}async delete(e,t){return this.makeRequest("DELETE",e,t)}urlFactory(e){return`${this.genericConnectorUrl}${e}`}configFactory(e,t,a){const n={method:e,headers:{...(null==t?void 0:t.headers)||{},"X-Localazy-Plugin-Id":`${this.pluginId}`,Accept:"application/json","Content-Type":"application/json"}};return a&&(n.body=JSON.stringify(a)),n}async makeRequest(e,t,a,n){let i=this.urlFactory(t);if("GET"===e&&(null==a?void 0:a.params)){i+=`?${new URLSearchParams(a.params).toString()}`}const s=await fetch(i,this.configFactory(e,a,n)),r=s.headers.get("content-type"),o="blob"===(null==a?void 0:a.responseType)||!1,c=(null==r?void 0:r.startsWith("application/json"))||!1;let l;if(l=o?await s.blob():c?await s.json():await s.text(),s.status>=400){const e=c&&l.error?l.error:s.statusText;throw new Error(`Request failed with status code ${s.status}: ${e}`)}return l}}class i{constructor(e){a(this,"api"),this.api=e}}class s extends i{async keys(e){return await this.api.client.get("/public/keys",{...e})}}class r extends i{async poll(e,t){return await this.api.client.get("/oauth/poll",{...t,params:{...null==t?void 0:t.params,...e}})}async continuousPoll(e,t){const a=e.pollingMaxAttempts||60,n=e.pollingIntervalMs||2e3;let i=1,s=await this.poll({readKey:e.readKey},t);return s.completed?s:new Promise(((r,o)=>{const c=setInterval((async()=>{s=await this.poll({readKey:e.readKey},t),s.completed&&(clearInterval(c),r(s)),i+=1,i>=a&&(clearInterval(c),o(new Error("Sign in attempts timed out.")))}),n)}))}}class o extends i{async track(e,t){return await this.api.client.post("/analytics/track",e,t)}}var c=(e=>(e[e.UNKNOWN_SERVICE=-1]="UNKNOWN_SERVICE",e[e.FIGMA=0]="FIGMA",e[e.STRAPI=1]="STRAPI",e[e.ZAPIER=2]="ZAPIER",e[e.STORYBLOK=3]="STORYBLOK",e[e.INTERCOM=4]="INTERCOM",e[e.DIRECTUS=5]="DIRECTUS",e))(c||{});e.ApiAnalytics=o,e.ApiBase=i,e.ApiOAuth=r,e.ApiPublic=s,e.FetchHttpAdapter=n,e.GenericConnectorClient=class{constructor(e){a(this,"client"),a(this,"public"),a(this,"oauth"),a(this,"analytics"),this.client=new n(e),this.public=new s(this),this.oauth=new r(this),this.analytics=new o(this)}},e.Services=c,e.getOAuthAuthorizationUrl=function(e,t){const a=new URLSearchParams;a.append("client_id",e.clientId),e.redirectUri&&a.append("redirect_uri",e.redirectUri),e.customId&&a.append("custom_id",e.customId),e.state&&a.append("state",e.state),e.scope&&a.append("scope",e.scope),e.allowCreate&&a.append("allow_create",e.allowCreate.toString()),e.createType&&a.append("create_type",e.createType),e.createLocale&&a.append("create_locale",e.createLocale),e.minimalRole&&a.append("minimal_role",e.minimalRole);const n=t||"https://localazy.com";return"/"!==new URL(n).pathname?`${n}?${a.toString()}`:`${n}/oauth/authorize?${a.toString()}`},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})})); | ||
class n{constructor(e){a(this,"genericConnectorUrl"),a(this,"pluginId"),this.genericConnectorUrl=e.genericConnectorUrl||"https://plugins.localazy.com/generic-connector",this.pluginId=e.pluginId}async get(e,t){return this.makeRequest("GET",e,t)}async post(e,t,a){return this.makeRequest("POST",e,a,t)}async put(e,t,a){return this.makeRequest("PUT",e,a,t)}async delete(e,t){return this.makeRequest("DELETE",e,t)}urlFactory(e){return`${this.genericConnectorUrl}${e}`}configFactory(e,t,a){const n={method:e,headers:{...(null==t?void 0:t.headers)||{},"X-Localazy-Plugin-Id":`${this.pluginId}`,Accept:"application/json","Content-Type":"application/json"}};return a&&(n.body=JSON.stringify(a)),n}async makeRequest(e,t,a,n){let i=this.urlFactory(t);if("GET"===e&&(null==a?void 0:a.params)){i+=`?${new URLSearchParams(a.params).toString()}`}const s=await fetch(i,this.configFactory(e,a,n)),r=s.headers.get("content-type"),o="blob"===(null==a?void 0:a.responseType)||!1,c=(null==r?void 0:r.startsWith("application/json"))||!1;let l;if(l=o?await s.blob():c?await s.json():await s.text(),s.status>=400){const e=c&&l.error?l.error:s.statusText;throw new Error(`Request failed with status code ${s.status}: ${e}`)}return l}}class i{constructor(e){a(this,"api"),this.api=e}}class s extends i{async keys(e){return await this.api.client.get("/public/keys",{...e})}}class r extends i{async poll(e,t){return await this.api.client.get("/oauth/poll",{...t,params:{...null==t?void 0:t.params,...e}})}async continuousPoll(e,t){const a=e.pollingMaxAttempts||60,n=e.pollingIntervalMs||2e3;let i=1,s=await this.poll({readKey:e.readKey},t);return s.completed?s:new Promise(((r,o)=>{const c=setInterval((async()=>{s=await this.poll({readKey:e.readKey},t),s.completed&&(clearInterval(c),r(s)),i+=1,i>=a&&(clearInterval(c),o(new Error("Sign in attempts timed out.")))}),n)}))}}class o extends i{async track(e,t){return await this.api.client.post("/analytics/track",e,t)}}var c=(e=>(e[e.UNKNOWN_SERVICE=-1]="UNKNOWN_SERVICE",e[e.FIGMA=0]="FIGMA",e[e.STRAPI=1]="STRAPI",e[e.ZAPIER=2]="ZAPIER",e[e.STORYBLOK=3]="STORYBLOK",e[e.INTERCOM=4]="INTERCOM",e[e.DIRECTUS=5]="DIRECTUS",e[e.ZENDESK=6]="ZENDESK",e))(c||{});e.ApiAnalytics=o,e.ApiBase=i,e.ApiOAuth=r,e.ApiPublic=s,e.FetchHttpAdapter=n,e.GenericConnectorClient=class{constructor(e){a(this,"client"),a(this,"public"),a(this,"oauth"),a(this,"analytics"),this.client=new n(e),this.public=new s(this),this.oauth=new r(this),this.analytics=new o(this)}},e.Services=c,e.getOAuthAuthorizationUrl=function(e,t){const a=new URLSearchParams;a.append("client_id",e.clientId),e.redirectUri&&a.append("redirect_uri",e.redirectUri),e.customId&&a.append("custom_id",e.customId),e.state&&a.append("state",e.state),e.scope&&a.append("scope",e.scope),e.allowCreate&&a.append("allow_create",e.allowCreate.toString()),e.createType&&a.append("create_type",e.createType),e.createLocale&&a.append("create_locale",e.createLocale),e.minimalRole&&a.append("minimal_role",e.minimalRole);const n=t||"https://localazy.com";return"/"!==new URL(n).pathname?`${n}?${a.toString()}`:`${n}/oauth/authorize?${a.toString()}`},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})})); | ||
//# sourceMappingURL=localazy-generic-connector-client.umd.min.js.map |
@@ -199,3 +199,4 @@ import { Locales } from '@localazy/languages'; | ||
'INTERCOM' = 4, | ||
'DIRECTUS' = 5 | ||
'DIRECTUS' = 5, | ||
'ZENDESK' = 6 | ||
} | ||
@@ -202,0 +203,0 @@ |
@@ -7,3 +7,3 @@ var __defProp = Object.defineProperty; | ||
}; | ||
/* @localazy/generic-connector-client@0.2.3 | ||
/* @localazy/generic-connector-client@0.3.0 | ||
* (c) 2024 Localazy <team@localazy.com> | ||
@@ -153,2 +153,3 @@ * @license MIT */ | ||
Services2[Services2["DIRECTUS"] = 5] = "DIRECTUS"; | ||
Services2[Services2["ZENDESK"] = 6] = "ZENDESK"; | ||
return Services2; | ||
@@ -155,0 +156,0 @@ })(Services || {}); |
var t=Object.defineProperty,e=(e,a,n)=>(((e,a,n)=>{a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n})(e,"symbol"!=typeof a?a+"":a,n),n); | ||
/* @localazy/generic-connector-client@0.2.3 | ||
/* @localazy/generic-connector-client@0.3.0 | ||
* (c) 2024 Localazy <team@localazy.com> | ||
* @license MIT */ | ||
class a{constructor(t){e(this,"genericConnectorUrl"),e(this,"pluginId"),this.genericConnectorUrl=t.genericConnectorUrl||"https://plugins.localazy.com/generic-connector",this.pluginId=t.pluginId}async get(t,e){return this.makeRequest("GET",t,e)}async post(t,e,a){return this.makeRequest("POST",t,a,e)}async put(t,e,a){return this.makeRequest("PUT",t,a,e)}async delete(t,e){return this.makeRequest("DELETE",t,e)}urlFactory(t){return`${this.genericConnectorUrl}${t}`}configFactory(t,e,a){const n={method:t,headers:{...(null==e?void 0:e.headers)||{},"X-Localazy-Plugin-Id":`${this.pluginId}`,Accept:"application/json","Content-Type":"application/json"}};return a&&(n.body=JSON.stringify(a)),n}async makeRequest(t,e,a,n){let s=this.urlFactory(e);if("GET"===t&&(null==a?void 0:a.params)){s+=`?${new URLSearchParams(a.params).toString()}`}const r=await fetch(s,this.configFactory(t,a,n)),i=r.headers.get("content-type"),o="blob"===(null==a?void 0:a.responseType)||!1,c=(null==i?void 0:i.startsWith("application/json"))||!1;let l;if(l=o?await r.blob():c?await r.json():await r.text(),r.status>=400){const t=c&&l.error?l.error:r.statusText;throw new Error(`Request failed with status code ${r.status}: ${t}`)}return l}}class n{constructor(t){e(this,"api"),this.api=t}}class s extends n{async keys(t){return await this.api.client.get("/public/keys",{...t})}}class r extends n{async poll(t,e){return await this.api.client.get("/oauth/poll",{...e,params:{...null==e?void 0:e.params,...t}})}async continuousPoll(t,e){const a=t.pollingMaxAttempts||60,n=t.pollingIntervalMs||2e3;let s=1,r=await this.poll({readKey:t.readKey},e);return r.completed?r:new Promise(((i,o)=>{const c=setInterval((async()=>{r=await this.poll({readKey:t.readKey},e),r.completed&&(clearInterval(c),i(r)),s+=1,s>=a&&(clearInterval(c),o(new Error("Sign in attempts timed out.")))}),n)}))}}class i extends n{async track(t,e){return await this.api.client.post("/analytics/track",t,e)}}class o{constructor(t){e(this,"client"),e(this,"public"),e(this,"oauth"),e(this,"analytics"),this.client=new a(t),this.public=new s(this),this.oauth=new r(this),this.analytics=new i(this)}}var c=(t=>(t[t.UNKNOWN_SERVICE=-1]="UNKNOWN_SERVICE",t[t.FIGMA=0]="FIGMA",t[t.STRAPI=1]="STRAPI",t[t.ZAPIER=2]="ZAPIER",t[t.STORYBLOK=3]="STORYBLOK",t[t.INTERCOM=4]="INTERCOM",t[t.DIRECTUS=5]="DIRECTUS",t))(c||{});function l(t,e){const a=new URLSearchParams;a.append("client_id",t.clientId),t.redirectUri&&a.append("redirect_uri",t.redirectUri),t.customId&&a.append("custom_id",t.customId),t.state&&a.append("state",t.state),t.scope&&a.append("scope",t.scope),t.allowCreate&&a.append("allow_create",t.allowCreate.toString()),t.createType&&a.append("create_type",t.createType),t.createLocale&&a.append("create_locale",t.createLocale),t.minimalRole&&a.append("minimal_role",t.minimalRole);const n=e||"https://localazy.com";return"/"!==new URL(n).pathname?`${n}?${a.toString()}`:`${n}/oauth/authorize?${a.toString()}`}export{i as ApiAnalytics,n as ApiBase,r as ApiOAuth,s as ApiPublic,a as FetchHttpAdapter,o as GenericConnectorClient,c as Services,l as getOAuthAuthorizationUrl}; | ||
class a{constructor(t){e(this,"genericConnectorUrl"),e(this,"pluginId"),this.genericConnectorUrl=t.genericConnectorUrl||"https://plugins.localazy.com/generic-connector",this.pluginId=t.pluginId}async get(t,e){return this.makeRequest("GET",t,e)}async post(t,e,a){return this.makeRequest("POST",t,a,e)}async put(t,e,a){return this.makeRequest("PUT",t,a,e)}async delete(t,e){return this.makeRequest("DELETE",t,e)}urlFactory(t){return`${this.genericConnectorUrl}${t}`}configFactory(t,e,a){const n={method:t,headers:{...(null==e?void 0:e.headers)||{},"X-Localazy-Plugin-Id":`${this.pluginId}`,Accept:"application/json","Content-Type":"application/json"}};return a&&(n.body=JSON.stringify(a)),n}async makeRequest(t,e,a,n){let s=this.urlFactory(e);if("GET"===t&&(null==a?void 0:a.params)){s+=`?${new URLSearchParams(a.params).toString()}`}const r=await fetch(s,this.configFactory(t,a,n)),i=r.headers.get("content-type"),o="blob"===(null==a?void 0:a.responseType)||!1,c=(null==i?void 0:i.startsWith("application/json"))||!1;let l;if(l=o?await r.blob():c?await r.json():await r.text(),r.status>=400){const t=c&&l.error?l.error:r.statusText;throw new Error(`Request failed with status code ${r.status}: ${t}`)}return l}}class n{constructor(t){e(this,"api"),this.api=t}}class s extends n{async keys(t){return await this.api.client.get("/public/keys",{...t})}}class r extends n{async poll(t,e){return await this.api.client.get("/oauth/poll",{...e,params:{...null==e?void 0:e.params,...t}})}async continuousPoll(t,e){const a=t.pollingMaxAttempts||60,n=t.pollingIntervalMs||2e3;let s=1,r=await this.poll({readKey:t.readKey},e);return r.completed?r:new Promise(((i,o)=>{const c=setInterval((async()=>{r=await this.poll({readKey:t.readKey},e),r.completed&&(clearInterval(c),i(r)),s+=1,s>=a&&(clearInterval(c),o(new Error("Sign in attempts timed out.")))}),n)}))}}class i extends n{async track(t,e){return await this.api.client.post("/analytics/track",t,e)}}class o{constructor(t){e(this,"client"),e(this,"public"),e(this,"oauth"),e(this,"analytics"),this.client=new a(t),this.public=new s(this),this.oauth=new r(this),this.analytics=new i(this)}}var c=(t=>(t[t.UNKNOWN_SERVICE=-1]="UNKNOWN_SERVICE",t[t.FIGMA=0]="FIGMA",t[t.STRAPI=1]="STRAPI",t[t.ZAPIER=2]="ZAPIER",t[t.STORYBLOK=3]="STORYBLOK",t[t.INTERCOM=4]="INTERCOM",t[t.DIRECTUS=5]="DIRECTUS",t[t.ZENDESK=6]="ZENDESK",t))(c||{});function l(t,e){const a=new URLSearchParams;a.append("client_id",t.clientId),t.redirectUri&&a.append("redirect_uri",t.redirectUri),t.customId&&a.append("custom_id",t.customId),t.state&&a.append("state",t.state),t.scope&&a.append("scope",t.scope),t.allowCreate&&a.append("allow_create",t.allowCreate.toString()),t.createType&&a.append("create_type",t.createType),t.createLocale&&a.append("create_locale",t.createLocale),t.minimalRole&&a.append("minimal_role",t.minimalRole);const n=e||"https://localazy.com";return"/"!==new URL(n).pathname?`${n}?${a.toString()}`:`${n}/oauth/authorize?${a.toString()}`}export{i as ApiAnalytics,n as ApiBase,r as ApiOAuth,s as ApiPublic,a as FetchHttpAdapter,o as GenericConnectorClient,c as Services,l as getOAuthAuthorizationUrl}; | ||
//# sourceMappingURL=localazy-generic-connector-client.min.js.map |
{ | ||
"name": "@localazy/generic-connector-client", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "Node.js module that allows to interact with the Localazy Generic Connector.", | ||
@@ -83,4 +83,4 @@ "author": "Localazy <team@localazy.com>", | ||
"@vitest/ui": "^1.4.0", | ||
"conventional-changelog": "^5.1.0", | ||
"conventional-changelog-cli": "^4.1.0", | ||
"conventional-changelog": "^6.0.0", | ||
"conventional-changelog-cli": "^5.0.0", | ||
"conventional-changelog-writer": "github:localazy/conventional-changelog-writer", | ||
@@ -87,0 +87,0 @@ "conventional-recommended-bump": "^9.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
85949
614
4