dimah-survey
Lifecycle

Collection settings

Control response reuse, reopening, collection windows, and capacity.

settings is the server-owned collection policy for one survey. It decides whether an identified respondent reuses a response, whether closed responses can reopen, when writes are accepted, and how many submissions are allowed.

Settings are not SurveyJS JSON and are never copied into response.definition. saveSurveySettings replaces the complete object.

Fields

import type { SurveySettings } from "@dimah-survey/core";

Prop

Type

saveSurvey inserts these defaults and then leaves the column alone. saveSurveySettings replaces the whole object. Send every field. closesAt must be later than opensAt when both are set. maxResponses is a positive integer or null.

Dates are ISO strings. If legacy storage contains an invalid settings object, the reader falls back to defaults rather than exposing malformed policy.

Reuse identified responses

For an identified principal, startResponse applies responses inside the store write:

PolicyResult
"one-open"Return the existing draft; otherwise create a new response
"single"Return the latest response of any status; create only when none exists

Anonymous starts always create a new response. Their response id is the capability; they cannot list responses. See Security.

"single" can return a submitted or abandoned row. The fill Model opens in display mode unless you reopen it. See React.

Enforce the window and cap

opensAt and closesAt are inclusive. Outside that window, start, partial save, and submit throw SURVEY_CLOSED. Abandon, get, and reopen stay available. GET /survey/published still returns the document, so the client can show that the survey is closed.

maxResponses counts rows already stored as submitted. The check runs before a new insert and before submit, inside the store lock. At the cap, both fail with RESPONSE_LIMIT. Returning an existing identified row does not consume capacity.

Reopen a response

reopen: true lets reopenResponse move a submitted or abandoned row back to draft. It clears submittedAt and does not change definition or data.

When reopening would create a second draft for the same survey and identified respondent, the write fails with OPEN_DRAFT. reopen: false instead fails with RESPONSE_CLOSED.

On this page