@fleetless/sdk 5.0.0 → 5.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/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
  /**
@@ -873,14 +937,492 @@ declare const cancelRejectedDetails: z.ZodObject<{
873
937
  }, z.core.$strip>>;
874
938
  }, z.core.$strip>;
875
939
  type CancelRejectedDetails = z.infer<typeof cancelRejectedDetails>;
940
+ /**
941
+ * The `details` of a `409 record_referenced` refusal. Counts only: the caller
942
+ * may not be allowed to read the records that point here, so neither their
943
+ * ids nor their values are told. Nor is the key of a collection the caller may
944
+ * not read, for the reason `collection_not_found` is answered for one: the list
945
+ * names only collections the caller may read, and it is empty when every
946
+ * collection that points here is one they may not.
947
+ */
948
+ declare const recordReferencedDetails: z.ZodObject<{
949
+ references: z.ZodArray<z.ZodObject<{
950
+ collection: z.ZodString;
951
+ count: z.ZodNumber;
952
+ }, z.core.$strict>>;
953
+ }, z.core.$strict>;
954
+ type RecordReferencedDetails = z.infer<typeof recordReferencedDetails>;
955
+ /** The `details` of a `409 record_changed` refusal: the revision the record is at now, for the caller to read it again. */
956
+ declare const recordChangedDetails: z.ZodObject<{
957
+ revision: z.ZodNumber;
958
+ }, z.core.$strict>;
959
+ type RecordChangedDetails = z.infer<typeof recordChangedDetails>;
960
+ /** The `details` of a `400 reference_invalid` refusal: which reference field, and why its value was refused. */
961
+ declare const referenceInvalidDetails: z.ZodObject<{
962
+ field: z.ZodString;
963
+ reason: z.ZodEnum<{
964
+ missing: "missing";
965
+ other_robot: "other_robot";
966
+ not_readable: "not_readable";
967
+ }>;
968
+ }, z.core.$strict>;
969
+ type ReferenceInvalidDetails = z.infer<typeof referenceInvalidDetails>;
970
+ /** The `details` of a `400 required_missing` refusal: every required field the write would leave empty. */
971
+ declare const requiredMissingDetails: z.ZodObject<{
972
+ fields: z.ZodArray<z.ZodString>;
973
+ }, z.core.$strict>;
974
+ type RequiredMissingDetails = z.infer<typeof requiredMissingDetails>;
876
975
  /**
877
976
  * The codes in use today. The wire deliberately allows any string — this
878
977
  * list is the shared vocabulary, not a closed set, so a new refusal never
879
978
  * needs a contracts release before it can be reported honestly.
880
979
  */
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"];
980
+ 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", "record_referenced", "record_changed", "collection_not_found", "collection_removed", "reference_invalid", "required_missing", "robot_not_attached"];
882
981
  type ErrorCode = (typeof ERROR_CODES)[number];
883
982
 
983
+
984
+ /**
985
+ * How a collection relates to robots. A property of the collection and not a
986
+ * field type, so a record's robot can neither be left out of a robot-bound
987
+ * collection nor changed afterwards.
988
+ */
989
+ declare const collectionBinding: z.ZodEnum<{
990
+ global: "global";
991
+ per_robot: "per_robot";
992
+ one_per_robot: "one_per_robot";
993
+ }>;
994
+ type CollectionBinding = z.infer<typeof collectionBinding>;
995
+ /**
996
+ * One field definition, discriminated on `type`. A union and not one object
997
+ * with every option optional: `max_length` on a `number` would otherwise parse
998
+ * and mean nothing.
999
+ */
1000
+ declare const collectionField: z.ZodDiscriminatedUnion<[z.ZodObject<{
1001
+ max_length: z.ZodOptional<z.ZodNumber>;
1002
+ pattern: z.ZodOptional<z.ZodString>;
1003
+ searchable: z.ZodOptional<z.ZodBoolean>;
1004
+ label: z.ZodOptional<z.ZodString>;
1005
+ description: z.ZodOptional<z.ZodString>;
1006
+ required: z.ZodOptional<z.ZodBoolean>;
1007
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1008
+ default: z.ZodOptional<z.ZodUnknown>;
1009
+ type: z.ZodLiteral<"text">;
1010
+ }, z.core.$strict>, z.ZodObject<{
1011
+ max_length: z.ZodOptional<z.ZodNumber>;
1012
+ searchable: z.ZodOptional<z.ZodBoolean>;
1013
+ label: z.ZodOptional<z.ZodString>;
1014
+ description: z.ZodOptional<z.ZodString>;
1015
+ required: z.ZodOptional<z.ZodBoolean>;
1016
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1017
+ default: z.ZodOptional<z.ZodUnknown>;
1018
+ type: z.ZodLiteral<"long_text">;
1019
+ }, z.core.$strict>, z.ZodObject<{
1020
+ integer: z.ZodOptional<z.ZodBoolean>;
1021
+ min: z.ZodOptional<z.ZodNumber>;
1022
+ max: z.ZodOptional<z.ZodNumber>;
1023
+ unit: z.ZodOptional<z.ZodString>;
1024
+ label: z.ZodOptional<z.ZodString>;
1025
+ description: z.ZodOptional<z.ZodString>;
1026
+ required: z.ZodOptional<z.ZodBoolean>;
1027
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1028
+ default: z.ZodOptional<z.ZodUnknown>;
1029
+ type: z.ZodLiteral<"number">;
1030
+ }, z.core.$strict>, z.ZodObject<{
1031
+ label: z.ZodOptional<z.ZodString>;
1032
+ description: z.ZodOptional<z.ZodString>;
1033
+ required: z.ZodOptional<z.ZodBoolean>;
1034
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1035
+ default: z.ZodOptional<z.ZodUnknown>;
1036
+ type: z.ZodLiteral<"boolean">;
1037
+ }, z.core.$strict>, z.ZodObject<{
1038
+ options: z.ZodArray<z.ZodObject<{
1039
+ value: z.ZodString;
1040
+ label: z.ZodOptional<z.ZodString>;
1041
+ }, z.core.$strict>>;
1042
+ multiple: z.ZodOptional<z.ZodBoolean>;
1043
+ searchable: z.ZodOptional<z.ZodBoolean>;
1044
+ label: z.ZodOptional<z.ZodString>;
1045
+ description: z.ZodOptional<z.ZodString>;
1046
+ required: z.ZodOptional<z.ZodBoolean>;
1047
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1048
+ default: z.ZodOptional<z.ZodUnknown>;
1049
+ type: z.ZodLiteral<"select">;
1050
+ }, z.core.$strict>, z.ZodObject<{
1051
+ label: z.ZodOptional<z.ZodString>;
1052
+ description: z.ZodOptional<z.ZodString>;
1053
+ required: z.ZodOptional<z.ZodBoolean>;
1054
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1055
+ default: z.ZodOptional<z.ZodUnknown>;
1056
+ type: z.ZodLiteral<"date">;
1057
+ }, z.core.$strict>, z.ZodObject<{
1058
+ label: z.ZodOptional<z.ZodString>;
1059
+ description: z.ZodOptional<z.ZodString>;
1060
+ required: z.ZodOptional<z.ZodBoolean>;
1061
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1062
+ default: z.ZodOptional<z.ZodUnknown>;
1063
+ type: z.ZodLiteral<"datetime">;
1064
+ }, z.core.$strict>, z.ZodObject<{
1065
+ schema: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
1066
+ label: z.ZodOptional<z.ZodString>;
1067
+ description: z.ZodOptional<z.ZodString>;
1068
+ required: z.ZodOptional<z.ZodBoolean>;
1069
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1070
+ default: z.ZodOptional<z.ZodUnknown>;
1071
+ type: z.ZodLiteral<"json">;
1072
+ }, z.core.$strict>, z.ZodObject<{
1073
+ to: z.ZodString;
1074
+ on_delete: z.ZodOptional<z.ZodEnum<{
1075
+ prevent: "prevent";
1076
+ clear: "clear";
1077
+ }>>;
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<"reference">;
1084
+ }, z.core.$strict>], "type">;
1085
+ type CollectionField = z.infer<typeof collectionField>;
1086
+
1087
+
1088
+ /**
1089
+ * Who made a change. `fleetless` is the platform itself (a schema change, an
1090
+ * automatic record) and always carries the nil id. `label` is worked out when
1091
+ * the record is read, from the person's display name, so a user who has since
1092
+ * been deleted reads `Deleted user` instead of leaving the record with a
1093
+ * dangling id. An email address is the fallback only for a reader who may see
1094
+ * it: a developer or a server key reading a person without a name, and an app
1095
+ * user reading their own label.
1096
+ */
1097
+ declare const collectionActor: z.ZodObject<{
1098
+ kind: z.ZodEnum<{
1099
+ developer: "developer";
1100
+ fleetless: "fleetless";
1101
+ server_key: "server_key";
1102
+ app_user: "app_user";
1103
+ }>;
1104
+ id: z.ZodUUID;
1105
+ label: z.ZodString;
1106
+ }, z.core.$strip>;
1107
+ type CollectionActor = z.infer<typeof collectionActor>;
1108
+ /**
1109
+ * One record. `display` is the collection's display template rendered for this
1110
+ * record, so a list can name its rows without knowing the template.
1111
+ */
1112
+ declare const collectionRecord: z.ZodObject<{
1113
+ id: z.ZodUUID;
1114
+ robot_id: z.ZodNullable<z.ZodUUID>;
1115
+ created_at: z.ZodISODateTime;
1116
+ created_by: z.ZodObject<{
1117
+ kind: z.ZodEnum<{
1118
+ developer: "developer";
1119
+ fleetless: "fleetless";
1120
+ server_key: "server_key";
1121
+ app_user: "app_user";
1122
+ }>;
1123
+ id: z.ZodUUID;
1124
+ label: z.ZodString;
1125
+ }, z.core.$strip>;
1126
+ updated_at: z.ZodISODateTime;
1127
+ updated_by: z.ZodObject<{
1128
+ kind: z.ZodEnum<{
1129
+ developer: "developer";
1130
+ fleetless: "fleetless";
1131
+ server_key: "server_key";
1132
+ app_user: "app_user";
1133
+ }>;
1134
+ id: z.ZodUUID;
1135
+ label: z.ZodString;
1136
+ }, z.core.$strip>;
1137
+ revision: z.ZodNumber;
1138
+ display: z.ZodString;
1139
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
1140
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1141
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
1142
+ deleted_by: z.ZodOptional<z.ZodObject<{
1143
+ kind: z.ZodEnum<{
1144
+ developer: "developer";
1145
+ fleetless: "fleetless";
1146
+ server_key: "server_key";
1147
+ app_user: "app_user";
1148
+ }>;
1149
+ id: z.ZodUUID;
1150
+ label: z.ZodString;
1151
+ }, z.core.$strip>>;
1152
+ }, z.core.$strip>;
1153
+ type CollectionRecord$1 = z.infer<typeof collectionRecord>;
1154
+ /**
1155
+ * One entry of a record's history. `changes` holds each changed field with its
1156
+ * old and new value, `null` standing for no value. A `delete` revision carries
1157
+ * the whole record so that a deleted record can be seen and brought back.
1158
+ */
1159
+ declare const collectionRevision: z.ZodObject<{
1160
+ seq: z.ZodNumber;
1161
+ op: z.ZodEnum<{
1162
+ create: "create";
1163
+ update: "update";
1164
+ delete: "delete";
1165
+ restore: "restore";
1166
+ }>;
1167
+ at: z.ZodISODateTime;
1168
+ actor: z.ZodObject<{
1169
+ kind: z.ZodEnum<{
1170
+ developer: "developer";
1171
+ fleetless: "fleetless";
1172
+ server_key: "server_key";
1173
+ app_user: "app_user";
1174
+ }>;
1175
+ id: z.ZodUUID;
1176
+ label: z.ZodString;
1177
+ }, z.core.$strip>;
1178
+ reason: z.ZodNullable<z.ZodString>;
1179
+ revision: z.ZodNumber;
1180
+ changes: z.ZodRecord<z.ZodString, z.ZodObject<{
1181
+ old: z.ZodUnknown;
1182
+ new: z.ZodUnknown;
1183
+ }, z.core.$strip>>;
1184
+ record: z.ZodNullable<z.ZodObject<{
1185
+ id: z.ZodUUID;
1186
+ robot_id: z.ZodNullable<z.ZodUUID>;
1187
+ created_at: z.ZodISODateTime;
1188
+ created_by: z.ZodObject<{
1189
+ kind: z.ZodEnum<{
1190
+ developer: "developer";
1191
+ fleetless: "fleetless";
1192
+ server_key: "server_key";
1193
+ app_user: "app_user";
1194
+ }>;
1195
+ id: z.ZodUUID;
1196
+ label: z.ZodString;
1197
+ }, z.core.$strip>;
1198
+ updated_at: z.ZodISODateTime;
1199
+ updated_by: z.ZodObject<{
1200
+ kind: z.ZodEnum<{
1201
+ developer: "developer";
1202
+ fleetless: "fleetless";
1203
+ server_key: "server_key";
1204
+ app_user: "app_user";
1205
+ }>;
1206
+ id: z.ZodUUID;
1207
+ label: z.ZodString;
1208
+ }, z.core.$strip>;
1209
+ revision: z.ZodNumber;
1210
+ display: z.ZodString;
1211
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
1212
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1213
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
1214
+ deleted_by: z.ZodOptional<z.ZodObject<{
1215
+ kind: z.ZodEnum<{
1216
+ developer: "developer";
1217
+ fleetless: "fleetless";
1218
+ server_key: "server_key";
1219
+ app_user: "app_user";
1220
+ }>;
1221
+ id: z.ZodUUID;
1222
+ label: z.ZodString;
1223
+ }, z.core.$strip>>;
1224
+ }, z.core.$strip>>;
1225
+ }, z.core.$strip>;
1226
+ type CollectionRevision$1 = z.infer<typeof collectionRevision>;
1227
+ declare const collectionRecordHistoryResponse: z.ZodObject<{
1228
+ revisions: z.ZodArray<z.ZodObject<{
1229
+ seq: z.ZodNumber;
1230
+ op: z.ZodEnum<{
1231
+ create: "create";
1232
+ update: "update";
1233
+ delete: "delete";
1234
+ restore: "restore";
1235
+ }>;
1236
+ at: z.ZodISODateTime;
1237
+ actor: z.ZodObject<{
1238
+ kind: z.ZodEnum<{
1239
+ developer: "developer";
1240
+ fleetless: "fleetless";
1241
+ server_key: "server_key";
1242
+ app_user: "app_user";
1243
+ }>;
1244
+ id: z.ZodUUID;
1245
+ label: z.ZodString;
1246
+ }, z.core.$strip>;
1247
+ reason: z.ZodNullable<z.ZodString>;
1248
+ revision: z.ZodNumber;
1249
+ changes: z.ZodRecord<z.ZodString, z.ZodObject<{
1250
+ old: z.ZodUnknown;
1251
+ new: z.ZodUnknown;
1252
+ }, z.core.$strip>>;
1253
+ record: z.ZodNullable<z.ZodObject<{
1254
+ id: z.ZodUUID;
1255
+ robot_id: z.ZodNullable<z.ZodUUID>;
1256
+ created_at: z.ZodISODateTime;
1257
+ created_by: z.ZodObject<{
1258
+ kind: z.ZodEnum<{
1259
+ developer: "developer";
1260
+ fleetless: "fleetless";
1261
+ server_key: "server_key";
1262
+ app_user: "app_user";
1263
+ }>;
1264
+ id: z.ZodUUID;
1265
+ label: z.ZodString;
1266
+ }, z.core.$strip>;
1267
+ updated_at: z.ZodISODateTime;
1268
+ updated_by: z.ZodObject<{
1269
+ kind: z.ZodEnum<{
1270
+ developer: "developer";
1271
+ fleetless: "fleetless";
1272
+ server_key: "server_key";
1273
+ app_user: "app_user";
1274
+ }>;
1275
+ id: z.ZodUUID;
1276
+ label: z.ZodString;
1277
+ }, z.core.$strip>;
1278
+ revision: z.ZodNumber;
1279
+ display: z.ZodString;
1280
+ missing_required: z.ZodOptional<z.ZodArray<z.ZodString>>;
1281
+ values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1282
+ deleted_at: z.ZodOptional<z.ZodISODateTime>;
1283
+ deleted_by: z.ZodOptional<z.ZodObject<{
1284
+ kind: z.ZodEnum<{
1285
+ developer: "developer";
1286
+ fleetless: "fleetless";
1287
+ server_key: "server_key";
1288
+ app_user: "app_user";
1289
+ }>;
1290
+ id: z.ZodUUID;
1291
+ label: z.ZodString;
1292
+ }, z.core.$strip>>;
1293
+ }, z.core.$strip>>;
1294
+ }, z.core.$strip>>;
1295
+ next_before_seq: z.ZodNullable<z.ZodNumber>;
1296
+ purged: z.ZodNullable<z.ZodObject<{
1297
+ before: z.ZodISODateTime;
1298
+ by: z.ZodObject<{
1299
+ kind: z.ZodEnum<{
1300
+ developer: "developer";
1301
+ fleetless: "fleetless";
1302
+ server_key: "server_key";
1303
+ app_user: "app_user";
1304
+ }>;
1305
+ id: z.ZodUUID;
1306
+ label: z.ZodString;
1307
+ }, z.core.$strip>;
1308
+ at: z.ZodISODateTime;
1309
+ }, z.core.$strip>>;
1310
+ }, z.core.$strip>;
1311
+ type CollectionRecordHistoryResponse = z.infer<typeof collectionRecordHistoryResponse>;
1312
+ /** The collections the caller can read, with their fields: what a client needs to build a form. */
1313
+ declare const collectionDefinitionsResponse: z.ZodObject<{
1314
+ version: z.ZodNullable<z.ZodNumber>;
1315
+ collections: z.ZodArray<z.ZodObject<{
1316
+ key: z.ZodString;
1317
+ label: z.ZodString;
1318
+ description: z.ZodString;
1319
+ binding: z.ZodEnum<{
1320
+ global: "global";
1321
+ per_robot: "per_robot";
1322
+ one_per_robot: "one_per_robot";
1323
+ }>;
1324
+ display: z.ZodString;
1325
+ fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
1326
+ max_length: z.ZodOptional<z.ZodNumber>;
1327
+ pattern: z.ZodOptional<z.ZodString>;
1328
+ searchable: z.ZodOptional<z.ZodBoolean>;
1329
+ label: z.ZodOptional<z.ZodString>;
1330
+ description: z.ZodOptional<z.ZodString>;
1331
+ required: z.ZodOptional<z.ZodBoolean>;
1332
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1333
+ default: z.ZodOptional<z.ZodUnknown>;
1334
+ type: z.ZodLiteral<"text">;
1335
+ }, z.core.$strict>, z.ZodObject<{
1336
+ max_length: z.ZodOptional<z.ZodNumber>;
1337
+ searchable: z.ZodOptional<z.ZodBoolean>;
1338
+ label: z.ZodOptional<z.ZodString>;
1339
+ description: z.ZodOptional<z.ZodString>;
1340
+ required: z.ZodOptional<z.ZodBoolean>;
1341
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1342
+ default: z.ZodOptional<z.ZodUnknown>;
1343
+ type: z.ZodLiteral<"long_text">;
1344
+ }, z.core.$strict>, z.ZodObject<{
1345
+ integer: z.ZodOptional<z.ZodBoolean>;
1346
+ min: z.ZodOptional<z.ZodNumber>;
1347
+ max: z.ZodOptional<z.ZodNumber>;
1348
+ unit: z.ZodOptional<z.ZodString>;
1349
+ label: z.ZodOptional<z.ZodString>;
1350
+ description: z.ZodOptional<z.ZodString>;
1351
+ required: z.ZodOptional<z.ZodBoolean>;
1352
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1353
+ default: z.ZodOptional<z.ZodUnknown>;
1354
+ type: z.ZodLiteral<"number">;
1355
+ }, z.core.$strict>, z.ZodObject<{
1356
+ label: z.ZodOptional<z.ZodString>;
1357
+ description: z.ZodOptional<z.ZodString>;
1358
+ required: z.ZodOptional<z.ZodBoolean>;
1359
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1360
+ default: z.ZodOptional<z.ZodUnknown>;
1361
+ type: z.ZodLiteral<"boolean">;
1362
+ }, z.core.$strict>, z.ZodObject<{
1363
+ options: z.ZodArray<z.ZodObject<{
1364
+ value: z.ZodString;
1365
+ label: z.ZodOptional<z.ZodString>;
1366
+ }, z.core.$strict>>;
1367
+ multiple: z.ZodOptional<z.ZodBoolean>;
1368
+ searchable: z.ZodOptional<z.ZodBoolean>;
1369
+ label: z.ZodOptional<z.ZodString>;
1370
+ description: z.ZodOptional<z.ZodString>;
1371
+ required: z.ZodOptional<z.ZodBoolean>;
1372
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1373
+ default: z.ZodOptional<z.ZodUnknown>;
1374
+ type: z.ZodLiteral<"select">;
1375
+ }, z.core.$strict>, z.ZodObject<{
1376
+ label: z.ZodOptional<z.ZodString>;
1377
+ description: z.ZodOptional<z.ZodString>;
1378
+ required: z.ZodOptional<z.ZodBoolean>;
1379
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1380
+ default: z.ZodOptional<z.ZodUnknown>;
1381
+ type: z.ZodLiteral<"date">;
1382
+ }, z.core.$strict>, z.ZodObject<{
1383
+ label: z.ZodOptional<z.ZodString>;
1384
+ description: z.ZodOptional<z.ZodString>;
1385
+ required: z.ZodOptional<z.ZodBoolean>;
1386
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1387
+ default: z.ZodOptional<z.ZodUnknown>;
1388
+ type: z.ZodLiteral<"datetime">;
1389
+ }, z.core.$strict>, z.ZodObject<{
1390
+ schema: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
1391
+ label: z.ZodOptional<z.ZodString>;
1392
+ description: z.ZodOptional<z.ZodString>;
1393
+ required: z.ZodOptional<z.ZodBoolean>;
1394
+ unique: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"collection">]>>;
1395
+ default: z.ZodOptional<z.ZodUnknown>;
1396
+ type: z.ZodLiteral<"json">;
1397
+ }, z.core.$strict>, z.ZodObject<{
1398
+ to: z.ZodString;
1399
+ on_delete: z.ZodOptional<z.ZodEnum<{
1400
+ prevent: "prevent";
1401
+ clear: "clear";
1402
+ }>>;
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<"reference">;
1409
+ }, z.core.$strict>], "type">>;
1410
+ can: z.ZodObject<{
1411
+ read: z.ZodBoolean;
1412
+ create: z.ZodBoolean;
1413
+ update: z.ZodUnion<readonly [z.ZodEnum<{
1414
+ all: "all";
1415
+ own: "own";
1416
+ }>, z.ZodLiteral<false>]>;
1417
+ delete: z.ZodUnion<readonly [z.ZodEnum<{
1418
+ all: "all";
1419
+ own: "own";
1420
+ }>, z.ZodLiteral<false>]>;
1421
+ }, z.core.$strip>;
1422
+ }, z.core.$strip>>;
1423
+ }, z.core.$strip>;
1424
+ type CollectionDefinitionsResponse = z.infer<typeof collectionDefinitionsResponse>;
1425
+
884
1426
  /**
885
1427
  * Codes the SDK produces itself rather than relaying from the server. Kept
886
1428
  * out of `@fleetless/contracts`' `ERROR_CODES` deliberately — that list is
@@ -927,9 +1469,17 @@ type ErrorCode = (typeof ERROR_CODES)[number];
927
1469
  * built with a `serverKey` — `register`, `login`, `logout`, the password
928
1470
  * and invitation calls, both OIDC calls, the two MCP decisions and the two
929
1471
  * 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
1472
+ * catch by message. **A fifth:** an id, slug or key that is only dots (`.`
1473
+ * or `..`) in any call that puts one into a path. It cannot name anything,
1474
+ * and as a path segment it would climb out of its route; no spelling of it
1475
+ * survives the URL parser. **A sixth:** a `collections.list` or
1476
+ * `collections.subscribe` `filter` that is not plain JSON (a BigInt, a
1477
+ * function, a number that is not finite, a cycle). **A seventh:** a
1478
+ * `collections.subscribe` whose frame, with its filter, is larger than the
1479
+ * 16,384 bytes the cloud takes on its realtime socket; the cloud would close
1480
+ * the connection for it, and again after every reconnect. All of them are
1481
+ * refused before any request is sent — as a rejection, since those methods
1482
+ * are `async`; `subscribe` is not, so it throws. A client-side mistake to fix, not something a
933
1483
  * server response could ever produce, which is why this code belongs here
934
1484
  * and not in `@fleetless/contracts`' `ERROR_CODES`.
935
1485
  * - `untrusted_absolute_url`: the SDK refused to fetch an absolute URL
@@ -2302,6 +2852,346 @@ interface CamerasApi {
2302
2852
  live(robotId: string, slug: string): Promise<CameraLiveSession>;
2303
2853
  }
2304
2854
 
2855
+ /**
2856
+ * One change to a record, as `collections.subscribe` hands it to its
2857
+ * callback.
2858
+ *
2859
+ * - `event` is `created`, `updated` or `deleted` when the record was written,
2860
+ * and `removed` or `entered` when it left or came into view of this
2861
+ * subscription without being deleted or created: its values stopped or
2862
+ * started matching the subscription's filter, the caller's role lost or
2863
+ * gained the right to read it, or its robot was detached or attached.
2864
+ * - `id` is the record's id.
2865
+ * - `record` is the whole record: as it is now for `created`, `updated`,
2866
+ * `entered` and `removed`, and as it was for `deleted`. It is absent only on
2867
+ * a `removed` event for a record the caller may no longer read, so that its
2868
+ * values are not told; the `id` still is.
2869
+ *
2870
+ * The wire frame is contracts' `collectionEvent`; the SDK hands over the
2871
+ * change itself, without the frame's `type` and `request_id`.
2872
+ */
2873
+ type CollectionEvent = Omit<CollectionEvent$1, 'type' | 'request_id'>;
2874
+ /**
2875
+ * What `collections.subscribe` takes besides the collection and the change
2876
+ * callback. Every field is optional.
2877
+ */
2878
+ interface CollectionSubscribeOptions {
2879
+ /** Only the records of this robot, in a collection that belongs to robots. */
2880
+ robot?: string;
2881
+ /**
2882
+ * Only records matching this filter are delivered. It is the `filter` of
2883
+ * `collections.list` — the same grammar, at most 3 levels and 50
2884
+ * conditions — and a record that stops matching is announced once as
2885
+ * `removed`. The SDK keeps a copy, so changing the object afterwards
2886
+ * changes nothing; a reactive proxy (Vue, Svelte, MobX) is fine. The filter
2887
+ * has to be plain JSON: a value JSON cannot hold (a BigInt, a function, a
2888
+ * number that is not finite, a cycle) makes `subscribe` throw
2889
+ * `invalid_option` before anything is sent.
2890
+ *
2891
+ * The whole subscription frame, filter included, may be at most 16,384
2892
+ * bytes (UTF-8): the cloud closes the connection for a larger one. A filter
2893
+ * of a few dozen conditions fits; many long values in `in` lists may not.
2894
+ * `subscribe` throws `invalid_option` for a frame over that, before anything
2895
+ * is sent, so narrow the filter or follow the collection by `robot`.
2896
+ */
2897
+ filter?: Record<string, unknown>;
2898
+ /**
2899
+ * Called when the cloud refuses the subscription (`collection_not_found`
2900
+ * for a collection that does not exist or that the caller may not read,
2901
+ * `forbidden`, `robot_not_attached`, `validation_error` for a filter it
2902
+ * cannot read, `internal_error` when it could not check), and when a
2903
+ * running one ends: `collection_removed` after a publish removed the
2904
+ * collection, or `forbidden` / `robot_not_attached` when a role change or a
2905
+ * detached robot no longer allows it. The subscription is over then and
2906
+ * delivers nothing more; subscribe again to follow the collection.
2907
+ *
2908
+ * Also called, without ending the subscription, when the channel cannot
2909
+ * authenticate at all (`no_session`, for instance) and when the cloud ends
2910
+ * the connection because its credential is no longer valid
2911
+ * (`token_revoked`). Nothing reconnects after that, and the subscription
2912
+ * stays registered: if the app opens the channel again (by signing in and
2913
+ * making a new subscription or command), it is sent again and `onReady`
2914
+ * is called once the cloud has confirmed it.
2915
+ */
2916
+ onError?(error: FleetlessError): void;
2917
+ /**
2918
+ * Called each time the cloud has confirmed the subscription: the first time
2919
+ * it is accepted, and again after every reconnect, once the subscription
2920
+ * was sent again on the new connection and accepted. From that moment on
2921
+ * every change the subscription covers reaches `onEvent`, so this is the
2922
+ * place to read the records that exist: call `collections.list` here and
2923
+ * show its result, then apply the events to it. An event can arrive while
2924
+ * the list is still being read, and may or may not be in its result; a
2925
+ * record's `revision` tells a newer state from an older one, so apply an
2926
+ * event only when it is newer than what the list returned for that `id`.
2927
+ *
2928
+ * The same code serves the first load and every later one. The cloud does
2929
+ * not replay what changed while the connection was down, so after a
2930
+ * reconnect the records the app holds may be stale: read them again here
2931
+ * and replace them.
2932
+ *
2933
+ * Not called before the cloud has answered, for a subscription it refuses
2934
+ * (that is `onError`), for one that ended (`unsubscribe`, or `onError` for
2935
+ * an ended one), nor when the app ends the subscription before the answer
2936
+ * arrives. A cloud that does not know this answer never calls it.
2937
+ */
2938
+ onReady?(): void;
2939
+ /**
2940
+ * Called with the schema version now in force when a developer publishes or
2941
+ * restores the app's collections. Rights, fields and collections may have
2942
+ * changed: read `collections.definitions` again.
2943
+ */
2944
+ onSchemaPublished?(version: number): void;
2945
+ }
2946
+
2947
+ /**
2948
+ * One record of a collection: its system fields (`id`, `robot_id`, who made
2949
+ * it and when, `revision`), `display` (the collection's display template
2950
+ * filled in for this record), `missing_required` (required fields that are
2951
+ * empty because the schema changed after the record was written; absent when
2952
+ * nothing is missing) and `values`, the record's own fields by key. A field
2953
+ * without a value is absent from `values`. With `expand`, a reference field
2954
+ * holds the referenced record in this same shape instead of its id, when the
2955
+ * caller may read that collection.
2956
+ *
2957
+ * The wire shape is contracts' `collectionRecord`; the alias exists so the
2958
+ * reference can describe it.
2959
+ */
2960
+ type CollectionRecord = CollectionRecord$1;
2961
+ /**
2962
+ * One change in the history of a record: `seq` (the position to page and
2963
+ * restore by), the operation (`create`, `update`, `delete` or `restore`), the
2964
+ * actor, `reason` (`schema v5`, `import`, `restore v4`, or `null` for an
2965
+ * ordinary write), the record's `revision` afterwards, `changes` (each touched
2966
+ * field with its old and new value) and, on a `delete`, the whole record.
2967
+ *
2968
+ * The wire shape is contracts' `collectionRevision`.
2969
+ */
2970
+ type CollectionRevision = CollectionRevision$1;
2971
+ /**
2972
+ * A collection as the caller may use it, from `collections.definitions`:
2973
+ * `key`, `label`, `description`, `binding` (`global`, `per_robot` or
2974
+ * `one_per_robot`), the `display` template, every field's definition under
2975
+ * `fields`, and `can`, what the caller may do with the records (`read`,
2976
+ * `create`, and for `update` and `delete` `'all'`, `'own'` or `false`) — the
2977
+ * answer to "which buttons do I draw".
2978
+ *
2979
+ * The wire shape is one entry of `collections` in contracts'
2980
+ * `collectionDefinitionsResponse`.
2981
+ */
2982
+ type CollectionDefinition = CollectionDefinitionsResponse['collections'][number];
2983
+ /**
2984
+ * What `collections.definitions` resolves with: `collections`, the collections
2985
+ * the caller may read (see `CollectionDefinition`), and `version`, the schema
2986
+ * version they belong to, `null` while the app has published none. Compare it
2987
+ * with the version `onSchemaPublished` hands over to tell whether what you hold
2988
+ * is current.
2989
+ *
2990
+ * The wire shape is contracts' `collectionDefinitionsResponse`.
2991
+ */
2992
+ type CollectionDefinitions = CollectionDefinitionsResponse;
2993
+ /**
2994
+ * What `collections.list` reads. Every field is optional; the wire names are
2995
+ * snake_case or encoded (`filter` is JSON text, `sort` and `expand` are
2996
+ * comma-separated) and this SDK spells them the way its other options are
2997
+ * spelt, leaving out whatever the caller did not set.
2998
+ */
2999
+ interface CollectionListOptions {
3000
+ /**
3001
+ * Words that must all occur, in any letter case, in at least one searchable
3002
+ * field of the record. At most 10 words, separated by whitespace.
3003
+ */
3004
+ search?: string;
3005
+ /**
3006
+ * A filter: `{ "<field>": { "<op>": value } }`, combined with
3007
+ * `{ and: [...] }` and `{ or: [...] }`. The operators are `eq`, `ne`, `lt`,
3008
+ * `lte`, `gt`, `gte`, `contains`, `in` and `empty`. A field is a field key,
3009
+ * `reference.field` to go one hop through a reference field, or one of the
3010
+ * system fields `id`, `robot_id`, `created_at`, `updated_at` and
3011
+ * `created_by`. Nested at most 3 levels, 50 conditions in all. A filter the
3012
+ * cloud cannot read rejects `validation_error` naming the part that is wrong.
3013
+ * The filter has to be plain JSON; a reactive proxy (Vue, Svelte, MobX) is
3014
+ * fine, and a value JSON cannot hold (a BigInt, a function, a number that is
3015
+ * not finite, a cycle) rejects `invalid_option` before anything is sent.
3016
+ */
3017
+ filter?: Record<string, unknown>;
3018
+ /**
3019
+ * Up to 3 fields to sort by, a leading `-` for descending, for example
3020
+ * `['-created_at']`. Ties are broken by `id`, so a page boundary is exact.
3021
+ */
3022
+ sort?: string[];
3023
+ /** How many records to return, 1 to 500; absent means 50. Above the cap the cloud refuses with `validation_error` rather than trimming. */
3024
+ limit?: number;
3025
+ /** The previous page's `nextCursor`. Send it back rather than computing one; it stays valid while records are written. */
3026
+ cursor?: string;
3027
+ /** `true` makes the page carry `total`, the number of records that match. */
3028
+ count?: boolean;
3029
+ /** 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. */
3030
+ expand?: string[];
3031
+ /** Only the records of this robot, in a collection that belongs to robots. */
3032
+ robot?: string;
3033
+ /** `true` lists deleted records instead, newest deletion first. Needs the right to create records in the collection. */
3034
+ deleted?: boolean;
3035
+ }
3036
+ /**
3037
+ * One page of `collections.list`.
3038
+ *
3039
+ * **Page until `nextCursor` is `null`, never until a page looks short.** The
3040
+ * cloud only knows a page is the last one when there is nothing behind it.
3041
+ */
3042
+ interface CollectionPage {
3043
+ /** The records of this page, in the requested order. */
3044
+ records: CollectionRecord[];
3045
+ /** Pass it as `cursor` to read the next page; `null` on the last page. */
3046
+ nextCursor: string | null;
3047
+ /** The number of records that match the whole query. Present only when the call asked for it with `count: true`. */
3048
+ total?: number;
3049
+ }
3050
+ /** The window of `collections.history`: both fields optional, newest revisions first. */
3051
+ interface CollectionHistoryOptions {
3052
+ /** How many revisions to return, 1 to 500. */
3053
+ limit?: number;
3054
+ /** The previous page's `nextBeforeSeq`: only revisions older than this `seq`. */
3055
+ beforeSeq?: number;
3056
+ }
3057
+ /**
3058
+ * One page of a record's history, newest revision first. `purged` is set when
3059
+ * an organization owner removed the older part of the history: it starts with
3060
+ * a note saying which revisions went, who removed them and when.
3061
+ */
3062
+ interface CollectionHistoryPage {
3063
+ /** The revisions of this page, newest first. */
3064
+ revisions: CollectionRevision[];
3065
+ /** Pass it as `beforeSeq` to read older revisions; `null` when there are none. */
3066
+ nextBeforeSeq: number | null;
3067
+ /** 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`. */
3068
+ purged: CollectionRecordHistoryResponse['purged'];
3069
+ }
3070
+ /**
3071
+ * The records of an app's collections, reachable as `client.collections`: the
3072
+ * app's own data model, written by a developer as a schema in the console and
3073
+ * read and written here with the caller's role.
3074
+ *
3075
+ * Every call is checked against the caller's rights on the collection and,
3076
+ * for a collection that belongs to robots, against the robots the caller
3077
+ * reaches. A collection the caller may not read at all rejects
3078
+ * `collection_not_found`, exactly as one that does not exist; one the caller
3079
+ * may read but not write rejects `forbidden`. The refusals specific to
3080
+ * records keep the cloud's codes, with `error.details` in the shape each
3081
+ * exported schema describes:
3082
+ *
3083
+ * - `required_missing` (400): `requiredMissingDetails` — the required fields left empty.
3084
+ * - `reference_invalid` (400): `referenceInvalidDetails` — the reference field and why it was refused.
3085
+ * - `record_changed` (409): `recordChangedDetails` — the revision the record is at now.
3086
+ * - `record_referenced` (409): `recordReferencedDetails` — the collections that still point at the record, with counts.
3087
+ * - `validation_error` (400) and `plan_limit` (409) as elsewhere.
3088
+ * - `rate_limited` (429): `RateLimitDetails` — `retry_after_ms`, how long to wait before writing again. Surfaced, never retried.
3089
+ */
3090
+ interface CollectionsApi {
3091
+ /**
3092
+ * The collections the caller may read, with their field definitions and
3093
+ * what the caller may do with each — what a screen needs to draw a list or
3094
+ * a form without hard-coding the schema — and the schema `version` they
3095
+ * belong to. `collections` is `[]` for an app that has published none, or
3096
+ * whose roles grant this caller none.
3097
+ *
3098
+ * The schema can change under a running app; a realtime subscription's
3099
+ * `onSchemaPublished` says when to read this again, and hands over the
3100
+ * version to compare with.
3101
+ */
3102
+ definitions(): Promise<CollectionDefinitions>;
3103
+ /**
3104
+ * One page of a collection's records, filtered, searched and sorted by the
3105
+ * cloud. In a collection that belongs to robots the caller sees only the
3106
+ * records of robots they reach.
3107
+ *
3108
+ * Rejects `invalid_option`, before anything is sent, for a `filter` that is
3109
+ * not plain JSON.
3110
+ */
3111
+ list(collection: string, options?: CollectionListOptions): Promise<CollectionPage>;
3112
+ /**
3113
+ * One record by id. Rejects `not_found` when there is no such record or
3114
+ * the caller may not see it. `expand` embeds reference fields, one hop.
3115
+ */
3116
+ get(collection: string, id: string, options?: {
3117
+ expand?: string[];
3118
+ }): Promise<CollectionRecord>;
3119
+ /**
3120
+ * The record of one robot in a `one_per_robot` collection, which always
3121
+ * has exactly one. Rejects `robot_not_attached` when the robot is not
3122
+ * attached to the app or the caller does not reach it, and `not_found`
3123
+ * when the collection holds no record for it. Use it on a `one_per_robot`
3124
+ * collection only: on a `per_robot` collection, which holds many records
3125
+ * per robot, it returns the first of them.
3126
+ */
3127
+ get(collection: string, by: {
3128
+ robot: string;
3129
+ }, options?: {
3130
+ expand?: string[];
3131
+ }): Promise<CollectionRecord>;
3132
+ /**
3133
+ * Creates a record. `values` holds the fields by key and must set every
3134
+ * required one. A collection that belongs to robots takes `robot`, the id
3135
+ * of the robot the record belongs to, which cannot change afterwards.
3136
+ * Rejects `required_missing`, `reference_invalid` or `validation_error`
3137
+ * for values the schema refuses, and `plan_limit` when the organization is
3138
+ * at its record or storage limit. A `one_per_robot` collection takes no
3139
+ * creates (`validation_error`): the platform keeps one record for every
3140
+ * attached robot already.
3141
+ */
3142
+ create(collection: string, values: Record<string, unknown>, options?: {
3143
+ robot?: string;
3144
+ }): Promise<CollectionRecord>;
3145
+ /**
3146
+ * Changes the fields in `values` and leaves the others alone; a `null`
3147
+ * clears a field. With `expectedRevision` (the `revision` you last read)
3148
+ * the write is refused with `record_changed` if the record has moved on, so
3149
+ * two editors do not silently overwrite each other.
3150
+ */
3151
+ update(collection: string, id: string, values: Record<string, unknown>, options?: {
3152
+ expectedRevision?: number;
3153
+ }): Promise<CollectionRecord>;
3154
+ /**
3155
+ * Deletes a record; its history is kept. Rejects `record_referenced` while
3156
+ * a record of another collection points at it with `on_delete: prevent`.
3157
+ * A `one_per_robot` collection takes no deletes (`validation_error`).
3158
+ */
3159
+ delete(collection: string, id: string): Promise<void>;
3160
+ /**
3161
+ * A record's history, newest revision first. Needs the right to update the
3162
+ * record.
3163
+ */
3164
+ history(collection: string, id: string, options?: CollectionHistoryOptions): Promise<CollectionHistoryPage>;
3165
+ /**
3166
+ * Follows a collection's changes live over the client's realtime channel:
3167
+ * `onEvent` is called for every record that is created, updated, deleted,
3168
+ * or comes into or leaves the view of this subscription (see
3169
+ * `CollectionEvent`). `options.robot` and `options.filter` narrow it; the
3170
+ * caller's rights are checked on every event, not only when subscribing.
3171
+ *
3172
+ * **There is no first snapshot, but the cloud confirms the subscription.**
3173
+ * Once it has accepted and registered it, `options.onReady` is called, and
3174
+ * from then on every change reaches `onEvent`. To show the records that
3175
+ * exist, `list` in `onReady`, so that no change can fall between the list
3176
+ * and the events; then apply the events to what the list returned. A
3177
+ * refusal is answered through `options.onError` and `onReady` is not called.
3178
+ *
3179
+ * Opens the channel if it is not open, and subscribes again by itself after
3180
+ * every reconnect. Changes made while the connection was down are not
3181
+ * replayed, but `onReady` is called again once the cloud has confirmed the
3182
+ * subscription on the new connection: the same `list` in the same place
3183
+ * refreshes what the app holds.
3184
+ *
3185
+ * Returns the function that ends the subscription. It is safe to call more
3186
+ * than once, and after the cloud ended the subscription itself.
3187
+ *
3188
+ * Throws `invalid_option`, before anything is sent, for a `filter` that is
3189
+ * not plain JSON, and for a subscription whose frame, with its filter, is
3190
+ * larger than the 16,384 bytes the cloud takes.
3191
+ */
3192
+ subscribe(collection: string, options: CollectionSubscribeOptions, onEvent: (event: CollectionEvent) => void): () => void;
3193
+ }
3194
+
2305
3195
  /**
2306
3196
  * The callbacks `datapoints.subscribe` reports through: one for values, one
2307
3197
  * for a refusal. `onEvent` fires immediately with the current value and
@@ -2735,6 +3625,8 @@ interface FleetlessClient {
2735
3625
  readonly assets: AssetsApi;
2736
3626
  /** Which robots this caller reaches, and what their role lets them do on each — the calls every screen starts from. */
2737
3627
  readonly robots: RobotsApi;
3628
+ /** The app's own data: the records of the collections a developer defined, read and written with the caller's role, and followed live. */
3629
+ readonly collections: CollectionsApi;
2738
3630
  /**
2739
3631
  * Closes the realtime channel and stops it from reconnecting. Safe with
2740
3632
  * no subscription ever made, and safe to call twice. A Node script (the
@@ -2760,4 +3652,4 @@ interface FleetlessClient {
2760
3652
  */
2761
3653
  declare function createClient(options: FleetlessClientOptions): FleetlessClient;
2762
3654
 
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 };
3655
+ 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 };