@peers-app/peers-sdk 0.1.4 → 0.1.6
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/context/data-context.js +1 -1
- package/dist/context/user-context-singleton.d.ts +1 -1
- package/dist/context/user-context-singleton.js +45 -43
- package/dist/context/user-context.d.ts +4 -4
- package/dist/context/user-context.js +26 -16
- package/dist/data/assistants.d.ts +1 -1
- package/dist/data/change-tracking.d.ts +16 -16
- package/dist/data/channels.d.ts +1 -1
- package/dist/data/data-locks.d.ts +2 -2
- package/dist/data/devices.d.ts +1 -1
- package/dist/data/embeddings.d.ts +1 -1
- package/dist/data/group-members.d.ts +2 -2
- package/dist/data/knowledge/knowledge-frames.d.ts +1 -1
- package/dist/data/knowledge/knowledge-links.d.ts +1 -1
- package/dist/data/knowledge/knowledge-values.d.ts +1 -1
- package/dist/data/knowledge/peer-types.d.ts +1 -1
- package/dist/data/knowledge/predicates.d.ts +1 -1
- package/dist/data/messages.d.ts +4 -4
- package/dist/data/peer-events/peer-event-handlers.d.ts +1 -1
- package/dist/data/peer-events/peer-event-types.d.ts +1 -1
- package/dist/data/tool-tests.d.ts +1 -1
- package/dist/data/tools.d.ts +1 -1
- package/dist/data/users.d.ts +2 -2
- package/dist/data/workflow-logs.d.ts +1 -1
- package/dist/data/workflows.d.ts +1 -1
- package/dist/rpc-types.d.ts +2 -1
- package/dist/rpc-types.js +2 -1
- package/package.json +7 -3
|
@@ -24,7 +24,7 @@ class DataContext {
|
|
|
24
24
|
this.tableContainer = new orm_1.TableContainer(tableFactory, groupId);
|
|
25
25
|
}
|
|
26
26
|
get dataContextId() {
|
|
27
|
-
return this.groupId || this.userContext.userId
|
|
27
|
+
return this.groupId || this.userContext.userId;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Call this to indicate that this should be the current data context to be used unless otherwise specified
|
|
@@ -5,7 +5,7 @@ export declare function getUserContext(): Promise<UserContext>;
|
|
|
5
5
|
export declare function setUserContext(userContext: UserContext): void;
|
|
6
6
|
export declare function getDefaultDataContext(): Promise<DataContext>;
|
|
7
7
|
export declare function getTableContainer(dataContext?: DataContext | undefined): import("../data/orm").TableContainer;
|
|
8
|
-
export declare function setDefaultClientUserContext(): void;
|
|
8
|
+
export declare function setDefaultClientUserContext(userId: string): void;
|
|
9
9
|
export declare function getAllTables(): {
|
|
10
10
|
[tableName: string]: Table<any>;
|
|
11
11
|
};
|
|
@@ -53,11 +53,11 @@ function getTableContainer(dataContext) {
|
|
|
53
53
|
}
|
|
54
54
|
return dataContext.tableContainer;
|
|
55
55
|
}
|
|
56
|
-
function setDefaultClientUserContext() {
|
|
56
|
+
function setDefaultClientUserContext(userId) {
|
|
57
57
|
const clientProxyDataSourceFactory = (metaData, schema, groupId) => {
|
|
58
58
|
return new client_proxy_data_source_1.ClientProxyDataSource(metaData, schema, groupId ?? '');
|
|
59
59
|
};
|
|
60
|
-
const userContext = new user_context_1.UserContext(clientProxyDataSourceFactory);
|
|
60
|
+
const userContext = new user_context_1.UserContext(userId, clientProxyDataSourceFactory);
|
|
61
61
|
(async () => {
|
|
62
62
|
const { GroupsTable } = await Promise.resolve().then(() => require("../data/groups"));
|
|
63
63
|
const { GroupMembersTable } = await Promise.resolve().then(() => require("../data/group-members"));
|
|
@@ -77,45 +77,47 @@ function getAllTables() {
|
|
|
77
77
|
}
|
|
78
78
|
return tableMap;
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
if (!rpc_types_1.isClient) {
|
|
81
|
+
async function getTable(dataContextId, tableName) {
|
|
82
|
+
const userContext = await getUserContext();
|
|
83
|
+
const table = userContext
|
|
84
|
+
.getDataContext(dataContextId || userContext.userId)
|
|
85
|
+
.tableContainer
|
|
86
|
+
.getTable(tableName);
|
|
87
|
+
return table;
|
|
88
|
+
}
|
|
89
|
+
// TODO: add check that client has permission to do the operation to the table
|
|
90
|
+
rpc_types_1.rpcServerCalls.tableGet = async (dataContextId, tableName, id) => {
|
|
91
|
+
const table = await getTable(dataContextId, tableName);
|
|
92
|
+
return table.get(id);
|
|
93
|
+
};
|
|
94
|
+
rpc_types_1.rpcServerCalls.tableList = async (dataContextId, tableName, filter, opts) => {
|
|
95
|
+
const table = await getTable(dataContextId, tableName);
|
|
96
|
+
return table.list(filter, opts);
|
|
97
|
+
};
|
|
98
|
+
rpc_types_1.rpcServerCalls.tableCount = async (dataContextId, tableName, filter) => {
|
|
99
|
+
const table = await getTable(dataContextId, tableName);
|
|
100
|
+
return table.count(filter);
|
|
101
|
+
};
|
|
102
|
+
rpc_types_1.rpcServerCalls.tableSave = async (dataContextId, tableName, data, opts) => {
|
|
103
|
+
const table = await getTable(dataContextId, tableName);
|
|
104
|
+
return table.save(data, opts);
|
|
105
|
+
};
|
|
106
|
+
rpc_types_1.rpcServerCalls.tableInsert = async (dataContextId, tableName, data) => {
|
|
107
|
+
const table = await getTable(dataContextId, tableName);
|
|
108
|
+
return table.insert(data);
|
|
109
|
+
};
|
|
110
|
+
rpc_types_1.rpcServerCalls.tableUpdate = async (dataContextId, tableName, data) => {
|
|
111
|
+
const table = await getTable(dataContextId, tableName);
|
|
112
|
+
return table.update(data);
|
|
113
|
+
};
|
|
114
|
+
rpc_types_1.rpcServerCalls.tableDelete = async (dataContextId, tableName, idOrRecord) => {
|
|
115
|
+
const table = await getTable(dataContextId, tableName);
|
|
116
|
+
return table.delete(idOrRecord);
|
|
117
|
+
};
|
|
118
|
+
rpc_types_1.rpcServerCalls.tableMethodCall = async (dataContextId, tableName, methodName, ...args) => {
|
|
119
|
+
const table = await getTable(dataContextId, tableName);
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
return table[methodName](...args);
|
|
122
|
+
};
|
|
87
123
|
}
|
|
88
|
-
// TODO: add check that client has permission to do the operation to the table
|
|
89
|
-
rpc_types_1.rpcServerCalls.tableGet = async (dataContextId, tableName, id) => {
|
|
90
|
-
const table = await getTable(dataContextId, tableName);
|
|
91
|
-
return table.get(id);
|
|
92
|
-
};
|
|
93
|
-
rpc_types_1.rpcServerCalls.tableList = async (dataContextId, tableName, filter, opts) => {
|
|
94
|
-
const table = await getTable(dataContextId, tableName);
|
|
95
|
-
return table.list(filter, opts);
|
|
96
|
-
};
|
|
97
|
-
rpc_types_1.rpcServerCalls.tableCount = async (dataContextId, tableName, filter) => {
|
|
98
|
-
const table = await getTable(dataContextId, tableName);
|
|
99
|
-
return table.count(filter);
|
|
100
|
-
};
|
|
101
|
-
rpc_types_1.rpcServerCalls.tableSave = async (dataContextId, tableName, data, opts) => {
|
|
102
|
-
const table = await getTable(dataContextId, tableName);
|
|
103
|
-
return table.save(data, opts);
|
|
104
|
-
};
|
|
105
|
-
rpc_types_1.rpcServerCalls.tableInsert = async (dataContextId, tableName, data) => {
|
|
106
|
-
const table = await getTable(dataContextId, tableName);
|
|
107
|
-
return table.insert(data);
|
|
108
|
-
};
|
|
109
|
-
rpc_types_1.rpcServerCalls.tableUpdate = async (dataContextId, tableName, data) => {
|
|
110
|
-
const table = await getTable(dataContextId, tableName);
|
|
111
|
-
return table.update(data);
|
|
112
|
-
};
|
|
113
|
-
rpc_types_1.rpcServerCalls.tableDelete = async (dataContextId, tableName, idOrRecord) => {
|
|
114
|
-
const table = await getTable(dataContextId, tableName);
|
|
115
|
-
return table.delete(idOrRecord);
|
|
116
|
-
};
|
|
117
|
-
rpc_types_1.rpcServerCalls.tableMethodCall = async (dataContextId, tableName, methodName, ...args) => {
|
|
118
|
-
const table = await getTable(dataContextId, tableName);
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
return table[methodName](...args);
|
|
121
|
-
};
|
|
@@ -5,8 +5,8 @@ import { TrustLevel } from "../device/socket.type";
|
|
|
5
5
|
import { IPublicPrivateKeys } from "../keys";
|
|
6
6
|
import { Observable } from "../observable";
|
|
7
7
|
export declare class UserContext {
|
|
8
|
+
readonly userId: string;
|
|
8
9
|
readonly dataSourceFactory: DataSourceFactory;
|
|
9
|
-
readonly userId: Observable<string>;
|
|
10
10
|
readonly deviceId: Observable<string>;
|
|
11
11
|
readonly currentlyActiveGroupId: Observable<string | undefined>;
|
|
12
12
|
readonly packagesRootDir: Observable<string>;
|
|
@@ -19,7 +19,7 @@ export declare class UserContext {
|
|
|
19
19
|
readonly groupDataContexts: Map<string, DataContext>;
|
|
20
20
|
readonly defaultDataContext: Observable<DataContext>;
|
|
21
21
|
readonly loadingPromise: Promise<UserContext>;
|
|
22
|
-
constructor(dataSourceFactory: DataSourceFactory);
|
|
22
|
+
constructor(userId: string, dataSourceFactory: DataSourceFactory);
|
|
23
23
|
private init;
|
|
24
24
|
/**
|
|
25
25
|
* We want to load all packages as part of user context initialization
|
|
@@ -37,12 +37,12 @@ export declare class UserContext {
|
|
|
37
37
|
getMe(): Promise<{
|
|
38
38
|
name: string;
|
|
39
39
|
publicKey: string;
|
|
40
|
-
userId: string;
|
|
41
40
|
publicBoxKey: string;
|
|
41
|
+
userId: string;
|
|
42
42
|
signature?: string | undefined;
|
|
43
43
|
trustLevel?: TrustLevel | undefined;
|
|
44
44
|
} | undefined>;
|
|
45
|
-
syncUserAndGroupObjects(keys: IPublicPrivateKeys, me?: IUser): Promise<void>;
|
|
45
|
+
syncUserAndGroupObjects(userId: string, keys: IPublicPrivateKeys, me?: IUser): Promise<void>;
|
|
46
46
|
subscribeToDataChangedAcrossAllGroups<T extends {
|
|
47
47
|
[key: string]: any;
|
|
48
48
|
}>(table: Table<T>, handler: (evt: ICrossGroupSubscriptionHandlerArgs<T>) => any): import("../events").ISubscriptionResult;
|
|
@@ -10,8 +10,9 @@ const keys_1 = require("../keys");
|
|
|
10
10
|
const observable_1 = require("../observable");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
class UserContext {
|
|
13
|
+
userId;
|
|
13
14
|
dataSourceFactory;
|
|
14
|
-
userId =
|
|
15
|
+
// public readonly userId: Observable<string> = observable<string>('');
|
|
15
16
|
deviceId = (0, observable_1.observable)('');
|
|
16
17
|
currentlyActiveGroupId = (0, observable_1.observable)();
|
|
17
18
|
packagesRootDir = (0, observable_1.observable)('');
|
|
@@ -22,7 +23,8 @@ class UserContext {
|
|
|
22
23
|
groupDataContexts = new Map();
|
|
23
24
|
defaultDataContext = (0, observable_1.observable)();
|
|
24
25
|
loadingPromise;
|
|
25
|
-
constructor(dataSourceFactory) {
|
|
26
|
+
constructor(userId, dataSourceFactory) {
|
|
27
|
+
this.userId = userId;
|
|
26
28
|
this.dataSourceFactory = dataSourceFactory;
|
|
27
29
|
this.userDataContext = new data_context_1.DataContext(this);
|
|
28
30
|
this.defaultDataContext(this.userDataContext);
|
|
@@ -72,7 +74,7 @@ class UserContext {
|
|
|
72
74
|
}
|
|
73
75
|
// ensure when currentlyActiveGroupId changes, currentlyActiveGroup is updated and vice versa
|
|
74
76
|
this.currentlyActiveGroupId.subscribe(async (groupId) => {
|
|
75
|
-
const dataContext = this.getDataContext(groupId || this.userId
|
|
77
|
+
const dataContext = this.getDataContext(groupId || this.userId);
|
|
76
78
|
this.defaultDataContext(dataContext);
|
|
77
79
|
});
|
|
78
80
|
this.defaultDataContext.subscribe((group) => {
|
|
@@ -85,11 +87,11 @@ class UserContext {
|
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
getDataContext(groupId) {
|
|
88
|
-
if (groupId === this.userId
|
|
90
|
+
if (!groupId || groupId === this.userId) {
|
|
89
91
|
return this.userDataContext;
|
|
90
92
|
}
|
|
91
93
|
if (!(0, utils_1.isid)(groupId)) {
|
|
92
|
-
throw new Error(`
|
|
94
|
+
throw new Error(`groupId is not a valid id: ${groupId}`);
|
|
93
95
|
}
|
|
94
96
|
if (!this.groupDataContexts.has(groupId)) {
|
|
95
97
|
if (!this.groupIds().includes(groupId)) {
|
|
@@ -112,9 +114,9 @@ class UserContext {
|
|
|
112
114
|
acc[curr.name] = curr.value?.value;
|
|
113
115
|
return acc;
|
|
114
116
|
}, {});
|
|
115
|
-
const userIdPVar =
|
|
116
|
-
this.userId(userIdPVar());
|
|
117
|
-
|
|
117
|
+
// const userIdPVar = deviceVar<string>('myUserId', { dbValue: varDbValues['myUserId'], userContext: this });
|
|
118
|
+
// this.userId(userIdPVar());
|
|
119
|
+
// linkObservables(userIdPVar, this.userId);
|
|
118
120
|
const deviceIdPVar = (0, data_1.deviceVar)('thisDeviceId', { dbValue: varDbValues['thisDeviceId'], userContext: this });
|
|
119
121
|
this.deviceId(deviceIdPVar());
|
|
120
122
|
(0, observable_1.linkObservables)(deviceIdPVar, this.deviceId);
|
|
@@ -131,15 +133,15 @@ class UserContext {
|
|
|
131
133
|
this.packageLocalPathsResolved(packageLocalPathsResolvedPVar());
|
|
132
134
|
(0, observable_1.linkObservables)(packageLocalPathsResolvedPVar, this.packageLocalPathsResolved);
|
|
133
135
|
if (typeof process !== 'undefined' && process.env) {
|
|
134
|
-
if (process.env.USER_ID) {
|
|
135
|
-
|
|
136
|
-
}
|
|
136
|
+
// if (process.env.USER_ID) {
|
|
137
|
+
// this.userId(process.env.USER_ID);
|
|
138
|
+
// }
|
|
137
139
|
if (process.env.DEVICE_ID) {
|
|
138
140
|
this.deviceId(process.env.DEVICE_ID);
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
await Promise.all([
|
|
142
|
-
userIdPVar.loadingPromise,
|
|
144
|
+
// userIdPVar.loadingPromise,
|
|
143
145
|
deviceIdPVar.loadingPromise,
|
|
144
146
|
packagesRootDirPVar.loadingPromise,
|
|
145
147
|
reloadPackagesOnPageRefreshPVar.loadingPromise,
|
|
@@ -147,15 +149,23 @@ class UserContext {
|
|
|
147
149
|
]);
|
|
148
150
|
}
|
|
149
151
|
async getMe() {
|
|
150
|
-
let dbMe = await (0, data_1.Users)(this.userDataContext).get(this.userId
|
|
152
|
+
let dbMe = await (0, data_1.Users)(this.userDataContext).get(this.userId, { useCache: true });
|
|
151
153
|
return dbMe;
|
|
152
154
|
}
|
|
153
|
-
async syncUserAndGroupObjects(keys, me) {
|
|
155
|
+
async syncUserAndGroupObjects(userId, keys, me) {
|
|
154
156
|
// update my user object for all contexts
|
|
155
157
|
const userContext = this;
|
|
156
158
|
me ??= await this.getMe();
|
|
157
159
|
if (!me) {
|
|
158
|
-
throw new Error('My user object was not passed in and was not found in my personal db')
|
|
160
|
+
// throw new Error('My user object was not passed in and was not found in my personal db')
|
|
161
|
+
console.warn(`My user object was not in db, creating now`);
|
|
162
|
+
me = {
|
|
163
|
+
userId,
|
|
164
|
+
name: 'Unnamed_1',
|
|
165
|
+
publicKey: '',
|
|
166
|
+
publicBoxKey: '',
|
|
167
|
+
trustLevel: socket_type_1.TrustLevel.Self,
|
|
168
|
+
};
|
|
159
169
|
}
|
|
160
170
|
me.publicKey = keys.publicKey;
|
|
161
171
|
me.publicBoxKey = keys.publicBoxKey;
|
|
@@ -190,7 +200,7 @@ class UserContext {
|
|
|
190
200
|
subscribeToDataChangedAcrossAllGroups(table, handler) {
|
|
191
201
|
const tableEventPrefix = `${table.tableName}_DataChanged_`;
|
|
192
202
|
const subscription = (0, events_1.subscribe)(evt => evt.name.startsWith(tableEventPrefix), async (evt) => {
|
|
193
|
-
const dataContextId = evt.name.endsWith('_') ? this.userId
|
|
203
|
+
const dataContextId = evt.name.endsWith('_') ? this.userId : evt.name.split('_').pop();
|
|
194
204
|
const dataContext = this.getDataContext(dataContextId);
|
|
195
205
|
handler({
|
|
196
206
|
name: evt.name,
|
|
@@ -39,7 +39,7 @@ export declare const assistantSchema: z.ZodObject<{
|
|
|
39
39
|
toolInclusionStrategy?: ToolInclusionStrategy | undefined;
|
|
40
40
|
}>;
|
|
41
41
|
export type IAssistant = z.infer<typeof assistantSchema>;
|
|
42
|
-
export declare function Assistants(dataContext?: DataContext): import("
|
|
42
|
+
export declare function Assistants(dataContext?: DataContext): import("..").Table<{
|
|
43
43
|
name: string;
|
|
44
44
|
createdAt: Date;
|
|
45
45
|
assistantId: string;
|
|
@@ -10,22 +10,22 @@ declare const insertChange: z.ZodObject<{
|
|
|
10
10
|
recordId: z.ZodString;
|
|
11
11
|
newRecord: z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
recordId: string;
|
|
13
14
|
changeId: string;
|
|
14
15
|
changeType: "insert" | "snapshot" | "restore";
|
|
15
16
|
timestamp: number;
|
|
16
17
|
timestampApplied: number;
|
|
17
18
|
tableName: string;
|
|
18
|
-
recordId: string;
|
|
19
19
|
newRecord: {} & {
|
|
20
20
|
[k: string]: any;
|
|
21
21
|
};
|
|
22
22
|
}, {
|
|
23
|
+
recordId: string;
|
|
23
24
|
changeId: string;
|
|
24
25
|
changeType: "insert" | "snapshot" | "restore";
|
|
25
26
|
timestamp: number;
|
|
26
27
|
timestampApplied: number;
|
|
27
28
|
tableName: string;
|
|
28
|
-
recordId: string;
|
|
29
29
|
newRecord: {} & {
|
|
30
30
|
[k: string]: any;
|
|
31
31
|
};
|
|
@@ -40,20 +40,20 @@ declare const deleteChange: z.ZodObject<{
|
|
|
40
40
|
recordId: z.ZodString;
|
|
41
41
|
oldRecord: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>>;
|
|
42
42
|
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
recordId: string;
|
|
43
44
|
changeId: string;
|
|
44
45
|
changeType: "delete";
|
|
45
46
|
timestamp: number;
|
|
46
47
|
timestampApplied: number;
|
|
47
48
|
tableName: string;
|
|
48
|
-
recordId: string;
|
|
49
49
|
oldRecord?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
|
|
50
50
|
}, {
|
|
51
|
+
recordId: string;
|
|
51
52
|
changeId: string;
|
|
52
53
|
changeType: "delete";
|
|
53
54
|
timestamp: number;
|
|
54
55
|
timestampApplied: number;
|
|
55
56
|
tableName: string;
|
|
56
|
-
recordId: string;
|
|
57
57
|
oldRecord?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
|
|
58
58
|
}>;
|
|
59
59
|
export type IChangeDelete = z.infer<typeof deleteChange>;
|
|
@@ -67,23 +67,23 @@ declare const updateChange: z.ZodObject<{
|
|
|
67
67
|
newRecord: z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>;
|
|
68
68
|
jsonDiff: z.ZodArray<z.ZodAny, "many">;
|
|
69
69
|
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
recordId: string;
|
|
70
71
|
changeId: string;
|
|
71
72
|
changeType: "update";
|
|
72
73
|
timestamp: number;
|
|
73
74
|
timestampApplied: number;
|
|
74
75
|
tableName: string;
|
|
75
|
-
recordId: string;
|
|
76
76
|
newRecord: {} & {
|
|
77
77
|
[k: string]: any;
|
|
78
78
|
};
|
|
79
79
|
jsonDiff: any[];
|
|
80
80
|
}, {
|
|
81
|
+
recordId: string;
|
|
81
82
|
changeId: string;
|
|
82
83
|
changeType: "update";
|
|
83
84
|
timestamp: number;
|
|
84
85
|
timestampApplied: number;
|
|
85
86
|
tableName: string;
|
|
86
|
-
recordId: string;
|
|
87
87
|
newRecord: {} & {
|
|
88
88
|
[k: string]: any;
|
|
89
89
|
};
|
|
@@ -99,22 +99,22 @@ declare const changeSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
99
99
|
recordId: z.ZodString;
|
|
100
100
|
newRecord: z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>;
|
|
101
101
|
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
recordId: string;
|
|
102
103
|
changeId: string;
|
|
103
104
|
changeType: "insert" | "snapshot" | "restore";
|
|
104
105
|
timestamp: number;
|
|
105
106
|
timestampApplied: number;
|
|
106
107
|
tableName: string;
|
|
107
|
-
recordId: string;
|
|
108
108
|
newRecord: {} & {
|
|
109
109
|
[k: string]: any;
|
|
110
110
|
};
|
|
111
111
|
}, {
|
|
112
|
+
recordId: string;
|
|
112
113
|
changeId: string;
|
|
113
114
|
changeType: "insert" | "snapshot" | "restore";
|
|
114
115
|
timestamp: number;
|
|
115
116
|
timestampApplied: number;
|
|
116
117
|
tableName: string;
|
|
117
|
-
recordId: string;
|
|
118
118
|
newRecord: {} & {
|
|
119
119
|
[k: string]: any;
|
|
120
120
|
};
|
|
@@ -127,20 +127,20 @@ declare const changeSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
127
127
|
recordId: z.ZodString;
|
|
128
128
|
oldRecord: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>>;
|
|
129
129
|
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
recordId: string;
|
|
130
131
|
changeId: string;
|
|
131
132
|
changeType: "delete";
|
|
132
133
|
timestamp: number;
|
|
133
134
|
timestampApplied: number;
|
|
134
135
|
tableName: string;
|
|
135
|
-
recordId: string;
|
|
136
136
|
oldRecord?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
|
|
137
137
|
}, {
|
|
138
|
+
recordId: string;
|
|
138
139
|
changeId: string;
|
|
139
140
|
changeType: "delete";
|
|
140
141
|
timestamp: number;
|
|
141
142
|
timestampApplied: number;
|
|
142
143
|
tableName: string;
|
|
143
|
-
recordId: string;
|
|
144
144
|
oldRecord?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
|
|
145
145
|
}>, z.ZodObject<{
|
|
146
146
|
changeId: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -152,23 +152,23 @@ declare const changeSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
152
152
|
newRecord: z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>;
|
|
153
153
|
jsonDiff: z.ZodArray<z.ZodAny, "many">;
|
|
154
154
|
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
recordId: string;
|
|
155
156
|
changeId: string;
|
|
156
157
|
changeType: "update";
|
|
157
158
|
timestamp: number;
|
|
158
159
|
timestampApplied: number;
|
|
159
160
|
tableName: string;
|
|
160
|
-
recordId: string;
|
|
161
161
|
newRecord: {} & {
|
|
162
162
|
[k: string]: any;
|
|
163
163
|
};
|
|
164
164
|
jsonDiff: any[];
|
|
165
165
|
}, {
|
|
166
|
+
recordId: string;
|
|
166
167
|
changeId: string;
|
|
167
168
|
changeType: "update";
|
|
168
169
|
timestamp: number;
|
|
169
170
|
timestampApplied: number;
|
|
170
171
|
tableName: string;
|
|
171
|
-
recordId: string;
|
|
172
172
|
newRecord: {} & {
|
|
173
173
|
[k: string]: any;
|
|
174
174
|
};
|
|
@@ -186,25 +186,25 @@ export declare const changeTrackingSchema: z.ZodObject<{
|
|
|
186
186
|
newRecord: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>>;
|
|
187
187
|
jsonDiff: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
188
188
|
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
recordId: string;
|
|
189
190
|
changeId: string;
|
|
190
191
|
changeType: "update" | "insert" | "delete" | "snapshot" | "restore";
|
|
191
192
|
timestamp: number;
|
|
192
193
|
timestampApplied: number;
|
|
193
194
|
tableName: string;
|
|
194
|
-
recordId: string;
|
|
195
195
|
newRecord?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
|
|
196
|
-
oldRecord?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
|
|
197
196
|
jsonDiff?: any[] | undefined;
|
|
197
|
+
oldRecord?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
|
|
198
198
|
}, {
|
|
199
|
+
recordId: string;
|
|
199
200
|
changeId: string;
|
|
200
201
|
changeType: "update" | "insert" | "delete" | "snapshot" | "restore";
|
|
201
202
|
timestamp: number;
|
|
202
203
|
timestampApplied: number;
|
|
203
204
|
tableName: string;
|
|
204
|
-
recordId: string;
|
|
205
205
|
newRecord?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
|
|
206
|
-
oldRecord?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
|
|
207
206
|
jsonDiff?: any[] | undefined;
|
|
207
|
+
oldRecord?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
|
|
208
208
|
}>;
|
|
209
209
|
export type IChangeAny = z.infer<typeof changeTrackingSchema>;
|
|
210
210
|
export declare class ChangeTrackingTable extends SQLDataSource<IChange> {
|
package/dist/data/channels.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const channelSchema: z.ZodObject<{
|
|
|
20
20
|
owningGroupId: string;
|
|
21
21
|
}>;
|
|
22
22
|
export type IChannel = z.infer<typeof channelSchema>;
|
|
23
|
-
export declare function Channels(dataContext?: DataContext): import("
|
|
23
|
+
export declare function Channels(dataContext?: DataContext): import("..").Table<{
|
|
24
24
|
name: string;
|
|
25
25
|
description: string;
|
|
26
26
|
createdAt: Date;
|
|
@@ -7,13 +7,13 @@ export declare const dataLockSchema: z.ZodObject<{
|
|
|
7
7
|
lockedUntil: z.ZodNumber;
|
|
8
8
|
acknowledged: z.ZodOptional<z.ZodNumber>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
recordId: string;
|
|
11
10
|
dataLockId: string;
|
|
11
|
+
recordId: string;
|
|
12
12
|
lockedUntil: number;
|
|
13
13
|
acknowledged?: number | undefined;
|
|
14
14
|
}, {
|
|
15
|
-
recordId: string;
|
|
16
15
|
dataLockId: string;
|
|
16
|
+
recordId: string;
|
|
17
17
|
lockedUntil: number;
|
|
18
18
|
acknowledged?: number | undefined;
|
|
19
19
|
}>;
|
package/dist/data/devices.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export interface IDeviceHandshake extends IDeviceInfo {
|
|
|
38
38
|
serverAddress: string;
|
|
39
39
|
timestamp: number;
|
|
40
40
|
}
|
|
41
|
-
export declare function Devices(dataContext?: DataContext): import("
|
|
41
|
+
export declare function Devices(dataContext?: DataContext): import("..").Table<{
|
|
42
42
|
userId: string;
|
|
43
43
|
trustLevel: TrustLevel;
|
|
44
44
|
deviceId: string;
|
|
@@ -34,7 +34,7 @@ export declare const embeddingSchema: z.ZodObject<{
|
|
|
34
34
|
embeddingType: string;
|
|
35
35
|
}>;
|
|
36
36
|
export type IEmbedding = z.infer<typeof embeddingSchema>;
|
|
37
|
-
export declare function Embeddings(dataContext?: DataContext): import("
|
|
37
|
+
export declare function Embeddings(dataContext?: DataContext): import("..").Table<{
|
|
38
38
|
metadata: {
|
|
39
39
|
fkId?: string | undefined;
|
|
40
40
|
} & {
|
|
@@ -13,16 +13,16 @@ export declare const groupMemberSchema: z.ZodObject<{
|
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
14
|
role: GroupMemberRole;
|
|
15
15
|
signature: string;
|
|
16
|
-
groupMemberId: string;
|
|
17
16
|
groupId: string;
|
|
18
17
|
userId: string;
|
|
18
|
+
groupMemberId: string;
|
|
19
19
|
deleted?: boolean | undefined;
|
|
20
20
|
}, {
|
|
21
21
|
role: GroupMemberRole;
|
|
22
22
|
signature: string;
|
|
23
|
-
groupMemberId: string;
|
|
24
23
|
groupId: string;
|
|
25
24
|
userId: string;
|
|
25
|
+
groupMemberId: string;
|
|
26
26
|
deleted?: boolean | undefined;
|
|
27
27
|
}>;
|
|
28
28
|
export type IGroupMember = z.infer<typeof groupMemberSchema>;
|
|
@@ -23,7 +23,7 @@ declare const knowledgeFrameSchema: z.ZodObject<{
|
|
|
23
23
|
conclusion?: string | undefined;
|
|
24
24
|
}>;
|
|
25
25
|
export type IKnowledgeFrame = z.infer<typeof knowledgeFrameSchema>;
|
|
26
|
-
export declare function KnowledgeFrames(dataContext?: DataContext): import("
|
|
26
|
+
export declare function KnowledgeFrames(dataContext?: DataContext): import("../..").Table<{
|
|
27
27
|
name: string;
|
|
28
28
|
body: string;
|
|
29
29
|
knowledgeFrameId: string;
|
|
@@ -20,7 +20,7 @@ declare const knowledgeLinkSchema: z.ZodObject<{
|
|
|
20
20
|
objectValueId?: string | undefined;
|
|
21
21
|
}>;
|
|
22
22
|
export type IKnowledgeLink = z.infer<typeof knowledgeLinkSchema>;
|
|
23
|
-
export declare function KnowledgeLinks(dataContext?: DataContext): import("
|
|
23
|
+
export declare function KnowledgeLinks(dataContext?: DataContext): import("../..").Table<{
|
|
24
24
|
knowledgeLinkId: string;
|
|
25
25
|
subjectValueId: string;
|
|
26
26
|
predicateId: string;
|
|
@@ -24,7 +24,7 @@ export declare const knowledgeValueSchema: z.ZodObject<{
|
|
|
24
24
|
lastModified?: Date | undefined;
|
|
25
25
|
}>;
|
|
26
26
|
export type IKnowledgeValue = z.infer<typeof knowledgeValueSchema>;
|
|
27
|
-
export declare function KnowledgeValues(dataContext?: DataContext): import("
|
|
27
|
+
export declare function KnowledgeValues(dataContext?: DataContext): import("../..").Table<{
|
|
28
28
|
name: string;
|
|
29
29
|
value: {} & {
|
|
30
30
|
[k: string]: any;
|
|
@@ -91,7 +91,7 @@ declare const valueTypeSchema: z.ZodObject<{
|
|
|
91
91
|
iconClass?: string | undefined;
|
|
92
92
|
}>;
|
|
93
93
|
export type IPeerType = z.infer<typeof valueTypeSchema>;
|
|
94
|
-
export declare function PeerTypes(dataContext?: DataContext): import("
|
|
94
|
+
export declare function PeerTypes(dataContext?: DataContext): import("../..").Table<{
|
|
95
95
|
name: string;
|
|
96
96
|
schema: {
|
|
97
97
|
type: import("../tools").IOSchemaType;
|
|
@@ -23,7 +23,7 @@ declare const predicateSchema: z.ZodObject<{
|
|
|
23
23
|
allowedObjectValueTypes?: string[] | undefined;
|
|
24
24
|
}>;
|
|
25
25
|
export type IPredicate = z.infer<typeof predicateSchema>;
|
|
26
|
-
export declare function Predicates(dataContext?: DataContext): import("
|
|
26
|
+
export declare function Predicates(dataContext?: DataContext): import("../..").Table<{
|
|
27
27
|
name: string;
|
|
28
28
|
predicateId: string;
|
|
29
29
|
description?: string | undefined;
|
package/dist/data/messages.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export declare const messageSchema: z.ZodObject<{
|
|
|
13
13
|
vars: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>>;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
15
|
message: string;
|
|
16
|
-
createdAt: Date;
|
|
17
16
|
userId: string;
|
|
17
|
+
createdAt: Date;
|
|
18
18
|
channelId: string;
|
|
19
19
|
messageId: string;
|
|
20
20
|
assistantId?: string | undefined;
|
|
@@ -24,8 +24,8 @@ export declare const messageSchema: z.ZodObject<{
|
|
|
24
24
|
fileIds?: string[] | undefined;
|
|
25
25
|
}, {
|
|
26
26
|
message: string;
|
|
27
|
-
createdAt: Date;
|
|
28
27
|
userId: string;
|
|
28
|
+
createdAt: Date;
|
|
29
29
|
channelId: string;
|
|
30
30
|
messageId: string;
|
|
31
31
|
assistantId?: string | undefined;
|
|
@@ -35,10 +35,10 @@ export declare const messageSchema: z.ZodObject<{
|
|
|
35
35
|
fileIds?: string[] | undefined;
|
|
36
36
|
}>;
|
|
37
37
|
export type IMessage = z.infer<typeof messageSchema>;
|
|
38
|
-
export declare function Messages(dataContext?: DataContext): import("
|
|
38
|
+
export declare function Messages(dataContext?: DataContext): import("..").Table<{
|
|
39
39
|
message: string;
|
|
40
|
-
createdAt: Date;
|
|
41
40
|
userId: string;
|
|
41
|
+
createdAt: Date;
|
|
42
42
|
channelId: string;
|
|
43
43
|
messageId: string;
|
|
44
44
|
assistantId?: string | undefined;
|
|
@@ -14,7 +14,7 @@ export declare const peerEventHandlerSchema: z.ZodObject<{
|
|
|
14
14
|
handlerWorkflowId: string;
|
|
15
15
|
}>;
|
|
16
16
|
export type IPeerEventHandler = z.infer<typeof peerEventHandlerSchema>;
|
|
17
|
-
export declare function PeerEventHandlers(dataContext?: DataContext): import("
|
|
17
|
+
export declare function PeerEventHandlers(dataContext?: DataContext): import("../..").Table<{
|
|
18
18
|
peerEventTypeId: string;
|
|
19
19
|
peerEventHandlerId: string;
|
|
20
20
|
handlerWorkflowId: string;
|
|
@@ -97,7 +97,7 @@ export declare const peerEventTypeSchema: z.ZodObject<{
|
|
|
97
97
|
nextScheduledTime?: number | undefined;
|
|
98
98
|
}>;
|
|
99
99
|
export type IPeerEventType = z.infer<typeof peerEventTypeSchema>;
|
|
100
|
-
export declare function PeerEventTypes(dataContext?: DataContext): import("
|
|
100
|
+
export declare function PeerEventTypes(dataContext?: DataContext): import("../..").Table<{
|
|
101
101
|
name: string;
|
|
102
102
|
description: string;
|
|
103
103
|
schema: {
|
|
@@ -26,7 +26,7 @@ export declare const toolTestSchema: z.ZodObject<{
|
|
|
26
26
|
mocks?: any;
|
|
27
27
|
}>;
|
|
28
28
|
export type IToolTest = z.infer<typeof toolTestSchema>;
|
|
29
|
-
export declare function ToolTests(dataContext?: DataContext): import("
|
|
29
|
+
export declare function ToolTests(dataContext?: DataContext): import("..").Table<{
|
|
30
30
|
code: string;
|
|
31
31
|
description: string;
|
|
32
32
|
toolId: string;
|
package/dist/data/tools.d.ts
CHANGED
|
@@ -311,7 +311,7 @@ export interface IToolInstance {
|
|
|
311
311
|
inputSchema?: z.ZodObject<any>;
|
|
312
312
|
outputSchema?: z.ZodObject<any>;
|
|
313
313
|
}
|
|
314
|
-
export declare function Tools(dataContext?: DataContext): import("
|
|
314
|
+
export declare function Tools(dataContext?: DataContext): import("..").Table<{
|
|
315
315
|
code: string;
|
|
316
316
|
name: string;
|
|
317
317
|
toolId: string;
|
package/dist/data/users.d.ts
CHANGED
|
@@ -12,15 +12,15 @@ export declare const userSchema: z.ZodObject<{
|
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
13
|
name: string;
|
|
14
14
|
publicKey: string;
|
|
15
|
-
userId: string;
|
|
16
15
|
publicBoxKey: string;
|
|
16
|
+
userId: string;
|
|
17
17
|
signature?: string | undefined;
|
|
18
18
|
trustLevel?: TrustLevel | undefined;
|
|
19
19
|
}, {
|
|
20
20
|
name: string;
|
|
21
21
|
publicKey: string;
|
|
22
|
-
userId: string;
|
|
23
22
|
publicBoxKey: string;
|
|
23
|
+
userId: string;
|
|
24
24
|
signature?: string | undefined;
|
|
25
25
|
trustLevel?: TrustLevel | undefined;
|
|
26
26
|
}>;
|
|
@@ -66,7 +66,7 @@ export declare const workflowLogSchema: z.ZodObject<{
|
|
|
66
66
|
isError?: boolean | undefined;
|
|
67
67
|
}>;
|
|
68
68
|
export type IWorkflowLog = z.infer<typeof workflowLogSchema>;
|
|
69
|
-
export declare function WorkflowLogs(dataContext?: DataContext): import("
|
|
69
|
+
export declare function WorkflowLogs(dataContext?: DataContext): import("..").Table<{
|
|
70
70
|
workflowLogId: string;
|
|
71
71
|
workflowRunId: string;
|
|
72
72
|
contextId: string;
|
package/dist/data/workflows.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DataContext } from "../context/data-context";
|
|
2
|
-
export declare function Workflows(dataContext?: DataContext): import("
|
|
2
|
+
export declare function Workflows(dataContext?: DataContext): import("..").Table<{
|
|
3
3
|
name: string;
|
|
4
4
|
description: string;
|
|
5
5
|
createdAt: Date;
|
package/dist/rpc-types.d.ts
CHANGED
|
@@ -12,12 +12,13 @@ export declare const rpcServerCalls: {
|
|
|
12
12
|
addRemotePackage: ((remoteRepo: string) => Promise<string>);
|
|
13
13
|
linkRemoteRepo: ((packageId: string) => Promise<void>);
|
|
14
14
|
installOrUpdatePackage: ((packageId: string) => Promise<void>);
|
|
15
|
+
setUserIdAndSecretKey: ((userId: string, secretKey: string) => Promise<void>);
|
|
16
|
+
getUserId: () => Promise<string | undefined>;
|
|
15
17
|
updateUserSettings: ((settings: {
|
|
16
18
|
id: string;
|
|
17
19
|
name: string;
|
|
18
20
|
value: any;
|
|
19
21
|
}) => Promise<void>);
|
|
20
|
-
setSecretKey: ((secretKey: string) => Promise<void>);
|
|
21
22
|
encryptData: ((value: string, groupId?: string) => Promise<string>);
|
|
22
23
|
tableGet: (dataContextId: string, tableName: string, id: string, opts?: {
|
|
23
24
|
useCache?: boolean;
|
package/dist/rpc-types.js
CHANGED
|
@@ -15,8 +15,9 @@ exports.rpcServerCalls = {
|
|
|
15
15
|
addRemotePackage: rpcStub('addRemotePackage'),
|
|
16
16
|
linkRemoteRepo: rpcStub('linkRemoteRepo'),
|
|
17
17
|
installOrUpdatePackage: rpcStub('installOrUpdatePackage'),
|
|
18
|
+
setUserIdAndSecretKey: rpcStub('setUserIdAndSecretKey'),
|
|
19
|
+
getUserId: rpcStub('getUserId'),
|
|
18
20
|
updateUserSettings: rpcStub('updateUserSettings'),
|
|
19
|
-
setSecretKey: rpcStub('setSecretKey'),
|
|
20
21
|
encryptData: rpcStub('encryptData'),
|
|
21
22
|
tableGet: rpcStub('tableGet'),
|
|
22
23
|
tableList: rpcStub('tableList'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peers-app/peers-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/peers-app/peers-sdk.git"
|
|
@@ -20,10 +20,14 @@
|
|
|
20
20
|
"./data": "./dist/data/index.js"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"
|
|
23
|
+
"clean": "rm -rf dist",
|
|
24
|
+
"build": "yarn clean && tsc",
|
|
24
25
|
"dev": "tsc -w",
|
|
25
26
|
"test": "jest",
|
|
26
|
-
"
|
|
27
|
+
"release:patch": "yarn build && npm version patch && git push && git push --tags",
|
|
28
|
+
"release:minor": "yarn build && npm version minor && git push && git push --tags",
|
|
29
|
+
"release:major": "yarn build && npm version major && git push && push --tags",
|
|
30
|
+
"release": "yarn release:patch"
|
|
27
31
|
},
|
|
28
32
|
"dependencies": {
|
|
29
33
|
"@noble/hashes": "^1.8.0",
|