@raytio/types 6.0.2 → 7.1.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/src/raytio.ts CHANGED
@@ -7,22 +7,26 @@ export type StringWithIdentity<T> = string & { $$typeof$$: T };
7
7
  /** @internal */
8
8
  type Json = Record<string, any>; // TODO: (semver breaking) unknown
9
9
 
10
- /** A `p_id` is the ID of a @see Relationship */
10
+ /** A `p_id` is the ID of a {@link Relationship} */
11
11
  export type PId = StringWithIdentity<"PId">;
12
- /** An `i_id` is the ID of an @see Instance */
12
+ /** An `i_id` is the ID of an {@link Instance} */
13
13
  export type IId = StringWithIdentity<"IId">;
14
- /** An `n_id` is the ID of a @see ProfileObject */
14
+ /** An `n_id` is the ID of a {@link ProfileObject} */
15
15
  export type NId = StringWithIdentity<"NId">;
16
16
  /** A `g_id` is the ID of a group */
17
17
  export type GId = StringWithIdentity<"GId">;
18
18
  /** A `u_id` is the ID of a user */
19
19
  export type UId = StringWithIdentity<"UId">;
20
- /** An `a_id` is the ID of an @see AA */
20
+ /** An `a_id` is the ID of an {@link AA} */
21
21
  export type AId = StringWithIdentity<"AId">;
22
- /** An `o_id` is the ID of an @see Organization */
22
+ /** An `o_id` is the ID of an {@link Organization} */
23
23
  export type OId = StringWithIdentity<"OId">;
24
- /** A `wi_id` is the ID of a @see Webhook */
24
+ /** A `wi_id` is the ID of a {@link Webhook} */
25
25
  export type WId = StringWithIdentity<"WId">;
26
+ /** An `l_id` is the ID of any data stored in the KV-Store */ // e.g. StoredWizardConfig and VerBundleMetadata
27
+ export type LId = StringWithIdentity<"LId">;
28
+
29
+ export type AnyId = PId | IId | NId | GId | UId | AId | OId | WId;
26
30
 
27
31
  export type DataTypes =
28
32
  | "string"
@@ -74,24 +78,25 @@ export type ProfileObjectForUpload<Properties = Json> = {
74
78
 
75
79
  /**
76
80
  * arbitrary key-values pairs stored on a Profile Object.
77
- * May contain nested JSON and @see Encrypted properties.
81
+ * May contain nested JSON and {@link Encrypted} properties.
78
82
  *
79
83
  * There are some limits to field names: they cannot be called
80
84
  * `__signature` nor can they include the character sequence `<=>`.
85
+ *
86
+ * @deprecated - use {@link Json}
81
87
  */
82
- export type Properties = {
83
- [fieldName: string]: any; // TODO: (semver breaking) unknown
84
- };
88
+ export type Properties = Json;
85
89
 
86
90
  export type UrnNodeType =
87
91
  | "user"
88
92
  | "profile_object"
89
93
  | "instance"
94
+ | "schema"
90
95
  | "temp_object" // this will only be encountered in backend environments which lack access to an applicationDecryptor, or from RapidShare
91
96
  | "document";
92
97
 
93
98
  /** e.g. "urn:user:..." */
94
- export type Urn = `urn:${UrnNodeType}:${string}`; // TODO: TS4.3 replace `string` with `IId | NId | GId | UId | AId`
99
+ export type Urn = `urn:${UrnNodeType}:${AnyId}`;
95
100
 
96
101
  export type Relationship = {
97
102
  start: Urn;
@@ -117,6 +122,13 @@ export type Lookup = {
117
122
  requires_2FA?: boolean;
118
123
  };
119
124
 
125
+ export type AATag =
126
+ | "type:client_only"
127
+ | "type:share_with_new_user"
128
+ // heritage
129
+ | `related_service_provider:n_id:${NId}`
130
+ | "ServiceProvider"; // TODO: document or delete
131
+
120
132
  export type AA = {
121
133
  a_id: AId;
122
134
  name: string;
@@ -127,7 +139,7 @@ export type AA = {
127
139
  /** Easy to use AA logo url for pasting inot emails */
128
140
  picture_url?: string;
129
141
  scopes?: string[];
130
- tags?: string[];
142
+ tags?: AATag[];
131
143
  callback_uri?: string[];
132
144
  /** markdown or string help information including [phoneNumber || email] */
133
145
  aa_help?: string;
@@ -137,7 +149,7 @@ export type AA = {
137
149
  };
138
150
  /** the n_id of the associated service provider */
139
151
  service_provider_n_id?: NId;
140
- /** the id of the associated organisation */
152
+ /** the id of the associated organization */
141
153
  org_id: OId;
142
154
 
143
155
  /** configuration for the submission rules */
@@ -148,7 +160,7 @@ export type AA = {
148
160
  auth_list_enabled?: boolean;
149
161
 
150
162
  /** @internal */
151
- _transitions?: unknown[];
163
+ transitions?: unknown[];
152
164
  };
153
165
 
154
166
  export type Instance = {
@@ -171,7 +183,7 @@ export type Instance = {
171
183
  start_date: string;
172
184
  /** The status of a submission */
173
185
  state: SubmissionStatus;
174
- /** @depreacted The status of a submission */
186
+ /** @deprecated The status of a submission */
175
187
  _state?: SubmissionStatus;
176
188
  /** Previous status of the shared information */
177
189
  previous_state: SubmissionStatus;
@@ -183,8 +195,7 @@ export type Instance = {
183
195
  profile_objects: ProfileObject[];
184
196
  // TODO: (semver breaking) mark as optional since the get-shared-data API doesn't return keys
185
197
  keys: {
186
- // TODO: TS4.3 use `NId` instead of `string`
187
- [nId: string]: {
198
+ [nId: NId]: {
188
199
  [fieldName: string]: {
189
200
  data: string;
190
201
  n_id: NId;
@@ -218,6 +229,16 @@ export type Organization = {
218
229
  customer: Record<string, unknown>;
219
230
  };
220
231
 
232
+ /** @internal some APIs now return extra info */
233
+ export type FullOrg = {
234
+ id: OId;
235
+ organization: Omit<Organization, "id">;
236
+ /** 🧙‍♂️ */
237
+ gandalf: unknown;
238
+ stripe: { customer: unknown };
239
+ centrix_credentials: unknown;
240
+ };
241
+
221
242
  /** validation data returned by preVerify (part of the extract&map API) */
222
243
  export type Validation = {
223
244
  score: number;
@@ -235,11 +256,15 @@ export type Validation = {
235
256
  };
236
257
  };
237
258
 
259
+ export type WebhookStatus = "subscribed" | "pending" | "unsubscribe_failed";
260
+
238
261
  export type Webhook = {
239
262
  wi_id: WId;
240
263
  /** n_id of "the webhook provider which can be set up against a service provider" */
241
264
  provider_webhook_id: NId;
242
- status: unknown;
265
+ /** not sure what this is */
266
+ provider_webhook_subscription_id: NId;
267
+ status: WebhookStatus;
243
268
  /** ISO Date */
244
269
  date_created: string;
245
270
  /** ISO Date */
@@ -251,9 +276,19 @@ export type Webhook = {
251
276
  field_name: string;
252
277
  };
253
278
  webhook_action: { webhook_action_type: string }[];
254
- provider_subscription_credentials: unknown;
255
279
  webhook_filter_source: string;
256
280
  webhook_field_mapping_schema: {
257
281
  [key: string]: string;
258
282
  };
283
+ webhook_processing_rules: unknown;
284
+
285
+ provider_subscription_credentials: unknown;
286
+ provider_signature_check_enabled: boolean;
287
+ provider_signature_credentials: unknown;
288
+
289
+ subscribe_log?: {
290
+ date: string;
291
+ response_status_code: number;
292
+ response_payload: Json;
293
+ }[];
259
294
  };
package/src/schema.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { AA, DataTypes, NId, Organization, Urn } from "./raytio";
1
+ import { AA, DataTypes, Organization, Urn } from "./raytio";
2
2
  import { WizardConfig } from "./wizard";
3
3
 
4
4
  /** should be renamed since this applies to ConditionallyVerifiable */
5
5
  export type ConditionallyRequired = {
6
6
  field: string;
7
+ // see `isConditionMet` for how this syntax works
7
8
  if: {
8
- [fieldName: string]: string[];
9
+ [fieldName: string]: (string | number | boolean)[];
9
10
  };
10
11
  };
11
12
 
@@ -23,8 +24,8 @@ export type SchemaFieldTag =
23
24
  | "display:survey"
24
25
  | "display:quoting"
25
26
  | "display:customModal"
27
+ | `display:replace:'${string}':'${string}'`
26
28
  | "display:terms_conditions"
27
- | "display:showOnWizard" // added by #837, TODO: document
28
29
  | `display:main_media:${string}` // property name to determine what image to display
29
30
  // date picker components
30
31
  | "date_component:day"
@@ -48,6 +49,7 @@ export type SchemaTag =
48
49
  | `oauth2_component:name:${string}`
49
50
  | `oauth2_component:redirect_url:${string}`
50
51
  // misc
52
+ | `time:${/* type */ string}:${/* seconds */ number}`
51
53
  | `link_to:${/* schemaName */ string}:${/* relationshipType */ string}`
52
54
  // type
53
55
  | "type:service_provider"
@@ -67,9 +69,15 @@ export type SchemaField = {
67
69
  examples?: unknown[];
68
70
  tags?: SchemaFieldTag[];
69
71
  type?: DataTypes;
70
- enum?: string[];
72
+ enum?: (string | number | boolean)[];
73
+ /** for number inputs, the maximum allowed value */
71
74
  maximum?: number;
75
+ /** for number inputs, the minimum allowed value */
72
76
  minimum?: number;
77
+ /** for number inputs, the step size used in the input or slider */
78
+ step?: number;
79
+ /** if true, the user must have encryption enabled to save this data, see #1324 */
80
+ encrypt_require?: boolean;
73
81
  /** @deprecated raytio's usage not documented */
74
82
  maxLength?: number;
75
83
  /** @deprecated raytio's usage not documented */
@@ -107,7 +115,7 @@ export type SchemaField = {
107
115
  [fieldName: string]: string[];
108
116
  };
109
117
 
110
- allOf?: [{ $ref: string }, SchemaField];
118
+ allOf?: [{ $ref: string }, ServerSchemaField];
111
119
 
112
120
  /** only checkbox uses this prop */
113
121
  content?: string;
@@ -151,15 +159,12 @@ export type SchemaField = {
151
159
  image_silhouette?: string;
152
160
  };
153
161
 
154
- /**
155
- * Raytio's variant of JSON Schema. All props marked as optional except
156
- * `name`. This type can be used for both the schema and for individual fields.
157
- */
158
- export type Schema = {
159
- /** @deprecated don't use this */
160
- $id?: string;
161
- $schema?: string;
162
- n_id?: NId;
162
+ /** the only difference between the client & server's definition is that the client adds `$prop` */
163
+ export type ServerSchemaField = Omit<SchemaField, "$prop">;
164
+
165
+ /** not exported. Attributes that are identical in both client schema & server schema */
166
+ export type CommonSchemaAttributes = {
167
+ type?: DataTypes;
163
168
 
164
169
  /** these fields will always exist on schema */
165
170
  name: string;
@@ -173,47 +178,14 @@ export type Schema = {
173
178
  * forms that accept different types of similar documents.
174
179
  */
175
180
  schema_group?: string;
176
- /** the localized title of the `schema_group`. added by the client */
177
- group_title?: string;
178
-
179
- /** @deprecated not sure why a schema would have this, only fields should */
180
- $ref?: string;
181
-
182
- version?: string;
183
- /** whether the `version` is the latest version */
184
- version_current?: boolean;
185
181
 
186
182
  tags?: SchemaTag[];
187
- /** originally `string[]`, the client modifies this */
188
- verified_fields?: (string | ConditionallyRequired)[];
189
-
190
- wasExpandedByClient?: boolean;
191
- /** added by client */
192
- required?: (string | ConditionallyRequired)[];
193
-
194
- type?: DataTypes;
195
- definitions?: Record<string, { $ref: Urn }>;
196
- allOf?: {
197
- $ref?: string;
198
- if?: Schema;
199
- // we don't suport else (yet)
200
- then?: Schema;
201
- }[];
202
-
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: {
208
- [fieldName: string]: SchemaField;
209
- };
210
183
 
211
184
  /* any overrides can be specfied per field or for the whole schema */
212
185
  i18n?: {
213
186
  [locale: string]: {
214
- // @ts-expect-error I don't understand what's wrong
215
- $schema: Schema;
216
- // not that for entries that start in "group:" or $loading_, only the title field will be used.
187
+ $schema: { title: string; title_plural?: string; description?: string };
188
+ // note that for entries that start in "group:" or $loading_, only the title field will be used.
217
189
  // ^ the exception is `group:{GROUP_NAME}:{SUB_GROUP}.field` which is used for the combined field title/desc
218
190
  // normal fields can specify any field attributes to override.
219
191
 
@@ -229,22 +201,11 @@ export type Schema = {
229
201
  $loading_delete_pending_ver: { title: string };
230
202
  $loading_pending_ver_resubmit: { title: string };
231
203
 
232
- [fieldNameOrGroupName: string]: Omit<SchemaField, "$prop"> & {
204
+ [fieldNameOrGroupName: string]: ServerSchemaField & {
233
205
  title_plural?: string;
234
206
  };
235
207
  };
236
208
  };
237
- /** @internal the client adds this after processing the i18n property */
238
- groupNames?: Record<string, string>;
239
- /** @internal added by the client to inform downstream components which locale from schema.i18n was used */
240
- clientLocale?: string;
241
-
242
- /**
243
- * @internal
244
- * the estimated loading times in seconds for various API calls. The client adds
245
- * this field after processing the schema tags.
246
- */
247
- timing?: Record<"extract" | "live_person" | "verify_pending_delay", number>;
248
209
 
249
210
  relationships?: {
250
211
  relationship_name: string;
@@ -287,12 +248,6 @@ export type Schema = {
287
248
  expand?: { fields: string[]; label: string }[];
288
249
  };
289
250
 
290
- /** @internal @deprecated do not use */
291
- unexpanded_allOf?: never;
292
-
293
- /** @internal @deprecated do not use */
294
- unexpanded_properties?: never;
295
-
296
251
  /** only the schema used for the onboarding wizard have this property */
297
252
  onboard_properties?: {
298
253
  /** Profile Objects that should be created */
@@ -332,32 +287,88 @@ export type Schema = {
332
287
  };
333
288
  };
334
289
 
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
- > & {
290
+ /**
291
+ * Raytio's variant of JSON Schema, as used by the client. It is a modified version
292
+ * of what the API returns.
293
+ */
294
+ export type Schema = CommonSchemaAttributes & {
295
+ /** the localized title of the `schema_group`. added by the client */
296
+ group_title?: string;
297
+
298
+ /** originally `string[]`, the client modifies this */
299
+ verified_fields?: (string | ConditionallyRequired)[];
300
+
301
+ /** originally `string[]`, the client modifies this */
302
+ required?: (string | ConditionallyRequired)[];
303
+
304
+ /** added by client */
305
+ wasExpandedByClient?: boolean;
306
+
307
+ /** ISO Date. Copied from {@link WrappedSchema} */
308
+ start_date?: string;
309
+ /** ISO Date. Copied from {@link WrappedSchema} If this tag exists, the schema is deprecated */
310
+ end_date?: string;
311
+
312
+ /** 🚨 Note that there are cases where properties are undefined, e.g. if the schema is a sub-object */
313
+ properties: {
314
+ [fieldName: string]: SchemaField;
315
+ };
316
+
317
+ /** the client adds this after processing the i18n property */
318
+ groupNames?: Record<string, string>;
319
+
320
+ /** added by the client to inform downstream components which locale from schema.i18n was used */
321
+ clientLocale?: string;
322
+
323
+ /** added by the client, copied from {@link WrappedSchema} */
324
+ version: string;
325
+
353
326
  /**
354
- * @deprecated this prop exists so that SchemaMetadata does not extend Schema.
355
- * use `getSchema(schemaName)` to fetch the full schema
327
+ * the estimated loading times in seconds for various API calls. The client adds
328
+ * this field after processing the schema tags.
356
329
  */
357
- __typeof__: "You cannot supply SchemaMetadata to a function that expects Schema";
330
+ timing?: Record<"extract" | "live_person" | "verify_pending_delay", number>;
358
331
 
359
- isProfileSchema: boolean;
360
- isSpSchema: boolean;
332
+ /** added by the client. If true, this should be shown to the client */
333
+ isProfileSchema?: boolean;
334
+
335
+ /** added by the client. If true, this schema somehow relates to legacy service providers */
336
+ isSpSchema?: boolean;
337
+ };
338
+
339
+ /** This is what's returned by the API */
340
+ export type WrappedSchema = {
341
+ active: true;
342
+ /** ISO Date */
343
+ start_date: string;
344
+ /** ISO Date. If this tag exists, the schema is deprecated. */
345
+ end_date: string;
346
+ name: string;
347
+ type: "ss" | "ps" | "us";
348
+ version: string;
349
+ /** whether the \`version\` is the latest version */
350
+ version_current: boolean;
351
+ schema: CommonSchemaAttributes & {
352
+ /** @deprecated don't use this */
353
+ $id?: string;
354
+ /** @deprecated don't use this */
355
+ $schema?: string;
356
+
357
+ definitions?: Record<string, { $ref: Urn }>;
358
+ allOf?: {
359
+ $ref?: string;
360
+ if?: Partial<WrappedSchema["schema"]>;
361
+ // we don't suport else (yet)
362
+ then?: Partial<WrappedSchema["schema"]>;
363
+ }[];
364
+
365
+ properties: {
366
+ [fieldName: string]: ServerSchemaField;
367
+ };
368
+
369
+ required?: string[];
370
+ verified_fields?: string[];
371
+ };
361
372
  };
362
373
 
363
374
  /** @ignore */
package/src/theme.ts CHANGED
@@ -10,7 +10,7 @@ export type Colors = {
10
10
  raytioOrangeText: string;
11
11
  raytioOrangeUi: string;
12
12
  raytioOrangeHover: string;
13
- /** only used by the fancy layout on the login screen */
13
+ /** */
14
14
  raytioOrangeShade: string;
15
15
  successGreen: string;
16
16
  loadingYellow: string;
@@ -20,9 +20,7 @@ export type VerificationPayload<WithValue extends boolean> = {
20
20
  verifier_source_id?: NId;
21
21
  verifier_service_id?: NId;
22
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,
23
+ // we are disabling the eslint rule because even tho `{}` acts illogically in typescript,
26
24
  // in this case it's working as expected in the intersection type, see
27
25
  // https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-632833366
28
26
  // and https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-645510515
@@ -85,7 +83,7 @@ export type VerificationProvider = {
85
83
  date?: Date;
86
84
  };
87
85
 
88
- /** This is what @raytio/core exposes, which is more useable than @see Verification */
86
+ /** This is what @raytio/core exposes, which is more useable than {@link Verification} */
89
87
  export type RealVer = {
90
88
  fieldName: string;
91
89
  value: unknown;
package/src/wizard.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import { AId } from "./raytio";
2
2
 
3
- /** configuration data for a single wizard page (@see WizardConfig) */
3
+ export type WizardPageTag =
4
+ // actions
5
+ "action:require_chip";
6
+
7
+ /** configuration data for a single wizard page ({@link WizardConfig}) */
4
8
  export type WizardPage = {
5
9
  /** if undefined, the schema title will be used */
6
10
  name?: string | symbol;
@@ -23,7 +27,7 @@ export type WizardPage = {
23
27
  service_provider_link?: boolean;
24
28
  /** custom text to display on the Create New button */
25
29
  create_new_text?: string;
26
- /** a URL to a preset for configuing NestedSchemaSelect. @see DeepConfig */
30
+ /** a URL to a preset for configuing NestedSchemaSelect. {@link DeepConfig} */
27
31
  selection_hierarchy_json?: string;
28
32
 
29
33
  /** whether the schema description should be shown */
@@ -60,7 +64,12 @@ export type WizardPage = {
60
64
  /** for ImageDynamicSection, the action to take if the API returns no `validation: {}` object */
61
65
  extract_threshold_null_action?: WizardPage["extract_threshold_fail_action"];
62
66
 
63
- /** if `false`, ProfileObjects created while completing the form will not be verified. `undefined` implies `true` */
67
+ /**
68
+ * if `false`, ProfileObjects created while completing the form will not be verified.
69
+ * if `true`, you can only select ProfileObjects that are partially or fully verified.
70
+ * `undefined` implies `true`.
71
+ * @default true
72
+ */
64
73
  verify_data?: boolean;
65
74
 
66
75
  /** a list of fields that should not be required, even if the schema says they're required */
@@ -72,11 +81,19 @@ export type WizardPage = {
72
81
 
73
82
  /** can you force the colour theme to change for just one page (#1066, #1074). At the moment this on pages that use WebcamImageCapture */
74
83
  display_mode?: "light" | "dark" | "default";
84
+
85
+ tags?: WizardPageTag[];
86
+
87
+ /**
88
+ * If specified, this is is a "Conditional Wizard Page", which is only shown
89
+ * if the rule passed. This field contains the ID (not name) of the rule.
90
+ */
91
+ branching_rule_name?: string;
75
92
  };
76
93
 
77
94
  /**
78
95
  * when a form link is generated, this is what gets saved on the API.
79
- * Each value can be overriden in the query parameters. If specified
96
+ * Each value can be overridden in the query parameters. If specified
80
97
  * in the query parameters, it needs to be base64 and/or url encoded.
81
98
  */
82
99
  export type WizardConfig = {