import { RequestBuilder } from "../request-builder"; import type { RequestOptions } from "../base-client"; import type { FormDeployment, FormGenerationJob, FormVersion, WorkspaceFormConfig } from "../_internal/types.gen"; export type { FormDeployment, FormGenerationJob, FormVersion, WorkspaceFormConfig, }; /** * Mirror of `GptCore.Tenancy.SealPolicy` embedded resource. Simple * fields use `"sealed" | "open"` atoms; per-field pinning uses * string arrays. * * KEEP IN SYNC with the duplicate definition in * `sdks/ts/packages/client/src/namespaces/forms.ts`. The admin SDK * intentionally does not depend on the client SDK, so this type is * maintained in two places. When `GptCore.Tenancy.SealPolicy` gains * a field, update both. */ export type SealPolicyShape = { prompt_template?: "sealed" | "open"; instructions?: "sealed" | "open"; default_instructions?: "sealed" | "open"; model_id?: "sealed" | "open"; temperature?: "sealed" | "open"; execution_mode?: "sealed" | "open"; output_schema_locked?: "sealed" | "open"; layout_locked?: "sealed" | "open"; logic_locked?: "sealed" | "open"; theme_locked?: "sealed" | "open"; output_schema?: "sealed" | "open"; layout_tree?: "sealed" | "open"; logic_rules?: "sealed" | "open"; theme_id?: "sealed" | "open"; theme_overrides?: "sealed" | "open"; custom_css?: "sealed" | "open"; assistant_agent_version_id?: "sealed" | "open"; access_mode?: "sealed" | "open"; allowed_origins?: "sealed" | "open"; min_submit_delay_ms?: "sealed" | "open"; disclose_logic_trace?: "sealed" | "open"; data_retention_days?: "sealed" | "open"; abandonment_threshold_days?: "sealed" | "open"; public_key_jwk?: "sealed" | "open"; output_schema_pins?: string[]; input_schema_pins?: string[]; tool_grant_pins?: string[]; }; /** * Attributes for creating a `FormDeployment` (admin SDK mirror of the * client SDK `CreateFormDeploymentAttributes`). */ export type CreateFormDeploymentAttributes = { form_id: string; application_id: string; tenant_id: string; pinned_version_id?: string | null; effective_version_id: string; is_application_default?: boolean; auto_deploy?: boolean; allow_tenant_clone?: boolean; overrides?: Record; seal_policy?: SealPolicyShape; }; export type UpdateFormDeploymentAttributes = { pinned_version_id?: string | null; is_application_default?: boolean; auto_deploy?: boolean; allow_tenant_clone?: boolean; overrides?: Record; seal_policy?: SealPolicyShape; }; export type CreateWorkspaceFormConfigAttributes = { workspace_id: string; form_deployment_id: string; overrides?: Record; schema_overrides?: Record; }; export type UpdateWorkspaceFormConfigAttributes = { overrides?: Record; schema_overrides?: Record; }; /** * One of the 8 fixed classes from `Compliance.FieldClassificationRegistry`. * Mirrors the client SDK's `ProtectionClass` type — kept inline because the * admin package doesn't depend on the client package. */ export type ProtectionClass = "public" | "pii" | "pii_sensitive" | "phi" | "pci_pan" | "pci_cvv" | "secret" | "custom"; /** * Input for `admin.forms.versions.classifyField`. * * Matches the resource's `:classify_field` action arguments: * - `fieldPath` (required) — the property name in output_schema.properties * - `protectionClass` (required) — one of the 8 ProtectionClass atoms * - `customLabel` (required if protectionClass === "custom"; otherwise optional) */ export interface ClassifyFieldInput { fieldPath: string; protectionClass: ProtectionClass; customLabel?: string; } /** * Attributes accepted when creating a form-generation job (admin). * * Matches the resource `accept` list on * `GptCore.Forms.Resources.FormGenerationJob` (`:create`): * `[:prompt, :application_id, :actor_user_id]`. */ export interface CreateFormGenerationJobInput { /** Natural-language description of the form to generate. */ prompt: string; /** Application UUID the job belongs to (drives tenant resolution). */ application_id: string; /** Optional User UUID for audit trail; omit for purely server-driven runs. */ actor_user_id?: string | null; } /** Filter + pagination args for `forms.generations.list`. */ export interface ListFormGenerationsArgs { /** Workspace UUID — required by the resource's tenant filter. */ workspace_id: string; /** Optional status filter; omit to return all jobs. */ status?: "pending" | "running" | "completed" | "failed"; /** Page size (JSON:API `page[limit]`). */ limit?: number; /** Page offset (JSON:API `page[offset]`). */ offset?: number; } /** * AI Form Generation (Slice 5). * * Creates a pending `FormGenerationJob`, enqueues the worker, and returns the * job row immediately. Poll `get` until `status` is `completed` or `failed`, * or subscribe to the `generation_completed` / `generation_failed` events on * the `forms:{workspace_id}` channel. */ export declare function createFormsNamespace(rb: RequestBuilder): { /** * AI form-generation job lifecycle: create, poll, list, cancel. */ generations: { /** * Kick off a new AI form generation. Returns a `:pending` job; the * worker transitions it through `:running` to `:completed` or `:failed`. * * @param input - Prompt, application_id, and optional actor_user_id. * @param options - Optional request options. * @returns The newly created `FormGenerationJob` (status `:pending`). * * @example * ```typescript * const job = await admin.forms.generations.create({ * prompt: "HIPAA-compliant patient intake form", * application_id: "", * }); * ``` */ create(input: CreateFormGenerationJobInput, options?: RequestOptions): Promise; /** * Fetch a single job by id. * * @param id - Job UUID. * @param options - Optional request options. * @returns The matching `FormGenerationJob`. */ get(id: string, options?: RequestOptions): Promise; /** * List jobs for a workspace; optionally filter by status. * * @param args - Workspace ID (required), optional status, limit, offset. * @param options - Optional request options. * @returns Array of `FormGenerationJob` rows ordered by `started_at` desc. * * @example * ```typescript * const jobs = await admin.forms.generations.list({ * workspace_id: "", * status: "completed", * limit: 50, * }); * ``` */ list(args: ListFormGenerationsArgs, options?: RequestOptions): Promise; /** * Cancel a pending or running job. * * **Idempotent when the job is already terminal at call time** — * cancelling a job whose loaded status is `:completed` or `:failed` * returns the row unchanged. * * **Concurrent-transition note:** if the worker transitions the job * to a terminal state between the server-side load and the SQL * UPDATE, the server returns a stale-record 4xx. Re-fetch the job * via `get` to observe the actual terminal state — the worker's * outcome is preserved. * * Routed as `PATCH /form-generations/:id/cancel` (the resource exposes * a `:cancel` update action; DELETE was avoided because AshJsonApi * does not support DELETE bodies for state-transitions). * * @param id - Job UUID. * @param options - Optional request options. * @returns The updated `FormGenerationJob` row. * * @example * ```typescript * const job = await admin.forms.generations.cancel(jobId); * ``` */ cancel(id: string, options?: RequestOptions): Promise; }; /** * Form version administrative operations. */ versions: { /** * Set the protection class for a single field on a form version. * * Mutates `output_schema.properties[fieldPath]["x-protection-class"]` * in place (does NOT create a new version row). Broadcasts a * `forms.version.published` event with `classification_deltas`. * * Authorization: `sk_sys_` keys (platform admin) OR `sk_srv_`/`sk_app_` * keys carrying the `forms:admin` scope. * * @param formVersionId - UUID of the form version to mutate. * @param input - Field path, target class, and (for `custom`) custom label. * @param options - Optional request options. * @returns The updated `FormVersion` row. * * @example * ```typescript * await admin.forms.versions.classifyField("ver-uuid", { * fieldPath: "patient.ssn", * protectionClass: "pii_sensitive", * }); * ``` */ classifyField(formVersionId: string, input: ClassifyFieldInput, options?: RequestOptions): Promise; }; /** * Form deployment governance — application-scoped deployments binding * a Form to an Application with version pinning, typed seal policy, * and update-tracking lifecycle. Capability-gated by * `:forms_deployment_governance` (premium tier). */ deployments: { /** * List all FormDeployments visible to the actor's application context. * * @param options - Optional request options. * @returns Promise resolving to an array of `FormDeployment` records. */ list(options?: RequestOptions): Promise; /** * Fetch a single FormDeployment by id. * * @param id - UUID of the FormDeployment. * @param options - Optional request options. * @returns Promise resolving to the requested `FormDeployment`. */ get(id: string, options?: RequestOptions): Promise; /** * Create a FormDeployment binding a Form to an Application. Tracking * mode (no `pinned_version_id`) follows the form's active version; * pinned mode freezes a specific version until the ISV calls * `acceptUpdate` after a tracking-worker notification. * * @param attributes - Typed create attributes including `form_id`, * `application_id`, `tenant_id`, optional `pinned_version_id`, * `effective_version_id`, `seal_policy`, and lifecycle flags. * @param options - Optional request options. * @returns Promise resolving to the created `FormDeployment`. * * @example * const deployment = await admin.forms.deployments.create({ * form_id, application_id, tenant_id, * effective_version_id: version.id, * seal_policy: { custom_css: "sealed", output_schema_pins: ["fld_protected"] }, * }); */ create(attributes: CreateFormDeploymentAttributes, options?: RequestOptions): Promise; /** * Update an existing FormDeployment. `effective_version_id`, * `application_id`, `tenant_id`, and `form_id` are immutable — * use `create` to bind a new deployment. * * @param id - UUID of the FormDeployment to update. * @param attributes - Patch attributes. Pass only the fields to change. * @param options - Optional request options. * @returns Promise resolving to the updated `FormDeployment`. * * @example * await admin.forms.deployments.update(deployment.id, { * auto_deploy: true, * seal_policy: { ...existing, theme_id: "sealed" }, * }); */ update(id: string, attributes: UpdateFormDeploymentAttributes, options?: RequestOptions): Promise; /** * Promote `available_version_id` to `effective_version_id` after the * `FormVersionTrackingWorker` has notified this deployment of a new * version. Resets `update_available` to false. Errors when no update * is pending. * * @param id - UUID of the FormDeployment. * @param options - Optional request options. * @returns Promise resolving to the deployment with promoted version. * * @example * await admin.forms.deployments.acceptUpdate(deployment.id); */ acceptUpdate(id: string, options?: RequestOptions): Promise; /** * Delete a FormDeployment. Capability-gated — emits * `[:gpt_core, :forms, :deployment_governance, :rejected]` telemetry * if the owning Application lacks `:forms_deployment_governance`. * * @param id - UUID of the FormDeployment to delete. * @param options - Optional request options. * @returns Promise resolving to `true` on success. * * @example * await admin.forms.deployments.destroy(deployment.id); */ destroy(id: string, options?: RequestOptions): Promise; }; /** * Workspace form configs — workspace-level overrides applied on top * of a parent `FormDeployment`, gated by the deployment's seal policy. */ workspaceConfigs: { /** * List all WorkspaceFormConfigs visible to the actor's tenant context. * * @param options - Optional request options. * @returns Promise resolving to an array of `WorkspaceFormConfig` records. */ list(options?: RequestOptions): Promise; /** * Fetch a single WorkspaceFormConfig by id. * * @param id - UUID of the WorkspaceFormConfig. * @param options - Optional request options. * @returns Promise resolving to the requested `WorkspaceFormConfig`. */ get(id: string, options?: RequestOptions): Promise; /** * Create a workspace-level override for a parent FormDeployment. * `overrides` apply to simple fields gated by `seal_policy.`; * `schema_overrides` apply to output_schema/input_schema add/remove/ * label gated by `seal_policy.*_pins`. * * @param attributes - Typed create attributes including * `workspace_id`, `form_deployment_id`, and optional `overrides` / * `schema_overrides` maps. * @param options - Optional request options. * @returns Promise resolving to the created `WorkspaceFormConfig`. * * @example * await admin.forms.workspaceConfigs.create({ * workspace_id: ws.id, * form_deployment_id: deployment.id, * overrides: { custom_css: ".x { color: blue; }" }, * }); */ create(attributes: CreateWorkspaceFormConfigAttributes, options?: RequestOptions): Promise; /** * Update an existing WorkspaceFormConfig. `workspace_id` and * `form_deployment_id` are immutable. * * @param id - UUID of the WorkspaceFormConfig to update. * @param attributes - Patch attributes. Pass only the fields to change. * @param options - Optional request options. * @returns Promise resolving to the updated `WorkspaceFormConfig`. * * @example * await admin.forms.workspaceConfigs.update(config.id, { * overrides: { ...config.overrides, custom_css: ".x { color: green; }" }, * }); */ update(id: string, attributes: UpdateWorkspaceFormConfigAttributes, options?: RequestOptions): Promise; /** * Delete a WorkspaceFormConfig. Capability-gated by * `:forms_deployment_governance`. * * @param id - UUID of the WorkspaceFormConfig to delete. * @param options - Optional request options. * @returns Promise resolving to `true` on success. * * @example * await admin.forms.workspaceConfigs.destroy(config.id); */ destroy(id: string, options?: RequestOptions): Promise; }; }; //# sourceMappingURL=forms.d.ts.map