@marktiderman/genesis-forms 0.1.1 → 0.3.0
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.
- package/README.md +121 -17
- package/conformance/{after-class-back-after-a-jump.scenario.json → event-feedback-back-after-a-jump.scenario.json} +21 -21
- package/conformance/{after-class-contact-yes-completed.scenario.json → event-feedback-contact-yes-completed.scenario.json} +21 -21
- package/conformance/{after-class-contact-yes-requires-name-and-email.scenario.json → event-feedback-contact-yes-requires-name-and-email.scenario.json} +19 -19
- package/conformance/{after-class-happy-path.scenario.json → event-feedback-happy-path.scenario.json} +24 -24
- package/conformance/{after-class-invalid-email-rejected.scenario.json → event-feedback-invalid-email-rejected.scenario.json} +19 -19
- package/conformance/{after-class-low-rating-skips-went-well.scenario.json → event-feedback-low-rating-skips-went-well.scenario.json} +21 -21
- package/conformance/{after-class-server-drops-unknown-and-hidden-answers.scenario.json → event-feedback-server-drops-unknown-and-hidden-answers.scenario.json} +22 -22
- package/conformance/{after-class-server-ignores-a-client-sent-coach.scenario.json → event-feedback-server-ignores-a-client-sent-owner.scenario.json} +24 -24
- package/conformance/{monthly-pulse-default-ending.scenario.json → monthly-check-in-default-ending.scenario.json} +6 -6
- package/conformance/{monthly-pulse-promoter-ending-via-jump.scenario.json → monthly-check-in-promoter-ending-via-jump.scenario.json} +6 -6
- package/dist/destinations.cjs +1211 -0
- package/dist/destinations.cjs.map +1 -0
- package/dist/destinations.d.cts +465 -0
- package/dist/destinations.d.ts +465 -0
- package/dist/destinations.js +1169 -0
- package/dist/destinations.js.map +1 -0
- package/dist/{engine-LsPRTzt3.d.cts → engine-CPLtKVew.d.cts} +7 -6
- package/dist/{engine-Cp5t2_Am.d.ts → engine-DOrPgFDw.d.ts} +7 -6
- package/dist/index.cjs +410 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +122 -18
- package/dist/index.d.ts +122 -18
- package/dist/index.js +399 -25
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +350 -29
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +13 -12
- package/dist/server.d.ts +13 -12
- package/dist/server.js +350 -29
- package/dist/server.js.map +1 -1
- package/dist/testing.cjs +354 -29
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +4 -3
- package/dist/testing.d.ts +4 -3
- package/dist/testing.js +354 -29
- package/dist/testing.js.map +1 -1
- package/dist/{validate-j8Z188mF.d.cts → types-BBKBQ8sp.d.cts} +9 -29
- package/dist/{validate-j8Z188mF.d.ts → types-BBKBQ8sp.d.ts} +9 -29
- package/dist/validate-BXXqi0fq.d.cts +30 -0
- package/dist/validate-BjNwF1UE.d.ts +30 -0
- package/package.json +14 -2
|
@@ -57,6 +57,12 @@ interface HiddenInput {
|
|
|
57
57
|
source: "url" | "host" | "server";
|
|
58
58
|
/** Masked in devtools unless revealed, like a sensitive field. */
|
|
59
59
|
sensitive?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Identifies the respondent (a user id, an email). When the form's
|
|
62
|
+
* `settings.anonymous` is true, `validateSubmission` leaves it out of the
|
|
63
|
+
* stored `hidden` and `context`. Logic still reads it.
|
|
64
|
+
*/
|
|
65
|
+
identifying?: boolean;
|
|
60
66
|
}
|
|
61
67
|
type Operator = "eq" | "neq" | "lt" | "lte" | "gt" | "gte" | "in" | "contains" | "answered" | "empty";
|
|
62
68
|
type Operand = {
|
|
@@ -99,7 +105,8 @@ interface Ending {
|
|
|
99
105
|
interface FormSettings {
|
|
100
106
|
/**
|
|
101
107
|
* A per-form admin setting, off by default. When true, fields marked
|
|
102
|
-
* `identifying` are not asked or stored,
|
|
108
|
+
* `identifying` are not asked or stored, identifying hidden inputs are
|
|
109
|
+
* not stored, events carry no timestamps, and
|
|
103
110
|
* the app's store keeps no identifying metadata with responses.
|
|
104
111
|
*/
|
|
105
112
|
anonymous?: boolean;
|
|
@@ -145,31 +152,4 @@ type FormEvent = {
|
|
|
145
152
|
at?: number;
|
|
146
153
|
};
|
|
147
154
|
|
|
148
|
-
|
|
149
|
-
interface StandardSchemaV1<T = unknown> {
|
|
150
|
-
readonly "~standard": {
|
|
151
|
-
readonly version: 1;
|
|
152
|
-
readonly vendor: string;
|
|
153
|
-
readonly validate: (value: unknown) => {
|
|
154
|
-
value: T;
|
|
155
|
-
issues?: undefined;
|
|
156
|
-
} | {
|
|
157
|
-
issues: ReadonlyArray<{
|
|
158
|
-
message: string;
|
|
159
|
-
}>;
|
|
160
|
-
} | Promise<unknown>;
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
/** A custom check for one field: a function, or any Standard Schema (Zod, Valibot, ArkType…). */
|
|
164
|
-
type FieldValidator = ((value: Json) => string | null) | StandardSchemaV1;
|
|
165
|
-
declare const REQUIRED_MESSAGE = "This question needs an answer.";
|
|
166
|
-
/**
|
|
167
|
-
* Validate one field's value. `requireAnswers: false` (drafts) checks the
|
|
168
|
-
* format of what was answered without requiring the rest.
|
|
169
|
-
*/
|
|
170
|
-
declare function validateField(field: FieldBlock, value: Json | undefined, options?: {
|
|
171
|
-
requireAnswers?: boolean;
|
|
172
|
-
custom?: FieldValidator;
|
|
173
|
-
}): string | null;
|
|
174
|
-
|
|
175
|
-
export { type Block as B, type ContentBlock as C, type Ending as E, type FieldBlock as F, type HiddenInput as H, type Json as J, type LogicRule as L, type Operator as O, type PageBreakBlock as P, REQUIRED_MESSAGE as R, type StandardSchemaV1 as S, type FormDefinition as a, type FormLayout as b, type FormSettings as c, type Condition as d, type FieldValidator as e, type FormEvent as f, type Operand as g, validateField as v };
|
|
155
|
+
export type { Block as B, ContentBlock as C, Ending as E, FormDefinition as F, HiddenInput as H, Json as J, LogicRule as L, Operator as O, PageBreakBlock as P, FieldBlock as a, FormLayout as b, FormSettings as c, Condition as d, FormEvent as e, Operand as f };
|
|
@@ -57,6 +57,12 @@ interface HiddenInput {
|
|
|
57
57
|
source: "url" | "host" | "server";
|
|
58
58
|
/** Masked in devtools unless revealed, like a sensitive field. */
|
|
59
59
|
sensitive?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Identifies the respondent (a user id, an email). When the form's
|
|
62
|
+
* `settings.anonymous` is true, `validateSubmission` leaves it out of the
|
|
63
|
+
* stored `hidden` and `context`. Logic still reads it.
|
|
64
|
+
*/
|
|
65
|
+
identifying?: boolean;
|
|
60
66
|
}
|
|
61
67
|
type Operator = "eq" | "neq" | "lt" | "lte" | "gt" | "gte" | "in" | "contains" | "answered" | "empty";
|
|
62
68
|
type Operand = {
|
|
@@ -99,7 +105,8 @@ interface Ending {
|
|
|
99
105
|
interface FormSettings {
|
|
100
106
|
/**
|
|
101
107
|
* A per-form admin setting, off by default. When true, fields marked
|
|
102
|
-
* `identifying` are not asked or stored,
|
|
108
|
+
* `identifying` are not asked or stored, identifying hidden inputs are
|
|
109
|
+
* not stored, events carry no timestamps, and
|
|
103
110
|
* the app's store keeps no identifying metadata with responses.
|
|
104
111
|
*/
|
|
105
112
|
anonymous?: boolean;
|
|
@@ -145,31 +152,4 @@ type FormEvent = {
|
|
|
145
152
|
at?: number;
|
|
146
153
|
};
|
|
147
154
|
|
|
148
|
-
|
|
149
|
-
interface StandardSchemaV1<T = unknown> {
|
|
150
|
-
readonly "~standard": {
|
|
151
|
-
readonly version: 1;
|
|
152
|
-
readonly vendor: string;
|
|
153
|
-
readonly validate: (value: unknown) => {
|
|
154
|
-
value: T;
|
|
155
|
-
issues?: undefined;
|
|
156
|
-
} | {
|
|
157
|
-
issues: ReadonlyArray<{
|
|
158
|
-
message: string;
|
|
159
|
-
}>;
|
|
160
|
-
} | Promise<unknown>;
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
/** A custom check for one field: a function, or any Standard Schema (Zod, Valibot, ArkType…). */
|
|
164
|
-
type FieldValidator = ((value: Json) => string | null) | StandardSchemaV1;
|
|
165
|
-
declare const REQUIRED_MESSAGE = "This question needs an answer.";
|
|
166
|
-
/**
|
|
167
|
-
* Validate one field's value. `requireAnswers: false` (drafts) checks the
|
|
168
|
-
* format of what was answered without requiring the rest.
|
|
169
|
-
*/
|
|
170
|
-
declare function validateField(field: FieldBlock, value: Json | undefined, options?: {
|
|
171
|
-
requireAnswers?: boolean;
|
|
172
|
-
custom?: FieldValidator;
|
|
173
|
-
}): string | null;
|
|
174
|
-
|
|
175
|
-
export { type Block as B, type ContentBlock as C, type Ending as E, type FieldBlock as F, type HiddenInput as H, type Json as J, type LogicRule as L, type Operator as O, type PageBreakBlock as P, REQUIRED_MESSAGE as R, type StandardSchemaV1 as S, type FormDefinition as a, type FormLayout as b, type FormSettings as c, type Condition as d, type FieldValidator as e, type FormEvent as f, type Operand as g, validateField as v };
|
|
155
|
+
export type { Block as B, ContentBlock as C, Ending as E, FormDefinition as F, HiddenInput as H, Json as J, LogicRule as L, Operator as O, PageBreakBlock as P, FieldBlock as a, FormLayout as b, FormSettings as c, Condition as d, FormEvent as e, Operand as f };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { J as Json, a as FieldBlock } from './types-BBKBQ8sp.cjs';
|
|
2
|
+
|
|
3
|
+
/** The Standard Schema interface (standardschema.dev), as far as validation needs it. */
|
|
4
|
+
interface StandardSchemaV1<T = unknown> {
|
|
5
|
+
readonly "~standard": {
|
|
6
|
+
readonly version: 1;
|
|
7
|
+
readonly vendor: string;
|
|
8
|
+
readonly validate: (value: unknown) => {
|
|
9
|
+
value: T;
|
|
10
|
+
issues?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
issues: ReadonlyArray<{
|
|
13
|
+
message: string;
|
|
14
|
+
}>;
|
|
15
|
+
} | Promise<unknown>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** A custom check for one field: a function, or any Standard Schema (Zod, Valibot, ArkType…). */
|
|
19
|
+
type FieldValidator = ((value: Json) => string | null) | StandardSchemaV1;
|
|
20
|
+
declare const REQUIRED_MESSAGE = "This question needs an answer.";
|
|
21
|
+
/**
|
|
22
|
+
* Validate one field's value. `requireAnswers: false` (drafts) checks the
|
|
23
|
+
* format of what was answered without requiring the rest.
|
|
24
|
+
*/
|
|
25
|
+
declare function validateField(field: FieldBlock, value: Json | undefined, options?: {
|
|
26
|
+
requireAnswers?: boolean;
|
|
27
|
+
custom?: FieldValidator;
|
|
28
|
+
}): string | null;
|
|
29
|
+
|
|
30
|
+
export { type FieldValidator as F, REQUIRED_MESSAGE as R, type StandardSchemaV1 as S, validateField as v };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { J as Json, a as FieldBlock } from './types-BBKBQ8sp.js';
|
|
2
|
+
|
|
3
|
+
/** The Standard Schema interface (standardschema.dev), as far as validation needs it. */
|
|
4
|
+
interface StandardSchemaV1<T = unknown> {
|
|
5
|
+
readonly "~standard": {
|
|
6
|
+
readonly version: 1;
|
|
7
|
+
readonly vendor: string;
|
|
8
|
+
readonly validate: (value: unknown) => {
|
|
9
|
+
value: T;
|
|
10
|
+
issues?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
issues: ReadonlyArray<{
|
|
13
|
+
message: string;
|
|
14
|
+
}>;
|
|
15
|
+
} | Promise<unknown>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** A custom check for one field: a function, or any Standard Schema (Zod, Valibot, ArkType…). */
|
|
19
|
+
type FieldValidator = ((value: Json) => string | null) | StandardSchemaV1;
|
|
20
|
+
declare const REQUIRED_MESSAGE = "This question needs an answer.";
|
|
21
|
+
/**
|
|
22
|
+
* Validate one field's value. `requireAnswers: false` (drafts) checks the
|
|
23
|
+
* format of what was answered without requiring the rest.
|
|
24
|
+
*/
|
|
25
|
+
declare function validateField(field: FieldBlock, value: Json | undefined, options?: {
|
|
26
|
+
requireAnswers?: boolean;
|
|
27
|
+
custom?: FieldValidator;
|
|
28
|
+
}): string | null;
|
|
29
|
+
|
|
30
|
+
export { type FieldValidator as F, REQUIRED_MESSAGE as R, type StandardSchemaV1 as S, validateField as v };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marktiderman/genesis-forms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"./dist/server.js",
|
|
10
10
|
"./dist/server.cjs",
|
|
11
11
|
"./dist/testing.js",
|
|
12
|
-
"./dist/testing.cjs"
|
|
12
|
+
"./dist/testing.cjs",
|
|
13
|
+
"./dist/destinations.js",
|
|
14
|
+
"./dist/destinations.cjs"
|
|
13
15
|
],
|
|
14
16
|
"description": "Genesis Forms engine: a serializable form definition, logic, navigation, validation and server-side checking. Zero dependencies; runs in browsers, React Native, Node and edge runtimes. Part of the Genesis framework.",
|
|
15
17
|
"repository": {
|
|
@@ -47,6 +49,16 @@
|
|
|
47
49
|
"default": "./dist/server.cjs"
|
|
48
50
|
}
|
|
49
51
|
},
|
|
52
|
+
"./destinations": {
|
|
53
|
+
"import": {
|
|
54
|
+
"types": "./dist/destinations.d.ts",
|
|
55
|
+
"default": "./dist/destinations.js"
|
|
56
|
+
},
|
|
57
|
+
"require": {
|
|
58
|
+
"types": "./dist/destinations.d.cts",
|
|
59
|
+
"default": "./dist/destinations.cjs"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
50
62
|
"./testing": {
|
|
51
63
|
"import": {
|
|
52
64
|
"types": "./dist/testing.d.ts",
|