@spotto/contract 1.0.70-alpha.11 → 1.0.70-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
- import { FormItem, FormPrefillRow, FormWriteBackRow } from '../../shared';
1
+ import { FormItem, FormSettings } from '../../shared';
2
2
  /**
3
3
  * Publishes a new version of the form. `{id}` is the version document the
4
4
  * editor loaded — the server inserts exactly `that.version + 1` and returns
5
5
  * 409 when the head has moved ("form changed — reload"). Version documents
6
6
  * themselves are never mutated. Omitted fields carry over from the loaded
7
- * version; `name` is immutable.
7
+ * version; `name` is immutable. A present `settings` replaces the loaded
8
+ * version's wholesale — publish `{}` to clear it.
8
9
  */
9
10
  export interface UpdateFormRequest {
10
11
  label?: string;
11
12
  items?: FormItem[];
12
- prefill?: FormPrefillRow[];
13
- writeBack?: FormWriteBackRow[];
13
+ settings?: FormSettings;
14
14
  }
@@ -1,5 +1,5 @@
1
1
  import { IEntityMeta } from '../../shared';
2
- import { FormItem, FormPrefillRow, FormWriteBackRow } from '../shared';
2
+ import { FormItem, FormSettings } from '../shared';
3
3
  import { GetFormsQuery } from './query';
4
4
  /** One immutable form version document. */
5
5
  export interface GetFormResponse {
@@ -12,8 +12,7 @@ export interface GetFormResponse {
12
12
  current: boolean;
13
13
  archived: boolean;
14
14
  items: FormItem[];
15
- prefill: FormPrefillRow[];
16
- writeBack: FormWriteBackRow[];
15
+ settings?: FormSettings;
17
16
  createdBy: string;
18
17
  meta?: IEntityMeta;
19
18
  }
@@ -1,10 +1,9 @@
1
- import { FormItem, FormPrefillRow, FormWriteBackRow } from '../shared';
1
+ import { FormItem, FormSettings } from '../shared';
2
2
  /** Creates a new form as version 1 (current). */
3
3
  export interface PostFormRequest {
4
4
  /** Immutable handle; referenced by actions. */
5
5
  name: string;
6
6
  label: string;
7
7
  items: FormItem[];
8
- prefill?: FormPrefillRow[];
9
- writeBack?: FormWriteBackRow[];
8
+ settings?: FormSettings;
10
9
  }
@@ -21,12 +21,33 @@ export interface FormFieldItem {
21
21
  expression?: string;
22
22
  /** Required (and only allowed) when source is CONTEXT. */
23
23
  from?: ReservedContextFieldName;
24
- /** Must be present to submit — only bites while the item is visible. */
24
+ /** Must be present to submit — only bites while the item is active. */
25
25
  required?: boolean;
26
- /** Shown, not editable (e.g. filled by prefill purely for context). */
26
+ /** Shown, not editable (e.g. a read-in shown purely for context). */
27
27
  readonly?: boolean;
28
- /** Open-time expression seeding the initial value (prefill wins over it). */
28
+ /**
29
+ * Open-time expression seeding the initial value — the one read-in
30
+ * mechanism. Naming a target field reads it in, including the item's own
31
+ * name (the form value is still empty at open, so the target shows
32
+ * through). A CHECKBOXES item's default must be exactly a field name (a
33
+ * copy — expressions cannot produce a selection).
34
+ */
29
35
  default?: string;
36
+ /**
37
+ * Push the item's value to the same-named target field at submit — the
38
+ * captured value for INPUT, the derived value for COMPUTED. Only bites
39
+ * while the item is active (`visibleWhen`); written as ordinary authored
40
+ * data (user-editable afterward) and triggers the standard recompute.
41
+ */
42
+ writeBack?: boolean;
43
+ /**
44
+ * Never displayed; the item still participates fully — seeded, computed,
45
+ * required, written back. `visibleWhen`, if any, still gates activity
46
+ * (which is how a write-back is made conditional).
47
+ */
48
+ hidden?: boolean;
49
+ /** The activity gate: a failing item is not shown, not required, and not
50
+ * written back. */
30
51
  visibleWhen?: string;
31
52
  /** Per-form display overrides; identity still comes from the definition. */
32
53
  label?: string;
@@ -48,6 +69,27 @@ export interface FormImageItem {
48
69
  export interface FormDividerItem {
49
70
  kind: 'divider';
50
71
  }
72
+ /**
73
+ * A hyperlink content block — opens `href` (validated http(s)-only at save,
74
+ * so a stored href is always safe to render as an anchor).
75
+ */
76
+ export interface FormLinkItem {
77
+ kind: 'link';
78
+ href: string;
79
+ /** Display text; the href itself shows when omitted. */
80
+ label?: string;
81
+ }
82
+ /**
83
+ * An embedded YouTube video. The URL is stored as authored (watch, share,
84
+ * shorts or embed form — validated against the YouTube hosts at save) and
85
+ * the client derives the embed markup, so only allowlisted hosts ever reach
86
+ * an iframe.
87
+ */
88
+ export interface FormVideoItem {
89
+ kind: 'video';
90
+ url: string;
91
+ caption?: string;
92
+ }
51
93
  /**
52
94
  * A signature/photo capture block. Produces an attachment reference on the
53
95
  * submission (never a fieldValue), keyed by the block's `name`.
@@ -59,28 +101,27 @@ export interface FormCaptureItem {
59
101
  label?: string;
60
102
  help?: string;
61
103
  }
62
- export declare type FormItem = FormFieldItem | FormSectionItem | FormTextItem | FormImageItem | FormDividerItem | FormCaptureItem;
104
+ export declare type FormItem = FormFieldItem | FormSectionItem | FormTextItem | FormImageItem | FormDividerItem | FormLinkItem | FormVideoItem | FormCaptureItem;
63
105
  export declare type FormItemKind = FormItem['kind'];
64
106
  /**
65
- * A read-in row: on open, seed form field `to` from the target — either a
66
- * copy of target field `from` or an `expression` over the target's effective
67
- * values (exactly one of the two), optionally gated by `when`.
68
- */
69
- export interface FormPrefillRow {
70
- to: string;
71
- from?: string;
72
- expression?: string;
73
- when?: string;
74
- }
75
- /**
76
- * A write-back row: on submit, set target field `to` — either a copy of
77
- * captured form value `from` or an `expression` over the merged env (exactly
78
- * one of the two), optionally gated by `when`. Written as ordinary authored
79
- * data (user-editable afterward) and triggers the standard recompute.
107
+ * Runner presentation options how the form presents its chrome, not what
108
+ * it collects. Optional as a whole, and PATCH replaces it wholesale, so an
109
+ * option can be cleared by publishing without it.
80
110
  */
81
- export interface FormWriteBackRow {
82
- to: string;
83
- from?: string;
84
- expression?: string;
85
- when?: string;
111
+ export interface FormSettings {
112
+ /** Overrides the submit button text (e.g. "Confirm"). */
113
+ submitLabel?: string;
114
+ /** Show a cancel button that closes the form without submitting. */
115
+ showCancel?: boolean;
116
+ /** Cancel button text — only allowed alongside `showCancel`. */
117
+ cancelLabel?: string;
118
+ /**
119
+ * Content-only: completing the form records NOTHING (no submission, no
120
+ * event, no write-back) — the server rejects a submission against it.
121
+ * Save-time validation forbids `writeBack: true` items, capture blocks
122
+ * and required items. For a recorded acknowledgment, use a
123
+ * non-informational form with a signature block and a "Confirm"
124
+ * submitLabel instead.
125
+ */
126
+ informational?: boolean;
86
127
  }
@@ -33,13 +33,13 @@ export interface ISubmissionAttachment {
33
33
  * DATETIME as a Date, CHECKBOXES as the full option array.
34
34
  */
35
35
  export declare type SubmissionWriteBackValue = string | number | boolean | string[];
36
- /** One write-back row's outcome — applied with values, or skipped with why. */
36
+ /** One write-back item's outcome — applied with values, or skipped with why. */
37
37
  export interface ISubmissionWriteBackAudit {
38
38
  to: string;
39
39
  appliedValue?: SubmissionWriteBackValue;
40
40
  /** The asset-level value the write replaced; absent when the field had none. */
41
41
  previousValue?: SubmissionWriteBackValue;
42
- /** Present on expression rows — the formula that produced the value. */
42
+ /** Present on COMPUTED items — the formula that produced the value. */
43
43
  expression?: string;
44
44
  skipped?: true;
45
45
  reason?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spotto/contract",
3
3
  "license": "ISC",
4
- "version": "1.0.70-alpha.11",
4
+ "version": "1.0.70-alpha.13",
5
5
  "description": "Spotto's API Contract type definitions",
6
6
  "main": "./dist/index.js",
7
7
  "files": [
@@ -18,5 +18,5 @@
18
18
  "@types/geojson": "^7946.0.11",
19
19
  "shx": "^0.3.4"
20
20
  },
21
- "gitHead": "3bfd5e720157f73503fd29486b6111952e44de5a"
21
+ "gitHead": "ee164edbac29f51e60ef9c6046399a9e0ac4c316"
22
22
  }