@droz-js/sdk
Advanced tools
Comparing version 0.3.12 to 0.3.13
{ | ||
"name": "@droz-js/sdk", | ||
"description": "Droz SDK", | ||
"version": "0.3.12", | ||
"version": "0.3.13", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "exports": { |
@@ -10,2 +10,3 @@ import type { ExecutionResult, GraphQLError } from 'graphql'; | ||
errors?: ReadonlyArray<Partial<GraphQLError>>; | ||
constructor(code: string, text: string); | ||
constructor(errors: ReadonlyArray<Partial<GraphQLError>>); | ||
@@ -12,0 +13,0 @@ } |
@@ -10,3 +10,9 @@ "use strict"; | ||
errors; | ||
constructor(errors) { | ||
constructor(errors, text) { | ||
if (typeof errors === 'string') { | ||
super(text); | ||
this.statusCode = 500; | ||
this.errorCode = errors; | ||
return; | ||
} | ||
const { message, extensions, originalError } = errors?.[0] ?? {}; | ||
@@ -13,0 +19,0 @@ super(message ?? 'Unknown Error', { |
@@ -9,3 +9,3 @@ export * from './sdks/drozcommons'; | ||
getAmplifyConfig(variables?: import("./sdks/drozcommons").Exact<{ | ||
[key: string]: never; | ||
forDev?: boolean; | ||
}>, options?: unknown): Promise<import("./sdks/drozcommons").GetAmplifyConfigQuery>; | ||
@@ -12,0 +12,0 @@ getAuthInfo(variables?: import("./sdks/drozcommons").Exact<{ |
@@ -0,3 +1,4 @@ | ||
import { CreatePresignedUploadUrlInput } from './sdks/nucleus'; | ||
export * from './sdks/nucleus'; | ||
export declare const Nucleus: new (options?: import("./client/http").HttpClientOptions) => { | ||
declare const Nucleus_base: new (options?: import("./client/http").HttpClientOptions) => { | ||
readonly http: any; | ||
@@ -187,2 +188,10 @@ forTenant(tenant: string): any; | ||
}>, options?: unknown): Promise<import("./sdks/nucleus").RemoveStateMachineConfigStateMutation>; | ||
createPresignedUploadUrl(variables: import("./sdks/nucleus").Exact<{ | ||
input: CreatePresignedUploadUrlInput; | ||
}>, options?: unknown): Promise<import("./sdks/nucleus").CreatePresignedUploadUrlMutation>; | ||
}; | ||
export declare class Nucleus extends Nucleus_base { | ||
uploadBlob(fileName: string, blob: Blob): Promise<string>; | ||
uploadFile(blob: File): Promise<string>; | ||
private upload; | ||
} |
@@ -18,5 +18,43 @@ "use strict"; | ||
exports.Nucleus = void 0; | ||
const helpers_1 = require("./client/helpers"); | ||
const http_1 = require("./client/http"); | ||
const nucleus_1 = require("./sdks/nucleus"); | ||
__exportStar(require("./sdks/nucleus"), exports); | ||
exports.Nucleus = (0, http_1.HttpClientBuilder)(nucleus_1.serviceName, nucleus_1.getSdk); | ||
class Nucleus extends (0, http_1.HttpClientBuilder)(nucleus_1.serviceName, nucleus_1.getSdk) { | ||
async uploadBlob(fileName, blob) { | ||
return await this.upload({ | ||
fileName, | ||
blob, | ||
contentType: blob.type, | ||
contentLength: blob.size | ||
}); | ||
} | ||
async uploadFile(blob) { | ||
return await this.upload({ | ||
blob, | ||
fileName: blob.name, | ||
contentType: blob.type, | ||
contentLength: blob.size | ||
}); | ||
} | ||
async upload(upload) { | ||
const { blob, ...input } = upload; | ||
const { createPresignedUploadUrl } = await this.createPresignedUploadUrl({ input }); | ||
if (createPresignedUploadUrl) { | ||
const { method, url, fields, cdnUrl } = createPresignedUploadUrl; | ||
const body = new FormData(); | ||
Object.entries(fields).forEach(([key, value]) => { | ||
body.append(key, value); | ||
}); | ||
body.append('file', blob); | ||
const response = await fetch(url, { method, body }); | ||
if (response.ok) { | ||
return cdnUrl; | ||
} | ||
const text = await response.text(); | ||
throw new helpers_1.SdkError('500-upload-failed', text); | ||
} | ||
throw new helpers_1.SdkError('500-upload-failed', 'No response from server'); | ||
} | ||
} | ||
exports.Nucleus = Nucleus; |
@@ -208,2 +208,5 @@ export type Maybe<T> = T; | ||
}; | ||
export type QueryAmplifyConfigArgs = { | ||
forDev?: InputMaybe<Scalars['Boolean']['input']>; | ||
}; | ||
export type QueryDeploymentLogsArgs = { | ||
@@ -258,3 +261,3 @@ deploymentId?: InputMaybe<Scalars['ID']['input']>; | ||
export type GetAmplifyConfigQueryVariables = Exact<{ | ||
[key: string]: never; | ||
forDev?: InputMaybe<Scalars['Boolean']['input']>; | ||
}>; | ||
@@ -363,3 +366,3 @@ export type GetAmplifyConfigQuery = Pick<Query, 'amplifyConfig'>; | ||
export declare const TenantFragmentDoc = "\n fragment tenant on Tenant {\n accountId\n tenantId\n name\n deployedVersions\n createdAt\n updatedAt\n}\n "; | ||
export declare const GetAmplifyConfigDocument = "\n query getAmplifyConfig {\n amplifyConfig\n}\n "; | ||
export declare const GetAmplifyConfigDocument = "\n query getAmplifyConfig($forDev: Boolean) {\n amplifyConfig(forDev: $forDev)\n}\n "; | ||
export declare const GetAuthInfoDocument = "\n query getAuthInfo {\n authInfo {\n authenticationEndpoint\n jwtIssuer\n loginUrl\n logoutUrl\n cognitoConfig {\n region\n userPoolId\n userPoolWebClientId\n }\n }\n}\n "; | ||
@@ -366,0 +369,0 @@ export declare const ListAccountsDocument = "\n query listAccounts {\n listAccounts {\n ...awsAccount\n }\n}\n \n fragment awsAccount on AwsAccount {\n id\n name\n tenantsCount\n}\n "; |
@@ -81,4 +81,4 @@ "use strict"; | ||
exports.GetAmplifyConfigDocument = ` | ||
query getAmplifyConfig { | ||
amplifyConfig | ||
query getAmplifyConfig($forDev: Boolean) { | ||
amplifyConfig(forDev: $forDev) | ||
} | ||
@@ -85,0 +85,0 @@ `; |
@@ -5,3 +5,3 @@ "use strict"; | ||
exports.GetCustomerDocument = exports.RemoveCredentialsDocument = exports.UpdateCredentialsDocument = exports.CreateCredentialsDocument = exports.CountCredentialsDocument = exports.ListCredentialsDocument = exports.GetCredentialsSecretDocument = exports.GetCredentialsDocument = exports.GetAuthInfoDocument = exports.GetAmplifyConfigDocument = exports.UnregisterAppInstanceDocument = exports.RegisterAppInstanceDocument = exports.CountAppInstancesDocument = exports.ListAppInstancesDocument = exports.GetAppInstanceDocument = exports.ListAppsDocument = exports.GetAppDocument = exports.RemoveRoleFromAgentDocument = exports.AddRoleToAgentDocument = exports.RemoveAgentDocument = exports.UpdateAgentDocument = exports.CreateApiKeyAgentDocument = exports.CreateAgentDocument = exports.UpdateMyProfileDocument = exports.ListApiKeyAgentsDocument = exports.ListAgentsDocument = exports.GetAgentDocument = exports.GetMeDocument = exports.StateMachineConfigConnectionFragmentDoc = exports.StateMachineConfigFragmentDoc = exports.StateMachineConfigStateFragmentDoc = exports.StateMachineConfigStateOnFragmentDoc = exports.SessionFragmentDoc = exports.RoleFragmentDoc = exports.PolicyFragmentDoc = exports.CronJobFragmentDoc = exports.CustomerFragmentDoc = exports.SafeCredentialsFragmentDoc = exports.AppWithInstancesFragmentDoc = exports.AppInstanceFragmentDoc = exports.AppFragmentDoc = exports.ApiKeyFragmentDoc = exports.AgentFragmentDoc = exports.Typenames = exports.StateMachineConfigStatus = exports.PatchOperation = exports.CustomerIndex = exports.CredentialsType = exports.AppType = exports.AppInstanceStatus = void 0; | ||
exports.serviceName = exports.getSdk = exports.RemoveStateMachineConfigStateDocument = exports.UpdateStateMachineConfigStateDocument = exports.CreateStateMachineConfigStateDocument = exports.PublishStateMachineConfigDocument = exports.EditStateMachineConfigDocument = exports.RemoveStateMachineConfigDocument = exports.UpdateStateMachineConfigDocument = exports.CreateStateMachineConfigDocument = exports.IsAppInstanceInUseDocument = exports.GetXStateMachineConfigDocument = exports.ListStateMachineConfigVersionsDocument = exports.ListDraftStateMachineConfigsDocument = exports.ListLiveStateMachineConfigsDocument = exports.CountLiveStateMachineConfigsDocument = exports.GetStateMachineDocument = exports.PatchSessionAttributesDocument = exports.SetSessionAttributeDocument = exports.GetSessionDocument = exports.StartSessionDocument = exports.GetSystemRoleDocument = exports.ListSystemRolesDocument = exports.RemoveCronJobDocument = exports.UpdateCronJobDocument = exports.CreateCronJobDocument = exports.ListCronJobsDocument = exports.GetCronJobDocument = exports.GetOrCreateCustomerDocument = exports.ListCustomersDocument = void 0; | ||
exports.serviceName = exports.getSdk = exports.CreatePresignedUploadUrlDocument = exports.RemoveStateMachineConfigStateDocument = exports.UpdateStateMachineConfigStateDocument = exports.CreateStateMachineConfigStateDocument = exports.PublishStateMachineConfigDocument = exports.EditStateMachineConfigDocument = exports.RemoveStateMachineConfigDocument = exports.UpdateStateMachineConfigDocument = exports.CreateStateMachineConfigDocument = exports.IsAppInstanceInUseDocument = exports.GetXStateMachineConfigDocument = exports.ListStateMachineConfigVersionsDocument = exports.ListDraftStateMachineConfigsDocument = exports.ListLiveStateMachineConfigsDocument = exports.CountLiveStateMachineConfigsDocument = exports.GetStateMachineDocument = exports.PatchSessionAttributesDocument = exports.SetSessionAttributeDocument = exports.GetSessionDocument = exports.StartSessionDocument = exports.GetSystemRoleDocument = exports.ListSystemRolesDocument = exports.RemoveCronJobDocument = exports.UpdateCronJobDocument = exports.CreateCronJobDocument = exports.ListCronJobsDocument = exports.GetCronJobDocument = exports.GetOrCreateCustomerDocument = exports.ListCustomersDocument = void 0; | ||
var AppInstanceStatus; | ||
@@ -63,2 +63,3 @@ (function (AppInstanceStatus) { | ||
Typenames["Sessions"] = "Sessions"; | ||
Typenames["Storage"] = "Storage"; | ||
})(Typenames || (exports.Typenames = Typenames = {})); | ||
@@ -670,2 +671,12 @@ exports.AgentFragmentDoc = ` | ||
${exports.StateMachineConfigFragmentDoc}`; | ||
exports.CreatePresignedUploadUrlDocument = ` | ||
mutation createPresignedUploadUrl($input: CreatePresignedUploadUrlInput!) { | ||
createPresignedUploadUrl(input: $input) { | ||
method | ||
url | ||
fields | ||
cdnUrl | ||
} | ||
} | ||
`; | ||
function getSdk(requester) { | ||
@@ -840,2 +851,5 @@ return { | ||
return requester(exports.RemoveStateMachineConfigStateDocument, variables, options); | ||
}, | ||
createPresignedUploadUrl(variables, options) { | ||
return requester(exports.CreatePresignedUploadUrlDocument, variables, options); | ||
} | ||
@@ -842,0 +856,0 @@ }; |
Sorry, the diff of this file is too big to display
323662
7239
3