skapi-js 2.0.5 → 2.2.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/skapi.d.ts CHANGED
@@ -85,7 +85,7 @@ type PostRecordConfig = {
85
85
  name?: string;
86
86
  /** Number range: 0 ~ 99. 'public' = 0, 'authorized' = 1, 'admin' = 99. '*' is shorthand for 'private'. Default: 'public' */
87
87
  access_group?: number | 'private' | '*' | 'public' | 'authorized' | 'admin';
88
- /** When true, Record will be only accessible for subscribed users. */
88
+ /** How the record reaches the uploader's subscribers. Signed-in users only. */
89
89
  subscription?: {
90
90
  is_subscription_record?: boolean;
91
91
  upload_to_feed?: boolean;
@@ -94,6 +94,16 @@ type PostRecordConfig = {
94
94
  notify_referencing_records?: boolean;
95
95
  } | null;
96
96
  };
97
+ /**
98
+ * Title and body of the push notification the record's creation sends to the uploader's
99
+ * subscribers with table.subscription.notify_subscribers. Both are required, and together
100
+ * they must fit 3072 bytes. Without it, subscribers get a default text. Ignored on updates
101
+ * and without notify_subscribers.
102
+ */
103
+ notification?: {
104
+ title: string;
105
+ body: string;
106
+ } | null;
97
107
  source?: {
98
108
  referencing_limit?: number;
99
109
  prevent_multiple_referencing?: boolean;
@@ -186,8 +196,9 @@ type RecordData = {
186
196
  name: string;
187
197
  /** Number range: 0 ~ 99 */
188
198
  access_group: number | 'private' | 'public' | 'authorized' | 'admin';
189
- /** User ID of subscription */
199
+ /** Subscription settings of the record. See PostRecordConfig.table.subscription. */
190
200
  subscription?: {
201
+ is_subscription_record: boolean;
191
202
  upload_to_feed: boolean;
192
203
  notify_subscribers: boolean;
193
204
  feed_referencing_records: boolean;
@@ -660,6 +671,393 @@ type Subscription = {
660
671
  get_notified: boolean;
661
672
  get_email: boolean;
662
673
  };
674
+ /**
675
+ * Comparison operator of a ticket condition row, and of `ip` and `user_agent`. The word forms
676
+ * are normalized to the symbols on registration.
677
+ *
678
+ * - '=' and '!=' compare the way JavaScript's === does: true is not 1 and "1" is not 1.
679
+ * - On two numbers, '>', '>=', '<' and '<=' compare numerically.
680
+ * - On two strings, '>=' means "starts with" and '<=' means "ends with". '>' and '<' use plain string order.
681
+ * - A string against a number (or the reverse), a boolean, null or undefined never passes '>', '>=', '<' or '<='.
682
+ * - With a list value, '=' and the ordering operators pass when any member passes. '!=' passes when the value is none of them.
683
+ */
684
+ type TicketConditionOperator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
685
+ /**
686
+ * One row of a ticket condition list: `headers`, `data`, `params` or `user` of a ticket's
687
+ * condition, or `headers`, `data` or `user` of a req action's response condition.
688
+ *
689
+ * How a list decides:
690
+ * - Rows on the same key are alternatives: the key passes when any one of them matches.
691
+ * - Every different key that has a match row (a row with an `operator`) must pass. The first key
692
+ * that does not fails the consumption with CONDITION_FAILED, `detail: { field, keys }`.
693
+ * - A field missing from the request is a mismatch for its key, '!=' included, not an error.
694
+ * The only rows that pass on a missing field are `= undefined` and `!= null`.
695
+ * - Every row is read, in order. For each key the FIRST matching row wins: its `setValueWhenMatch`
696
+ * applies and its `placeholder` captures, and later rows on that key are skipped. A row that
697
+ * does not match captures nothing, so several rows on one key, each with its own
698
+ * `setValueWhenMatch`, followed by a catch-all row, work as a lookup table.
699
+ * - A capture-only row (a `placeholder` and no `operator`) never counts toward passing. It
700
+ * captures whenever its field exists.
701
+ * - Header names ignore case, and header values are always strings. Query string values are
702
+ * JSON-parsed when they parse, otherwise they stay strings: `?qty=2` is the number 2 and
703
+ * `?code=LAUNCH24` the string "LAUNCH24". '=' is strict, so it compares the parsed value: a
704
+ * `params` row needs `value: 2`, not "2", to match `?qty=2`.
705
+ *
706
+ * null and undefined (`data` and `params` rows only, in a response condition too):
707
+ * - `= null` passes when the field is present and null. `!= null` passes otherwise, a missing field included.
708
+ * - `= undefined` passes when the field is missing. `!= undefined` passes when it is present, null included.
709
+ * - '>', '>=', '<' and '<=' never pass with null or undefined.
710
+ * - undefined is a row with an `operator` and no `value` key, which is what `value: undefined` sends.
711
+ * A value list may contain null. undefined is only ever a single value.
712
+ */
713
+ type TicketConditionRow = {
714
+ /**
715
+ * Where the row looks, relative to its own list and written without `${ }`:
716
+ * - `data` rows: a path into the request body. "id" is the body's `id`, "order[id]" is `order.id`.
717
+ * - `params` rows: a path into the query string, read the same way.
718
+ * - `data` rows of a req action's response condition: a path into the response body ("status" is the response's `status`).
719
+ * - `headers` rows: the header name, matched case-insensitively.
720
+ * - `user` rows: the consumer attribute name.
721
+ *
722
+ * Never templated.
723
+ */
724
+ key: string;
725
+ /** Absent on a capture-only row, which has a `placeholder` and no `value`. */
726
+ operator?: TicketConditionOperator;
727
+ /**
728
+ * A literal, never templated. A list is read as described in TicketConditionOperator.
729
+ * null, a list containing null, and undefined (an `operator` with no `value` key) are for
730
+ * `data` and `params` rows only.
731
+ */
732
+ value?: string | number | boolean | null | undefined | Array<string | number | boolean | null>;
733
+ /** `data` and `params` rows only. When this row is the first matching row of its key, the value at `key` in the request data is replaced by this before anything else reads it. null replaces nothing. */
734
+ setValueWhenMatch?: any;
735
+ /**
736
+ * `data` and `params` rows only. Remembers the value at `key` under this name, and the
737
+ * actions read it as `${placeholder[NAME]}`. A match row captures only when it is the first
738
+ * matching row of its key. A field that is missing captures nothing. Must match
739
+ * ^[A-Za-z_][A-Za-z0-9_]*$.
740
+ */
741
+ placeholder?: string;
742
+ };
743
+ /**
744
+ * An HMAC signature over the request, computed with a secret shared with the sender. Verified
745
+ * before anything else runs: the `timestamp` (when set) must be an integer within `tolerance` of
746
+ * now, the bytes described by `signed` are signed with the stored secret (`secret_prefix` removed,
747
+ * then decoded per `secret_encoding`), and the result is compared in constant time against every
748
+ * `${signature}` captured from the header. Any failure is a plain mismatch.
749
+ *
750
+ * Templates (`signed`, `timestamp`) are literal text with these tokens: `${body}` (the raw request
751
+ * body exactly as received), `${method}` (the HTTP method, upper case), `${header:Name}` (a request
752
+ * header, case-insensitive; an absent header fails verification) and any capture from `parts` other
753
+ * than `${signature}`. An unknown token is refused at registration. These tokens exist only in
754
+ * the signature templates: they are not the references actions use (see TicketAction).
755
+ *
756
+ * Public-key signature schemes (RSA, ECDSA, Ed25519) are not supported.
757
+ */
758
+ type TicketSignatureCondition = {
759
+ /**
760
+ * The name of a Secret Key of the project, never the secret itself. Must exist at
761
+ * registration. It is only used to verify the signature: no action sends it, and its
762
+ * Destinations do not limit the ticket's req actions.
763
+ */
764
+ secretName: string;
765
+ /** The request header carrying the signature. Case-insensitive. Up to 256 characters. */
766
+ header: string;
767
+ /** Default 'sha256'. */
768
+ algorithm?: 'sha256' | 'sha1' | 'sha512';
769
+ /** How the signature value in the header is encoded. Default 'hex'. */
770
+ encoding?: 'hex' | 'base64';
771
+ /** Splits the header value into items, each trimmed. 1 to 8 characters. Absent: the whole header value is one item. */
772
+ separator?: string;
773
+ /**
774
+ * Patterns matched against each header item, in order; the first whose literal text fits
775
+ * captures the rest. Each pattern is literal text with at most one `${name}` capture (letters,
776
+ * digits and _; not `body` or `method`). `${signature}` may be captured by several items (any one matching passes) and
777
+ * must appear in at least one pattern; any other name becomes a token for the templates (the
778
+ * first capture wins). Items that match no pattern are ignored. Up to 10 patterns of up to 256
779
+ * characters each. Default ["${signature}"].
780
+ */
781
+ parts?: string[];
782
+ /** Template of the signed bytes. Up to 512 characters. Default "${body}". */
783
+ signed?: string;
784
+ /** Template resolving to unix time, in seconds or in milliseconds (a value above 10^12). Up to 512 characters. Absent: no timestamp check. */
785
+ timestamp?: string;
786
+ /** Seconds the timestamp may be away from now, 1 to 86400. Only used with `timestamp`. Default 300. */
787
+ tolerance?: number;
788
+ /** How the stored secret becomes the HMAC key bytes. Default 'raw'. */
789
+ secret_encoding?: 'raw' | 'base64' | 'hex';
790
+ /** Removed from the start of the stored secret before decoding. Up to 64 characters. */
791
+ secret_prefix?: string;
792
+ };
793
+ /**
794
+ * What a consumption request must look like before the ticket's actions run. The parts are
795
+ * checked in the order listed here and the first part that fails is the reported one. An absent
796
+ * or empty part checks nothing.
797
+ */
798
+ type TicketCondition = {
799
+ /** Answer HTTP 200 even when the consumption fails. For webhooks that retry on errors. It only changes the status: a failing request still fails. */
800
+ return200?: boolean;
801
+ /** Absent = both allowed. */
802
+ method?: 'GET' | 'POST';
803
+ /** Verified first, over the raw request body. See TicketSignatureCondition. */
804
+ signature?: TicketSignatureCondition;
805
+ /**
806
+ * The caller's IP address. Fails only when none of the listed values passes ('!=': when it
807
+ * is one of them). A value that is empty ("" or []), null or missing checks nothing, and
808
+ * registration drops it.
809
+ */
810
+ ip?: {
811
+ operator: TicketConditionOperator;
812
+ value: string | string[];
813
+ };
814
+ /** The User-Agent header, decided like `ip`. */
815
+ user_agent?: {
816
+ operator: TicketConditionOperator;
817
+ value: string | string[];
818
+ };
819
+ /** Rows against the request headers. See TicketConditionRow. Every row compares with a value: null, or no `value`, is refused. */
820
+ headers?: TicketConditionRow[];
821
+ /** Rows against the request body. Refused when `method` is 'GET': a GET request has no body. */
822
+ data?: TicketConditionRow[];
823
+ /** Rows against the query string, read on GET and on POST. */
824
+ params?: TicketConditionRow[];
825
+ /**
826
+ * Rows against the consumer's attributes (user_id, email, access_group, ...). Signed requests
827
+ * only: an app user of this project calling consumeTicket() with `auth: true`. A third-party
828
+ * webhook has no session, so a ticket using this always fails for webhooks (AUTH_REQUIRED).
829
+ * The actions read the same attributes as `${user[key]}`. Every row compares with a value:
830
+ * null, or no `value`, is refused.
831
+ */
832
+ user?: TicketConditionRow[];
833
+ /**
834
+ * Record ID the consumer must own or have been granted. Signed requests only, like `user`:
835
+ * a ticket using this always fails for webhooks. The actions read it as `${record_access}`.
836
+ */
837
+ record_access?: string;
838
+ };
839
+ /**
840
+ * What a `req` action checks on the response before its nested actions run: `headers` and
841
+ * `data` rows work as in the ticket's condition (captures and `setValueWhenMatch` included).
842
+ * `headers` rows read the response headers and `data` row keys are paths into the parsed
843
+ * response body. `user` and `record_access` still check the consumer, so they only work for
844
+ * signed requests. A response that is not 2xx fails before this is checked.
845
+ */
846
+ type TicketResponseCondition = Pick<TicketCondition, 'headers' | 'data' | 'user' | 'record_access'>;
847
+ /**
848
+ * One step of a ticket's action chain. Actions run in order. When an action fails its `err`
849
+ * chain runs and the consumption stops. Nothing is rolled back.
850
+ *
851
+ * `exe` values are templated right before the action runs. Every reference is written inside
852
+ * `${ }`, and text outside `${ }` is always literal, whatever it looks like: "order[id]" is just
853
+ * that text. A value that is exactly one `${...}` keeps the type of what it reads; inside longer
854
+ * text it becomes text (JSON for anything but a string). `$${...}` writes a literal `${...}`.
855
+ * Object keys, condition rows and `setValueWhenMatch` are never templated.
856
+ *
857
+ * | Reference | Reads |
858
+ * |---|---|
859
+ * | `${data}`, `${data[key]}` | The incoming request body (a text body too), or one key of it: `${data[id]}` is the body's `id`, `${data[order][id]}` its `order.id`. Always the incoming body, also in nested actions. |
860
+ * | `${params}`, `${params[key]}` | The incoming query string, or one key of it. |
861
+ * | `${headers[name]}` | An incoming header, name case-insensitive. Authorization and Cookie read "<redacted>". |
862
+ * | `${placeholder[NAME]}` | A value a condition row captured with `placeholder`. |
863
+ * | `${user}`, `${user[key]}` | The signed-in user's attributes. Signed requests only. |
864
+ * | `${ip}`, `${user_agent}`, `${method}` | The caller's IP address, User-Agent and HTTP method. |
865
+ * | `${record_access}` | The record ID the condition's `record_access` names. Signed requests only. |
866
+ * | `${response}`, `${response[key]}` | The parsed body of the enclosing req action's response. Only in that req's nested `actions` and their `err` chains. |
867
+ * | `${result}`, `${result[key]}` | The result of the previous action in the same chain. A nested chain and an `err` chain start without one. |
868
+ * | `${error}`, `${error[key]}` | In an `err` chain, the failure: `code`, `message`, `detail`, `action` (the act) and `path`. |
869
+ * | `${ticket}`, `${ticket[key]}` | This consumption: `id`, `service`, `owner`, `consume_id` and `timestamp`. |
870
+ * | `${CLIENT_SECRET}` | Reserved. See `secretName` on the req action. |
871
+ *
872
+ * Registration refuses anything else inside `${ }` (an unknown root such as `${id}`, keys under
873
+ * a root that takes none such as `${ip[x]}`, `${placeholder}` or `${headers}` without a key,
874
+ * broken brackets) with a message listing these forms, and a reference written where it can
875
+ * never resolve (`${response}` outside a req's nested actions, `${error}` outside an `err`
876
+ * chain, `${record_access}` when the condition names no record). When the action runs, a
877
+ * reference that does not resolve fails it before it does anything: PATH_NOT_FOUND,
878
+ * PLACEHOLDER_MISSING for a placeholder that was never captured, or AUTH_REQUIRED for `${user}`
879
+ * on a request that is not signed in. Its `err` chain runs and the consumption stops.
880
+ */
881
+ type TicketAction = {
882
+ /** Set the access group of a user. */
883
+ act: 'acsg';
884
+ exe: {
885
+ /** 1 ~ 99, or "admin", or a reference that gives one when the action runs, such as "${placeholder[GROUP]}". */
886
+ group: number | 'admin' | `${string}\${${string}}${string}`;
887
+ /** Blank = the consumer (signed-in consumption only). The project owner cannot be a target. */
888
+ user_id?: string;
889
+ };
890
+ err?: TicketAction[];
891
+ } | {
892
+ /** Grant private access to a record. */
893
+ act: 'acsr';
894
+ exe: {
895
+ /** A record ID, not a unique ID. */
896
+ record_id: string;
897
+ /** Blank = the consumer. */
898
+ user_id?: string | string[];
899
+ };
900
+ err?: TicketAction[];
901
+ } | {
902
+ /** Post a record. Everything but `user_id` is the payload postRecord() sends, so the same rules apply. A `unique_id` makes a retried webhook update the same record instead of adding one. */
903
+ act: 'pstr';
904
+ exe: {
905
+ table: string | {
906
+ name: string;
907
+ access_group?: number | 'public' | 'authorized' | 'admin' | 'private';
908
+ subscription?: NonNullable<PostRecordConfig['table']>['subscription'];
909
+ };
910
+ data?: any;
911
+ index?: {
912
+ name: string;
913
+ value: string | number | boolean;
914
+ };
915
+ tags?: string[];
916
+ unique_id?: string;
917
+ /** Update instead of create. */
918
+ record_id?: string;
919
+ reference?: string;
920
+ readonly?: boolean;
921
+ source?: PostRecordConfig['source'];
922
+ /** Post as this user instead of the project owner. */
923
+ user_id?: string;
924
+ };
925
+ err?: TicketAction[];
926
+ } | {
927
+ /** HTTP request with its own response condition and nested chain. Result: the parsed response body. */
928
+ act: 'req';
929
+ exe: {
930
+ /**
931
+ * http:// or https:// with a hostname, such as "https://api.example.com/orders/${data[id]}".
932
+ * The scheme is always written out, so a URL that is one whole reference is refused.
933
+ * No IP literal, no userinfo, never under the api domain. Redirects are not followed.
934
+ * A value put into the URL with `${...}` is percent-encoded, so it cannot add path
935
+ * segments or query parameters ("." and ".." are refused). `${CLIENT_SECRET}` is
936
+ * never allowed here. Sent as a browser sends it: a hostname outside ASCII is
937
+ * IDNA-encoded, a tab or line break is removed, and in the path and query a space,
938
+ * any other control character and every character outside ASCII is percent-encoded.
939
+ */
940
+ url: string;
941
+ /** Default GET. */
942
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
943
+ /**
944
+ * The name of a Secret Key of the project, never the secret itself. Must exist at
945
+ * registration. Never templated.
946
+ *
947
+ * - `${CLIENT_SECRET}` in this action's `headers`, `data` and `params` values is
948
+ * replaced by the key's value, server side, when the call is sent. It is refused
949
+ * anywhere else: in the url, in other actions, in a req without `secretName`, in
950
+ * header names or object keys, and in condition rows. Text in the incoming request
951
+ * that reads "${CLIENT_SECRET}" is never expanded.
952
+ * - The url's scheme and host must be written out: no "${...}" before the path.
953
+ * - When the key has Destinations, the call must go to one of them, or it fails with
954
+ * REQUEST_FAILED, `detail: { reason: 'refused_address' }`. A req without
955
+ * `secretName` is not limited.
956
+ * - The value is never logged. A copy in the answer or an error, as sent or escaped
957
+ * up to three times over (percent, backslash or HTML escapes; each level in one
958
+ * notation), reads "${CLIENT_SECRET}" instead. An answer of any size is read whole
959
+ * and still parses as JSON; reading a very long answer can run out of the
960
+ * ticket's time, which fails with REQUEST_FAILED, `detail: { reason: 'timeout' }`.
961
+ * A key that no longer exists fails with
962
+ * REQUEST_FAILED, `detail: { reason: 'secret_missing', secretName }`.
963
+ */
964
+ secretName?: string;
965
+ /**
966
+ * Request headers, values templated. Two headers are the engine's own, and
967
+ * registration refuses either one, in any case and with any surrounding spaces:
968
+ * Host (always the url's host) and X-Skapi-Ticket (every call carries
969
+ * `X-Skapi-Ticket: <service id>/<ticket id>`).
970
+ *
971
+ * A name must be ASCII, with no ":", line break or NUL. A value cannot hold a line
972
+ * break, NUL or a character outside Latin-1 (send such values in the body).
973
+ * - Registration refuses a name that breaks this rule, and a value whose text outside
974
+ * its `${...}` references breaks it, so a header the call could never send is not
975
+ * saved.
976
+ * - A value that breaks it only once templated fails the call with REQUEST_FAILED,
977
+ * `detail: { reason: 'invalid_header', header }`, before anything is sent.
978
+ *
979
+ * Each message names the header, never its value.
980
+ */
981
+ headers?: {
982
+ [name: string]: string;
983
+ };
984
+ /** POST and PUT body. Sent as JSON when a content-type header says application/json, else form encoded. */
985
+ data?: any;
986
+ /** Query string. */
987
+ params?: {
988
+ [key: string]: any;
989
+ };
990
+ /** Legacy. Registration moves these rows to the end of `condition.data`. */
991
+ match?: TicketConditionRow[];
992
+ /** Checked against the response. Captures land in the shared placeholder pool. See TicketResponseCondition. */
993
+ condition?: TicketResponseCondition;
994
+ /**
995
+ * Nested chain, run when the response passes `condition`. It reads the response body
996
+ * as `${response}` and `${response[key]}`, while `${data}` is still the incoming
997
+ * request body. Any action can nest, including another req with its own `secretName`.
998
+ */
999
+ actions?: TicketAction[];
1000
+ };
1001
+ err?: TicketAction[];
1002
+ };
1003
+ /** An issued ticket as getTickets() and registerTicket() return it. */
1004
+ type Ticket = {
1005
+ ticket_id: string;
1006
+ description?: string;
1007
+ /** Remaining consumptions. Absent = unlimited. */
1008
+ count?: number;
1009
+ /** Absolute expiry in ms since epoch. Absent = never. */
1010
+ time_to_live?: number;
1011
+ /** true = once per user, n = n times. Absent or 0 = unlimited. Only enforced for signed-in consumers. */
1012
+ limit_per_user?: boolean | number;
1013
+ /** Created at (ms). */
1014
+ timestamp: number;
1015
+ /** Last registered at (ms). */
1016
+ updated?: number;
1017
+ condition?: TicketCondition;
1018
+ actions?: TicketAction[];
1019
+ /**
1020
+ * true on a ticket saved before this release (the dashboard marks it "previous rules"). It
1021
+ * keeps running by the rules it was saved with until it is registered again, which applies
1022
+ * the current rules. `condition` and `actions` are shown converted to the current format.
1023
+ * Returned to the project owner only. See
1024
+ * https://docs.skapi.com/deprecated/deprecated.html#tickets-saved-before-this-release
1025
+ */
1026
+ legacy?: boolean;
1027
+ };
1028
+ type TicketErrorCode = 'INVALID_SERVICE' | 'SERVICE_DISABLED' | 'TICKET_NOT_FOUND' | 'TICKET_EXPIRED' | 'TICKET_EXHAUSTED' | 'USER_LIMIT_REACHED' | 'ISSUER_CANNOT_CONSUME' | 'AUTH_REQUIRED' | 'METHOD_NOT_ALLOWED' | 'CONDITION_FAILED' | 'PATH_NOT_FOUND' | 'PLACEHOLDER_MISSING' | 'REQUEST_FAILED' | 'TIMEOUT' | 'ACTION_FAILED' | 'ACTION_FORBIDDEN' | 'INTERNAL_ERROR';
1029
+ /**
1030
+ * The body a consume endpoint answers with when the consumption fails, and the `cause` of the
1031
+ * SkapiError consumeTicket() rejects with. A success body never has `stage`; an error body
1032
+ * always does, also when the ticket answers HTTP 200 (`return200`).
1033
+ */
1034
+ type TicketError = {
1035
+ code: TicketErrorCode;
1036
+ /** Human readable, one sentence. */
1037
+ message: string;
1038
+ stage: 'ticket' | 'condition' | 'action';
1039
+ /** Only when stage is "action": the action that failed and its place in the chain, such as "actions[1].err[0]". */
1040
+ action?: {
1041
+ act: TicketAction['act'];
1042
+ path: string;
1043
+ };
1044
+ /**
1045
+ * Code specific, JSON safe. For example { expired_at } on TICKET_EXPIRED, and { field, keys }
1046
+ * on CONDITION_FAILED, where `field` is the part that failed ("data", "headers", ...) and
1047
+ * `keys` the row keys that did not pass. `field` is "loop" when the request was sent by a
1048
+ * ticket's own req action (a ticket cannot consume a ticket).
1049
+ *
1050
+ * REQUEST_FAILED carries { status, body } for an answer of 300 or above (`body` is the parsed
1051
+ * answer, or the first 4 KB of its text when longer, compact JSON for a JSON answer, with a
1052
+ * Secret Key the req sent replaced by the text "${CLIENT_SECRET}"), { reason } with reason
1053
+ * "timeout", "refused_address" or "connection", { reason: "invalid_header", header } for a
1054
+ * header that cannot be sent, or { reason: "secret_missing", secretName }.
1055
+ */
1056
+ detail?: {
1057
+ [key: string]: any;
1058
+ };
1059
+ ticket_id: string;
1060
+ };
663
1061
 
664
1062
  type Types_BinaryFile = BinaryFile;
665
1063
  type Types_Condition = Condition;
@@ -689,13 +1087,22 @@ type Types_RequestHistory = RequestHistory;
689
1087
  type Types_Subscription = Subscription;
690
1088
  type Types_Table = Table;
691
1089
  type Types_Tag = Tag;
1090
+ type Types_Ticket = Ticket;
1091
+ type Types_TicketAction = TicketAction;
1092
+ type Types_TicketCondition = TicketCondition;
1093
+ type Types_TicketConditionOperator = TicketConditionOperator;
1094
+ type Types_TicketConditionRow = TicketConditionRow;
1095
+ type Types_TicketError = TicketError;
1096
+ type Types_TicketErrorCode = TicketErrorCode;
1097
+ type Types_TicketResponseCondition = TicketResponseCondition;
1098
+ type Types_TicketSignatureCondition = TicketSignatureCondition;
692
1099
  type Types_UniqueId = UniqueId;
693
1100
  type Types_UserAttributes = UserAttributes;
694
1101
  type Types_UserProfile = UserProfile;
695
1102
  type Types_UserPublic = UserPublic;
696
1103
  type Types_WebSocketMessage = WebSocketMessage;
697
1104
  declare namespace Types {
698
- export type { Types_BinaryFile as BinaryFile, Types_Condition as Condition, Types_Connection as Connection, Types_ConnectionInfo as ConnectionInfo, Types_DatabaseResponse as DatabaseResponse, Types_DelRecordQuery as DelRecordQuery, Types_EncryptionOptions as EncryptionOptions, Types_FetchOptions as FetchOptions, Types_FileInfo as FileInfo, Types_Form as Form, Types_GetRecordQuery as GetRecordQuery, Types_Index as Index, Types_Newsletter as Newsletter, Types_NewsletterGroup as NewsletterGroup, Types_PostRecordConfig as PostRecordConfig, Types_ProgressCallback as ProgressCallback, Types_RTCConnector as RTCConnector, Types_RTCConnectorParams as RTCConnectorParams, Types_RTCEvent as RTCEvent, Types_RTCReceiverParams as RTCReceiverParams, Types_RTCResolved as RTCResolved, Types_RealtimeCallback as RealtimeCallback, Types_RecordData as RecordData, Types_RecordEncryptionInfo as RecordEncryptionInfo, Types_RequestHistory as RequestHistory, Types_Subscription as Subscription, Types_Table as Table, Types_Tag as Tag, Types_UniqueId as UniqueId, Types_UserAttributes as UserAttributes, Types_UserProfile as UserProfile, Types_UserPublic as UserPublic, Types_WebSocketMessage as WebSocketMessage };
1105
+ export type { Types_BinaryFile as BinaryFile, Types_Condition as Condition, Types_Connection as Connection, Types_ConnectionInfo as ConnectionInfo, Types_DatabaseResponse as DatabaseResponse, Types_DelRecordQuery as DelRecordQuery, Types_EncryptionOptions as EncryptionOptions, Types_FetchOptions as FetchOptions, Types_FileInfo as FileInfo, Types_Form as Form, Types_GetRecordQuery as GetRecordQuery, Types_Index as Index, Types_Newsletter as Newsletter, Types_NewsletterGroup as NewsletterGroup, Types_PostRecordConfig as PostRecordConfig, Types_ProgressCallback as ProgressCallback, Types_RTCConnector as RTCConnector, Types_RTCConnectorParams as RTCConnectorParams, Types_RTCEvent as RTCEvent, Types_RTCReceiverParams as RTCReceiverParams, Types_RTCResolved as RTCResolved, Types_RealtimeCallback as RealtimeCallback, Types_RecordData as RecordData, Types_RecordEncryptionInfo as RecordEncryptionInfo, Types_RequestHistory as RequestHistory, Types_Subscription as Subscription, Types_Table as Table, Types_Tag as Tag, Types_Ticket as Ticket, Types_TicketAction as TicketAction, Types_TicketCondition as TicketCondition, Types_TicketConditionOperator as TicketConditionOperator, Types_TicketConditionRow as TicketConditionRow, Types_TicketError as TicketError, Types_TicketErrorCode as TicketErrorCode, Types_TicketResponseCondition as TicketResponseCondition, Types_TicketSignatureCondition as TicketSignatureCondition, Types_UniqueId as UniqueId, Types_UserAttributes as UserAttributes, Types_UserProfile as UserProfile, Types_UserPublic as UserPublic, Types_WebSocketMessage as WebSocketMessage };
699
1106
  }
700
1107
 
701
1108
  declare function terminatePendingRequests(): void;
@@ -859,12 +1266,16 @@ declare class Skapi {
859
1266
  };
860
1267
  private __connection;
861
1268
  private __authConnection;
1269
+ private __projectIdInput;
862
1270
  private __network_logs;
863
1271
  private __endpoint_version;
864
1272
  private __public_identifier;
865
1273
  private bearerToken;
866
1274
  private _alert;
867
1275
  constructor(service: string, owner?: string | Options, options?: Options | any, __etc?: any);
1276
+ private _resolveProject;
1277
+ private _startAfterProjectIdInput;
1278
+ private _start;
868
1279
  /**
869
1280
  * Returns current connection metadata such as service name, client IP, user agent, locale, and SDK version.
870
1281
  * @param params Request parameters. When `refresh` is true, the cached connection metadata is re-fetched before returning; otherwise the cached connection is returned.
@@ -948,6 +1359,18 @@ declare class Skapi {
948
1359
  }): Promise<string | void>;
949
1360
  /**
950
1361
  * Queries unique ID records by unique_id or condition filters.
1362
+ *
1363
+ * Refused to a signed out caller when the project's `require_login`
1364
+ * setting is on: REQUIRE_LOGIN from the SDK, INVALID_REQUEST from the
1365
+ * backend for a caller that skips it. A project that has never set the
1366
+ * flag counts as ON. This listing used to be served to anyone who knew
1367
+ * the project id, and called with no `unique_id` it enumerates every
1368
+ * unique ID in the project.
1369
+ *
1370
+ * The listing is NOT filtered by access group: a row is keyed by the
1371
+ * unique ID alone, so any caller who gets past the sign in check sees the
1372
+ * IDs of records in every group, each with the record ID it maps to.
1373
+ * Fetching those records still goes through the usual access checks.
951
1374
  * @param params Request parameters.
952
1375
  * @param fetchOptions Pagination and fetch behavior options.
953
1376
  * @returns A promise that resolves to Promise<DatabaseResponse<UniqueId>>.
@@ -991,6 +1414,23 @@ declare class Skapi {
991
1414
  openIdLogin(params: {
992
1415
  token: string;
993
1416
  id: string;
1417
+ /**
1418
+ * Merges this OpenID identity into the existing account whose ORIGINAL login
1419
+ * ID (its username, or the e-mail it was created with when it has none) is
1420
+ * this OpenID account's login ID. `true` merges; an array of OpenID attribute
1421
+ * names also copies those attributes to the account. Merging replaces the
1422
+ * account's password.
1423
+ *
1424
+ * Never merges through an e-mail login alias. openIdLogin() fails with EXISTS,
1425
+ * with or without merge, when this OpenID account's login ID is the verified
1426
+ * e-mail login of another account of the project (an account created with a
1427
+ * username, or one whose e-mail was changed to it), and in the rare case the
1428
+ * alias cannot be removed safely. Any other account holding that login ID as an
1429
+ * e-mail login alias has not verified the e-mail, so it loses the alias instead
1430
+ * and a new OpenID account is created for this login ID: the two accounts then
1431
+ * share the e-mail address. The alias is removed before signup restrictions are
1432
+ * checked, so it is gone even when the login is then refused for another reason.
1433
+ */
994
1434
  merge?: boolean | string[];
995
1435
  template?: {
996
1436
  /** message_id of the template to use for the welcome e-mail (sent the first time this OpenID user account is created). */
@@ -1035,9 +1475,12 @@ declare class Skapi {
1035
1475
  group: string;
1036
1476
  }>): Promise<string>;
1037
1477
  /**
1478
+ * **Deprecated. Use `forwardRequest(form, options)` instead.**
1479
+ *
1038
1480
  * Sends a secure outbound request using a Skapi client secret key.
1039
1481
  * @param params Request parameters.
1040
1482
  * @returns A promise that resolves to the final API response, or to a status object when the request is queued.
1483
+ * @deprecated Use forwardRequest(form, options), which takes the form as its first argument and makes the client secret optional. This name keeps working unchanged, and both dispatch the same request through the same code.
1041
1484
  */
1042
1485
  clientSecretRequest(params: {
1043
1486
  url: string;
@@ -1070,6 +1513,8 @@ declare class Skapi {
1070
1513
  }) => Promise<any>;
1071
1514
  }>;
1072
1515
  /**
1516
+ * **Deprecated. Use `forwardRequestHistory` instead, which is this same function.**
1517
+ *
1073
1518
  * Retrieves the history of client secret requests for a given URL and method.
1074
1519
  *
1075
1520
  * Listing modifiers: `compact` returns lightweight label/marker stubs
@@ -1083,6 +1528,7 @@ declare class Skapi {
1083
1528
  * @param params Request parameters.
1084
1529
  * @param fetchOptions Pagination and fetch behavior options.
1085
1530
  * @returns A promise that resolves to a paginated list of request history items.
1531
+ * @deprecated Use forwardRequestHistory, which is this same function. A request started under either name is listed by both.
1086
1532
  */
1087
1533
  clientSecretRequestHistory(params: {
1088
1534
  url: string;
@@ -1094,11 +1540,8 @@ declare class Skapi {
1094
1540
  queue_exclude?: string;
1095
1541
  }, fetchOptions?: FetchOptions): Promise<DatabaseResponse<RequestHistory[]>>;
1096
1542
  /**
1097
- * Cancels a pending client secret request and removes it from the client-side queue if applicable.
1098
- * @param params Request parameters.
1099
- * @returns A promise that resolves to a result object with removed status and message.
1100
- */
1101
- /**
1543
+ * **Deprecated. Use `forwardRequestStream` instead, which is this same function.**
1544
+ *
1102
1545
  * Reads a streamed clientSecretRequest that this call did not start: a page reload,
1103
1546
  * a second tab, or a turn from history that was never finalized.
1104
1547
  *
@@ -1117,6 +1560,7 @@ declare class Skapi {
1117
1560
  * onStream: (chunk) => parser.feed(chunk)
1118
1561
  * });
1119
1562
  * ```
1563
+ * @deprecated Use forwardRequestStream, which is this same function.
1120
1564
  */
1121
1565
  clientSecretRequestStream(requestId: string, options: {
1122
1566
  url?: string;
@@ -1130,6 +1574,8 @@ declare class Skapi {
1130
1574
  owner?: string;
1131
1575
  }): Promise<any>;
1132
1576
  /**
1577
+ * **Deprecated. Use `forwardRequestFinalize` instead, which is this same function.**
1578
+ *
1133
1579
  * Stores the version of a streamed response you want KEPT as history, and releases
1134
1580
  * the relayed chunks it was assembled from.
1135
1581
  *
@@ -1145,6 +1591,7 @@ declare class Skapi {
1145
1591
  * method: 'POST'
1146
1592
  * });
1147
1593
  * ```
1594
+ * @deprecated Use forwardRequestFinalize, which is this same function.
1148
1595
  */
1149
1596
  clientSecretRequestFinalize(requestId: string, data?: any, options?: {
1150
1597
  url?: string;
@@ -1155,6 +1602,14 @@ declare class Skapi {
1155
1602
  finalized: boolean;
1156
1603
  message: string;
1157
1604
  }>;
1605
+ /**
1606
+ * **Deprecated. Use `cancelForwardRequest` instead, which is this same function.**
1607
+ *
1608
+ * Cancels a pending client secret request and removes it from the client-side queue if applicable.
1609
+ * @param params Request parameters.
1610
+ * @returns A promise that resolves to a result object with removed status and message.
1611
+ * @deprecated Use cancelForwardRequest, which is this same function.
1612
+ */
1158
1613
  cancelClientSecretRequest(params: {
1159
1614
  url: string;
1160
1615
  method: 'GET' | 'POST' | 'DELETE' | 'PUT';
@@ -1165,6 +1620,8 @@ declare class Skapi {
1165
1620
  message: string;
1166
1621
  }>;
1167
1622
  /**
1623
+ * **Deprecated. Use `stopForwardRequestPolling` instead, which is this same function.**
1624
+ *
1168
1625
  * Stops live polling for client secret requests without cancelling the requests
1169
1626
  * themselves. The server-side work continues; only this client stops asking about it.
1170
1627
  *
@@ -1180,6 +1637,7 @@ declare class Skapi {
1180
1637
  *
1181
1638
  * @param params Which polls to stop.
1182
1639
  * @returns The number of polls stopped.
1640
+ * @deprecated Use stopForwardRequestPolling, which is this same function.
1183
1641
  */
1184
1642
  stopClientSecretPolling(params?: {
1185
1643
  url?: string;
@@ -1190,14 +1648,18 @@ declare class Skapi {
1190
1648
  owner?: string;
1191
1649
  }): number;
1192
1650
  /**
1193
- * True if a poll result came from stopClientSecretPolling rather than the server.
1651
+ * True if a poll result came from stopForwardRequestPolling (or its deprecated alias
1652
+ * stopClientSecretPolling) rather than the server.
1194
1653
  * @param res A resolved poll result.
1195
1654
  */
1196
1655
  isPollStopped(res: any): boolean;
1197
1656
  /**
1657
+ * **Deprecated. Use `forwardRequestQueueCount` instead, which is this same function.**
1658
+ *
1198
1659
  * Returns the number of requests currently waiting in a named client secret request queue.
1199
1660
  * @param params Request parameters.
1200
1661
  * @returns A promise that resolves to queue count information.
1662
+ * @deprecated Use forwardRequestQueueCount, which is this same function.
1201
1663
  */
1202
1664
  clientSecretRequestQueueCount(params: {
1203
1665
  queue: string;
@@ -1208,34 +1670,191 @@ declare class Skapi {
1208
1670
  in_queue: number;
1209
1671
  }>;
1210
1672
  /**
1211
- * Consumes a one-time ticket and executes the ticketed request payload.
1673
+ * Lists forwarded requests for a given url and method, newest first.
1674
+ *
1675
+ * Listing modifiers: `compact` returns lightweight label/marker stubs
1676
+ * (request_text, response_text, response_complete_marker) instead of the
1677
+ * full request/response bodies, which stay on the server; `queue_exact`
1678
+ * restricts a queue listing to exactly the named queue (the queue lookup is
1679
+ * otherwise a prefix range, so queue "u1" would also match "u1-bg");
1680
+ * `queue_exclude` drops one queue's rows from the listing. Both queue
1681
+ * filters are applied server-side after the range read, so a page can come
1682
+ * back short while more matches remain - keep paging by startKey/endOfList.
1683
+ *
1684
+ * The same function as the deprecated clientSecretRequestHistory, so a request
1685
+ * sent under either name is listed here.
1212
1686
  * @param params Request parameters.
1213
- * @returns A promise that resolves to Promise<any>.
1687
+ * @param fetchOptions Pagination and fetch behavior options.
1688
+ * @returns A promise that resolves to a paginated list of request history items.
1689
+ */
1690
+ forwardRequestHistory(params: {
1691
+ url: string;
1692
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD';
1693
+ queue?: string;
1694
+ status?: 'pending' | 'running' | 'resolved' | 'failed';
1695
+ compact?: boolean;
1696
+ queue_exact?: boolean;
1697
+ queue_exclude?: string;
1698
+ }, fetchOptions?: FetchOptions): Promise<DatabaseResponse<RequestHistory[]>>;
1699
+ /**
1700
+ * Reads a streamed forwardRequest that this call did not start: a page reload,
1701
+ * a second tab, or a turn from history that was never finalized.
1702
+ *
1703
+ * `onStream` receives the relayed text in order, exactly as the destination sent it.
1704
+ * skapi does not parse it; whatever grammar those bytes are in belongs to the caller
1705
+ * and its destination. Pass `since` to resume rather than re-read from the beginning.
1706
+ *
1707
+ * When the request is still running this polls until it settles. When it has already
1708
+ * settled it reads every chunk once and resolves.
1709
+ *
1710
+ * ```js
1711
+ * const parser = createMyParser();
1712
+ * await skapi.forwardRequestStream(requestId, {
1713
+ * url: 'https://api.example.com/v1/chat',
1714
+ * method: 'POST',
1715
+ * onStream: (chunk) => parser.feed(chunk)
1716
+ * });
1717
+ * ```
1718
+ */
1719
+ forwardRequestStream(requestId: string, options: {
1720
+ url?: string;
1721
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD';
1722
+ onStream?: (chunk: string, seq: number, via?: 'socket' | 'poll') => void;
1723
+ since?: number;
1724
+ poll?: number;
1725
+ realtimeGroup?: string;
1726
+ onResponse?: (res: any) => void;
1727
+ onError?: (err: any) => void;
1728
+ service?: string;
1729
+ owner?: string;
1730
+ }): Promise<any>;
1731
+ /**
1732
+ * Stores the version of a streamed response you want KEPT as history, and releases
1733
+ * the relayed chunks it was assembled from.
1734
+ *
1735
+ * The content is entirely yours. skapi neither validates nor interprets it: it stores
1736
+ * what you tell it to store. Only the caller who made the request may finalize it.
1737
+ *
1738
+ * Until you finalize, the chunks stay indefinitely and every read of that turn has to
1739
+ * fetch and re-parse all of them, so finalize as soon as you have rendered the answer.
1740
+ *
1741
+ * ```js
1742
+ * await skapi.forwardRequestFinalize(requestId, parser.result(), {
1743
+ * url: 'https://api.example.com/v1/chat',
1744
+ * method: 'POST'
1745
+ * });
1746
+ * ```
1747
+ */
1748
+ forwardRequestFinalize(requestId: string, data?: any, options?: {
1749
+ url?: string;
1750
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD';
1751
+ service?: string;
1752
+ owner?: string;
1753
+ }): Promise<{
1754
+ finalized: boolean;
1755
+ message: string;
1756
+ }>;
1757
+ /**
1758
+ * Cancels a queued forwarded request and removes it from the client-side queue if applicable.
1759
+ * @param params Request parameters.
1760
+ * @returns A promise that resolves to a result object with removed status and message.
1761
+ */
1762
+ cancelForwardRequest(params: {
1763
+ url: string;
1764
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD';
1765
+ id: string;
1766
+ queue?: string;
1767
+ }): Promise<{
1768
+ removed: boolean;
1769
+ message: string;
1770
+ }>;
1771
+ /**
1772
+ * Stops live polling of forwarded requests without cancelling the requests
1773
+ * themselves. The server-side work continues; only this client stops asking about it.
1774
+ *
1775
+ * Use it to drop polling traffic while the user is not looking at the results (a
1776
+ * hidden tab, a closed view), then simply poll again when they return. Polls run
1777
+ * one-at-a-time per queue, so a poll for a request that never settles otherwise
1778
+ * blocks every poll queued behind it.
1779
+ *
1780
+ * Pass `id` (with `url` and `method`) to stop one request, `queue` to stop a queue's
1781
+ * polls, or neither to stop all of them. A stopped poll resolves with
1782
+ * `{ id, status: 'stopped' }` rather than rejecting, and its `onResponse`/`onError`
1783
+ * callbacks are not called.
1784
+ *
1785
+ * @param params Which polls to stop.
1786
+ * @returns The number of polls stopped.
1787
+ */
1788
+ stopForwardRequestPolling(params?: {
1789
+ url?: string;
1790
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD';
1791
+ id?: string;
1792
+ queue?: string;
1793
+ service?: string;
1794
+ owner?: string;
1795
+ }): number;
1796
+ /**
1797
+ * Returns the number of requests currently waiting in a named forward request queue.
1798
+ * @param params Request parameters.
1799
+ * @returns A promise that resolves to queue count information.
1800
+ */
1801
+ forwardRequestQueueCount(params: {
1802
+ queue: string;
1803
+ service?: string;
1804
+ owner?: string;
1805
+ }): Promise<{
1806
+ queue_name: string;
1807
+ in_queue: number;
1808
+ }>;
1809
+ /**
1810
+ * Consumes a ticket: calls its endpoint with `data`, so the ticket's condition is checked and
1811
+ * its actions run. An anonymous POST goes to `/tp/`, an anonymous GET to `/tg/` with `data`
1812
+ * as the query string, and a signed-in consumption (`auth: true`) to `/tpa/`, which is POST only.
1813
+ *
1814
+ * A failed consumption rejects with a SkapiError: `err.code` is the ticket error code and
1815
+ * `err.cause` the flat TicketError body (`err.cause.stage`, `err.cause.action`, `err.cause.detail`).
1816
+ * This holds when the ticket answers HTTP 200 as well (`return200`): the body is inspected, not the status.
1817
+ * @param params Request parameters.
1818
+ * @returns A promise that resolves to Promise<{ ticket_id: string; consume_id: string; user_id: string; is_test: boolean; timestamp: number; hash: string; }>.
1214
1819
  */
1215
1820
  consumeTicket(params: {
1821
+ /** ID of the ticket to consume. */
1216
1822
  ticket_id: string;
1217
- method: string;
1823
+ /** "GET" or "POST". */
1824
+ method: 'GET' | 'POST';
1825
+ /** Consume as the signed-in user. POST only. */
1218
1826
  auth?: boolean;
1827
+ /** The POST body, or the query string of a GET. */
1219
1828
  data?: {
1220
1829
  [key: string]: any;
1221
1830
  };
1222
- }): Promise<any>;
1831
+ }): Promise<{
1832
+ ticket_id: string;
1833
+ consume_id: string;
1834
+ user_id: string;
1835
+ is_test: boolean;
1836
+ timestamp: number;
1837
+ hash: string;
1838
+ }>;
1223
1839
  /**
1224
- * Lists consumed tickets with optional filters and pagination.
1840
+ * Lists the tickets the signed-in user has consumed, with optional filters and pagination.
1225
1841
  * @param params Request parameters.
1226
1842
  * @param fetchOptions Pagination and fetch behavior options.
1227
1843
  * @returns A promise that resolves to Promise<DatabaseResponse<any>>.
1228
1844
  */
1229
1845
  getConsumedTickets(params: {
1846
+ /** Only the consumptions of this ticket. */
1230
1847
  ticket_id?: string;
1231
1848
  }, fetchOptions?: FetchOptions): Promise<DatabaseResponse<any>>;
1232
1849
  /**
1233
1850
  * Lists issued tickets with optional filters and pagination.
1851
+ * The project owner gets the full ticket (condition, actions, count, expiry, per-user limit); any other signed-in user gets `ticket_id`, `description`, `count`, `time_to_live` and `timestamp` only.
1234
1852
  * @param params Request parameters.
1235
1853
  * @param fetchOptions Pagination and fetch behavior options.
1236
1854
  * @returns A promise that resolves to Promise<DatabaseResponse<any>>.
1237
1855
  */
1238
1856
  getTickets(params: {
1857
+ /** Absent = every ticket. "<id>" = that ticket. "#<id>#" = the consumption log of that ticket (project owner only). */
1239
1858
  ticket_id?: string;
1240
1859
  }, fetchOptions?: FetchOptions): Promise<DatabaseResponse<any>>;
1241
1860
  /**
@@ -1292,30 +1911,71 @@ declare class Skapi {
1292
1911
  user_id: string;
1293
1912
  }): Promise<'SUCCESS: Account has been deleted.'>;
1294
1913
  /**
1295
- * Invites a user by email with optional attributes and invitation email options.
1296
- * @param params Payload for the request.
1297
- * @param options Optional behavior configuration.
1914
+ * Invites a user by e-mail. The invitation carries a temporary password and a
1915
+ * link to accept, valid for 7 days. Admin only (access_group 90 and above).
1916
+ *
1917
+ * Every profile attribute passed in `params` is written to the account when the
1918
+ * invitation is sent and is kept unchanged when the user accepts; accepting only
1919
+ * activates the account and marks its e-mail verified.
1920
+ *
1921
+ * Refused with EXISTS when the e-mail, or the username when one is given, is
1922
+ * already another account's login ID, and with EXISTS "User is already
1923
+ * invited." while the e-mail has a pending invitation.
1924
+ * @param params The invited user's e-mail, and optionally their profile.
1925
+ * @param options Where to send them after accepting, newsletter opt-in, and a custom template.
1298
1926
  * @returns A promise that resolves to Promise<'SUCCESS: Invitation has been sent. (User ID: xxx...)'>.
1299
1927
  */
1300
1928
  inviteUser(params: UserAttributes & {
1929
+ /** Required. The invitation, with the temporary password and the link to accept, is sent here. */
1930
+ email: string;
1931
+ /**
1932
+ * Optional. Becomes the invited account's PERMANENT login username and
1933
+ * can never be changed. The e-mail also logs the account in once the
1934
+ * invitation is accepted (best effort), not while it is pending. Refused
1935
+ * with EXISTS when the username or the e-mail is already another
1936
+ * account's login ID.
1937
+ */
1938
+ username?: string;
1939
+ /** ID of an OpenID logger registered in the project, to link the invited account to it. */
1301
1940
  openid_id?: string;
1941
+ /** 1~99. Defaults to 1. 99 is admin level. */
1302
1942
  access_group?: number;
1303
1943
  }, options?: {
1944
+ /** URL the user is taken to after accepting. Must not contain "#". */
1304
1945
  confirmation_url?: string;
1946
+ /**
1947
+ * Subscribe the user to Service Email (group 1) once they accept.
1948
+ * Requires `confirmation_url`. Defaults to false.
1949
+ */
1305
1950
  email_subscription?: boolean;
1951
+ /** A custom HTML template for this invitation e-mail. Both fields are required. */
1306
1952
  template?: {
1953
+ /** URL of the HTML template. Must include the required invitation placeholders. */
1307
1954
  url: string;
1955
+ /** Subject line of the e-mail. */
1308
1956
  subject: string;
1309
1957
  };
1310
1958
  }): Promise<'SUCCESS: Invitation has been sent. (User ID: xxx...)'>;
1311
1959
  /**
1312
1960
  * Creates a user account directly from admin context.
1961
+ *
1962
+ * Refused with EXISTS when the e-mail, or the username when one is given, is
1963
+ * already another account's login ID.
1313
1964
  * @param params Payload for the request.
1314
1965
  * @returns A promise that resolves to Promise<UserProfile & { email_admin: string; username: string; }>.
1315
1966
  */
1316
1967
  createAccount(params: UserAttributes & {
1968
+ /** Required. Always. */
1317
1969
  email: string;
1318
1970
  password: string;
1971
+ /**
1972
+ * Optional. Becomes the account's PERMANENT login username, which
1973
+ * always logs the account in. The e-mail is created unverified, so it
1974
+ * logs the account in only once the user verifies it with verifyEmail()
1975
+ * after logging in with the username. Refused with EXISTS when the
1976
+ * username or the e-mail is already another account's login ID.
1977
+ */
1978
+ username?: string;
1319
1979
  access_group?: number;
1320
1980
  }): Promise<UserProfile & {
1321
1981
  email_admin: string;
@@ -1333,6 +1993,29 @@ declare class Skapi {
1333
1993
  /**
1334
1994
  * Updates another user's profile attributes from admin context.
1335
1995
  * Requires the target user's user_id plus at least one attribute to update.
1996
+ *
1997
+ * Never the caller's own account, the project owner and access group 99 admins
1998
+ * included: the caller's own user_id is refused with INVALID_REQUEST and
1999
+ * 'Cannot modify attributes of the current user.' before any request is sent.
2000
+ * Change your own profile with updateProfile() without user_id.
2001
+ *
2002
+ * An admin in access groups 90 ~ 98 cannot update an account whose access group
2003
+ * is at or above their own, a disabled account included (it counts at the group
2004
+ * it had): refused with INVALID_REQUEST and 'No access to modify admin.', and
2005
+ * nothing is written. Access group 99 admins and the project owner are not limited.
2006
+ *
2007
+ * A changed e-mail is written unverified: this method never marks an e-mail
2008
+ * verified, for an admin in access groups 90 ~ 98 or anyone else. The new e-mail
2009
+ * logs the account in only once the user verifies it with verifyEmail(). The
2010
+ * previous e-mail stops logging in when the change is written, unless it is the
2011
+ * e-mail an account without a username was created with, which stays its login
2012
+ * ID. A username always logs in. The change is refused with EXISTS and
2013
+ * 'E-mail "user@email.com" is already a login ID in this service.' when the
2014
+ * e-mail is a login ID another account of the project was granted: the address
2015
+ * that account was created or invited with, or one it has verified. An e-mail
2016
+ * login another account holds without having verified the address blocks
2017
+ * nothing; it is removed, and that account keeps the login ID it was created
2018
+ * with.
1336
2019
  * @param params Target user_id and the attributes to update.
1337
2020
  * @returns A promise that resolves to Promise<'SUCCESS: User attributes updated.'>.
1338
2021
  */
@@ -1435,32 +2118,67 @@ declare class Skapi {
1435
2118
  }>(params: Params[] | Form<Params>, url?: string): Promise<Response | Response[]>;
1436
2119
  /**
1437
2120
  * Relays a request to a destination of your choosing from the server side,
1438
- * with the service api key added where the browser cannot read it, and
1439
- * streams the destination's response back as it arrives.
1440
- *
1441
- * The body is relayed verbatim, so an html form reaches the destination as
1442
- * multipart/form-data, files included; the form's own enctype and method
1443
- * attributes are not used. Supply options.onStream to receive the response
1444
- * chunk by chunk. An error response throws a SkapiError either way; reading
1445
- * the status code or a response header needs options.responseType
1446
- * 'response'. options.signal stops the client receiving the response, it
1447
- * does not cancel the request already sent to the destination.
1448
- *
1449
- * @param form Form element, submit event, FormData, or a plain object. Sent to the destination verbatim.
1450
- * @param options Destination url, method, headers, and an optional onStream callback.
1451
- * @returns A promise that resolves to the destination's response.
1452
- */
1453
- forwardRequest(form: any, options: {
2121
+ * optionally with one of your stored client secrets substituted in where you
2122
+ * put "$CLIENT_SECRET", so the secret never reaches the browser.
2123
+ *
2124
+ * The first argument is the form: a submit event, a form element, FormData, a
2125
+ * plain object, or null when everything is already in the options. It is
2126
+ * FLATTENED to fields and merged into the request, into `params` for GET,
2127
+ * DELETE and HEAD and into `data` otherwise; where a key is in both, the one
2128
+ * you typed in options wins. Files are dropped by that flattening, because
2129
+ * the merged object travels as JSON. Pass `multipart: true` to relay the
2130
+ * form's own bytes instead, files included, the way a browser would send
2131
+ * them; keep that body under 2 MB once encoded, and `data` is refused
2132
+ * alongside it.
2133
+ *
2134
+ * `secretName` is optional: name one and its value is substituted server side
2135
+ * and its allowed destinations are enforced, name none and only what you
2136
+ * supplied is forwarded. `skapiHeaders` tells the destination who is calling,
2137
+ * from the verified identity of the request; a header of your own starting
2138
+ * with "x-skapi-" is refused, which is what makes that prefix worth trusting.
2139
+ *
2140
+ * Queueing, polling, `stream`, `realtime` and the poll handle on the reply all
2141
+ * behave exactly as they do for the deprecated clientSecretRequest, because
2142
+ * they are the same code.
2143
+ *
2144
+ * @param form Submit event, form element, FormData, plain object, or null for no form body.
2145
+ * @param options Destination url and method, the optional secret name, and how to read the answer.
2146
+ * @returns A promise that resolves to the destination's response, or to a status object when the request is queued.
2147
+ */
2148
+ forwardRequest(form: SubmitEvent | HTMLFormElement | FormData | {
2149
+ [key: string]: any;
2150
+ } | null, options: {
2151
+ secretName?: string;
1454
2152
  url: string;
1455
2153
  method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD';
1456
2154
  headers?: {
1457
2155
  [key: string]: string;
1458
2156
  };
1459
- apiKeyHeader?: string;
1460
- apiKeyScheme?: string;
1461
- onStream?: (chunk: string) => void;
1462
- signal?: AbortSignal;
2157
+ data?: {
2158
+ [key: string]: any;
2159
+ };
2160
+ params?: {
2161
+ [key: string]: string;
2162
+ };
2163
+ multipart?: boolean;
2164
+ skapiHeaders?: boolean | {
2165
+ user?: boolean;
2166
+ service?: boolean;
2167
+ };
2168
+ service?: string;
2169
+ owner?: string;
2170
+ poll?: number;
2171
+ queue?: string;
2172
+ expires?: number;
2173
+ stream?: boolean;
2174
+ realtime?: boolean;
2175
+ onStream?: (chunk: string, seq: number, via?: 'socket' | 'poll') => void;
2176
+ onResponse?: (res: any, meta?: {
2177
+ executed?: number;
2178
+ }) => void;
2179
+ onError?: (err: any) => void;
1463
2180
  responseType?: 'json' | 'text' | 'response';
2181
+ signal?: AbortSignal;
1464
2182
  }): Promise<any>;
1465
2183
  /**
1466
2184
  * Returns a normalized response object for form-based handler flows.
@@ -1478,6 +2196,52 @@ declare class Skapi {
1478
2196
  }, fetchOptions?: FetchOptions): Promise<DatabaseResponse<RecordData>>;
1479
2197
  /**
1480
2198
  * Lists table metadata with optional table-name filters.
2199
+ *
2200
+ * With `table` given and `condition` omitted, the table name is matched
2201
+ * exactly. With `table` omitted entirely, every table is returned.
2202
+ * `gte` / `>=` is a prefix search ("table names starting with x"), while
2203
+ * `gt` / `>` is a lexicographic greater-than that spills past the prefix
2204
+ * into every later table name.
2205
+ *
2206
+ * Every combination:
2207
+ * - `getTables({})`: every table in the project.
2208
+ * - `getTables({ table: 'x' })`: exact match on 'x'.
2209
+ * - `getTables({ table: 'x', condition: 'gte' })`: prefix, every table
2210
+ * name starting with 'x'.
2211
+ * - `getTables({ table: '' })`: errors with '"table" should not be empty.'
2212
+ * - `getTables({ condition: 'gte' })` with no `table`: errors with
2213
+ * '"table" is required for condition.'
2214
+ *
2215
+ * When you are looking for a table rather than listing them all, pass
2216
+ * `gte`: a name recorded two ways, such as "Asian Spice House" and "Asian
2217
+ * Spice House (alias)", is only found by the prefix. Real table names
2218
+ * very often carry a leading name shared with the rest of their data set,
2219
+ * a source or dataset prefix, so an exact match finds one spelling and
2220
+ * silently misses its siblings while the prefix finds the family. When
2221
+ * you already know the exact name, omitting `condition` is the exact
2222
+ * match you want. Omit the key to get the default: an explicit undefined
2223
+ * or null `condition` is rejected with INVALID_PARAMETER.
2224
+ *
2225
+ * Refused to a signed out caller when the project's `require_login`
2226
+ * setting is on. The SDK throws REQUIRE_LOGIN before the request leaves,
2227
+ * and the backend refuses the same call with INVALID_REQUEST, so a direct
2228
+ * HTTP call or an older SDK with no gate is refused too. A project that
2229
+ * has never set the flag counts as ON, the same default
2230
+ * `getConnectionInfo()` already reports as `conf.require_login`. Table
2231
+ * metadata used to be served to anyone who knew the project id, so an
2232
+ * integration that listed tables with no signed in user now gets an error
2233
+ * where it used to get a list.
2234
+ *
2235
+ * Table NAMES are never filtered: every table in the project is listed,
2236
+ * whatever access group the records inside it live in. The per access
2237
+ * group counters are filtered to the caller.
2238
+ * `number_of_records_in_access_group_public` goes to everyone, a signed in
2239
+ * user also receives the counters up to and including their own access
2240
+ * group, and `number_of_records_in_access_group_private` and
2241
+ * `number_of_records_in_access_group_admin` go to an admin or the project
2242
+ * owner only. `number_of_records` and `size` are NOT filtered: both stay
2243
+ * totals over every access group, so `number_of_records` is normally
2244
+ * larger than the counters you can see add up to.
1481
2245
  * @param query Query object used to filter results.
1482
2246
  * @param fetchOptions Pagination and fetch behavior options.
1483
2247
  * @returns A promise that resolves to Promise<DatabaseResponse<Table>>.
@@ -1486,11 +2250,58 @@ declare class Skapi {
1486
2250
  /** If omitted, fetches the full list of tables. */
1487
2251
  query?: {
1488
2252
  table?: string;
1489
- /** Condition operator of table name. */
2253
+ /** Condition operator of table name. Omitted: exact match on the given table name. `gte` / `>=`: prefix. */
1490
2254
  condition?: Condition;
1491
2255
  }, fetchOptions?: FetchOptions): Promise<DatabaseResponse<Table>>;
1492
2256
  /**
1493
2257
  * Lists index metadata and aggregated index statistics for a table.
2258
+ *
2259
+ * There is no top-level `condition` here. With no `index` and no `order`,
2260
+ * every index of the table is listed, which is a prefix read. An `index`
2261
+ * without a trailing '.' is an exact match on that index name; an `index`
2262
+ * ending in '.' is a prefix that lists the children of that compound
2263
+ * index, so "Band." lists Band.name, Band.year.
2264
+ *
2265
+ * The only condition is `order.condition`, which requires `order.value`.
2266
+ * Omitting it matches `order.value` exactly.
2267
+ *
2268
+ * Every combination (`table` is required, so there is no no-argument
2269
+ * form):
2270
+ * - `getIndexes({ table: 't' })`: every index of table 't'.
2271
+ * - `getIndexes({ table: 't', index: 'Band' })`: exact match on the index
2272
+ * 'Band'.
2273
+ * - `getIndexes({ table: 't', index: 'Band.' })`: prefix, the children of
2274
+ * the compound index, so Band.name, Band.year.
2275
+ * - `getIndexes({ table: 't', order: { by: 'index_name', value: 'B' } })`:
2276
+ * exact match against the value.
2277
+ * - `getIndexes({ table: 't', order: { by: 'total_number' } })`: the whole
2278
+ * partition, ordered by that attribute.
2279
+ * - `order.condition` without `order.value`: errors.
2280
+ * - no `table`: errors with '"table" is required.'
2281
+ *
2282
+ * When you are looking for an index rather than listing them all, use the
2283
+ * prefix form (no `index`, or a name ending in '.') the way `gte` explores
2284
+ * in getTables and getTags, since an exact `index` name returns only that
2285
+ * one entry. Index names very often carry a leading name shared with the
2286
+ * rest of their data set, so an exact match finds one spelling and
2287
+ * silently misses its siblings while the prefix finds the family. Omit the
2288
+ * key to get the default: an explicit undefined or null condition is
2289
+ * rejected with INVALID_PARAMETER.
2290
+ *
2291
+ * Refused to a signed out caller when the project's `require_login`
2292
+ * setting is on: REQUIRE_LOGIN from the SDK, INVALID_REQUEST from the
2293
+ * backend for a caller that skips it. A project that has never set the
2294
+ * flag counts as ON. Index metadata used to be served to anyone who knew
2295
+ * the project id.
2296
+ *
2297
+ * The listing is NOT filtered by access group, for any caller. A stored
2298
+ * index row is keyed by table and index name with the access group left
2299
+ * out of the key, so one row aggregates every group: `number_of_records`,
2300
+ * `total_number`, `average_number` and the rest span the whole table,
2301
+ * private and admin records included. Anyone who gets past the sign in
2302
+ * check therefore reads the project's entire index vocabulary. The
2303
+ * records behind it stay gated, but an index name is visible to every
2304
+ * signed in user.
1494
2305
  * @param query Query object used to filter results.
1495
2306
  * @param fetchOptions Pagination and fetch behavior options.
1496
2307
  * @returns A promise that resolves to Promise<DatabaseResponse<Index>>.
@@ -1506,11 +2317,56 @@ declare class Skapi {
1506
2317
  by: 'average_number' | 'total_number' | 'number_count' | 'average_bool' | 'total_bool' | 'bool_count' | 'string_count' | 'index_name' | 'number_of_records';
1507
2318
  /** Value to query. */
1508
2319
  value?: number | boolean | string;
2320
+ /** Requires "value". Omitted: exact match against "value". */
1509
2321
  condition?: Condition;
1510
2322
  };
1511
2323
  }, fetchOptions?: FetchOptions): Promise<DatabaseResponse<Index>>;
1512
2324
  /**
1513
2325
  * Lists tags used in a table with optional tag-name filtering.
2326
+ *
2327
+ * With `condition` omitted the default depends on what else you gave:
2328
+ * `table` and `tag` together match the tag exactly, `table` alone is a
2329
+ * prefix ('>=') that lists every tag in that table, and neither one
2330
+ * returns every tag in the project, ordered by record count, descending.
2331
+ * `gte` / `>=` is a prefix search.
2332
+ *
2333
+ * Every combination:
2334
+ * - `getTags({})`: every tag in the project, ordered by record count,
2335
+ * descending.
2336
+ * - `getTags({ table: 't' })`: every tag in table 't'.
2337
+ * - `getTags({ table: 't', tag: 'g' })`: exact match on the tag 'g' in
2338
+ * table 't'.
2339
+ * - `getTags({ tag: 'g' })` with no `table`: the tag 'g' across all
2340
+ * tables.
2341
+ * - `getTags({ table: 't', tag: 'g', condition: 'gte' })`: prefix, every
2342
+ * tag in 't' starting with 'g'.
2343
+ * - `getTags({ condition: 'gte' })` with neither `table` nor `tag`: errors
2344
+ * with '"table" or "tag" is required for condition.'
2345
+ *
2346
+ * When you are looking for a tag rather than listing them all, pass
2347
+ * `gte`: a name recorded two ways, such as "Asian Spice House" and "Asian
2348
+ * Spice House (alias)", is only found by the prefix. Real tags very often
2349
+ * carry a leading name shared with the rest of their data set, a series
2350
+ * name or an artist recorded once plainly and once with a parenthesised
2351
+ * alias, so an exact match finds one spelling and silently misses its
2352
+ * siblings while the prefix finds the family. When you already know the
2353
+ * exact name, omitting `condition` is the exact match you want. Omit the
2354
+ * key to get the default: an explicit undefined or null `condition` is
2355
+ * rejected with INVALID_PARAMETER.
2356
+ *
2357
+ * Refused to a signed out caller when the project's `require_login`
2358
+ * setting is on: REQUIRE_LOGIN from the SDK, INVALID_REQUEST from the
2359
+ * backend for a caller that skips it. A project that has never set the
2360
+ * flag counts as ON. Tag metadata used to be served to anyone who knew
2361
+ * the project id.
2362
+ *
2363
+ * The listing is NOT filtered by access group, for any caller. A stored
2364
+ * tag row is keyed by tag and table name with the access group left out
2365
+ * of the key, so `number_of_records` counts the records in every group
2366
+ * together. Anyone who gets past the sign in check reads the project's
2367
+ * entire tag vocabulary, tags carried only by private or admin records
2368
+ * included. The records behind it stay gated, but a tag name is visible
2369
+ * to every signed in user, so do not put anything secret in one.
1514
2370
  * @param query Query object used to filter results.
1515
2371
  * @param fetchOptions Pagination and fetch behavior options.
1516
2372
  * @returns A promise that resolves to Promise<DatabaseResponse<Tag>>.
@@ -1520,7 +2376,7 @@ declare class Skapi {
1520
2376
  table?: string;
1521
2377
  /** Tag name */
1522
2378
  tag?: string;
1523
- /** String query condition for tag name. */
2379
+ /** String query condition for tag name. Omitted: exact match when `table` and `tag` are both given, prefix when only `table` is given. */
1524
2380
  condition?: Condition;
1525
2381
  }, fetchOptions?: FetchOptions): Promise<DatabaseResponse<Tag>>;
1526
2382
  /**
@@ -1612,10 +2468,10 @@ declare class Skapi {
1612
2468
  VAPIDPublicKey: string;
1613
2469
  }>;
1614
2470
  /**
1615
- * Sends push notifications to one or more users.
1616
- * @param params Payload for the request.
1617
- * @param user_ids Parameter for this operation.
1618
- * @returns A promise that resolves to Promise<"SUCCESS: Notification sent.">.
2471
+ * Sends push notifications to one or more users. Admins only.
2472
+ * @param params Title and body of the push. Together at most 3072 bytes.
2473
+ * @param user_ids Users to push to, up to 1000. Every device each of them registered with subscribeNotification() gets it. Without it, every registered device of the project gets it.
2474
+ * @returns A promise that resolves to Promise<"SUCCESS: Notification sent.">. The pushes are sent right after it resolves.
1619
2475
  */
1620
2476
  pushNotification(params: {
1621
2477
  title: string;
@@ -1648,36 +2504,45 @@ declare class Skapi {
1648
2504
  /**
1649
2505
  * Gets newsletter subscription status for the requested groups.
1650
2506
  * Takes a numeric group, "public", "authorized" or a named newsletter group. Omit the group for every group the user is subscribed to.
2507
+ * The project owner, Skapi staff and access group 99 admins get every subscriber of the group instead, and can pass "email" to get only the subscribers whose e-mail address starts with it.
2508
+ * An admin in access groups 90 ~ 98 gets the subscriber list too, but reads it through a privacy layer:
2509
+ * "subscribed_email" is masked ("j**@**.com") and the mask is lossy, so two different subscribers can read the same;
2510
+ * "subscriber_token" comes with each masked row as an opaque, stable, per address key, and it is the only value that tells such rows apart, so key lists and selections on it, never on the masked address;
2511
+ * the token is not a readable address and is scoped to this service, owner and group, so it cannot be matched against a token from another group or project, and it is a key for working with a listing, not an id to store: the platform can reissue tokens;
2512
+ * "startKey" is sealed by the server and has to be handed back verbatim, which fetchMore already does;
2513
+ * and "email" is refused with "No access.".
1651
2514
  * @param params Request parameters.
1652
2515
  * @param fetchOptions Pagination and fetch behavior options.
1653
- * @returns A promise that resolves to Promise<{ active: boolean; timestamp: number; group: number | string; subscribed_email: string; }[]>.
2516
+ * @returns A promise that resolves to Promise<{ active: boolean; timestamp: number; group: number | string; subscribed_email: string; subscriber_token?: string; }[]>.
1654
2517
  */
1655
2518
  getNewsletterSubscription(params?: {
1656
2519
  /** Numeric group, "public", "authorized" or a named newsletter group. Omit or null for every group. */
1657
2520
  group?: number | 'public' | 'authorized' | (string & {}) | null;
2521
+ /**
2522
+ * Another user's subscriptions. The project owner's account, Skapi staff and
2523
+ * admins (access groups 90 ~ 99) only. An admin in access groups 90 ~ 98 reads
2524
+ * that user's address masked.
2525
+ */
1658
2526
  user_id?: string;
2527
+ /** Owner, Skapi staff and access group 99 only. Returns the subscribers of "group" whose e-mail address starts with this text. Requires "group", cannot be used with "user_id". Admins 90 ~ 98 are refused with "No access.". */
2528
+ email?: string;
1659
2529
  }, fetchOptions?: FetchOptions): Promise<{
1660
2530
  active: boolean;
2531
+ /** Undefined on a group's whole subscriber list, which the index does not carry it on. */
1661
2532
  timestamp: number;
1662
2533
  group: number | string;
1663
2534
  subscribed_email: string;
2535
+ /** Only when the address above is masked. Opaque, stable per address key. */
2536
+ subscriber_token?: string;
1664
2537
  }[] | DatabaseResponse<{
1665
2538
  active: boolean;
2539
+ /** Undefined on a group's whole subscriber list, which the index does not carry it on. */
1666
2540
  timestamp: number;
1667
2541
  group: number | string;
1668
2542
  subscribed_email: string;
2543
+ /** Only when the address above is masked. Opaque, stable per address key. */
2544
+ subscriber_token?: string;
1669
2545
  }>>;
1670
- /**
1671
- * Requests a username change confirmation flow for the current user.
1672
- * @param params Request parameters.
1673
- * @returns A promise that resolves to Promise<'SUCCESS: confirmation e-mail has been sent.'>.
1674
- */
1675
- requestUsernameChange(params: {
1676
- /** Redirect URL when user clicks on the link. */
1677
- redirect?: string;
1678
- /** username(e-mail) user wish to change to. */
1679
- username: string;
1680
- }): Promise<'SUCCESS: confirmation e-mail has been sent.'>;
1681
2546
  /**
1682
2547
  * Reports whether client-side record encryption is on, and whether it is
1683
2548
  * currently unlocked.
@@ -1865,9 +2730,13 @@ declare class Skapi {
1865
2730
  * @returns A promise that resolves to Promise<UserProfile>.
1866
2731
  */
1867
2732
  login(params: Form<{
1868
- /** if given, username will be used instead of email. */
2733
+ /** if given, username will be used instead of email. A username always logs its account in. */
1869
2734
  username?: string;
1870
- /** E-Mail for signin. 64 character max. */
2735
+ /**
2736
+ * E-Mail for signin. 64 character max. The e-mail an account without a username
2737
+ * was created with always logs it in. Any other e-mail (that of an account created
2738
+ * with a username, or a changed e-mail) logs in only once it is verified (verifyEmail()).
2739
+ */
1871
2740
  email: string;
1872
2741
  /** Password for signin. Should be at least 6 characters. */
1873
2742
  password: string;
@@ -1887,7 +2756,19 @@ declare class Skapi {
1887
2756
  * @returns A promise that resolves to Promise<UserProfile | "SUCCESS: The account has been created. User's signup confirmation is required." | 'SUCCESS: The account has been created.'>.
1888
2757
  */
1889
2758
  signup(params: Form<UserAttributes & {
2759
+ /** Required. Always. */
2760
+ email: string;
1890
2761
  password: String;
2762
+ /**
2763
+ * Optional. When given it becomes the account's PERMANENT login
2764
+ * username, which always logs the account in and can never be changed.
2765
+ * The e-mail also logs the account in, but only once it is verified:
2766
+ * opening the signup confirmation link verifies it, and without signup
2767
+ * confirmation the user verifies it with verifyEmail() after logging in
2768
+ * with the username. After an e-mail change the new e-mail logs in once
2769
+ * it is verified the same way. E-mail login is not enabled while that
2770
+ * e-mail is already another account's login ID.
2771
+ */
1891
2772
  username?: string;
1892
2773
  }>, option?: {
1893
2774
  /**
@@ -1898,7 +2779,7 @@ declare class Skapi {
1898
2779
  */
1899
2780
  signup_confirmation?: boolean | string;
1900
2781
  /**
1901
- * When true, user will be subscribed to the service newsletter (group 1) once they are signed up.
2782
+ * When true, user will be subscribed to Service Email (group 1) once they are signed up.
1902
2783
  * User's signup confirmation is required for this parameter.
1903
2784
  * Default is false.
1904
2785
  */
@@ -1929,6 +2810,13 @@ declare class Skapi {
1929
2810
  }>): Promise<'SUCCESS: New password has been set.'>;
1930
2811
  /**
1931
2812
  * Verifies the user email address with a confirmation code.
2813
+ * Call it without `code` to send the code, then with the code the user received.
2814
+ * Once the e-mail is verified it also logs the account in (a few seconds after
2815
+ * the verification succeeds) when the account was created with a username or its
2816
+ * e-mail was changed, unless that e-mail is a login ID another account of the
2817
+ * project was granted: the address that account was created or invited with, or
2818
+ * one it has verified. An e-mail login another account holds without having
2819
+ * verified the address is removed, and this account gets the login.
1932
2820
  * @param params Payload for the request.
1933
2821
  * @returns A promise that resolves to Promise<string>.
1934
2822
  */
@@ -1976,6 +2864,19 @@ declare class Skapi {
1976
2864
  }): Promise<'SUCCESS: Password has been changed.'>;
1977
2865
  /**
1978
2866
  * Updates profile attributes for the authenticated user.
2867
+ *
2868
+ * A changed e-mail is written unverified, and it logs the account in only once
2869
+ * it is verified with verifyEmail(): the login follows a few seconds after the
2870
+ * verification succeeds. The previous e-mail stops logging in right after the
2871
+ * change, unless it is the e-mail an account without a username was created with,
2872
+ * which stays its login ID. A username always logs in. E-mail login is not added
2873
+ * while the new e-mail is a login ID another account of the project was granted:
2874
+ * the address that account was created or invited with, or one it has verified.
2875
+ * An e-mail login another account holds without having verified the address is
2876
+ * removed instead, and this account gets the login.
2877
+ *
2878
+ * With another user's `user_id` it updates that user from admin context and
2879
+ * follows the rules of updateUserAttributes(). Your own `user_id` is ignored.
1979
2880
  * @param params Payload for the request.
1980
2881
  * @returns A promise that resolves to Promise<UserProfile>.
1981
2882
  */
@@ -2007,7 +2908,9 @@ declare class Skapi {
2007
2908
  }, fetchOptions?: FetchOptions): Promise<DatabaseResponse<Subscription>>;
2008
2909
  /**
2009
2910
  * Subscribes to another user with optional feed/notification/email preferences.
2010
- * @param params Request parameters.
2911
+ * Calling it again on the same user changes only the options given and keeps the rest,
2912
+ * so `get_notified` can be turned on or off without touching `get_feed`.
2913
+ * @param params Request parameters. `get_feed`: the user's records posted with `upload_to_feed` appear in getFeed(). `get_notified`: push notifications for the user's records posted with `notify_subscribers`, and for new references to their records with `notify_referencing_records` (the device also needs subscribeNotification()). A new subscription starts with every option off.
2011
2914
  * @returns A promise that resolves to Promise<Subscription>.
2012
2915
  */
2013
2916
  subscribe(params: {
@@ -2062,12 +2965,13 @@ declare class Skapi {
2062
2965
 
2063
2966
  declare class SkapiError extends Error {
2064
2967
  code: string | number;
2065
- cause: Error;
2968
+ /** The underlying Error, or the flat TicketError body of a failed ticket consumption (consumeTicket). */
2969
+ cause: Error | TicketError;
2066
2970
  constructor(error: any, options?: {
2067
2971
  name?: string;
2068
2972
  code?: string;
2069
- cause?: Error;
2973
+ cause?: Error | TicketError;
2070
2974
  });
2071
2975
  }
2072
2976
 
2073
- export { type BinaryFile, type Condition, type Connection, type ConnectionInfo, type DatabaseResponse, type DelRecordQuery, type FetchOptions, type FileInfo, type Form, type GetRecordQuery, type Index, type Newsletter, type NewsletterGroup, type PostRecordConfig, type ProgressCallback, type RTCConnector, type RTCConnectorParams, type RTCEvent, type RTCReceiverParams, type RTCResolved, type RealtimeCallback, type RecordData, Skapi, SkapiError, type Subscription, type Table, type Tag, Types, type UniqueId, type UserAttributes, type UserProfile, type UserPublic, type WebSocketMessage };
2977
+ export { type BinaryFile, type Condition, type Connection, type ConnectionInfo, type DatabaseResponse, type DelRecordQuery, type FetchOptions, type FileInfo, type Form, type GetRecordQuery, type Index, type Newsletter, type NewsletterGroup, type PostRecordConfig, type ProgressCallback, type RTCConnector, type RTCConnectorParams, type RTCEvent, type RTCReceiverParams, type RTCResolved, type RealtimeCallback, type RecordData, Skapi, SkapiError, type Subscription, type Table, type Tag, type Ticket, type TicketAction, type TicketCondition, type TicketConditionOperator, type TicketConditionRow, type TicketError, type TicketErrorCode, type TicketResponseCondition, type TicketSignatureCondition, Types, type UniqueId, type UserAttributes, type UserProfile, type UserPublic, type WebSocketMessage };