Code Monkey home page Code Monkey logo

sdk-for-deno's Introduction

Appwrite Deno SDK

License Version Build Status Twitter Account Discord

This SDK is compatible with Appwrite server version 1.4.x. For older versions, please check previous releases.

Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Deno SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs

Appwrite

Installation

import * as sdk from "https://deno.land/x/appwrite/mod.ts";

Getting Started

Init your SDK

Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section.

let client = new sdk.Client();

client
    .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
    .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    .setSelfSigned() // Use only on dev mode with a self-signed SSL cert
;

Make your first request

Once your SDK object is set, create any of the Appwrite service objects 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.

let users = new sdk.Users(client);

let user = await users.create(ID.unique(), '[email protected]', 'password');
console.log(user);

Full Example

import * as sdk from "https://deno.land/x/appwrite/mod.ts";

let client = new sdk.Client();
let users = new sdk.Users(client);

client
    .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
    .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    .setSelfSigned() // Use only on dev mode with a self-signed SSL cert
;

let user = await users.create(ID.unique(), '[email protected]', 'password');
console.log(user);

Error Handling

The Appwrite Deno SDK raises AppwriteException object with message, code and response properties. You can handle any errors by catching AppwriteException and present the message to the user or handle it yourself based on the provided error information. Below is an example.

let users = new sdk.Users(client);

try {
    let user = await users.create(ID.unique(), '[email protected]', 'password');
} catch(e) {
    console.log(e.message);
}

Learn more

You can use the following resources to learn more and get help

Minimal supported version for Deno SDK is 1.19.0.

Contribution

This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.

License

Please see the BSD-3-Clause license file for more information.

sdk-for-deno's People

Contributors

abnegate avatar christyjacob4 avatar eigengravy avatar eldadfux avatar lohanidamodar avatar meldiron avatar torstendittmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-for-deno's Issues

Implement Interfaces on responses

This library is useless unless we implement interfaces for the returned objects from the different functions offered by Appwrite. I understand that these were auto-generated but there must be a way we can improve and/or fix this problem.

Database.listDocuments() unexpected behavior with offset and filter

Offset and Limit appear to be switched for the listDocuments() function.

What's odd, is I check the code here and it looks fine. But when I run this code, this is what I get.

const response = await .database.listDocuments(
        BOT_RUN_COLLECTION_ID,
        ['last_processed_id!=null', 'last_processed_id!=""'],
        0, // offset, should be the limit according to docs.
        1, //limit, out of order. Should be switched with offset according to docs.
        'processed_to',
        'DESC',
        'datetime'
      )
      console.log(response)

Console:

{
  sum: 12,
  documents: [
    {
      "$id": "*****",
      "$collection": "*****",
      "$permissions": { read: [Array], write: [Array] },
      mentions_processed: 3,
      processed_to: "2021-04-03T01:30:23.000Z",
      duplicate_submissions: 0,
      novel_submissions: 0,
      last_processed_id: "****"
    }
  ]
}

When I switch them and run:

      const response = await database.listDocuments(
        BOT_RUN_COLLECTION_ID,
        ['last_processed_id!=null', 'last_processed_id!=""'],
        1, // supposed to be the limit
        0, // supposed to be the offset
        'processed_to',
        'DESC',
        'datetime'
      )
      console.log(response)

I get this resposne:

{ sum: 12, documents: [] }

So the offset and limit appear to be switched in order.

CreateCollection API has problem

In SDK the createCollection gives error.

error: TS2322 [ERROR]: Type '{ label: string; key: string; type: string; default: string; required: true; array: false; }' is not assignable to type 'string'. [{ "label": "Name", "key": "name", "type": "text", "default": "Empty Name", "required": true, "array": false, } ]

When I here checked the signature of the method.

async createCollection(name: string, read: Array<string>, write: Array<string>, rules: Array<string>): Promise<string> {

Here Rules is declared as Array of Strings. But It should be array of Objects or any Type. I have invoked the Crate Collection API like this.

let response = await database.createCollection( 'Movies', // Collection Name ['*'], // Read permissions ['*'], // Write permissions [{ "label": "Name", "key": "name", "type": "text", "default": "Empty Name", "required": true, "array": false, } ] );

As this does not go with the above CreateCollection Signature. Please have a look.

Thanks
Punit

๐Ÿ› Bug Report: the definition file return for the attributes property, a list of string for the reponse of database.listAttributes in the sdk

๐Ÿ‘Ÿ Reproduction steps

When I

import * as sdk from "https://deno.land/x/appwrite/mod.ts";


// Init SDK
let client = new sdk.Client();

let database = new sdk.Database(client);

client
    .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
    .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;


let promise = database.listAttributes('[COLLECTION_ID]');

promise.then(function (response) {
    console.log(response);
}, function (error) {
    console.log(error);
});

๐Ÿ‘ Expected behavior

I expected I have at least a object with the key in the definition

let {total, attributes } = database.listAttributes('[COLLECTION_ID]');

where
attributes => { key:string }[]

and even It should be

{ key:string 
| attributeBoolean?
| attributeInteger?
| attributeFloat?
| attributeEmail?
| attributeEnum?
| attributeUrl?
| attributeIp?
| attributeString?}[]

๐Ÿ‘Ž Actual Behavior

It actually

let {total, attributes } = database.listAttributes('[COLLECTION_ID]');

I have
attributes => string[]

๐ŸŽฒ Appwrite version

Version 0.10.x

๐ŸŽฒ Deno version

Version 1.14.x

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Upgrade our issue templates to use GitHub issue forms โœ๏ธ

Introduction

GitHub has recently rolled out a public beta for their issue forms feature. This would allow you to create interactive issue templates and validate them ๐Ÿคฏ.

Appwrite currently uses the older issue template format. Your task is to create GitHub issue forms for this repository. Please use Appwrite's issue templates as a reference for this PR.

Tasks summary:

  • Fork & clone this repository
  • Prepare bug report issue form in .github/ISSUE_TEMPLATE/bug.yaml
  • Prepare documentation issue form in .github/ISSUE_TEMPLATE/documentation.yaml
  • Prepare feature request issue form in .github/ISSUE_TEMPLATE/feature.yaml
  • Push changes to master and test issue forms on your fork
  • Submit pull request

If you need any help, reach out to us on our Discord server.

Are you ready to work on this issue? ๐Ÿค” Let us know, and we will assign it to you ๐Ÿ˜Š

Happy Appwriting!

๐Ÿ› Bug Report: conversion.ts module not found in inputFile.ts appwrite deno sdk

๐Ÿ‘Ÿ Reproduction steps

Hi, I want to extend appwrite with a custom deno backend and connect via the deno sdk to appwrite.

When i start deno and the dependencies get downloaded i get the following error:
deno run --allow-net test.ts
Warning Implicitly using latest version (0.173.0) for https://deno.land/std/streams/conversion.ts
error: Module not found "https://deno.land/std/streams/conversion.ts".
at https://deno.land/x/[email protected]/src/inputFile.ts:1:42

test.ts

import * as sdk from "https://deno.land/x/appwrite/mod.ts";

let client = new sdk.Client();
let databases = new sdk.Databases(client);

client
  .setEndpoint("http://localhost/v1") // Your API Endpoint
  .setProject("") // Your project ID
  .setKey("") // Your secret API key
  .setSelfSigned(); // Use only on dev mode with a self-signed SSL cert

let response = await databases.listCollections("dbId");
console.log(response);

I tried different appwrite sdk version and it looks like only older version will work for < 5.0.0 (3.0.0/4.0.0)
Also with a docker container it is the same issue.

FROM denoland/deno:1.24.3
EXPOSE 8000
WORKDIR /app
USER deno
COPY . .
RUN deno cache test.ts
CMD ["run", "--allow-all", "test.ts"]

I was not able to find any solution or somebody who have the same problem as me with google.
I tested the same test.ts on a M1 Mac with latest deno and appwrite sdk and the same error occurs.
Hope you can help me here.

๐Ÿ‘ Expected behavior

Download all dependencies and continue

๐Ÿ‘Ž Actual Behavior

throw error:
error: Module not found "https://deno.land/std/streams/conversion.ts".
at https://deno.land/x/[email protected]/src/inputFile.ts:1:42

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐ŸŽฒ Deno version

Different version (specify in environment)

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

linux: manjaro up to date

deno 1.29.4 (release, x86_64-unknown-linux-gnu)
v8 10.9.194.5
typescript 4.9.4

tested also other deno versions:
deno 1.24.x

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.