@fleetless/sdk 5.0.0 → 5.2.0-next.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/dist/index.d.ts CHANGED
@@ -464,6 +464,70 @@ declare const datapointEvent: z.ZodObject<{
464
464
  timestamp_ms: z.ZodNumber;
465
465
  }, z.core.$strip>;
466
466
  type DatapointEvent = z.infer<typeof datapointEvent>;
467
+ /**
468
+ * One change to a record the subscriber can see. `record` is the whole record,
469
+ * up to 1 MB, in the shape the REST routes answer.
470
+ *
471
+ * **A client that cannot keep up is disconnected, not skipped.** A socket whose
472
+ * send buffer holds more than 8 MiB, or that has more than 2,000 collection
473
+ * changes waiting to be delivered (a bulk import into a big collection does
474
+ * that), is closed with code 1013 ("try again later"). The client reconnects,
475
+ * subscribes again and lists again.
476
+ */
477
+ declare const collectionEvent: z.ZodObject<{
478
+ type: z.ZodLiteral<"collection_event">;
479
+ request_id: z.ZodString;
480
+ event: z.ZodEnum<{
481
+ deleted: "deleted";
482
+ created: "created";
483
+ updated: "updated";
484
+ removed: "removed";
485
+ entered: "entered";
486
+ }>;
487
+ id: z.ZodUUID;
488
+ record: z.ZodOptional<z.ZodObject<{
489
+ id: z.ZodUUID;
490
+ robot_id: z.ZodNullable<z.ZodUUID>;
491
+ created_at: z.ZodISODateTime;
492
+ created_by: z.ZodObject<{
493
+ kind: z.ZodEnum<{
494
+ developer: "developer";
495
+ fleetless: "fleetless";
496
+ server_key: "server_key";
497
+ app_user: "app_user";
498
+ }>;
499
+ id: z.ZodUUID;
500
+ label: z.ZodString;
501
+ }, z.core.$strip>;
502
+ updated_at: z.ZodISODateTime;
503
+ updated_by: z.ZodObject<{
504
+ kind: z.ZodEnum<{
505
+ developer: "developer";
506
+ fleetless: "fleetless";
507
+ server_key: "server_key";
508
+ app_user: "app_user";
509
+ }>;
510
+ id: z.ZodUUID;
511
+ label: z.ZodString;
512
+ }, z.core.$strip>;
513
+ revision: z.ZodNumber;
514
+ display: z.ZodString;
515
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
516
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
517
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
518
+ deleted_by: z.ZodOptional<z.ZodObject<{
519
+ kind: z.ZodEnum<{
520
+ developer: "developer";
521
+ fleetless: "fleetless";
522
+ server_key: "server_key";
523
+ app_user: "app_user";
524
+ }>;
525
+ id: z.ZodUUID;
526
+ label: z.ZodString;
527
+ }, z.core.$strip>>;
528
+ }, z.core.$strip>>;
529
+ }, z.core.$strict>;
530
+ type CollectionEvent$1 = z.infer<typeof collectionEvent>;
467
531
 
468
532
 
469
533
  /**
@@ -550,19 +614,30 @@ type ClientOidcErrorCode = z.infer<typeof clientOidcErrorCode>;
550
614
  * MCP sign-in instead, which reads and decides the same interaction.
551
615
  *
552
616
  * `client_name_verified` is `z.literal(false)`, and that is the whole point of
553
- * the field. The name comes from an **unauthenticated** dynamic registration —
554
- * the client typed it about itself, nobody checked it — so a consent screen
617
+ * the field. The name comes from an **unauthenticated** dynamic registration,
618
+ * or from a Client ID Metadata Document the client published about itself —
619
+ * either way the client typed it, nobody checked it — so a consent screen
555
620
  * that rendered it as though it were an identity would be teaching people to
556
621
  * trust a string an attacker chooses. A literal rather than a boolean because
557
622
  * there is no verified case to distinguish: an app that reads this field at all
558
623
  * has to handle the untrusted one, and a `true` branch would be dead code
559
624
  * pretending to be a safeguard.
625
+ *
626
+ * **What was checked is `client_id_host`, and only for a metadata-document
627
+ * client**: the authorization server fetched the document from that host over
628
+ * HTTPS, and the document named the URL it was fetched from. That proves who
629
+ * controls the domain, nothing about the name. A consent screen shows the
630
+ * domain beside the name, and the redirect host beside both, because the
631
+ * redirect host is where the authorization code goes.
560
632
  */
561
633
  declare const clientMcpInteraction: z.ZodObject<{
562
634
  id: z.ZodString;
563
635
  app_id: z.ZodUUID;
564
636
  client_name: z.ZodNullable<z.ZodString>;
565
637
  client_name_verified: z.ZodLiteral<false>;
638
+ client_id_host: z.ZodNullable<z.ZodString>;
639
+ redirect_uri_host: z.ZodString;
640
+ redirect_uri_loopback: z.ZodBoolean;
566
641
  scopes: z.ZodArray<z.ZodString>;
567
642
  already_granted: z.ZodBoolean;
568
643
  expires_at: z.ZodISODateTime;
@@ -592,6 +667,7 @@ type ClientMcpInteraction = z.infer<typeof clientMcpInteraction>;
592
667
  */
593
668
  declare const mcpConsentGrant: z.ZodObject<{
594
669
  client_id: z.ZodString;
670
+ client_id_host: z.ZodNullable<z.ZodString>;
595
671
  client_name: z.ZodNullable<z.ZodString>;
596
672
  client_name_verified: z.ZodLiteral<false>;
597
673
  granted_at: z.ZodISODateTime;
@@ -873,14 +949,492 @@ declare const cancelRejectedDetails: z.ZodObject<{
873
949
  }, z.core.$strip>>;
874
950
  }, z.core.$strip>;
875
951
  type CancelRejectedDetails = z.infer<typeof cancelRejectedDetails>;
952
+ /**
953
+ * The `details` of a `409 record_referenced` refusal. Counts only: the caller
954
+ * may not be allowed to read the records that point here, so neither their
955
+ * ids nor their values are told. Nor is the key of a collection the caller may
956
+ * not read, for the reason `collection_not_found` is answered for one: the list
957
+ * names only collections the caller may read, and it is empty when every
958
+ * collection that points here is one they may not.
959
+ */
960
+ declare const recordReferencedDetails: z.ZodObject<{
961
+ references: z.ZodArray<z.ZodObject<{
962
+ collection: z.ZodString;
963
+ count: z.ZodNumber;
964
+ }, z.core.$strict>>;
965
+ }, z.core.$strict>;
966
+ type RecordReferencedDetails = z.infer<typeof recordReferencedDetails>;
967
+ /** The `details` of a `409 record_changed` refusal: the revision the record is at now, for the caller to read it again. */
968
+ declare const recordChangedDetails: z.ZodObject<{
969
+ revision: z.ZodNumber;
970
+ }, z.core.$strict>;
971
+ type RecordChangedDetails = z.infer<typeof recordChangedDetails>;
972
+ /** The `details` of a `400 reference_invalid` refusal: which reference field, and why its value was refused. */
973
+ declare const referenceInvalidDetails: z.ZodObject<{
974
+ field: z.ZodString;
975
+ reason: z.ZodEnum<{
976
+ missing: "missing";
977
+ other_robot: "other_robot";
978
+ not_readable: "not_readable";
979
+ }>;
980
+ }, z.core.$strict>;
981
+ type ReferenceInvalidDetails = z.infer<typeof referenceInvalidDetails>;
982
+ /** The `details` of a `400 required_missing` refusal: every required field the write would leave empty. */
983
+ declare const requiredMissingDetails: z.ZodObject<{
984
+ fields: z.ZodArray<z.ZodString>;
985
+ }, z.core.$strict>;
986
+ type RequiredMissingDetails = z.infer<typeof requiredMissingDetails>;
876
987
  /**
877
988
  * The codes in use today. The wire deliberately allows any string — this
878
989
  * list is the shared vocabulary, not a closed set, so a new refusal never
879
990
  * needs a contracts release before it can be reported honestly.
880
991
  */
881
- declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "bridge_too_old", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "cancel_rejected", "job_lost", "operator_verified_stopped", "job_unknown_to_bridge", "action_server_lost", "action_failed", "goal_rejected", "goal_send_failed", "result_failed", "goal_uncontrollable", "bridge_disconnected", "config_changed", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "role_cycle", "role_key_taken", "confirmation_required", "target_state_conflict", "job_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired", "invalid_code", "method_not_allowed", "plan_limit", "plan_required", "org_locked", "file_too_large", "billing_unavailable", "legal_offer_unavailable", "payment_provider_unavailable", "history_migrating", "billing_documents_unavailable", "support_read_only", "support_forbidden"];
992
+ declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "bridge_too_old", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "cancel_rejected", "job_lost", "operator_verified_stopped", "job_unknown_to_bridge", "action_server_lost", "action_failed", "goal_rejected", "goal_send_failed", "result_failed", "goal_uncontrollable", "bridge_disconnected", "config_changed", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "role_cycle", "role_key_taken", "confirmation_required", "target_state_conflict", "job_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired", "invalid_code", "method_not_allowed", "plan_limit", "plan_required", "org_locked", "file_too_large", "billing_unavailable", "legal_offer_unavailable", "payment_provider_unavailable", "history_migrating", "billing_documents_unavailable", "support_read_only", "support_forbidden", "logo_draw_unavailable", "plan_purchase_closed", "record_referenced", "record_changed", "collection_not_found", "collection_removed", "reference_invalid", "required_missing", "robot_not_attached"];
882
993
  type ErrorCode = (typeof ERROR_CODES)[number];
883
994
 
995
+
996
+ /**
997
+ * How a collection relates to robots. A property of the collection and not a
998
+ * field type, so a record's robot can neither be left out of a robot-bound
999
+ * collection nor changed afterwards.
1000
+ */
1001
+ declare const collectionBinding: z.ZodEnum<{
1002
+ global: "global";
1003
+ per_robot: "per_robot";
1004
+ one_per_robot: "one_per_robot";
1005
+ }>;
1006
+ type CollectionBinding = z.infer<typeof collectionBinding>;
1007
+ /**
1008
+ * One field definition, discriminated on `type`. A union and not one object
1009
+ * with every option optional: `max_length` on a `number` would otherwise parse
1010
+ * and mean nothing.
1011
+ */
1012
+ declare const collectionField: z.ZodDiscriminatedUnion<[z.ZodObject<{
1013
+ max_length: z.ZodOptional<z.ZodNumber>;
1014
+ pattern: z.ZodOptional<z.ZodString>;
1015
+ searchable: z.ZodOptional<z.ZodBoolean>;
1016
+ label: z.ZodOptional<z.ZodString>;
1017
+ description: z.ZodOptional<z.ZodString>;
1018
+ required: z.ZodOptional<z.ZodBoolean>;
1019
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1020
+ default: z.ZodOptional<z.ZodUnknown>;
1021
+ type: z.ZodLiteral<"text">;
1022
+ }, z.core.$strict>, z.ZodObject<{
1023
+ max_length: z.ZodOptional<z.ZodNumber>;
1024
+ searchable: z.ZodOptional<z.ZodBoolean>;
1025
+ label: z.ZodOptional<z.ZodString>;
1026
+ description: z.ZodOptional<z.ZodString>;
1027
+ required: z.ZodOptional<z.ZodBoolean>;
1028
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1029
+ default: z.ZodOptional<z.ZodUnknown>;
1030
+ type: z.ZodLiteral<"long_text">;
1031
+ }, z.core.$strict>, z.ZodObject<{
1032
+ integer: z.ZodOptional<z.ZodBoolean>;
1033
+ min: z.ZodOptional<z.ZodNumber>;
1034
+ max: z.ZodOptional<z.ZodNumber>;
1035
+ unit: z.ZodOptional<z.ZodString>;
1036
+ label: z.ZodOptional<z.ZodString>;
1037
+ description: z.ZodOptional<z.ZodString>;
1038
+ required: z.ZodOptional<z.ZodBoolean>;
1039
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1040
+ default: z.ZodOptional<z.ZodUnknown>;
1041
+ type: z.ZodLiteral<"number">;
1042
+ }, z.core.$strict>, z.ZodObject<{
1043
+ label: z.ZodOptional<z.ZodString>;
1044
+ description: z.ZodOptional<z.ZodString>;
1045
+ required: z.ZodOptional<z.ZodBoolean>;
1046
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1047
+ default: z.ZodOptional<z.ZodUnknown>;
1048
+ type: z.ZodLiteral<"boolean">;
1049
+ }, z.core.$strict>, z.ZodObject<{
1050
+ options: z.ZodArray<z.ZodObject<{
1051
+ value: z.ZodString;
1052
+ label: z.ZodOptional<z.ZodString>;
1053
+ }, z.core.$strict>>;
1054
+ multiple: z.ZodOptional<z.ZodBoolean>;
1055
+ searchable: z.ZodOptional<z.ZodBoolean>;
1056
+ label: z.ZodOptional<z.ZodString>;
1057
+ description: z.ZodOptional<z.ZodString>;
1058
+ required: z.ZodOptional<z.ZodBoolean>;
1059
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1060
+ default: z.ZodOptional<z.ZodUnknown>;
1061
+ type: z.ZodLiteral<"select">;
1062
+ }, z.core.$strict>, z.ZodObject<{
1063
+ label: z.ZodOptional<z.ZodString>;
1064
+ description: z.ZodOptional<z.ZodString>;
1065
+ required: z.ZodOptional<z.ZodBoolean>;
1066
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1067
+ default: z.ZodOptional<z.ZodUnknown>;
1068
+ type: z.ZodLiteral<"date">;
1069
+ }, z.core.$strict>, z.ZodObject<{
1070
+ label: z.ZodOptional<z.ZodString>;
1071
+ description: z.ZodOptional<z.ZodString>;
1072
+ required: z.ZodOptional<z.ZodBoolean>;
1073
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1074
+ default: z.ZodOptional<z.ZodUnknown>;
1075
+ type: z.ZodLiteral<"datetime">;
1076
+ }, z.core.$strict>, z.ZodObject<{
1077
+ schema: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
1078
+ label: z.ZodOptional<z.ZodString>;
1079
+ description: z.ZodOptional<z.ZodString>;
1080
+ required: z.ZodOptional<z.ZodBoolean>;
1081
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1082
+ default: z.ZodOptional<z.ZodUnknown>;
1083
+ type: z.ZodLiteral<"json">;
1084
+ }, z.core.$strict>, z.ZodObject<{
1085
+ to: z.ZodString;
1086
+ on_delete: z.ZodOptional<z.ZodEnum<{
1087
+ prevent: "prevent";
1088
+ clear: "clear";
1089
+ }>>;
1090
+ label: z.ZodOptional<z.ZodString>;
1091
+ description: z.ZodOptional<z.ZodString>;
1092
+ required: z.ZodOptional<z.ZodBoolean>;
1093
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1094
+ default: z.ZodOptional<z.ZodUnknown>;
1095
+ type: z.ZodLiteral<"reference">;
1096
+ }, z.core.$strict>], "type">;
1097
+ type CollectionField = z.infer<typeof collectionField>;
1098
+
1099
+
1100
+ /**
1101
+ * Who made a change. `fleetless` is the platform itself (a schema change, an
1102
+ * automatic record) and always carries the nil id. `label` is worked out when
1103
+ * the record is read, from the person's display name, so a user who has since
1104
+ * been deleted reads `Deleted user` instead of leaving the record with a
1105
+ * dangling id. An email address is the fallback only for a reader who may see
1106
+ * it: a developer or a server key reading a person without a name, and an app
1107
+ * user reading their own label.
1108
+ */
1109
+ declare const collectionActor: z.ZodObject<{
1110
+ kind: z.ZodEnum<{
1111
+ developer: "developer";
1112
+ fleetless: "fleetless";
1113
+ server_key: "server_key";
1114
+ app_user: "app_user";
1115
+ }>;
1116
+ id: z.ZodUUID;
1117
+ label: z.ZodString;
1118
+ }, z.core.$strip>;
1119
+ type CollectionActor = z.infer<typeof collectionActor>;
1120
+ /**
1121
+ * One record. `display` is the collection's display template rendered for this
1122
+ * record, so a list can name its rows without knowing the template.
1123
+ */
1124
+ declare const collectionRecord: z.ZodObject<{
1125
+ id: z.ZodUUID;
1126
+ robot_id: z.ZodNullable<z.ZodUUID>;
1127
+ created_at: z.ZodISODateTime;
1128
+ created_by: z.ZodObject<{
1129
+ kind: z.ZodEnum<{
1130
+ developer: "developer";
1131
+ fleetless: "fleetless";
1132
+ server_key: "server_key";
1133
+ app_user: "app_user";
1134
+ }>;
1135
+ id: z.ZodUUID;
1136
+ label: z.ZodString;
1137
+ }, z.core.$strip>;
1138
+ updated_at: z.ZodISODateTime;
1139
+ updated_by: z.ZodObject<{
1140
+ kind: z.ZodEnum<{
1141
+ developer: "developer";
1142
+ fleetless: "fleetless";
1143
+ server_key: "server_key";
1144
+ app_user: "app_user";
1145
+ }>;
1146
+ id: z.ZodUUID;
1147
+ label: z.ZodString;
1148
+ }, z.core.$strip>;
1149
+ revision: z.ZodNumber;
1150
+ display: z.ZodString;
1151
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
1152
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1153
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
1154
+ deleted_by: z.ZodOptional<z.ZodObject<{
1155
+ kind: z.ZodEnum<{
1156
+ developer: "developer";
1157
+ fleetless: "fleetless";
1158
+ server_key: "server_key";
1159
+ app_user: "app_user";
1160
+ }>;
1161
+ id: z.ZodUUID;
1162
+ label: z.ZodString;
1163
+ }, z.core.$strip>>;
1164
+ }, z.core.$strip>;
1165
+ type CollectionRecord$1 = z.infer<typeof collectionRecord>;
1166
+ /**
1167
+ * One entry of a record's history. `changes` holds each changed field with its
1168
+ * old and new value, `null` standing for no value. A `delete` revision carries
1169
+ * the whole record so that a deleted record can be seen and brought back.
1170
+ */
1171
+ declare const collectionRevision: z.ZodObject<{
1172
+ seq: z.ZodNumber;
1173
+ op: z.ZodEnum<{
1174
+ create: "create";
1175
+ update: "update";
1176
+ delete: "delete";
1177
+ restore: "restore";
1178
+ }>;
1179
+ at: z.ZodISODateTime;
1180
+ actor: z.ZodObject<{
1181
+ kind: z.ZodEnum<{
1182
+ developer: "developer";
1183
+ fleetless: "fleetless";
1184
+ server_key: "server_key";
1185
+ app_user: "app_user";
1186
+ }>;
1187
+ id: z.ZodUUID;
1188
+ label: z.ZodString;
1189
+ }, z.core.$strip>;
1190
+ reason: z.ZodNullable<z.ZodString>;
1191
+ revision: z.ZodNumber;
1192
+ changes: z.ZodRecord<z.ZodString, z.ZodObject<{
1193
+ old: z.ZodUnknown;
1194
+ new: z.ZodUnknown;
1195
+ }, z.core.$strip>>;
1196
+ record: z.ZodNullable<z.ZodObject<{
1197
+ id: z.ZodUUID;
1198
+ robot_id: z.ZodNullable<z.ZodUUID>;
1199
+ created_at: z.ZodISODateTime;
1200
+ created_by: z.ZodObject<{
1201
+ kind: z.ZodEnum<{
1202
+ developer: "developer";
1203
+ fleetless: "fleetless";
1204
+ server_key: "server_key";
1205
+ app_user: "app_user";
1206
+ }>;
1207
+ id: z.ZodUUID;
1208
+ label: z.ZodString;
1209
+ }, z.core.$strip>;
1210
+ updated_at: z.ZodISODateTime;
1211
+ updated_by: z.ZodObject<{
1212
+ kind: z.ZodEnum<{
1213
+ developer: "developer";
1214
+ fleetless: "fleetless";
1215
+ server_key: "server_key";
1216
+ app_user: "app_user";
1217
+ }>;
1218
+ id: z.ZodUUID;
1219
+ label: z.ZodString;
1220
+ }, z.core.$strip>;
1221
+ revision: z.ZodNumber;
1222
+ display: z.ZodString;
1223
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
1224
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1225
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
1226
+ deleted_by: z.ZodOptional<z.ZodObject<{
1227
+ kind: z.ZodEnum<{
1228
+ developer: "developer";
1229
+ fleetless: "fleetless";
1230
+ server_key: "server_key";
1231
+ app_user: "app_user";
1232
+ }>;
1233
+ id: z.ZodUUID;
1234
+ label: z.ZodString;
1235
+ }, z.core.$strip>>;
1236
+ }, z.core.$strip>>;
1237
+ }, z.core.$strip>;
1238
+ type CollectionRevision$1 = z.infer<typeof collectionRevision>;
1239
+ declare const collectionRecordHistoryResponse: z.ZodObject<{
1240
+ revisions: z.ZodArray<z.ZodObject<{
1241
+ seq: z.ZodNumber;
1242
+ op: z.ZodEnum<{
1243
+ create: "create";
1244
+ update: "update";
1245
+ delete: "delete";
1246
+ restore: "restore";
1247
+ }>;
1248
+ at: z.ZodISODateTime;
1249
+ actor: z.ZodObject<{
1250
+ kind: z.ZodEnum<{
1251
+ developer: "developer";
1252
+ fleetless: "fleetless";
1253
+ server_key: "server_key";
1254
+ app_user: "app_user";
1255
+ }>;
1256
+ id: z.ZodUUID;
1257
+ label: z.ZodString;
1258
+ }, z.core.$strip>;
1259
+ reason: z.ZodNullable<z.ZodString>;
1260
+ revision: z.ZodNumber;
1261
+ changes: z.ZodRecord<z.ZodString, z.ZodObject<{
1262
+ old: z.ZodUnknown;
1263
+ new: z.ZodUnknown;
1264
+ }, z.core.$strip>>;
1265
+ record: z.ZodNullable<z.ZodObject<{
1266
+ id: z.ZodUUID;
1267
+ robot_id: z.ZodNullable<z.ZodUUID>;
1268
+ created_at: z.ZodISODateTime;
1269
+ created_by: z.ZodObject<{
1270
+ kind: z.ZodEnum<{
1271
+ developer: "developer";
1272
+ fleetless: "fleetless";
1273
+ server_key: "server_key";
1274
+ app_user: "app_user";
1275
+ }>;
1276
+ id: z.ZodUUID;
1277
+ label: z.ZodString;
1278
+ }, z.core.$strip>;
1279
+ updated_at: z.ZodISODateTime;
1280
+ updated_by: z.ZodObject<{
1281
+ kind: z.ZodEnum<{
1282
+ developer: "developer";
1283
+ fleetless: "fleetless";
1284
+ server_key: "server_key";
1285
+ app_user: "app_user";
1286
+ }>;
1287
+ id: z.ZodUUID;
1288
+ label: z.ZodString;
1289
+ }, z.core.$strip>;
1290
+ revision: z.ZodNumber;
1291
+ display: z.ZodString;
1292
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
1293
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1294
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
1295
+ deleted_by: z.ZodOptional<z.ZodObject<{
1296
+ kind: z.ZodEnum<{
1297
+ developer: "developer";
1298
+ fleetless: "fleetless";
1299
+ server_key: "server_key";
1300
+ app_user: "app_user";
1301
+ }>;
1302
+ id: z.ZodUUID;
1303
+ label: z.ZodString;
1304
+ }, z.core.$strip>>;
1305
+ }, z.core.$strip>>;
1306
+ }, z.core.$strip>>;
1307
+ next_before_seq: z.ZodNullable<z.ZodNumber>;
1308
+ purged: z.ZodNullable<z.ZodObject<{
1309
+ before: z.ZodISODateTime;
1310
+ by: z.ZodObject<{
1311
+ kind: z.ZodEnum<{
1312
+ developer: "developer";
1313
+ fleetless: "fleetless";
1314
+ server_key: "server_key";
1315
+ app_user: "app_user";
1316
+ }>;
1317
+ id: z.ZodUUID;
1318
+ label: z.ZodString;
1319
+ }, z.core.$strip>;
1320
+ at: z.ZodISODateTime;
1321
+ }, z.core.$strip>>;
1322
+ }, z.core.$strip>;
1323
+ type CollectionRecordHistoryResponse = z.infer<typeof collectionRecordHistoryResponse>;
1324
+ /** The collections the caller can read, with their fields: what a client needs to build a form. */
1325
+ declare const collectionDefinitionsResponse: z.ZodObject<{
1326
+ version: z.ZodNullable<z.ZodNumber>;
1327
+ collections: z.ZodArray<z.ZodObject<{
1328
+ key: z.ZodString;
1329
+ label: z.ZodString;
1330
+ description: z.ZodString;
1331
+ binding: z.ZodEnum<{
1332
+ global: "global";
1333
+ per_robot: "per_robot";
1334
+ one_per_robot: "one_per_robot";
1335
+ }>;
1336
+ display: z.ZodString;
1337
+ fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
1338
+ max_length: z.ZodOptional<z.ZodNumber>;
1339
+ pattern: z.ZodOptional<z.ZodString>;
1340
+ searchable: z.ZodOptional<z.ZodBoolean>;
1341
+ label: z.ZodOptional<z.ZodString>;
1342
+ description: z.ZodOptional<z.ZodString>;
1343
+ required: z.ZodOptional<z.ZodBoolean>;
1344
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1345
+ default: z.ZodOptional<z.ZodUnknown>;
1346
+ type: z.ZodLiteral<"text">;
1347
+ }, z.core.$strict>, z.ZodObject<{
1348
+ max_length: z.ZodOptional<z.ZodNumber>;
1349
+ searchable: z.ZodOptional<z.ZodBoolean>;
1350
+ label: z.ZodOptional<z.ZodString>;
1351
+ description: z.ZodOptional<z.ZodString>;
1352
+ required: z.ZodOptional<z.ZodBoolean>;
1353
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1354
+ default: z.ZodOptional<z.ZodUnknown>;
1355
+ type: z.ZodLiteral<"long_text">;
1356
+ }, z.core.$strict>, z.ZodObject<{
1357
+ integer: z.ZodOptional<z.ZodBoolean>;
1358
+ min: z.ZodOptional<z.ZodNumber>;
1359
+ max: z.ZodOptional<z.ZodNumber>;
1360
+ unit: z.ZodOptional<z.ZodString>;
1361
+ label: z.ZodOptional<z.ZodString>;
1362
+ description: z.ZodOptional<z.ZodString>;
1363
+ required: z.ZodOptional<z.ZodBoolean>;
1364
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1365
+ default: z.ZodOptional<z.ZodUnknown>;
1366
+ type: z.ZodLiteral<"number">;
1367
+ }, z.core.$strict>, z.ZodObject<{
1368
+ label: z.ZodOptional<z.ZodString>;
1369
+ description: z.ZodOptional<z.ZodString>;
1370
+ required: z.ZodOptional<z.ZodBoolean>;
1371
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1372
+ default: z.ZodOptional<z.ZodUnknown>;
1373
+ type: z.ZodLiteral<"boolean">;
1374
+ }, z.core.$strict>, z.ZodObject<{
1375
+ options: z.ZodArray<z.ZodObject<{
1376
+ value: z.ZodString;
1377
+ label: z.ZodOptional<z.ZodString>;
1378
+ }, z.core.$strict>>;
1379
+ multiple: z.ZodOptional<z.ZodBoolean>;
1380
+ searchable: z.ZodOptional<z.ZodBoolean>;
1381
+ label: z.ZodOptional<z.ZodString>;
1382
+ description: z.ZodOptional<z.ZodString>;
1383
+ required: z.ZodOptional<z.ZodBoolean>;
1384
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1385
+ default: z.ZodOptional<z.ZodUnknown>;
1386
+ type: z.ZodLiteral<"select">;
1387
+ }, z.core.$strict>, z.ZodObject<{
1388
+ label: z.ZodOptional<z.ZodString>;
1389
+ description: z.ZodOptional<z.ZodString>;
1390
+ required: z.ZodOptional<z.ZodBoolean>;
1391
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1392
+ default: z.ZodOptional<z.ZodUnknown>;
1393
+ type: z.ZodLiteral<"date">;
1394
+ }, z.core.$strict>, z.ZodObject<{
1395
+ label: z.ZodOptional<z.ZodString>;
1396
+ description: z.ZodOptional<z.ZodString>;
1397
+ required: z.ZodOptional<z.ZodBoolean>;
1398
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1399
+ default: z.ZodOptional<z.ZodUnknown>;
1400
+ type: z.ZodLiteral<"datetime">;
1401
+ }, z.core.$strict>, z.ZodObject<{
1402
+ schema: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
1403
+ label: z.ZodOptional<z.ZodString>;
1404
+ description: z.ZodOptional<z.ZodString>;
1405
+ required: z.ZodOptional<z.ZodBoolean>;
1406
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1407
+ default: z.ZodOptional<z.ZodUnknown>;
1408
+ type: z.ZodLiteral<"json">;
1409
+ }, z.core.$strict>, z.ZodObject<{
1410
+ to: z.ZodString;
1411
+ on_delete: z.ZodOptional<z.ZodEnum<{
1412
+ prevent: "prevent";
1413
+ clear: "clear";
1414
+ }>>;
1415
+ label: z.ZodOptional<z.ZodString>;
1416
+ description: z.ZodOptional<z.ZodString>;
1417
+ required: z.ZodOptional<z.ZodBoolean>;
1418
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1419
+ default: z.ZodOptional<z.ZodUnknown>;
1420
+ type: z.ZodLiteral<"reference">;
1421
+ }, z.core.$strict>], "type">>;
1422
+ can: z.ZodObject<{
1423
+ read: z.ZodBoolean;
1424
+ create: z.ZodBoolean;
1425
+ update: z.ZodUnion<readonly [z.ZodEnum<{
1426
+ all: "all";
1427
+ own: "own";
1428
+ }>, z.ZodLiteral<false>]>;
1429
+ delete: z.ZodUnion<readonly [z.ZodEnum<{
1430
+ all: "all";
1431
+ own: "own";
1432
+ }>, z.ZodLiteral<false>]>;
1433
+ }, z.core.$strip>;
1434
+ }, z.core.$strip>>;
1435
+ }, z.core.$strip>;
1436
+ type CollectionDefinitionsResponse = z.infer<typeof collectionDefinitionsResponse>;
1437
+
884
1438
  /**
885
1439
  * Codes the SDK produces itself rather than relaying from the server. Kept
886
1440
  * out of `@fleetless/contracts`' `ERROR_CODES` deliberately — that list is
@@ -927,9 +1481,17 @@ type ErrorCode = (typeof ERROR_CODES)[number];
927
1481
  * built with a `serverKey` — `register`, `login`, `logout`, the password
928
1482
  * and invitation calls, both OIDC calls, the two MCP decisions and the two
929
1483
  * grant calls. Those threw a bare `Error` before, which a caller could only
930
- * catch by message. All of them are refused
931
- * before any request is sent — as a rejection, since every one of those
932
- * methods is `async`. A client-side mistake to fix, not something a
1484
+ * catch by message. **A fifth:** an id, slug or key that is only dots (`.`
1485
+ * or `..`) in any call that puts one into a path. It cannot name anything,
1486
+ * and as a path segment it would climb out of its route; no spelling of it
1487
+ * survives the URL parser. **A sixth:** a `collections.list` or
1488
+ * `collections.subscribe` `filter` that is not plain JSON (a BigInt, a
1489
+ * function, a number that is not finite, a cycle). **A seventh:** a
1490
+ * `collections.subscribe` whose frame, with its filter, is larger than the
1491
+ * 16,384 bytes the cloud takes on its realtime socket; the cloud would close
1492
+ * the connection for it, and again after every reconnect. All of them are
1493
+ * refused before any request is sent — as a rejection, since those methods
1494
+ * are `async`; `subscribe` is not, so it throws. A client-side mistake to fix, not something a
933
1495
  * server response could ever produce, which is why this code belongs here
934
1496
  * and not in `@fleetless/contracts`' `ERROR_CODES`.
935
1497
  * - `untrusted_absolute_url`: the SDK refused to fetch an absolute URL
@@ -2302,6 +2864,346 @@ interface CamerasApi {
2302
2864
  live(robotId: string, slug: string): Promise<CameraLiveSession>;
2303
2865
  }
2304
2866
 
2867
+ /**
2868
+ * One change to a record, as `collections.subscribe` hands it to its
2869
+ * callback.
2870
+ *
2871
+ * - `event` is `created`, `updated` or `deleted` when the record was written,
2872
+ * and `removed` or `entered` when it left or came into view of this
2873
+ * subscription without being deleted or created: its values stopped or
2874
+ * started matching the subscription's filter, the caller's role lost or
2875
+ * gained the right to read it, or its robot was detached or attached.
2876
+ * - `id` is the record's id.
2877
+ * - `record` is the whole record: as it is now for `created`, `updated`,
2878
+ * `entered` and `removed`, and as it was for `deleted`. It is absent only on
2879
+ * a `removed` event for a record the caller may no longer read, so that its
2880
+ * values are not told; the `id` still is.
2881
+ *
2882
+ * The wire frame is contracts' `collectionEvent`; the SDK hands over the
2883
+ * change itself, without the frame's `type` and `request_id`.
2884
+ */
2885
+ type CollectionEvent = Omit<CollectionEvent$1, 'type' | 'request_id'>;
2886
+ /**
2887
+ * What `collections.subscribe` takes besides the collection and the change
2888
+ * callback. Every field is optional.
2889
+ */
2890
+ interface CollectionSubscribeOptions {
2891
+ /** Only the records of this robot, in a collection that belongs to robots. */
2892
+ robot?: string;
2893
+ /**
2894
+ * Only records matching this filter are delivered. It is the `filter` of
2895
+ * `collections.list` — the same grammar, at most 3 levels and 50
2896
+ * conditions — and a record that stops matching is announced once as
2897
+ * `removed`. The SDK keeps a copy, so changing the object afterwards
2898
+ * changes nothing; a reactive proxy (Vue, Svelte, MobX) is fine. The filter
2899
+ * has to be plain JSON: a value JSON cannot hold (a BigInt, a function, a
2900
+ * number that is not finite, a cycle) makes `subscribe` throw
2901
+ * `invalid_option` before anything is sent.
2902
+ *
2903
+ * The whole subscription frame, filter included, may be at most 16,384
2904
+ * bytes (UTF-8): the cloud closes the connection for a larger one. A filter
2905
+ * of a few dozen conditions fits; many long values in `in` lists may not.
2906
+ * `subscribe` throws `invalid_option` for a frame over that, before anything
2907
+ * is sent, so narrow the filter or follow the collection by `robot`.
2908
+ */
2909
+ filter?: Record<string, unknown>;
2910
+ /**
2911
+ * Called when the cloud refuses the subscription (`collection_not_found`
2912
+ * for a collection that does not exist or that the caller may not read,
2913
+ * `forbidden`, `robot_not_attached`, `validation_error` for a filter it
2914
+ * cannot read, `internal_error` when it could not check), and when a
2915
+ * running one ends: `collection_removed` after a publish removed the
2916
+ * collection, or `forbidden` / `robot_not_attached` when a role change or a
2917
+ * detached robot no longer allows it. The subscription is over then and
2918
+ * delivers nothing more; subscribe again to follow the collection.
2919
+ *
2920
+ * Also called, without ending the subscription, when the channel cannot
2921
+ * authenticate at all (`no_session`, for instance) and when the cloud ends
2922
+ * the connection because its credential is no longer valid
2923
+ * (`token_revoked`). Nothing reconnects after that, and the subscription
2924
+ * stays registered: if the app opens the channel again (by signing in and
2925
+ * making a new subscription or command), it is sent again and `onReady`
2926
+ * is called once the cloud has confirmed it.
2927
+ */
2928
+ onError?(error: FleetlessError): void;
2929
+ /**
2930
+ * Called each time the cloud has confirmed the subscription: the first time
2931
+ * it is accepted, and again after every reconnect, once the subscription
2932
+ * was sent again on the new connection and accepted. From that moment on
2933
+ * every change the subscription covers reaches `onEvent`, so this is the
2934
+ * place to read the records that exist: call `collections.list` here and
2935
+ * show its result, then apply the events to it. An event can arrive while
2936
+ * the list is still being read, and may or may not be in its result; a
2937
+ * record's `revision` tells a newer state from an older one, so apply an
2938
+ * event only when it is newer than what the list returned for that `id`.
2939
+ *
2940
+ * The same code serves the first load and every later one. The cloud does
2941
+ * not replay what changed while the connection was down, so after a
2942
+ * reconnect the records the app holds may be stale: read them again here
2943
+ * and replace them.
2944
+ *
2945
+ * Not called before the cloud has answered, for a subscription it refuses
2946
+ * (that is `onError`), for one that ended (`unsubscribe`, or `onError` for
2947
+ * an ended one), nor when the app ends the subscription before the answer
2948
+ * arrives. A cloud that does not know this answer never calls it.
2949
+ */
2950
+ onReady?(): void;
2951
+ /**
2952
+ * Called with the schema version now in force when a developer publishes or
2953
+ * restores the app's collections. Rights, fields and collections may have
2954
+ * changed: read `collections.definitions` again.
2955
+ */
2956
+ onSchemaPublished?(version: number): void;
2957
+ }
2958
+
2959
+ /**
2960
+ * One record of a collection: its system fields (`id`, `robot_id`, who made
2961
+ * it and when, `revision`), `display` (the collection's display template
2962
+ * filled in for this record), `missing_required` (required fields that are
2963
+ * empty because the schema changed after the record was written; absent when
2964
+ * nothing is missing) and `values`, the record's own fields by key. A field
2965
+ * without a value is absent from `values`. With `expand`, a reference field
2966
+ * holds the referenced record in this same shape instead of its id, when the
2967
+ * caller may read that collection.
2968
+ *
2969
+ * The wire shape is contracts' `collectionRecord`; the alias exists so the
2970
+ * reference can describe it.
2971
+ */
2972
+ type CollectionRecord = CollectionRecord$1;
2973
+ /**
2974
+ * One change in the history of a record: `seq` (the position to page and
2975
+ * restore by), the operation (`create`, `update`, `delete` or `restore`), the
2976
+ * actor, `reason` (`schema v5`, `import`, `restore v4`, or `null` for an
2977
+ * ordinary write), the record's `revision` afterwards, `changes` (each touched
2978
+ * field with its old and new value) and, on a `delete`, the whole record.
2979
+ *
2980
+ * The wire shape is contracts' `collectionRevision`.
2981
+ */
2982
+ type CollectionRevision = CollectionRevision$1;
2983
+ /**
2984
+ * A collection as the caller may use it, from `collections.definitions`:
2985
+ * `key`, `label`, `description`, `binding` (`global`, `per_robot` or
2986
+ * `one_per_robot`), the `display` template, every field's definition under
2987
+ * `fields`, and `can`, what the caller may do with the records (`read`,
2988
+ * `create`, and for `update` and `delete` `'all'`, `'own'` or `false`) — the
2989
+ * answer to "which buttons do I draw".
2990
+ *
2991
+ * The wire shape is one entry of `collections` in contracts'
2992
+ * `collectionDefinitionsResponse`.
2993
+ */
2994
+ type CollectionDefinition = CollectionDefinitionsResponse['collections'][number];
2995
+ /**
2996
+ * What `collections.definitions` resolves with: `collections`, the collections
2997
+ * the caller may read (see `CollectionDefinition`), and `version`, the schema
2998
+ * version they belong to, `null` while the app has published none. Compare it
2999
+ * with the version `onSchemaPublished` hands over to tell whether what you hold
3000
+ * is current.
3001
+ *
3002
+ * The wire shape is contracts' `collectionDefinitionsResponse`.
3003
+ */
3004
+ type CollectionDefinitions = CollectionDefinitionsResponse;
3005
+ /**
3006
+ * What `collections.list` reads. Every field is optional; the wire names are
3007
+ * snake_case or encoded (`filter` is JSON text, `sort` and `expand` are
3008
+ * comma-separated) and this SDK spells them the way its other options are
3009
+ * spelt, leaving out whatever the caller did not set.
3010
+ */
3011
+ interface CollectionListOptions {
3012
+ /**
3013
+ * Words that must all occur, in any letter case, in at least one searchable
3014
+ * field of the record. At most 10 words, separated by whitespace.
3015
+ */
3016
+ search?: string;
3017
+ /**
3018
+ * A filter: `{ "<field>": { "<op>": value } }`, combined with
3019
+ * `{ and: [...] }` and `{ or: [...] }`. The operators are `eq`, `ne`, `lt`,
3020
+ * `lte`, `gt`, `gte`, `contains`, `in` and `empty`. A field is a field key,
3021
+ * `reference.field` to go one hop through a reference field, or one of the
3022
+ * system fields `id`, `robot_id`, `created_at`, `updated_at` and
3023
+ * `created_by`. Nested at most 3 levels, 50 conditions in all. A filter the
3024
+ * cloud cannot read rejects `validation_error` naming the part that is wrong.
3025
+ * The filter has to be plain JSON; a reactive proxy (Vue, Svelte, MobX) is
3026
+ * fine, and a value JSON cannot hold (a BigInt, a function, a number that is
3027
+ * not finite, a cycle) rejects `invalid_option` before anything is sent.
3028
+ */
3029
+ filter?: Record<string, unknown>;
3030
+ /**
3031
+ * Up to 3 fields to sort by, a leading `-` for descending, for example
3032
+ * `['-created_at']`. Ties are broken by `id`, so a page boundary is exact.
3033
+ */
3034
+ sort?: string[];
3035
+ /** How many records to return, 1 to 500; absent means 50. Above the cap the cloud refuses with `validation_error` rather than trimming. */
3036
+ limit?: number;
3037
+ /** The previous page's `nextCursor`. Send it back rather than computing one; it stays valid while records are written. */
3038
+ cursor?: string;
3039
+ /** `true` makes the page carry `total`, the number of records that match. */
3040
+ count?: boolean;
3041
+ /** Reference fields to embed as records instead of ids, one hop. A record is embedded only when the caller may read its collection; otherwise the id stays. */
3042
+ expand?: string[];
3043
+ /** Only the records of this robot, in a collection that belongs to robots. */
3044
+ robot?: string;
3045
+ /** `true` lists deleted records instead, newest deletion first. Needs the right to create records in the collection. */
3046
+ deleted?: boolean;
3047
+ }
3048
+ /**
3049
+ * One page of `collections.list`.
3050
+ *
3051
+ * **Page until `nextCursor` is `null`, never until a page looks short.** The
3052
+ * cloud only knows a page is the last one when there is nothing behind it.
3053
+ */
3054
+ interface CollectionPage {
3055
+ /** The records of this page, in the requested order. */
3056
+ records: CollectionRecord[];
3057
+ /** Pass it as `cursor` to read the next page; `null` on the last page. */
3058
+ nextCursor: string | null;
3059
+ /** The number of records that match the whole query. Present only when the call asked for it with `count: true`. */
3060
+ total?: number;
3061
+ }
3062
+ /** The window of `collections.history`: both fields optional, newest revisions first. */
3063
+ interface CollectionHistoryOptions {
3064
+ /** How many revisions to return, 1 to 500. */
3065
+ limit?: number;
3066
+ /** The previous page's `nextBeforeSeq`: only revisions older than this `seq`. */
3067
+ beforeSeq?: number;
3068
+ }
3069
+ /**
3070
+ * One page of a record's history, newest revision first. `purged` is set when
3071
+ * an organization owner removed the older part of the history: it starts with
3072
+ * a note saying which revisions went, who removed them and when.
3073
+ */
3074
+ interface CollectionHistoryPage {
3075
+ /** The revisions of this page, newest first. */
3076
+ revisions: CollectionRevision[];
3077
+ /** Pass it as `beforeSeq` to read older revisions; `null` when there are none. */
3078
+ nextBeforeSeq: number | null;
3079
+ /** The removal of the older history, or `null` when none happened. `by` is the owner who removed it, an actor with a `label` like a record's `created_by`. */
3080
+ purged: CollectionRecordHistoryResponse['purged'];
3081
+ }
3082
+ /**
3083
+ * The records of an app's collections, reachable as `client.collections`: the
3084
+ * app's own data model, written by a developer as a schema in the console and
3085
+ * read and written here with the caller's role.
3086
+ *
3087
+ * Every call is checked against the caller's rights on the collection and,
3088
+ * for a collection that belongs to robots, against the robots the caller
3089
+ * reaches. A collection the caller may not read at all rejects
3090
+ * `collection_not_found`, exactly as one that does not exist; one the caller
3091
+ * may read but not write rejects `forbidden`. The refusals specific to
3092
+ * records keep the cloud's codes, with `error.details` in the shape each
3093
+ * exported schema describes:
3094
+ *
3095
+ * - `required_missing` (400): `requiredMissingDetails` — the required fields left empty.
3096
+ * - `reference_invalid` (400): `referenceInvalidDetails` — the reference field and why it was refused.
3097
+ * - `record_changed` (409): `recordChangedDetails` — the revision the record is at now.
3098
+ * - `record_referenced` (409): `recordReferencedDetails` — the collections that still point at the record, with counts.
3099
+ * - `validation_error` (400) and `plan_limit` (409) as elsewhere.
3100
+ * - `rate_limited` (429): `RateLimitDetails` — `retry_after_ms`, how long to wait before writing again. Surfaced, never retried.
3101
+ */
3102
+ interface CollectionsApi {
3103
+ /**
3104
+ * The collections the caller may read, with their field definitions and
3105
+ * what the caller may do with each — what a screen needs to draw a list or
3106
+ * a form without hard-coding the schema — and the schema `version` they
3107
+ * belong to. `collections` is `[]` for an app that has published none, or
3108
+ * whose roles grant this caller none.
3109
+ *
3110
+ * The schema can change under a running app; a realtime subscription's
3111
+ * `onSchemaPublished` says when to read this again, and hands over the
3112
+ * version to compare with.
3113
+ */
3114
+ definitions(): Promise<CollectionDefinitions>;
3115
+ /**
3116
+ * One page of a collection's records, filtered, searched and sorted by the
3117
+ * cloud. In a collection that belongs to robots the caller sees only the
3118
+ * records of robots they reach.
3119
+ *
3120
+ * Rejects `invalid_option`, before anything is sent, for a `filter` that is
3121
+ * not plain JSON.
3122
+ */
3123
+ list(collection: string, options?: CollectionListOptions): Promise<CollectionPage>;
3124
+ /**
3125
+ * One record by id. Rejects `not_found` when there is no such record or
3126
+ * the caller may not see it. `expand` embeds reference fields, one hop.
3127
+ */
3128
+ get(collection: string, id: string, options?: {
3129
+ expand?: string[];
3130
+ }): Promise<CollectionRecord>;
3131
+ /**
3132
+ * The record of one robot in a `one_per_robot` collection, which always
3133
+ * has exactly one. Rejects `robot_not_attached` when the robot is not
3134
+ * attached to the app or the caller does not reach it, and `not_found`
3135
+ * when the collection holds no record for it. Use it on a `one_per_robot`
3136
+ * collection only: on a `per_robot` collection, which holds many records
3137
+ * per robot, it returns the first of them.
3138
+ */
3139
+ get(collection: string, by: {
3140
+ robot: string;
3141
+ }, options?: {
3142
+ expand?: string[];
3143
+ }): Promise<CollectionRecord>;
3144
+ /**
3145
+ * Creates a record. `values` holds the fields by key and must set every
3146
+ * required one. A collection that belongs to robots takes `robot`, the id
3147
+ * of the robot the record belongs to, which cannot change afterwards.
3148
+ * Rejects `required_missing`, `reference_invalid` or `validation_error`
3149
+ * for values the schema refuses, and `plan_limit` when the organization is
3150
+ * at its record or storage limit. A `one_per_robot` collection takes no
3151
+ * creates (`validation_error`): the platform keeps one record for every
3152
+ * attached robot already.
3153
+ */
3154
+ create(collection: string, values: Record<string, unknown>, options?: {
3155
+ robot?: string;
3156
+ }): Promise<CollectionRecord>;
3157
+ /**
3158
+ * Changes the fields in `values` and leaves the others alone; a `null`
3159
+ * clears a field. With `expectedRevision` (the `revision` you last read)
3160
+ * the write is refused with `record_changed` if the record has moved on, so
3161
+ * two editors do not silently overwrite each other.
3162
+ */
3163
+ update(collection: string, id: string, values: Record<string, unknown>, options?: {
3164
+ expectedRevision?: number;
3165
+ }): Promise<CollectionRecord>;
3166
+ /**
3167
+ * Deletes a record; its history is kept. Rejects `record_referenced` while
3168
+ * a record of another collection points at it with `on_delete: prevent`.
3169
+ * A `one_per_robot` collection takes no deletes (`validation_error`).
3170
+ */
3171
+ delete(collection: string, id: string): Promise<void>;
3172
+ /**
3173
+ * A record's history, newest revision first. Needs the right to update the
3174
+ * record.
3175
+ */
3176
+ history(collection: string, id: string, options?: CollectionHistoryOptions): Promise<CollectionHistoryPage>;
3177
+ /**
3178
+ * Follows a collection's changes live over the client's realtime channel:
3179
+ * `onEvent` is called for every record that is created, updated, deleted,
3180
+ * or comes into or leaves the view of this subscription (see
3181
+ * `CollectionEvent`). `options.robot` and `options.filter` narrow it; the
3182
+ * caller's rights are checked on every event, not only when subscribing.
3183
+ *
3184
+ * **There is no first snapshot, but the cloud confirms the subscription.**
3185
+ * Once it has accepted and registered it, `options.onReady` is called, and
3186
+ * from then on every change reaches `onEvent`. To show the records that
3187
+ * exist, `list` in `onReady`, so that no change can fall between the list
3188
+ * and the events; then apply the events to what the list returned. A
3189
+ * refusal is answered through `options.onError` and `onReady` is not called.
3190
+ *
3191
+ * Opens the channel if it is not open, and subscribes again by itself after
3192
+ * every reconnect. Changes made while the connection was down are not
3193
+ * replayed, but `onReady` is called again once the cloud has confirmed the
3194
+ * subscription on the new connection: the same `list` in the same place
3195
+ * refreshes what the app holds.
3196
+ *
3197
+ * Returns the function that ends the subscription. It is safe to call more
3198
+ * than once, and after the cloud ended the subscription itself.
3199
+ *
3200
+ * Throws `invalid_option`, before anything is sent, for a `filter` that is
3201
+ * not plain JSON, and for a subscription whose frame, with its filter, is
3202
+ * larger than the 16,384 bytes the cloud takes.
3203
+ */
3204
+ subscribe(collection: string, options: CollectionSubscribeOptions, onEvent: (event: CollectionEvent) => void): () => void;
3205
+ }
3206
+
2305
3207
  /**
2306
3208
  * The callbacks `datapoints.subscribe` reports through: one for values, one
2307
3209
  * for a refusal. `onEvent` fires immediately with the current value and
@@ -2735,6 +3637,8 @@ interface FleetlessClient {
2735
3637
  readonly assets: AssetsApi;
2736
3638
  /** Which robots this caller reaches, and what their role lets them do on each — the calls every screen starts from. */
2737
3639
  readonly robots: RobotsApi;
3640
+ /** The app's own data: the records of the collections a developer defined, read and written with the caller's role, and followed live. */
3641
+ readonly collections: CollectionsApi;
2738
3642
  /**
2739
3643
  * Closes the realtime channel and stops it from reconnecting. Safe with
2740
3644
  * no subscription ever made, and safe to call twice. A Node script (the
@@ -2760,4 +3664,4 @@ interface FleetlessClient {
2760
3664
  */
2761
3665
  declare function createClient(options: FleetlessClientOptions): FleetlessClient;
2762
3666
 
2763
- export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BeginTwoFactorSetupOptions, type BusyDetails, CANCEL_RETURN_CODES, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type CancelRejectedDetails, type CancelReturnCode, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type ClientRobotListItem, type CompleteOidcLoginOptions, type ConfirmTwoFactorSetupOptions, type CreateMeshLoaderOptions, type CredentialSource, type DatapointEvent, type DatapointSubscription, type DatapointSubscriptionHandlers, type DatapointValue, type DatapointsApi, type FleetlessClient, type FleetlessClientConfig, type FleetlessClientOptions, FleetlessError, type FleetlessErrorCode, type FleetlessErrorOptions, type HistoryAggregation, type HistoryBucketsResponse, type HistoryOptions, type HistorySamplesResponse, InMemoryTokenStore, type InvokeOptions, type Job, type JobEvent, type JobHistoryOptions, type JobOrigin, type JobRun, type JobRunListResponse, type JobState, type JobSubscription, type JobSubscriptionHandlers, type JobsApi, type McpCapabilities, type McpConsentGrant, type McpExposure, type McpInteractionDecision, type McpRobotDatasheet, type MeshLoaderDelegate, type OidcLoginRequest, type ParameterInvalidDetails, type ParameterViolation, type PrepareUrdfSceneOptions, type ProviderButton, type PublishersApi, type RateLimitDetails, type RegisterOptions, type RobotsApi, SDK_ERROR_CODES, type SdkErrorCode, type SendCommandOptions, type ServicesApi, type SignInMethods, type SignInResult, type StoredSession, type TokenStore, type TwoFactorSetup, type TwoFactorSetupConfirmation, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, type VerifyTwoFactorOptions, cancelRejectedDetails, createClient, parameterInvalidDetails };
3667
+ export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BeginTwoFactorSetupOptions, type BusyDetails, CANCEL_RETURN_CODES, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type CancelRejectedDetails, type CancelReturnCode, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type ClientRobotListItem, type CollectionActor, type CollectionBinding, type CollectionDefinition, type CollectionDefinitions, type CollectionEvent, type CollectionField, type CollectionHistoryOptions, type CollectionHistoryPage, type CollectionListOptions, type CollectionPage, type CollectionRecord, type CollectionRevision, type CollectionSubscribeOptions, type CollectionsApi, type CompleteOidcLoginOptions, type ConfirmTwoFactorSetupOptions, type CreateMeshLoaderOptions, type CredentialSource, type DatapointEvent, type DatapointSubscription, type DatapointSubscriptionHandlers, type DatapointValue, type DatapointsApi, type FleetlessClient, type FleetlessClientConfig, type FleetlessClientOptions, FleetlessError, type FleetlessErrorCode, type FleetlessErrorOptions, type HistoryAggregation, type HistoryBucketsResponse, type HistoryOptions, type HistorySamplesResponse, InMemoryTokenStore, type InvokeOptions, type Job, type JobEvent, type JobHistoryOptions, type JobOrigin, type JobRun, type JobRunListResponse, type JobState, type JobSubscription, type JobSubscriptionHandlers, type JobsApi, type McpCapabilities, type McpConsentGrant, type McpExposure, type McpInteractionDecision, type McpRobotDatasheet, type MeshLoaderDelegate, type OidcLoginRequest, type ParameterInvalidDetails, type ParameterViolation, type PrepareUrdfSceneOptions, type ProviderButton, type PublishersApi, type RateLimitDetails, type RecordChangedDetails, type RecordReferencedDetails, type ReferenceInvalidDetails, type RegisterOptions, type RequiredMissingDetails, type RobotsApi, SDK_ERROR_CODES, type SdkErrorCode, type SendCommandOptions, type ServicesApi, type SignInMethods, type SignInResult, type StoredSession, type TokenStore, type TwoFactorSetup, type TwoFactorSetupConfirmation, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, type VerifyTwoFactorOptions, cancelRejectedDetails, createClient, parameterInvalidDetails, recordChangedDetails, recordReferencedDetails, referenceInvalidDetails, requiredMissingDetails };