@peers-app/peers-sdk 0.7.2 → 0.7.5
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.d.ts +1 -1
- package/dist/context/data-context.js +2 -3
- package/dist/context/user-context-singleton.js +13 -31
- package/dist/context/user-context.d.ts +2 -5
- package/dist/context/user-context.js +20 -15
- 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/data-locks.test.js +3 -0
- package/dist/data/devices.d.ts +4 -4
- package/dist/data/embeddings.d.ts +1 -1
- package/dist/data/group-members.d.ts +7 -4
- package/dist/data/group-members.js +98 -32
- package/dist/data/groups.d.ts +7 -3
- package/dist/data/groups.js +91 -30
- package/dist/data/index.d.ts +1 -0
- package/dist/data/index.js +1 -0
- 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/orm/client-proxy.data-source.js +8 -18
- package/dist/data/orm/decorators.d.ts +1 -1
- package/dist/data/orm/decorators.js +7 -6
- package/dist/data/packages.d.ts +2 -1
- package/dist/data/packages.js +90 -40
- 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/persistent-vars.js +124 -119
- package/dist/data/tool-tests.d.ts +1 -1
- package/dist/data/tools.d.ts +1 -1
- package/dist/data/user-permissions.test.js +7 -10
- package/dist/data/user-trust-levels.d.ts +42 -0
- package/dist/data/user-trust-levels.js +60 -0
- package/dist/data/users.d.ts +7 -7
- package/dist/data/users.js +86 -27
- package/dist/data/workflow-logs.d.ts +1 -1
- package/dist/data/workflow-runs.js +1 -1
- package/dist/data/workflows.d.ts +1 -1
- package/dist/device/connection.js +2 -2
- package/dist/device/get-trust-level.js +10 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/logging/console-logger.d.ts +10 -0
- package/dist/logging/console-logger.js +206 -0
- package/dist/logging/console-logs.table.d.ts +48 -0
- package/dist/logging/console-logs.table.js +140 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.js +18 -0
- package/dist/rpc-types.d.ts +0 -11
- package/dist/rpc-types.js +0 -8
- package/dist/types/peer-device.d.ts +10 -0
- package/dist/users.query.d.ts +3 -1
- package/dist/users.query.js +39 -11
- package/package.json +1 -1
|
@@ -1,16 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
2
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
37
|
exports.GroupMembersTable = exports.groupMembersTableName = exports.groupMemberSchema = void 0;
|
|
4
38
|
exports.GroupMembers = GroupMembers;
|
|
5
39
|
const zod_1 = require("zod");
|
|
6
40
|
const user_context_singleton_1 = require("../context/user-context-singleton");
|
|
41
|
+
const decorators_1 = require("../data/orm/decorators");
|
|
7
42
|
const zod_types_1 = require("../types/zod-types");
|
|
8
|
-
const orm_1 = require("./orm");
|
|
9
|
-
const table_definitions_system_1 = require("./orm/table-definitions.system");
|
|
10
|
-
const types_1 = require("./orm/types");
|
|
11
43
|
const group_member_roles_1 = require("./group-member-roles");
|
|
12
44
|
const group_permissions_1 = require("./group-permissions");
|
|
13
|
-
const
|
|
45
|
+
const table_1 = require("./orm/table");
|
|
46
|
+
const table_definitions_system_1 = require("./orm/table-definitions.system");
|
|
47
|
+
const types_1 = require("./orm/types");
|
|
48
|
+
const users_1 = require("./users");
|
|
14
49
|
exports.groupMemberSchema = zod_1.z.object({
|
|
15
50
|
groupMemberId: zod_types_1.zodPeerId,
|
|
16
51
|
groupId: zod_types_1.zodPeerId.describe('The id of the group'),
|
|
@@ -29,38 +64,69 @@ const metaData = {
|
|
|
29
64
|
{ fields: ['groupId', 'userId'], unique: true },
|
|
30
65
|
]
|
|
31
66
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
67
|
+
let GroupMembersTable = (() => {
|
|
68
|
+
let _classSuper = table_1.Table;
|
|
69
|
+
let _instanceExtraInitializers = [];
|
|
70
|
+
let _signAndSave_decorators;
|
|
71
|
+
return class GroupMembersTable extends _classSuper {
|
|
72
|
+
static {
|
|
73
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
74
|
+
_signAndSave_decorators = [(0, decorators_1.ProxyClientTableMethodCalls)()];
|
|
75
|
+
__esDecorate(this, null, _signAndSave_decorators, { kind: "method", name: "signAndSave", static: false, private: false, access: { has: obj => "signAndSave" in obj, get: obj => obj.signAndSave }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
76
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
37
77
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
78
|
+
static isPassthrough = false;
|
|
79
|
+
async save(groupMember, opts) {
|
|
80
|
+
if (GroupMembersTable.isPassthrough) {
|
|
81
|
+
return super.save(groupMember, opts);
|
|
82
|
+
}
|
|
83
|
+
const me = await (0, users_1.getMe)();
|
|
84
|
+
if (groupMember.groupId === me.userId) {
|
|
85
|
+
throw new Error('Group members cannot be added to personal user contexts');
|
|
86
|
+
}
|
|
87
|
+
const oldGroupMember = groupMember.groupMemberId ? await this.get(groupMember.groupMemberId) : undefined;
|
|
88
|
+
if (await (0, group_permissions_1.isGroupMemberSignatureValid)(groupMember.groupId, groupMember, oldGroupMember)) {
|
|
89
|
+
return super.save(groupMember, opts);
|
|
90
|
+
}
|
|
91
|
+
throw new Error('Group member signature is not valid');
|
|
41
92
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
93
|
+
async signAndSave(groupMember, opts) {
|
|
94
|
+
if (!GroupMembersTable.addSignatureToGroupMember) {
|
|
95
|
+
throw new Error('Group member signing must be enabled to sign and save group members. Call GroupMembersTable.enableGroupMemberSigning(fn) to enable it.');
|
|
96
|
+
}
|
|
97
|
+
groupMember = GroupMembersTable.addSignatureToGroupMember(groupMember);
|
|
98
|
+
return this.save(groupMember, opts);
|
|
47
99
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
await
|
|
100
|
+
async delete(groupMemberId) {
|
|
101
|
+
if (GroupMembersTable.isPassthrough) {
|
|
102
|
+
return super.delete(groupMemberId);
|
|
103
|
+
}
|
|
104
|
+
const groupMember = await this.get(groupMemberId);
|
|
105
|
+
if (groupMember) {
|
|
106
|
+
groupMember.deleted = true;
|
|
107
|
+
groupMember.role = group_member_roles_1.GroupMemberRole.None;
|
|
108
|
+
// we do a soft delete by saving the object with deleted=true and
|
|
109
|
+
await this.signAndSave(groupMember);
|
|
110
|
+
}
|
|
53
111
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
112
|
+
static addSignatureToGroupMember = undefined;
|
|
113
|
+
static enableGroupMemberSigning(fn) {
|
|
114
|
+
GroupMembersTable.addSignatureToGroupMember = fn;
|
|
115
|
+
}
|
|
116
|
+
/** @deprecated Forbidden on GroupsTable; use save() */
|
|
117
|
+
insert(..._args) {
|
|
118
|
+
throw new Error('GroupsTable forbids insert; use save()');
|
|
119
|
+
}
|
|
120
|
+
/** @deprecated Forbidden on GroupsTable; use save() */
|
|
121
|
+
update(..._args) {
|
|
122
|
+
throw new Error('GroupsTable forbids update; use save()');
|
|
123
|
+
}
|
|
124
|
+
constructor() {
|
|
125
|
+
super(...arguments);
|
|
126
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
})();
|
|
64
130
|
exports.GroupMembersTable = GroupMembersTable;
|
|
65
131
|
(0, table_definitions_system_1.registerSystemTableDefinition)(metaData, exports.groupMemberSchema, GroupMembersTable);
|
|
66
132
|
function GroupMembers(dataContext) {
|
package/dist/data/groups.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { DataContext } from "../context/data-context";
|
|
3
3
|
import { GroupMemberRole } from "./group-member-roles";
|
|
4
|
-
import { ISaveOptions
|
|
4
|
+
import type { ISaveOptions } from "./orm/data-query";
|
|
5
|
+
import { Table } from "./orm/table";
|
|
5
6
|
export declare const groupSchema: z.ZodObject<{
|
|
6
7
|
groupId: z.ZodEffects<z.ZodString, string, string>;
|
|
7
8
|
name: z.ZodString;
|
|
@@ -18,9 +19,9 @@ export declare const groupSchema: z.ZodObject<{
|
|
|
18
19
|
description: string;
|
|
19
20
|
signature: string;
|
|
20
21
|
publicKey: string;
|
|
22
|
+
publicBoxKey: string;
|
|
21
23
|
groupId: string;
|
|
22
24
|
founderUserId: string;
|
|
23
|
-
publicBoxKey: string;
|
|
24
25
|
disabled?: boolean | undefined;
|
|
25
26
|
iconClassName?: string | undefined;
|
|
26
27
|
publicRole?: GroupMemberRole | undefined;
|
|
@@ -29,9 +30,9 @@ export declare const groupSchema: z.ZodObject<{
|
|
|
29
30
|
description: string;
|
|
30
31
|
signature: string;
|
|
31
32
|
publicKey: string;
|
|
33
|
+
publicBoxKey: string;
|
|
32
34
|
groupId: string;
|
|
33
35
|
founderUserId: string;
|
|
34
|
-
publicBoxKey: string;
|
|
35
36
|
disabled?: boolean | undefined;
|
|
36
37
|
iconClassName?: string | undefined;
|
|
37
38
|
publicRole?: GroupMemberRole | undefined;
|
|
@@ -41,7 +42,10 @@ export declare const groupsTableName = "Groups";
|
|
|
41
42
|
export declare class GroupsTable extends Table<IGroup> {
|
|
42
43
|
static isPassthrough: boolean;
|
|
43
44
|
save(group: IGroup, opts?: ISaveOptions): Promise<IGroup>;
|
|
45
|
+
signAndSave(group: IGroup, opts?: ISaveOptions): Promise<IGroup>;
|
|
44
46
|
delete(groupId: string): Promise<void>;
|
|
47
|
+
private static addSignatureToGroup;
|
|
48
|
+
static enableGroupSigning(fn: (group: IGroup) => IGroup): void;
|
|
45
49
|
/** @deprecated Direct inserts forbidden; use save() */
|
|
46
50
|
insert(..._args: Parameters<Table<IGroup>['insert']>): never;
|
|
47
51
|
/** @deprecated Direct updates forbidden; use save() */
|
package/dist/data/groups.js
CHANGED
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
2
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
37
|
exports.GroupsTable = exports.groupsTableName = exports.groupSchema = void 0;
|
|
4
38
|
exports.Groups = Groups;
|
|
@@ -7,7 +41,8 @@ const user_context_singleton_1 = require("../context/user-context-singleton");
|
|
|
7
41
|
const zod_types_1 = require("../types/zod-types");
|
|
8
42
|
const group_member_roles_1 = require("./group-member-roles");
|
|
9
43
|
const group_permissions_1 = require("./group-permissions");
|
|
10
|
-
const
|
|
44
|
+
const decorators_1 = require("./orm/decorators");
|
|
45
|
+
const table_1 = require("./orm/table");
|
|
11
46
|
const table_definitions_system_1 = require("./orm/table-definitions.system");
|
|
12
47
|
const types_1 = require("./orm/types");
|
|
13
48
|
exports.groupSchema = zod_1.z.object({
|
|
@@ -33,39 +68,65 @@ const metaData = {
|
|
|
33
68
|
{ fields: ['name'] },
|
|
34
69
|
]
|
|
35
70
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
71
|
+
let GroupsTable = (() => {
|
|
72
|
+
let _classSuper = table_1.Table;
|
|
73
|
+
let _instanceExtraInitializers = [];
|
|
74
|
+
let _signAndSave_decorators;
|
|
75
|
+
return class GroupsTable extends _classSuper {
|
|
76
|
+
static {
|
|
77
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
78
|
+
_signAndSave_decorators = [(0, decorators_1.ProxyClientTableMethodCalls)()];
|
|
79
|
+
__esDecorate(this, null, _signAndSave_decorators, { kind: "method", name: "signAndSave", static: false, private: false, access: { has: obj => "signAndSave" in obj, get: obj => obj.signAndSave }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
80
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
41
81
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
82
|
+
static isPassthrough = false;
|
|
83
|
+
async save(group, opts) {
|
|
84
|
+
if (GroupsTable.isPassthrough) {
|
|
85
|
+
return super.save(group, opts);
|
|
86
|
+
}
|
|
87
|
+
const userContext = await (0, user_context_singleton_1.getUserContext)();
|
|
88
|
+
const userContextGroups = Groups(userContext.userDataContext);
|
|
89
|
+
if (userContextGroups === this) {
|
|
90
|
+
// users can do whatever they want to groups in their personal space
|
|
91
|
+
return super.save(group, opts);
|
|
92
|
+
}
|
|
93
|
+
const oldGroup = await this.get(group.groupId);
|
|
94
|
+
await (0, group_permissions_1.verifyGroupSignature)(group, oldGroup);
|
|
46
95
|
return super.save(group, opts);
|
|
47
96
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const userContextGroups = Groups(userContext.userDataContext);
|
|
55
|
-
if (userContextGroups === this) {
|
|
56
|
-
return super.delete(groupId);
|
|
97
|
+
async signAndSave(group, opts) {
|
|
98
|
+
if (!GroupsTable.addSignatureToGroup) {
|
|
99
|
+
throw new Error('Group signing must be enabled to sign and save groups. Call GroupsTable.enableGroupSigning(fn) to enable it.');
|
|
100
|
+
}
|
|
101
|
+
group = GroupsTable.addSignatureToGroup(group);
|
|
102
|
+
return this.save(group, opts);
|
|
57
103
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
104
|
+
async delete(groupId) {
|
|
105
|
+
const userContext = await (0, user_context_singleton_1.getUserContext)();
|
|
106
|
+
const userContextGroups = Groups(userContext.userDataContext);
|
|
107
|
+
if (userContextGroups === this) {
|
|
108
|
+
return super.delete(groupId);
|
|
109
|
+
}
|
|
110
|
+
throw new Error('Only deleting groups from the user context Groups table is allowed');
|
|
111
|
+
}
|
|
112
|
+
static addSignatureToGroup = undefined;
|
|
113
|
+
static enableGroupSigning(fn) {
|
|
114
|
+
this.addSignatureToGroup = fn;
|
|
115
|
+
}
|
|
116
|
+
/** @deprecated Direct inserts forbidden; use save() */
|
|
117
|
+
insert(..._args) {
|
|
118
|
+
throw new Error('Direct inserts forbidden; use save()');
|
|
119
|
+
}
|
|
120
|
+
/** @deprecated Direct updates forbidden; use save() */
|
|
121
|
+
update(..._args) {
|
|
122
|
+
throw new Error('Direct updates forbidden; use save()');
|
|
123
|
+
}
|
|
124
|
+
constructor() {
|
|
125
|
+
super(...arguments);
|
|
126
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
})();
|
|
69
130
|
exports.GroupsTable = GroupsTable;
|
|
70
131
|
(0, table_definitions_system_1.registerSystemTableDefinition)(metaData, exports.groupSchema, GroupsTable);
|
|
71
132
|
function Groups(dataContext) {
|
package/dist/data/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from "./tool-tests";
|
|
|
27
27
|
export * from "./tools";
|
|
28
28
|
export * from "./users";
|
|
29
29
|
export * from "./user-permissions";
|
|
30
|
+
export * from "./user-trust-levels";
|
|
30
31
|
export * from "./workflow-logs";
|
|
31
32
|
export * from "./workflow-runs";
|
|
32
33
|
export * from "./workflows";
|
package/dist/data/index.js
CHANGED
|
@@ -43,6 +43,7 @@ __exportStar(require("./tool-tests"), exports);
|
|
|
43
43
|
__exportStar(require("./tools"), exports);
|
|
44
44
|
__exportStar(require("./users"), exports);
|
|
45
45
|
__exportStar(require("./user-permissions"), exports);
|
|
46
|
+
__exportStar(require("./user-trust-levels"), exports);
|
|
46
47
|
__exportStar(require("./workflow-logs"), exports);
|
|
47
48
|
__exportStar(require("./workflow-runs"), exports);
|
|
48
49
|
__exportStar(require("./workflows"), exports);
|
|
@@ -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("../orm").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("../orm").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("../orm").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("../orm").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("../orm").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
|
-
userId: string;
|
|
17
16
|
createdAt: Date;
|
|
17
|
+
userId: string;
|
|
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
|
-
userId: string;
|
|
28
27
|
createdAt: Date;
|
|
28
|
+
userId: string;
|
|
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("./orm").Table<{
|
|
39
39
|
message: string;
|
|
40
|
-
userId: string;
|
|
41
40
|
createdAt: Date;
|
|
41
|
+
userId: string;
|
|
42
42
|
channelId: string;
|
|
43
43
|
messageId: string;
|
|
44
44
|
assistantId?: string | undefined;
|
|
@@ -23,43 +23,33 @@ class ClientProxyDataSource {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
async get(id, opts = {}) {
|
|
26
|
-
return rpc_types_1.rpcServerCalls.
|
|
26
|
+
return rpc_types_1.rpcServerCalls.tableMethodCall(this.dataContextId, this.tableName, 'get', id, opts);
|
|
27
27
|
}
|
|
28
28
|
async list(filter = {}, opts = {}) {
|
|
29
|
-
return rpc_types_1.rpcServerCalls.
|
|
29
|
+
return rpc_types_1.rpcServerCalls.tableMethodCall(this.dataContextId, this.tableName, 'list', filter, opts);
|
|
30
30
|
}
|
|
31
31
|
;
|
|
32
32
|
async count(filter = {}) {
|
|
33
|
-
return rpc_types_1.rpcServerCalls.
|
|
33
|
+
return rpc_types_1.rpcServerCalls.tableMethodCall(this.dataContextId, this.tableName, 'count', filter);
|
|
34
34
|
}
|
|
35
35
|
;
|
|
36
36
|
cursor(filter = {}, opts = {}) {
|
|
37
37
|
return (0, data_query_1.dataSourceCursor)(this, filter, opts);
|
|
38
38
|
}
|
|
39
39
|
async findOne(filter = {}, opts) {
|
|
40
|
-
|
|
41
|
-
const records = await this.list(filter, { pageSize: 1 });
|
|
42
|
-
return records[0];
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
const records = await this.list(filter, { pageSize: 2 });
|
|
46
|
-
if (records.length > 1) {
|
|
47
|
-
throw new Error(`Matched more than one record for ${this.tableName} with query ${JSON.stringify(filter)}`);
|
|
48
|
-
}
|
|
49
|
-
return records[0];
|
|
50
|
-
}
|
|
40
|
+
return rpc_types_1.rpcServerCalls.tableMethodCall(this.dataContextId, this.tableName, 'findOne', filter, opts);
|
|
51
41
|
}
|
|
52
42
|
async save(record, opts) {
|
|
53
|
-
return rpc_types_1.rpcServerCalls.
|
|
43
|
+
return rpc_types_1.rpcServerCalls.tableMethodCall(this.dataContextId, this.tableName, 'save', record, opts);
|
|
54
44
|
}
|
|
55
45
|
async insert(record) {
|
|
56
|
-
return rpc_types_1.rpcServerCalls.
|
|
46
|
+
return rpc_types_1.rpcServerCalls.tableMethodCall(this.dataContextId, this.tableName, 'insert', record);
|
|
57
47
|
}
|
|
58
48
|
async update(record) {
|
|
59
|
-
return rpc_types_1.rpcServerCalls.
|
|
49
|
+
return rpc_types_1.rpcServerCalls.tableMethodCall(this.dataContextId, this.tableName, 'update', record);
|
|
60
50
|
}
|
|
61
51
|
async delete(idOrRecord) {
|
|
62
|
-
return rpc_types_1.rpcServerCalls.
|
|
52
|
+
return rpc_types_1.rpcServerCalls.tableMethodCall(this.dataContextId, this.tableName, 'delete', idOrRecord);
|
|
63
53
|
}
|
|
64
54
|
}
|
|
65
55
|
exports.ClientProxyDataSource = ClientProxyDataSource;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* When used on the client side, these methods will be automatically proxied
|
|
4
4
|
* to the server via rpcServerCalls.tableMethodCall.
|
|
5
5
|
*/
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function ProxyClientTableMethodCalls(): (target: any, context: any) => any;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ProxyClientTableMethodCalls = ProxyClientTableMethodCalls;
|
|
4
|
+
const rpc_types_1 = require("../../rpc-types");
|
|
4
5
|
/**
|
|
5
6
|
* Decorator that marks a table method as server-side only.
|
|
6
7
|
* When used on the client side, these methods will be automatically proxied
|
|
7
8
|
* to the server via rpcServerCalls.tableMethodCall.
|
|
8
9
|
*/
|
|
9
|
-
function
|
|
10
|
+
function ProxyClientTableMethodCalls() {
|
|
10
11
|
return function (target, context) {
|
|
11
|
-
if (context.kind === 'method' &&
|
|
12
|
+
if (context.kind === 'method' && rpc_types_1.isClient) {
|
|
12
13
|
const methodName = context.name;
|
|
14
|
+
// WARNING: Using typescript's magical `this` param
|
|
13
15
|
return function (...args) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return rpcServerCalls.tableMethodCall(this.dataContextId, this.tableName, methodName, ...args);
|
|
16
|
+
const dataContextId = this.dataSource.dataContextId || this.groupId || '';
|
|
17
|
+
return rpc_types_1.rpcServerCalls.tableMethodCall(dataContextId, this.tableName, methodName, ...args);
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
return target;
|
package/dist/data/packages.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { DataContext } from "../context/data-context";
|
|
3
|
-
import { ISaveOptions
|
|
3
|
+
import type { ISaveOptions } from "./orm/data-query";
|
|
4
|
+
import { Table } from "./orm/table";
|
|
4
5
|
declare const schema: z.ZodObject<{
|
|
5
6
|
packageId: z.ZodString;
|
|
6
7
|
name: z.ZodString;
|