@droz-js/sdk
Advanced tools
Comparing version 0.5.13 to 0.5.14
{ | ||
"name": "@droz-js/sdk", | ||
"description": "Droz SDK", | ||
"version": "0.5.13", | ||
"version": "0.5.14", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "exports": { |
@@ -108,2 +108,5 @@ "use strict"; | ||
body | ||
}).catch(error => { | ||
console.error('[Droz SDK]:error', error); | ||
throw error; | ||
}); | ||
@@ -110,0 +113,0 @@ if (response.status === 200) { |
@@ -23,2 +23,37 @@ "use strict"; | ||
__exportStar(require("./sdks/nucleus"), exports); | ||
function browserUpload(method, url, body, onProgress) { | ||
return new Promise((resolve, reject) => { | ||
const xhr = new XMLHttpRequest(); | ||
if (onProgress) { | ||
xhr.upload.addEventListener('progress', evt => { | ||
onProgress(evt.loaded / evt.total); | ||
}); | ||
} | ||
xhr.addEventListener('load', () => { | ||
const ok = xhr.status >= 200 && xhr.status < 300; | ||
const text = xhr.responseText; | ||
if (onProgress) | ||
onProgress(1); // Ensure progress is 100% after load | ||
resolve({ ok, text }); | ||
}); | ||
xhr.addEventListener('error', () => { | ||
reject(new helpers_1.SdkError('500-upload-failed', 'Upload failed')); | ||
}); | ||
xhr.addEventListener('abort', () => { | ||
reject(new helpers_1.SdkError('400-upload-aborted', 'Upload aborted by user')); | ||
}); | ||
xhr.open(method, url, true); | ||
xhr.send(body); | ||
}); | ||
} | ||
async function nodejsUpload(method, url, body) { | ||
return await fetch(url, { method, body }) | ||
.catch(error => { | ||
throw new helpers_1.SdkError('500-upload-failed', error.message); | ||
}) | ||
.then(async (response) => { | ||
const text = await response.text(); | ||
return { ok: response.ok, text }; | ||
}); | ||
} | ||
class Nucleus extends (0, http_1.HttpClientBuilder)(nucleus_1.serviceName, nucleus_1.getSdk) { | ||
@@ -68,27 +103,8 @@ async uploadBlob(fileName, blob, onProgress) { | ||
async post(method, url, body, onProgress) { | ||
return new Promise((resolve, reject) => { | ||
const xhr = new XMLHttpRequest(); | ||
if (onProgress) { | ||
xhr.upload.addEventListener('progress', evt => { | ||
onProgress(evt.loaded / evt.total); | ||
}); | ||
} | ||
xhr.addEventListener('load', () => { | ||
const ok = xhr.status >= 200 && xhr.status < 300; | ||
const text = xhr.responseText; | ||
if (onProgress) | ||
onProgress(1); // Ensure progress is 100% after load | ||
resolve({ ok, text }); | ||
}); | ||
xhr.addEventListener('error', () => { | ||
reject(new helpers_1.SdkError('500-upload-failed', 'Upload failed')); | ||
}); | ||
xhr.addEventListener('abort', () => { | ||
reject(new helpers_1.SdkError('400-upload-aborted', 'Upload aborted by user')); | ||
}); | ||
xhr.open(method, url, true); | ||
xhr.send(body); | ||
}); | ||
if (typeof XMLHttpRequest === 'undefined') { | ||
return nodejsUpload(method, url, body); | ||
} | ||
return browserUpload(method, url, body, onProgress); | ||
} | ||
} | ||
exports.Nucleus = Nucleus; |
@@ -138,2 +138,3 @@ "use strict"; | ||
name | ||
alternateName | ||
@@ -140,0 +141,0 @@ phone |
@@ -203,2 +203,3 @@ export type Maybe<T> = T; | ||
export type ZendeskCustomer = { | ||
alternateName?: Maybe<Scalars['String']['output']>; | ||
createdAt: Scalars['DateTime']['output']; | ||
@@ -252,3 +253,3 @@ document?: Maybe<Scalars['String']['output']>; | ||
}); | ||
export type ZendeskCustomerFragment = Pick<ZendeskCustomer, 'id' | 'name' | 'email' | 'phone' | 'externalId' | 'document' | 'createdAt' | 'updatedAt'>; | ||
export type ZendeskCustomerFragment = Pick<ZendeskCustomer, 'id' | 'name' | 'alternateName' | 'email' | 'phone' | 'externalId' | 'document' | 'createdAt' | 'updatedAt'>; | ||
export type GetZendeskInstanceQueryVariables = Exact<{ | ||
@@ -313,3 +314,3 @@ id: Scalars['ID']['input']; | ||
export declare const ZendeskInstanceFragmentDoc = "\n fragment zendeskInstance on ZendeskInstance {\n id\n name\n domain\n credentialId\n closedStatuses\n appChannelRoleMappings {\n appId\n channelId\n zendeskRoleId\n }\n sessionFieldMappings {\n expression\n customFieldId\n }\n createdAt\n updatedAt\n}\n "; | ||
export declare const ZendeskCustomerFragmentDoc = "\n fragment zendeskCustomer on ZendeskCustomer {\n id\n name\n email\n phone\n externalId\n document\n createdAt\n updatedAt\n}\n "; | ||
export declare const ZendeskCustomerFragmentDoc = "\n fragment zendeskCustomer on ZendeskCustomer {\n id\n name\n alternateName\n email\n phone\n externalId\n document\n createdAt\n updatedAt\n}\n "; | ||
export declare const GetZendeskInstanceDocument = "\n query getZendeskInstance($id: ID!) {\n getZendeskInstance(id: $id) {\n ...zendeskInstance\n }\n}\n \n fragment zendeskInstance on ZendeskInstance {\n id\n name\n domain\n credentialId\n closedStatuses\n appChannelRoleMappings {\n appId\n channelId\n zendeskRoleId\n }\n sessionFieldMappings {\n expression\n customFieldId\n }\n createdAt\n updatedAt\n}\n "; | ||
@@ -320,3 +321,3 @@ export declare const ListZendeskInstancesDocument = "\n query listZendeskInstances {\n listZendeskInstances {\n ...zendeskInstance\n }\n}\n \n fragment zendeskInstance on ZendeskInstance {\n id\n name\n domain\n credentialId\n closedStatuses\n appChannelRoleMappings {\n appId\n channelId\n zendeskRoleId\n }\n sessionFieldMappings {\n expression\n customFieldId\n }\n createdAt\n updatedAt\n}\n "; | ||
export declare const AssertCanUserInteractDocument = "\n query assertCanUserInteract($ticketId: ID!, $userId: Float!) {\n assertCanUserInteract(ticketId: $ticketId, userId: $userId)\n}\n "; | ||
export declare const GetTicketSessionAttributesDocument = "\n query getTicketSessionAttributes($ticketId: ID!) {\n getTicketSessionAttributes(ticketId: $ticketId) {\n sessionId\n instanceId\n organization\n customer {\n ...zendeskCustomer\n }\n source\n order\n products\n triggerApp {\n id\n name\n description\n }\n }\n}\n \n fragment zendeskCustomer on ZendeskCustomer {\n id\n name\n email\n phone\n externalId\n document\n createdAt\n updatedAt\n}\n "; | ||
export declare const GetTicketSessionAttributesDocument = "\n query getTicketSessionAttributes($ticketId: ID!) {\n getTicketSessionAttributes(ticketId: $ticketId) {\n sessionId\n instanceId\n organization\n customer {\n ...zendeskCustomer\n }\n source\n order\n products\n triggerApp {\n id\n name\n description\n }\n }\n}\n \n fragment zendeskCustomer on ZendeskCustomer {\n id\n name\n alternateName\n email\n phone\n externalId\n document\n createdAt\n updatedAt\n}\n "; | ||
export declare const CreateZendeskInstanceDocument = "\n mutation createZendeskInstance($input: CreateZendeskInstanceInput!) {\n createZendeskInstance(input: $input) {\n ...zendeskInstance\n }\n}\n \n fragment zendeskInstance on ZendeskInstance {\n id\n name\n domain\n credentialId\n closedStatuses\n appChannelRoleMappings {\n appId\n channelId\n zendeskRoleId\n }\n sessionFieldMappings {\n expression\n customFieldId\n }\n createdAt\n updatedAt\n}\n "; | ||
@@ -323,0 +324,0 @@ export declare const UpdateZendeskInstanceDocument = "\n mutation updateZendeskInstance($input: UpdateZendeskInstanceInput!) {\n updateZendeskInstance(input: $input) {\n ...zendeskInstance\n }\n}\n \n fragment zendeskInstance on ZendeskInstance {\n id\n name\n domain\n credentialId\n closedStatuses\n appChannelRoleMappings {\n appId\n channelId\n zendeskRoleId\n }\n sessionFieldMappings {\n expression\n customFieldId\n }\n createdAt\n updatedAt\n}\n "; |
@@ -43,2 +43,3 @@ "use strict"; | ||
name | ||
alternateName | ||
@@ -45,0 +46,0 @@ phone |
Sorry, the diff of this file is too big to display
382975
8304
2