bundlesocial 1.0.0 → 1.2.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/dist/index.d.mts +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -133,6 +133,14 @@ type TeamGetTeamResponse = {
|
|
|
133
133
|
updatedAt: string | null;
|
|
134
134
|
deletedAt?: string | null;
|
|
135
135
|
}>;
|
|
136
|
+
webhooks: Array<{
|
|
137
|
+
id: string;
|
|
138
|
+
teamId: string;
|
|
139
|
+
url: string;
|
|
140
|
+
createdAt: string | null;
|
|
141
|
+
updatedAt: string | null;
|
|
142
|
+
deletedAt?: string | null;
|
|
143
|
+
}>;
|
|
136
144
|
socialAccounts: Array<{
|
|
137
145
|
id: string;
|
|
138
146
|
type: 'TIKTOK' | 'YOUTUBE' | 'INSTAGRAM' | 'FACEBOOK' | 'TWITTER' | 'THREADS' | 'LINKEDIN' | 'PINTEREST' | 'REDDIT' | 'TELEGRAM' | 'DISCORD' | 'SLACK';
|
|
@@ -1473,6 +1481,14 @@ type $OpenApiTs = {
|
|
|
1473
1481
|
updatedAt: string | null;
|
|
1474
1482
|
deletedAt?: string | null;
|
|
1475
1483
|
}>;
|
|
1484
|
+
webhooks: Array<{
|
|
1485
|
+
id: string;
|
|
1486
|
+
teamId: string;
|
|
1487
|
+
url: string;
|
|
1488
|
+
createdAt: string | null;
|
|
1489
|
+
updatedAt: string | null;
|
|
1490
|
+
deletedAt?: string | null;
|
|
1491
|
+
}>;
|
|
1476
1492
|
socialAccounts: Array<{
|
|
1477
1493
|
id: string;
|
|
1478
1494
|
type: 'TIKTOK' | 'YOUTUBE' | 'INSTAGRAM' | 'FACEBOOK' | 'TWITTER' | 'THREADS' | 'LINKEDIN' | 'PINTEREST' | 'REDDIT' | 'TELEGRAM' | 'DISCORD' | 'SLACK';
|
|
@@ -3103,8 +3119,33 @@ declare class ApiError extends Error {
|
|
|
3103
3119
|
constructor(request: ApiRequestOptions, response: ApiResult, message: string);
|
|
3104
3120
|
}
|
|
3105
3121
|
|
|
3122
|
+
type WebhookEventType = 'post.published';
|
|
3123
|
+
type WebhookEvent = {
|
|
3124
|
+
type: 'post.published';
|
|
3125
|
+
data: PostGetResponse;
|
|
3126
|
+
};
|
|
3127
|
+
declare class Webhooks {
|
|
3128
|
+
constructor();
|
|
3129
|
+
/**
|
|
3130
|
+
* Verify the signature of a webhook request
|
|
3131
|
+
* @param body - Stringified body of the webhook request
|
|
3132
|
+
* @param signature - The signature passed in the `x-signature` header
|
|
3133
|
+
* @param secret - The webhook secret used to sign the request
|
|
3134
|
+
* @returns Whether the signature is valid
|
|
3135
|
+
*/
|
|
3136
|
+
private verifySignature;
|
|
3137
|
+
/**
|
|
3138
|
+
* Construct a webhook event from a request
|
|
3139
|
+
* @param rawBody - The raw body of the webhook request
|
|
3140
|
+
* @param signature - The signature passed in the `x-signature` header
|
|
3141
|
+
* @param secret - The webhook secret used to sign the request
|
|
3142
|
+
* @returns Parsed webhook event
|
|
3143
|
+
*/
|
|
3144
|
+
constructEvent(rawBody: string, signature: string, secret: string): WebhookEvent;
|
|
3145
|
+
}
|
|
3106
3146
|
declare class Bundlesocial extends Client {
|
|
3147
|
+
webhooks: Webhooks;
|
|
3107
3148
|
constructor(apiKey: string, options?: OpenAPIConfig);
|
|
3108
3149
|
}
|
|
3109
3150
|
|
|
3110
|
-
export { $OpenApiTs, ApiError, AppGetHealthResponse, BaseHttpRequest, Bundlesocial, CancelError, CancelablePromise, OpenAPI, OpenAPIConfig, PostCreateData, PostCreateResponse, PostDeleteData, PostDeleteResponse, PostGetData, PostGetListData, PostGetListResponse, PostGetResponse, PostUpdateData, PostUpdateResponse, TeamGetTeamResponse, UploadCreateData, UploadCreateResponse, UploadDeleteData, UploadDeleteManyData, UploadDeleteManyResponse, UploadDeleteResponse, UploadGetData, UploadGetListResponse, UploadGetResponse };
|
|
3151
|
+
export { $OpenApiTs, ApiError, AppGetHealthResponse, BaseHttpRequest, Bundlesocial, CancelError, CancelablePromise, OpenAPI, OpenAPIConfig, PostCreateData, PostCreateResponse, PostDeleteData, PostDeleteResponse, PostGetData, PostGetListData, PostGetListResponse, PostGetResponse, PostUpdateData, PostUpdateResponse, TeamGetTeamResponse, UploadCreateData, UploadCreateResponse, UploadDeleteData, UploadDeleteManyData, UploadDeleteManyResponse, UploadDeleteResponse, UploadGetData, UploadGetListResponse, UploadGetResponse, WebhookEvent, WebhookEventType };
|
package/dist/index.d.ts
CHANGED
|
@@ -133,6 +133,14 @@ type TeamGetTeamResponse = {
|
|
|
133
133
|
updatedAt: string | null;
|
|
134
134
|
deletedAt?: string | null;
|
|
135
135
|
}>;
|
|
136
|
+
webhooks: Array<{
|
|
137
|
+
id: string;
|
|
138
|
+
teamId: string;
|
|
139
|
+
url: string;
|
|
140
|
+
createdAt: string | null;
|
|
141
|
+
updatedAt: string | null;
|
|
142
|
+
deletedAt?: string | null;
|
|
143
|
+
}>;
|
|
136
144
|
socialAccounts: Array<{
|
|
137
145
|
id: string;
|
|
138
146
|
type: 'TIKTOK' | 'YOUTUBE' | 'INSTAGRAM' | 'FACEBOOK' | 'TWITTER' | 'THREADS' | 'LINKEDIN' | 'PINTEREST' | 'REDDIT' | 'TELEGRAM' | 'DISCORD' | 'SLACK';
|
|
@@ -1473,6 +1481,14 @@ type $OpenApiTs = {
|
|
|
1473
1481
|
updatedAt: string | null;
|
|
1474
1482
|
deletedAt?: string | null;
|
|
1475
1483
|
}>;
|
|
1484
|
+
webhooks: Array<{
|
|
1485
|
+
id: string;
|
|
1486
|
+
teamId: string;
|
|
1487
|
+
url: string;
|
|
1488
|
+
createdAt: string | null;
|
|
1489
|
+
updatedAt: string | null;
|
|
1490
|
+
deletedAt?: string | null;
|
|
1491
|
+
}>;
|
|
1476
1492
|
socialAccounts: Array<{
|
|
1477
1493
|
id: string;
|
|
1478
1494
|
type: 'TIKTOK' | 'YOUTUBE' | 'INSTAGRAM' | 'FACEBOOK' | 'TWITTER' | 'THREADS' | 'LINKEDIN' | 'PINTEREST' | 'REDDIT' | 'TELEGRAM' | 'DISCORD' | 'SLACK';
|
|
@@ -3103,8 +3119,33 @@ declare class ApiError extends Error {
|
|
|
3103
3119
|
constructor(request: ApiRequestOptions, response: ApiResult, message: string);
|
|
3104
3120
|
}
|
|
3105
3121
|
|
|
3122
|
+
type WebhookEventType = 'post.published';
|
|
3123
|
+
type WebhookEvent = {
|
|
3124
|
+
type: 'post.published';
|
|
3125
|
+
data: PostGetResponse;
|
|
3126
|
+
};
|
|
3127
|
+
declare class Webhooks {
|
|
3128
|
+
constructor();
|
|
3129
|
+
/**
|
|
3130
|
+
* Verify the signature of a webhook request
|
|
3131
|
+
* @param body - Stringified body of the webhook request
|
|
3132
|
+
* @param signature - The signature passed in the `x-signature` header
|
|
3133
|
+
* @param secret - The webhook secret used to sign the request
|
|
3134
|
+
* @returns Whether the signature is valid
|
|
3135
|
+
*/
|
|
3136
|
+
private verifySignature;
|
|
3137
|
+
/**
|
|
3138
|
+
* Construct a webhook event from a request
|
|
3139
|
+
* @param rawBody - The raw body of the webhook request
|
|
3140
|
+
* @param signature - The signature passed in the `x-signature` header
|
|
3141
|
+
* @param secret - The webhook secret used to sign the request
|
|
3142
|
+
* @returns Parsed webhook event
|
|
3143
|
+
*/
|
|
3144
|
+
constructEvent(rawBody: string, signature: string, secret: string): WebhookEvent;
|
|
3145
|
+
}
|
|
3106
3146
|
declare class Bundlesocial extends Client {
|
|
3147
|
+
webhooks: Webhooks;
|
|
3107
3148
|
constructor(apiKey: string, options?: OpenAPIConfig);
|
|
3108
3149
|
}
|
|
3109
3150
|
|
|
3110
|
-
export { $OpenApiTs, ApiError, AppGetHealthResponse, BaseHttpRequest, Bundlesocial, CancelError, CancelablePromise, OpenAPI, OpenAPIConfig, PostCreateData, PostCreateResponse, PostDeleteData, PostDeleteResponse, PostGetData, PostGetListData, PostGetListResponse, PostGetResponse, PostUpdateData, PostUpdateResponse, TeamGetTeamResponse, UploadCreateData, UploadCreateResponse, UploadDeleteData, UploadDeleteManyData, UploadDeleteManyResponse, UploadDeleteResponse, UploadGetData, UploadGetListResponse, UploadGetResponse };
|
|
3151
|
+
export { $OpenApiTs, ApiError, AppGetHealthResponse, BaseHttpRequest, Bundlesocial, CancelError, CancelablePromise, OpenAPI, OpenAPIConfig, PostCreateData, PostCreateResponse, PostDeleteData, PostDeleteResponse, PostGetData, PostGetListData, PostGetListResponse, PostGetResponse, PostUpdateData, PostUpdateResponse, TeamGetTeamResponse, UploadCreateData, UploadCreateResponse, UploadDeleteData, UploadDeleteManyData, UploadDeleteManyResponse, UploadDeleteResponse, UploadGetData, UploadGetListResponse, UploadGetResponse, WebhookEvent, WebhookEventType };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var A=Object.defineProperty,B=Object.defineProperties,k=Object.getOwnPropertyDescriptor,M=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var U=(t,e,r)=>e in t?A(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,u=(t,e)=>{for(var r in e||(e={}))g.call(e,r)&&U(t,r,e[r]);if(N)for(var r of N(e))$.call(e,r)&&U(t,r,e[r]);return t},f=(t,e)=>B(t,M(e));var W=(t,e)=>{for(var r in e)A(t,r,{get:e[r],enumerable:!0})},V=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of F(e))!g.call(t,s)&&s!==r&&A(t,s,{get:()=>e[s],enumerable:!(o=k(e,s))||o.enumerable});return t};var K=t=>V(A({},"__esModule",{value:!0}),t);var h=(t,e,r)=>new Promise((o,s)=>{var n=p=>{try{i(r.next(p))}catch(l){s(l)}},a=p=>{try{i(r.throw(p))}catch(l){s(l)}},i=p=>p.done?o(p.value):Promise.resolve(p.value).then(n,a);i((r=r.apply(t,e)).next())});var oe={};W(oe,{ApiError:()=>d,BaseHttpRequest:()=>m,Bundlesocial:()=>_,CancelError:()=>y,CancelablePromise:()=>R,OpenAPI:()=>q});module.exports=K(oe);var c=class{constructor(){this._fns=[]}eject(e){let r=this._fns.indexOf(e);r!==-1&&(this._fns=[...this._fns.slice(0,r),...this._fns.slice(r+1)])}use(e){this._fns=[...this._fns,e]}},q={BASE:"https://api.bundle.social",CREDENTIALS:"include",ENCODE_PATH:void 0,HEADERS:void 0,PASSWORD:void 0,TOKEN:void 0,USERNAME:void 0,VERSION:"1.0.0",WITH_CREDENTIALS:!1,interceptors:{request:new c,response:new c}};var m=class{constructor(e){this.config=e}};var d=class extends Error{constructor(r,o,s){super(s);this.name="ApiError",this.url=o.url,this.status=o.status,this.statusText=o.statusText,this.body=o.body,this.request=r}};var y=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},R=class{constructor(e){this._isResolved=!1,this._isRejected=!1,this._isCancelled=!1,this.cancelHandlers=[],this.promise=new Promise((r,o)=>{this._resolve=r,this._reject=o;let s=i=>{this._isResolved||this._isRejected||this._isCancelled||(this._isResolved=!0,this._resolve&&this._resolve(i))},n=i=>{this._isResolved||this._isRejected||this._isCancelled||(this._isRejected=!0,this._reject&&this._reject(i))},a=i=>{this._isResolved||this._isRejected||this._isCancelled||this.cancelHandlers.push(i)};return Object.defineProperty(a,"isResolved",{get:()=>this._isResolved}),Object.defineProperty(a,"isRejected",{get:()=>this._isRejected}),Object.defineProperty(a,"isCancelled",{get:()=>this._isCancelled}),e(s,n,a)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(e,r){return this.promise.then(e,r)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e)}cancel(){if(!(this._isResolved||this._isRejected||this._isCancelled)){if(this._isCancelled=!0,this.cancelHandlers.length)try{for(let e of this.cancelHandlers)e()}catch(e){console.warn("Cancellation threw an error",e);return}this.cancelHandlers.length=0,this._reject&&this._reject(new y("Request aborted"))}}get isCancelled(){return this._isCancelled}};var b=t=>typeof t=="string",w=t=>b(t)&&t!=="",I=t=>t instanceof Blob,j=t=>t instanceof FormData,z=t=>{try{return btoa(t)}catch(e){return Buffer.from(t).toString("base64")}},J=t=>{let e=[],r=(s,n)=>{e.push(`${encodeURIComponent(s)}=${encodeURIComponent(String(n))}`)},o=(s,n)=>{n!=null&&(n instanceof Date?r(s,n.toISOString()):Array.isArray(n)?n.forEach(a=>o(s,a)):typeof n=="object"?Object.entries(n).forEach(([a,i])=>o(`${s}[${a}]`,i)):r(s,n))};return Object.entries(t).forEach(([s,n])=>o(s,n)),e.length?`?${e.join("&")}`:""},Q=(t,e)=>{let r=t.ENCODE_PATH||encodeURI,o=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(n,a)=>{var i;return(i=e.path)!=null&&i.hasOwnProperty(a)?r(String(e.path[a])):n}),s=t.BASE+o;return e.query?s+J(e.query):s},X=t=>{if(t.formData){let e=new FormData,r=(o,s)=>{b(s)||I(s)?e.append(o,s):e.append(o,JSON.stringify(s))};return Object.entries(t.formData).filter(([,o])=>o!=null).forEach(([o,s])=>{Array.isArray(s)?s.forEach(n=>r(o,n)):r(o,s)}),e}},C=(t,e)=>h(void 0,null,function*(){return typeof e=="function"?e(t):e}),Y=(t,e)=>h(void 0,null,function*(){let[r,o,s,n]=yield Promise.all([C(e,t.TOKEN),C(e,t.USERNAME),C(e,t.PASSWORD),C(e,t.HEADERS)]),a=Object.entries(u(u({Accept:"application/json"},n),e.headers)).filter(([,i])=>i!=null).reduce((i,[p,l])=>f(u({},i),{[p]:String(l)}),{});if(w(r)&&(a.Authorization=`Bearer ${r}`),w(o)&&w(s)){let i=z(`${o}:${s}`);a.Authorization=`Basic ${i}`}return e.body!==void 0&&(e.mediaType?a["Content-Type"]=e.mediaType:I(e.body)?a["Content-Type"]=e.body.type||"application/octet-stream":b(e.body)?a["Content-Type"]="text/plain":j(e.body)||(a["Content-Type"]="application/json")),new Headers(a)}),Z=t=>{var e,r;if(t.body!==void 0)return(e=t.mediaType)!=null&&e.includes("application/json")||(r=t.mediaType)!=null&&r.includes("+json")?JSON.stringify(t.body):b(t.body)||I(t.body)||j(t.body)?t.body:JSON.stringify(t.body)},ee=(t,e,r,o,s,n,a)=>h(void 0,null,function*(){let i=new AbortController,p={headers:n,body:o!=null?o:s,method:e.method,signal:i.signal};t.WITH_CREDENTIALS&&(p.credentials=t.CREDENTIALS);for(let l of t.interceptors.request._fns)p=yield l(p);return a(()=>i.abort()),yield fetch(r,p)}),te=(t,e)=>{if(e){let r=t.headers.get(e);if(b(r))return r}},re=t=>h(void 0,null,function*(){if(t.status!==204)try{let e=t.headers.get("Content-Type");if(e){let r=["application/octet-stream","application/pdf","application/zip","audio/","image/","video/"];if(e.includes("application/json")||e.includes("+json"))return yield t.json();if(r.some(o=>e.includes(o)))return yield t.blob();if(e.includes("multipart/form-data"))return yield t.formData();if(e.includes("text/"))return yield t.text()}}catch(e){console.error(e)}}),se=(t,e)=>{var s,n;let o=u({400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"Im a teapot",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"},t.errors)[e.status];if(o)throw new d(t,e,o);if(!e.ok){let a=(s=e.status)!=null?s:"unknown",i=(n=e.statusText)!=null?n:"unknown",p=(()=>{try{return JSON.stringify(e.body,null,2)}catch(l){return}})();throw new d(t,e,`Generic Error: status: ${a}; status text: ${i}; body: ${p}`)}},G=(t,e)=>new R((r,o,s)=>h(void 0,null,function*(){try{let n=Q(t,e),a=X(e),i=Z(e),p=yield Y(t,e);if(!s.isCancelled){let l=yield ee(t,e,n,i,a,p,s);for(let L of t.interceptors.response._fns)l=yield L(l);let P=yield re(l),v=te(l,e.responseHeader),H={url:n,ok:l.ok,status:l.status,statusText:l.statusText,body:v!=null?v:P};se(e,H),r(H.body)}}catch(n){o(n)}}));var E=class extends m{constructor(e){super(e)}request(e){return G(this.config,e)}};var O=class{constructor(e){this.httpRequest=e}appGetHealth(){return this.httpRequest.request({method:"GET",url:"/api/v1/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},D=class{constructor(e){this.httpRequest=e}teamGetTeam(){return this.httpRequest.request({method:"GET",url:"/api/v1/team/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},S=class{constructor(e){this.httpRequest=e}uploadCreate(e={}){return this.httpRequest.request({method:"POST",url:"/api/v1/upload/",formData:e.formData,mediaType:"multipart/form-data",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadGetList(){return this.httpRequest.request({method:"GET",url:"/api/v1/upload/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadDeleteMany(e={}){return this.httpRequest.request({method:"DELETE",url:"/api/v1/upload/",body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadGet(e){return this.httpRequest.request({method:"GET",url:"/api/v1/upload/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadDelete(e){return this.httpRequest.request({method:"DELETE",url:"/api/v1/upload/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},x=class{constructor(e){this.httpRequest=e}postCreate(e={}){return this.httpRequest.request({method:"POST",url:"/api/v1/post/",body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postGetList(e={}){return this.httpRequest.request({method:"GET",url:"/api/v1/post/",query:{status:e.status,orderBy:e.orderBy,order:e.order,q:e.q,platforms:e.platforms,offset:e.offset,limit:e.limit},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postGet(e){return this.httpRequest.request({method:"GET",url:"/api/v1/post/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postUpdate(e){return this.httpRequest.request({method:"PUT",url:"/api/v1/post/{id}",path:{id:e.id},body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postDelete(e){return this.httpRequest.request({method:"DELETE",url:"/api/v1/post/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}};var T=class{constructor(e,r=E){var o,s,n,a,i,p,l,P;this.request=new r({BASE:(o=e==null?void 0:e.BASE)!=null?o:"https://api.bundle.social",VERSION:(s=e==null?void 0:e.VERSION)!=null?s:"1.0.0",WITH_CREDENTIALS:(n=e==null?void 0:e.WITH_CREDENTIALS)!=null?n:!1,CREDENTIALS:(a=e==null?void 0:e.CREDENTIALS)!=null?a:"include",TOKEN:e==null?void 0:e.TOKEN,USERNAME:e==null?void 0:e.USERNAME,PASSWORD:e==null?void 0:e.PASSWORD,HEADERS:e==null?void 0:e.HEADERS,ENCODE_PATH:e==null?void 0:e.ENCODE_PATH,interceptors:{request:(p=(i=e==null?void 0:e.interceptors)==null?void 0:i.request)!=null?p:new c,response:(P=(l=e==null?void 0:e.interceptors)==null?void 0:l.response)!=null?P:new c}}),this.app=new O(this.request),this.post=new x(this.request),this.team=new D(this.request),this.upload=new S(this.request)}};var _=class extends T{constructor(e,r){super(f(u({},r),{HEADERS:f(u(u({},q.HEADERS),r==null?void 0:r.HEADERS),{"x-api-key":e})}))}};0&&(module.exports={ApiError,BaseHttpRequest,Bundlesocial,CancelError,CancelablePromise,OpenAPI});
|
|
1
|
+
"use strict";var F=Object.create;var f=Object.defineProperty,W=Object.defineProperties,$=Object.getOwnPropertyDescriptor,V=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols,K=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var U=(t,e,r)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,u=(t,e)=>{for(var r in e||(e={}))j.call(e,r)&&U(t,r,e[r]);if(N)for(var r of N(e))z.call(e,r)&&U(t,r,e[r]);return t},b=(t,e)=>W(t,V(e));var Q=(t,e)=>{for(var r in e)f(t,r,{get:e[r],enumerable:!0})},G=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of J(e))!j.call(t,o)&&o!==r&&f(t,o,{get:()=>e[o],enumerable:!(s=$(e,o))||s.enumerable});return t};var X=(t,e,r)=>(r=t!=null?F(K(t)):{},G(e||!t||!t.__esModule?f(r,"default",{value:t,enumerable:!0}):r,t)),Y=t=>G(f({},"__esModule",{value:!0}),t);var h=(t,e,r)=>new Promise((s,o)=>{var n=p=>{try{i(r.next(p))}catch(l){o(l)}},a=p=>{try{i(r.throw(p))}catch(l){o(l)}},i=p=>p.done?s(p.value):Promise.resolve(p.value).then(n,a);i((r=r.apply(t,e)).next())});var le={};Q(le,{ApiError:()=>d,BaseHttpRequest:()=>m,Bundlesocial:()=>g,CancelError:()=>y,CancelablePromise:()=>R,OpenAPI:()=>q});module.exports=Y(le);var c=class{constructor(){this._fns=[]}eject(e){let r=this._fns.indexOf(e);r!==-1&&(this._fns=[...this._fns.slice(0,r),...this._fns.slice(r+1)])}use(e){this._fns=[...this._fns,e]}},q={BASE:"https://api.bundle.social",CREDENTIALS:"include",ENCODE_PATH:void 0,HEADERS:void 0,PASSWORD:void 0,TOKEN:void 0,USERNAME:void 0,VERSION:"1.0.0",WITH_CREDENTIALS:!1,interceptors:{request:new c,response:new c}};var m=class{constructor(e){this.config=e}};var d=class extends Error{constructor(r,s,o){super(o);this.name="ApiError",this.url=s.url,this.status=s.status,this.statusText=s.statusText,this.body=s.body,this.request=r}};var y=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},R=class{constructor(e){this._isResolved=!1,this._isRejected=!1,this._isCancelled=!1,this.cancelHandlers=[],this.promise=new Promise((r,s)=>{this._resolve=r,this._reject=s;let o=i=>{this._isResolved||this._isRejected||this._isCancelled||(this._isResolved=!0,this._resolve&&this._resolve(i))},n=i=>{this._isResolved||this._isRejected||this._isCancelled||(this._isRejected=!0,this._reject&&this._reject(i))},a=i=>{this._isResolved||this._isRejected||this._isCancelled||this.cancelHandlers.push(i)};return Object.defineProperty(a,"isResolved",{get:()=>this._isResolved}),Object.defineProperty(a,"isRejected",{get:()=>this._isRejected}),Object.defineProperty(a,"isCancelled",{get:()=>this._isCancelled}),e(o,n,a)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(e,r){return this.promise.then(e,r)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e)}cancel(){if(!(this._isResolved||this._isRejected||this._isCancelled)){if(this._isCancelled=!0,this.cancelHandlers.length)try{for(let e of this.cancelHandlers)e()}catch(e){console.warn("Cancellation threw an error",e);return}this.cancelHandlers.length=0,this._reject&&this._reject(new y("Request aborted"))}}get isCancelled(){return this._isCancelled}};var T=t=>typeof t=="string",w=t=>T(t)&&t!=="",I=t=>t instanceof Blob,L=t=>t instanceof FormData,Z=t=>{try{return btoa(t)}catch(e){return Buffer.from(t).toString("base64")}},ee=t=>{let e=[],r=(o,n)=>{e.push(`${encodeURIComponent(o)}=${encodeURIComponent(String(n))}`)},s=(o,n)=>{n!=null&&(n instanceof Date?r(o,n.toISOString()):Array.isArray(n)?n.forEach(a=>s(o,a)):typeof n=="object"?Object.entries(n).forEach(([a,i])=>s(`${o}[${a}]`,i)):r(o,n))};return Object.entries(t).forEach(([o,n])=>s(o,n)),e.length?`?${e.join("&")}`:""},te=(t,e)=>{let r=t.ENCODE_PATH||encodeURI,s=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(n,a)=>{var i;return(i=e.path)!=null&&i.hasOwnProperty(a)?r(String(e.path[a])):n}),o=t.BASE+s;return e.query?o+ee(e.query):o},re=t=>{if(t.formData){let e=new FormData,r=(s,o)=>{T(o)||I(o)?e.append(s,o):e.append(s,JSON.stringify(o))};return Object.entries(t.formData).filter(([,s])=>s!=null).forEach(([s,o])=>{Array.isArray(o)?o.forEach(n=>r(s,n)):r(s,o)}),e}},E=(t,e)=>h(void 0,null,function*(){return typeof e=="function"?e(t):e}),se=(t,e)=>h(void 0,null,function*(){let[r,s,o,n]=yield Promise.all([E(e,t.TOKEN),E(e,t.USERNAME),E(e,t.PASSWORD),E(e,t.HEADERS)]),a=Object.entries(u(u({Accept:"application/json"},n),e.headers)).filter(([,i])=>i!=null).reduce((i,[p,l])=>b(u({},i),{[p]:String(l)}),{});if(w(r)&&(a.Authorization=`Bearer ${r}`),w(s)&&w(o)){let i=Z(`${s}:${o}`);a.Authorization=`Basic ${i}`}return e.body!==void 0&&(e.mediaType?a["Content-Type"]=e.mediaType:I(e.body)?a["Content-Type"]=e.body.type||"application/octet-stream":T(e.body)?a["Content-Type"]="text/plain":L(e.body)||(a["Content-Type"]="application/json")),new Headers(a)}),oe=t=>{var e,r;if(t.body!==void 0)return(e=t.mediaType)!=null&&e.includes("application/json")||(r=t.mediaType)!=null&&r.includes("+json")?JSON.stringify(t.body):T(t.body)||I(t.body)||L(t.body)?t.body:JSON.stringify(t.body)},ne=(t,e,r,s,o,n,a)=>h(void 0,null,function*(){let i=new AbortController,p={headers:n,body:s!=null?s:o,method:e.method,signal:i.signal};t.WITH_CREDENTIALS&&(p.credentials=t.CREDENTIALS);for(let l of t.interceptors.request._fns)p=yield l(p);return a(()=>i.abort()),yield fetch(r,p)}),ie=(t,e)=>{if(e){let r=t.headers.get(e);if(T(r))return r}},ae=t=>h(void 0,null,function*(){if(t.status!==204)try{let e=t.headers.get("Content-Type");if(e){let r=["application/octet-stream","application/pdf","application/zip","audio/","image/","video/"];if(e.includes("application/json")||e.includes("+json"))return yield t.json();if(r.some(s=>e.includes(s)))return yield t.blob();if(e.includes("multipart/form-data"))return yield t.formData();if(e.includes("text/"))return yield t.text()}}catch(e){console.error(e)}}),pe=(t,e)=>{var o,n;let s=u({400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"Im a teapot",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"},t.errors)[e.status];if(s)throw new d(t,e,s);if(!e.ok){let a=(o=e.status)!=null?o:"unknown",i=(n=e.statusText)!=null?n:"unknown",p=(()=>{try{return JSON.stringify(e.body,null,2)}catch(l){return}})();throw new d(t,e,`Generic Error: status: ${a}; status text: ${i}; body: ${p}`)}},B=(t,e)=>new R((r,s,o)=>h(void 0,null,function*(){try{let n=te(t,e),a=re(e),i=oe(e),p=yield se(t,e);if(!o.isCancelled){let l=yield ne(t,e,n,i,a,p,o);for(let M of t.interceptors.response._fns)l=yield M(l);let A=yield ae(l),x=ie(l,e.responseHeader),H={url:n,ok:l.ok,status:l.status,statusText:l.statusText,body:x!=null?x:A};pe(e,H),r(H.body)}}catch(n){s(n)}}));var C=class extends m{constructor(e){super(e)}request(e){return B(this.config,e)}};var O=class{constructor(e){this.httpRequest=e}appGetHealth(){return this.httpRequest.request({method:"GET",url:"/api/v1/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},D=class{constructor(e){this.httpRequest=e}teamGetTeam(){return this.httpRequest.request({method:"GET",url:"/api/v1/team/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},S=class{constructor(e){this.httpRequest=e}uploadCreate(e={}){return this.httpRequest.request({method:"POST",url:"/api/v1/upload/",formData:e.formData,mediaType:"multipart/form-data",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadGetList(){return this.httpRequest.request({method:"GET",url:"/api/v1/upload/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadDeleteMany(e={}){return this.httpRequest.request({method:"DELETE",url:"/api/v1/upload/",body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadGet(e){return this.httpRequest.request({method:"GET",url:"/api/v1/upload/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadDelete(e){return this.httpRequest.request({method:"DELETE",url:"/api/v1/upload/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},v=class{constructor(e){this.httpRequest=e}postCreate(e={}){return this.httpRequest.request({method:"POST",url:"/api/v1/post/",body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postGetList(e={}){return this.httpRequest.request({method:"GET",url:"/api/v1/post/",query:{status:e.status,orderBy:e.orderBy,order:e.order,q:e.q,platforms:e.platforms,offset:e.offset,limit:e.limit},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postGet(e){return this.httpRequest.request({method:"GET",url:"/api/v1/post/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postUpdate(e){return this.httpRequest.request({method:"PUT",url:"/api/v1/post/{id}",path:{id:e.id},body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postDelete(e){return this.httpRequest.request({method:"DELETE",url:"/api/v1/post/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}};var P=class{constructor(e,r=C){var s,o,n,a,i,p,l,A;this.request=new r({BASE:(s=e==null?void 0:e.BASE)!=null?s:"https://api.bundle.social",VERSION:(o=e==null?void 0:e.VERSION)!=null?o:"1.0.0",WITH_CREDENTIALS:(n=e==null?void 0:e.WITH_CREDENTIALS)!=null?n:!1,CREDENTIALS:(a=e==null?void 0:e.CREDENTIALS)!=null?a:"include",TOKEN:e==null?void 0:e.TOKEN,USERNAME:e==null?void 0:e.USERNAME,PASSWORD:e==null?void 0:e.PASSWORD,HEADERS:e==null?void 0:e.HEADERS,ENCODE_PATH:e==null?void 0:e.ENCODE_PATH,interceptors:{request:(p=(i=e==null?void 0:e.interceptors)==null?void 0:i.request)!=null?p:new c,response:(A=(l=e==null?void 0:e.interceptors)==null?void 0:l.response)!=null?A:new c}}),this.app=new O(this.request),this.post=new v(this.request),this.team=new D(this.request),this.upload=new S(this.request)}};var k=X(require("crypto"));var _=class{constructor(){}verifySignature(e,r,s){return k.default.createHmac("sha256",s).update(e).digest("hex")===r}constructEvent(e,r,s){let o=typeof e=="string"?e:JSON.stringify(e);if(!this.verifySignature(o,r,s))throw new Error("Invalid signature");return JSON.parse(o)}},g=class extends P{constructor(r,s){super(b(u({},s),{HEADERS:b(u(u({},q.HEADERS),s==null?void 0:s.HEADERS),{"x-api-key":r})}));this.webhooks=new _}};0&&(module.exports={ApiError,BaseHttpRequest,Bundlesocial,CancelError,CancelablePromise,OpenAPI});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var G=Object.defineProperty,L=Object.defineProperties;var B=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var H=(t,e,r)=>e in t?G(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,u=(t,e)=>{for(var r in e||(e={}))k.call(e,r)&&H(t,r,e[r]);if(_)for(var r of _(e))M.call(e,r)&&H(t,r,e[r]);return t},y=(t,e)=>L(t,B(e));var m=(t,e,r)=>new Promise((o,s)=>{var n=p=>{try{i(r.next(p))}catch(l){s(l)}},a=p=>{try{i(r.throw(p))}catch(l){s(l)}},i=p=>p.done?o(p.value):Promise.resolve(p.value).then(n,a);i((r=r.apply(t,e)).next())});var d=class{constructor(){this._fns=[]}eject(e){let r=this._fns.indexOf(e);r!==-1&&(this._fns=[...this._fns.slice(0,r),...this._fns.slice(r+1)])}use(e){this._fns=[...this._fns,e]}},x={BASE:"https://api.bundle.social",CREDENTIALS:"include",ENCODE_PATH:void 0,HEADERS:void 0,PASSWORD:void 0,TOKEN:void 0,USERNAME:void 0,VERSION:"1.0.0",WITH_CREDENTIALS:!1,interceptors:{request:new d,response:new d}};var R=class{constructor(e){this.config=e}};var c=class extends Error{constructor(r,o,s){super(s);this.name="ApiError",this.url=o.url,this.status=o.status,this.statusText=o.statusText,this.body=o.body,this.request=r}};var f=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},h=class{constructor(e){this._isResolved=!1,this._isRejected=!1,this._isCancelled=!1,this.cancelHandlers=[],this.promise=new Promise((r,o)=>{this._resolve=r,this._reject=o;let s=i=>{this._isResolved||this._isRejected||this._isCancelled||(this._isResolved=!0,this._resolve&&this._resolve(i))},n=i=>{this._isResolved||this._isRejected||this._isCancelled||(this._isRejected=!0,this._reject&&this._reject(i))},a=i=>{this._isResolved||this._isRejected||this._isCancelled||this.cancelHandlers.push(i)};return Object.defineProperty(a,"isResolved",{get:()=>this._isResolved}),Object.defineProperty(a,"isRejected",{get:()=>this._isRejected}),Object.defineProperty(a,"isCancelled",{get:()=>this._isCancelled}),e(s,n,a)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(e,r){return this.promise.then(e,r)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e)}cancel(){if(!(this._isResolved||this._isRejected||this._isCancelled)){if(this._isCancelled=!0,this.cancelHandlers.length)try{for(let e of this.cancelHandlers)e()}catch(e){console.warn("Cancellation threw an error",e);return}this.cancelHandlers.length=0,this._reject&&this._reject(new f("Request aborted"))}}get isCancelled(){return this._isCancelled}};var b=t=>typeof t=="string",v=t=>b(t)&&t!=="",w=t=>t instanceof Blob,N=t=>t instanceof FormData,F=t=>{try{return btoa(t)}catch(e){return Buffer.from(t).toString("base64")}},$=t=>{let e=[],r=(s,n)=>{e.push(`${encodeURIComponent(s)}=${encodeURIComponent(String(n))}`)},o=(s,n)=>{n!=null&&(n instanceof Date?r(s,n.toISOString()):Array.isArray(n)?n.forEach(a=>o(s,a)):typeof n=="object"?Object.entries(n).forEach(([a,i])=>o(`${s}[${a}]`,i)):r(s,n))};return Object.entries(t).forEach(([s,n])=>o(s,n)),e.length?`?${e.join("&")}`:""},W=(t,e)=>{let r=t.ENCODE_PATH||encodeURI,o=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(n,a)=>{var i;return(i=e.path)!=null&&i.hasOwnProperty(a)?r(String(e.path[a])):n}),s=t.BASE+o;return e.query?s+$(e.query):s},V=t=>{if(t.formData){let e=new FormData,r=(o,s)=>{b(s)||w(s)?e.append(o,s):e.append(o,JSON.stringify(s))};return Object.entries(t.formData).filter(([,o])=>o!=null).forEach(([o,s])=>{Array.isArray(s)?s.forEach(n=>r(o,n)):r(o,s)}),e}},A=(t,e)=>m(void 0,null,function*(){return typeof e=="function"?e(t):e}),K=(t,e)=>m(void 0,null,function*(){let[r,o,s,n]=yield Promise.all([A(e,t.TOKEN),A(e,t.USERNAME),A(e,t.PASSWORD),A(e,t.HEADERS)]),a=Object.entries(u(u({Accept:"application/json"},n),e.headers)).filter(([,i])=>i!=null).reduce((i,[p,l])=>y(u({},i),{[p]:String(l)}),{});if(v(r)&&(a.Authorization=`Bearer ${r}`),v(o)&&v(s)){let i=F(`${o}:${s}`);a.Authorization=`Basic ${i}`}return e.body!==void 0&&(e.mediaType?a["Content-Type"]=e.mediaType:w(e.body)?a["Content-Type"]=e.body.type||"application/octet-stream":b(e.body)?a["Content-Type"]="text/plain":N(e.body)||(a["Content-Type"]="application/json")),new Headers(a)}),z=t=>{var e,r;if(t.body!==void 0)return(e=t.mediaType)!=null&&e.includes("application/json")||(r=t.mediaType)!=null&&r.includes("+json")?JSON.stringify(t.body):b(t.body)||w(t.body)||N(t.body)?t.body:JSON.stringify(t.body)},J=(t,e,r,o,s,n,a)=>m(void 0,null,function*(){let i=new AbortController,p={headers:n,body:o!=null?o:s,method:e.method,signal:i.signal};t.WITH_CREDENTIALS&&(p.credentials=t.CREDENTIALS);for(let l of t.interceptors.request._fns)p=yield l(p);return a(()=>i.abort()),yield fetch(r,p)}),Q=(t,e)=>{if(e){let r=t.headers.get(e);if(b(r))return r}},X=t=>m(void 0,null,function*(){if(t.status!==204)try{let e=t.headers.get("Content-Type");if(e){let r=["application/octet-stream","application/pdf","application/zip","audio/","image/","video/"];if(e.includes("application/json")||e.includes("+json"))return yield t.json();if(r.some(o=>e.includes(o)))return yield t.blob();if(e.includes("multipart/form-data"))return yield t.formData();if(e.includes("text/"))return yield t.text()}}catch(e){console.error(e)}}),Y=(t,e)=>{var s,n;let o=u({400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"Im a teapot",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"},t.errors)[e.status];if(o)throw new c(t,e,o);if(!e.ok){let a=(s=e.status)!=null?s:"unknown",i=(n=e.statusText)!=null?n:"unknown",p=(()=>{try{return JSON.stringify(e.body,null,2)}catch(l){return}})();throw new c(t,e,`Generic Error: status: ${a}; status text: ${i}; body: ${p}`)}},U=(t,e)=>new h((r,o,s)=>m(void 0,null,function*(){try{let n=W(t,e),a=V(e),i=z(e),p=yield K(t,e);if(!s.isCancelled){let l=yield J(t,e,n,i,a,p,s);for(let j of t.interceptors.response._fns)l=yield j(l);let P=yield X(l),S=Q(l,e.responseHeader),I={url:n,ok:l.ok,status:l.status,statusText:l.statusText,body:S!=null?S:P};Y(e,I),r(I.body)}}catch(n){o(n)}}));var q=class extends R{constructor(e){super(e)}request(e){return U(this.config,e)}};var C=class{constructor(e){this.httpRequest=e}appGetHealth(){return this.httpRequest.request({method:"GET",url:"/api/v1/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},E=class{constructor(e){this.httpRequest=e}teamGetTeam(){return this.httpRequest.request({method:"GET",url:"/api/v1/team/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},O=class{constructor(e){this.httpRequest=e}uploadCreate(e={}){return this.httpRequest.request({method:"POST",url:"/api/v1/upload/",formData:e.formData,mediaType:"multipart/form-data",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadGetList(){return this.httpRequest.request({method:"GET",url:"/api/v1/upload/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadDeleteMany(e={}){return this.httpRequest.request({method:"DELETE",url:"/api/v1/upload/",body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadGet(e){return this.httpRequest.request({method:"GET",url:"/api/v1/upload/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadDelete(e){return this.httpRequest.request({method:"DELETE",url:"/api/v1/upload/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},D=class{constructor(e){this.httpRequest=e}postCreate(e={}){return this.httpRequest.request({method:"POST",url:"/api/v1/post/",body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postGetList(e={}){return this.httpRequest.request({method:"GET",url:"/api/v1/post/",query:{status:e.status,orderBy:e.orderBy,order:e.order,q:e.q,platforms:e.platforms,offset:e.offset,limit:e.limit},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postGet(e){return this.httpRequest.request({method:"GET",url:"/api/v1/post/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postUpdate(e){return this.httpRequest.request({method:"PUT",url:"/api/v1/post/{id}",path:{id:e.id},body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postDelete(e){return this.httpRequest.request({method:"DELETE",url:"/api/v1/post/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}};var T=class{constructor(e,r=q){var o,s,n,a,i,p,l,P;this.request=new r({BASE:(o=e==null?void 0:e.BASE)!=null?o:"https://api.bundle.social",VERSION:(s=e==null?void 0:e.VERSION)!=null?s:"1.0.0",WITH_CREDENTIALS:(n=e==null?void 0:e.WITH_CREDENTIALS)!=null?n:!1,CREDENTIALS:(a=e==null?void 0:e.CREDENTIALS)!=null?a:"include",TOKEN:e==null?void 0:e.TOKEN,USERNAME:e==null?void 0:e.USERNAME,PASSWORD:e==null?void 0:e.PASSWORD,HEADERS:e==null?void 0:e.HEADERS,ENCODE_PATH:e==null?void 0:e.ENCODE_PATH,interceptors:{request:(p=(i=e==null?void 0:e.interceptors)==null?void 0:i.request)!=null?p:new d,response:(P=(l=e==null?void 0:e.interceptors)==null?void 0:l.response)!=null?P:new d}}),this.app=new C(this.request),this.post=new D(this.request),this.team=new E(this.request),this.upload=new O(this.request)}};var g=class extends T{constructor(e,r){super(y(u({},r),{HEADERS:y(u(u({},x.HEADERS),r==null?void 0:r.HEADERS),{"x-api-key":e})}))}};export{c as ApiError,R as BaseHttpRequest,g as Bundlesocial,f as CancelError,h as CancelablePromise,x as OpenAPI};
|
|
1
|
+
var L=Object.defineProperty,B=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var H=(t,e,r)=>e in t?L(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,u=(t,e)=>{for(var r in e||(e={}))M.call(e,r)&&H(t,r,e[r]);if(g)for(var r of g(e))F.call(e,r)&&H(t,r,e[r]);return t},y=(t,e)=>B(t,k(e));var m=(t,e,r)=>new Promise((s,o)=>{var n=p=>{try{i(r.next(p))}catch(l){o(l)}},a=p=>{try{i(r.throw(p))}catch(l){o(l)}},i=p=>p.done?s(p.value):Promise.resolve(p.value).then(n,a);i((r=r.apply(t,e)).next())});var d=class{constructor(){this._fns=[]}eject(e){let r=this._fns.indexOf(e);r!==-1&&(this._fns=[...this._fns.slice(0,r),...this._fns.slice(r+1)])}use(e){this._fns=[...this._fns,e]}},v={BASE:"https://api.bundle.social",CREDENTIALS:"include",ENCODE_PATH:void 0,HEADERS:void 0,PASSWORD:void 0,TOKEN:void 0,USERNAME:void 0,VERSION:"1.0.0",WITH_CREDENTIALS:!1,interceptors:{request:new d,response:new d}};var R=class{constructor(e){this.config=e}};var c=class extends Error{constructor(r,s,o){super(o);this.name="ApiError",this.url=s.url,this.status=s.status,this.statusText=s.statusText,this.body=s.body,this.request=r}};var f=class extends Error{constructor(e){super(e),this.name="CancelError"}get isCancelled(){return!0}},h=class{constructor(e){this._isResolved=!1,this._isRejected=!1,this._isCancelled=!1,this.cancelHandlers=[],this.promise=new Promise((r,s)=>{this._resolve=r,this._reject=s;let o=i=>{this._isResolved||this._isRejected||this._isCancelled||(this._isResolved=!0,this._resolve&&this._resolve(i))},n=i=>{this._isResolved||this._isRejected||this._isCancelled||(this._isRejected=!0,this._reject&&this._reject(i))},a=i=>{this._isResolved||this._isRejected||this._isCancelled||this.cancelHandlers.push(i)};return Object.defineProperty(a,"isResolved",{get:()=>this._isResolved}),Object.defineProperty(a,"isRejected",{get:()=>this._isRejected}),Object.defineProperty(a,"isCancelled",{get:()=>this._isCancelled}),e(o,n,a)})}get[Symbol.toStringTag](){return"Cancellable Promise"}then(e,r){return this.promise.then(e,r)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e)}cancel(){if(!(this._isResolved||this._isRejected||this._isCancelled)){if(this._isCancelled=!0,this.cancelHandlers.length)try{for(let e of this.cancelHandlers)e()}catch(e){console.warn("Cancellation threw an error",e);return}this.cancelHandlers.length=0,this._reject&&this._reject(new f("Request aborted"))}}get isCancelled(){return this._isCancelled}};var b=t=>typeof t=="string",x=t=>b(t)&&t!=="",w=t=>t instanceof Blob,N=t=>t instanceof FormData,W=t=>{try{return btoa(t)}catch(e){return Buffer.from(t).toString("base64")}},$=t=>{let e=[],r=(o,n)=>{e.push(`${encodeURIComponent(o)}=${encodeURIComponent(String(n))}`)},s=(o,n)=>{n!=null&&(n instanceof Date?r(o,n.toISOString()):Array.isArray(n)?n.forEach(a=>s(o,a)):typeof n=="object"?Object.entries(n).forEach(([a,i])=>s(`${o}[${a}]`,i)):r(o,n))};return Object.entries(t).forEach(([o,n])=>s(o,n)),e.length?`?${e.join("&")}`:""},V=(t,e)=>{let r=t.ENCODE_PATH||encodeURI,s=e.url.replace("{api-version}",t.VERSION).replace(/{(.*?)}/g,(n,a)=>{var i;return(i=e.path)!=null&&i.hasOwnProperty(a)?r(String(e.path[a])):n}),o=t.BASE+s;return e.query?o+$(e.query):o},J=t=>{if(t.formData){let e=new FormData,r=(s,o)=>{b(o)||w(o)?e.append(s,o):e.append(s,JSON.stringify(o))};return Object.entries(t.formData).filter(([,s])=>s!=null).forEach(([s,o])=>{Array.isArray(o)?o.forEach(n=>r(s,n)):r(s,o)}),e}},A=(t,e)=>m(void 0,null,function*(){return typeof e=="function"?e(t):e}),K=(t,e)=>m(void 0,null,function*(){let[r,s,o,n]=yield Promise.all([A(e,t.TOKEN),A(e,t.USERNAME),A(e,t.PASSWORD),A(e,t.HEADERS)]),a=Object.entries(u(u({Accept:"application/json"},n),e.headers)).filter(([,i])=>i!=null).reduce((i,[p,l])=>y(u({},i),{[p]:String(l)}),{});if(x(r)&&(a.Authorization=`Bearer ${r}`),x(s)&&x(o)){let i=W(`${s}:${o}`);a.Authorization=`Basic ${i}`}return e.body!==void 0&&(e.mediaType?a["Content-Type"]=e.mediaType:w(e.body)?a["Content-Type"]=e.body.type||"application/octet-stream":b(e.body)?a["Content-Type"]="text/plain":N(e.body)||(a["Content-Type"]="application/json")),new Headers(a)}),z=t=>{var e,r;if(t.body!==void 0)return(e=t.mediaType)!=null&&e.includes("application/json")||(r=t.mediaType)!=null&&r.includes("+json")?JSON.stringify(t.body):b(t.body)||w(t.body)||N(t.body)?t.body:JSON.stringify(t.body)},Q=(t,e,r,s,o,n,a)=>m(void 0,null,function*(){let i=new AbortController,p={headers:n,body:s!=null?s:o,method:e.method,signal:i.signal};t.WITH_CREDENTIALS&&(p.credentials=t.CREDENTIALS);for(let l of t.interceptors.request._fns)p=yield l(p);return a(()=>i.abort()),yield fetch(r,p)}),X=(t,e)=>{if(e){let r=t.headers.get(e);if(b(r))return r}},Y=t=>m(void 0,null,function*(){if(t.status!==204)try{let e=t.headers.get("Content-Type");if(e){let r=["application/octet-stream","application/pdf","application/zip","audio/","image/","video/"];if(e.includes("application/json")||e.includes("+json"))return yield t.json();if(r.some(s=>e.includes(s)))return yield t.blob();if(e.includes("multipart/form-data"))return yield t.formData();if(e.includes("text/"))return yield t.text()}}catch(e){console.error(e)}}),Z=(t,e)=>{var o,n;let s=u({400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"Im a teapot",421:"Misdirected Request",422:"Unprocessable Content",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"},t.errors)[e.status];if(s)throw new c(t,e,s);if(!e.ok){let a=(o=e.status)!=null?o:"unknown",i=(n=e.statusText)!=null?n:"unknown",p=(()=>{try{return JSON.stringify(e.body,null,2)}catch(l){return}})();throw new c(t,e,`Generic Error: status: ${a}; status text: ${i}; body: ${p}`)}},U=(t,e)=>new h((r,s,o)=>m(void 0,null,function*(){try{let n=V(t,e),a=J(e),i=z(e),p=yield K(t,e);if(!o.isCancelled){let l=yield Q(t,e,n,i,a,p,o);for(let G of t.interceptors.response._fns)l=yield G(l);let P=yield Y(l),S=X(l,e.responseHeader),_={url:n,ok:l.ok,status:l.status,statusText:l.statusText,body:S!=null?S:P};Z(e,_),r(_.body)}}catch(n){s(n)}}));var q=class extends R{constructor(e){super(e)}request(e){return U(this.config,e)}};var E=class{constructor(e){this.httpRequest=e}appGetHealth(){return this.httpRequest.request({method:"GET",url:"/api/v1/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},C=class{constructor(e){this.httpRequest=e}teamGetTeam(){return this.httpRequest.request({method:"GET",url:"/api/v1/team/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},O=class{constructor(e){this.httpRequest=e}uploadCreate(e={}){return this.httpRequest.request({method:"POST",url:"/api/v1/upload/",formData:e.formData,mediaType:"multipart/form-data",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadGetList(){return this.httpRequest.request({method:"GET",url:"/api/v1/upload/",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadDeleteMany(e={}){return this.httpRequest.request({method:"DELETE",url:"/api/v1/upload/",body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadGet(e){return this.httpRequest.request({method:"GET",url:"/api/v1/upload/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}uploadDelete(e){return this.httpRequest.request({method:"DELETE",url:"/api/v1/upload/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}},D=class{constructor(e){this.httpRequest=e}postCreate(e={}){return this.httpRequest.request({method:"POST",url:"/api/v1/post/",body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postGetList(e={}){return this.httpRequest.request({method:"GET",url:"/api/v1/post/",query:{status:e.status,orderBy:e.orderBy,order:e.order,q:e.q,platforms:e.platforms,offset:e.offset,limit:e.limit},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postGet(e){return this.httpRequest.request({method:"GET",url:"/api/v1/post/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postUpdate(e){return this.httpRequest.request({method:"PUT",url:"/api/v1/post/{id}",path:{id:e.id},body:e.requestBody,mediaType:"application/json",errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}postDelete(e){return this.httpRequest.request({method:"DELETE",url:"/api/v1/post/{id}",path:{id:e.id},errors:{400:"400",401:"401",403:"403",404:"404",500:"500"}})}};var T=class{constructor(e,r=q){var s,o,n,a,i,p,l,P;this.request=new r({BASE:(s=e==null?void 0:e.BASE)!=null?s:"https://api.bundle.social",VERSION:(o=e==null?void 0:e.VERSION)!=null?o:"1.0.0",WITH_CREDENTIALS:(n=e==null?void 0:e.WITH_CREDENTIALS)!=null?n:!1,CREDENTIALS:(a=e==null?void 0:e.CREDENTIALS)!=null?a:"include",TOKEN:e==null?void 0:e.TOKEN,USERNAME:e==null?void 0:e.USERNAME,PASSWORD:e==null?void 0:e.PASSWORD,HEADERS:e==null?void 0:e.HEADERS,ENCODE_PATH:e==null?void 0:e.ENCODE_PATH,interceptors:{request:(p=(i=e==null?void 0:e.interceptors)==null?void 0:i.request)!=null?p:new d,response:(P=(l=e==null?void 0:e.interceptors)==null?void 0:l.response)!=null?P:new d}}),this.app=new E(this.request),this.post=new D(this.request),this.team=new C(this.request),this.upload=new O(this.request)}};import ee from"crypto";var I=class{constructor(){}verifySignature(e,r,s){return ee.createHmac("sha256",s).update(e).digest("hex")===r}constructEvent(e,r,s){let o=typeof e=="string"?e:JSON.stringify(e);if(!this.verifySignature(o,r,s))throw new Error("Invalid signature");return JSON.parse(o)}},j=class extends T{constructor(r,s){super(y(u({},s),{HEADERS:y(u(u({},v.HEADERS),s==null?void 0:s.HEADERS),{"x-api-key":r})}));this.webhooks=new I}};export{c as ApiError,R as BaseHttpRequest,j as Bundlesocial,f as CancelError,h as CancelablePromise,v as OpenAPI};
|