Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 3.1.0

* Add support for `createPurchase` method in `Domains` service
* Fix very large double values (for example 1.7976931348623157e+308) from being expanded into giant integer literals

## 3.0.0

* Breaking: EmailTemplateType enum values renamed and updated (Magicsession -> MagicSession, Mfachallenge -> MfaChallenge, Sessionalert -> SessionAlert, Otpsession -> OtpSession) and their underlying string values changed accordingly, which may affect existing integrations.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console";
To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:

```html
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@3.0.0"></script>
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@3.1.0"></script>
```


Expand Down
25 changes: 25 additions & 0 deletions docs/examples/domains/create-purchase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
```javascript
import { Client, Domains } from "@appwrite.io/console";

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

const domains = new Domains(client);

const result = await domains.createPurchase({
domain: '',
teamId: '<TEAM_ID>',
Comment on lines +10 to +12
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use a placeholder domain instead of an empty string.

Line 11 currently uses domain: '', which can be misleading in copy/paste usage. Consider a placeholder like <DOMAIN> or a sample such as example.com.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/examples/domains/create-purchase.md` around lines 10 - 12, The example
uses an empty string for the domain which is misleading; update the
domains.createPurchase call to use a clear placeholder or sample value (e.g.,
"<DOMAIN>" or "example.com") instead of '', changing the domain field in the
createPurchase example to the chosen placeholder so copy/paste users see a valid
value for the domain parameter in the domains.createPurchase invocation.

firstName: '<FIRST_NAME>',
lastName: '<LAST_NAME>',
email: 'email@example.com',
phone: '+12065550100',
billingAddressId: '<BILLING_ADDRESS_ID>',
paymentMethodId: '<PAYMENT_METHOD_ID>',
addressLine3: '<ADDRESS_LINE3>', // optional
companyName: '<COMPANY_NAME>', // optional
periodYears: 1 // optional
});

console.log(result);
```
3 changes: 2 additions & 1 deletion docs/examples/organizations/get-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const client = new Client()
const organizations = new Organizations(client);

const result = await organizations.getScopes({
organizationId: '<ORGANIZATION_ID>'
organizationId: '<ORGANIZATION_ID>',
projectId: '<PROJECT_ID>' // optional
});

console.log(result);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@appwrite.io/console",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
"version": "3.0.0",
"version": "3.1.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
9 changes: 7 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true });

const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
const MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
const MAX_INT64 = BigInt('9223372036854775807');
const MIN_INT64 = BigInt('-9223372036854775808');

function isBigNumber(value: any): boolean {
return value !== null
Expand All @@ -25,7 +27,10 @@ function reviver(_key: string, value: any): any {
if (bi >= MIN_SAFE && bi <= MAX_SAFE) {
return Number(str);
}
return bi;
if (bi >= MIN_INT64 && bi <= MAX_INT64) {
return bi;
}
return value.toNumber();
}
return value.toNumber();
}
Expand Down Expand Up @@ -395,7 +400,7 @@ class Client {
'x-sdk-name': 'Console',
'x-sdk-platform': 'console',
'x-sdk-language': 'web',
'x-sdk-version': '3.0.0',
'x-sdk-version': '3.1.0',
'X-Appwrite-Response-Format': '1.8.0',
};

Expand Down
6 changes: 5 additions & 1 deletion src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8567,6 +8567,10 @@ export namespace Models {
* Domain registrar (e.g. "appwrite" or "third_party").
*/
registrar: string;
/**
* Payment status for domain purchase.
*/
paymentStatus: string;
/**
* Nameservers setting. "Appwrite" or empty string.
*/
Expand All @@ -8584,7 +8588,7 @@ export namespace Models {
*/
autoRenewal: boolean;
/**
* Renewal price (in USD).
* Renewal price (in cents).
*/
renewalPrice: number;
/**
Expand Down
26 changes: 26 additions & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,40 @@ export class Query {

/**
* Filter resources where attribute contains the specified value.
* For string attributes, checks if the string contains the substring.
*
* Note: For array attributes, use {@link containsAny} or {@link containsAll} instead.
* @param {string} attribute
* @param {string | string[]} value
* @returns {string}
*/
static contains = (attribute: string, value: string | any[]): string =>
new Query("contains", attribute, value).toString();

/**
* Filter resources where attribute contains ANY of the specified values.
* For array and relationship attributes, matches documents where the attribute
* contains at least one of the given values.
*
* @param {string} attribute
* @param {any[]} value
* @returns {string}
*/
static containsAny = (attribute: string, value: any[]): string =>
new Query("containsAny", attribute, value).toString();

/**
* Filter resources where attribute contains ALL of the specified values.
* For array and relationship attributes, matches documents where the attribute
* contains every one of the given values.
*
* @param {string} attribute
* @param {any[]} value
* @returns {string}
*/
static containsAll = (attribute: string, value: any[]): string =>
new Query("containsAll", attribute, value).toString();

/**
* Filter resources where attribute does not contain the specified value.
*
Expand Down
147 changes: 147 additions & 0 deletions src/services/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,153 @@ export class Domains {
);
}

/**
* Create a domain purchase with registrant information.
*
* @param {string} params.domain - Fully qualified domain name to purchase (for example, example.com).
* @param {string} params.teamId - Team ID that will own the domain.
* @param {string} params.firstName - Registrant first name used for domain registration.
* @param {string} params.lastName - Registrant last name used for domain registration.
* @param {string} params.email - Registrant email address for registration and notices.
* @param {string} params.phone - Registrant phone number in E.164 format (for example, +15555551234).
* @param {string} params.billingAddressId - Billing address ID used for registration contact details.
* @param {string} params.paymentMethodId - Payment method ID to authorize and capture the purchase.
* @param {string} params.addressLine3 - Additional address line for the registrant (line 3).
* @param {string} params.companyName - Company or organization name for the registrant.
* @param {number} params.periodYears - Registration term in years (1-10).
* @throws {AppwriteException}
* @returns {Promise<Models.Domain>}
*/
createPurchase(params: { domain: string, teamId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number }): Promise<Models.Domain>;
/**
* Create a domain purchase with registrant information.
*
* @param {string} domain - Fully qualified domain name to purchase (for example, example.com).
* @param {string} teamId - Team ID that will own the domain.
* @param {string} firstName - Registrant first name used for domain registration.
* @param {string} lastName - Registrant last name used for domain registration.
* @param {string} email - Registrant email address for registration and notices.
* @param {string} phone - Registrant phone number in E.164 format (for example, +15555551234).
* @param {string} billingAddressId - Billing address ID used for registration contact details.
* @param {string} paymentMethodId - Payment method ID to authorize and capture the purchase.
* @param {string} addressLine3 - Additional address line for the registrant (line 3).
* @param {string} companyName - Company or organization name for the registrant.
* @param {number} periodYears - Registration term in years (1-10).
* @throws {AppwriteException}
* @returns {Promise<Models.Domain>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
createPurchase(domain: string, teamId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number): Promise<Models.Domain>;
createPurchase(
paramsOrFirst: { domain: string, teamId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number } | string,
...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?]
): Promise<Models.Domain> {
let params: { domain: string, teamId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number };

if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { domain: string, teamId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number };
} else {
params = {
domain: paramsOrFirst as string,
teamId: rest[0] as string,
firstName: rest[1] as string,
lastName: rest[2] as string,
email: rest[3] as string,
phone: rest[4] as string,
billingAddressId: rest[5] as string,
paymentMethodId: rest[6] as string,
addressLine3: rest[7] as string,
companyName: rest[8] as string,
periodYears: rest[9] as number
};
}

const domain = params.domain;
const teamId = params.teamId;
const firstName = params.firstName;
const lastName = params.lastName;
const email = params.email;
const phone = params.phone;
const billingAddressId = params.billingAddressId;
const paymentMethodId = params.paymentMethodId;
const addressLine3 = params.addressLine3;
const companyName = params.companyName;
const periodYears = params.periodYears;

if (typeof domain === 'undefined') {
throw new AppwriteException('Missing required parameter: "domain"');
}
if (typeof teamId === 'undefined') {
throw new AppwriteException('Missing required parameter: "teamId"');
}
if (typeof firstName === 'undefined') {
throw new AppwriteException('Missing required parameter: "firstName"');
}
if (typeof lastName === 'undefined') {
throw new AppwriteException('Missing required parameter: "lastName"');
}
if (typeof email === 'undefined') {
throw new AppwriteException('Missing required parameter: "email"');
}
if (typeof phone === 'undefined') {
throw new AppwriteException('Missing required parameter: "phone"');
}
if (typeof billingAddressId === 'undefined') {
throw new AppwriteException('Missing required parameter: "billingAddressId"');
}
if (typeof paymentMethodId === 'undefined') {
throw new AppwriteException('Missing required parameter: "paymentMethodId"');
}

const apiPath = '/domains/purchases';
const payload: Payload = {};
if (typeof domain !== 'undefined') {
payload['domain'] = domain;
}
if (typeof teamId !== 'undefined') {
payload['teamId'] = teamId;
}
if (typeof firstName !== 'undefined') {
payload['firstName'] = firstName;
}
if (typeof lastName !== 'undefined') {
payload['lastName'] = lastName;
}
if (typeof email !== 'undefined') {
payload['email'] = email;
}
if (typeof phone !== 'undefined') {
payload['phone'] = phone;
}
if (typeof billingAddressId !== 'undefined') {
payload['billingAddressId'] = billingAddressId;
}
if (typeof addressLine3 !== 'undefined') {
payload['addressLine3'] = addressLine3;
}
if (typeof companyName !== 'undefined') {
payload['companyName'] = companyName;
}
if (typeof periodYears !== 'undefined') {
payload['periodYears'] = periodYears;
}
if (typeof paymentMethodId !== 'undefined') {
payload['paymentMethodId'] = paymentMethodId;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
'content-type': 'application/json',
}

return this.client.call(
'post',
uri,
apiHeaders,
payload
);
}

/**
* List domain suggestions.
*
Expand Down
20 changes: 14 additions & 6 deletions src/services/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2496,40 +2496,48 @@ export class Organizations {
* Get Scopes
*
* @param {string} params.organizationId - Organization id
* @param {string} params.projectId - Project id
* @throws {AppwriteException}
* @returns {Promise<Models.Roles>}
*/
getScopes(params: { organizationId: string }): Promise<Models.Roles>;
getScopes(params: { organizationId: string, projectId?: string }): Promise<Models.Roles>;
/**
* Get Scopes
*
* @param {string} organizationId - Organization id
* @param {string} projectId - Project id
* @throws {AppwriteException}
* @returns {Promise<Models.Roles>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
getScopes(organizationId: string): Promise<Models.Roles>;
getScopes(organizationId: string, projectId?: string): Promise<Models.Roles>;
getScopes(
paramsOrFirst: { organizationId: string } | string
paramsOrFirst: { organizationId: string, projectId?: string } | string,
...rest: [(string)?]
): Promise<Models.Roles> {
let params: { organizationId: string };
let params: { organizationId: string, projectId?: string };

if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
params = (paramsOrFirst || {}) as { organizationId: string };
params = (paramsOrFirst || {}) as { organizationId: string, projectId?: string };
} else {
params = {
organizationId: paramsOrFirst as string
organizationId: paramsOrFirst as string,
projectId: rest[0] as string
};
}

const organizationId = params.organizationId;
const projectId = params.projectId;

if (typeof organizationId === 'undefined') {
throw new AppwriteException('Missing required parameter: "organizationId"');
}

const apiPath = '/organizations/{organizationId}/roles'.replace('{organizationId}', organizationId);
const payload: Payload = {};
if (typeof projectId !== 'undefined') {
payload['projectId'] = projectId;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down