@ibgib/core-gib 0.0.22 → 0.0.24
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/witness/app/app-base-v1.d.mts +18 -8
- package/dist/witness/app/app-base-v1.d.mts.map +1 -1
- package/dist/witness/app/app-base-v1.mjs +18 -8
- package/dist/witness/app/app-base-v1.mjs.map +1 -1
- package/dist/witness/robbot/robbot-base-v1.d.mts +7 -7
- package/dist/witness/robbot/robbot-base-v1.d.mts.map +1 -1
- package/dist/witness/robbot/robbot-base-v1.mjs +47 -41
- package/dist/witness/robbot/robbot-base-v1.mjs.map +1 -1
- package/dist/witness/robbot/robbot-types.d.mts +20 -0
- package/dist/witness/robbot/robbot-types.d.mts.map +1 -1
- package/dist/witness/robbot/robbot-types.mjs +3 -0
- package/dist/witness/robbot/robbot-types.mjs.map +1 -1
- package/dist/witness/space/filesystem-space/filesystem-constants.d.mts +14 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.d.mts.map +1 -1
- package/dist/witness/space/filesystem-space/filesystem-constants.mjs +14 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.mjs.map +1 -1
- package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts +7 -1
- package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts.map +1 -1
- package/dist/witness/space/filesystem-space/filesystem-space-v1.mjs +47 -11
- package/dist/witness/space/filesystem-space/filesystem-space-v1.mjs.map +1 -1
- package/dist/witness/space/filesystem-space/filesystem-types.d.mts +7 -0
- package/dist/witness/space/filesystem-space/filesystem-types.d.mts.map +1 -1
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.d.mts +8 -3
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.d.mts.map +1 -1
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.mjs +39 -24
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.mjs.map +1 -1
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mjs +1 -1
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mjs.map +1 -1
- package/dist/witness/space/space-respec-helper.d.mts.map +1 -1
- package/dist/witness/space/space-respec-helper.mjs +33 -2
- package/dist/witness/space/space-respec-helper.mjs.map +1 -1
- package/dist/witness/space/space-types.d.mts +18 -0
- package/dist/witness/space/space-types.d.mts.map +1 -1
- package/dist/witness/space/space-types.mjs.map +1 -1
- package/package.json +2 -2
- package/src/witness/app/app-base-v1.mts +18 -8
- package/src/witness/robbot/robbot-base-v1.mts +39 -33
- package/src/witness/robbot/robbot-types.mts +20 -0
- package/src/witness/space/filesystem-space/filesystem-constants.mts +15 -0
- package/src/witness/space/filesystem-space/filesystem-space-v1.mts +66 -11
- package/src/witness/space/filesystem-space/filesystem-types.mts +8 -0
- package/src/witness/space/filesystem-space/node-filesystem-space-v1.mts +40 -24
- package/src/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mts +1 -1
- package/src/witness/space/space-respec-helper.mts +38 -2
- package/src/witness/space/space-types.mts +18 -0
|
@@ -24,7 +24,9 @@ import {
|
|
|
24
24
|
IBGIB_ENCODING, IBGIB_IBGIBS_SUBPATH, IBGIB_META_SUBPATH,
|
|
25
25
|
DEFAULT_FILESYSTEM_SPACE_DESCRIPTION,
|
|
26
26
|
IBGIB_BIN_SUBPATH,
|
|
27
|
-
IBGIB_DNA_SUBPATH
|
|
27
|
+
IBGIB_DNA_SUBPATH,
|
|
28
|
+
DEFAULT_LONG_PATH_LENGTH,
|
|
29
|
+
IBGIB_LONG_SUBPATH,
|
|
28
30
|
} from './filesystem-constants.mjs';
|
|
29
31
|
import { FilesystemSpaceData_V1, FilesystemSpaceOptionsData, FilesystemSpaceOptionsIbGib, FilesystemSpaceOptionsRel8ns, FilesystemSpaceResultData, FilesystemSpaceResultIbGib, FilesystemSpaceResultRel8ns, FilesystemSpace_V1 } from './filesystem-space-v1.mjs';
|
|
30
32
|
|
|
@@ -91,7 +93,7 @@ export interface NodeFilesystemSpaceData_V1 extends FilesystemSpaceData_V1 {
|
|
|
91
93
|
* (but of course won't be the end of the world when this doesn't happen).
|
|
92
94
|
*/
|
|
93
95
|
const DEFAULT_NODE_FILESYSTEM_SPACE_DATA_V1: NodeFilesystemSpaceData_V1 = {
|
|
94
|
-
version: '
|
|
96
|
+
version: '2',
|
|
95
97
|
uuid: ZERO_SPACE_ID,
|
|
96
98
|
name: IBGIB_SPACE_NAME_DEFAULT,
|
|
97
99
|
classname: 'NodeFilesystemSpace_V1',
|
|
@@ -101,8 +103,11 @@ const DEFAULT_NODE_FILESYSTEM_SPACE_DATA_V1: NodeFilesystemSpaceData_V1 = {
|
|
|
101
103
|
spaceSubPath: IBGIB_SPACE_SUBPATH_DEFAULT,
|
|
102
104
|
ibgibsSubPath: IBGIB_IBGIBS_SUBPATH,
|
|
103
105
|
metaSubPath: IBGIB_META_SUBPATH,
|
|
104
|
-
binSubPath:
|
|
105
|
-
dnaSubPath:
|
|
106
|
+
binSubPath: IBGIB_BIN_SUBPATH,
|
|
107
|
+
dnaSubPath: IBGIB_DNA_SUBPATH,
|
|
108
|
+
longSubPath: IBGIB_LONG_SUBPATH,
|
|
109
|
+
mitigateLongPaths: true,
|
|
110
|
+
longPathLength: DEFAULT_LONG_PATH_LENGTH,
|
|
106
111
|
persistOptsAndResultIbGibs: false,
|
|
107
112
|
validateIbGibAddrsMatchIbGibs: false,
|
|
108
113
|
longPollingIntervalMs: DEFAULT_LOCAL_SPACE_POLLING_INTERVAL_MS,
|
|
@@ -247,10 +252,15 @@ export async function validateNodeFilesystemSpace_V1Intrinsically({ space }: { s
|
|
|
247
252
|
}
|
|
248
253
|
|
|
249
254
|
/**
|
|
250
|
-
* Base class convenience for a local space with V1 ibgibs
|
|
255
|
+
* Base class convenience for a local space with V1 ibgibs working with the node
|
|
256
|
+
* filesystem.
|
|
251
257
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
258
|
+
* Unfortunately, file systems have short file name requirements, where 255 is
|
|
259
|
+
* often the max length of a filename. So this cannot store ibgibs directly by
|
|
260
|
+
* their address.
|
|
261
|
+
*
|
|
262
|
+
* This naively caches ibGibs in memory. When not found there, will looks in
|
|
263
|
+
* files using Ionic `FileSystem`.
|
|
254
264
|
*/
|
|
255
265
|
export class NodeFilesystemSpace_V1<
|
|
256
266
|
TData extends NodeFilesystemSpaceData_V1 = NodeFilesystemSpaceData_V1,
|
|
@@ -374,6 +384,11 @@ export class NodeFilesystemSpace_V1<
|
|
|
374
384
|
if (!this.data.binSubPath) { this.data.binSubPath = IBGIB_BIN_SUBPATH; }
|
|
375
385
|
if (!this.data.dnaSubPath) { this.data.dnaSubPath = IBGIB_DNA_SUBPATH; }
|
|
376
386
|
|
|
387
|
+
// do nothing, allow falsy
|
|
388
|
+
if (this.data.longSubPath === undefined) { this.data.longSubPath = IBGIB_LONG_SUBPATH; }
|
|
389
|
+
if (this.data.longPathLength === undefined) { this.data.longPathLength = DEFAULT_LONG_PATH_LENGTH; }
|
|
390
|
+
if (this.data.mitigateLongPaths === undefined) { this.data.mitigateLongPaths = true; }
|
|
391
|
+
|
|
377
392
|
this.ib = getSpaceIb({ space: this, classname: this.data!.classname });
|
|
378
393
|
|
|
379
394
|
this.gib = await getGib({ ibGib: this });
|
|
@@ -401,11 +416,14 @@ export class NodeFilesystemSpace_V1<
|
|
|
401
416
|
let path: string = "";
|
|
402
417
|
let filename: string = "";
|
|
403
418
|
let data: any = "";
|
|
419
|
+
|
|
404
420
|
if (ibGib) {
|
|
405
421
|
const addr = getIbGibAddr({ ibGib });
|
|
406
422
|
filename = this.getFilename({ addr });
|
|
407
423
|
const isBin = isBinary({ addr });
|
|
408
|
-
path = this.buildPath({
|
|
424
|
+
path = this.buildPath({
|
|
425
|
+
addr, filename, isMeta, isDna: isDna ?? false, isBin,
|
|
426
|
+
});
|
|
409
427
|
|
|
410
428
|
if (!isBin) {
|
|
411
429
|
// we only want to persist the ibGib protocol
|
|
@@ -419,19 +437,11 @@ export class NodeFilesystemSpace_V1<
|
|
|
419
437
|
}
|
|
420
438
|
|
|
421
439
|
if (logalot) { console.log(`${lc} path: ${path}, directory: ${thisData.baseDir}, encoding: ${thisData.encoding} (I: d4440ececbe6c859f8fcf6d7ece12522)`); }
|
|
422
|
-
// throw new Error(`writeFile not implemented yet from capacitor version (E: e096812ae5ec084afd3f3afe874f8423)`);
|
|
423
440
|
|
|
424
441
|
let fullPath = pathUtils.join(thisData.baseDir, path);
|
|
425
442
|
if (logalot) { console.log(`${lc} fullPath: ${fullPath}`); }
|
|
426
443
|
|
|
427
444
|
await writeFile(fullPath, data, 'utf8');
|
|
428
|
-
// const resWrite = await Filesystem.writeFile({
|
|
429
|
-
// path,
|
|
430
|
-
// data,
|
|
431
|
-
// directory: thisData.baseDir,
|
|
432
|
-
// encoding: thisData.encoding,
|
|
433
|
-
// });
|
|
434
|
-
// if (logalot) { console.log(`${lc} resWrite.uri: ${resWrite.uri}`); }
|
|
435
445
|
|
|
436
446
|
result.success = true;
|
|
437
447
|
} catch (error) {
|
|
@@ -459,12 +469,13 @@ export class NodeFilesystemSpace_V1<
|
|
|
459
469
|
const data = this.data;
|
|
460
470
|
let path: string = "";
|
|
461
471
|
let filename: string = "";
|
|
472
|
+
|
|
462
473
|
if (!isBinary({ addr })) {
|
|
463
474
|
filename = this.getFilename({ addr });
|
|
464
|
-
path = this.buildPath({ filename, isMeta, isDna: isDna ?? false });
|
|
475
|
+
path = this.buildPath({ addr, filename, isMeta, isDna: isDna ?? false, });
|
|
465
476
|
} else {
|
|
466
477
|
filename = this.getFilename({ addr });
|
|
467
|
-
path = this.buildPath({ filename, isMeta: false, isDna: false, isBin: true });
|
|
478
|
+
path = this.buildPath({ addr, filename, isMeta: false, isDna: false, isBin: true, });
|
|
468
479
|
}
|
|
469
480
|
if (logalot) { console.log(`${lc} path: ${path}, directory: ${data.baseDir}`); }
|
|
470
481
|
// throw new Error(`deleteFile not implemented yet from capacitor version (E: 06538d1154c71658a72099323553fa23)`);
|
|
@@ -503,30 +514,31 @@ export class NodeFilesystemSpace_V1<
|
|
|
503
514
|
let path: string = "";
|
|
504
515
|
let filename: string = "";
|
|
505
516
|
let paths: string[] = [];
|
|
517
|
+
|
|
506
518
|
if (!addrIsBin) {
|
|
507
519
|
filename = this.getFilename({ addr });
|
|
508
520
|
|
|
509
521
|
if (isMeta) {
|
|
510
522
|
// explicitly stating meta, so only look in meta
|
|
511
523
|
paths = [
|
|
512
|
-
this.buildPath({ filename, isMeta: true, isDna: false }),
|
|
524
|
+
this.buildPath({ addr, filename, isMeta: true, isDna: false, }),
|
|
513
525
|
];
|
|
514
526
|
} else if (isDna) {
|
|
515
527
|
// explicitly stating dna, so only look in dna
|
|
516
|
-
paths = [this.buildPath({ filename, isMeta: false, isDna: true }),];
|
|
528
|
+
paths = [this.buildPath({ addr, filename, isMeta: false, isDna: true, }),];
|
|
517
529
|
} else {
|
|
518
530
|
// could be regular, meta or dna, so we'll search everywhere, but first regular.
|
|
519
531
|
paths = [
|
|
520
|
-
this.buildPath({ filename, isMeta: false, isDna: false }),
|
|
521
|
-
this.buildPath({ filename, isMeta: true, isDna: false }),
|
|
522
|
-
this.buildPath({ filename, isMeta: false, isDna: true }),
|
|
532
|
+
this.buildPath({ addr, filename, isMeta: false, isDna: false, }),
|
|
533
|
+
this.buildPath({ addr, filename, isMeta: true, isDna: false, }),
|
|
534
|
+
this.buildPath({ addr, filename, isMeta: false, isDna: true, }),
|
|
523
535
|
];
|
|
524
536
|
}
|
|
525
537
|
} else {
|
|
526
538
|
// const addr = getBinAddr({binHash, binExt});
|
|
527
539
|
filename = this.getFilename({ addr });
|
|
528
540
|
// filename = this.getFilename({binHash, binExt});
|
|
529
|
-
path = this.buildPath({ filename, isDna: false, isMeta: false, isBin: true })
|
|
541
|
+
path = this.buildPath({ addr, filename, isDna: false, isMeta: false, isBin: true, })
|
|
530
542
|
paths = [path];
|
|
531
543
|
}
|
|
532
544
|
let resRead: any = null;
|
|
@@ -628,6 +640,10 @@ export class NodeFilesystemSpace_V1<
|
|
|
628
640
|
data.baseSubPath + '/' + data.spaceSubPath + '/' + data.dnaSubPath,
|
|
629
641
|
];
|
|
630
642
|
|
|
643
|
+
if (data.mitigateLongPaths) {
|
|
644
|
+
paths.push(data.baseSubPath + '/' + data.spaceSubPath + '/' + data.longSubPath);
|
|
645
|
+
}
|
|
646
|
+
|
|
631
647
|
const getPathKey = (p: string) => { return directory.toString() + '/' + p; }
|
|
632
648
|
|
|
633
649
|
let allExist = paths.every(path => this.pathExistsMap[getPathKey(path)]);
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
lastOfEach, lastOfAll,
|
|
4
4
|
ifWeMight, iReckon, respecfully
|
|
5
5
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
6
|
+
import { pickRandom_Letters } from '@ibgib/helper-gib';
|
|
6
7
|
// const maam = `[${import.meta.url}]`, sir = maam;
|
|
7
8
|
import { IbGibAddr, getIbGibAddr } from "@ibgib/ts-gib";
|
|
8
9
|
import { IbGib_V1, } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
@@ -66,7 +67,6 @@ export async function testSpace_createAndInit({
|
|
|
66
67
|
}: CommonSpaceSpecOptions): Promise<void> {
|
|
67
68
|
const logContext = `[${testSpace_PutGetDelete.name}]${desc ?? ''}`;
|
|
68
69
|
|
|
69
|
-
debugger;
|
|
70
70
|
await respecfully(sir, logContext, async () => {
|
|
71
71
|
|
|
72
72
|
let initialData: any | undefined;
|
|
@@ -87,7 +87,6 @@ export async function testSpace_createAndInit({
|
|
|
87
87
|
|
|
88
88
|
const fnIfWeBlock: any = shortcircuitRespec ? ifWeMight : ifWe;
|
|
89
89
|
|
|
90
|
-
debugger;
|
|
91
90
|
await fnIfWeBlock(sir, `when created and initialized, space should be initialized`, async () => {
|
|
92
91
|
space = await fnGetSpace(initialData, initialRel8ns);
|
|
93
92
|
await space.initialized;
|
|
@@ -202,6 +201,43 @@ export async function testSpace_PutGetDelete({
|
|
|
202
201
|
iReckon(sir, resGet.errorMsg).asTo('resGet after delete').isGonnaBeTruthy();
|
|
203
202
|
iReckon(sir, resGet.ibGibs).asTo('resGet after delete').isGonnaBeUndefined();
|
|
204
203
|
});
|
|
204
|
+
|
|
205
|
+
const testLengths = [255, 256, 300, 500, 1000];
|
|
206
|
+
for (let i = 0; i < testLengths.length; i++) {
|
|
207
|
+
const testLength = testLengths[i];
|
|
208
|
+
await fnIfWeBlock(sir, `${logContext}, should put/get/delete LONG addr (${testLength} length)`, async () => {
|
|
209
|
+
let newIbGib: IbGib_V1 = {
|
|
210
|
+
ib: pickRandom_Letters({ count: testLength }),
|
|
211
|
+
data: { x: 1 },
|
|
212
|
+
rel8ns: { ancestor: ['test yo^gib'] }
|
|
213
|
+
}
|
|
214
|
+
newIbGib.gib = await getGib({ ibGib: newIbGib, hasTjp: false });
|
|
215
|
+
const newIbGibAddr: IbGibAddr = getIbGibAddr({ ibGib: newIbGib });
|
|
216
|
+
|
|
217
|
+
// put
|
|
218
|
+
let resPut = await putInSpace({ ibGib: newIbGib, space });
|
|
219
|
+
iReckon(sir, resPut).asTo('resPut').isGonnaBeTruthy();
|
|
220
|
+
iReckon(sir, resPut.success).isGonnaBeTrue();
|
|
221
|
+
|
|
222
|
+
// get
|
|
223
|
+
let resGet = await getFromSpace({ addr: newIbGibAddr, space });
|
|
224
|
+
iReckon(sir, resGet).asTo('resGet').isGonnaBeTruthy();
|
|
225
|
+
iReckon(sir, resGet.success).asTo('resGet').isGonnaBeTrue();
|
|
226
|
+
iReckon(sir, resGet.errorMsg).asTo('resGet').isGonnaBeFalsy();
|
|
227
|
+
iReckon(sir, resGet.ibGibs).asTo('resGet').isGonnaBeTruthy();
|
|
228
|
+
iReckon(sir, resGet.ibGibs!.length).asTo('resGet').isGonnaBe(1);
|
|
229
|
+
iReckon(sir, resGet.ibGibs![0]).asTo('resGet').isGonnaBe(newIbGib);
|
|
230
|
+
|
|
231
|
+
// delete
|
|
232
|
+
await deleteFromSpace({ addr: newIbGibAddr, space });
|
|
233
|
+
resGet = await getFromSpace({ addr: newIbGibAddr, space });
|
|
234
|
+
iReckon(sir, resGet).asTo('resGet after delete').isGonnaBeTruthy();
|
|
235
|
+
iReckon(sir, resGet.success).asTo('resGet after delete').isGonnaBeFalse();
|
|
236
|
+
iReckon(sir, resGet.errorMsg).asTo('resGet after delete').isGonnaBeTruthy();
|
|
237
|
+
iReckon(sir, resGet.ibGibs).asTo('resGet after delete').isGonnaBeUndefined();
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
}
|
|
205
241
|
});
|
|
206
242
|
}
|
|
207
243
|
|
|
@@ -71,8 +71,26 @@ export interface IbGibSpaceData_Subpathed extends IbGibSpaceData {
|
|
|
71
71
|
uuid: SpaceId;
|
|
72
72
|
baseDir: string | any;
|
|
73
73
|
encoding: string | any;
|
|
74
|
+
/**
|
|
75
|
+
* this is to help mitigate against too long path limits
|
|
76
|
+
*/
|
|
77
|
+
mitigateLongPaths?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* if mitigating against long path lengths, this is the deciding split.
|
|
80
|
+
*
|
|
81
|
+
* so if the longPathLength is 250, and a full path would be 250, then
|
|
82
|
+
* that is now a long path. 249 would be a short path and would not need
|
|
83
|
+
* mitigation.
|
|
84
|
+
*/
|
|
85
|
+
longPathLength?: number;
|
|
74
86
|
baseSubPath: string;
|
|
75
87
|
spaceSubPath: string;
|
|
88
|
+
/**
|
|
89
|
+
* if a filepath is too long, things get stuffed in here
|
|
90
|
+
*
|
|
91
|
+
* this is to help mitigate against too long path limits
|
|
92
|
+
*/
|
|
93
|
+
longSubPath?: string;
|
|
76
94
|
ibgibsSubPath: string;
|
|
77
95
|
metaSubPath: string;
|
|
78
96
|
binSubPath: string;
|