# dimah-survey

> Server-owned publishing and response lifecycles for SurveyJS JSON. Publish a document, freeze the definition each response starts with, and validate submit against that same snapshot.

SurveyJS owns the schema, Creator, question behavior, and renderer. Your application owns authentication, database migrations, files, and UI. dimah-survey owns publish, response snapshots, drafts, collection policy, and submit validation.

TypeScript packages: `@dimah-survey/core` (protocol, browser clients, schemas, errors, store types), `@dimah-survey/server` (`dimahSurvey()`, guards, validation, adapters, `memoryAdapter()`), `@dimah-survey/react` (SurveyJS Model and Creator bindings), `@dimah-survey/db` (SQL store). HTTP adapters: Next.js App Router, Express, Hono, Fastify, Elysia, SvelteKit, and Node.

Use it when a SurveyJS app needs explicit publish and reproducible response history. Skip it for a visual form builder, hosted survey product, SurveyJS renderer, or dimah-form integration.

Install: `npm i @dimah-survey/server @dimah-survey/react survey-core survey-react-ui`. Add `@dimah-survey/db` for the SQL store. Published and still before `1.0.0`. A release may change the API.

- Auth stays in the consumer `guard`. Do not look for library auth.
- `draftJson` is the editor copy. `publishedJson` is what new responses clone. A later publish does not change `response.definition`.
- Submit validation runs on the stored response definition, not the live draft or the latest publish.
- Partial save replaces `survey.data`. It is not a key patch.
- Fill and editor are separate HTTP audiences over one shared store.
- Do not wrap the SurveyJS renderer, translate SurveyJS JSON into another field model, or import `@dimah-form/*`.

## Docs

- [Overview](https://survey.dimah.dev/docs.md): Understand the server-owned lifecycle around SurveyJS JSON.
- [Quickstart](https://survey.dimah.dev/docs/quickstart.md): Build a complete SurveyJS response flow in Next.js.
- [When to use](https://survey.dimah.dev/docs/comparison.md): Decide whether your SurveyJS application needs a server-owned response lifecycle.
- [Survey lifecycle](https://survey.dimah.dev/docs/surveys.md): Author a draft, publish explicitly, and preserve every response snapshot.
- [Collection settings](https://survey.dimah.dev/docs/settings.md): Control response reuse, reopening, collection windows, and capacity.
- [Response lifecycle](https://survey.dimah.dev/docs/responses.md): Start from a frozen definition, save drafts, and validate the same snapshot on submit.
- [Mount the server](https://survey.dimah.dev/docs/integration.md): Create isolated fill and editor handlers, then mount them in your runtime.
- [Persistence](https://survey.dimah.dev/docs/persistence.md): Use memory locally, connect the SQL store, or implement SurveyStore.
- [Authorization and identity](https://survey.dimah.dev/docs/security.md): Guard fill and editor independently, then establish response ownership on the server.
- [Fill with React](https://survey.dimah.dev/docs/react.md): Hydrate a SurveyJS Model from the response snapshot and bind server writes.
- [Survey Creator](https://survey.dimah.dev/docs/creator.md): Bind Creator autosave to the editor draft while keeping publish explicit.
- [Packages](https://survey.dimah.dev/docs/packages.md): Choose the protocol, server, React, and SQL layers your application needs.
- [Configuration](https://survey.dimah.dev/docs/configuration.md): Configure server audiences, browser clients, validation, hooks, and React bindings.
- [HTTP protocol](https://survey.dimah.dev/docs/protocol.md): Map fill and editor routes to browser clients and the in-process API.
- [Errors](https://survey.dimah.dev/docs/errors.md): Handle stable error codes, HTTP status mapping, and validation details.

## Packages

- [@dimah-survey/core](https://github.com/dimah-kz/dimah-survey/tree/main/packages/core): protocol, clients, schemas, errors, and store types
- [@dimah-survey/server](https://github.com/dimah-kz/dimah-survey/tree/main/packages/server): `dimahSurvey()`, guards, validation, adapters, and `memoryAdapter()`
- [@dimah-survey/react](https://github.com/dimah-kz/dimah-survey/tree/main/packages/react): SurveyJS Model and Creator bindings
- [@dimah-survey/db](https://github.com/dimah-kz/dimah-survey/tree/main/packages/db): SQL `SurveyStore`

## Optional

- [Full docs dump](https://survey.dimah.dev/llms-full.txt): every page as markdown
- [GitHub](https://github.com/dimah-kz/dimah-survey): source repository
- [X](https://x.com/dimahkzx): updates
