Giter Site home page Giter Site logo

realm-types's Introduction

๐™๐™š๐™–๐™ก๐™ข ๐™’๐™ž๐™ฉ๐™ | ๐’ฏ๐“Ž๐“…โ„ฏ๐“ˆ โ‹† หš๏ฝกโ‹†เญจหšโœง

Installation

npm

npm install "@realm.w/types@latest"

pnpm

pnpm add "@realm.w/types@latest"

yarn

yarn install "@realm.w/types@latest"

Globals

Place this file at the root of your src directory or at the root of your functions source directory for TypeScript Server to infer appropriate types for the global variables.

global.d.ts

import 
declare global {
    const context: NormalContext;

    const BSON: {
        ObjectId: InstanceType<ObjectId>
    };
}

context.ts

import { Context as __Context } from "@realm.w/types";
import { UserType } from "@realm.w/types/out/functions/context/shared";

// ---- For better structure, and observability, you can 
// ---- define your bindings, variables, etc. in separate files
import { CustomData, ProfileData, DataSources, Environment, Functions, Values } from "./types";

// @ts-expect-error
export type Context<U extends UserType> = __Context<U, Values, Functions, DataSources, Environment, CustomData, ProfileData>;

// ---- For functions which are meant to be invoked by the enduser
export type NormalContext = Context<"normal">;

// ---- For functions which are run by system itself (e.g. triggers/graphql resolvers)
// ---- P.S.: you can redefine global context in scope of certain functions to be sure in typings) 
export type SystemContext = Context<"system">;

Collaboration

You are welcome to propose new features. You can also complain about the bugs, open all sorts of code related issues.

Licence

MIT

realm-types's People

Watchers

 avatar

realm-types's Issues

Replace `UserType` with a less verbous name

UserType refers to the executioner of the function and has nothing with the user of realm API which may invoke the function. ExecutionEnvironment could be a longer, but more clear name.

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.