sapixdb 0.1.0 → 0.3.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/admin.d.ts +88 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +101 -0
- package/dist/admin.js.map +1 -0
- package/dist/client.d.ts +83 -27
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +189 -40
- package/dist/client.js.map +1 -1
- package/dist/collection.d.ts +130 -37
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +186 -66
- package/dist/collection.js.map +1 -1
- package/dist/errors.d.ts +25 -7
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +50 -11
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/stream.d.ts +42 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +60 -0
- package/dist/stream.js.map +1 -0
- package/dist/types.d.ts +191 -50
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +15 -25
- package/README.md +0 -295
- package/dist/graph.d.ts +0 -28
- package/dist/graph.d.ts.map +0 -1
- package/dist/graph.js +0 -44
- package/dist/graph.js.map +0 -1
- package/dist/http.d.ts +0 -3
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -42
- package/dist/http.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { SapixClient } from "./client.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { SapixError,
|
|
5
|
-
export
|
|
2
|
+
export { AdminClient } from "./admin.js";
|
|
3
|
+
export { CollectionClient, CollectionSnapshot } from "./collection.js";
|
|
4
|
+
export { SapixError, SapixRateLimitError } from "./errors.js";
|
|
5
|
+
export { openAgentStream, openGlobalStream } from "./stream.js";
|
|
6
|
+
export type { AddEdgeRequest, AddRecordRefRequest, AgentStatusResponse, ApiKeyPatch, ApiKeyUsage, ApiKeyView, ChainHeadResponse, CheckpointResponse, CreateApiKeyRequest, CreateApiKeyResponse, DeletedRecord, EdgeView, GenesisRequest, GenesisResponse, HealthResponse, ListApiKeysResponse, QueryResult, RecordRefView, RecordView, SapixClientOptions, SaqlQuery, StrandRecordsResponse, WhereFilter, WriteResponse, } from "./types.js";
|
|
7
|
+
export type { StreamEvent, SubscribeOptions } from "./stream.js";
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,QAAQ,EACR,cAAc,EACd,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,qBAAqB,EACrB,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { SapixClient } from "./client.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { SapixError,
|
|
2
|
+
export { AdminClient } from "./admin.js";
|
|
3
|
+
export { CollectionClient, CollectionSnapshot } from "./collection.js";
|
|
4
|
+
export { SapixError, SapixRateLimitError } from "./errors.js";
|
|
5
|
+
export { openAgentStream, openGlobalStream } from "./stream.js";
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/stream.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** A realtime write event pushed via SSE from SapixDB. */
|
|
2
|
+
export interface StreamEvent {
|
|
3
|
+
agent_id: string;
|
|
4
|
+
event_type: string;
|
|
5
|
+
record_id: string;
|
|
6
|
+
content_hash: string;
|
|
7
|
+
timestamp_ms: number;
|
|
8
|
+
payload?: unknown;
|
|
9
|
+
}
|
|
10
|
+
/** Options for SSE subscriptions. */
|
|
11
|
+
export interface SubscribeOptions {
|
|
12
|
+
/** HLC timestamp — the server replays records written after this before going live. */
|
|
13
|
+
since?: number;
|
|
14
|
+
/** Only emit events whose JSON payload contains this top-level field name. */
|
|
15
|
+
filter?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Open an SSE stream for a single named agent.
|
|
19
|
+
*
|
|
20
|
+
* Returns an `EventSource`. Call `.close()` to unsubscribe.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const es = client.subscribeAgent("orders", (ev) => {
|
|
24
|
+
* console.log(ev.record_id, ev.payload);
|
|
25
|
+
* });
|
|
26
|
+
* es.close();
|
|
27
|
+
*/
|
|
28
|
+
export declare function openAgentStream(baseUrl: string, agentId: string, onEvent: (event: StreamEvent) => void, opts?: SubscribeOptions): EventSource;
|
|
29
|
+
/**
|
|
30
|
+
* Open an SSE stream for all agents on the node.
|
|
31
|
+
*
|
|
32
|
+
* Returns an `EventSource`. Call `.close()` to unsubscribe.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const es = client.subscribeGlobal((ev) => {
|
|
36
|
+
* console.log(ev.agent_id, ev.record_id);
|
|
37
|
+
* }, { agents: ["orders", "payments"] });
|
|
38
|
+
*/
|
|
39
|
+
export declare function openGlobalStream(baseUrl: string, onEvent: (event: StreamEvent) => void, opts?: SubscribeOptions & {
|
|
40
|
+
agents?: string[];
|
|
41
|
+
}): EventSource;
|
|
42
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EACrC,IAAI,CAAC,EAAE,gBAAgB,GACtB,WAAW,CAcb;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EACrC,IAAI,CAAC,EAAE,gBAAgB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC9C,WAAW,CAeb"}
|
package/dist/stream.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open an SSE stream for a single named agent.
|
|
3
|
+
*
|
|
4
|
+
* Returns an `EventSource`. Call `.close()` to unsubscribe.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const es = client.subscribeAgent("orders", (ev) => {
|
|
8
|
+
* console.log(ev.record_id, ev.payload);
|
|
9
|
+
* });
|
|
10
|
+
* es.close();
|
|
11
|
+
*/
|
|
12
|
+
export function openAgentStream(baseUrl, agentId, onEvent, opts) {
|
|
13
|
+
const params = new URLSearchParams();
|
|
14
|
+
if (opts?.since != null)
|
|
15
|
+
params.set("since", String(opts.since));
|
|
16
|
+
if (opts?.filter)
|
|
17
|
+
params.set("filter", opts.filter);
|
|
18
|
+
const qs = params.size > 0 ? `?${params}` : "";
|
|
19
|
+
const es = new EventSource(`${baseUrl}/v1/agents/${agentId}/stream${qs}`);
|
|
20
|
+
es.addEventListener("record.written", (e) => {
|
|
21
|
+
try {
|
|
22
|
+
onEvent(JSON.parse(e.data));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// ignore malformed events
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return es;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Open an SSE stream for all agents on the node.
|
|
32
|
+
*
|
|
33
|
+
* Returns an `EventSource`. Call `.close()` to unsubscribe.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const es = client.subscribeGlobal((ev) => {
|
|
37
|
+
* console.log(ev.agent_id, ev.record_id);
|
|
38
|
+
* }, { agents: ["orders", "payments"] });
|
|
39
|
+
*/
|
|
40
|
+
export function openGlobalStream(baseUrl, onEvent, opts) {
|
|
41
|
+
const params = new URLSearchParams();
|
|
42
|
+
if (opts?.agents?.length)
|
|
43
|
+
params.set("agents", opts.agents.join(","));
|
|
44
|
+
if (opts?.since != null)
|
|
45
|
+
params.set("since", String(opts.since));
|
|
46
|
+
if (opts?.filter)
|
|
47
|
+
params.set("filter", opts.filter);
|
|
48
|
+
const qs = params.size > 0 ? `?${params}` : "";
|
|
49
|
+
const es = new EventSource(`${baseUrl}/v1/stream${qs}`);
|
|
50
|
+
es.addEventListener("record.written", (e) => {
|
|
51
|
+
try {
|
|
52
|
+
onEvent(JSON.parse(e.data));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// ignore malformed events
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return es;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,OAAe,EACf,OAAqC,EACrC,IAAuB;IAEvB,MAAM,MAAM,GAAG,IAAI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AQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,MAAM,EAAE,GAAG,IAAI,WAAW,CAAC,GAAG,OAAO,aAAa,EAAE,EAAE,CAAC,CAAC;IACxD,EAAE,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,CAAC,CAAQ,EAAE,EAAE;QACjD,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAE,CAAkB,CAAC,IAAI,CAAgB,CAAC,CAAC;QAC/D,CAAC;QAAC,MAAM,CAAC;YACP,0BAA0B;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,65 +1,206 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export interface
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
export interface GenesisRequest {
|
|
2
|
+
zone?: "immutable_core" | "protected" | "governed" | "free";
|
|
3
|
+
}
|
|
4
|
+
export interface GenesisResponse {
|
|
5
|
+
agent_id: string;
|
|
6
|
+
public_key_hex: string;
|
|
7
|
+
genesis_record_id: string;
|
|
8
|
+
chain_head_hex: string;
|
|
9
|
+
zone: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentStatusResponse {
|
|
12
|
+
agent_id: string;
|
|
13
|
+
record_count: number;
|
|
14
|
+
chain_head: string;
|
|
15
|
+
schema_version: number;
|
|
16
|
+
zone: string;
|
|
17
|
+
caged: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface WriteRequest {
|
|
20
|
+
/** Base64-encoded payload bytes. */
|
|
21
|
+
payload_b64: string;
|
|
22
|
+
/** Block flag bits: GENESIS=1, TOMBSTONE=2, BLOB_REF=4. Default 0. */
|
|
23
|
+
flags?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface WriteResponse {
|
|
26
|
+
record_id: string;
|
|
27
|
+
content_hash: string;
|
|
28
|
+
chain_head: string;
|
|
29
|
+
/** null = Codios not configured (open mode); true = Codios authorized. */
|
|
30
|
+
codios_verified: boolean | null;
|
|
31
|
+
/** "open" or "enforced" */
|
|
32
|
+
codios_mode: string;
|
|
33
|
+
codios_contract_id?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface RecordView {
|
|
36
|
+
record_id: string;
|
|
37
|
+
content_hash: string;
|
|
38
|
+
parent_hash: string;
|
|
39
|
+
/** HLC timestamp packed as a u64. JSON number — safe to ~2^53 ms (~year 285,428). */
|
|
40
|
+
timestamp_hlc: number;
|
|
41
|
+
/** Wall-clock milliseconds since epoch extracted from the HLC. */
|
|
42
|
+
timestamp_ms: number;
|
|
43
|
+
/** Base64-encoded raw MessagePack payload bytes. */
|
|
44
|
+
payload_b64: string;
|
|
45
|
+
/**
|
|
46
|
+
* Payload decoded from MessagePack to a plain JSON value.
|
|
47
|
+
* `null` when the payload is raw binary (not a MessagePack map).
|
|
48
|
+
*/
|
|
49
|
+
payload: Record<string, unknown> | null;
|
|
50
|
+
/** Block flag bits (bit0=GENESIS, bit1=TOMBSTONE, bit2=BLOB_REF, bit3=MUTATION). */
|
|
51
|
+
flags: number;
|
|
52
|
+
schema_version: number;
|
|
53
|
+
}
|
|
54
|
+
export interface ChainHeadResponse {
|
|
55
|
+
chain_head: string;
|
|
56
|
+
record_count: number;
|
|
32
57
|
}
|
|
33
|
-
export interface
|
|
34
|
-
|
|
58
|
+
export interface StrandRecordsResponse {
|
|
59
|
+
records: RecordView[];
|
|
60
|
+
total: number;
|
|
35
61
|
}
|
|
36
|
-
export interface
|
|
62
|
+
export interface WhereFilter {
|
|
63
|
+
field: string;
|
|
64
|
+
op: "eq" | "between";
|
|
65
|
+
value: unknown;
|
|
66
|
+
/** Upper bound for `between` queries. */
|
|
67
|
+
upper?: unknown;
|
|
68
|
+
}
|
|
69
|
+
export type SaqlQuery = {
|
|
70
|
+
type: "hash";
|
|
71
|
+
content_hash: string;
|
|
72
|
+
} | {
|
|
73
|
+
type: "time_range";
|
|
74
|
+
from_ts: number;
|
|
75
|
+
to_ts: number;
|
|
76
|
+
} | {
|
|
77
|
+
type: "latest";
|
|
78
|
+
limit?: number;
|
|
79
|
+
} | {
|
|
80
|
+
type: "chain_head";
|
|
81
|
+
} | {
|
|
82
|
+
type: "as_of";
|
|
83
|
+
timestamp_hlc: number;
|
|
84
|
+
limit?: number;
|
|
85
|
+
} | {
|
|
86
|
+
type: "scan";
|
|
87
|
+
limit?: number;
|
|
88
|
+
filter?: WhereFilter;
|
|
89
|
+
};
|
|
90
|
+
export interface QueryResult {
|
|
91
|
+
records: RecordView[];
|
|
92
|
+
}
|
|
93
|
+
export interface AddEdgeRequest {
|
|
37
94
|
src: string;
|
|
38
|
-
dst: string;
|
|
39
95
|
edge_type: string;
|
|
96
|
+
dst: string;
|
|
40
97
|
weight?: number;
|
|
41
98
|
}
|
|
42
|
-
export interface
|
|
99
|
+
export interface EdgeView {
|
|
100
|
+
src: string;
|
|
101
|
+
edge_type: string;
|
|
102
|
+
dst: string;
|
|
43
103
|
timestamp_hlc: number;
|
|
104
|
+
weight: number;
|
|
105
|
+
}
|
|
106
|
+
export interface AddRecordRefRequest {
|
|
107
|
+
src_agent: string;
|
|
108
|
+
src_content_hash: string;
|
|
109
|
+
edge_type: string;
|
|
110
|
+
dst_agent: string;
|
|
111
|
+
dst_content_hash: string;
|
|
112
|
+
}
|
|
113
|
+
export interface RecordRefView {
|
|
114
|
+
src_agent: string;
|
|
115
|
+
src_content_hash: string;
|
|
116
|
+
edge_type: string;
|
|
117
|
+
dst_agent: string;
|
|
118
|
+
dst_content_hash: string;
|
|
44
119
|
}
|
|
45
|
-
export interface
|
|
46
|
-
|
|
47
|
-
|
|
120
|
+
export interface ApiKeyView {
|
|
121
|
+
key_id: string;
|
|
122
|
+
/** First 14 characters of the key, e.g. ``sapix_sk_a3f9…`` */
|
|
123
|
+
key_prefix: string;
|
|
124
|
+
label: string;
|
|
125
|
+
scopes: string[];
|
|
126
|
+
created_at_ms: number;
|
|
127
|
+
/** undefined = permanent key */
|
|
128
|
+
expires_at_ms?: number;
|
|
129
|
+
revoked: boolean;
|
|
130
|
+
caller_id?: string;
|
|
131
|
+
/** undefined = unlimited */
|
|
132
|
+
rate_limit_rps?: number;
|
|
48
133
|
}
|
|
49
|
-
export interface
|
|
50
|
-
|
|
51
|
-
|
|
134
|
+
export interface CreateApiKeyRequest {
|
|
135
|
+
label: string;
|
|
136
|
+
scopes: string[];
|
|
137
|
+
/** Unix ms expiry. Omit for a permanent key. */
|
|
138
|
+
expires_at_ms?: number;
|
|
139
|
+
caller_id?: string;
|
|
140
|
+
rate_limit_rps?: number;
|
|
52
141
|
}
|
|
53
|
-
export interface
|
|
142
|
+
export interface CreateApiKeyResponse extends ApiKeyView {
|
|
143
|
+
/** The full secret key — shown exactly once. Save it immediately. */
|
|
144
|
+
key: string;
|
|
145
|
+
warning: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Partial update for an existing key.
|
|
149
|
+
* Only provided fields are changed.
|
|
150
|
+
* Set a nullable field to `null` to clear it (e.g. remove expiry).
|
|
151
|
+
*/
|
|
152
|
+
export interface ApiKeyPatch {
|
|
153
|
+
label?: string;
|
|
154
|
+
scopes?: string[];
|
|
155
|
+
/** `null` = remove expiry (make permanent). */
|
|
156
|
+
expires_at_ms?: number | null;
|
|
157
|
+
/** `null` = remove caller identity override. */
|
|
158
|
+
caller_id?: string | null;
|
|
159
|
+
/** `null` = remove rate limit (unlimited). */
|
|
160
|
+
rate_limit_rps?: number | null;
|
|
161
|
+
}
|
|
162
|
+
export interface ApiKeyUsage {
|
|
163
|
+
key_id: string;
|
|
164
|
+
label: string;
|
|
165
|
+
request_count_since_restart: number;
|
|
166
|
+
/** undefined if the key has never been used since last restart. */
|
|
167
|
+
last_used_at_ms?: number;
|
|
168
|
+
}
|
|
169
|
+
export interface ListApiKeysResponse {
|
|
170
|
+
keys: ApiKeyView[];
|
|
171
|
+
total: number;
|
|
172
|
+
}
|
|
173
|
+
/** Returned by POST /v1/control/checkpoint. Requires root key or admin:* scope. */
|
|
174
|
+
export interface CheckpointResponse {
|
|
54
175
|
status: string;
|
|
55
|
-
|
|
176
|
+
agents_checkpointed: number;
|
|
177
|
+
}
|
|
178
|
+
/** A soft-deleted (tombstoned) record returned by GET /v1/agents/:id/records/deleted. */
|
|
179
|
+
export interface DeletedRecord {
|
|
180
|
+
record_id: string;
|
|
181
|
+
content_hash: string;
|
|
182
|
+
deleted_at_ms: number;
|
|
56
183
|
}
|
|
57
|
-
export interface
|
|
58
|
-
|
|
59
|
-
|
|
184
|
+
export interface HealthResponse {
|
|
185
|
+
status: "ok";
|
|
186
|
+
agent: string;
|
|
60
187
|
}
|
|
61
|
-
export interface
|
|
62
|
-
|
|
63
|
-
|
|
188
|
+
export interface SapixClientOptions {
|
|
189
|
+
/** sapix-agent base URL, e.g. "http://localhost:7475" */
|
|
190
|
+
baseUrl: string;
|
|
191
|
+
/**
|
|
192
|
+
* API key for SapixDB bearer-token authentication.
|
|
193
|
+
* When set, every request includes `Authorization: Bearer <apiKey>`.
|
|
194
|
+
*/
|
|
195
|
+
apiKey?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Caller identity forwarded to Codios as `caller_identity`.
|
|
198
|
+
* Sent as `X-Sapix-Caller: <callerId>`.
|
|
199
|
+
*/
|
|
200
|
+
callerId?: string;
|
|
201
|
+
/** Request timeout in milliseconds. Default: 10_000. */
|
|
202
|
+
timeoutMs?: number;
|
|
203
|
+
/** Optional fetch override (useful for testing). Default: globalThis.fetch */
|
|
204
|
+
fetch?: typeof globalThis.fetch;
|
|
64
205
|
}
|
|
65
206
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,gBAAgB,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;CAC7D;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAID,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,2BAA2B;IA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AM,CAAC;CACvB;AAID,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAID,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,kFAAkF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sapixdb",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "TypeScript SDK for SapixDB agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -11,33 +11,23 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"dev": "tsc --watch",
|
|
17
|
-
"test": "node --experimental-vm-modules node_modules/.bin/jest"
|
|
18
|
-
},
|
|
19
14
|
"files": [
|
|
20
|
-
"dist"
|
|
21
|
-
"README.md"
|
|
22
|
-
],
|
|
23
|
-
"keywords": [
|
|
24
|
-
"sapixdb",
|
|
25
|
-
"database",
|
|
26
|
-
"agent-native",
|
|
27
|
-
"ai-database",
|
|
28
|
-
"sdk",
|
|
29
|
-
"typescript"
|
|
15
|
+
"dist"
|
|
30
16
|
],
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"url": "https://github.com/sensart/sapixdb"
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"test": "node --experimental-vm-modules node_modules/.bin/jest",
|
|
20
|
+
"typecheck": "tsc --noEmit"
|
|
36
21
|
},
|
|
37
22
|
"devDependencies": {
|
|
38
|
-
"typescript": "^5.4.0"
|
|
23
|
+
"typescript": "^5.4.0",
|
|
24
|
+
"@types/node": "^20.0.0",
|
|
25
|
+
"jest": "^29.0.0",
|
|
26
|
+
"@jest/globals": "^29.0.0",
|
|
27
|
+
"ts-jest": "^29.0.0"
|
|
39
28
|
},
|
|
40
29
|
"engines": {
|
|
41
|
-
"node": ">=18
|
|
42
|
-
}
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"license": "Apache-2.0"
|
|
43
33
|
}
|