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

refactor: streaming js api #1

Merged
merged 4 commits into from
Aug 3, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.idea
.vscode
.env
1 change: 1 addition & 0 deletions docs/ee43850a-1f0c-11ee-98fa-00155da08df7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"page_content": "[{\"level\": 1, \"title\": \" Getting Started for Web \", \"body\": [\"Appwrite is a development platform that provides a powerful API and management console to get your next project up and running quickly.\", \"Create your first project now and start building on Appwrite Cloud.\"]}, {\"level\": 2, \"title\": \"Add Your Web Platform\", \"body\": [\"To init your SDK and interact with Appwrite services, you need to add a web platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before and click the 'Add Platform' button.\", \"From the options, choose to add a web platform and add your client app hostname. By adding your hostname to your project platform, you are allowing cross-domain communication between your project and the Appwrite API. Only web apps hosted on domains specified in a web platform will be able to make requests to your Appwrite instance, preventing unwanted access from malicious actors.\", \"Web platforms allow wildcard hostnames through a * character. The wildcard character can be applied anywhere in a hostname, both *.example.com and prod.*.example.com are valid examples. Avoid using wildcards unless necessary to keep your Appwrite project secure.\"]}, {\"level\": 2, \"title\": \"Get Appwrite Web SDK\", \"body\": []}, {\"level\": 3, \"title\": \"NPM\", \"body\": [\"Use NPM (node package manager) from your command line to add Appwrite SDK to your project.\", \" npm install appwrite\", \"When you're using a bundler (like Browserify or Webpack), import the Appwrite module when you need it:\", \" import { Client, Account, ID } from 'appwrite';\"]}, {\"level\": 3, \"title\": \"CDN\", \"body\": [\"To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services:\", \" <script src=\\\"https://cdn.jsdelivr.net/npm/[email protected]\\\"></script>\\n<script>\\n const { Client, Account, ID } = Appwrite;\\n // Your code below...\\n</script>\"]}, {\"level\": 2, \"title\": \"Init your SDK\", \"body\": [\"Initialize your SDK code with your project ID which can be found in your project settings page.\", \" const client = new Client()\\n .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint\\n .setProject('[PROJECT_ID]'); // Your project ID\\n\"]}, {\"level\": 2, \"title\": \"Make Your First Request\", \"body\": [\"After your SDK configuration is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would use is found in the SDK documentation or in the API References section.\", \" const account = new Account(client);\\n\\n// Register User\\naccount.create(\\n ID.unique(),\\n '[email protected]',\\n 'password',\\n 'Jane Doe'\\n).then(response => {\\n console.log(response);\\n}, error => {\\n console.log(error);\\n});\"]}, {\"level\": 2, \"title\": \"Listen to Changes\", \"body\": [\"To listen to changes in realtime from Appwrite, subscribe to a variety of channels and receive updates within milliseconds. Full documentation for Realtime is found here.\", \" // Subscribe to files channel\\nclient.subscribe('files', response => {\\n if(response.events.includes('buckets.*.files.*.create')) {\\n // Log when a new file is uploaded\\n console.log(response.payload);\\n }\\n});\"]}, {\"level\": 2, \"title\": \"Full Example\", \"body\": [\" import { Client, Account, ID } from \\\"appwrite\\\";\\n\\nconst client = new Client()\\n .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint\\n .setProject('[PROJECT_ID]'); // Your project ID\\n\\nconst account = new Account(client);\\n\\n// Register User\\naccount.create(\\n ID.unique(),\\n '[email protected]',\\n 'password',\\n 'Jane Doe'\\n).then(response => {\\n console.log(response);\\n}, error => {\\n console.log(error);\\n});\\n\\n// Subscribe to files channel\\nclient.subscribe('files', response => {\\n if(response.events.includes('buckets.*.files.*.create')) {\\n // Log when a new file is uploaded\\n console.log(response.payload);\\n }\\n});\"]}, {\"level\": 2, \"title\": \"Demos\", \"body\": [\"Below is a list of some demos to help you get started with Appwrite for Web using your favorite tools and framework of choice.\", \" Demo GitHub Repository Todo App with React JS appwrite/todo-with-react Live Example Todo App with Vue JS appwrite/todo-with-vue Live Example Todo App with Angular appwrite/todo-with-angular Live Example Todo App with Svelte appwrite/todo-with-svelte Live Example \"]}]", "metadata": {"source": "https://appwrite.io/docs/getting-started-for-web"}}
1 change: 1 addition & 0 deletions docs/ee438b68-1f0c-11ee-98fa-00155da08df7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"page_content": "[{\"level\": 1, \"title\": \" Getting Started for Flutter \", \"body\": [\"Appwrite is a development platform that provides a powerful API and management console to get your next project up and running quickly.\", \"Create your first project now and start building on Appwrite Cloud.\"]}, {\"level\": 2, \"title\": \"Add your Flutter Platform\", \"body\": [\"To init your SDK and start interacting with Appwrite services, you need to add a new Flutter platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before, and click the 'Add Platform' button. Only API requests initiated from platforms added to your Appwrite project will be accepted. This prevents unauthorized apps from accessing your Appwrite project.\", \"From the options, choose to add a new Flutter platform and add your app credentials. Appwrite Flutter SDK currently supports building apps for Android, iOS, Linux, Mac OS, Web and Windows.\", \"If you are building your Flutter application for multiple devices, you have to follow this process for each different device.\"]}, {\"level\": 3, \"title\": \"Android\", \"body\": [\"For Android first add your app name and package name, Your package name is generally the applicationId in your app-level build.gradle file. By registering your new app platform, you are allowing your app to communicate with the Appwrite API.\", \"In order to capture the Appwrite OAuth callback url, the following activity needs to be added inside the `<application>` tag, along side the existing `<activity>` tags in your AndroidManifest.xml. Be sure to replace the [PROJECT_ID] string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console.\", \" <manifest ...>\\n ...\\n <application ...>\\n ...\\n <!-- Add this inside the `<application>` tag, along side the existing `<activity>` tags -->\\n <activity android:name=\\\"com.linusu.flutter_web_auth_2.CallbackActivity\\\" android:exported=\\\"true\\\">\\n <intent-filter android:label=\\\"flutter_web_auth_2\\\">\\n <action android:name=\\\"android.intent.action.VIEW\\\" />\\n <category android:name=\\\"android.intent.category.DEFAULT\\\" />\\n <category android:name=\\\"android.intent.category.BROWSABLE\\\" />\\n <data android:scheme=\\\"appwrite-callback-[PROJECT_ID]\\\" />\\n </intent-filter>\\n </activity>\\n </application>\\n</manifest>\"]}, {\"level\": 3, \"title\": \"iOS\", \"body\": [\"For iOS first add your app name and Bundle ID, You can find your Bundle Identifier in the General tab for your app's primary target in Xcode.\", \"The Appwrite SDK uses ASWebAuthenticationSession on iOS 12+ and SFAuthenticationSession on iOS 11 to allow OAuth authentication. You have to change your iOS Deployment Target in Xcode to be iOS >= 11 to be able to build your app on an emulator or a real device.\", \" In Xcode, open Runner.xcworkspace in your app's iOS folder. To view your app's settings, select the Runner project in the Xcode project navigator. Then, in the main view sidebar, select the Runner target. Select the General tab. In Deployment Info, 'Target' select iOS 11.0\"]}, {\"level\": 3, \"title\": \"Linux\", \"body\": [\"For Linux add your app name and package name, Your package name is generally the name in your pubspec.yaml file. If you cannot find the correct package name, run the application in linux, and make any request with proper exception handling, you should get the application id needed to add in the received error message.\"]}, {\"level\": 3, \"title\": \"macOS\", \"body\": [\"For macOS add your app name and Bundle ID, You can find your Bundle Identifier in the General tab for your app's primary target in Xcode.\", \"The Appwrite SDK uses ASWebAuthenticationSession on macOS 10.15+ to allow OAuth authentication. You have to change your macOS Deployment Target in Xcode to be macOS >= 10.15 to be able to build your app for macOS.\"]}, {\"level\": 3, \"title\": \"Web\", \"body\": [\"To build web apps that integrate with Appwrite successfully, you must add a web platform on your Appwrite project's dashboard and list the domain your website uses to allow communication to the Appwrite API. The process is similar to the adding a web platform in the web guide.\", \"For web in order to capture the OAuth2 callback URL and send it to the application using JavaScript postMessage(), you need to create an html file inside ./web folder of your Flutter project. For example auth.html with the following content.\", \" <!DOCTYPE html>\\n<title>Authentication complete</title>\\n<p>Authentication is complete. If this does not happen automatically, please\\nclose the window.\\n<script>\\n window.opener.postMessage({\\n 'flutter-web-auth-2': window.location.href\\n }, window.location.origin);\\n window.close();\\n</script>\", \"The redirection URL passed to the authentication service must be the same as the URL on which the application is running (schema, host, port if necessary), and the path must point to created HTML file, /auth.html in this case. The callbackUrlScheme parameter of the authenticate() method does not take into account, so it is possible to use a schema for native platforms in the code.\", \" Flutter Web Cross-Domain Communication & Cookies While running Flutter Web, make sure your Appwrite server and your Flutter client use the same top-level domain and protocol (HTTP or HTTPS) to communicate. When communicating between different domains or protocols, you may receive HTTP status error 401 because some modern browsers block cross-site or insecure cookies for enhanced privacy. In production, Appwrite allows you set multiple custom-domains for each project.\"]}, {\"level\": 3, \"title\": \"Windows\", \"body\": [\"For Windows add your app name and package name, Your package name is generally the name in your pubspec.yaml file. If you cannot find the correct package name, run the application in windows, and make any request with proper exception handling, you should get the application id needed to add in the received error message.\"]}, {\"level\": 2, \"title\": \"Get Appwrite Flutter SDK\", \"body\": [\"Add Appwrite SDK to your package's pubspec.yaml file (view example):\", \" dependencies:\\n appwrite: ^9.0.0\", \"You can also install the SDK using the Dart package manager from your terminal:\", \" flutter pub add appwrite\"]}, {\"level\": 2, \"title\": \"Init your SDK\", \"body\": [\"Initialize your SDK with your endpoint and project ID, which can be found on your project settings page. It's usually a good practice to initialize the Client and make it available across the app using the state management solution of your choice, as the Client is required for making any calls to the Appwrite API.\", \" import 'package:appwrite/appwrite.dart';\\n\\nClient client = Client()\\n .setEndpoint('https://cloud.appwrite.io/v1') // Your Appwrite Endpoint\\n .setProject('[PROJECT_ID]'); // Your project ID\", \"Before sending any API calls to your new Appwrite project, make sure your mobile device or emulator has network access to your Appwrite project's hostname or IP address.\"]}, {\"level\": 2, \"title\": \"Make Your First Request\", \"body\": [\"After your SDK configuration is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.\", \" // Register User\\nAccount account = Account(client);\\n\\nfinal user = await account.create(\\n userId: ID.unique(),\\n email: '[email protected]',\\n password: 'password',\\n name: 'My Name'\\n);\\n\"]}, {\"level\": 2, \"title\": \"Listen to Changes\", \"body\": [\"If you want to listen to changes in realtime from Appwrite, you can subscribe to a variety of channels and receive updates within milliseconds. Full documentation for Realtime can be found here.\", \" // Subscribe to files channel\\nfinal realtime = Realtime(client);\\nfinal subscription = realtime.subscribe(['files']);\\n\\nsubscription.stream.listen((response) {\\n if (response.events.contains('buckets.*.files.*.create') {\\n // Log when a new file is uploaded\\n print(response.payload);\\n }\\n});\\n\"]}, {\"level\": 2, \"title\": \"Full Example\", \"body\": [\" import 'package:appwrite/appwrite.dart';\\n\\nClient client = Client()\\n .setEndpoint('https://cloud.appwrite.io/v1') // Your Appwrite Endpoint\\n .setProject('[PROJECT_ID]'); // Your project ID\\n\\nAccount account = Account(client);\\n\\nfinal user = await account.create(\\n userId: ID.unique(),\\n email: '[email protected]',\\n password: 'password',\\n name: 'My Name'\\n);\\n\\n// Subscribe to files channel\\nfinal realtime = Realtime(client);\\nfinal subscription = realtime.subscribe(['files']);\\n\\nsubscription.stream.listen((response) {\\n if (response.events.contains('buckets.*.files.*.create')) {\\n // Log when a new file is uploaded\\n print(response.payload);\\n }\\n});\\n\"]}]", "metadata": {"source": "https://appwrite.io/docs/getting-started-for-flutter"}}
1 change: 1 addition & 0 deletions docs/ee438ef6-1f0c-11ee-98fa-00155da08df7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"page_content": "[{\"level\": 1, \"title\": \" Getting Started for Apple \", \"body\": [\"Appwrite is a development platform that provides a powerful API and management console to get your next project up and running quickly.\", \"Create your first project now and start building on Appwrite Cloud.\"]}, {\"level\": 2, \"title\": \"Add your Apple Platform\", \"body\": [\"To init your SDK and start interacting with Appwrite services, you need to add a new Apple platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before, and click the 'Add Platform' button. Only API requests initiated from platforms added to your Appwrite project will be accepted. This prevents unauthorized apps from accessing your Appwrite project.\", \"From the options, choose to add a new Apple platform, select the iOS, macOS, watchOS or tvOS tab and add your app name and bundle identifier, Your bundle identifier can be found at the top of the General tab in your project settings, or in your Info.plist file. By registering your new app platform, you are allowing your app to communicate with the Appwrite API.\"]}, {\"level\": 2, \"title\": \"Get Appwrite Apple SDK\", \"body\": []}, {\"level\": 3, \"title\": \"Using Xcode\", \"body\": [\" Select File > Add Packages Search for the Appwrite SDK with the URL https://github.com/appwrite/sdk-for-apple In the right panel, select your target project and add your desired version rules Select Add Package and wait for package resolution to complete Make sure the Appwrite package product is checked and select Add Package again\"]}, {\"level\": 3, \"title\": \"Using Swift Packages\", \"body\": [\"Add the following to your Package.swift file: \", \" dependencies: [\\n .package(\\n name: \\\"Appwrite\\\",\\n url: \\\"https://github.com/appwrite/sdk-for-swift\\\",\\n .exact(\\\"2.0.0\\\")\\n )\\n]')\", \"Then add the dependency to your target:\", \" targets: [\\n .target(\\n name: \\\"[YOUR_TARGET]\\\",\\n dependencies: [\\n \\\"Appwrite\\\"\\n ]\\n )\\n]\"]}, {\"level\": 3, \"title\": \"OAuth Callback\", \"body\": [\"In order to capture the Appwrite OAuth callback url, the following URL scheme needs to added to your `Info.plist`\", \" <key>CFBundleURLTypes</key>\\n<array>\\n<dict>\\n <key>CFBundleTypeRole</key>\\n <string>Editor</string>\\n <key>CFBundleURLName</key>\\n <string>io.appwrite</string>\\n <key>CFBundleURLSchemes</key>\\n <array>\\n <string>appwrite-callback-[PROJECT_ID]</string>\\n </array>\\n</dict>\\n</array>\\n\", \"If you're using UIKit, you'll also need to add a hook to your SceneDelegate.swift file to ensure cookies work correctly.\", \" \\nfunc scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {\\n guard let url = URLContexts.first?.url,\\n url.absoluteString.contains(\\\"appwrite-callback\\\") else {\\n return\\n }\\n WebAuthComponent.handleIncomingCookie(from: url)\\n}\\n\"]}, {\"level\": 2, \"title\": \"Init your SDK\", \"body\": [\"Initialize your SDK code with your project ID, which can be found in your project settings page.\", \" import Appwrite\\nimport AppwriteModels\\n\\nlet client = Client()\\n .setEndpoint(\\\"https://cloud.appwrite.io/v1\\\") // Your Appwrite Endpoint\\n .setProject(\\\"[PROJECT_ID]\\\") // Your project ID\", \"Before sending any API calls to your new Appwrite project, make sure your device or emulator has network access to your Appwrite project's hostname or IP address.\"]}, {\"level\": 2, \"title\": \"Make Your First Request\", \"body\": [\"After your SDK configuration is set, access any of the Appwrite services and choose any request to send. Complete documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.\", \" // Register User\\nlet account = Account(client)\\n\\nlet user = try await account.create(\\n userId: ID.unique(),\\n email: \\\"[email protected]\\\",\\n password: \\\"password\\\"\\n)\"]}, {\"level\": 2, \"title\": \"Listen to Changes\", \"body\": [\"To listen to changes in realtime from Appwrite, subscribe to a variety of channels and receive updates within milliseconds. Full documentation for Realtime can be found here.\", \" // Subscribe to files channel\\nlet realtime = Realtime(client)\\n\\nlet subscription = realtime.subscribe(channels: [\\\"files\\\"]) { message in\\n if (message.events!.contains(\\\"buckets.*.files.*.create\\\")) {\\n // Log when a new file is uploaded\\n print(String(describing: message.payload))\\n }\\n}\", \"If you're using macOS, for realtime to function correctly you need to ensure you have both \\\"Outgoing Connections (Client)\\\" and \\\"Incoming Connections (Server)\\\" enabled in your App Sandbox settings in your project file.\"]}, {\"level\": 2, \"title\": \"Full Example\", \"body\": [\" import Appwrite\\nimport AppwriteModels\\n\\nlet client = Client()\\n .setEndpoint(\\\"https://cloud.appwrite.io/v1\\\") // Your Appwrite Endpoint\\n .setProject(\\\"[PROJECT_ID]\\\") // Your project ID\\n\\n// Register User\\nlet account = Account(client)\\n\\nlet user = try await account.create(\\n userId: ID.unique(),\\n email: \\\"[email protected]\\\",\\n password: \\\"password\\\"\\n)\\n\\n// Subscribe to files channel\\nlet realtime = Realtime(client)\\n\\nlet subscription = realtime.subscribe(channels: [\\\"files\\\"]) { message in\\n if (message.events!.contains(\\\"buckets.*.files.*.create\\\")) {\\n // Log when a new file is uploaded\\n print(String(describing: message.payload))\\n }\\n}\"]}]", "metadata": {"source": "https://appwrite.io/docs/getting-started-for-apple"}}
Loading