SDK Reference
Every public export of @emofy/dev-sdk — functions, classes, interfaces, and types — generated from the SDK's TypeScript surface via TypeDoc.
SDK Reference
Complete reference for every public export of @emofy/dev-sdk (46 symbols), generated from the SDK's TypeScript surface. For a guided introduction see the SDK overview and the quickstart.
Functions
createEmofyClient
Function
@emofy/dev-sdk — official TypeScript SDK for the Emofy Developer API (v1).
Types are generated from the frozen OpenAPI contract (PRD-223 snapshot); the runtime is a thin hand-written fetch client with V1 envelope unwrap, a typed error surface, Retry-After-aware backoff, idempotency-key transmission, and a programmatic deprecation signal.
createEmofyClient(config: EmofyClientConfig): EmofyClientisV1Envelope
Function
Type guard: does json structurally match the V1 { data, meta } envelope?
isV1Envelope(json: unknown): jsonverifyWebhookSignature
Function
Verify an Emofy-Signature header against the raw request body and your
webhook secret. Returns true only if the timestamp is within the replay
window AND at least one v1= segment matches — covering the secret-rotation
grace window where two signatures (new + old secret) are present.
verifyWebhookSignature(payload: string | Buffer<ArrayBufferLike>, header: string | null | undefined, secret: string, options: VerifyWebhookOptions): booleanClasses
EmofyApiError
Class
Thrown for any non-2xx response (and network failures). Carries the parsed
V1 error envelope fields so a consumer can branch on error.code /
error.status without re-reading the response.
| Member | Type | Description |
|---|---|---|
code | EmofyApiErrorCode | undefined | Catalogued V1 error code when recognised; the raw string otherwise. |
details | unknown | |
isForbidden | boolean | |
isNetworkError | boolean | |
isNotFound | boolean | |
isRateLimited | boolean | |
isUnauthorized | boolean | |
requestId | string | undefined | |
status | number |
Interfaces
AcademicNamespace
Interface
| Member | Type | Description |
|---|---|---|
assignments | AssignmentsResource | |
attendance | AttendanceResource | |
classrooms | ClassroomsResource | |
courses | CoursesResource | |
enrollments | EnrollmentsResource | |
grades | GradesResource | |
lessons | LessonsResource | |
students | StudentsResource | |
teachers | TeachersResource |
AssignmentsResource
Interface
| Member | Type | Description |
|---|---|---|
create | Promise<SingleResult<T>> | |
get | Promise<SingleResult<T>> | |
getSubmissions | Promise<ListResult<T>> | |
list | Promise<ListResult<T>> | |
submit | Promise<SingleResult<T>> |
AttendanceResource
Interface
| Member | Type | Description |
|---|---|---|
bulkMark | Promise<SingleResult<T>> | |
getStudentAttendance | Promise<ListResult<T>> | |
list | Promise<ListResult<T>> | |
mark | Promise<SingleResult<T>> |
ClassroomsResource
Interface
| Member | Type | Description |
|---|---|---|
create | Promise<SingleResult<T>> | |
delete | Promise<SingleResult<T>> | |
get | Promise<SingleResult<T>> | |
list | Promise<ListResult<T>> | |
update | Promise<SingleResult<T>> |
CoursesResource
Interface
| Member | Type | Description |
|---|---|---|
create | Promise<SingleResult<T>> | |
get | Promise<SingleResult<T>> | |
getOfferings | Promise<ListResult<T>> | |
getPrerequisites | Promise<ListResult<T>> | |
list | Promise<ListResult<T>> | |
listStandards | Promise<ListResult<T>> | |
update | Promise<SingleResult<T>> |
DeprecationInfo
Interface
Programmatic signal raised when the server marks a route deprecated.
| Member | Type | Description |
|---|---|---|
deprecatedAt | number | null | Parsed from Deprecation: @<unix-epoch> (RFC 9745), in ms; null if absent. |
docsUrl | string | null | Docs URL from Link: <url>; rel="deprecation"; null if absent. |
path | string | The request path that returned the deprecation headers. |
raw | object | Raw header values, for logging/forwarding. |
sunsetAt | number | null | Parsed from Sunset: <HTTP-date> (RFC 8594), in ms; null if absent. |
EmofyApiErrorBody
Interface
Shape of the error object inside a V1 error envelope.
| Member | Type | Description |
|---|---|---|
code? | string | |
details? | unknown | |
message? | string | |
requestId? | string | |
timestamp? | string |
EmofyClient
Interface
@emofy/dev-sdk — official TypeScript SDK for the Emofy Developer API (v1).
Types are generated from the frozen OpenAPI contract (PRD-223 snapshot); the runtime is a thin hand-written fetch client with V1 envelope unwrap, a typed error surface, Retry-After-aware backoff, idempotency-key transmission, and a programmatic deprecation signal.
| Member | Type | Description |
|---|---|---|
academic | AcademicNamespace | |
family | FamilyResource | |
feed | FeedResource | |
feedBookmarks | FeedBookmarksResource | |
feedComments | FeedCommentsResource | |
feedExperienceRoles | FeedExperienceRolesResource | |
feedPolls | FeedPollsResource | |
feedReactions | FeedReactionsResource | |
feedReports | FeedReportsResource | |
feedScheduled | FeedScheduledResource | |
identity | IdentityResource | |
messaging | MessagingResource | |
profiles | ProfilesResource | |
request | Promise<SingleResult<T>> | Low-level request — used by the resource accessors. |
requestList | Promise<ListResult<T>> | Low-level list request — unwraps data: T[] + pagination meta. |
store | StoreResource | |
tasks | TasksResource & object | Tasks resource — the full generated surface (list, getById, create, update, delete, complete, reopen, listProjects) PLUS the back-compat get alias for getById (the original quickstart surface, FR-7). The alias keeps client.tasks.{list,get,create} byte-compatible. |
usage | UsageResource |
EmofyClientConfig
Interface
@emofy/dev-sdk — official TypeScript SDK for the Emofy Developer API (v1).
Types are generated from the frozen OpenAPI contract (PRD-223 snapshot); the runtime is a thin hand-written fetch client with V1 envelope unwrap, a typed error surface, Retry-After-aware backoff, idempotency-key transmission, and a programmatic deprecation signal.
| Member | Type | Description |
|---|---|---|
apiKey | string | Organization-scoped API key — sent as Authorization: Bearer <apiKey>. |
baseUrl | string | API base URL, e.g. https://api.emofy.net/api/v1. |
fetchImpl? | (input: URL | RequestInfo, init: RequestInit) => Promise<Response> | Injectable fetch — defaults to global fetch. Used by the test harness. |
maxRetries? | number | Max automatic retries on 429 / 5xx / network error. Default 3 (§FR-1). |
onDeprecation? | (info: DeprecationInfo) => void | Called once per distinct deprecated route the client observes. Default: console.warn once per path (AC2.2). Pass a no-op to silence. |
retryBaseMs? | number | Base backoff in ms (exponential). Default 250. |
sleepImpl? | (ms: number) => Promise<void> | Injectable sleep — defaults to real setTimeout. Used by fake-timer tests. |
EnrollmentsResource
Interface
| Member | Type | Description |
|---|---|---|
create | Promise<SingleResult<T>> | |
getSectionEnrollments | Promise<ListResult<T>> | |
list | Promise<ListResult<T>> | |
update | Promise<SingleResult<T>> |
FamilyResource
Interface
| Member | Type | Description |
|---|---|---|
getChild | Promise<SingleResult<T>> | |
getChildren | Promise<ListResult<T>> | |
getHealthInfo | Promise<SingleResult<T>> | |
getMembers | Promise<ListResult<T>> | |
getTrustedContacts | Promise<ListResult<T>> |
FeedBookmarksResource
Interface
| Member | Type | Description |
|---|---|---|
getBookmarks | Promise<ListResult<T>> | |
toggleBookmark | Promise<SingleResult<T>> |
FeedCommentsResource
Interface
| Member | Type | Description |
|---|---|---|
createComment | Promise<SingleResult<T>> | |
deleteComment | Promise<SingleResult<T>> | |
getComments | Promise<ListResult<T>> |
FeedExperienceRolesResource
Interface
| Member | Type | Description |
|---|---|---|
getMembers | Promise<ListResult<T>> | |
getRoles | Promise<ListResult<T>> |
FeedPollsResource
Interface
| Member | Type | Description |
|---|---|---|
getPollResults | Promise<SingleResult<T>> | |
votePoll | Promise<SingleResult<T>> |
FeedReactionsResource
Interface
| Member | Type | Description |
|---|---|---|
getReactions | Promise<ListResult<T>> | |
toggleReaction | Promise<SingleResult<T>> |
FeedReportsResource
Interface
| Member | Type | Description |
|---|---|---|
getReports | Promise<ListResult<T>> | |
reportPost | Promise<SingleResult<T>> | |
reviewReport | Promise<SingleResult<T>> |
FeedResource
Interface
| Member | Type | Description |
|---|---|---|
createPost | Promise<SingleResult<T>> | |
deletePost | Promise<SingleResult<T>> | |
getPost | Promise<SingleResult<T>> | |
getTimeline | Promise<ListResult<T>> | |
updatePost | Promise<SingleResult<T>> |
FeedScheduledResource
Interface
| Member | Type | Description |
|---|---|---|
cancelSchedule | Promise<SingleResult<T>> | |
getScheduledPosts | Promise<ListResult<T>> | |
publishNow | Promise<SingleResult<T>> |
GeneratedResources
Interface
@emofy/dev-sdk — official TypeScript SDK for the Emofy Developer API (v1).
Types are generated from the frozen OpenAPI contract (PRD-223 snapshot); the runtime is a thin hand-written fetch client with V1 envelope unwrap, a typed error surface, Retry-After-aware backoff, idempotency-key transmission, and a programmatic deprecation signal.
| Member | Type | Description |
|---|---|---|
academic | AcademicNamespace | |
family | FamilyResource | |
feed | FeedResource | |
feedBookmarks | FeedBookmarksResource | |
feedComments | FeedCommentsResource | |
feedExperienceRoles | FeedExperienceRolesResource | |
feedPolls | FeedPollsResource | |
feedReactions | FeedReactionsResource | |
feedReports | FeedReportsResource | |
feedScheduled | FeedScheduledResource | |
identity | IdentityResource | |
messaging | MessagingResource | |
profiles | ProfilesResource | |
store | StoreResource | |
tasks | TasksResource | |
usage | UsageResource |
GradesResource
Interface
| Member | Type | Description |
|---|---|---|
bulkSubmitGrades | Promise<SingleResult<T>> | |
createAssessment | Promise<SingleResult<T>> | |
getStudentGrades | Promise<ListResult<T>> | |
listAssessments | Promise<ListResult<T>> | |
listGrades | Promise<ListResult<T>> | |
submitGrade | Promise<SingleResult<T>> |
IdentityResource
Interface
| Member | Type | Description |
|---|---|---|
getCurrentUser | Promise<SingleResult<T>> | |
getMember | Promise<SingleResult<T>> | |
getUser | Promise<SingleResult<T>> | |
listMembers | Promise<ListResult<T>> | |
listUsers | Promise<ListResult<T>> |
LessonsResource
Interface
| Member | Type | Description |
|---|---|---|
create | Promise<SingleResult<T>> | |
get | Promise<SingleResult<T>> | |
getSchedule | Promise<ListResult<T>> | |
list | Promise<ListResult<T>> | |
update | Promise<SingleResult<T>> |
ListParams
Interface
Common pagination params for list calls (offset OR cursor).
| Member | Type | Description |
|---|---|---|
cursor? | string | |
limit? | number | |
page? | number |
ListResult
Interface
Result of a list call: data plus the structured pagination meta.
| Member | Type | Description |
|---|---|---|
data | T[] | |
meta | ResponseMeta | |
pagination | PaginationMeta | undefined | |
rateLimit | RateLimitInfo |
MessagingResource
Interface
| Member | Type | Description |
|---|---|---|
createConversation | Promise<SingleResult<T>> | |
createGroup | Promise<SingleResult<T>> | |
listConversations | Promise<ListResult<T>> | |
listGroups | Promise<ListResult<T>> | |
listMessages | Promise<ListResult<T>> | |
sendMessage | Promise<SingleResult<T>> |
PaginationMeta
Interface
Structured paginator shape carried in meta.pagination (PRD-222 AC3.1).
| Member | Type | Description |
|---|---|---|
hasMore | boolean | |
limit | number | |
nextCursor? | string | null | |
page | number | |
total? | number |
ProfilesResource
Interface
| Member | Type | Description |
|---|---|---|
getProfile | Promise<SingleResult<T>> | |
list | Promise<ListResult<T>> |
RateLimitInfo
Interface
Rate-limit snapshot read off X-RateLimit-* headers (AC1.3).
| Member | Type | Description |
|---|---|---|
limit | number | null | |
remaining | number | null | |
resetAt | number | null |
RequestOptions
Interface
@emofy/dev-sdk — official TypeScript SDK for the Emofy Developer API (v1).
Types are generated from the frozen OpenAPI contract (PRD-223 snapshot); the runtime is a thin hand-written fetch client with V1 envelope unwrap, a typed error surface, Retry-After-aware backoff, idempotency-key transmission, and a programmatic deprecation signal.
| Member | Type | Description |
|---|---|---|
body? | unknown | JSON body for mutations. |
headers? | Record<string, string> | Extra headers (merged last). |
idempotencyKey? | string | Idempotency key — only meaningful on mutations; sent as Idempotency-Key. The backend behavior lands in PRD-224; the SDK's job is to transmit it. |
query? | Record<string, string | number | boolean | null | undefined> | Query params; undefined/null values are skipped. |
signal? | AbortSignal | AbortSignal for cancellation. |
ResponseMeta
Interface
The meta object on every V1 success response.
| Member | Type | Description |
|---|---|---|
hasMore? | boolean | |
limit? | number | |
nextCursor? | string | null | |
page? | number | |
pagination? | PaginationMeta | |
requestId | string | |
timestamp | string | |
total? | number |
SingleResult
Interface
Result of a single-resource call.
| Member | Type | Description |
|---|---|---|
data | T | |
meta | ResponseMeta | |
rateLimit | RateLimitInfo |
StoreResource
Interface
| Member | Type | Description |
|---|---|---|
get | Promise<SingleResult<T>> | Get app detail by ID |
install | Promise<SingleResult<T>> | Install an app for the organization |
list | Promise<ListResult<T>> | List published apps (paginated) |
listInstalled | Promise<ListResult<T>> | List installed apps for the organization |
uninstall | Promise<SingleResult<T>> | Uninstall an app from the organization |
StudentsResource
Interface
| Member | Type | Description |
|---|---|---|
get | Promise<SingleResult<T>> | |
getEnrollments | Promise<ListResult<T>> | |
list | Promise<ListResult<T>> |
TasksResource
Interface
| Member | Type | Description |
|---|---|---|
complete | Promise<SingleResult<T>> | |
create | Promise<SingleResult<T>> | |
delete | Promise<SingleResult<T>> | |
getById | Promise<SingleResult<T>> | |
list | Promise<ListResult<T>> | |
listProjects | Promise<ListResult<T>> | |
reopen | Promise<SingleResult<T>> | |
update | Promise<SingleResult<T>> |
TeachersResource
Interface
| Member | Type | Description |
|---|---|---|
get | Promise<SingleResult<T>> | |
list | Promise<ListResult<T>> |
UsageResource
Interface
| Member | Type | Description |
|---|---|---|
getKeyUsage | Promise<SingleResult<T>> | Per-API-key usage breakdown (org-owned keys only) |
getOrgUsage | Promise<SingleResult<T>> | Org API usage time-series (requests / errors / p95 / rate-limit hits) |
V1Envelope
Interface
Generic V1 success envelope.
| Member | Type | Description |
|---|---|---|
data | T | |
meta | ResponseMeta |
VerifyWebhookOptions
Interface
| Member | Type | Description |
|---|---|---|
now? | number | Override "now" (ms) — for deterministic tests. Default Date.now(). |
toleranceMs? | number | Replay tolerance in ms. Default 5 minutes (matches the platform contract). |
Type aliases
CreateTaskBody
Type alias
Request-body type for creating a task, sourced from the generated contract.
type CreateTaskBody = components["schemas"]["V1CreateTaskDto"]EmofyApiErrorCode
Type alias
Open union: a known code (autocompleted) OR any other string the server may
return. (string & {}) preserves literal-completion for the known members.
type EmofyApiErrorCode = KnownApiErrorCode | string & objectKnownApiErrorCode
Type alias
The stable, developer-facing V1 error codes worth branching on. Casing is intentionally lower_snake (generics/domain/reserved) — it matches the live contract verbatim. Family UPPER_SNAKE codes are covered by the open fallback.
type KnownApiErrorCode = "bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "validation_error" | "rate_limit_exceeded" | "internal_error" | "unknown_error" | "report_not_found" | "report_not_pending" | "post_already_deleted" | "self_report_not_allowed" | "invalid_user_report_body" | "invalid_moderation_query" | "invalid_review_action_body" | "organization_context_required" | "membership_inactive" | "missing_initdata" | "initdata_invalid" | "initdata_expired" | "credential_not_found" | "scope_insufficient" | "scope_unmapped" | "invalid_cursor" | "idempotency_conflict" | "idempotency_key_reused" | "org_quota_exceeded"