Skip to content

Commit 40d238d

Browse files
authored
Merge pull request #62 from appwrite/dev
feat: Console SDK update for version 3.1.0
2 parents d4a0f81 + c4077a5 commit 40d238d

File tree

10 files changed

+233
-12
lines changed

10 files changed

+233
-12
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 3.1.0
4+
5+
* Add support for `createPurchase` method in `Domains` service
6+
* Fix very large double values (for example 1.7976931348623157e+308) from being expanded into giant integer literals
7+
38
## 3.0.0
49

510
* 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.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { Client, Account } from "@appwrite.io/console";
3333
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:
3434

3535
```html
36-
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@3.0.0"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/console@3.1.0"></script>
3737
```
3838

3939

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
```javascript
2+
import { Client, Domains } from "@appwrite.io/console";
3+
4+
const client = new Client()
5+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
6+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
7+
8+
const domains = new Domains(client);
9+
10+
const result = await domains.createPurchase({
11+
domain: '',
12+
teamId: '<TEAM_ID>',
13+
firstName: '<FIRST_NAME>',
14+
lastName: '<LAST_NAME>',
15+
email: 'email@example.com',
16+
phone: '+12065550100',
17+
billingAddressId: '<BILLING_ADDRESS_ID>',
18+
paymentMethodId: '<PAYMENT_METHOD_ID>',
19+
addressLine3: '<ADDRESS_LINE3>', // optional
20+
companyName: '<COMPANY_NAME>', // optional
21+
periodYears: 1 // optional
22+
});
23+
24+
console.log(result);
25+
```

docs/examples/organizations/get-scopes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const client = new Client()
88
const organizations = new Organizations(client);
99

1010
const result = await organizations.getScopes({
11-
organizationId: '<ORGANIZATION_ID>'
11+
organizationId: '<ORGANIZATION_ID>',
12+
projectId: '<PROJECT_ID>' // optional
1213
});
1314

1415
console.log(result);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@appwrite.io/console",
33
"homepage": "https://appwrite.io/support",
44
"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",
5-
"version": "3.0.0",
5+
"version": "3.1.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true });
77

88
const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
99
const MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
10+
const MAX_INT64 = BigInt('9223372036854775807');
11+
const MIN_INT64 = BigInt('-9223372036854775808');
1012

1113
function isBigNumber(value: any): boolean {
1214
return value !== null
@@ -25,7 +27,10 @@ function reviver(_key: string, value: any): any {
2527
if (bi >= MIN_SAFE && bi <= MAX_SAFE) {
2628
return Number(str);
2729
}
28-
return bi;
30+
if (bi >= MIN_INT64 && bi <= MAX_INT64) {
31+
return bi;
32+
}
33+
return value.toNumber();
2934
}
3035
return value.toNumber();
3136
}
@@ -395,7 +400,7 @@ class Client {
395400
'x-sdk-name': 'Console',
396401
'x-sdk-platform': 'console',
397402
'x-sdk-language': 'web',
398-
'x-sdk-version': '3.0.0',
403+
'x-sdk-version': '3.1.0',
399404
'X-Appwrite-Response-Format': '1.8.0',
400405
};
401406

src/models.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8567,6 +8567,10 @@ export namespace Models {
85678567
* Domain registrar (e.g. "appwrite" or "third_party").
85688568
*/
85698569
registrar: string;
8570+
/**
8571+
* Payment status for domain purchase.
8572+
*/
8573+
paymentStatus: string;
85708574
/**
85718575
* Nameservers setting. "Appwrite" or empty string.
85728576
*/
@@ -8584,7 +8588,7 @@ export namespace Models {
85848588
*/
85858589
autoRenewal: boolean;
85868590
/**
8587-
* Renewal price (in USD).
8591+
* Renewal price (in cents).
85888592
*/
85898593
renewalPrice: number;
85908594
/**

src/query.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,40 @@ export class Query {
272272

273273
/**
274274
* Filter resources where attribute contains the specified value.
275+
* For string attributes, checks if the string contains the substring.
275276
*
277+
* Note: For array attributes, use {@link containsAny} or {@link containsAll} instead.
276278
* @param {string} attribute
277279
* @param {string | string[]} value
278280
* @returns {string}
279281
*/
280282
static contains = (attribute: string, value: string | any[]): string =>
281283
new Query("contains", attribute, value).toString();
282284

285+
/**
286+
* Filter resources where attribute contains ANY of the specified values.
287+
* For array and relationship attributes, matches documents where the attribute
288+
* contains at least one of the given values.
289+
*
290+
* @param {string} attribute
291+
* @param {any[]} value
292+
* @returns {string}
293+
*/
294+
static containsAny = (attribute: string, value: any[]): string =>
295+
new Query("containsAny", attribute, value).toString();
296+
297+
/**
298+
* Filter resources where attribute contains ALL of the specified values.
299+
* For array and relationship attributes, matches documents where the attribute
300+
* contains every one of the given values.
301+
*
302+
* @param {string} attribute
303+
* @param {any[]} value
304+
* @returns {string}
305+
*/
306+
static containsAll = (attribute: string, value: any[]): string =>
307+
new Query("containsAll", attribute, value).toString();
308+
283309
/**
284310
* Filter resources where attribute does not contain the specified value.
285311
*

src/services/domains.ts

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,153 @@ export class Domains {
206206
);
207207
}
208208

209+
/**
210+
* Create a domain purchase with registrant information.
211+
*
212+
* @param {string} params.domain - Fully qualified domain name to purchase (for example, example.com).
213+
* @param {string} params.teamId - Team ID that will own the domain.
214+
* @param {string} params.firstName - Registrant first name used for domain registration.
215+
* @param {string} params.lastName - Registrant last name used for domain registration.
216+
* @param {string} params.email - Registrant email address for registration and notices.
217+
* @param {string} params.phone - Registrant phone number in E.164 format (for example, +15555551234).
218+
* @param {string} params.billingAddressId - Billing address ID used for registration contact details.
219+
* @param {string} params.paymentMethodId - Payment method ID to authorize and capture the purchase.
220+
* @param {string} params.addressLine3 - Additional address line for the registrant (line 3).
221+
* @param {string} params.companyName - Company or organization name for the registrant.
222+
* @param {number} params.periodYears - Registration term in years (1-10).
223+
* @throws {AppwriteException}
224+
* @returns {Promise<Models.Domain>}
225+
*/
226+
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>;
227+
/**
228+
* Create a domain purchase with registrant information.
229+
*
230+
* @param {string} domain - Fully qualified domain name to purchase (for example, example.com).
231+
* @param {string} teamId - Team ID that will own the domain.
232+
* @param {string} firstName - Registrant first name used for domain registration.
233+
* @param {string} lastName - Registrant last name used for domain registration.
234+
* @param {string} email - Registrant email address for registration and notices.
235+
* @param {string} phone - Registrant phone number in E.164 format (for example, +15555551234).
236+
* @param {string} billingAddressId - Billing address ID used for registration contact details.
237+
* @param {string} paymentMethodId - Payment method ID to authorize and capture the purchase.
238+
* @param {string} addressLine3 - Additional address line for the registrant (line 3).
239+
* @param {string} companyName - Company or organization name for the registrant.
240+
* @param {number} periodYears - Registration term in years (1-10).
241+
* @throws {AppwriteException}
242+
* @returns {Promise<Models.Domain>}
243+
* @deprecated Use the object parameter style method for a better developer experience.
244+
*/
245+
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>;
246+
createPurchase(
247+
paramsOrFirst: { domain: string, teamId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number } | string,
248+
...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?]
249+
): Promise<Models.Domain> {
250+
let params: { domain: string, teamId: string, firstName: string, lastName: string, email: string, phone: string, billingAddressId: string, paymentMethodId: string, addressLine3?: string, companyName?: string, periodYears?: number };
251+
252+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
253+
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 };
254+
} else {
255+
params = {
256+
domain: paramsOrFirst as string,
257+
teamId: rest[0] as string,
258+
firstName: rest[1] as string,
259+
lastName: rest[2] as string,
260+
email: rest[3] as string,
261+
phone: rest[4] as string,
262+
billingAddressId: rest[5] as string,
263+
paymentMethodId: rest[6] as string,
264+
addressLine3: rest[7] as string,
265+
companyName: rest[8] as string,
266+
periodYears: rest[9] as number
267+
};
268+
}
269+
270+
const domain = params.domain;
271+
const teamId = params.teamId;
272+
const firstName = params.firstName;
273+
const lastName = params.lastName;
274+
const email = params.email;
275+
const phone = params.phone;
276+
const billingAddressId = params.billingAddressId;
277+
const paymentMethodId = params.paymentMethodId;
278+
const addressLine3 = params.addressLine3;
279+
const companyName = params.companyName;
280+
const periodYears = params.periodYears;
281+
282+
if (typeof domain === 'undefined') {
283+
throw new AppwriteException('Missing required parameter: "domain"');
284+
}
285+
if (typeof teamId === 'undefined') {
286+
throw new AppwriteException('Missing required parameter: "teamId"');
287+
}
288+
if (typeof firstName === 'undefined') {
289+
throw new AppwriteException('Missing required parameter: "firstName"');
290+
}
291+
if (typeof lastName === 'undefined') {
292+
throw new AppwriteException('Missing required parameter: "lastName"');
293+
}
294+
if (typeof email === 'undefined') {
295+
throw new AppwriteException('Missing required parameter: "email"');
296+
}
297+
if (typeof phone === 'undefined') {
298+
throw new AppwriteException('Missing required parameter: "phone"');
299+
}
300+
if (typeof billingAddressId === 'undefined') {
301+
throw new AppwriteException('Missing required parameter: "billingAddressId"');
302+
}
303+
if (typeof paymentMethodId === 'undefined') {
304+
throw new AppwriteException('Missing required parameter: "paymentMethodId"');
305+
}
306+
307+
const apiPath = '/domains/purchases';
308+
const payload: Payload = {};
309+
if (typeof domain !== 'undefined') {
310+
payload['domain'] = domain;
311+
}
312+
if (typeof teamId !== 'undefined') {
313+
payload['teamId'] = teamId;
314+
}
315+
if (typeof firstName !== 'undefined') {
316+
payload['firstName'] = firstName;
317+
}
318+
if (typeof lastName !== 'undefined') {
319+
payload['lastName'] = lastName;
320+
}
321+
if (typeof email !== 'undefined') {
322+
payload['email'] = email;
323+
}
324+
if (typeof phone !== 'undefined') {
325+
payload['phone'] = phone;
326+
}
327+
if (typeof billingAddressId !== 'undefined') {
328+
payload['billingAddressId'] = billingAddressId;
329+
}
330+
if (typeof addressLine3 !== 'undefined') {
331+
payload['addressLine3'] = addressLine3;
332+
}
333+
if (typeof companyName !== 'undefined') {
334+
payload['companyName'] = companyName;
335+
}
336+
if (typeof periodYears !== 'undefined') {
337+
payload['periodYears'] = periodYears;
338+
}
339+
if (typeof paymentMethodId !== 'undefined') {
340+
payload['paymentMethodId'] = paymentMethodId;
341+
}
342+
const uri = new URL(this.client.config.endpoint + apiPath);
343+
344+
const apiHeaders: { [header: string]: string } = {
345+
'content-type': 'application/json',
346+
}
347+
348+
return this.client.call(
349+
'post',
350+
uri,
351+
apiHeaders,
352+
payload
353+
);
354+
}
355+
209356
/**
210357
* List domain suggestions.
211358
*

src/services/organizations.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,40 +2496,48 @@ export class Organizations {
24962496
* Get Scopes
24972497
*
24982498
* @param {string} params.organizationId - Organization id
2499+
* @param {string} params.projectId - Project id
24992500
* @throws {AppwriteException}
25002501
* @returns {Promise<Models.Roles>}
25012502
*/
2502-
getScopes(params: { organizationId: string }): Promise<Models.Roles>;
2503+
getScopes(params: { organizationId: string, projectId?: string }): Promise<Models.Roles>;
25032504
/**
25042505
* Get Scopes
25052506
*
25062507
* @param {string} organizationId - Organization id
2508+
* @param {string} projectId - Project id
25072509
* @throws {AppwriteException}
25082510
* @returns {Promise<Models.Roles>}
25092511
* @deprecated Use the object parameter style method for a better developer experience.
25102512
*/
2511-
getScopes(organizationId: string): Promise<Models.Roles>;
2513+
getScopes(organizationId: string, projectId?: string): Promise<Models.Roles>;
25122514
getScopes(
2513-
paramsOrFirst: { organizationId: string } | string
2515+
paramsOrFirst: { organizationId: string, projectId?: string } | string,
2516+
...rest: [(string)?]
25142517
): Promise<Models.Roles> {
2515-
let params: { organizationId: string };
2518+
let params: { organizationId: string, projectId?: string };
25162519

25172520
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
2518-
params = (paramsOrFirst || {}) as { organizationId: string };
2521+
params = (paramsOrFirst || {}) as { organizationId: string, projectId?: string };
25192522
} else {
25202523
params = {
2521-
organizationId: paramsOrFirst as string
2524+
organizationId: paramsOrFirst as string,
2525+
projectId: rest[0] as string
25222526
};
25232527
}
25242528

25252529
const organizationId = params.organizationId;
2530+
const projectId = params.projectId;
25262531

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

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

25352543
const apiHeaders: { [header: string]: string } = {

0 commit comments

Comments
 (0)