@constl/utils-tests 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attente.js +1 -1
- package/dist/attente.js.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +5 -4
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -4
- package/renovate.json +1 -3
- package/src/@types/shims-orbit-db-core.d.ts +236 -0
- package/src/attente.ts +18 -16
- package/src/client.ts +17 -14
- package/src/index.ts +15 -21
- package/src/orbitDbTestUtils.ts +1 -1
- package/src/version.ts +1 -1
- package/src/@types/shims-orbit-db.d.ts +0 -1
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.2.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.2.0",
|
|
3
3
|
"license": "AGPL-3.0-or-later",
|
|
4
4
|
"name": "@constl/utils-tests",
|
|
5
5
|
"author": "Julien Jean Malard-Adam",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"postbuild": "./dist/**/*"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@constl/ipa": "^0.8.
|
|
24
|
-
"@constl/orbit-db-types": "^1.1.0",
|
|
23
|
+
"@constl/ipa": "^0.8.3",
|
|
25
24
|
"@types/crypto-js": "^4.1.1",
|
|
26
25
|
"@types/mocha": "^10.0.1",
|
|
27
26
|
"@types/node": "^20.5.4",
|
|
@@ -54,10 +53,10 @@
|
|
|
54
53
|
},
|
|
55
54
|
"dependencies": {
|
|
56
55
|
"@achingbrain/nat-port-mapper": "1.0.8",
|
|
56
|
+
"@orbitdb/core": "^1.0.0",
|
|
57
57
|
"chokidar": "^3.5.3",
|
|
58
58
|
"genversion": "^3.1.1",
|
|
59
59
|
"ipfs-core": "^0.18.1",
|
|
60
|
-
"orbit-db": "^0.29.0",
|
|
61
60
|
"rimraf": "^5.0.1",
|
|
62
61
|
"uint8arrays": "^4.0.6",
|
|
63
62
|
"uuid": "^9.0.0",
|
package/renovate.json
CHANGED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
declare module "@orbitdb/core" {
|
|
2
|
+
import EventEmitter from "events";
|
|
3
|
+
import type { IPFS } from "ipfs-core";
|
|
4
|
+
|
|
5
|
+
export function Database(args: {
|
|
6
|
+
ipfs: IPFS;
|
|
7
|
+
identity?: Identity;
|
|
8
|
+
address: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
access?: AccessController;
|
|
11
|
+
directory?: string;
|
|
12
|
+
meta?: object;
|
|
13
|
+
headsStorage?: Storage;
|
|
14
|
+
entryStorage?: Storage;
|
|
15
|
+
indexStorage?: Storage;
|
|
16
|
+
referencesCount?: number;
|
|
17
|
+
syncAutomatically?: boolean;
|
|
18
|
+
onUpdate?: () => void;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
type: string;
|
|
21
|
+
addOperation: (args: {
|
|
22
|
+
op: string;
|
|
23
|
+
key: string | null;
|
|
24
|
+
value: unknown;
|
|
25
|
+
}) => Promise<string>;
|
|
26
|
+
address: string;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
drop(): Promise<void>;
|
|
29
|
+
events: EventEmitter;
|
|
30
|
+
access: AccessController;
|
|
31
|
+
log: Log;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
34
|
+
export type Identity = {
|
|
35
|
+
id: string;
|
|
36
|
+
publicKey: string;
|
|
37
|
+
signatures: {
|
|
38
|
+
id: string;
|
|
39
|
+
publicKey: string;
|
|
40
|
+
};
|
|
41
|
+
type: string;
|
|
42
|
+
sign: (identity: Identity, data: string) => Promise<string>;
|
|
43
|
+
verify: (
|
|
44
|
+
signature: string,
|
|
45
|
+
publicKey: string,
|
|
46
|
+
data: string,
|
|
47
|
+
) => Promise<boolean>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type OrbitDB = {
|
|
51
|
+
id: string;
|
|
52
|
+
open: (
|
|
53
|
+
address: string,
|
|
54
|
+
OrbitDBDatabaseOptions?,
|
|
55
|
+
) => ReturnType<typeof Database>;
|
|
56
|
+
stop;
|
|
57
|
+
ipfs;
|
|
58
|
+
directory;
|
|
59
|
+
keystore;
|
|
60
|
+
identity: Identity;
|
|
61
|
+
peerId;
|
|
62
|
+
};
|
|
63
|
+
export function createOrbitDB(args: {
|
|
64
|
+
ipfs: IPFS;
|
|
65
|
+
directory: string;
|
|
66
|
+
}): Promise<OrbitDB>;
|
|
67
|
+
|
|
68
|
+
export function useAccessController(accessController: { type: string }): void;
|
|
69
|
+
export function isValidAddress(address: unknown): boolean;
|
|
70
|
+
|
|
71
|
+
export type Log = {
|
|
72
|
+
id;
|
|
73
|
+
clock: Clock;
|
|
74
|
+
heads: () => Promise<Entry[]>;
|
|
75
|
+
traverse: () => AsyncGenerator<Entry, void, unknown>;
|
|
76
|
+
};
|
|
77
|
+
export type Identity = {
|
|
78
|
+
id: string;
|
|
79
|
+
publicKey: object;
|
|
80
|
+
sigantures: object;
|
|
81
|
+
type: string;
|
|
82
|
+
sign: () => string;
|
|
83
|
+
verify: () => boolean;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export function AccessControllerGenerator({
|
|
87
|
+
orbitdb,
|
|
88
|
+
identities,
|
|
89
|
+
address,
|
|
90
|
+
}: {
|
|
91
|
+
orbitdb: OrbitDB;
|
|
92
|
+
identities: Identities;
|
|
93
|
+
address?: string;
|
|
94
|
+
}): Promise<AccessController>;
|
|
95
|
+
|
|
96
|
+
export class AccessController {
|
|
97
|
+
type: string;
|
|
98
|
+
address: string;
|
|
99
|
+
canAppend: (entry: Entry) => Promise<boolean>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function IPFSAccessController(args: {
|
|
103
|
+
write: string[];
|
|
104
|
+
storage: Storage;
|
|
105
|
+
}): (args: {
|
|
106
|
+
orbitdb: OrbitDB;
|
|
107
|
+
identities: Identities;
|
|
108
|
+
address: string;
|
|
109
|
+
}) => Promise<{
|
|
110
|
+
type: "ipfs";
|
|
111
|
+
address: string;
|
|
112
|
+
write: string[];
|
|
113
|
+
canAppend: (entry: Entry) => Promise<boolean>;
|
|
114
|
+
}>;
|
|
115
|
+
export class Identities {
|
|
116
|
+
getIdentity;
|
|
117
|
+
verifyIdentity: (identity) => boolean;
|
|
118
|
+
}
|
|
119
|
+
export class Storage {
|
|
120
|
+
put;
|
|
121
|
+
get;
|
|
122
|
+
}
|
|
123
|
+
export function IPFSBlockStorage({
|
|
124
|
+
ipfs: IPFS,
|
|
125
|
+
pin: boolean,
|
|
126
|
+
}): Promise<Storage>;
|
|
127
|
+
export function LRUStorage({ size: number }): Promise<Storage>;
|
|
128
|
+
export function ComposedStorage(...args: Storage[]): Promise<Storage>;
|
|
129
|
+
|
|
130
|
+
export type OrbitDBDatabaseOptions = {
|
|
131
|
+
type: string;
|
|
132
|
+
AccessController: AccessControllerGenerator;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type Clock = {
|
|
136
|
+
id: string;
|
|
137
|
+
time: number;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type Entry<T = unknown> = {
|
|
141
|
+
id: string;
|
|
142
|
+
payload: { op: string; key: string | null; value?: T };
|
|
143
|
+
next: string[];
|
|
144
|
+
refs: string[];
|
|
145
|
+
clock: Clock;
|
|
146
|
+
v: integer;
|
|
147
|
+
key: string;
|
|
148
|
+
identity: string;
|
|
149
|
+
sig: string;
|
|
150
|
+
hash: string;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Temporaires
|
|
154
|
+
export type Store = FeedStore | SetStore | KeyValueStore | OrderedKeyValueStore;
|
|
155
|
+
|
|
156
|
+
export type FeedStore = Awaited<ReturnType<typeof Database>> & {
|
|
157
|
+
remove: (hash: string) => Promise<string>
|
|
158
|
+
};
|
|
159
|
+
export type FeedStoreTypé<T extends élémentsBd> = Omit<
|
|
160
|
+
FeedStore,
|
|
161
|
+
"add" | "all"
|
|
162
|
+
> & {
|
|
163
|
+
add: (value: T) => Promise<string>;
|
|
164
|
+
all: () => Promise<
|
|
165
|
+
{
|
|
166
|
+
value: T;
|
|
167
|
+
hash: string;
|
|
168
|
+
}[]
|
|
169
|
+
>;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export type SetDatabase = ReturnType<typeof Database>;
|
|
173
|
+
export type SetStore = Awaited<SetDatabase>;
|
|
174
|
+
export type SetStoreTypé<T extends élémentsBd> = Omit<
|
|
175
|
+
SetStore,
|
|
176
|
+
"put" | "set" | "del" | "all"
|
|
177
|
+
> & {
|
|
178
|
+
put: (value: T) => Promise<string>;
|
|
179
|
+
set: SetStoreTypé<T>["put"];
|
|
180
|
+
del: (value: T) => Promise<string>;
|
|
181
|
+
all: () => Promise<
|
|
182
|
+
{
|
|
183
|
+
value: T;
|
|
184
|
+
hash: string;
|
|
185
|
+
}[]
|
|
186
|
+
>;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export type OrderedKeyValue = ReturnType<typeof Database>;
|
|
190
|
+
export type OrderedKeyValueStore = Awaited<OrderedKeyValue>;
|
|
191
|
+
export type OrderedKeyValueStoreTypé<T extends { [clef: string]: unknown }> =
|
|
192
|
+
Omit<OrderedKeyValueStore, "put" | "set" | "del" | "move" | "get" | "all"> & {
|
|
193
|
+
put: <K extends keyof T>(
|
|
194
|
+
key: K,
|
|
195
|
+
value: T[K],
|
|
196
|
+
position?: number
|
|
197
|
+
) => Promise<string>;
|
|
198
|
+
set: OrderedKeyValueStoreTypé<T>["put"];
|
|
199
|
+
del: <K extends keyof T>(key: K) => Promise<string>;
|
|
200
|
+
move: <K extends keyof T>(key: K, position: number) => Promise<string>;
|
|
201
|
+
get: <K extends keyof T>(key: K) => Promise<T[K] | undefined>;
|
|
202
|
+
all: () => Promise<
|
|
203
|
+
{
|
|
204
|
+
key: keyof T;
|
|
205
|
+
value: T[keyof T];
|
|
206
|
+
hash: string;
|
|
207
|
+
}[]
|
|
208
|
+
>;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export type KeyValueStore = {
|
|
212
|
+
type: "keyvalue";
|
|
213
|
+
address: string;
|
|
214
|
+
put(key: string, value: unknown): Promise<string>;
|
|
215
|
+
set: KeyValueStore["put"];
|
|
216
|
+
del(key: string): Promise<string>;
|
|
217
|
+
get(key: string): Promise<unknown | undefined>;
|
|
218
|
+
all(): Promise<{ key: string; value: unknown; hash: string }[]>;
|
|
219
|
+
close(): Promise<void>;
|
|
220
|
+
drop(): Promise<void>;
|
|
221
|
+
events: EventEmitter;
|
|
222
|
+
access: AccessController;
|
|
223
|
+
log: Log;
|
|
224
|
+
};
|
|
225
|
+
export type KeyValueStoreTypé<T extends { [clef: string]: unknown }> = Omit<
|
|
226
|
+
KeyValueStore,
|
|
227
|
+
"put" | "set" | "del" | "get" | "all"
|
|
228
|
+
> & {
|
|
229
|
+
put<K extends keyof T>(key: K, value: T[K]): Promise<string>;
|
|
230
|
+
set: KeyValueStoreTypé<T>["put"];
|
|
231
|
+
del<K extends keyof T>(key: K): Promise<string>;
|
|
232
|
+
get<K extends keyof T>(key: K): Promise<T[K] | undefined>;
|
|
233
|
+
all(): Promise<T>;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
}
|
package/src/attente.ts
CHANGED
|
@@ -71,7 +71,7 @@ export class AttendreFichierExiste extends EventEmitter {
|
|
|
71
71
|
if (fichier === this.fichier) return;
|
|
72
72
|
else
|
|
73
73
|
throw new Error(
|
|
74
|
-
`Fichier téléchargé a le nom ${fichier}, et non pas ${this.fichier}
|
|
74
|
+
`Fichier téléchargé a le nom ${fichier}, et non pas ${this.fichier}.`,
|
|
75
75
|
);
|
|
76
76
|
} else {
|
|
77
77
|
const chokidar = await import("chokidar");
|
|
@@ -115,7 +115,10 @@ export class AttendreFichierModifié extends EventEmitter {
|
|
|
115
115
|
this.fsOublier.push(() => this.attendreExiste.annuler());
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
async attendre(
|
|
118
|
+
async attendre(
|
|
119
|
+
tempsAvant: number,
|
|
120
|
+
condition?: () => Promise<boolean>,
|
|
121
|
+
): Promise<void> {
|
|
119
122
|
await this.attendreExiste.attendre();
|
|
120
123
|
const chokidar = await import("chokidar");
|
|
121
124
|
const fs = await import("fs");
|
|
@@ -125,21 +128,20 @@ export class AttendreFichierModifié extends EventEmitter {
|
|
|
125
128
|
|
|
126
129
|
const vérifierModifié = async () => {
|
|
127
130
|
try {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
rejeter(e);
|
|
131
|
+
const { mtime } = fs.statSync(this.fichier);
|
|
132
|
+
const prêt = mtime.getTime() > tempsAvant;
|
|
133
|
+
|
|
134
|
+
if (prêt && (!condition || (await condition()))) {
|
|
135
|
+
await écouteur.close();
|
|
136
|
+
clearInterval(intervale);
|
|
137
|
+
résoudre();
|
|
138
|
+
}
|
|
139
|
+
} catch (e) {
|
|
140
|
+
// Le fichier a été effacé
|
|
141
|
+
écouteur.close();
|
|
142
|
+
rejeter(e);
|
|
141
143
|
}
|
|
142
|
-
|
|
144
|
+
};
|
|
143
145
|
|
|
144
146
|
écouteur.on("change", async (adresse) => {
|
|
145
147
|
if (adresse !== this.fichier) return;
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import OrbitDB from "
|
|
1
|
+
import {createOrbitDB, OrbitDB} from "@orbitdb/core";
|
|
2
2
|
import { initierSFIP, arrêterSFIP } from "@/sfip.js";
|
|
3
3
|
import { isBrowser } from "wherearewe";
|
|
4
4
|
import type { IPFS } from "ipfs-core";
|
|
@@ -7,9 +7,8 @@ import type { client } from "@constl/ipa";
|
|
|
7
7
|
import { connectPeers } from "@/orbitDbTestUtils.js";
|
|
8
8
|
import { dossierTempoTests } from "@/dossiers.js";
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
export const générerOrbites = async (
|
|
12
|
-
n = 1
|
|
11
|
+
n = 1,
|
|
13
12
|
): Promise<{ orbites: OrbitDB[]; fOublier: () => Promise<void> }> => {
|
|
14
13
|
const sfips: IPFS[] = [];
|
|
15
14
|
const orbites: OrbitDB[] = [];
|
|
@@ -24,7 +23,8 @@ export const générerOrbites = async (
|
|
|
24
23
|
const _générer = async (i: number): Promise<void> => {
|
|
25
24
|
const racineDossier = `${racineDossierOrbite}/${i}`;
|
|
26
25
|
const sfip = await initierSFIP(`${racineDossier}/sfip`);
|
|
27
|
-
const orbite = await
|
|
26
|
+
const orbite = await createOrbitDB({
|
|
27
|
+
ipfs: sfip,
|
|
28
28
|
directory: `${racineDossier}/orbite`,
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -42,13 +42,13 @@ export const générerOrbites = async (
|
|
|
42
42
|
await Promise.all(
|
|
43
43
|
orbites.map(async (orbite) => {
|
|
44
44
|
await orbite.stop();
|
|
45
|
-
})
|
|
45
|
+
}),
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
await Promise.all(
|
|
49
49
|
sfips.map(async (d) => {
|
|
50
50
|
await arrêterSFIP(d);
|
|
51
|
-
})
|
|
51
|
+
}),
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
fEffacerRacineDossierOrbite();
|
|
@@ -56,21 +56,24 @@ export const générerOrbites = async (
|
|
|
56
56
|
return { orbites, fOublier };
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
export const générerClients = async<T> ({
|
|
59
|
+
export const générerClients = async <T>({
|
|
61
60
|
n = 1,
|
|
62
61
|
type = "proc",
|
|
63
|
-
générerClient
|
|
62
|
+
générerClient,
|
|
64
63
|
}: {
|
|
65
|
-
n: number
|
|
66
|
-
type?: "proc" | "travailleur"
|
|
67
|
-
générerClient: (args: {
|
|
64
|
+
n: number;
|
|
65
|
+
type?: "proc" | "travailleur";
|
|
66
|
+
générerClient: (args: {
|
|
67
|
+
opts: client.optsConstellation;
|
|
68
|
+
mandataire: "proc" | "travailleur";
|
|
69
|
+
}) => T;
|
|
68
70
|
}): Promise<{
|
|
69
71
|
clients: T[];
|
|
70
72
|
fOublier: () => Promise<void>;
|
|
71
73
|
}> => {
|
|
72
74
|
const clients: T[] = [];
|
|
73
75
|
const fsOublier: (() => Promise<void>)[] = [];
|
|
76
|
+
|
|
74
77
|
// Nécessaire pour Playwright
|
|
75
78
|
if (isBrowser) window.localStorage.clear();
|
|
76
79
|
|
|
@@ -81,7 +84,7 @@ export const générerClients = async<T> ({
|
|
|
81
84
|
for (const i in [...Array(n).keys()]) {
|
|
82
85
|
const client = générerClient({
|
|
83
86
|
opts: { orbite: orbites[i] },
|
|
84
|
-
mandataire: type
|
|
87
|
+
mandataire: type,
|
|
85
88
|
});
|
|
86
89
|
clients.push(client);
|
|
87
90
|
}
|
|
@@ -99,7 +102,7 @@ export const générerClients = async<T> ({
|
|
|
99
102
|
|
|
100
103
|
const fOublier = async () => {
|
|
101
104
|
if (isBrowser) return; // Mystère et boule de gomme !!
|
|
102
|
-
|
|
105
|
+
|
|
103
106
|
// @ts-expect-error À régler: type pour `fermer`
|
|
104
107
|
await Promise.all(clients.map((client) => client.fermer()));
|
|
105
108
|
await Promise.all(fsOublier.map((f) => f()));
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { once } from "events";
|
|
2
2
|
|
|
3
|
-
import OrbitDB from "
|
|
4
|
-
import type Store from "orbit-db-store";
|
|
5
|
-
import type KeyValueStore from "orbit-db-kvstore";
|
|
6
|
-
import type FeedStore from "orbit-db-feedstore";
|
|
3
|
+
import { FeedStoreTypé, KeyValueStoreTypé, OrbitDB, type Store } from "@orbitdb/core";
|
|
7
4
|
|
|
8
5
|
import type { client, réseau } from "@constl/ipa";
|
|
9
6
|
|
|
@@ -16,12 +13,10 @@ export * as client from "@/client.js";
|
|
|
16
13
|
export * as dossiers from "@/dossiers.js";
|
|
17
14
|
export { version } from "@/version.js";
|
|
18
15
|
|
|
19
|
-
const attendreInvité = (
|
|
16
|
+
const attendreInvité = (accès: ContrôleurConstellation, idInvité: string): Promise<void> =>
|
|
20
17
|
new Promise<void>((resolve) => {
|
|
21
18
|
const testAutorisé = async () => {
|
|
22
|
-
const autorisé = await (
|
|
23
|
-
bd.access as unknown as ContrôleurConstellation
|
|
24
|
-
).estAutorisé(idInvité);
|
|
19
|
+
const autorisé = await accès.estAutorisé(idInvité);
|
|
25
20
|
if (autorisé) {
|
|
26
21
|
clearInterval(interval);
|
|
27
22
|
resolve();
|
|
@@ -33,7 +28,7 @@ const attendreInvité = (bd: Store, idInvité: string): Promise<void> =>
|
|
|
33
28
|
|
|
34
29
|
export const clientConnectéÀ = async (
|
|
35
30
|
client1: client.ClientConstellation,
|
|
36
|
-
client2: client.ClientConstellation
|
|
31
|
+
client2: client.ClientConstellation,
|
|
37
32
|
): Promise<void> => {
|
|
38
33
|
const dispositifsConnectés = new AttendreRésultat<
|
|
39
34
|
réseau.statutDispositif[]
|
|
@@ -71,35 +66,34 @@ export const attendreSync = async (bd: Store): Promise<void> => {
|
|
|
71
66
|
};
|
|
72
67
|
|
|
73
68
|
export const peutÉcrire = async (
|
|
74
|
-
bd:
|
|
75
|
-
attendre?: OrbitDB
|
|
69
|
+
bd: KeyValueStoreTypé<{ test: number }> | FeedStoreTypé<string>,
|
|
70
|
+
attendre?: OrbitDB,
|
|
76
71
|
): Promise<boolean> => {
|
|
77
72
|
if (attendre) {
|
|
78
|
-
await attendreInvité(bd, attendre.identity.id);
|
|
73
|
+
await attendreInvité(bd.access as unknown as ContrôleurConstellation, attendre.identity.id);
|
|
79
74
|
}
|
|
80
75
|
|
|
81
76
|
try {
|
|
82
77
|
if (bd.type === "keyvalue") {
|
|
78
|
+
const bdKV = bd as KeyValueStoreTypé<{ test: number }>
|
|
83
79
|
const CLEF = "test";
|
|
84
80
|
const VAL = 123;
|
|
85
81
|
|
|
86
|
-
await
|
|
87
|
-
const val =
|
|
82
|
+
await bdKV.set(CLEF, VAL);
|
|
83
|
+
const val = await bdKV.get(CLEF);
|
|
88
84
|
|
|
89
|
-
await (bd as
|
|
85
|
+
await (bd as KeyValueStoreTypé<{ test: number }>).del(CLEF);
|
|
90
86
|
return val === VAL;
|
|
91
87
|
} else if (bd.type === "feed") {
|
|
92
88
|
const VAL = "test";
|
|
93
89
|
|
|
94
|
-
await (bd as
|
|
95
|
-
const éléments = (bd as
|
|
96
|
-
.iterator({ limit: -1 })
|
|
97
|
-
.collect();
|
|
90
|
+
await (bd as FeedStoreTypé<string>).add(VAL);
|
|
91
|
+
const éléments = await (bd as FeedStoreTypé<string>).all();
|
|
98
92
|
|
|
99
93
|
const autorisé =
|
|
100
|
-
éléments.length === 1 && éléments[0].
|
|
94
|
+
éléments.length === 1 && éléments[0].value === VAL;
|
|
101
95
|
if (éléments.length === 1) {
|
|
102
|
-
await (bd as
|
|
96
|
+
await (bd as FeedStoreTypé<string>).remove(éléments[0].hash);
|
|
103
97
|
}
|
|
104
98
|
return autorisé;
|
|
105
99
|
} else {
|
package/src/orbitDbTestUtils.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '0.
|
|
2
|
+
export const version = '0.2.0';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { OrbidtDB, OrbitDBAccessControllers } from "@constl/orbit-db-types";
|