SDK API

A dense, direct guide to all SDK classes, namespaces, method signatures, parameters, and return types.

Class: `ThinkingDifferently`

The main entry point class of the TypeScript SDK client.

new ThinkingDifferently(config: SDKConfig)

Instantiates the SDK client. Options:

  • apiKey: string (Required) - Public client key.
  • securityKey: string (Optional) - Secret server key.
  • publicKey: string (Optional) - Offline JWT PEM key.
.setSecurityKey(key: string): void

Dynamically updates the security authorization key.

.setPublicKey(key: string): void

Dynamically updates the public key for offline session checks.

.verifyJwt(token: string, publicKey?: string): Promise<any>

Offline cryptographic verification of an Ed25519 JWT session token.

.collection(name: string): QueryBuilder

Returns a mutable QueryBuilder instance scoped to the target collection.

Class: `QueryBuilder`

A chainable helper class used to configure query filters and dispatch database requests.

.where(field: string, operator: Operator, value: unknown): QueryBuilder

Adds a filter condition to the internal query structure.

.limit(count: number): QueryBuilder

Restricts returned count. Must be a positive integer.

.sort(field: string, direction: "asc" | "desc"): QueryBuilder

Specifies sort ordering constraints.

.set(field: string, value: unknown): QueryBuilder

Prepares updates to be applied during patch requests.

.toJSON(): Query

Returns a deep cloned copy of the raw query structure object.

.get<T = any>(): Promise<T[]>

Executes the query and returns matching documents.

.count(): Promise<number>

Returns the count of matching documents.

.insert(data: unknown): Promise<any>

Inserts a document (accepts raw objects or `FormData`).

.updateById(id: string): Promise<any>

Updates a target document by ID with fields configured by `.set()`.

.updateOne(): Promise<any>

Updates the first matched document with fields configured by `.set()`.

.updateMany(): Promise<any>

Updates all matching documents with fields configured by `.set()`.

.DeleteById(id: string): Promise<any>

Deletes a document by database ID. Note the capital **D**.

.deleteOne(): Promise<any>

Deletes the first matched document.

.deleteMany(): Promise<any>

Deletes all matching documents.

Namespace: `sdk.auth`

Contains administrative user logins and session validation interfaces.

sdk.auth.admin.credentials(email, password): Promise<LoginResponse>

Performs credentials login with email/password.

sdk.auth.admin.getToken(): string | null

Returns the loaded administrator session JWT token string.

sdk.auth.admin.setToken(token: string): void

Manually sets an active administrator token onto request headers.