skapi-js 2.0.0-rc.8 → 2.0.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.mts CHANGED
@@ -53,8 +53,8 @@ type GetRecordQuery = {
53
53
  table?: string | {
54
54
  /** Max 256 characters, where / ! * # % each count as 3. Blocks control chars and sentinel 􏿿. */
55
55
  name: string;
56
- /** Number range: 0 ~ 99. Default: 'public' */
57
- access_group?: number | 'private' | 'public' | 'authorized' | 'admin';
56
+ /** Number range: 0 ~ 99. 'public' = 0, 'authorized' = 1, 'admin' = 99. '*' is shorthand for 'private'. Default: 'public' */
57
+ access_group?: number | 'private' | '*' | 'public' | 'authorized' | 'admin';
58
58
  /** User ID of subscription */
59
59
  subscription?: string;
60
60
  };
@@ -83,8 +83,8 @@ type PostRecordConfig = {
83
83
  table?: {
84
84
  /** Max 256 characters, where / ! * # % each count as 3. Blocks control chars and sentinel 􏿿. */
85
85
  name?: string;
86
- /** Number range: 0 ~ 99. Default: 'public' */
87
- access_group?: number | 'private' | 'public' | 'authorized' | 'admin';
86
+ /** Number range: 0 ~ 99. 'public' = 0, 'authorized' = 1, 'admin' = 99. '*' is shorthand for 'private'. Default: 'public' */
87
+ access_group?: number | 'private' | '*' | 'public' | 'authorized' | 'admin';
88
88
  /** When true, Record will be only accessible for subscribed users. */
89
89
  subscription?: {
90
90
  is_subscription_record?: boolean;
@@ -170,7 +170,7 @@ type EncryptionOptions = boolean | {
170
170
  * encrypted records are permanently unreadable.
171
171
  */
172
172
  recovery?: 'code' | 'none';
173
- /** Reserved keyring table name. Default 'skapi__keyring'. */
173
+ /** Reserved keyring table name. Default '__skapi__keyring'. */
174
174
  table?: string;
175
175
  };
176
176
  type RecordData = {
@@ -248,6 +248,12 @@ type Connection = {
248
248
  prevent_inquiry: boolean;
249
249
  prevent_signup: boolean;
250
250
  prevent_anonymous: boolean;
251
+ /**
252
+ * BunnyQuery: whether the embeddable chat requires an account before a
253
+ * visitor can use it. Unrelated to `prevent_anonymous`, which governs
254
+ * anonymous record WRITES. Defaults to true.
255
+ */
256
+ require_login?: boolean;
251
257
  };
252
258
  ai_agent?: string;
253
259
  };
@@ -544,6 +550,7 @@ type RequestHistory = {
544
550
  latency?: number;
545
551
  onResponse?: (res: any) => void;
546
552
  onError?: (err: any) => void;
553
+ onStream?: (chunk: string, seq: number) => void;
547
554
  }) => Promise<any>;
548
555
  };
549
556
  type DatabaseResponse<T> = {
@@ -579,6 +586,12 @@ type ConnectionInfo = {
579
586
  prevent_signup: boolean;
580
587
  prevent_inquiry: boolean;
581
588
  prevent_anonymous: boolean;
589
+ /**
590
+ * BunnyQuery: whether the embeddable chat requires an account before a
591
+ * visitor can use it. Unrelated to `prevent_anonymous`, which governs
592
+ * anonymous record WRITES. Defaults to true.
593
+ */
594
+ require_login?: boolean;
582
595
  };
583
596
  };
584
597
  type Table = {
@@ -995,6 +1008,8 @@ declare class Skapi {
995
1008
  expires?: number;
996
1009
  onResponse?: (res: any) => void;
997
1010
  onError?: (err: any) => void;
1011
+ stream?: boolean;
1012
+ onStream?: (chunk: string, seq: number) => void;
998
1013
  }): Promise<any | {
999
1014
  id: string;
1000
1015
  status: 'running' | 'pending';
@@ -1002,6 +1017,7 @@ declare class Skapi {
1002
1017
  in_queue: number;
1003
1018
  poll?: (arg?: {
1004
1019
  latency?: number;
1020
+ onStream?: (chunk: string, seq: number) => void;
1005
1021
  }) => Promise<any>;
1006
1022
  }>;
1007
1023
  /**
@@ -1033,6 +1049,63 @@ declare class Skapi {
1033
1049
  * @param params Request parameters.
1034
1050
  * @returns A promise that resolves to a result object with removed status and message.
1035
1051
  */
1052
+ /**
1053
+ * Reads a streamed clientSecretRequest that this call did not start: a page reload,
1054
+ * a second tab, or a turn from history that was never finalized.
1055
+ *
1056
+ * `onStream` receives the relayed text in order, exactly as the destination sent it.
1057
+ * skapi does not parse it; whatever grammar those bytes are in belongs to the caller
1058
+ * and its destination. Pass `since` to resume rather than re-read from the beginning.
1059
+ *
1060
+ * When the request is still running this polls until it settles. When it has already
1061
+ * settled it reads every chunk once and resolves.
1062
+ *
1063
+ * ```js
1064
+ * const parser = createMyParser();
1065
+ * await skapi.clientSecretRequestStream(requestId, {
1066
+ * url: 'https://api.example.com/v1/chat',
1067
+ * method: 'POST',
1068
+ * onStream: (chunk) => parser.feed(chunk)
1069
+ * });
1070
+ * ```
1071
+ */
1072
+ clientSecretRequestStream(requestId: string, options: {
1073
+ url?: string;
1074
+ method?: 'GET' | 'POST' | 'DELETE' | 'PUT';
1075
+ onStream?: (chunk: string, seq: number) => void;
1076
+ since?: number;
1077
+ poll?: number;
1078
+ onResponse?: (res: any) => void;
1079
+ onError?: (err: any) => void;
1080
+ service?: string;
1081
+ owner?: string;
1082
+ }): Promise<any>;
1083
+ /**
1084
+ * Stores the version of a streamed response you want KEPT as history, and releases
1085
+ * the relayed chunks it was assembled from.
1086
+ *
1087
+ * The content is entirely yours. skapi neither validates nor interprets it: it stores
1088
+ * what you tell it to store. Only the caller who made the request may finalize it.
1089
+ *
1090
+ * Until you finalize, the chunks stay indefinitely and every read of that turn has to
1091
+ * fetch and re-parse all of them, so finalize as soon as you have rendered the answer.
1092
+ *
1093
+ * ```js
1094
+ * await skapi.clientSecretRequestFinalize(requestId, parser.result(), {
1095
+ * url: 'https://api.example.com/v1/chat',
1096
+ * method: 'POST'
1097
+ * });
1098
+ * ```
1099
+ */
1100
+ clientSecretRequestFinalize(requestId: string, data?: any, options?: {
1101
+ url?: string;
1102
+ method?: 'GET' | 'POST' | 'DELETE' | 'PUT';
1103
+ service?: string;
1104
+ owner?: string;
1105
+ }): Promise<{
1106
+ finalized: boolean;
1107
+ message: string;
1108
+ }>;
1036
1109
  cancelClientSecretRequest(params: {
1037
1110
  url: string;
1038
1111
  method: 'GET' | 'POST' | 'DELETE' | 'PUT';
package/dist/skapi.d.ts CHANGED
@@ -53,8 +53,8 @@ type GetRecordQuery = {
53
53
  table?: string | {
54
54
  /** Max 256 characters, where / ! * # % each count as 3. Blocks control chars and sentinel 􏿿. */
55
55
  name: string;
56
- /** Number range: 0 ~ 99. Default: 'public' */
57
- access_group?: number | 'private' | 'public' | 'authorized' | 'admin';
56
+ /** Number range: 0 ~ 99. 'public' = 0, 'authorized' = 1, 'admin' = 99. '*' is shorthand for 'private'. Default: 'public' */
57
+ access_group?: number | 'private' | '*' | 'public' | 'authorized' | 'admin';
58
58
  /** User ID of subscription */
59
59
  subscription?: string;
60
60
  };
@@ -83,8 +83,8 @@ type PostRecordConfig = {
83
83
  table?: {
84
84
  /** Max 256 characters, where / ! * # % each count as 3. Blocks control chars and sentinel 􏿿. */
85
85
  name?: string;
86
- /** Number range: 0 ~ 99. Default: 'public' */
87
- access_group?: number | 'private' | 'public' | 'authorized' | 'admin';
86
+ /** Number range: 0 ~ 99. 'public' = 0, 'authorized' = 1, 'admin' = 99. '*' is shorthand for 'private'. Default: 'public' */
87
+ access_group?: number | 'private' | '*' | 'public' | 'authorized' | 'admin';
88
88
  /** When true, Record will be only accessible for subscribed users. */
89
89
  subscription?: {
90
90
  is_subscription_record?: boolean;
@@ -170,7 +170,7 @@ type EncryptionOptions = boolean | {
170
170
  * encrypted records are permanently unreadable.
171
171
  */
172
172
  recovery?: 'code' | 'none';
173
- /** Reserved keyring table name. Default 'skapi__keyring'. */
173
+ /** Reserved keyring table name. Default '__skapi__keyring'. */
174
174
  table?: string;
175
175
  };
176
176
  type RecordData = {
@@ -248,6 +248,12 @@ type Connection = {
248
248
  prevent_inquiry: boolean;
249
249
  prevent_signup: boolean;
250
250
  prevent_anonymous: boolean;
251
+ /**
252
+ * BunnyQuery: whether the embeddable chat requires an account before a
253
+ * visitor can use it. Unrelated to `prevent_anonymous`, which governs
254
+ * anonymous record WRITES. Defaults to true.
255
+ */
256
+ require_login?: boolean;
251
257
  };
252
258
  ai_agent?: string;
253
259
  };
@@ -544,6 +550,7 @@ type RequestHistory = {
544
550
  latency?: number;
545
551
  onResponse?: (res: any) => void;
546
552
  onError?: (err: any) => void;
553
+ onStream?: (chunk: string, seq: number) => void;
547
554
  }) => Promise<any>;
548
555
  };
549
556
  type DatabaseResponse<T> = {
@@ -579,6 +586,12 @@ type ConnectionInfo = {
579
586
  prevent_signup: boolean;
580
587
  prevent_inquiry: boolean;
581
588
  prevent_anonymous: boolean;
589
+ /**
590
+ * BunnyQuery: whether the embeddable chat requires an account before a
591
+ * visitor can use it. Unrelated to `prevent_anonymous`, which governs
592
+ * anonymous record WRITES. Defaults to true.
593
+ */
594
+ require_login?: boolean;
582
595
  };
583
596
  };
584
597
  type Table = {
@@ -995,6 +1008,8 @@ declare class Skapi {
995
1008
  expires?: number;
996
1009
  onResponse?: (res: any) => void;
997
1010
  onError?: (err: any) => void;
1011
+ stream?: boolean;
1012
+ onStream?: (chunk: string, seq: number) => void;
998
1013
  }): Promise<any | {
999
1014
  id: string;
1000
1015
  status: 'running' | 'pending';
@@ -1002,6 +1017,7 @@ declare class Skapi {
1002
1017
  in_queue: number;
1003
1018
  poll?: (arg?: {
1004
1019
  latency?: number;
1020
+ onStream?: (chunk: string, seq: number) => void;
1005
1021
  }) => Promise<any>;
1006
1022
  }>;
1007
1023
  /**
@@ -1033,6 +1049,63 @@ declare class Skapi {
1033
1049
  * @param params Request parameters.
1034
1050
  * @returns A promise that resolves to a result object with removed status and message.
1035
1051
  */
1052
+ /**
1053
+ * Reads a streamed clientSecretRequest that this call did not start: a page reload,
1054
+ * a second tab, or a turn from history that was never finalized.
1055
+ *
1056
+ * `onStream` receives the relayed text in order, exactly as the destination sent it.
1057
+ * skapi does not parse it; whatever grammar those bytes are in belongs to the caller
1058
+ * and its destination. Pass `since` to resume rather than re-read from the beginning.
1059
+ *
1060
+ * When the request is still running this polls until it settles. When it has already
1061
+ * settled it reads every chunk once and resolves.
1062
+ *
1063
+ * ```js
1064
+ * const parser = createMyParser();
1065
+ * await skapi.clientSecretRequestStream(requestId, {
1066
+ * url: 'https://api.example.com/v1/chat',
1067
+ * method: 'POST',
1068
+ * onStream: (chunk) => parser.feed(chunk)
1069
+ * });
1070
+ * ```
1071
+ */
1072
+ clientSecretRequestStream(requestId: string, options: {
1073
+ url?: string;
1074
+ method?: 'GET' | 'POST' | 'DELETE' | 'PUT';
1075
+ onStream?: (chunk: string, seq: number) => void;
1076
+ since?: number;
1077
+ poll?: number;
1078
+ onResponse?: (res: any) => void;
1079
+ onError?: (err: any) => void;
1080
+ service?: string;
1081
+ owner?: string;
1082
+ }): Promise<any>;
1083
+ /**
1084
+ * Stores the version of a streamed response you want KEPT as history, and releases
1085
+ * the relayed chunks it was assembled from.
1086
+ *
1087
+ * The content is entirely yours. skapi neither validates nor interprets it: it stores
1088
+ * what you tell it to store. Only the caller who made the request may finalize it.
1089
+ *
1090
+ * Until you finalize, the chunks stay indefinitely and every read of that turn has to
1091
+ * fetch and re-parse all of them, so finalize as soon as you have rendered the answer.
1092
+ *
1093
+ * ```js
1094
+ * await skapi.clientSecretRequestFinalize(requestId, parser.result(), {
1095
+ * url: 'https://api.example.com/v1/chat',
1096
+ * method: 'POST'
1097
+ * });
1098
+ * ```
1099
+ */
1100
+ clientSecretRequestFinalize(requestId: string, data?: any, options?: {
1101
+ url?: string;
1102
+ method?: 'GET' | 'POST' | 'DELETE' | 'PUT';
1103
+ service?: string;
1104
+ owner?: string;
1105
+ }): Promise<{
1106
+ finalized: boolean;
1107
+ message: string;
1108
+ }>;
1036
1109
  cancelClientSecretRequest(params: {
1037
1110
  url: string;
1038
1111
  method: 'GET' | 'POST' | 'DELETE' | 'PUT';