@realm.w/types
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

𝙍𝙚𝙖𝙡𝙢 𝙒𝙞𝙩𝙝 | 𝒯𝓎𝓅ℯ𝓈 ⋆ ˚。⋆୨˚✧

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

Package Sidebar

Install

npm i @realm.w/types

Weekly Downloads

0

Version

0.1.5

License

MIT

Unpacked Size

22.1 kB

Total Files

38

Last publish

Collaborators

  • uceumice