@raytio/types 5.2.0 → 6.0.1

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/src/schema.ts CHANGED
@@ -23,12 +23,18 @@ export type SchemaFieldTag =
23
23
  | "display:survey"
24
24
  | "display:quoting"
25
25
  | "display:customModal"
26
+ | "display:terms_conditions"
26
27
  | "display:showOnWizard" // added by #837, TODO: document
27
28
  | `display:main_media:${string}` // property name to determine what image to display
29
+ // date picker components
30
+ | "date_component:day"
31
+ | "date_component:month"
32
+ | "date_component:year"
28
33
  // other
29
34
  | "action:client_upload"
30
35
  | "verify:show_if_pending"
31
36
  | "special:hide_select_behind_button"
37
+ | "type:capture_geolocation" // triggers the wizard's GeoLocationInput field
32
38
  | "type:extract_required";
33
39
 
34
40
  export type SchemaTag =
@@ -38,6 +44,11 @@ export type SchemaTag =
38
44
  // camera
39
45
  | "default_camera:rear"
40
46
  | "default_camera:front"
47
+ // oauth group rule
48
+ | `oauth2_component:name:${string}`
49
+ | `oauth2_component:redirect_url:${string}`
50
+ // misc
51
+ | `link_to:${/* schemaName */ string}:${/* relationshipType */ string}`
41
52
  // type
42
53
  | "type:service_provider"
43
54
  | "type:service_offer"
@@ -49,21 +60,21 @@ export type SchemaField = {
49
60
  /** @deprecated don't use, it's inconsistent */
50
61
  $id?: string;
51
62
  title?: string;
63
+ title_plural?: string;
52
64
  description?: string;
53
65
  /** readOnly means the Wizard won't show this field */
54
66
  readOnly?: boolean;
55
67
  examples?: unknown[];
56
68
  tags?: SchemaFieldTag[];
57
69
  type?: DataTypes;
58
- enum?: unknown[];
70
+ enum?: string[];
59
71
  maximum?: number;
60
72
  minimum?: number;
61
73
  /** @deprecated raytio's usage not documented */
62
74
  maxLength?: number;
63
75
  /** @deprecated raytio's usage not documented */
64
76
  minLength?: number;
65
- /** @internal added by the client. It's the default value based on the existing values from subschema on their profile */
66
- defaultValue?: unknown;
77
+ /** the default value */
67
78
  default?: unknown;
68
79
  pattern?: string;
69
80
  /** whether the field should be encrypted */
@@ -71,13 +82,17 @@ export type SchemaField = {
71
82
  format?: "date" | "date-time";
72
83
  contentMediaType?: string;
73
84
  contentEncoding?: "base64";
74
- /** for nested JSON */
85
+ /** `items` is used for nested arrays, (while `properties` is used for nested objects) */
75
86
  items?: {
76
87
  type: DataTypes;
77
88
  properties: {
78
89
  [subFieldName: string]: SchemaField;
79
90
  };
80
91
  };
92
+ /** `properties` is used for nested objects, (while `items` is used for nested arrays) */
93
+ properties?: {
94
+ [subFieldName: string]: SchemaField;
95
+ };
81
96
 
82
97
  /** If this field refers to a sub-object */
83
98
  $ref?: string;
@@ -99,10 +114,10 @@ export type SchemaField = {
99
114
  /** URL to a JSON file in the `Lookup` format */
100
115
  lookup?: string;
101
116
  /** @internal the client adds this - it's the fieldName. */
102
- $prop?: string;
117
+ $prop: string;
103
118
  priority?: number;
104
119
  /** @internal if supplied, it's the existing field values. Added by the client */
105
- subObjectRef?: (string | number)[]; //
120
+ subObjectRef?: unknown[];
106
121
  /** specifies that the description is formatted in markdown */
107
122
  description_decorator?: "md";
108
123
  /** if a `pattern` is specified, this is the error message */
@@ -119,6 +134,8 @@ export type SchemaField = {
119
134
  };
120
135
  /** if this field is a table input, this determines the text to show on the "Add Row" btn */
121
136
  add_row_btn_label?: string;
137
+ /** if this field is a table input, this determines the text to show if the table is empty */
138
+ table_empty_message?: string;
122
139
 
123
140
  /**
124
141
  * used on fields that are a signature file picker, see !849
@@ -144,9 +161,13 @@ export type Schema = {
144
161
  $schema?: string;
145
162
  n_id?: NId;
146
163
 
147
- /** name will always exist on schema */
164
+ /** these fields will always exist on schema */
148
165
  name: string;
166
+ title: string;
167
+ description: string;
149
168
 
169
+ /** plural version of the title */
170
+ title_plural?: string;
150
171
  /**
151
172
  * the group that a schema belongs to, such as "passports". This is useful for
152
173
  * forms that accept different types of similar documents.
@@ -155,12 +176,13 @@ export type Schema = {
155
176
  /** the localized title of the `schema_group`. added by the client */
156
177
  group_title?: string;
157
178
 
158
- title?: string;
159
- description?: string;
160
-
161
179
  /** @deprecated not sure why a schema would have this, only fields should */
162
180
  $ref?: string;
163
181
 
182
+ version?: string;
183
+ /** whether the `version` is the latest version */
184
+ version_current?: boolean;
185
+
164
186
  tags?: SchemaTag[];
165
187
  /** originally `string[]`, the client modifies this */
166
188
  verified_fields?: (string | ConditionallyRequired)[];
@@ -178,13 +200,11 @@ export type Schema = {
178
200
  then?: Schema;
179
201
  }[];
180
202
 
181
- /**
182
- * this is deliberately an optional prop, there are cases where properties are
183
- * undefined, e.g.
184
- * - from get-all-schema API
185
- * - if the schema is a sub-object
186
- */
187
- properties?: {
203
+ /** If this tag exists, the schema is deprecated. ISO Date. */
204
+ end_date?: string;
205
+
206
+ /** 🚨 Note that there are cases where properties are undefined, e.g. if the schema is a sub-object */
207
+ properties: {
188
208
  [fieldName: string]: SchemaField;
189
209
  };
190
210
 
@@ -194,6 +214,7 @@ export type Schema = {
194
214
  // @ts-expect-error I don't understand what's wrong
195
215
  $schema: Schema;
196
216
  // not that for entries that start in "group:" or $loading_, only the title field will be used.
217
+ // ^ the exception is `group:{GROUP_NAME}:{SUB_GROUP}.field` which is used for the combined field title/desc
197
218
  // normal fields can specify any field attributes to override.
198
219
 
199
220
  // see !1796 for where these are used
@@ -208,7 +229,9 @@ export type Schema = {
208
229
  $loading_delete_pending_ver: { title: string };
209
230
  $loading_pending_ver_resubmit: { title: string };
210
231
 
211
- [fieldNameOrGroupName: string]: SchemaField & { title_plural?: string };
232
+ [fieldNameOrGroupName: string]: Omit<SchemaField, "$prop"> & {
233
+ title_plural?: string;
234
+ };
212
235
  };
213
236
  };
214
237
  /** @internal the client adds this after processing the i18n property */
@@ -308,3 +331,34 @@ export type Schema = {
308
331
  return_to?: string;
309
332
  };
310
333
  };
334
+
335
+ /** Only certain properties from the schema */
336
+ export type SchemaMetadata = Pick<
337
+ Schema,
338
+ // if you update this list, also update SCHEMA_METADATA_FIELDS
339
+ | "name"
340
+ | "title"
341
+ | "description"
342
+ | "schema_group"
343
+ | "end_date"
344
+ | "i18n"
345
+ | "display"
346
+ | "tags"
347
+ // added by the client
348
+ | "clientLocale"
349
+ | "groupNames"
350
+ | "title_plural"
351
+ | "group_title"
352
+ > & {
353
+ /**
354
+ * @deprecated this prop exists so that SchemaMetadata does not extend Schema.
355
+ * use `getSchema(schemaName)` to fetch the full schema
356
+ */
357
+ __typeof__: "You cannot supply SchemaMetadata to a function that expects Schema";
358
+
359
+ isProfileSchema: boolean;
360
+ isSpSchema: boolean;
361
+ };
362
+
363
+ /** @ignore */
364
+ export type RelationDefinition = NonNullable<Schema["relationships"]>[number];
package/src/theme.ts CHANGED
@@ -24,3 +24,5 @@ export type Colors = {
24
24
  blankBackground: string;
25
25
  blank: string;
26
26
  };
27
+
28
+ export type CustomFonts = { header?: string; body?: string };
@@ -1,5 +1,34 @@
1
1
  import { NId, ProfileObject } from "./raytio";
2
2
 
3
+ export type VerificationPayload<WithValue extends boolean> = {
4
+ // we deliberately haven't defined 'sub'
5
+ field: string;
6
+ schema?: string;
7
+ metadata?: Record<string, unknown>;
8
+ passed: boolean;
9
+ request_div: string;
10
+ /** @deprecated don't use this, it looks like the schema name but it's not */
11
+ source: string;
12
+ /** the n_id of the parent profile object that this ver belongs (NOT the n_id of the field) */
13
+ source_n_id?: NId;
14
+ /** like `source_n_id` */
15
+ source_hashed_n_id?: NId;
16
+ type?: null;
17
+ v_id: string;
18
+ verification_date: string;
19
+ verifier_id?: NId;
20
+ verifier_source_id?: NId;
21
+ verifier_service_id?: NId;
22
+ verifier_div: string;
23
+ /** ISO Date */
24
+ valid_until?: string;
25
+ // we are disabling the eslint rule beacuse even tho `{}` acts illogically in typescript,
26
+ // in this case it's working as expected in the intersection type, see
27
+ // https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-632833366
28
+ // and https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-645510515
29
+ // eslint-disable-next-line @typescript-eslint/ban-types
30
+ } & (WithValue extends true ? { value: string | number } : {});
31
+
3
32
  /**
4
33
  * Different APIs inconsistently include the `value` prop. If you know it exists,
5
34
  * use `Verification<true>`, otherwise just `Verification`. Verifications from
@@ -17,27 +46,7 @@ export type Verification<WithValue extends boolean = false> = ProfileObject<{
17
46
  verifications: [
18
47
  {
19
48
  signature: string;
20
- data: {
21
- field: string;
22
- metadata?: Record<string, unknown>;
23
- passed: boolean;
24
- request_div: string;
25
- /** @deprecated don't use this, it looks like the schema name but it's not */
26
- source: string;
27
- /** the n_id of the parent profile object that this ver belongs (NOT the n_id of the field) */
28
- source_n_id: NId;
29
- v_id: string;
30
- verification_date: string;
31
- verifier_id?: NId;
32
- verifier_source_id?: NId;
33
- verifier_service_id?: NId;
34
- verifier_div: string;
35
- // we are disabling the eslint rule beacuse even tho `{}` acts illogically in typescript,
36
- // in this case it's working as expected in the intersection type, see
37
- // https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-632833366
38
- // and https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-645510515
39
- // eslint-disable-next-line @typescript-eslint/ban-types
40
- } & (WithValue extends true ? { value: string | number } : {});
49
+ data: VerificationPayload<WithValue>;
41
50
  },
42
51
  ];
43
52
  }>;
@@ -46,6 +55,8 @@ export type Verification<WithValue extends boolean = false> = ProfileObject<{
46
55
  * "Not Verified" means show no badge, cf. "Verified False" means the
47
56
  * verifier revealed that the data was wrong. So show a ❌
48
57
  */
58
+ // We cannot change the enum values, since ScoreRules have been generated
59
+ // with the enum values hardcoded. The enum value are also used to find the "best" or "worst" verification (lower=better)
49
60
  export enum FieldVerification {
50
61
  Verified = 60_001,
51
62
  NotVerified,
@@ -53,6 +64,8 @@ export enum FieldVerification {
53
64
  Expired,
54
65
  }
55
66
 
67
+ // We cannot change the enum values, since ScoreRules have been generated
68
+ // with the enum values hardcoded.
56
69
  export enum POVerification {
57
70
  FullyVerified = 70_001,
58
71
  PartiallyVerified,
@@ -69,13 +82,13 @@ export type VerificationProvider = {
69
82
  dataSourceNId?: NId;
70
83
  serviceProviderNId?: NId;
71
84
  /** the date which the verification was verified on, or last re-verified on */
72
- date: Date;
85
+ date?: Date;
73
86
  };
74
87
 
75
88
  /** This is what @raytio/core exposes, which is more useable than @see Verification */
76
89
  export type RealVer = {
77
90
  fieldName: string;
78
- value: string | number;
91
+ value: unknown;
79
92
  provider: VerificationProvider;
80
93
  signature: string;
81
94
  /**
package/src/wizard.ts CHANGED
@@ -1,13 +1,18 @@
1
1
  import { AId } from "./raytio";
2
2
 
3
3
  /** configuration data for a single wizard page (@see WizardConfig) */
4
- export interface WizardPage {
4
+ export type WizardPage = {
5
5
  /** if undefined, the schema title will be used */
6
6
  name?: string | symbol;
7
7
  filter: "oneOf" | "anyOf";
8
8
  schemas: string[];
9
9
 
10
+ /** the fallback description, if there isn't one for the specific situation */
10
11
  description?: string;
12
+ description_select?: string;
13
+ description_create?: string;
14
+ description_update?: string;
15
+
11
16
  /** if explictly == false, then it's an AO (not a PO), in which case there can only be one schema */
12
17
  profile?: boolean;
13
18
  /** if true this page can be skipped. The PageResult wil be undefined */
@@ -52,16 +57,22 @@ export interface WizardPage {
52
57
  | "review" // continue to review page
53
58
  | "next_step"; // continue & skip the review page
54
59
 
60
+ /** for ImageDynamicSection, the action to take if the API returns no `validation: {}` object */
61
+ extract_threshold_null_action?: WizardPage["extract_threshold_fail_action"];
62
+
55
63
  /** if `false`, ProfileObjects created while completing the form will not be verified. `undefined` implies `true` */
56
- verify?: boolean;
64
+ verify_data?: boolean;
57
65
 
58
66
  /** a list of fields that should not be required, even if the schema says they're required */
59
67
  optional_fields?: string[];
60
68
 
61
- /** the infomation to share. undefined implies both. */
69
+ /** the information to share. undefined implies both. */
62
70
  // TODO: 'profile' is not supported yet
63
71
  share?: "profile" | "verification" | "both";
64
- }
72
+
73
+ /** can you force the colour theme to change for just one page (#1066, #1074). At the moment this on pages that use WebcamImageCapture */
74
+ display_mode?: "light" | "dark" | "default";
75
+ };
65
76
 
66
77
  /**
67
78
  * when a form link is generated, this is what gets saved on the API.
@@ -104,7 +115,7 @@ export type WizardConfig = {
104
115
  emails?: string[];
105
116
 
106
117
  /**
107
- * whether the "quick onboard" process should be used if the user visits
118
+ * whether the passwordless-signup process should be used if the user visits
108
119
  * this form, and they are not logged in. If false, the standard sign-up
109
120
  * process will be used
110
121
  */