@ibgib/core-gib 0.0.7 → 0.0.10
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/README.md +34 -13
- package/dist/assumptions.respec.d.mts +2 -0
- package/dist/assumptions.respec.d.mts.map +1 -0
- package/dist/assumptions.respec.mjs +41 -0
- package/dist/assumptions.respec.mjs.map +1 -0
- package/dist/common/form/form-helper.d.mts.map +1 -1
- package/dist/common/form/form-helper.mjs +0 -2
- package/dist/common/form/form-helper.mjs.map +1 -1
- package/dist/core-constants.d.mts +0 -2
- package/dist/core-constants.d.mts.map +1 -1
- package/dist/core-constants.mjs +0 -2
- package/dist/core-constants.mjs.map +1 -1
- package/dist/core-helper.respec.d.mts +2 -0
- package/dist/core-helper.respec.d.mts.map +1 -0
- package/dist/core-helper.respec.mjs +53 -0
- package/dist/core-helper.respec.mjs.map +1 -0
- package/dist/core-types.d.mts +24 -2
- package/dist/core-types.d.mts.map +1 -1
- package/dist/respec-gib.node.d.mts +2 -0
- package/dist/respec-gib.node.d.mts.map +1 -0
- package/dist/respec-gib.node.mjs +211 -0
- package/dist/respec-gib.node.mjs.map +1 -0
- package/dist/spec-helper.node.respec.d.mts +12 -0
- package/dist/spec-helper.node.respec.d.mts.map +1 -0
- package/dist/spec-helper.node.respec.mjs +43 -0
- package/dist/spec-helper.node.respec.mjs.map +1 -0
- package/dist/witness/app/app-base-v1.d.mts +1 -0
- package/dist/witness/app/app-base-v1.d.mts.map +1 -1
- package/dist/witness/app/app-base-v1.mjs +48 -11
- package/dist/witness/app/app-base-v1.mjs.map +1 -1
- package/dist/witness/app/app-constants.d.mts +2 -0
- package/dist/witness/app/app-constants.d.mts.map +1 -1
- package/dist/witness/app/app-constants.mjs +2 -0
- package/dist/witness/app/app-constants.mjs.map +1 -1
- package/dist/witness/app/app-helper.d.mts.map +1 -1
- package/dist/witness/app/app-helper.mjs +2 -1
- package/dist/witness/app/app-helper.mjs.map +1 -1
- package/dist/witness/robbot/robbot-base-v1.d.mts +4 -5
- package/dist/witness/robbot/robbot-base-v1.d.mts.map +1 -1
- package/dist/witness/robbot/robbot-base-v1.mjs +29 -1
- package/dist/witness/robbot/robbot-base-v1.mjs.map +1 -1
- package/dist/witness/robbot/robbot-helper.respec.d.mts +2 -0
- package/dist/witness/robbot/robbot-helper.respec.d.mts.map +1 -0
- package/dist/witness/robbot/robbot-helper.respec.mjs +106 -0
- package/dist/witness/robbot/robbot-helper.respec.mjs.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-helper.d.mts +3 -0
- package/dist/witness/space/bootstrap/bootstrap-helper.d.mts.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-helper.mjs +51 -0
- package/dist/witness/space/bootstrap/bootstrap-helper.mjs.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-types.d.mts +117 -0
- package/dist/witness/space/bootstrap/bootstrap-types.d.mts.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-types.mjs +7 -0
- package/dist/witness/space/bootstrap/bootstrap-types.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.d.mts +64 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.mjs +64 -0
- package/dist/witness/space/filesystem-space/filesystem-constants.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts +180 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.mjs +1145 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.mjs +107 -0
- package/dist/witness/space/filesystem-space/filesystem-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-types.d.mts +73 -0
- package/dist/witness/space/filesystem-space/filesystem-types.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/filesystem-types.mjs +2 -0
- package/dist/witness/space/filesystem-space/filesystem-types.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.d.mts +90 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.mjs +669 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.mjs.map +1 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.d.mts +2 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.d.mts.map +1 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mjs +129 -0
- package/dist/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mjs.map +1 -0
- package/dist/witness/space/{inner-space-v1.d.mts → inner-space/inner-space-v1.d.mts} +2 -2
- package/dist/witness/space/inner-space/inner-space-v1.d.mts.map +1 -0
- package/dist/witness/space/{inner-space-v1.mjs → inner-space/inner-space-v1.mjs} +3 -3
- package/dist/witness/space/inner-space/inner-space-v1.mjs.map +1 -0
- package/dist/witness/space/inner-space/inner-space-v1.respec.d.mts +2 -0
- package/dist/witness/space/inner-space/inner-space-v1.respec.d.mts.map +1 -0
- package/dist/witness/space/inner-space/inner-space-v1.respec.mjs +56 -0
- package/dist/witness/space/inner-space/inner-space-v1.respec.mjs.map +1 -0
- package/dist/witness/space/space-constants.d.mts +0 -27
- package/dist/witness/space/space-constants.d.mts.map +1 -1
- package/dist/witness/space/space-constants.mjs +0 -27
- package/dist/witness/space/space-constants.mjs.map +1 -1
- package/dist/witness/space/space-helper.d.mts +3 -3
- package/dist/witness/space/space-helper.d.mts.map +1 -1
- package/dist/witness/space/space-helper.mjs +6 -51
- package/dist/witness/space/space-helper.mjs.map +1 -1
- package/dist/witness/space/space-respec-helper.d.mts +71 -0
- package/dist/witness/space/space-respec-helper.d.mts.map +1 -0
- package/dist/witness/space/space-respec-helper.mjs +186 -0
- package/dist/witness/space/space-respec-helper.mjs.map +1 -0
- package/dist/witness/space/space-types.d.mts +0 -98
- package/dist/witness/space/space-types.d.mts.map +1 -1
- package/dist/witness/space/space-types.mjs +0 -1
- package/dist/witness/space/space-types.mjs.map +1 -1
- package/dist/witness/witness-base-v1.d.mts.map +1 -1
- package/dist/witness/witness-base-v1.mjs +7 -7
- package/dist/witness/witness-base-v1.mjs.map +1 -1
- package/dist/witness/witness-helper.d.mts +8 -0
- package/dist/witness/witness-helper.d.mts.map +1 -1
- package/dist/witness/witness-helper.mjs +30 -0
- package/dist/witness/witness-helper.mjs.map +1 -1
- package/package.json +12 -15
- package/src/{assumptions.spec.mts → assumptions.respec.mts} +11 -5
- package/src/common/form/form-helper.mts +3 -4
- package/src/core-constants.mts +0 -2
- package/src/core-helper.respec.mts +71 -0
- package/src/core-types.mts +24 -2
- package/src/respec-gib.node.mts +199 -0
- package/src/spec-helper.node.respec.mts +45 -0
- package/src/witness/app/app-base-v1.mts +38 -23
- package/src/witness/app/app-constants.mts +3 -0
- package/src/witness/app/app-helper.mts +2 -1
- package/src/witness/robbot/robbot-base-v1.mts +9 -6
- package/src/witness/robbot/{robbot-helper.spec.mts → robbot-helper.respec.mts} +39 -33
- package/src/witness/space/bootstrap/bootstrap-helper.mts +50 -0
- package/src/witness/space/bootstrap/bootstrap-types.mts +123 -0
- package/src/witness/space/filesystem-space/filesystem-constants.mts +66 -0
- package/src/witness/space/filesystem-space/filesystem-space-v1.mts +1283 -0
- package/src/witness/space/filesystem-space/filesystem-space-v1.respec.mts +110 -0
- package/src/witness/space/filesystem-space/filesystem-types.mts +75 -0
- package/src/witness/space/filesystem-space/node-filesystem-space-v1.mts +697 -0
- package/src/witness/space/filesystem-space/node-filesystem-space-v1.node.respec.mts +148 -0
- package/src/witness/space/{inner-space-v1.mts → inner-space/inner-space-v1.mts} +5 -6
- package/src/witness/space/{inner-space-v1.spec.mts → inner-space/inner-space-v1.respec.mts} +17 -8
- package/src/witness/space/space-constants.mts +0 -27
- package/src/witness/space/space-helper.mts +17 -54
- package/src/witness/space/{space-spec-helper.spec.mts → space-respec-helper.mts} +97 -57
- package/src/witness/space/space-types.mts +0 -105
- package/src/witness/witness-base-v1.mts +8 -6
- package/src/witness/witness-helper.mts +31 -0
- package/tsconfig.json +4 -2
- package/dist/witness/space/inner-space-v1.d.mts.map +0 -1
- package/dist/witness/space/inner-space-v1.mjs.map +0 -1
- package/jasmine-browser.json +0 -18
- package/jasmine.json +0 -6
- package/src/core-helper.spec.mts +0 -64
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { getRegExp, UUID_REGEXP } from '@ibgib/helper-gib';
|
|
3
|
-
|
|
4
|
-
import { GLOBAL_LOG_A_LOT, SAFE_SPECIAL_CHARS } from '../../core-constants.mjs';
|
|
3
|
+
|
|
5
4
|
import { DynamicForm, FormItemInfo } from './form-items.mjs';
|
|
6
|
-
|
|
5
|
+
import { GLOBAL_LOG_A_LOT, SAFE_SPECIAL_CHARS } from '../../core-constants.mjs';
|
|
7
6
|
|
|
8
7
|
const logalot = GLOBAL_LOG_A_LOT || false;
|
|
9
8
|
|
|
@@ -16,6 +15,7 @@ const logalot = GLOBAL_LOG_A_LOT || false;
|
|
|
16
15
|
*/
|
|
17
16
|
export class DynamicFormBuilder {
|
|
18
17
|
protected lc: string = `[${DynamicFormBuilder.name}]`;
|
|
18
|
+
|
|
19
19
|
protected items: FormItemInfo[] = [];
|
|
20
20
|
protected what: string = '';
|
|
21
21
|
/**
|
|
@@ -250,4 +250,3 @@ export class DynamicFormBuilder {
|
|
|
250
250
|
} as DynamicForm;
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
|
package/src/core-constants.mts
CHANGED
|
@@ -495,8 +495,6 @@ export const SIMPLE_CONFIG_KEY_ROBBOT_SELECTED_ADDR = 'robbotBarSelectedAddr';
|
|
|
495
495
|
|
|
496
496
|
// #region app
|
|
497
497
|
|
|
498
|
-
export const APP_NAME_REGEXP = /^[a-zA-Z0-9_\-.]{1,32}$/;
|
|
499
|
-
export const APP_REL8N_NAME = 'app';
|
|
500
498
|
export const DEFAULT_APP_ICON = 'apps-outline';
|
|
501
499
|
|
|
502
500
|
// #endregion app
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
firstOfEach, firstOfAll, ifWe,
|
|
3
|
+
lastOfEach, lastOfAll,
|
|
4
|
+
ifWeMight, iReckon, respecfully
|
|
5
|
+
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
6
|
+
const maam = `[${import.meta.url}]`, sir = maam;
|
|
7
|
+
|
|
8
|
+
let crypto = globalThis.crypto;
|
|
9
|
+
let { subtle } = crypto;
|
|
10
|
+
|
|
11
|
+
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
12
|
+
|
|
13
|
+
import { fooClone, fooFactory, fooGetIbAndGib } from './core-helper.mjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Test helper functions.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
await respecfully(sir, `foo clone`, async () => {
|
|
20
|
+
|
|
21
|
+
await ifWe(sir, `should foo Clone yo (testing node/browser isomorphic packages)`, () => {
|
|
22
|
+
let obj = 1;
|
|
23
|
+
let clone = fooClone(obj);
|
|
24
|
+
iReckon(sir, clone).asTo('clone foo yo').isGonnaBe(obj);
|
|
25
|
+
// expect(1).asTo('expected fail test case').isGonnaBe(2);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await ifWe(sir, `should foo getibAndGib yo (testing node/browser isomorphic packages)`, () => {
|
|
29
|
+
let result = fooGetIbAndGib();
|
|
30
|
+
iReckon(sir, result.ib).asTo('ib').isGonnaBe('ib');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
await ifWe(sir, `should foo factory yo (testing node/browser isomorphic packages)`, async () => {
|
|
34
|
+
let result = await fooFactory();
|
|
35
|
+
iReckon(sir, result).asTo('result').isGonnaBeTruthy();
|
|
36
|
+
iReckon(sir, result.ib).asTo('result.ib').isGonnaBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
async function hash({
|
|
42
|
+
s,
|
|
43
|
+
}: {
|
|
44
|
+
s: string,
|
|
45
|
+
}): Promise<string> {
|
|
46
|
+
if (!s) { return ''; }
|
|
47
|
+
let algorithm = 'SHA-256';
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
const msgUint8 = new TextEncoder().encode(s);
|
|
51
|
+
const buffer = await subtle.digest(algorithm, msgUint8);
|
|
52
|
+
const asArray = Array.from(new Uint8Array(buffer));
|
|
53
|
+
return asArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.error(e.message ?? e);
|
|
56
|
+
throw e;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
await respecfully(sir, `non-ts-gib isomorphic crypto hashing`, async () => {
|
|
61
|
+
|
|
62
|
+
await ifWe(sir, `should digest simple string consistently using crypto.subtle directly `, async () => {
|
|
63
|
+
let h = await hash({ s: '42' });
|
|
64
|
+
iReckon(sir, h).asTo('42').isGonnaBe('73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049');
|
|
65
|
+
});
|
|
66
|
+
await ifWe(sir, `should digest simple stringified ibgib consistently using crypto.subtle directly `, async () => {
|
|
67
|
+
let ibgib: IbGib_V1 = { ib: 'ib', gib: 'gib' };
|
|
68
|
+
let h = await hash({ s: JSON.stringify(ibgib) }); // doesn't use ts-gib but consistent stringifying json is important
|
|
69
|
+
iReckon(sir, h).asTo('ib^gib').isGonnaBe('cbad0694a257358c044611ea1fa88ace71a01a9b8409d2354d0387d8043f7671');
|
|
70
|
+
});
|
|
71
|
+
});
|
package/src/core-types.mts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
import { IbGibAddr, TransformResult } from '@ibgib/ts-gib';
|
|
4
|
+
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
5
|
+
|
|
2
6
|
import {
|
|
3
7
|
DeleteIbGibOpts, DeleteIbGibResult, GetIbGibOpts, GetIbGibResult,
|
|
4
8
|
IbGibTimelineUpdateInfo, PutIbGibOpts, PutIbGibResult,
|
|
@@ -6,12 +10,10 @@ import {
|
|
|
6
10
|
} from './common/other/other-types.mjs';
|
|
7
11
|
import { SpaceId } from './witness/space/space-types.mjs';
|
|
8
12
|
import { RobbotIbGib_V1, RobbotPromptResult } from './witness/robbot/robbot-types.mjs';
|
|
9
|
-
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
10
13
|
import { PicIbGib_V1, UpdatePicPromptResult } from './common/pic/pic-types.mjs';
|
|
11
14
|
import { CommentIbGib_V1, UpdateCommentPromptResult } from './common/comment/comment-types.mjs';
|
|
12
15
|
import { AppIbGib_V1, AppPromptResult } from './witness/app/app-types.mjs';
|
|
13
16
|
import { RootData } from './common/root/root-types.mjs';
|
|
14
|
-
import { IbGibAddr, TransformResult } from '@ibgib/ts-gib';
|
|
15
17
|
import { GetDependencyGraphOptions } from './common/other/graph-helper.mjs';
|
|
16
18
|
import { CiphertextIbGib_V1, EncryptionData_V1, SecretData_V1, SecretIbGib_V1 } from './common/encrypt/encrypt-types.mjs';
|
|
17
19
|
import { SyncSagaInfo } from './witness/space/outer-space/outer-space-types.mjs';
|
|
@@ -517,3 +519,23 @@ export interface IbGibLocalSpaceService_AllPowerful {
|
|
|
517
519
|
space?: IbGibSpaceAny,
|
|
518
520
|
}): Promise<void>;
|
|
519
521
|
}
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Function (provider?) that alerts the user of a given `title` and `msg`.
|
|
526
|
+
*/
|
|
527
|
+
export type AlertFunction = ({ title, msg }: { title: string, msg: string }) => Promise<void>;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Function (provider?) that returns user text, prompting with the given `title` and `msg`.
|
|
531
|
+
*/
|
|
532
|
+
export type PromptFunction = ({ title, msg }: { title: string, msg: string }) => Promise<string | null>;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Function (provider?) that returns a password, prompting with the given `title` and `msg`.
|
|
536
|
+
*
|
|
537
|
+
* This is the same atow as the {@link PromptFunction}.
|
|
538
|
+
*
|
|
539
|
+
* In the future, maybe a prompt signature with a `private` param would be more appropriate/DRY.
|
|
540
|
+
*/
|
|
541
|
+
export type PromptPasswordFunction = PromptFunction;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { readdir, open } from 'node:fs/promises';
|
|
2
|
+
import { statSync } from 'node:fs';
|
|
3
|
+
import * as pathUtils from 'path';
|
|
4
|
+
|
|
5
|
+
import { pretty } from '@ibgib/helper-gib';
|
|
6
|
+
import { getGlobalRespecGib } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
7
|
+
|
|
8
|
+
// #region settings
|
|
9
|
+
/**
|
|
10
|
+
* This is how I enable/disable verbose logging. Do with it what you will.
|
|
11
|
+
*/
|
|
12
|
+
const logalot = false;
|
|
13
|
+
|
|
14
|
+
/** set this to the root of the respecs to look at */
|
|
15
|
+
const RESPEC_ROOT_DIR_RELATIVE_TO_BASE = './dist';
|
|
16
|
+
|
|
17
|
+
/** change this to suit your naming convention */
|
|
18
|
+
const RESPEC_FILE_REG_EXP = /^.+respec\.mjs$/;
|
|
19
|
+
// const RESPEC_FILE_REG_EXP = /^.*respec-gib.respec\.mjs$/;
|
|
20
|
+
// if (respecPath.includes('respec-gib.respec.mjs')) {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* If on, will first load a file and see if there is an extra respecful
|
|
24
|
+
* `await respecfully`/`ifWe` block. Use these if you want to focus on a single or
|
|
25
|
+
* subset of respecs.
|
|
26
|
+
*
|
|
27
|
+
* If there are no extra respecful blocks found in an entire file, that file
|
|
28
|
+
* will be skipped.
|
|
29
|
+
*
|
|
30
|
+
* Note: this only is a flag to search through respec files.
|
|
31
|
+
*/
|
|
32
|
+
const LOOK_FOR_EXTRA_RESPEC = true;
|
|
33
|
+
/**
|
|
34
|
+
* The names of the functions that indicate that we want to focus on just those
|
|
35
|
+
* blocks.
|
|
36
|
+
*
|
|
37
|
+
* ATOW, for first run implementation here, I am implementing it such that it
|
|
38
|
+
* will filter out files that don't have these indicators. The respec files that
|
|
39
|
+
* do have these will execute fully, but the output will only include these
|
|
40
|
+
* particular blocks.
|
|
41
|
+
*/
|
|
42
|
+
const EXTRA_RESPEC_FUNCTION_NAMES: string[] = ['await respecfullyDear', 'ifWeMight'];
|
|
43
|
+
|
|
44
|
+
// #endregion settings
|
|
45
|
+
|
|
46
|
+
// #region 1. get respec paths
|
|
47
|
+
|
|
48
|
+
const basePath = process.cwd();
|
|
49
|
+
const srcPath = pathUtils.join(basePath, RESPEC_ROOT_DIR_RELATIVE_TO_BASE);
|
|
50
|
+
|
|
51
|
+
if (logalot) { console.log(`cwd: ${process.cwd()}`); }
|
|
52
|
+
if (logalot) { console.log(`basePath: ${basePath}`); }
|
|
53
|
+
if (logalot) { console.log(`srcPath: ${srcPath}`); }
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
const respecGib = getGlobalRespecGib();
|
|
57
|
+
const allRespecPaths = await getRespecFileFullPaths(srcPath, []);
|
|
58
|
+
|
|
59
|
+
if (logalot) { console.log(`allRespecPaths: ${allRespecPaths} (I: f5182a455375a8cf2aa6e1127a082423)`); }
|
|
60
|
+
let filteredRespecPaths: string[] | undefined = undefined;
|
|
61
|
+
|
|
62
|
+
if (LOOK_FOR_EXTRA_RESPEC) {
|
|
63
|
+
const hasExtraRespecPromises = allRespecPaths.map(async respecPath => {
|
|
64
|
+
const hasExtra = await respecFileHasExtraRespec(respecPath);
|
|
65
|
+
return [respecPath, hasExtra] as [string, boolean];
|
|
66
|
+
});
|
|
67
|
+
const resPathHasExtraTuples = await Promise.all(hasExtraRespecPromises);
|
|
68
|
+
filteredRespecPaths = resPathHasExtraTuples
|
|
69
|
+
.filter(([_respecPath, hasExtra]) => hasExtra)
|
|
70
|
+
.map(([respecPath, _hasExtra]) => respecPath);
|
|
71
|
+
|
|
72
|
+
// if there are no files that have extra respec then we do all files
|
|
73
|
+
if (filteredRespecPaths.length === 0) {
|
|
74
|
+
if (logalot) { console.log(`filteredRespecPaths is empty. doing allRespecPaths found (I: b98f54656899646025eecb4c028ab523)`); }
|
|
75
|
+
filteredRespecPaths = allRespecPaths.concat();
|
|
76
|
+
} else {
|
|
77
|
+
console.log(`filteredRespecPaths for extra respec: ${filteredRespecPaths} (I: b98f54656899646025eecb4c028ab523)`);
|
|
78
|
+
respecGib.extraRespecOnly = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// #endregion 1. get respec paths
|
|
83
|
+
|
|
84
|
+
respecGib.allRespecPaths = allRespecPaths;
|
|
85
|
+
respecGib.filteredRespecPaths = filteredRespecPaths;
|
|
86
|
+
const respecPaths = filteredRespecPaths ?? allRespecPaths;
|
|
87
|
+
respecGib.respecPaths = respecPaths;
|
|
88
|
+
if (logalot) { console.log(`respecPaths found:\n${respecPaths}`); }
|
|
89
|
+
|
|
90
|
+
// #region 2. execute paths' respective respecs
|
|
91
|
+
|
|
92
|
+
// for now, we'll do sequentially, but in the future we could conceivable farm
|
|
93
|
+
// these out to other node processes, or at least Promise.all
|
|
94
|
+
|
|
95
|
+
for (let i = 0; i < respecPaths.length; i++) {
|
|
96
|
+
const respecPath = respecPaths[i];
|
|
97
|
+
if (logalot) { console.log(respecPath); }
|
|
98
|
+
const esm = await import(respecPath);
|
|
99
|
+
if (logalot) { console.log(pretty(Object.keys(esm))); }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const skippedRespecPathCount = respecGib.allRespecPaths.length - respecGib.respecPaths.length;
|
|
103
|
+
if (skippedRespecPathCount > 0) {
|
|
104
|
+
console.log('');
|
|
105
|
+
console.error('\x1b[33m%s\x1b[0m', `${skippedRespecPathCount} respec files completely skipped.`); // yellow
|
|
106
|
+
}
|
|
107
|
+
if (respecGib.ifWeBlocksSkipped > 0) {
|
|
108
|
+
console.log('');
|
|
109
|
+
console.error('\x1b[33m%s\x1b[0m', `${respecGib.ifWeBlocksSkipped} ifWe blocks ran but skipped reporting`); // yellow
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (respecGib.errorMsgs.length === 0) {
|
|
113
|
+
console.log('');
|
|
114
|
+
console.error('\x1b[32m%s\x1b[0m', `💚💚 nothing but respec 💚💚`); // green
|
|
115
|
+
} else {
|
|
116
|
+
console.log('');
|
|
117
|
+
console.error('\x1b[31m%s\x1b[0m', `💔💔 DISrespec found 💔💔`); // red
|
|
118
|
+
for (const errorMsg of respecGib.errorMsgs) {
|
|
119
|
+
console.error('\x1b[31m%s\x1b[0m', errorMsg); // red
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// #endregion 2. execute paths' respective respecs
|
|
124
|
+
|
|
125
|
+
// #region helper functions
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* builds a list of respec file paths, recursively traversing subdirectories
|
|
129
|
+
* starting from `dirPath`.
|
|
130
|
+
*
|
|
131
|
+
* @param dirPath a full path corresponding to a directory
|
|
132
|
+
* @param found respec paths already found (used in recursive calls)
|
|
133
|
+
* @returns list of all respec paths according to the respec regexp constant {@link RESPEC_FILE_REG_EXP}
|
|
134
|
+
*/
|
|
135
|
+
async function getRespecFileFullPaths(dirPath: string, found: string[]): Promise<string[]> {
|
|
136
|
+
const lc = `[${getRespecFileFullPaths.name}][${dirPath}]`;
|
|
137
|
+
try {
|
|
138
|
+
if (logalot) { console.log(`${lc} starting... (I: 16026290523925f79ba1933847e2a623)`); }
|
|
139
|
+
found ??= [];
|
|
140
|
+
const children = await readdir(dirPath);
|
|
141
|
+
if (logalot) { for (let i = 0; i < children.length; i++) { console.log(children[i]); } }
|
|
142
|
+
const files: string[] = [];
|
|
143
|
+
const dirs: string[] = [];
|
|
144
|
+
children.forEach(name => {
|
|
145
|
+
const fullPath = pathUtils.join(dirPath, name);
|
|
146
|
+
const stat = statSync(fullPath);
|
|
147
|
+
if (stat.isDirectory()) {
|
|
148
|
+
// symbolic link could create a loop
|
|
149
|
+
if (!stat.isSymbolicLink()) { dirs.push(fullPath); }
|
|
150
|
+
} else if (!!name.match(RESPEC_FILE_REG_EXP)) {
|
|
151
|
+
files.push(fullPath);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
found = found.concat(files);
|
|
156
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
157
|
+
const subfound = await getRespecFileFullPaths(dirs[i], found);
|
|
158
|
+
found = found.concat(subfound);
|
|
159
|
+
}
|
|
160
|
+
return Array.from(new Set(found)); // unique
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.error(`${lc} ${error.message}`);
|
|
163
|
+
throw error;
|
|
164
|
+
} finally {
|
|
165
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Searches through the file (without importing it) for extra respecful
|
|
171
|
+
* functions.
|
|
172
|
+
*
|
|
173
|
+
* @param respecPath
|
|
174
|
+
* @returns true if extra respecful functions found in file
|
|
175
|
+
*/
|
|
176
|
+
async function respecFileHasExtraRespec(respecPath: string): Promise<boolean> {
|
|
177
|
+
const lc = `[${respecFileHasExtraRespec.name}]`;
|
|
178
|
+
try {
|
|
179
|
+
if (logalot) { console.log(`${lc} starting... (I: 61f3221917ba77175efa305b14defc23)`); }
|
|
180
|
+
const file = await open(respecPath);
|
|
181
|
+
for await (const line of file.readLines()) {
|
|
182
|
+
const hasExtraRespecInLine =
|
|
183
|
+
EXTRA_RESPEC_FUNCTION_NAMES.some(fnName => {
|
|
184
|
+
if (line.includes(`${fnName}(`)) { return true; }
|
|
185
|
+
});
|
|
186
|
+
if (hasExtraRespecInLine) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.error(`${lc} ${error.message}`);
|
|
193
|
+
throw error;
|
|
194
|
+
} finally {
|
|
195
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// #endregion helper functions
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { default as pathUtils } from 'path';
|
|
2
|
+
|
|
3
|
+
import { delay, getUUID, } from '@ibgib/helper-gib';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* helper function to get the filename for use in specs.
|
|
7
|
+
*
|
|
8
|
+
* @param importMetaUrl import.meta.url
|
|
9
|
+
* @returns currently executing filename
|
|
10
|
+
*/
|
|
11
|
+
export async function getCurrentFilename(importMetaUrl: string): Promise<string> {
|
|
12
|
+
const lc = `[${getCurrentFilename.name}]`;
|
|
13
|
+
try {
|
|
14
|
+
const pieces = importMetaUrl.split(pathUtils.sep);
|
|
15
|
+
let filename = pieces.at(-1)?.replace(/\.mjs$/, '')
|
|
16
|
+
if (!filename) {
|
|
17
|
+
console.warn(`filename not able to be gotten?`);
|
|
18
|
+
filename = (new Date()).toTimeString() + (await getUUID());
|
|
19
|
+
}
|
|
20
|
+
return `ibgib${pathUtils.sep}${filename}`;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error(`${lc} ${error.message}`);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function specGetSpaceId(): Promise<string> {
|
|
28
|
+
await delay(10);
|
|
29
|
+
let uuid = await getUUID();
|
|
30
|
+
let now = new Date();
|
|
31
|
+
now.getMinutes();
|
|
32
|
+
let timeComponent = now.getMinutes().toString() + now.getSeconds().toString() + now.getMilliseconds().toString()
|
|
33
|
+
uuid = timeComponent + uuid.substring(timeComponent.length, uuid.length);
|
|
34
|
+
return uuid;
|
|
35
|
+
}
|
|
36
|
+
export function specGetSpaceName(uuid: string): string {
|
|
37
|
+
return uuid.substring(0, 12);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function specGetSpaceDescription(uuid: string): string {
|
|
41
|
+
return 'description for ' + uuid.substring(0, 8);
|
|
42
|
+
}
|
|
43
|
+
export function specGetBaseSubPath(uuid: string): string {
|
|
44
|
+
return uuid.slice();
|
|
45
|
+
}
|
|
@@ -13,12 +13,14 @@ import { CommentIbGib_V1 } from '../../common/comment/comment-types.mjs';
|
|
|
13
13
|
import { PicIbGib_V1 } from '../../common/pic/pic-types.mjs';
|
|
14
14
|
import { ErrorIbGib_V1 } from '../../common/error/error-types.mjs';
|
|
15
15
|
import { validateCommonAppData } from './app-helper.mjs';
|
|
16
|
-
import { argy_, isArg, resulty_ } from '../witness-helper.mjs';
|
|
16
|
+
import { argy_, isArg, isCommand, resulty_ } from '../witness-helper.mjs';
|
|
17
17
|
import { IbGibLocalSpaceService_AllPowerful } from '../../core-types.mjs';
|
|
18
18
|
import { pretty } from '@ibgib/helper-gib';
|
|
19
19
|
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
20
20
|
import { errorIbGib } from '../../common/error/error-helper.mjs';
|
|
21
21
|
import { getIbGibAddr } from '@ibgib/ts-gib';
|
|
22
|
+
import { isComment } from '../../common/comment/comment-helper.mjs';
|
|
23
|
+
import { isPic } from '../../common/pic/pic-helper.mjs';
|
|
22
24
|
|
|
23
25
|
const logalot = GLOBAL_LOG_A_LOT || false;
|
|
24
26
|
|
|
@@ -54,18 +56,6 @@ export abstract class AppBase_V1<
|
|
|
54
56
|
* Log context for convenience with logging. (Ignore if you don't want to use this.)
|
|
55
57
|
*/
|
|
56
58
|
protected lc: string = `[${AppBase_V1.name}]`;
|
|
57
|
-
// protected lc: string = `[${AppBase_V1.name}]`;
|
|
58
|
-
|
|
59
|
-
// getAppIb(classname: string): string {
|
|
60
|
-
// const lc = `${this.lc}[${this.getAppIb.name}]`;
|
|
61
|
-
// if (!classname) {
|
|
62
|
-
// classname = this.lc?.replace('[','').replace(']','') || AppBase_V1.name+'_descendant';
|
|
63
|
-
// console.warn(`${lc} classname is falsy. Using ${classname}.`);
|
|
64
|
-
// }
|
|
65
|
-
// const name = this.data?.name || IBGIB_SPACE_NAME_DEFAULT;
|
|
66
|
-
// const id = this.data?.uuid || undefined;
|
|
67
|
-
// return `witness space ${classname} ${name} ${id}`;
|
|
68
|
-
// }
|
|
69
59
|
|
|
70
60
|
/**
|
|
71
61
|
* Reference to the local ibgibs service, which is one way at getting at the
|
|
@@ -90,22 +80,42 @@ export abstract class AppBase_V1<
|
|
|
90
80
|
try {
|
|
91
81
|
if (logalot) { console.log(`${lc} starting...`); }
|
|
92
82
|
|
|
83
|
+
|
|
84
|
+
await this.loadNewerSelfIfAvailable();
|
|
85
|
+
|
|
86
|
+
let result = await this.routeAndDoArg({ arg });
|
|
87
|
+
if (!result) { result = await this.doDefault({ ibGib: arg }); }
|
|
88
|
+
if (!result) { console.warn(`${lc} result falsy...Could not produce result? Was doDefault implemented in concrete class? (W: 15e70486bc33922f9388961bab815223)`); }
|
|
89
|
+
return result;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(`${lc} ${error.message}`);
|
|
92
|
+
throw error;
|
|
93
|
+
} finally {
|
|
94
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
protected async loadNewerSelfIfAvailable(): Promise<void> {
|
|
99
|
+
const lc = `${this.lc}[${this.loadNewerSelfIfAvailable.name}]`;
|
|
100
|
+
try {
|
|
101
|
+
if (logalot) { console.log(`${lc} starting... (I: 94755c3131f4dfa12d20fa38e2926522)`); }
|
|
93
102
|
if (this.ibgibsSvc) {
|
|
94
103
|
// check for newer version of self locally before executing
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
//
|
|
99
|
-
let resGet = await this.ibgibsSvc.get({ addr:
|
|
104
|
+
const thisAddr = getIbGibAddr({ ibGib: this });
|
|
105
|
+
const thisLatestAddr = await this.ibgibsSvc.getLatestAddr({ ibGib: this });
|
|
106
|
+
if (thisLatestAddr && thisLatestAddr !== thisAddr) {
|
|
107
|
+
// witness has a newer ibgib in its timeline
|
|
108
|
+
let resGet = await this.ibgibsSvc.get({ addr: thisLatestAddr });
|
|
100
109
|
if (!resGet || !resGet?.success || (resGet?.ibGibs ?? []).length === 0) {
|
|
101
|
-
throw new Error(`could not get
|
|
110
|
+
throw new Error(`could not get latest this ibgib in timeline? (E: 15fa346c8ac17edb96e4b0870104c122)`);
|
|
102
111
|
}
|
|
103
112
|
await this.loadIbGibDto(resGet.ibGibs![0] as IbGib_V1<TData, TRel8ns>);
|
|
104
113
|
const validationErrors = await this.validateThis();
|
|
105
114
|
if (validationErrors?.length > 0) { throw new Error(`validationErrors when loading newer version: ${pretty(validationErrors)} (E: 0d9f0684a1ff6af44e20a57130e3ac22)`); }
|
|
106
115
|
}
|
|
116
|
+
} else {
|
|
117
|
+
console.warn(`${lc} this.ibgibsSvc undefined (W: 44cc5bf1b14b4695b8de4c589787be06)`);
|
|
107
118
|
}
|
|
108
|
-
return this.routeAndDoArg({ arg });
|
|
109
119
|
} catch (error) {
|
|
110
120
|
console.error(`${lc} ${error.message}`);
|
|
111
121
|
throw error;
|
|
@@ -138,11 +148,16 @@ export abstract class AppBase_V1<
|
|
|
138
148
|
const lc = `${this.lc}[${this.routeAndDoArg.name}]`;
|
|
139
149
|
try {
|
|
140
150
|
if (logalot) { console.log(`${lc} starting...`); }
|
|
141
|
-
|
|
142
|
-
|
|
151
|
+
const ibGib = arg as IbGib_V1;
|
|
152
|
+
if (isArg({ ibGib })) {
|
|
153
|
+
if (isCommand({ ibGib })) {
|
|
143
154
|
return this.doCmdArg({ arg: arg as AppCmdIbGib<IbGib_V1, AppCmdData, AppCmdRel8ns> });
|
|
155
|
+
} else if (isComment({ ibGib })) {
|
|
156
|
+
return this.doComment({ ibGib: ibGib as CommentIbGib_V1 });
|
|
157
|
+
} else if (isPic({ ibGib })) {
|
|
158
|
+
return this.doPic({ ibGib: ibGib as PicIbGib_V1 });
|
|
144
159
|
} else {
|
|
145
|
-
return
|
|
160
|
+
return undefined;
|
|
146
161
|
}
|
|
147
162
|
}
|
|
148
163
|
} catch (error) {
|
|
@@ -3,8 +3,9 @@ import { Gib, Ib, } from '@ibgib/ts-gib';
|
|
|
3
3
|
import { validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
7
7
|
import { AppData_V1, } from './app-types.mjs';
|
|
8
|
+
import { APP_NAME_REGEXP, APP_REL8N_NAME, } from './app-constants.mjs';
|
|
8
9
|
import { IbGibAppAny } from './app-base-v1.mjs';
|
|
9
10
|
// import { CommonService } from '../../services/common.service.mjs';
|
|
10
11
|
// import { getFn_promptAppIbGib } from './prompt-functions.mjs';
|
|
@@ -26,7 +26,7 @@ import { CommentIbGib_V1 } from '../../common/comment/comment-types.mjs';
|
|
|
26
26
|
import { PicIbGib_V1 } from '../../common/pic/pic-types.mjs';
|
|
27
27
|
import { getInteractionIbGib_V1, validateCommonRobbotData } from './robbot-helper.mjs';
|
|
28
28
|
import { argy_, isArg, resulty_ } from '../witness-helper.mjs';
|
|
29
|
-
import { IbGibLocalSpaceService_AllPowerful
|
|
29
|
+
import { IbGibLocalSpaceService_AllPowerful } from '../../core-types.mjs';
|
|
30
30
|
import { validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
31
31
|
import { ErrorIbGib_V1 } from '../../common/error/error-types.mjs';
|
|
32
32
|
import { Lex, clone, delay, getTimestamp, getUUID, pretty } from '@ibgib/helper-gib';
|
|
@@ -115,7 +115,7 @@ export abstract class RobbotBase_V1<
|
|
|
115
115
|
* Reference to the local ibgibs service, which is one way at getting at the
|
|
116
116
|
* local user space.
|
|
117
117
|
*/
|
|
118
|
-
public ibgibsSvc:
|
|
118
|
+
public ibgibsSvc: IbGibLocalSpaceService_AllPowerful | undefined;
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* When the robbot has to get some ibgibs, might as well store them here so
|
|
@@ -195,7 +195,7 @@ export abstract class RobbotBase_V1<
|
|
|
195
195
|
* the single `witness` access point, but of course these runtime aspects
|
|
196
196
|
* won't be memoized if storing the ibgib.
|
|
197
197
|
*/
|
|
198
|
-
public initialized: Promise<void>;
|
|
198
|
+
// public initialized: Promise<void>;
|
|
199
199
|
|
|
200
200
|
constructor(initialData?: TData, initialRel8ns?: TRel8ns) {
|
|
201
201
|
super(initialData, initialRel8ns);
|
|
@@ -331,7 +331,10 @@ export abstract class RobbotBase_V1<
|
|
|
331
331
|
|
|
332
332
|
await this.loadNewerSelfIfAvailable();
|
|
333
333
|
|
|
334
|
-
|
|
334
|
+
let result = await this.routeAndDoArg({ arg });
|
|
335
|
+
if (!result) { result = await this.doDefault({ ibGib: arg }); }
|
|
336
|
+
if (!result) { console.warn(`${lc} result falsy...Could not produce result? Was doDefault implemented in concrete class? (W: 67f5fc5e6e864a13b0053fb54cfba100)`); }
|
|
337
|
+
return result;
|
|
335
338
|
} catch (error) {
|
|
336
339
|
console.error(`${lc} ${error.message}`);
|
|
337
340
|
throw error;
|
|
@@ -639,7 +642,7 @@ export abstract class RobbotBase_V1<
|
|
|
639
642
|
/**
|
|
640
643
|
* If provided, will register the newly created ibgib.
|
|
641
644
|
*/
|
|
642
|
-
ibgibsSvc?:
|
|
645
|
+
ibgibsSvc?: IbGibLocalSpaceService_AllPowerful,
|
|
643
646
|
// /**
|
|
644
647
|
// * If given (which atow is most likely the case), then the {@link TransformResult} will
|
|
645
648
|
// * be persisted in this `space`.
|
|
@@ -882,7 +885,7 @@ export abstract class RobbotBase_V1<
|
|
|
882
885
|
}: {
|
|
883
886
|
text: string,
|
|
884
887
|
contextIbGib: IbGib_V1,
|
|
885
|
-
ibgibsSvc?:
|
|
888
|
+
ibgibsSvc?: IbGibLocalSpaceService_AllPowerful,
|
|
886
889
|
}): Promise<void> {
|
|
887
890
|
const lc = `${this.lc}[${this.createCommentAndRel8ToContextIbGib.name}]`;
|
|
888
891
|
try {
|