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
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Use Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24.14.1'
registry-url: 'https://registry.npmjs.org'
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
min-release-age=7
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Change log

## 0.30.0

* Added: Realtime `presences` channel and `RealtimePresence` types for presence subscriptions
* Added: `Advisor` and `Presences` services
* Added: `Insight`, `Presence`, and `Report` models with list variants
* Added: `fusionauth`, `keycloak`, and `kick` providers to `OAuthProvider` enum
* Added: `Client.setCookie()` method for forwarding cookies in server-side runtimes
* Updated: `X-Appwrite-Response-Format` header to `1.9.5`

## 0.29.0

* Breaking: Added `subscribe` message flow for Realtime subscription updates.
* Breaking: Added `close()` support for Realtime subscriptions.
* Added: Added `subscriptions` metadata to Realtime events for targeted callbacks.
* Updated: Updated `X-Appwrite-Response-Format` header to `1.9.2`.
* Breaking: Added `subscribe` message flow for Realtime subscription updates
* Breaking: Added `close()` support for Realtime subscriptions
* Added: Added `subscriptions` metadata to Realtime events for targeted callbacks
* Updated: Updated `X-Appwrite-Response-Format` header to `1.9.2`

## 0.28.0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite React Native SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.9.2-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.9.5-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
16 changes: 16 additions & 0 deletions docs/examples/advisor/get-insight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
import { Client, Advisor } from "react-native-appwrite";

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

const advisor = new Advisor(client);

const result = await advisor.getInsight({
reportId: '<REPORT_ID>',
insightId: '<INSIGHT_ID>'
});

console.log(result);
```
15 changes: 15 additions & 0 deletions docs/examples/advisor/get-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```javascript
import { Client, Advisor } from "react-native-appwrite";

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

const advisor = new Advisor(client);

const result = await advisor.getReport({
reportId: '<REPORT_ID>'
});

console.log(result);
```
17 changes: 17 additions & 0 deletions docs/examples/advisor/list-insights.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```javascript
import { Client, Advisor } from "react-native-appwrite";

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

const advisor = new Advisor(client);

const result = await advisor.listInsights({
reportId: '<REPORT_ID>',
queries: [], // optional
total: false // optional
});

console.log(result);
```
16 changes: 16 additions & 0 deletions docs/examples/advisor/list-reports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```javascript
import { Client, Advisor } from "react-native-appwrite";

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

const advisor = new Advisor(client);

const result = await advisor.listReports({
queries: [], // optional
total: false // optional
});

console.log(result);
```
2 changes: 1 addition & 1 deletion docs/examples/functions/create-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const result = await functions.createExecution({
functionId: '<FUNCTION_ID>',
body: '<BODY>', // optional
async: false, // optional
path: '<PATH>', // optional
xpath: '<PATH>', // optional
method: ExecutionMethod.GET, // optional
headers: {}, // optional
scheduledAt: '<SCHEDULED_AT>' // optional
Expand Down
15 changes: 15 additions & 0 deletions docs/examples/presences/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```javascript
import { Client, Presences } from "react-native-appwrite";

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

const presences = new Presences(client);

const result = await presences.delete({
presenceId: '<PRESENCE_ID>'
});

console.log(result);
```
15 changes: 15 additions & 0 deletions docs/examples/presences/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```javascript
import { Client, Presences } from "react-native-appwrite";

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

const presences = new Presences(client);

const result = await presences.get({
presenceId: '<PRESENCE_ID>'
});

console.log(result);
```
17 changes: 17 additions & 0 deletions docs/examples/presences/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```javascript
import { Client, Presences } from "react-native-appwrite";

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

const presences = new Presences(client);

const result = await presences.list({
queries: [], // optional
total: false, // optional
ttl: 0 // optional
});

console.log(result);
```
20 changes: 20 additions & 0 deletions docs/examples/presences/update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
```javascript
import { Client, Presences, Permission, Role } from "react-native-appwrite";

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

const presences = new Presences(client);

const result = await presences.update({
presenceId: '<PRESENCE_ID>',
status: '<STATUS>', // optional
expiresAt: '2020-10-15T06:38:00.000+00:00', // optional
metadata: {}, // optional
permissions: ["read("any")"], // optional
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 The permission string "read("any")" is a JavaScript syntax error. The inner double-quotes terminate the outer string literal before the closing ), so pasting this snippet will throw a parse error. The file already imports Permission and Role, so the idiomatic form should be used instead.

Suggested change
permissions: ["read("any")"], // optional
permissions: [Permission.read(Role.any())], // optional

purge: false // optional
});

console.log(result);
```
19 changes: 19 additions & 0 deletions docs/examples/presences/upsert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```javascript
import { Client, Presences, Permission, Role } from "react-native-appwrite";

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

const presences = new Presences(client);

const result = await presences.upsert({
presenceId: '<PRESENCE_ID>',
status: '<STATUS>',
permissions: ["read("any")"], // optional
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Same invalid permission string as in update.md"read("any")" is a JavaScript syntax error. The imported Permission and Role helpers should be used here too for consistency and correctness.

Suggested change
permissions: ["read("any")"], // optional
permissions: [Permission.read(Role.any())], // optional

expiresAt: '2020-10-15T06:38:00.000+00:00', // optional
metadata: {} // optional
});

console.log(result);
```
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "react-native-appwrite",
"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": "0.29.0",
"version": "0.30.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down Expand Up @@ -52,6 +52,7 @@
"glob": "^13.0.0",
"rimraf": "^6.0.0",
"@xmldom/xmldom": "^0.9.10",
"uuid": "^14.0.0"
"uuid": "^14.0.0",
"postcss": "^8.5.12"
}
}
15 changes: 12 additions & 3 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ interface Func { _fn: any }
interface Execution { _exec: any }
interface Team { _team: any }
interface Membership { _mem: any }
interface Presence { _presence: any }
interface Resolved { _res: any }

type Actionable = Document | Row | File | Team | Membership;
type Actionable = Document | Row | File | Team | Membership | Presence;

function normalize(id: string): string {
if (id === undefined || id === null) {
Expand Down Expand Up @@ -79,7 +80,7 @@ export class Channel<T> {
return this.resolve("create");
}

upsert(this: Channel<Document | Row>): Channel<Resolved> {
upsert(this: Channel<Document | Row | Presence>): Channel<Resolved> {
return this.resolve("upsert");
}

Expand Down Expand Up @@ -120,6 +121,10 @@ export class Channel<T> {
return new Channel<Membership>(["memberships", normalize(id)]);
}

static presence(id: string) {
return new Channel<Presence>(["presences", normalize(id)]);
}

static account(): string {
return "account";
}
Expand Down Expand Up @@ -148,8 +153,12 @@ export class Channel<T> {
static memberships(): string {
return "memberships";
}

static presences(): string {
return "presences";
}
}

// Export types for backward compatibility with realtime
export type ActionableChannel = Channel<Document> | Channel<Row> | Channel<File> | Channel<Execution> | Channel<Team> | Channel<Membership>;
export type ActionableChannel = Channel<Document> | Channel<Row> | Channel<File> | Channel<Execution> | Channel<Team> | Channel<Membership> | Channel<Presence>;
export type ResolvedChannel = Channel<Resolved>;
Loading