Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: regenerate sdk #38

Merged
merged 3 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite Console SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.6.2-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
Expand Down
14 changes: 14 additions & 0 deletions docs/examples/organizations/validate-invoice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Client, Organizations } from "@appwrite.io/console";

const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const organizations = new Organizations(client);

const result = await organizations.validateInvoice(
'<ORGANIZATION_ID>', // organizationId
'<INVOICE_ID>' // invoiceId
);

console.log(result);
23 changes: 20 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ class Client {
* @returns {this}
*/
setEndpoint(endpoint: string): this {
if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
throw new AppwriteException('Invalid endpoint URL: ' + endpoint);
}

this.config.endpoint = endpoint;
this.config.endpointRealtime = this.config.endpointRealtime || this.config.endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
this.config.endpointRealtime = endpoint.replace('https://', 'wss://').replace('http://', 'ws://');

return this;
}
Expand All @@ -344,8 +348,11 @@ class Client {
* @returns {this}
*/
setEndpointRealtime(endpointRealtime: string): this {
this.config.endpointRealtime = endpointRealtime;
if (!endpointRealtime.startsWith('ws://') && !endpointRealtime.startsWith('wss://')) {
throw new AppwriteException('Invalid realtime endpoint URL: ' + endpointRealtime);
}

this.config.endpointRealtime = endpointRealtime;
return this;
}

Expand Down Expand Up @@ -669,6 +676,10 @@ class Client {
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
const file = Object.values(originalPayload).find((value) => value instanceof File);

if (!file) {
throw new Error('File not found in payload');
}

if (file.size <= Client.CHUNK_SIZE) {
return await this.call(method, url, headers, originalPayload);
}
Expand Down Expand Up @@ -736,7 +747,13 @@ class Client {
}

if (400 <= response.status) {
throw new AppwriteException(data?.message, response.status, data?.type, data);
let responseText = '';
if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {
responseText = JSON.stringify(data);
} else {
responseText = data?.message;
}
throw new AppwriteException(data?.message, response.status, data?.type, responseText);
}

const cookieFallback = response.headers.get('X-Fallback-Cookies');
Expand Down
1 change: 1 addition & 0 deletions src/enums/o-auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum OAuthProvider {
Dropbox = 'dropbox',
Etsy = 'etsy',
Facebook = 'facebook',
Figma = 'figma',
Github = 'github',
Gitlab = 'gitlab',
Google = 'google',
Expand Down
124 changes: 118 additions & 6 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ export namespace Models {
/**
* Collection attributes.
*/
attributes: string[];
attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[];
/**
* Collection indexes.
*/
Expand All @@ -611,7 +611,7 @@ export namespace Models {
/**
* List of attributes.
*/
attributes: string[];
attributes: (Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString)[];
}
/**
* AttributeString
Expand Down Expand Up @@ -4340,6 +4340,10 @@ export namespace Models {
* Region ID
*/
$id: string;
/**
* User ID
*/
userId: string;
/**
* Street address
*/
Expand Down Expand Up @@ -4456,11 +4460,11 @@ export namespace Models {
/**
* Additional resources
*/
usage: AdditionalResource[];
usage: UsageBillingPlan;
/**
* Addons
*/
addons: BillingPlanAddon[];
addons: BillingPlanAddon;
/**
* Custom SMTP
*/
Expand Down Expand Up @@ -4514,6 +4518,15 @@ export namespace Models {
* BillingPlanAddon
*/
export type BillingPlanAddon = {
/**
* Addon seats
*/
seats: BillingPlanAddonDetails;
}
/**
* BillingPlanAddonDetails
*/
export type BillingPlanAddonDetails = {
/**
* Is the addon supported in the plan?
*/
Expand All @@ -4539,6 +4552,39 @@ export namespace Models {
*/
value: number;
}
/**
* BillingLimits
*/
export type BillingLimits = {
/**
* Bandwidth limit
*/
bandwidth: number;
/**
* Storage limit
*/
storage: number;
/**
* Users limit
*/
users: number;
/**
* Executions limit
*/
executions: number;
/**
* GBHours limit
*/
GBHours: number;
/**
* Image transformations limit
*/
imageTransformations: number;
/**
* Auth phone limit
*/
authPhone: number;
}
/**
* Campaign
*/
Expand Down Expand Up @@ -4624,6 +4670,10 @@ export namespace Models {
* Status of the coupon. Can be one of `disabled`, `active` or `expired`.
*/
status: string;
/**
* If the coupon is only valid for new organizations or not.
*/
onlyNewOrgs: boolean;
}
/**
* Credit
Expand Down Expand Up @@ -4726,7 +4776,7 @@ export namespace Models {
/**
* Usage breakdown per resource
*/
usage: object;
usage: UsageInvoice[];
/**
* Invoice Amount
*/
Expand Down Expand Up @@ -4899,7 +4949,7 @@ export namespace Models {
/**
* Billing limits reached
*/
billingLimits: object;
billingLimits: BillingLimits;
/**
* Billing plan downgrade
*/
Expand Down Expand Up @@ -5285,6 +5335,68 @@ export namespace Models {
*/
authPhoneEstimate: number;
}
/**
* UsageInvoice
*/
export type UsageInvoice = {
/**
* Invoice name
*/
name: string;
/**
* Invoice value
*/
value: number;
/**
* Invoice amount
*/
amount: number;
/**
* Invoice rate
*/
rate: number;
/**
* Invoice description
*/
desc: string;
}
/**
* usageBillingPlan
*/
export type UsageBillingPlan = {
/**
* Bandwidth additional resources
*/
bandwidth: AdditionalResource;
/**
* Executions additional resources
*/
executions: AdditionalResource;
/**
* Member additional resources
*/
member: AdditionalResource;
/**
* Realtime additional resources
*/
realtime: AdditionalResource;
/**
* Storage additional resources
*/
storage: AdditionalResource;
/**
* User additional resources
*/
users: AdditionalResource;
/**
* GBHour additional resources
*/
GBHours: AdditionalResource;
/**
* Image transformation additional resources
*/
imageTransformations: AdditionalResource;
}
/**
* Aggregation team list
*/
Expand Down
Loading