@marktiderman/genesis-forms 0.8.0 → 0.9.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 +299 -10
- package/dist/destinations.cjs +202 -39
- package/dist/destinations.cjs.map +1 -1
- package/dist/destinations.d.cts +67 -21
- package/dist/destinations.d.ts +67 -21
- package/dist/destinations.js +202 -40
- package/dist/destinations.js.map +1 -1
- package/dist/{engine-Bj23YJlB.d.cts → engine-BaHPC2-1.d.cts} +2 -2
- package/dist/{engine-CzinTJph.d.ts → engine-Da99Tv-E.d.ts} +2 -2
- package/dist/index.cjs +996 -167
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +288 -11
- package/dist/index.d.ts +288 -11
- package/dist/index.js +975 -168
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +563 -173
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +3 -474
- package/dist/server.d.ts +3 -474
- package/dist/server.js +558 -174
- package/dist/server.js.map +1 -1
- package/dist/submit-protocol-CFi-0Qd0.d.ts +840 -0
- package/dist/submit-protocol-D0cOckmK.d.cts +840 -0
- package/dist/testing.cjs +250 -154
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +4 -4
- package/dist/testing.d.ts +4 -4
- package/dist/testing.js +250 -154
- package/dist/testing.js.map +1 -1
- package/dist/{types-jqDKcmP4.d.cts → types-C0pUfew3.d.cts} +7 -1
- package/dist/{types-jqDKcmP4.d.ts → types-C0pUfew3.d.ts} +7 -1
- package/dist/{validate-DvfQHYnu.d.ts → validate-DpmBssFk.d.ts} +258 -140
- package/dist/{validate-irIPubxc.d.cts → validate-U5LoW3eR.d.cts} +258 -140
- package/package.json +2 -2
- package/dist/upload-protocol-BOe018kL.d.cts +0 -122
- package/dist/upload-protocol-BUO74WkS.d.ts +0 -122
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { a as FieldBlock, J as Json } from './types-jqDKcmP4.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The `photo` field type: a respondent attaches up to a few photos, such as a
|
|
5
|
-
* picture of broken equipment. The answer holds references the host's storage
|
|
6
|
-
* handed back (`PhotoRef`), never the bytes: the renderer uploads through the
|
|
7
|
-
* host (`onUpload` on genesis-forms-web's `Form`), so the engine and the
|
|
8
|
-
* server stay storage-agnostic. A host's server should check that each
|
|
9
|
-
* reference is a file it stored for this respondent before saving.
|
|
10
|
-
*
|
|
11
|
-
* Opt-in in a builder palette (`UPLOAD_FIELD_TYPES`), since a host must be
|
|
12
|
-
* able to store the files.
|
|
13
|
-
*/
|
|
14
|
-
declare const PHOTO_TYPE = "photo";
|
|
15
|
-
/** Field types that need the host to store files; a builder offers them only when the host names them. */
|
|
16
|
-
declare const UPLOAD_FIELD_TYPES: readonly ["photo"];
|
|
17
|
-
/** One stored photo, as the host's upload returned it. */
|
|
18
|
-
type PhotoRef = {
|
|
19
|
-
/** The host's id for the stored file. */
|
|
20
|
-
id: string;
|
|
21
|
-
/** The file's name on the respondent's device. */
|
|
22
|
-
name: string;
|
|
23
|
-
/** Its MIME type, such as `image/jpeg`. */
|
|
24
|
-
type: string;
|
|
25
|
-
/** Bytes. */
|
|
26
|
-
size: number;
|
|
27
|
-
};
|
|
28
|
-
type PhotoFormat = "jpeg" | "png" | "heic" | "webp";
|
|
29
|
-
/** The MIME types each format covers. */
|
|
30
|
-
declare const PHOTO_FORMATS: Record<PhotoFormat, readonly string[]>;
|
|
31
|
-
declare const DEFAULT_PHOTO_FILES = 3;
|
|
32
|
-
declare const MAX_PHOTO_FILES = 5;
|
|
33
|
-
declare const DEFAULT_PHOTO_SIZE_MB = 10;
|
|
34
|
-
declare const MAX_PHOTO_SIZE_MB = 25;
|
|
35
|
-
/** The longest reference id and file name a photo answer may carry. */
|
|
36
|
-
declare const MAX_PHOTO_ID_LENGTH = 200;
|
|
37
|
-
declare const MAX_PHOTO_NAME_LENGTH = 255;
|
|
38
|
-
declare const isPhotoFormat: (v: unknown) => v is PhotoFormat;
|
|
39
|
-
interface PhotoLimits {
|
|
40
|
-
maxFiles: number;
|
|
41
|
-
maxSizeMb: number;
|
|
42
|
-
maxBytes: number;
|
|
43
|
-
formats: PhotoFormat[];
|
|
44
|
-
/** Every MIME type the formats cover. */
|
|
45
|
-
mimeTypes: string[];
|
|
46
|
-
}
|
|
47
|
-
/** A photo field's limits; a prop that is missing or out of range uses its default. */
|
|
48
|
-
declare function photoLimits(field: FieldBlock): PhotoLimits;
|
|
49
|
-
/** Whether `v` has a photo reference's shape (any type and size). */
|
|
50
|
-
declare function isPhotoRef(v: unknown): v is PhotoRef;
|
|
51
|
-
/** The well-formed references in a photo answer, as `{ id, name, type, size }` only. */
|
|
52
|
-
declare function photoRefs(value: Json | undefined): PhotoRef[];
|
|
53
|
-
/** "JPEG, PNG or WebP". */
|
|
54
|
-
declare function photoFormatList(formats: readonly PhotoFormat[]): string;
|
|
55
|
-
/** The message for a file of a type the field doesn't take. */
|
|
56
|
-
declare const photoTypeMessage: (field: FieldBlock) => string;
|
|
57
|
-
/** The message for a file over the field's size limit. */
|
|
58
|
-
declare const photoSizeMessage: (field: FieldBlock) => string;
|
|
59
|
-
/** The message for more photos than the field takes. */
|
|
60
|
-
declare const photoCountMessage: (field: FieldBlock) => string;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The upload handshake's JSON, shared by the server (`createUploadHandler` in
|
|
64
|
-
* `/server`) and the browser (genesis-forms-web's `signedUploadHost`). A
|
|
65
|
-
* respondent's browser asks the app's server for one signed upload per file,
|
|
66
|
-
* then sends the bytes straight to storage with it; the answer keeps only the
|
|
67
|
-
* reference the server handed back.
|
|
68
|
-
*
|
|
69
|
-
* Moved up from the host app's feedback photo uploads; the field names and
|
|
70
|
-
* status codes are the ones it used, so its browsers and server keep talking.
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* What the browser POSTs (`content-type: application/json`, at most
|
|
75
|
-
* `MAX_UPLOAD_REQUEST_BYTES`). Exactly one of `attemptId` (a new response: the
|
|
76
|
-
* visit's attempt id, a UUID) and `edit` (an edit link's token, while changing
|
|
77
|
-
* a sent response).
|
|
78
|
-
*/
|
|
79
|
-
interface UploadRequest {
|
|
80
|
-
/** The upload field's id. */
|
|
81
|
-
fieldId: string;
|
|
82
|
-
/** The file's name on the respondent's device. */
|
|
83
|
-
name: string;
|
|
84
|
-
/** Its MIME type. */
|
|
85
|
-
type: string;
|
|
86
|
-
/** Bytes. */
|
|
87
|
-
size: number;
|
|
88
|
-
attemptId?: string | undefined;
|
|
89
|
-
edit?: string | undefined;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Where the browser sends the bytes, as the app's storage signed it. Supabase
|
|
93
|
-
* Storage hands back `path` and `token` (with `bucket`, for
|
|
94
|
-
* `uploadToSignedUrl`); a store that signs a plain URL sets `url`, which
|
|
95
|
-
* `signedUploadHost` PUTs the file to when no `send` is given.
|
|
96
|
-
*/
|
|
97
|
-
interface SignedUpload {
|
|
98
|
-
path: string;
|
|
99
|
-
token: string;
|
|
100
|
-
bucket?: string | undefined;
|
|
101
|
-
url?: string | undefined;
|
|
102
|
-
}
|
|
103
|
-
/** 200: the reference the answer keeps, and where to send the bytes. */
|
|
104
|
-
interface UploadGrant {
|
|
105
|
-
ref: PhotoRef;
|
|
106
|
-
upload: SignedUpload;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Any other status: words to show the respondent, and for some a `code`:
|
|
110
|
-
* `closed` (409, an edit while the form takes no changes), `bad_link` (403, an
|
|
111
|
-
* edit link that doesn't check out) or `too_many_photos` (429, the attempt or
|
|
112
|
-
* edit has as many uploads as the store allows; the name the host app's
|
|
113
|
-
* browsers already know, kept for every upload field type).
|
|
114
|
-
*/
|
|
115
|
-
interface UploadRefusal {
|
|
116
|
-
error: string;
|
|
117
|
-
code?: string | undefined;
|
|
118
|
-
}
|
|
119
|
-
/** The longest upload request body: a few fields of JSON. */
|
|
120
|
-
declare const MAX_UPLOAD_REQUEST_BYTES = 4000;
|
|
121
|
-
|
|
122
|
-
export { DEFAULT_PHOTO_FILES as D, MAX_PHOTO_FILES as M, type PhotoFormat as P, type SignedUpload as S, UPLOAD_FIELD_TYPES as U, type PhotoRef as a, DEFAULT_PHOTO_SIZE_MB as b, MAX_PHOTO_ID_LENGTH as c, MAX_PHOTO_NAME_LENGTH as d, MAX_PHOTO_SIZE_MB as e, MAX_UPLOAD_REQUEST_BYTES as f, PHOTO_FORMATS as g, PHOTO_TYPE as h, type PhotoLimits as i, type UploadGrant as j, type UploadRefusal as k, type UploadRequest as l, isPhotoFormat as m, isPhotoRef as n, photoFormatList as o, photoCountMessage as p, photoLimits as q, photoRefs as r, photoSizeMessage as s, photoTypeMessage as t };
|