@omujs/omu 0.9.48 → 0.9.50
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/address.js +1 -0
- package/dist/address.js.map +7 -0
- package/dist/api/asset/extension.d.ts +25 -0
- package/dist/api/asset/extension.js +2 -0
- package/dist/api/asset/extension.js.map +7 -0
- package/dist/api/asset/index.d.ts +2 -0
- package/dist/api/asset/index.js +2 -0
- package/dist/api/asset/index.js.map +7 -0
- package/dist/api/dashboard/extension.d.ts +181 -0
- package/dist/api/dashboard/extension.js +2 -0
- package/dist/api/dashboard/extension.js.map +7 -0
- package/{src/api/dashboard/handler.ts → dist/api/dashboard/handler.d.ts} +3 -5
- package/dist/api/dashboard/handler.js +1 -0
- package/dist/api/dashboard/handler.js.map +7 -0
- package/dist/api/dashboard/index.d.ts +3 -0
- package/dist/api/dashboard/index.js +2 -0
- package/dist/api/dashboard/index.js.map +7 -0
- package/dist/api/dashboard/packets.d.ts +63 -0
- package/dist/api/dashboard/packets.js +2 -0
- package/dist/api/dashboard/packets.js.map +7 -0
- package/dist/api/endpoint/endpoint.d.ts +21 -0
- package/dist/api/endpoint/endpoint.js +2 -0
- package/dist/api/endpoint/endpoint.js.map +7 -0
- package/dist/api/endpoint/extension.d.ts +17 -0
- package/dist/api/endpoint/extension.js +2 -0
- package/dist/api/endpoint/extension.js.map +7 -0
- package/{src/api/endpoint/index.ts → dist/api/endpoint/index.d.ts} +0 -1
- package/dist/api/endpoint/index.js +2 -0
- package/dist/api/endpoint/index.js.map +7 -0
- package/dist/api/endpoint/packets.d.ts +51 -0
- package/dist/api/endpoint/packets.js +2 -0
- package/dist/api/endpoint/packets.js.map +7 -0
- package/dist/api/extension-registry.d.ts +8 -0
- package/dist/api/extension-registry.js +2 -0
- package/dist/api/extension-registry.js.map +7 -0
- package/dist/api/extension.d.ts +11 -0
- package/dist/api/extension.js +2 -0
- package/dist/api/extension.js.map +7 -0
- package/dist/api/http/extension.d.ts +41 -0
- package/dist/api/http/extension.js +2 -0
- package/dist/api/http/extension.js.map +7 -0
- package/dist/api/http/http.d.ts +36 -0
- package/dist/api/http/http.js +2 -0
- package/dist/api/http/http.js.map +7 -0
- package/{src/api/http/index.ts → dist/api/http/index.d.ts} +0 -1
- package/dist/api/http/index.js +2 -0
- package/dist/api/http/index.js.map +7 -0
- package/dist/api/http/websocket.d.ts +125 -0
- package/dist/api/http/websocket.js +2 -0
- package/dist/api/http/websocket.js.map +7 -0
- package/dist/api/i18n/extension.d.ts +19 -0
- package/dist/api/i18n/extension.js +2 -0
- package/dist/api/i18n/extension.js.map +7 -0
- package/{src/api/i18n/index.ts → dist/api/i18n/index.d.ts} +0 -1
- package/dist/api/i18n/index.js +2 -0
- package/dist/api/i18n/index.js.map +7 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +7 -0
- package/dist/api/logger/extension.d.ts +25 -0
- package/dist/api/logger/extension.js +2 -0
- package/dist/api/logger/extension.js.map +7 -0
- package/dist/api/logger/index.d.ts +1 -0
- package/dist/api/logger/index.js +2 -0
- package/dist/api/logger/index.js.map +7 -0
- package/dist/api/logger/packets.d.ts +18 -0
- package/dist/api/logger/packets.js +2 -0
- package/dist/api/logger/packets.js.map +7 -0
- package/dist/api/permission/extension.d.ts +19 -0
- package/dist/api/permission/extension.js +2 -0
- package/dist/api/permission/extension.js.map +7 -0
- package/{src/api/permission/index.ts → dist/api/permission/index.d.ts} +0 -1
- package/dist/api/permission/index.js +2 -0
- package/dist/api/permission/index.js.map +7 -0
- package/dist/api/permission/permission.d.ts +25 -0
- package/dist/api/permission/permission.js +2 -0
- package/dist/api/permission/permission.js.map +7 -0
- package/dist/api/plugin/extension.d.ts +43 -0
- package/dist/api/plugin/extension.js +2 -0
- package/dist/api/plugin/extension.js.map +7 -0
- package/{src/api/plugin/index.ts → dist/api/plugin/index.d.ts} +0 -1
- package/dist/api/plugin/index.js +2 -0
- package/dist/api/plugin/index.js.map +7 -0
- package/{src/api/plugin/package-info.ts → dist/api/plugin/package-info.d.ts} +0 -7
- package/dist/api/plugin/package-info.js +1 -0
- package/dist/api/plugin/package-info.js.map +7 -0
- package/dist/api/registry/extension.d.ts +23 -0
- package/dist/api/registry/extension.js +2 -0
- package/dist/api/registry/extension.js.map +7 -0
- package/{src/api/registry/index.ts → dist/api/registry/index.d.ts} +0 -1
- package/dist/api/registry/index.js +2 -0
- package/dist/api/registry/index.js.map +7 -0
- package/dist/api/registry/packets.d.ts +20 -0
- package/dist/api/registry/packets.js +2 -0
- package/dist/api/registry/packets.js.map +7 -0
- package/{src/api/registry/registry.ts → dist/api/registry/registry.d.ts} +11 -53
- package/dist/api/registry/registry.js +2 -0
- package/dist/api/registry/registry.js.map +7 -0
- package/dist/api/server/extension.d.ts +61 -0
- package/dist/api/server/extension.js +2 -0
- package/dist/api/server/extension.js.map +7 -0
- package/dist/api/server/index.d.ts +1 -0
- package/dist/api/server/index.js +2 -0
- package/dist/api/server/index.js.map +7 -0
- package/dist/api/session/extension.d.ts +52 -0
- package/dist/api/session/extension.js +2 -0
- package/dist/api/session/extension.js.map +7 -0
- package/dist/api/session/index.d.ts +1 -0
- package/dist/api/session/index.js +2 -0
- package/dist/api/session/index.js.map +7 -0
- package/dist/api/signal/extension.d.ts +19 -0
- package/dist/api/signal/extension.js +2 -0
- package/dist/api/signal/extension.js.map +7 -0
- package/dist/api/signal/index.d.ts +1 -0
- package/dist/api/signal/index.js +2 -0
- package/dist/api/signal/index.js.map +7 -0
- package/dist/api/signal/packets.d.ts +21 -0
- package/dist/api/signal/packets.js +2 -0
- package/dist/api/signal/packets.js.map +7 -0
- package/dist/api/signal/signal.d.ts +33 -0
- package/dist/api/signal/signal.js +2 -0
- package/dist/api/signal/signal.js.map +7 -0
- package/dist/api/table/extension.d.ts +26 -0
- package/dist/api/table/extension.js +2 -0
- package/dist/api/table/extension.js.map +7 -0
- package/{src/api/table/index.ts → dist/api/table/index.d.ts} +0 -1
- package/dist/api/table/index.js +2 -0
- package/dist/api/table/index.js.map +7 -0
- package/dist/api/table/packets.d.ts +65 -0
- package/dist/api/table/packets.js +2 -0
- package/dist/api/table/packets.js.map +7 -0
- package/dist/api/table/table.d.ts +75 -0
- package/dist/api/table/table.js +2 -0
- package/dist/api/table/table.js.map +7 -0
- package/dist/app.d.ts +49 -0
- package/dist/app.js +2 -0
- package/dist/app.js.map +7 -0
- package/dist/const.d.ts +2 -0
- package/dist/const.js +2 -0
- package/dist/const.js.map +7 -0
- package/dist/errors.d.ts +36 -0
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +7 -0
- package/dist/event/index.d.ts +6 -0
- package/dist/event/index.js +2 -0
- package/dist/event/index.js.map +7 -0
- package/dist/helper.d.ts +10 -0
- package/dist/helper.js +2 -0
- package/dist/helper.js.map +7 -0
- package/dist/identifier.d.ts +51 -0
- package/dist/identifier.js +2 -0
- package/dist/identifier.js.map +7 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/{src/localization/index.ts → dist/localization/index.d.ts} +0 -1
- package/dist/localization/index.js +2 -0
- package/dist/localization/index.js.map +7 -0
- package/dist/localization/locale.d.ts +735 -0
- package/dist/localization/locale.js +2 -0
- package/dist/localization/locale.js.map +7 -0
- package/{src/localization/localization.ts → dist/localization/localization.d.ts} +0 -2
- package/dist/localization/localization.js +1 -0
- package/dist/localization/localization.js.map +7 -0
- package/dist/lock.d.ts +6 -0
- package/dist/lock.js +2 -0
- package/dist/lock.js.map +7 -0
- package/dist/network/connection.d.ts +17 -0
- package/dist/network/connection.js +2 -0
- package/dist/network/connection.js.map +7 -0
- package/dist/network/encryption.d.ts +38 -0
- package/dist/network/encryption.js +2 -0
- package/dist/network/encryption.js.map +7 -0
- package/dist/network/frame-transport.d.ts +22 -0
- package/dist/network/frame-transport.js +2 -0
- package/dist/network/frame-transport.js.map +7 -0
- package/{src/network/index.ts → dist/network/index.d.ts} +0 -1
- package/dist/network/index.js +2 -0
- package/dist/network/index.js.map +7 -0
- package/dist/network/network.d.ts +59 -0
- package/dist/network/network.js +2 -0
- package/dist/network/network.js.map +7 -0
- package/{src/network/packet/index.ts → dist/network/packet/index.d.ts} +0 -1
- package/dist/network/packet/index.js +2 -0
- package/dist/network/packet/index.js.map +7 -0
- package/dist/network/packet/packet-types.d.ts +84 -0
- package/dist/network/packet/packet-types.js +2 -0
- package/dist/network/packet/packet-types.js.map +7 -0
- package/dist/network/packet/packet.d.ts +25 -0
- package/dist/network/packet/packet.js +2 -0
- package/dist/network/packet/packet.js.map +7 -0
- package/dist/network/websocket-transport.d.ts +24 -0
- package/dist/network/websocket-transport.js +2 -0
- package/dist/network/websocket-transport.js.map +7 -0
- package/dist/omu.d.ts +61 -0
- package/dist/omu.js +2 -0
- package/dist/omu.js.map +7 -0
- package/dist/result.d.ts +26 -0
- package/dist/result.js +2 -0
- package/dist/result.js.map +7 -0
- package/dist/serialize/bytebuffer.d.ts +73 -0
- package/dist/serialize/bytebuffer.js +2 -0
- package/dist/serialize/bytebuffer.js.map +7 -0
- package/dist/serialize/index.d.ts +2 -0
- package/dist/serialize/index.js +2 -0
- package/dist/serialize/index.js.map +7 -0
- package/dist/serialize/serializer.d.ts +26 -0
- package/dist/serialize/serializer.js +2 -0
- package/dist/serialize/serializer.js.map +7 -0
- package/dist/token.d.ts +14 -0
- package/dist/token.js +2 -0
- package/dist/token.js.map +7 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +7 -0
- package/package.json +12 -9
- package/CHANGELOG.md +0 -1845
- package/src/api/asset/extension.ts +0 -193
- package/src/api/asset/index.ts +0 -5
- package/src/api/dashboard/extension.ts +0 -651
- package/src/api/dashboard/index.ts +0 -38
- package/src/api/dashboard/packets.ts +0 -126
- package/src/api/endpoint/endpoint.ts +0 -56
- package/src/api/endpoint/extension.ts +0 -133
- package/src/api/endpoint/packets.ts +0 -176
- package/src/api/extension-registry.ts +0 -17
- package/src/api/extension.ts +0 -19
- package/src/api/http/extension.ts +0 -401
- package/src/api/http/http.ts +0 -79
- package/src/api/http/websocket.ts +0 -283
- package/src/api/i18n/extension.ts +0 -65
- package/src/api/index.ts +0 -3
- package/src/api/logger/extension.ts +0 -75
- package/src/api/logger/index.ts +0 -4
- package/src/api/logger/packets.ts +0 -38
- package/src/api/permission/extension.ts +0 -107
- package/src/api/permission/permission.ts +0 -53
- package/src/api/plugin/extension.ts +0 -100
- package/src/api/registry/extension.ts +0 -326
- package/src/api/registry/packets.ts +0 -64
- package/src/api/server/extension.ts +0 -155
- package/src/api/server/index.ts +0 -11
- package/src/api/session/extension.ts +0 -205
- package/src/api/session/index.ts +0 -7
- package/src/api/signal/extension.ts +0 -125
- package/src/api/signal/index.ts +0 -1
- package/src/api/signal/packets.ts +0 -61
- package/src/api/signal/signal.ts +0 -67
- package/src/api/table/extension.ts +0 -554
- package/src/api/table/packets.ts +0 -252
- package/src/api/table/table.ts +0 -113
- package/src/app.ts +0 -95
- package/src/const.ts +0 -2
- package/src/errors.ts +0 -70
- package/src/event/index.ts +0 -18
- package/src/helper.ts +0 -16
- package/src/identifier.ts +0 -256
- package/src/index.ts +0 -87
- package/src/localization/locale.ts +0 -737
- package/src/lock.ts +0 -43
- package/src/network/connection.ts +0 -45
- package/src/network/encryption.ts +0 -221
- package/src/network/frame-transport.ts +0 -186
- package/src/network/network.ts +0 -322
- package/src/network/packet/packet-types.ts +0 -164
- package/src/network/packet/packet.ts +0 -55
- package/src/network/websocket-transport.ts +0 -123
- package/src/omu.ts +0 -156
- package/src/result.ts +0 -78
- package/src/serialize/bytebuffer.ts +0 -432
- package/src/serialize/index.ts +0 -2
- package/src/serialize/serializer.ts +0 -149
- package/src/token.ts +0 -39
- package/src/version.ts +0 -2
- package/tsconfig.json +0 -18
- /package/{src/address.ts → dist/address.d.ts} +0 -0
package/src/api/table/packets.ts
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { Identifier } from '../../identifier';
|
|
2
|
-
import { ByteReader, ByteWriter, Flags } from '../../serialize';
|
|
3
|
-
|
|
4
|
-
import type { TableConfig } from './table.js';
|
|
5
|
-
|
|
6
|
-
export class TablePacket {
|
|
7
|
-
constructor(public readonly id: Identifier) {}
|
|
8
|
-
|
|
9
|
-
public static serialize(packet: TablePacket): Uint8Array {
|
|
10
|
-
const writer = new ByteWriter();
|
|
11
|
-
writer.writeString(packet.id.key());
|
|
12
|
-
return writer.finish();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public static deserialize(data: Uint8Array): TablePacket {
|
|
16
|
-
const reader = ByteReader.fromUint8Array(data);
|
|
17
|
-
const id = Identifier.fromKey(reader.readString());
|
|
18
|
-
return new TablePacket(id);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class TableItemsPacket {
|
|
23
|
-
constructor(
|
|
24
|
-
public readonly id: Identifier,
|
|
25
|
-
public readonly items: Record<string, Uint8Array>,
|
|
26
|
-
) {}
|
|
27
|
-
|
|
28
|
-
public static serialize(packet: TableItemsPacket): Uint8Array {
|
|
29
|
-
const writer = new ByteWriter();
|
|
30
|
-
writer.writeString(packet.id.key());
|
|
31
|
-
writer.writeULEB128(Object.keys(packet.items).length);
|
|
32
|
-
for (const [key, value] of Object.entries(packet.items)) {
|
|
33
|
-
writer.writeString(key);
|
|
34
|
-
writer.writeUint8Array(value);
|
|
35
|
-
}
|
|
36
|
-
return writer.finish();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public static deserialize(data: Uint8Array): TableItemsPacket {
|
|
40
|
-
const reader = ByteReader.fromUint8Array(data);
|
|
41
|
-
const id = Identifier.fromKey(reader.readString());
|
|
42
|
-
const count = reader.readULEB128();
|
|
43
|
-
const items: Record<string, Uint8Array> = {};
|
|
44
|
-
for (let i = 0; i < count; i++) {
|
|
45
|
-
const key = reader.readString();
|
|
46
|
-
const value = reader.readUint8Array();
|
|
47
|
-
items[key] = value;
|
|
48
|
-
}
|
|
49
|
-
return new TableItemsPacket(id, items);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class TableKeysPacket {
|
|
54
|
-
constructor(
|
|
55
|
-
public readonly id: Identifier,
|
|
56
|
-
public readonly keys: string[],
|
|
57
|
-
) {}
|
|
58
|
-
|
|
59
|
-
public static serialize(packet: TableKeysPacket): Uint8Array {
|
|
60
|
-
const writer = new ByteWriter();
|
|
61
|
-
writer.writeString(packet.id.key());
|
|
62
|
-
writer.writeULEB128(packet.keys.length);
|
|
63
|
-
for (const key of packet.keys) {
|
|
64
|
-
writer.writeString(key);
|
|
65
|
-
}
|
|
66
|
-
return writer.finish();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public static deserialize(data: Uint8Array): TableKeysPacket {
|
|
70
|
-
const reader = ByteReader.fromUint8Array(data);
|
|
71
|
-
const id = Identifier.fromKey(reader.readString());
|
|
72
|
-
const count = reader.readULEB128();
|
|
73
|
-
const keys: string[] = [];
|
|
74
|
-
for (let i = 0; i < count; i++) {
|
|
75
|
-
keys.push(reader.readString());
|
|
76
|
-
}
|
|
77
|
-
return new TableKeysPacket(id, keys);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export class TableProxyPacket {
|
|
82
|
-
constructor(
|
|
83
|
-
public readonly id: Identifier,
|
|
84
|
-
public readonly items: Record<string, Uint8Array>,
|
|
85
|
-
public readonly key: number,
|
|
86
|
-
) {}
|
|
87
|
-
|
|
88
|
-
public static serialize(packet: TableProxyPacket): Uint8Array {
|
|
89
|
-
const writer = new ByteWriter();
|
|
90
|
-
writer.writeString(packet.id.key());
|
|
91
|
-
writer.writeULEB128(packet.key);
|
|
92
|
-
writer.writeULEB128(Object.keys(packet.items).length);
|
|
93
|
-
for (const [key, value] of Object.entries(packet.items)) {
|
|
94
|
-
writer.writeString(key);
|
|
95
|
-
writer.writeUint8Array(value);
|
|
96
|
-
}
|
|
97
|
-
return writer.finish();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public static deserialize(data: Uint8Array): TableProxyPacket {
|
|
101
|
-
const reader = ByteReader.fromUint8Array(data);
|
|
102
|
-
const id = Identifier.fromKey(reader.readString());
|
|
103
|
-
const key = reader.readULEB128();
|
|
104
|
-
const count = reader.readULEB128();
|
|
105
|
-
const items: Record<string, Uint8Array> = {};
|
|
106
|
-
for (let i = 0; i < count; i++) {
|
|
107
|
-
const key = reader.readString();
|
|
108
|
-
const value = reader.readUint8Array();
|
|
109
|
-
items[key] = value;
|
|
110
|
-
}
|
|
111
|
-
return new TableProxyPacket(id, items, key);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
export class TableFetchPacket {
|
|
115
|
-
constructor(
|
|
116
|
-
public readonly id: Identifier,
|
|
117
|
-
public readonly limit: number,
|
|
118
|
-
public readonly backward: boolean = false,
|
|
119
|
-
public readonly cursor: string | null = null,
|
|
120
|
-
) {}
|
|
121
|
-
|
|
122
|
-
public static serialize(packet: TableFetchPacket): Uint8Array {
|
|
123
|
-
const writer = new ByteWriter();
|
|
124
|
-
writer.writeString(packet.id.key());
|
|
125
|
-
writer.writeULEB128(packet.limit);
|
|
126
|
-
const flags = new Flags({ length: 2 });
|
|
127
|
-
flags.set(0, packet.backward);
|
|
128
|
-
flags.set(1, packet.cursor !== null);
|
|
129
|
-
writer.writeFlags(flags);
|
|
130
|
-
if (packet.cursor !== null) {
|
|
131
|
-
writer.writeString(packet.cursor);
|
|
132
|
-
}
|
|
133
|
-
return writer.finish();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public static deserialize(data: Uint8Array): TableFetchPacket {
|
|
137
|
-
const reader = ByteReader.fromUint8Array(data);
|
|
138
|
-
const id = Identifier.fromKey(reader.readString());
|
|
139
|
-
const limit = reader.readULEB128();
|
|
140
|
-
const flags = reader.readFlags(2);
|
|
141
|
-
const backward = flags.get(0);
|
|
142
|
-
const cursor = flags.ifSet(1, () => reader.readString());
|
|
143
|
-
return new TableFetchPacket(id, limit, backward, cursor);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export class TableFetchRangePacket {
|
|
148
|
-
constructor(
|
|
149
|
-
public readonly id: Identifier,
|
|
150
|
-
public readonly start: string,
|
|
151
|
-
public readonly end: string,
|
|
152
|
-
) {}
|
|
153
|
-
|
|
154
|
-
public static serialize(packet: TableFetchRangePacket): Uint8Array {
|
|
155
|
-
const writer = new ByteWriter();
|
|
156
|
-
writer.writeString(packet.id.key());
|
|
157
|
-
writer.writeString(packet.start);
|
|
158
|
-
writer.writeString(packet.end);
|
|
159
|
-
return writer.finish();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public static deserialize(data: Uint8Array): TableFetchRangePacket {
|
|
163
|
-
const reader = ByteReader.fromUint8Array(data);
|
|
164
|
-
const id = Identifier.fromKey(reader.readString());
|
|
165
|
-
const start = reader.readString();
|
|
166
|
-
const end = reader.readString();
|
|
167
|
-
return new TableFetchRangePacket(id, start, end);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export class SetConfigPacket {
|
|
172
|
-
constructor(
|
|
173
|
-
public readonly id: Identifier,
|
|
174
|
-
public readonly config: TableConfig,
|
|
175
|
-
) {}
|
|
176
|
-
|
|
177
|
-
public static serialize(packet: SetConfigPacket): Uint8Array {
|
|
178
|
-
const writer = new ByteWriter();
|
|
179
|
-
writer.writeString(packet.id.key());
|
|
180
|
-
writer.writeString(JSON.stringify(packet.config));
|
|
181
|
-
return writer.finish();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
public static deserialize(data: Uint8Array): SetConfigPacket {
|
|
185
|
-
const reader = ByteReader.fromUint8Array(data);
|
|
186
|
-
const id = Identifier.fromKey(reader.readString());
|
|
187
|
-
const config = JSON.parse(reader.readString());
|
|
188
|
-
return new SetConfigPacket(id, config);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export class SetPermissionPacket {
|
|
193
|
-
constructor(
|
|
194
|
-
public readonly id: Identifier,
|
|
195
|
-
public readonly all: Identifier | null,
|
|
196
|
-
public readonly read: Identifier | null,
|
|
197
|
-
public readonly write: Identifier | null,
|
|
198
|
-
public readonly remove: Identifier | null,
|
|
199
|
-
public readonly proxy: Identifier | null,
|
|
200
|
-
) {}
|
|
201
|
-
|
|
202
|
-
public static serialize(packet: SetPermissionPacket): Uint8Array {
|
|
203
|
-
const writer = new ByteWriter();
|
|
204
|
-
writer.writeString(packet.id.key());
|
|
205
|
-
let flags = 0;
|
|
206
|
-
if (packet.all !== null) {
|
|
207
|
-
flags |= 0b1;
|
|
208
|
-
}
|
|
209
|
-
if (packet.read !== null) {
|
|
210
|
-
flags |= 0b10;
|
|
211
|
-
}
|
|
212
|
-
if (packet.write !== null) {
|
|
213
|
-
flags |= 0b100;
|
|
214
|
-
}
|
|
215
|
-
if (packet.remove !== null) {
|
|
216
|
-
flags |= 0b1000;
|
|
217
|
-
}
|
|
218
|
-
if (packet.proxy !== null) {
|
|
219
|
-
flags |= 0b10000;
|
|
220
|
-
}
|
|
221
|
-
writer.writeUint8(flags);
|
|
222
|
-
if (packet.all) {
|
|
223
|
-
writer.writeString(packet.all.key());
|
|
224
|
-
}
|
|
225
|
-
if (packet.read) {
|
|
226
|
-
writer.writeString(packet.read.key());
|
|
227
|
-
}
|
|
228
|
-
if (packet.write) {
|
|
229
|
-
writer.writeString(packet.write.key());
|
|
230
|
-
}
|
|
231
|
-
if (packet.remove) {
|
|
232
|
-
writer.writeString(packet.remove.key());
|
|
233
|
-
}
|
|
234
|
-
if (packet.proxy) {
|
|
235
|
-
writer.writeString(packet.proxy.key());
|
|
236
|
-
}
|
|
237
|
-
return writer.finish();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public static deserialize(data: Uint8Array): SetPermissionPacket {
|
|
241
|
-
const reader = ByteReader.fromUint8Array(data);
|
|
242
|
-
const id = Identifier.fromKey(reader.readString());
|
|
243
|
-
const flags = reader.readUint8();
|
|
244
|
-
const all = flags & 0b1 ? Identifier.fromKey(reader.readString()) : null;
|
|
245
|
-
const read = flags & 0b10 ? Identifier.fromKey(reader.readString()) : null;
|
|
246
|
-
const write = flags & 0b100 ? Identifier.fromKey(reader.readString()) : null;
|
|
247
|
-
const remove = flags & 0b1000 ? Identifier.fromKey(reader.readString()) : null;
|
|
248
|
-
const proxy = flags & 0b10000 ? Identifier.fromKey(reader.readString()) : null;
|
|
249
|
-
return new SetPermissionPacket(id, all, read, write, remove, proxy);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
package/src/api/table/table.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { EventEmitter, Unlisten } from '../../event';
|
|
2
|
-
import { Identifier, IntoId } from '../../identifier';
|
|
3
|
-
import type { JsonType, Serializable } from '../../serialize';
|
|
4
|
-
import { Serializer } from '../../serialize';
|
|
5
|
-
|
|
6
|
-
export type TableConfig = {
|
|
7
|
-
cache_size: number;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export interface Table<T> {
|
|
11
|
-
readonly cache: ReadonlyMap<string, T>;
|
|
12
|
-
readonly event: TableEvents<T>;
|
|
13
|
-
get(key: string): Promise<T | undefined>;
|
|
14
|
-
getMany(...keys: string[]): Promise<Map<string, T>>;
|
|
15
|
-
add(...item: T[]): Promise<void>;
|
|
16
|
-
update(...item: T[]): Promise<void>;
|
|
17
|
-
remove(...items: T[]): Promise<void>;
|
|
18
|
-
clear(): Promise<void>;
|
|
19
|
-
has(key: string): Promise<boolean>;
|
|
20
|
-
hasMany<T extends Record<string, unknown>>(...keys: (keyof T)[]): Promise<{ [key in keyof T]: boolean }>;
|
|
21
|
-
hasAll(...keys: string[]): Promise<boolean>;
|
|
22
|
-
hasAny(...keys: string[]): Promise<boolean>;
|
|
23
|
-
|
|
24
|
-
fetchItems({
|
|
25
|
-
limit,
|
|
26
|
-
backward,
|
|
27
|
-
cursor,
|
|
28
|
-
}: {
|
|
29
|
-
limit: number;
|
|
30
|
-
backward?: boolean;
|
|
31
|
-
cursor?: string;
|
|
32
|
-
}): Promise<Map<string, T>>;
|
|
33
|
-
fetchRange({ start, end }: { start: string; end: string }): Promise<Map<string, T>>;
|
|
34
|
-
fetchAll(): Promise<Map<string, T>>;
|
|
35
|
-
iterate({ backward, cursor }: { backward?: boolean; cursor?: string }): AsyncIterable<T>;
|
|
36
|
-
size(): Promise<number>;
|
|
37
|
-
|
|
38
|
-
proxy(proxy: (item: T) => T | undefined): Unlisten;
|
|
39
|
-
setCacheSize(size: number): void;
|
|
40
|
-
setConfig(config: TableConfig): void;
|
|
41
|
-
setPermissions(permissions: TablePermissions): void;
|
|
42
|
-
|
|
43
|
-
listen(listener?: (items: Map<string, T>) => void): Unlisten;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type TableEvents<T> = {
|
|
47
|
-
add: EventEmitter<[Map<string, T>]>;
|
|
48
|
-
update: EventEmitter<[Map<string, T>]>;
|
|
49
|
-
remove: EventEmitter<[Map<string, T>]>;
|
|
50
|
-
clear: EventEmitter<[]>;
|
|
51
|
-
cacheUpdate: EventEmitter<[Map<string, T>]>;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export type TablePermissions = {
|
|
55
|
-
all?: Identifier;
|
|
56
|
-
read?: Identifier;
|
|
57
|
-
write?: Identifier;
|
|
58
|
-
remove?: Identifier;
|
|
59
|
-
proxy?: Identifier;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export class TableType<T> {
|
|
63
|
-
constructor(
|
|
64
|
-
public id: Identifier,
|
|
65
|
-
public serializer: Serializable<T, Uint8Array>,
|
|
66
|
-
public keyFunction: (item: T) => string,
|
|
67
|
-
public permissions?: TablePermissions | undefined,
|
|
68
|
-
) {}
|
|
69
|
-
|
|
70
|
-
public static createJson<T, D extends JsonType = JsonType>(
|
|
71
|
-
identifier: IntoId,
|
|
72
|
-
{
|
|
73
|
-
name,
|
|
74
|
-
key,
|
|
75
|
-
permissions,
|
|
76
|
-
serializer,
|
|
77
|
-
}: {
|
|
78
|
-
name: string;
|
|
79
|
-
key: (item: T) => string;
|
|
80
|
-
permissions?: TablePermissions;
|
|
81
|
-
serializer?: Serializable<T, D>;
|
|
82
|
-
},
|
|
83
|
-
): TableType<T> {
|
|
84
|
-
return new TableType<T>(
|
|
85
|
-
Identifier.from(identifier).join(name),
|
|
86
|
-
Serializer.pipe<T, D, Uint8Array>(serializer ?? Serializer.noop(), Serializer.json()),
|
|
87
|
-
key,
|
|
88
|
-
permissions,
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public static createSerialized<T>(
|
|
93
|
-
identifier: IntoId,
|
|
94
|
-
{
|
|
95
|
-
name,
|
|
96
|
-
key,
|
|
97
|
-
permissions,
|
|
98
|
-
serializer,
|
|
99
|
-
}: {
|
|
100
|
-
name: string;
|
|
101
|
-
key: (item: T) => string;
|
|
102
|
-
permissions?: TablePermissions;
|
|
103
|
-
serializer: Serializable<T, Uint8Array>;
|
|
104
|
-
},
|
|
105
|
-
): TableType<T> {
|
|
106
|
-
return new TableType<T>(
|
|
107
|
-
Identifier.from(identifier).join(name),
|
|
108
|
-
serializer,
|
|
109
|
-
key,
|
|
110
|
-
permissions,
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
}
|
package/src/app.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Identifier, IntoId } from './identifier';
|
|
2
|
-
import type { Locale } from './localization/locale.js';
|
|
3
|
-
import type { LocalizedText } from './localization/localization.js';
|
|
4
|
-
|
|
5
|
-
export type AppMetadata = {
|
|
6
|
-
locale: Locale;
|
|
7
|
-
name?: LocalizedText;
|
|
8
|
-
icon?: LocalizedText;
|
|
9
|
-
description?: LocalizedText;
|
|
10
|
-
image?: LocalizedText;
|
|
11
|
-
site?: LocalizedText;
|
|
12
|
-
repository?: LocalizedText;
|
|
13
|
-
authors?: LocalizedText;
|
|
14
|
-
license?: LocalizedText;
|
|
15
|
-
tags?: string[];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type AppType = 'app' | 'service' | 'remote' | 'plugin' | 'dashboard';
|
|
19
|
-
|
|
20
|
-
export type DependencySpecifier = {
|
|
21
|
-
version: string;
|
|
22
|
-
index?: string;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type AppJson = {
|
|
26
|
-
id: string;
|
|
27
|
-
type: AppType;
|
|
28
|
-
parent_id?: string;
|
|
29
|
-
version?: string;
|
|
30
|
-
url?: string;
|
|
31
|
-
metadata?: AppMetadata;
|
|
32
|
-
dependencies?: Record<string, DependencySpecifier | string>;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export class App {
|
|
36
|
-
public readonly id: Identifier;
|
|
37
|
-
public readonly type: AppType;
|
|
38
|
-
public readonly parentId?: Identifier;
|
|
39
|
-
public readonly version?: string;
|
|
40
|
-
public readonly url?: string;
|
|
41
|
-
public readonly metadata?: AppMetadata;
|
|
42
|
-
public readonly dependencies: Record<string, DependencySpecifier | string>;
|
|
43
|
-
|
|
44
|
-
constructor(id: IntoId, options: {
|
|
45
|
-
type?: AppType;
|
|
46
|
-
parentId?: IntoId;
|
|
47
|
-
version?: string;
|
|
48
|
-
url?: string;
|
|
49
|
-
metadata?: AppMetadata;
|
|
50
|
-
dependencies?: Record<string, DependencySpecifier | string>;
|
|
51
|
-
}) {
|
|
52
|
-
this.id = Identifier.from(id);
|
|
53
|
-
this.parentId = Identifier.fromOptional(options.parentId);
|
|
54
|
-
this.version = options.version;
|
|
55
|
-
this.url = options.url;
|
|
56
|
-
this.metadata = options.metadata;
|
|
57
|
-
this.type = options.type ?? 'app';
|
|
58
|
-
this.dependencies = options.dependencies ?? {};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public static deserialize(info: AppJson): App {
|
|
62
|
-
const id = Identifier.fromKey(info.id);
|
|
63
|
-
return new App(id, {
|
|
64
|
-
parentId: Identifier.fromOptional(info.parent_id),
|
|
65
|
-
version: info.version,
|
|
66
|
-
url: info.url,
|
|
67
|
-
type: info.type,
|
|
68
|
-
metadata: info.metadata,
|
|
69
|
-
dependencies: info.dependencies ?? {},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public static serialize(data: App): AppJson {
|
|
74
|
-
return {
|
|
75
|
-
id: data.id.key(),
|
|
76
|
-
type: data.type,
|
|
77
|
-
parent_id: data.parentId?.key(),
|
|
78
|
-
version: data.version,
|
|
79
|
-
url: data.url,
|
|
80
|
-
metadata: data.metadata,
|
|
81
|
-
dependencies: data.dependencies,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public join(...paths: string[]): App {
|
|
86
|
-
return new App(this.id.join(...paths), {
|
|
87
|
-
parentId: this.parentId,
|
|
88
|
-
version: this.version,
|
|
89
|
-
url: this.url,
|
|
90
|
-
type: this.type,
|
|
91
|
-
metadata: this.metadata,
|
|
92
|
-
dependencies: this.dependencies,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
package/src/const.ts
DELETED
package/src/errors.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { DisconnectType } from './network/packet/packet-types.js';
|
|
2
|
-
export class OmuError extends Error {
|
|
3
|
-
constructor(message: string | null) {
|
|
4
|
-
super(message ?? undefined);
|
|
5
|
-
this.name = this.constructor.name;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class DisconnectReason extends OmuError {
|
|
10
|
-
constructor(
|
|
11
|
-
public type: DisconnectType,
|
|
12
|
-
public message = '',
|
|
13
|
-
) {
|
|
14
|
-
super(message);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class ServerRestart extends DisconnectReason {
|
|
19
|
-
constructor(message: string) {
|
|
20
|
-
super(DisconnectType.SERVER_RESTART, message);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class AnotherConnection extends DisconnectReason {
|
|
25
|
-
constructor(message: string) {
|
|
26
|
-
super(DisconnectType.ANOTHER_CONNECTION, message);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class PermissionDenied extends DisconnectReason {
|
|
31
|
-
constructor(message: string) {
|
|
32
|
-
super(DisconnectType.PERMISSION_DENIED, message);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class AppRemoved extends DisconnectReason {
|
|
37
|
-
constructor(message: string) {
|
|
38
|
-
super(DisconnectType.APP_REMOVED, message);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class InvalidToken extends DisconnectReason {
|
|
43
|
-
constructor(message: string) {
|
|
44
|
-
super(DisconnectType.INVALID_TOKEN, message);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export class InvalidOrigin extends DisconnectReason {
|
|
49
|
-
constructor(message: string) {
|
|
50
|
-
super(DisconnectType.INVALID_ORIGIN, message);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export class InvalidVersion extends DisconnectReason {
|
|
55
|
-
constructor(message: string) {
|
|
56
|
-
super(DisconnectType.INVALID_VERSION, message);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export class InvalidPacket extends DisconnectReason {
|
|
61
|
-
constructor(message: string) {
|
|
62
|
-
super(DisconnectType.INVALID_PACKET, message);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export class InternalError extends DisconnectReason {
|
|
67
|
-
constructor(message: string) {
|
|
68
|
-
super(DisconnectType.INTERNAL_ERROR, message);
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/event/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type Unlisten = () => void;
|
|
2
|
-
|
|
3
|
-
export class EventEmitter<P extends Array<any>> {
|
|
4
|
-
private readonly listeners: Array<(...args: P) => Promise<void> | void> = [];
|
|
5
|
-
|
|
6
|
-
public listen(listener: (...args: P) => any): Unlisten {
|
|
7
|
-
this.listeners.push(listener);
|
|
8
|
-
return () => {
|
|
9
|
-
this.listeners.splice(this.listeners.indexOf(listener), 1);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public async emit(...args: P): Promise<void> {
|
|
14
|
-
for (const listener of [...this.listeners]) {
|
|
15
|
-
await listener(...args);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/helper.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
type Ok<T> = {
|
|
2
|
-
ok: true;
|
|
3
|
-
data: T;
|
|
4
|
-
};
|
|
5
|
-
type Err<E> = {
|
|
6
|
-
ok: false;
|
|
7
|
-
data: E;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function tryCatch<T, E = Error>(func: () => T): Ok<T> | Err<E> {
|
|
11
|
-
try {
|
|
12
|
-
return { ok: true, data: func() };
|
|
13
|
-
} catch (e) {
|
|
14
|
-
return { ok: false, data: e as E };
|
|
15
|
-
}
|
|
16
|
-
}
|