Skip to content

spec: export a typed hook ctx.api (HookApi / HookObjectApi / HookQuery) — every metadata app hand-declares it today #18163

Description

@os-elon-musk

Gap

@objectstack/spec 17.4.0 exports no type for the ctx.api a *.hook.ts body receives. Checked on the installed package: grep -rhoE "export (type|interface) (HookApi|HookContext|HookObjectApi)" node_modules/@objectstack/spec/dist/data/*.d.ts returns nothing. A hook therefore casts ctx.api as HookApi | undefined against a type the app wrote.

Evidence (hotcrm, origin/main c716a2c)

  • src/objects/_hook-api.ts — ~2,358 authored tokens declaring HookQuery, HookCountQuery, HookUpdateDoc, HookUpdateOptions, HookDeleteOptions, HookObjectApi, HookApi; imported by all 17 hook files in the app.
  • The file exists to make the where / filter mixing hazard a compile error (HookQuery omits filter; test/hook-query-predicate.test.ts pins the engine per method) — i.e. it encodes engine behaviour the platform knows and the app re-derived.
  • Under the ADR-0130 package split (Epic: split HotCRM into ADR-0130 packages — sales is the app, service / revenue / marketing are modules, a directory is a package hotcrm#1904) it is the largest source file more than one package needs, and it is a compensation for a platform gap, which hotcrm's AGENTS.md forbids keeping once the platform supplies the type.

Ask

Export the hook API surface from @objectstack/spec/data (or wherever the hook contract lives) so that an app's hook can import type { HookApi } from '@objectstack/spec/data' and delete its own copy. The where-only query shape (no filter key) should be the exported shape, since the engine folds filter to where and refuses both.

Dedupe words: HookApi, hook ctx.api type, _hook-api.ts, HookQuery, HookObjectApi.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions