Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
// This file is auto-generated by @hey-api/openapi-ts
import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';
import { client } from './client.gen';
import type { BatchSendMessageHandlerData, BatchSendMessageHandlerErrors, BatchSendMessageHandlerResponses, BroadcastMessageHandlerData, BroadcastMessageHandlerErrors, BroadcastMessageHandlerResponses, GetEntityHandlerData, GetEntityHandlerErrors, GetEntityHandlerResponses, SendMessageHandlerData, SendMessageHandlerErrors, SendMessageHandlerResponses } from './types.gen';
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
/**
* You can provide a client instance returned by `createClient()` instead of
* individual options. This might be also useful if you want to implement a
* custom client.
*/
client?: Client;
/**
* You can pass arbitrary values through the `meta` object. This can be
* used to access values that aren't defined as part of the SDK function.
*/
meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
};
class HeyApiClient {
protected client: Client;
constructor(args?: {
client?: Client;
}) {
this.client = args?.client ?? client;
}
}
class HeyApiRegistry<T> {
private readonly defaultKey = 'default';
private readonly instances: Map<string, T> = new Map();
get(key?: string): T {
const instance = this.instances.get(key ?? this.defaultKey);
if (!instance) {
throw new Error(`No SDK client found. Create one with "new Sdk()" to fix this error.`);
}
return instance;
}
set(value: T, key?: string): void {
this.instances.set(key ?? this.defaultKey, value);
}
}
export class Sdk extends HeyApiClient {
public static readonly __registry: HeyApiRegistry<Sdk> = new HeyApiRegistry<Sdk>();
constructor(args?: {
client?: Client;
key?: string;
}) {
super(args);
Sdk.__registry.set(this, args?.key);
}
public batchSendMessageHandler<ThrowOnError extends boolean = false>(options: Options<BatchSendMessageHandlerData, ThrowOnError>): RequestResult<BatchSendMessageHandlerResponses, BatchSendMessageHandlerErrors, ThrowOnError> {
return (options.client ?? this.client).post<BatchSendMessageHandlerResponses, BatchSendMessageHandlerErrors, ThrowOnError>({
security: [{ name: 'x-internal-auth-key', type: 'apiKey' }],
url: '/batch_send',
...options,
headers: {
'Content-Type': 'application/json',
...options.headers
}
});
}
/**
* Sends a message to every open connection on every instance. Delivery is
* best-effort and asynchronous, so there are no receipts.
*/
public broadcastMessageHandler<ThrowOnError extends boolean = false>(options: Options<BroadcastMessageHandlerData, ThrowOnError>): RequestResult<BroadcastMessageHandlerResponses, BroadcastMessageHandlerErrors, ThrowOnError> {
return (options.client ?? this.client).post<BroadcastMessageHandlerResponses, BroadcastMessageHandlerErrors, ThrowOnError>({
security: [{ name: 'x-internal-auth-key', type: 'apiKey' }],
url: '/message/broadcast',
...options,
headers: {
'Content-Type': 'application/json',
...options.headers
}
});
}
public sendMessageHandler<ThrowOnError extends boolean = false>(options: Options<SendMessageHandlerData, ThrowOnError>): RequestResult<SendMessageHandlerResponses, SendMessageHandlerErrors, ThrowOnError> {
return (options.client ?? this.client).post<SendMessageHandlerResponses, SendMessageHandlerErrors, ThrowOnError>({
security: [{ name: 'x-internal-auth-key', type: 'apiKey' }],
url: '/message/send/{entity_type}/{entity_id}',
...options,
headers: {
'Content-Type': 'application/json',
...options.headers
}
});
}
public getEntityHandler<ThrowOnError extends boolean = false>(options: Options<GetEntityHandlerData, ThrowOnError>): RequestResult<GetEntityHandlerResponses, GetEntityHandlerErrors, ThrowOnError> {
return (options.client ?? this.client).get<GetEntityHandlerResponses, GetEntityHandlerErrors, ThrowOnError>({
security: [{ name: 'x-internal-auth-key', type: 'apiKey' }],
url: '/track/{entity_type}/{entity_id}',
...options
});
}
}