@k2b/rsql 0.4.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/modules/namespaces.js +28 -2
- package/dist/types.d.ts +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,13 +61,17 @@ The `rsql` export reads `RSQL_URL` and `RSQL_API_TOKEN` lazily on first access:
|
|
|
61
61
|
```ts
|
|
62
62
|
import { rsql } from "@k2b/rsql";
|
|
63
63
|
|
|
64
|
-
await rsql.namespaces.list();
|
|
64
|
+
const page = await rsql.namespaces.list({ limit: 100 });
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
Imports remain browser-safe because environment variables are not read during
|
|
68
68
|
module evaluation. Browser applications should use an explicit client and must
|
|
69
69
|
not expose a server-wide administrative token.
|
|
70
70
|
|
|
71
|
+
Namespace lists use cursor pagination. Pass `page.data.next_cursor` to the next
|
|
72
|
+
`list` call, or call `listAll()` explicitly when the complete fleet must be
|
|
73
|
+
loaded into memory.
|
|
74
|
+
|
|
71
75
|
## Development
|
|
72
76
|
|
|
73
77
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createRsqlClient } from "./client.js";
|
|
2
2
|
export { rsql } from "./default.js";
|
|
3
|
-
export type { ApiErrorBody, ChangelogEntry, ColumnDefinition, CreateRsqlClientOptions, ImportFile, IndexCreateRequest, ListMeta, ListResponse, MutateOptions, NamespaceConfig, NamespaceDefinition, NamespaceModule, NamespaceOverview, NamespaceRecord, NamespacesModule, QueryInput, QueryRequest, QueryStatement, QueryValue, OverviewLatency, OverviewWindowName, RowsModule, RsqlClient, RsqlResult, SSEEvent, SSESubscribeOptions, SSESubscription, StorageSnapshot, TableCreateRequest, TableExportOptions, TableModule, TablesModule, TableUpdateRequest, } from "./types.js";
|
|
3
|
+
export type { ApiErrorBody, ChangelogEntry, ColumnDefinition, CreateRsqlClientOptions, ImportFile, IndexCreateRequest, ListMeta, ListResponse, MutateOptions, NamespaceConfig, NamespaceDefinition, NamespaceListOptions, NamespaceModule, NamespaceOverview, NamespacePage, NamespaceRecord, NamespacesModule, QueryInput, QueryRequest, QueryStatement, QueryValue, OverviewLatency, OverviewWindowName, RowsModule, RsqlClient, RsqlResult, SSEEvent, SSESubscribeOptions, SSESubscription, StorageSnapshot, TableCreateRequest, TableExportOptions, TableModule, TablesModule, TableUpdateRequest, } from "./types.js";
|
|
@@ -15,8 +15,33 @@ export const createNamespacesModule = (http) => {
|
|
|
15
15
|
body: JSON.stringify(payload),
|
|
16
16
|
});
|
|
17
17
|
},
|
|
18
|
-
list() {
|
|
19
|
-
return http.json(`/${version}/namespaces
|
|
18
|
+
list(options) {
|
|
19
|
+
return http.json(http.withQuery(`/${version}/namespaces`, {
|
|
20
|
+
limit: options?.limit,
|
|
21
|
+
cursor: options?.cursor,
|
|
22
|
+
}));
|
|
23
|
+
},
|
|
24
|
+
async listAll() {
|
|
25
|
+
const records = [];
|
|
26
|
+
let cursor;
|
|
27
|
+
let lastResult;
|
|
28
|
+
do {
|
|
29
|
+
lastResult = await http.json(http.withQuery(`/${version}/namespaces`, {
|
|
30
|
+
limit: 500,
|
|
31
|
+
cursor,
|
|
32
|
+
}));
|
|
33
|
+
if (!lastResult.ok) {
|
|
34
|
+
return lastResult;
|
|
35
|
+
}
|
|
36
|
+
records.push(...lastResult.data.data);
|
|
37
|
+
cursor = lastResult.data.next_cursor;
|
|
38
|
+
} while (cursor);
|
|
39
|
+
return {
|
|
40
|
+
ok: true,
|
|
41
|
+
data: records,
|
|
42
|
+
status: lastResult?.status ?? 200,
|
|
43
|
+
headers: lastResult?.headers ?? new Headers(),
|
|
44
|
+
};
|
|
20
45
|
},
|
|
21
46
|
get(name) {
|
|
22
47
|
return http.json(`/${version}/namespaces/${encodeURIComponent(name)}`);
|
|
@@ -64,6 +89,7 @@ export const createNamespacesModule = (http) => {
|
|
|
64
89
|
const withDefaultNamespaceConfig = (config) => {
|
|
65
90
|
const fallback = {
|
|
66
91
|
journal_mode: "wal",
|
|
92
|
+
synchronous: "full",
|
|
67
93
|
busy_timeout: 5000,
|
|
68
94
|
query_timeout: 10000,
|
|
69
95
|
foreign_keys: true,
|
package/dist/types.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface CreateRsqlClientOptions {
|
|
|
20
20
|
}
|
|
21
21
|
export interface NamespaceConfig {
|
|
22
22
|
journal_mode: string;
|
|
23
|
+
synchronous?: "full" | "normal";
|
|
23
24
|
busy_timeout: number;
|
|
24
25
|
max_db_size?: number;
|
|
25
26
|
query_timeout: number;
|
|
@@ -76,8 +77,8 @@ export interface IndexCreateRequest {
|
|
|
76
77
|
_meta?: Record<string, unknown>;
|
|
77
78
|
}
|
|
78
79
|
export interface ListMeta {
|
|
79
|
-
total_count
|
|
80
|
-
filter_count
|
|
80
|
+
total_count?: number;
|
|
81
|
+
filter_count?: number;
|
|
81
82
|
limit: number;
|
|
82
83
|
offset: number;
|
|
83
84
|
}
|
|
@@ -143,6 +144,14 @@ export interface NamespaceRecord {
|
|
|
143
144
|
last_activity_at?: string;
|
|
144
145
|
storage?: StorageSnapshot;
|
|
145
146
|
}
|
|
147
|
+
export interface NamespaceListOptions {
|
|
148
|
+
limit?: number;
|
|
149
|
+
cursor?: string;
|
|
150
|
+
}
|
|
151
|
+
export interface NamespacePage {
|
|
152
|
+
data: NamespaceRecord[];
|
|
153
|
+
next_cursor?: string;
|
|
154
|
+
}
|
|
146
155
|
export type OverviewWindowName = "1h" | "24h" | "7d" | "30d";
|
|
147
156
|
export interface StorageSnapshot {
|
|
148
157
|
used_bytes: number;
|
|
@@ -225,7 +234,8 @@ export interface NamespaceOverview {
|
|
|
225
234
|
}
|
|
226
235
|
export interface NamespacesModule {
|
|
227
236
|
create(request: NamespaceDefinition): Promise<RsqlResult<NamespaceRecord>>;
|
|
228
|
-
list(): Promise<RsqlResult<
|
|
237
|
+
list(options?: NamespaceListOptions): Promise<RsqlResult<NamespacePage>>;
|
|
238
|
+
listAll(): Promise<RsqlResult<NamespaceRecord[]>>;
|
|
229
239
|
get(name: string): Promise<RsqlResult<NamespaceRecord>>;
|
|
230
240
|
update(name: string, config: NamespaceConfig): Promise<RsqlResult<NamespaceRecord>>;
|
|
231
241
|
delete(name: string): Promise<RsqlResult<void>>;
|