@ibgib/core-gib 0.0.4
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/.vscode/core-gib-snippets.code-snippets +189 -0
- package/.vscode/launch.json +24 -0
- package/.vscode/settings.json +56 -0
- package/.vscode/tasks.json +37 -0
- package/CHANGELOG.md +11 -0
- package/README.md +215 -0
- package/dist/common/aws-constants.d.mts +7 -0
- package/dist/common/aws-constants.d.mts.map +1 -0
- package/dist/common/aws-constants.mjs +7 -0
- package/dist/common/aws-constants.mjs.map +1 -0
- package/dist/common/bin/bin-types.d.mts +17 -0
- package/dist/common/bin/bin-types.d.mts.map +1 -0
- package/dist/common/bin/bin-types.mjs +3 -0
- package/dist/common/bin/bin-types.mjs.map +1 -0
- package/dist/common/cache/cache-types.d.mts +57 -0
- package/dist/common/cache/cache-types.d.mts.map +1 -0
- package/dist/common/cache/cache-types.mjs +2 -0
- package/dist/common/cache/cache-types.mjs.map +1 -0
- package/dist/common/comment/comment-constants.d.mts +11 -0
- package/dist/common/comment/comment-constants.d.mts.map +1 -0
- package/dist/common/comment/comment-constants.mjs +11 -0
- package/dist/common/comment/comment-constants.mjs.map +1 -0
- package/dist/common/comment/comment-helper.d.mts +59 -0
- package/dist/common/comment/comment-helper.d.mts.map +1 -0
- package/dist/common/comment/comment-helper.mjs +173 -0
- package/dist/common/comment/comment-helper.mjs.map +1 -0
- package/dist/common/comment/comment-types.d.mts +16 -0
- package/dist/common/comment/comment-types.d.mts.map +1 -0
- package/dist/common/comment/comment-types.mjs +2 -0
- package/dist/common/comment/comment-types.mjs.map +1 -0
- package/dist/common/display/display-helper.d.mts +19 -0
- package/dist/common/display/display-helper.d.mts.map +1 -0
- package/dist/common/display/display-helper.mjs +68 -0
- package/dist/common/display/display-helper.mjs.map +1 -0
- package/dist/common/display/display-types.d.mts +97 -0
- package/dist/common/display/display-types.d.mts.map +1 -0
- package/dist/common/display/display-types.mjs +37 -0
- package/dist/common/display/display-types.mjs.map +1 -0
- package/dist/common/encrypt/encrypt-constants.d.mts +27 -0
- package/dist/common/encrypt/encrypt-constants.d.mts.map +1 -0
- package/dist/common/encrypt/encrypt-constants.mjs +27 -0
- package/dist/common/encrypt/encrypt-constants.mjs.map +1 -0
- package/dist/common/encrypt/encrypt-types.d.mts +116 -0
- package/dist/common/encrypt/encrypt-types.d.mts.map +1 -0
- package/dist/common/encrypt/encrypt-types.mjs +9 -0
- package/dist/common/encrypt/encrypt-types.mjs.map +1 -0
- package/dist/common/error/error-constants.d.mts +9 -0
- package/dist/common/error/error-constants.d.mts.map +1 -0
- package/dist/common/error/error-constants.mjs +9 -0
- package/dist/common/error/error-constants.mjs.map +1 -0
- package/dist/common/error/error-helper.d.mts +43 -0
- package/dist/common/error/error-helper.d.mts.map +1 -0
- package/dist/common/error/error-helper.mjs +167 -0
- package/dist/common/error/error-helper.mjs.map +1 -0
- package/dist/common/error/error-types.d.mts +58 -0
- package/dist/common/error/error-types.d.mts.map +1 -0
- package/dist/common/error/error-types.mjs +2 -0
- package/dist/common/error/error-types.mjs.map +1 -0
- package/dist/common/form/form-helper.d.mts +97 -0
- package/dist/common/form/form-helper.d.mts.map +1 -0
- package/dist/common/form/form-helper.mjs +185 -0
- package/dist/common/form/form-helper.mjs.map +1 -0
- package/dist/common/form/form-items.d.mts +229 -0
- package/dist/common/form/form-items.d.mts.map +1 -0
- package/dist/common/form/form-items.mjs +63 -0
- package/dist/common/form/form-items.mjs.map +1 -0
- package/dist/common/import-export/import-export-types.d.mts +18 -0
- package/dist/common/import-export/import-export-types.d.mts.map +1 -0
- package/dist/common/import-export/import-export-types.mjs +2 -0
- package/dist/common/import-export/import-export-types.mjs.map +1 -0
- package/dist/common/legacy/legacy-types.d.mts +2 -0
- package/dist/common/legacy/legacy-types.d.mts.map +1 -0
- package/dist/common/legacy/legacy-types.mjs +2 -0
- package/dist/common/legacy/legacy-types.mjs.map +1 -0
- package/dist/common/link/link-constants.d.mts +2 -0
- package/dist/common/link/link-constants.d.mts.map +1 -0
- package/dist/common/link/link-constants.mjs +2 -0
- package/dist/common/link/link-constants.mjs.map +1 -0
- package/dist/common/link/link-helper.d.mts +37 -0
- package/dist/common/link/link-helper.d.mts.map +1 -0
- package/dist/common/link/link-helper.mjs +143 -0
- package/dist/common/link/link-helper.mjs.map +1 -0
- package/dist/common/link/link-types.d.mts +14 -0
- package/dist/common/link/link-types.d.mts.map +1 -0
- package/dist/common/link/link-types.mjs +2 -0
- package/dist/common/link/link-types.mjs.map +1 -0
- package/dist/common/other/graph-helper.d.mts +166 -0
- package/dist/common/other/graph-helper.d.mts.map +1 -0
- package/dist/common/other/graph-helper.mjs +710 -0
- package/dist/common/other/graph-helper.mjs.map +1 -0
- package/dist/common/other/ibgib-helper.d.mts +245 -0
- package/dist/common/other/ibgib-helper.d.mts.map +1 -0
- package/dist/common/other/ibgib-helper.mjs +641 -0
- package/dist/common/other/ibgib-helper.mjs.map +1 -0
- package/dist/common/other/other-constants.d.mts +53 -0
- package/dist/common/other/other-constants.d.mts.map +1 -0
- package/dist/common/other/other-constants.mjs +67 -0
- package/dist/common/other/other-constants.mjs.map +1 -0
- package/dist/common/other/other-types.d.mts +166 -0
- package/dist/common/other/other-types.d.mts.map +1 -0
- package/dist/common/other/other-types.mjs +30 -0
- package/dist/common/other/other-types.mjs.map +1 -0
- package/dist/common/other/svg-constants.d.mts +2 -0
- package/dist/common/other/svg-constants.d.mts.map +1 -0
- package/dist/common/other/svg-constants.mjs +2 -0
- package/dist/common/other/svg-constants.mjs.map +1 -0
- package/dist/common/other/svg-helper.d.mts +54 -0
- package/dist/common/other/svg-helper.d.mts.map +1 -0
- package/dist/common/other/svg-helper.mjs +170 -0
- package/dist/common/other/svg-helper.mjs.map +1 -0
- package/dist/common/pic/pic-constants.d.mts +13 -0
- package/dist/common/pic/pic-constants.d.mts.map +1 -0
- package/dist/common/pic/pic-constants.mjs +13 -0
- package/dist/common/pic/pic-constants.mjs.map +1 -0
- package/dist/common/pic/pic-helper.d.mts +70 -0
- package/dist/common/pic/pic-helper.d.mts.map +1 -0
- package/dist/common/pic/pic-helper.mjs +235 -0
- package/dist/common/pic/pic-helper.mjs.map +1 -0
- package/dist/common/pic/pic-types.d.mts +23 -0
- package/dist/common/pic/pic-types.d.mts.map +1 -0
- package/dist/common/pic/pic-types.mjs +2 -0
- package/dist/common/pic/pic-types.mjs.map +1 -0
- package/dist/common/root/root-constants.d.mts +40 -0
- package/dist/common/root/root-constants.d.mts.map +1 -0
- package/dist/common/root/root-constants.mjs +40 -0
- package/dist/common/root/root-constants.mjs.map +1 -0
- package/dist/common/root/root-types.d.mts +9 -0
- package/dist/common/root/root-types.d.mts.map +1 -0
- package/dist/common/root/root-types.mjs +2 -0
- package/dist/common/root/root-types.mjs.map +1 -0
- package/dist/common/tag/tag-constants.d.mts +21 -0
- package/dist/common/tag/tag-constants.d.mts.map +1 -0
- package/dist/common/tag/tag-constants.mjs +28 -0
- package/dist/common/tag/tag-constants.mjs.map +1 -0
- package/dist/common/tag/tag-types.d.mts +14 -0
- package/dist/common/tag/tag-types.d.mts.map +1 -0
- package/dist/common/tag/tag-types.mjs +2 -0
- package/dist/common/tag/tag-types.mjs.map +1 -0
- package/dist/core-constants.d.mts +89 -0
- package/dist/core-constants.d.mts.map +1 -0
- package/dist/core-constants.mjs +484 -0
- package/dist/core-constants.mjs.map +1 -0
- package/dist/core-helper.d.mts +6 -0
- package/dist/core-helper.d.mts.map +1 -0
- package/dist/core-helper.mjs +28 -0
- package/dist/core-helper.mjs.map +1 -0
- package/dist/core-types.d.mts +520 -0
- package/dist/core-types.d.mts.map +1 -0
- package/dist/core-types.mjs +2 -0
- package/dist/core-types.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/dist/witness/app/app-base-v1.d.mts +130 -0
- package/dist/witness/app/app-base-v1.d.mts.map +1 -0
- package/dist/witness/app/app-base-v1.mjs +462 -0
- package/dist/witness/app/app-base-v1.mjs.map +1 -0
- package/dist/witness/app/app-constants.d.mts +10 -0
- package/dist/witness/app/app-constants.d.mts.map +1 -0
- package/dist/witness/app/app-constants.mjs +13 -0
- package/dist/witness/app/app-constants.mjs.map +1 -0
- package/dist/witness/app/app-helper.d.mts +85 -0
- package/dist/witness/app/app-helper.d.mts.map +1 -0
- package/dist/witness/app/app-helper.mjs +258 -0
- package/dist/witness/app/app-helper.mjs.map +1 -0
- package/dist/witness/app/app-types.d.mts +211 -0
- package/dist/witness/app/app-types.d.mts.map +1 -0
- package/dist/witness/app/app-types.mjs +49 -0
- package/dist/witness/app/app-types.mjs.map +1 -0
- package/dist/witness/app/chat-app/chat-app-types.d.mts +18 -0
- package/dist/witness/app/chat-app/chat-app-types.d.mts.map +1 -0
- package/dist/witness/app/chat-app/chat-app-types.mjs +25 -0
- package/dist/witness/app/chat-app/chat-app-types.mjs.map +1 -0
- package/dist/witness/app/flash-app/flash-app-types.d.mts +16 -0
- package/dist/witness/app/flash-app/flash-app-types.d.mts.map +1 -0
- package/dist/witness/app/flash-app/flash-app-types.mjs +23 -0
- package/dist/witness/app/flash-app/flash-app-types.mjs.map +1 -0
- package/dist/witness/app/raw-app/raw-app-types.d.mts +18 -0
- package/dist/witness/app/raw-app/raw-app-types.d.mts.map +1 -0
- package/dist/witness/app/raw-app/raw-app-types.mjs +25 -0
- package/dist/witness/app/raw-app/raw-app-types.mjs.map +1 -0
- package/dist/witness/app/todo-app/todo-app-types.d.ts +33 -0
- package/dist/witness/app/todo-app/todo-app-types.d.ts.map +1 -0
- package/dist/witness/app/todo-app/todo-app-types.js +31 -0
- package/dist/witness/app/todo-app/todo-app-types.js.map +1 -0
- package/dist/witness/robbot/robbot-base-v1.d.ts +432 -0
- package/dist/witness/robbot/robbot-base-v1.d.ts.map +1 -0
- package/dist/witness/robbot/robbot-base-v1.js +1407 -0
- package/dist/witness/robbot/robbot-base-v1.js.map +1 -0
- package/dist/witness/robbot/robbot-constants.d.mts +24 -0
- package/dist/witness/robbot/robbot-constants.d.mts.map +1 -0
- package/dist/witness/robbot/robbot-constants.mjs +24 -0
- package/dist/witness/robbot/robbot-constants.mjs.map +1 -0
- package/dist/witness/robbot/robbot-helper.d.mts +152 -0
- package/dist/witness/robbot/robbot-helper.d.mts.map +1 -0
- package/dist/witness/robbot/robbot-helper.mjs +609 -0
- package/dist/witness/robbot/robbot-helper.mjs.map +1 -0
- package/dist/witness/robbot/robbot-types.d.mts +539 -0
- package/dist/witness/robbot/robbot-types.d.mts.map +1 -0
- package/dist/witness/robbot/robbot-types.mjs +294 -0
- package/dist/witness/robbot/robbot-types.mjs.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-constants.d.mts +14 -0
- package/dist/witness/space/bootstrap/bootstrap-constants.d.mts.map +1 -0
- package/dist/witness/space/bootstrap/bootstrap-constants.mjs +15 -0
- package/dist/witness/space/bootstrap/bootstrap-constants.mjs.map +1 -0
- package/dist/witness/space/inner-space-v1.d.ts +63 -0
- package/dist/witness/space/inner-space-v1.d.ts.map +1 -0
- package/dist/witness/space/inner-space-v1.js +356 -0
- package/dist/witness/space/inner-space-v1.js.map +1 -0
- package/dist/witness/space/outer-space/outer-space-constants.d.mts +2 -0
- package/dist/witness/space/outer-space/outer-space-constants.d.mts.map +1 -0
- package/dist/witness/space/outer-space/outer-space-constants.mjs +2 -0
- package/dist/witness/space/outer-space/outer-space-constants.mjs.map +1 -0
- package/dist/witness/space/outer-space/outer-space-helper.d.mts +28 -0
- package/dist/witness/space/outer-space/outer-space-helper.d.mts.map +1 -0
- package/dist/witness/space/outer-space/outer-space-helper.mjs +87 -0
- package/dist/witness/space/outer-space/outer-space-helper.mjs.map +1 -0
- package/dist/witness/space/outer-space/outer-space-types.d.mts +548 -0
- package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -0
- package/dist/witness/space/outer-space/outer-space-types.mjs +118 -0
- package/dist/witness/space/outer-space/outer-space-types.mjs.map +1 -0
- package/dist/witness/space/space-base-v1.d.mts +147 -0
- package/dist/witness/space/space-base-v1.d.mts.map +1 -0
- package/dist/witness/space/space-base-v1.mjs +350 -0
- package/dist/witness/space/space-base-v1.mjs.map +1 -0
- package/dist/witness/space/space-constants.d.mts +181 -0
- package/dist/witness/space/space-constants.d.mts.map +1 -0
- package/dist/witness/space/space-constants.mjs +192 -0
- package/dist/witness/space/space-constants.mjs.map +1 -0
- package/dist/witness/space/space-helper.d.mts +666 -0
- package/dist/witness/space/space-helper.d.mts.map +1 -0
- package/dist/witness/space/space-helper.mjs +2830 -0
- package/dist/witness/space/space-helper.mjs.map +1 -0
- package/dist/witness/space/space-types.d.mts +422 -0
- package/dist/witness/space/space-types.d.mts.map +1 -0
- package/dist/witness/space/space-types.mjs +52 -0
- package/dist/witness/space/space-types.mjs.map +1 -0
- package/dist/witness/witness-base-v1.d.ts +144 -0
- package/dist/witness/witness-base-v1.d.ts.map +1 -0
- package/dist/witness/witness-base-v1.js +300 -0
- package/dist/witness/witness-base-v1.js.map +1 -0
- package/dist/witness/witness-constants.d.mts +3 -0
- package/dist/witness/witness-constants.d.mts.map +1 -0
- package/dist/witness/witness-constants.mjs +3 -0
- package/dist/witness/witness-constants.mjs.map +1 -0
- package/dist/witness/witness-form-builder.d.mts +45 -0
- package/dist/witness/witness-form-builder.d.mts.map +1 -0
- package/dist/witness/witness-form-builder.mjs +95 -0
- package/dist/witness/witness-form-builder.mjs.map +1 -0
- package/dist/witness/witness-helper.d.mts +89 -0
- package/dist/witness/witness-helper.d.mts.map +1 -0
- package/dist/witness/witness-helper.mjs +229 -0
- package/dist/witness/witness-helper.mjs.map +1 -0
- package/dist/witness/witness-types.d.mts +211 -0
- package/dist/witness/witness-types.d.mts.map +1 -0
- package/dist/witness/witness-types.mjs +2 -0
- package/dist/witness/witness-types.mjs.map +1 -0
- package/jasmine-browser.json +18 -0
- package/jasmine.json +6 -0
- package/package.json +67 -0
- package/src/assumptions.spec.mts +45 -0
- package/src/common/aws-constants.mts +5 -0
- package/src/common/bin/bin-types.mts +17 -0
- package/src/common/cache/cache-types.mts +53 -0
- package/src/common/comment/comment-constants.mts +10 -0
- package/src/common/comment/comment-helper.mts +211 -0
- package/src/common/comment/comment-types.mts +19 -0
- package/src/common/display/display-helper.mts +88 -0
- package/src/common/display/display-types.mts +108 -0
- package/src/common/encrypt/encrypt-constants.mts +28 -0
- package/src/common/encrypt/encrypt-types.mts +130 -0
- package/src/common/error/error-constants.mts +8 -0
- package/src/common/error/error-helper.mts +155 -0
- package/src/common/error/error-types.mts +62 -0
- package/src/common/form/form-helper.mts +253 -0
- package/src/common/form/form-items.mts +236 -0
- package/src/common/import-export/import-export-types.mts +18 -0
- package/src/common/legacy/about-legacy.md +0 -0
- package/src/common/legacy/legacy-types.mts +0 -0
- package/src/common/link/link-constants.mts +1 -0
- package/src/common/link/link-helper.mts +155 -0
- package/src/common/link/link-types.mts +16 -0
- package/src/common/other/graph-helper.mts +853 -0
- package/src/common/other/ibgib-helper.mts +671 -0
- package/src/common/other/other-constants.mts +76 -0
- package/src/common/other/other-types.mts +186 -0
- package/src/common/other/svg-constants.mts +1 -0
- package/src/common/other/svg-helper.mts +238 -0
- package/src/common/pic/pic-constants.mts +13 -0
- package/src/common/pic/pic-helper.mts +295 -0
- package/src/common/pic/pic-types.mts +29 -0
- package/src/common/root/root-constants.mts +41 -0
- package/src/common/root/root-types.mts +8 -0
- package/src/common/tag/tag-constants.mts +34 -0
- package/src/common/tag/tag-types.mts +19 -0
- package/src/core-constants.mts +506 -0
- package/src/core-helper.mts +33 -0
- package/src/core-types.mts +519 -0
- package/src/helper.spec.mts +64 -0
- package/src/index.mts +1 -0
- package/src/witness/app/app-base-v1.mts +584 -0
- package/src/witness/app/app-constants.mts +16 -0
- package/src/witness/app/app-helper.mts +322 -0
- package/src/witness/app/app-types.mts +252 -0
- package/src/witness/app/chat-app/chat-app-types.mts +40 -0
- package/src/witness/app/flash-app/flash-app-types.mts +38 -0
- package/src/witness/app/raw-app/raw-app-types.mts +40 -0
- package/src/witness/app/todo-app/todo-app-types.ts +59 -0
- package/src/witness/robbot/robbot-base-v1.ts +1531 -0
- package/src/witness/robbot/robbot-constants.mts +25 -0
- package/src/witness/robbot/robbot-helper.mts +676 -0
- package/src/witness/robbot/robbot-helper.spec.mts +135 -0
- package/src/witness/robbot/robbot-types.mts +797 -0
- package/src/witness/space/bootstrap/bootstrap-constants.mts +15 -0
- package/src/witness/space/inner-space-v1.ts +372 -0
- package/src/witness/space/outer-space/outer-space-constants.mts +1 -0
- package/src/witness/space/outer-space/outer-space-helper.mts +91 -0
- package/src/witness/space/outer-space/outer-space-types.mts +627 -0
- package/src/witness/space/space-base-v1.mts +414 -0
- package/src/witness/space/space-constants.mts +208 -0
- package/src/witness/space/space-helper.mts +3242 -0
- package/src/witness/space/space-types.mts +476 -0
- package/src/witness/witness-base-v1.ts +325 -0
- package/src/witness/witness-constants.mts +2 -0
- package/src/witness/witness-form-builder.mts +128 -0
- package/src/witness/witness-helper.mts +256 -0
- package/src/witness/witness-types.mts +249 -0
- package/tsconfig.json +15 -0
- package/tsconfig.test.json +10 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import * as h from '@ibgib/helper-gib';
|
|
2
|
+
import { getIbGibAddr, IbGibRel8ns } from '@ibgib/ts-gib';
|
|
3
|
+
import { IbGib_V1, IbGibRel8ns_V1, sha256v1, } from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
4
|
+
import { getGibInfo } from '@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import { WitnessData_V1, WitnessRel8ns_V1, Witness_V1, } from './witness-types.mjs';
|
|
8
|
+
import { validateGib, validateIb, validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
9
|
+
import { ErrorIbGib_V1 } from '../common/error/error-types.mjs';
|
|
10
|
+
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
11
|
+
import { GLOBAL_LOG_A_LOT } from '../core-constants.mjs';
|
|
12
|
+
|
|
13
|
+
const logalot = GLOBAL_LOG_A_LOT || false;
|
|
14
|
+
|
|
15
|
+
export abstract class WitnessBase_V1<
|
|
16
|
+
TOptionsData extends any,
|
|
17
|
+
TOptionsRel8ns extends IbGibRel8ns_V1,
|
|
18
|
+
TOptionsIbGib extends IbGib_V1<TOptionsData, TOptionsRel8ns>,
|
|
19
|
+
TResultData extends any,
|
|
20
|
+
TResultRel8ns extends IbGibRel8ns_V1,
|
|
21
|
+
TResultIbGib extends IbGib_V1<TResultData, TResultRel8ns> | ErrorIbGib_V1,
|
|
22
|
+
TData extends WitnessData_V1 = any,
|
|
23
|
+
TRel8ns extends IbGibRel8ns_V1 = IbGibRel8ns_V1
|
|
24
|
+
>
|
|
25
|
+
implements Witness_V1<
|
|
26
|
+
TOptionsData, TOptionsRel8ns, TOptionsIbGib, // options arg
|
|
27
|
+
TResultData, TResultRel8ns, TResultIbGib, // result
|
|
28
|
+
TData, TRel8ns // this witness itself
|
|
29
|
+
> {
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Log context for convenience with logging. (Ignore if you don't want to use this.)
|
|
33
|
+
*/
|
|
34
|
+
protected lc: string = `[${WitnessBase_V1.name}]`;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Optional arg for verbose logging.
|
|
38
|
+
*/
|
|
39
|
+
protected set trace(value: boolean) {
|
|
40
|
+
const lc = `${this.lc}[set trace]`;
|
|
41
|
+
if (value === (this.data?.trace || false)) { return; }
|
|
42
|
+
if (this.data) {
|
|
43
|
+
this.data.trace = value;
|
|
44
|
+
delete this.gib; // gib is invalid now
|
|
45
|
+
} else {
|
|
46
|
+
console.warn(`${lc} data is falsy. Can't set.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
protected get trace(): boolean { return this.data?.trace ?? false; }
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Optional configuration for `witness` call.
|
|
53
|
+
* If true, then this space will catch any error that propagates up
|
|
54
|
+
* from the `witnessImpl` function.
|
|
55
|
+
*
|
|
56
|
+
* ## notes
|
|
57
|
+
*
|
|
58
|
+
* Descendants of Witness who don't override the base `witness` function
|
|
59
|
+
* (but rather override `witnessImpl` as expected) don't need to check
|
|
60
|
+
* for this explicitly, since it is referenced in the base `witness`
|
|
61
|
+
* function implementation.
|
|
62
|
+
*/
|
|
63
|
+
protected set catchAllErrors(value: boolean) {
|
|
64
|
+
const lc = `${this.lc}[set catchAllErrors]`;
|
|
65
|
+
if (value === this.data?.catchAllErrors) { return; }
|
|
66
|
+
if (this.data) {
|
|
67
|
+
this.data.catchAllErrors = value;
|
|
68
|
+
delete this.gib;
|
|
69
|
+
} else {
|
|
70
|
+
console.error(`${lc} data is falsy. Can't set value.`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
protected get catchAllErrors(): boolean {
|
|
74
|
+
const lc = `${this.lc}[catchAllErrors]`;
|
|
75
|
+
const result = this.data?.catchAllErrors || false;
|
|
76
|
+
if (logalot || this.trace) { console.log(`${lc} result: ${result}`) }
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// #region IbGib interface fields: ib, gib, data, rel8ns
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Used per use case in implementing class.
|
|
84
|
+
*
|
|
85
|
+
* This property is a simple property (no getter/setter with backing
|
|
86
|
+
* fields). This is to simplify usage with DTOs (Data Transfer Objects) for
|
|
87
|
+
* storing in spaces.
|
|
88
|
+
*/
|
|
89
|
+
ib: string = '';
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Used per use case in implementing class.
|
|
93
|
+
*
|
|
94
|
+
* This property is a simple property (no getter/setter with backing
|
|
95
|
+
* fields). This is to simplify usage with DTOs (Data Transfer Objects) for
|
|
96
|
+
* storing in spaces.
|
|
97
|
+
*/
|
|
98
|
+
gib: string | undefined;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Used per use case in implementing class.
|
|
102
|
+
*
|
|
103
|
+
* This property is a simple property (no getter/setter with backing
|
|
104
|
+
* fields). This is to simplify usage with DTOs (Data Transfer Objects) for
|
|
105
|
+
* storing in spaces.
|
|
106
|
+
*/
|
|
107
|
+
data: TData | undefined;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Used per use case in implementing class.
|
|
111
|
+
*
|
|
112
|
+
* This property is a simple property (no getter/setter with backing
|
|
113
|
+
* fields). This is to simplify usage with DTOs (Data Transfer Objects) for
|
|
114
|
+
* storing in spaces.
|
|
115
|
+
*/
|
|
116
|
+
rel8ns: TRel8ns | undefined;
|
|
117
|
+
|
|
118
|
+
// #endregion IbGib interface fields: ib, gib, data, rel8ns
|
|
119
|
+
|
|
120
|
+
constructor(initialData?: TData, initialRel8ns?: TRel8ns) {
|
|
121
|
+
if (initialData) { this.data = initialData; }
|
|
122
|
+
if (initialRel8ns) { this.rel8ns = initialRel8ns; }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Creates a data transfer object (dto) snapshot out of this
|
|
127
|
+
* witness' `ib`, `gib`, `data` and `rel8ns` properties.
|
|
128
|
+
*
|
|
129
|
+
* I say "snapshot" because this copies each property
|
|
130
|
+
* (`ib`, `gib`, `data`, `rel8ns`).
|
|
131
|
+
*
|
|
132
|
+
* ## thoughts
|
|
133
|
+
*
|
|
134
|
+
* Witness classes need to be able to persist their ibgib
|
|
135
|
+
* just as regular data. But witnesses have the additional
|
|
136
|
+
* layer of behavior (e.g. the `witness` function) that
|
|
137
|
+
* will not persist (until we get more integrated version control
|
|
138
|
+
* types of functionality in ibgib).
|
|
139
|
+
*
|
|
140
|
+
* @returns dto ibgib object with just clones of this.ib/gib/data/rel8ns props.
|
|
141
|
+
*
|
|
142
|
+
* @see {loadIbGibDto}
|
|
143
|
+
*/
|
|
144
|
+
toIbGibDto(): IbGib_V1<TData, TRel8ns> {
|
|
145
|
+
return toDto({ ibGib: this });
|
|
146
|
+
// const lc = `${this.lc}[${this.toIbGibDto.name}]`;
|
|
147
|
+
// if (!this.ib) { console.warn(`${lc} this.ib is falsy. (W: 60162e3ab42941e9a68cd6adc8d23387)`); }
|
|
148
|
+
// if (!this.gib) { console.warn(`${lc} this.gib is falsy. (W: 61dc535639dc410d874635013fce5b8a)`); }
|
|
149
|
+
|
|
150
|
+
// let dtoIbGib: IbGib_V1<TData, TRel8ns> = { ib: (this.ib || '').slice() };
|
|
151
|
+
// if (this.gib) { dtoIbGib.gib = this.gib.slice(); };
|
|
152
|
+
// if (this.data) { dtoIbGib.data = h.clone(this.data); }
|
|
153
|
+
// if (this.rel8ns) { dtoIbGib.rel8ns = h.clone(this.rel8ns); }
|
|
154
|
+
|
|
155
|
+
// return dtoIbGib;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* (Re)hydrates this witness class with the ibgib information from the dto.
|
|
160
|
+
*
|
|
161
|
+
* ## notes
|
|
162
|
+
*
|
|
163
|
+
* * You can extend this function for witness-specific behavior when loading.
|
|
164
|
+
*
|
|
165
|
+
* @param dto ib, gib, data & rel8ns to load for this witness ibgib instance.
|
|
166
|
+
*
|
|
167
|
+
* @see {toIbGibDto}
|
|
168
|
+
*/
|
|
169
|
+
loadIbGibDto(dto: IbGib_V1<TData, TRel8ns>): Promise<void> {
|
|
170
|
+
const lc = `${this.lc}[${this.loadIbGibDto.name}]`;
|
|
171
|
+
try {
|
|
172
|
+
if (logalot) { console.log(`${lc} starting...`); }
|
|
173
|
+
|
|
174
|
+
if (!dto.ib) { console.warn(`${lc} dto.ib is falsy.`); }
|
|
175
|
+
if (!dto.gib) { console.warn(`${lc} dto.gib is falsy.`); }
|
|
176
|
+
|
|
177
|
+
this.ib = h.clone(dto.ib);
|
|
178
|
+
this.gib = h.clone(dto.gib);
|
|
179
|
+
if (dto.data) {
|
|
180
|
+
this.data = h.clone(dto.data);
|
|
181
|
+
} else {
|
|
182
|
+
delete this.data;
|
|
183
|
+
}
|
|
184
|
+
if (dto.rel8ns) { this.rel8ns = h.clone(dto.rel8ns); } else { delete this.rel8ns; }
|
|
185
|
+
|
|
186
|
+
return Promise.resolve();
|
|
187
|
+
} catch (error) {
|
|
188
|
+
console.error(`${lc} ${error.message}`);
|
|
189
|
+
throw error;
|
|
190
|
+
} finally {
|
|
191
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The primary function of a witness is...well... to witness things.
|
|
197
|
+
*
|
|
198
|
+
* So this is the base implementation that includes validation
|
|
199
|
+
* plumbing, tracing, error checking/catching - all depending
|
|
200
|
+
* on witness configuration.
|
|
201
|
+
*
|
|
202
|
+
*
|
|
203
|
+
* ## usage
|
|
204
|
+
*
|
|
205
|
+
* Only override this function if you really want custom handling of
|
|
206
|
+
* the plumbing. Instead override `witnessImpl`.
|
|
207
|
+
*
|
|
208
|
+
* {@see validateThis}
|
|
209
|
+
* {@see validateWitnessArg}
|
|
210
|
+
*
|
|
211
|
+
* @param arg
|
|
212
|
+
* @returns
|
|
213
|
+
*/
|
|
214
|
+
async witness(arg: TOptionsIbGib): Promise<TResultIbGib | undefined> {
|
|
215
|
+
const lc = `${this.lc}[${this.witness.name}]`;
|
|
216
|
+
try {
|
|
217
|
+
if (!this.gib) { this.gib = await sha256v1(this.toIbGibDto()); }
|
|
218
|
+
const validationErrors_this = await this.validateThis();
|
|
219
|
+
if (validationErrors_this?.length > 0) {
|
|
220
|
+
for (const error of validationErrors_this) { console.error(`${lc} ${error}`); }
|
|
221
|
+
throw new Error(`internal witness validation failed. See \`WitnessBase_V1.validateThis\` (E: 2b5f73cadbfa416ba189346f3c31cd0c)`);
|
|
222
|
+
}
|
|
223
|
+
const validationErrors_arg = await this.validateWitnessArg(arg);
|
|
224
|
+
if (validationErrors_arg?.length > 0) {
|
|
225
|
+
for (const error of validationErrors_arg) { console.error(`${lc} ${error}`); }
|
|
226
|
+
debugger;
|
|
227
|
+
throw new Error(`arg validation failed. See \`WitnessBase_V1.validateWitnessArg\` (E: 51531a1d928a485e8ffc277145ec44e9)`);
|
|
228
|
+
}
|
|
229
|
+
if (logalot || this.trace) { console.log(`${lc} addr: ${getIbGibAddr(arg)}`); }
|
|
230
|
+
if (logalot) { console.log(`${lc} addr: ${getIbGibAddr(arg)} (I: f4cf13a44c4e4fc3903f14018e616c64)`); }
|
|
231
|
+
const result = await this.witnessImpl(arg);
|
|
232
|
+
|
|
233
|
+
// persist the arg and result if we're configured to do so it is up
|
|
234
|
+
// to the implementation whether or not to throw on this.
|
|
235
|
+
if (this.data?.persistOptsAndResultIbGibs) {
|
|
236
|
+
await this.persistOptsAndResultIbGibs({ arg, result });
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return result;
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.error(`${lc} ${error.message || 'unknown error (E: 3e22bea4c7fb4668bf13d7146b927869)'}`);
|
|
242
|
+
if (!this.catchAllErrors) {
|
|
243
|
+
throw error;
|
|
244
|
+
} else {
|
|
245
|
+
return; // undefined
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
protected abstract witnessImpl(arg: TOptionsIbGib): Promise<TResultIbGib | undefined>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Validate the incoming arg.
|
|
253
|
+
*
|
|
254
|
+
* Override this in descending classes per use case.
|
|
255
|
+
*/
|
|
256
|
+
protected async validateWitnessArg(arg: TOptionsIbGib): Promise<string[]> {
|
|
257
|
+
const lc = `${this.lc}[${this.validateWitnessArg.name}]`;
|
|
258
|
+
try {
|
|
259
|
+
const errors: string[] = [];
|
|
260
|
+
if (!arg) { errors.push(`arg required (E: a222db3b668e4bb09cfd82e75c07bfa6)`); }
|
|
261
|
+
|
|
262
|
+
const ibErrors = validateIb({ ib: arg?.ib });
|
|
263
|
+
if (ibErrors?.length ?? 0 > 0) { errors.push(`invalid arg.ib (E: 2ae362ef274d4c3bb9716800f2106d28) errors: ${ibErrors!.join('\n')}`); }
|
|
264
|
+
|
|
265
|
+
const gibErrors = validateGib({ gib: arg?.gib! });
|
|
266
|
+
if (gibErrors?.length ?? 0 > 0) { errors.push(`invalid arg.gib (E: 73be275058084d768a39299337f2ce34) errors: ${gibErrors!.join('\n')}`); }
|
|
267
|
+
|
|
268
|
+
const intrinsicErrors = await validateIbGibIntrinsically({ ibGib: arg as IbGib_V1<any> });
|
|
269
|
+
if (intrinsicErrors?.length ?? 0 > 0) {
|
|
270
|
+
errors.push(`arg ibgib invalid intrinsically (E: 73be275058084d768a39299337f2ce34) errors: ${intrinsicErrors!.join('\n')}`);
|
|
271
|
+
} else if (!this.data?.allowPrimitiveArgs) {
|
|
272
|
+
// further check to see if primitive
|
|
273
|
+
const gibInfo = getGibInfo({ gib: arg.gib });
|
|
274
|
+
if (gibInfo.isPrimitive) { errors.push(`arg is primitive (i.e. gib === "gib") and witness.data.allowPrimitiveArgs is falsy. (E: d0aa3d7ad4f54b01bd0023300d15ecd9)`) }
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return errors;
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.error(`${lc} ${error.message}`);
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Validate this witness object, checking its own `data` and `rel8ns`, and
|
|
286
|
+
* possibly other state.
|
|
287
|
+
*
|
|
288
|
+
* ## notes
|
|
289
|
+
*
|
|
290
|
+
* ATOW base implementation of this just checks for non-falsy
|
|
291
|
+
* `this.ib` and `this.gib`
|
|
292
|
+
*/
|
|
293
|
+
protected async validateThis(): Promise<string[]> {
|
|
294
|
+
const lc = `${this.lc}[${this.validateThis.name}]`;
|
|
295
|
+
const errors: string[] = [];
|
|
296
|
+
try {
|
|
297
|
+
if (!this.ib) { errors.push(`this.ib is falsy.`); }
|
|
298
|
+
if (!this.gib) { errors.push(`this.gib is falsy.`); }
|
|
299
|
+
} catch (error) {
|
|
300
|
+
console.error(`${lc} ${error.message}`);
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
return errors;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Empty implementation in this base class.
|
|
308
|
+
*
|
|
309
|
+
* @see {@link WitnessData_V1.persistOptsAndResultIbGibs}
|
|
310
|
+
*/
|
|
311
|
+
protected persistOptsAndResultIbGibs({
|
|
312
|
+
arg,
|
|
313
|
+
result
|
|
314
|
+
}: {
|
|
315
|
+
arg: TOptionsIbGib,
|
|
316
|
+
result: TResultIbGib | undefined
|
|
317
|
+
}): Promise<void> {
|
|
318
|
+
const lc = `${this.lc}[${this.persistOptsAndResultIbGibs.name}]`;
|
|
319
|
+
console.warn(`${lc} not implemented in this base class. Override this in descendent class. (W: 087514e851704322a4ec8069a73ce944)`);
|
|
320
|
+
return Promise.resolve();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export type WitnessAny = WitnessBase_V1<any, IbGibRel8ns_V1, IbGib_V1, any, IbGibRel8ns, IbGib_V1, WitnessData_V1, WitnessRel8ns_V1>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { GLOBAL_LOG_A_LOT } from '../core-constants.mjs';
|
|
2
|
+
import { DynamicFormBuilder } from '../common/form/form-helper.mjs';
|
|
3
|
+
import { WitnessData_V1 } from '../witness/witness-types.mjs';
|
|
4
|
+
|
|
5
|
+
const logalot = GLOBAL_LOG_A_LOT || false;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Fluent-style builder helper class.
|
|
9
|
+
*
|
|
10
|
+
* I'm making this to share common fields' settings among witness classes.
|
|
11
|
+
*
|
|
12
|
+
* Descend from this class for sharing other commonalities.
|
|
13
|
+
*/
|
|
14
|
+
export class WitnessFormBuilder extends DynamicFormBuilder {
|
|
15
|
+
protected lc: string = `[${WitnessFormBuilder.name}]`;
|
|
16
|
+
|
|
17
|
+
allowPrimitiveArgs({
|
|
18
|
+
of,
|
|
19
|
+
required = true,
|
|
20
|
+
}: {
|
|
21
|
+
of: boolean | undefined,
|
|
22
|
+
required?: boolean,
|
|
23
|
+
}): WitnessFormBuilder {
|
|
24
|
+
this.addItem({
|
|
25
|
+
// witness.data.allowPrimitiveArgs
|
|
26
|
+
name: "allowPrimitiveArgs",
|
|
27
|
+
description: `Technical setting on if this ${this.what} accepts primitive incoming ibgibs`,
|
|
28
|
+
label: "Allow Primitive Args",
|
|
29
|
+
dataType: 'toggle',
|
|
30
|
+
value: of ?? true,
|
|
31
|
+
readonly: true,
|
|
32
|
+
required,
|
|
33
|
+
});
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
catchAllErrors({
|
|
38
|
+
of,
|
|
39
|
+
required = true,
|
|
40
|
+
}: {
|
|
41
|
+
of: boolean | undefined,
|
|
42
|
+
required?: boolean,
|
|
43
|
+
}): WitnessFormBuilder {
|
|
44
|
+
this.addItem({
|
|
45
|
+
// witness.data.catchAllErrors
|
|
46
|
+
name: "catchAllErrors",
|
|
47
|
+
description: `Technical setting on what the ${this.what} does when it encounters an internal error.`,
|
|
48
|
+
label: "Catch All Errors",
|
|
49
|
+
dataType: 'toggle',
|
|
50
|
+
value: of ?? true,
|
|
51
|
+
readonly: true,
|
|
52
|
+
required,
|
|
53
|
+
});
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
persistOptsAndResultIbGibs({
|
|
58
|
+
of,
|
|
59
|
+
required = true,
|
|
60
|
+
}: {
|
|
61
|
+
of: boolean | undefined,
|
|
62
|
+
required?: boolean,
|
|
63
|
+
}): WitnessFormBuilder {
|
|
64
|
+
this.addItem({
|
|
65
|
+
// witness.data.persistOptsAndResultIbGibs
|
|
66
|
+
name: "persistOptsAndResultIbGibs",
|
|
67
|
+
description: `Technical setting on if the ${this.what} maintains an audit trail of all of its inputs/outputs.`,
|
|
68
|
+
label: "Persist Opts and Result IbGibs",
|
|
69
|
+
dataType: 'toggle',
|
|
70
|
+
value: of ?? false,
|
|
71
|
+
readonly: true,
|
|
72
|
+
required,
|
|
73
|
+
});
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
trace({
|
|
78
|
+
of,
|
|
79
|
+
required,
|
|
80
|
+
}: {
|
|
81
|
+
of: boolean | undefined,
|
|
82
|
+
required?: boolean,
|
|
83
|
+
}): WitnessFormBuilder {
|
|
84
|
+
this.addItem({
|
|
85
|
+
// witness.data.trace
|
|
86
|
+
name: "trace",
|
|
87
|
+
description: `Technical setting on if the ${this.what}'s activity should be traced (logged to the console).`,
|
|
88
|
+
label: "Trace",
|
|
89
|
+
dataType: 'toggle',
|
|
90
|
+
value: of ?? false,
|
|
91
|
+
readonly: true,
|
|
92
|
+
required,
|
|
93
|
+
});
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Includes common witness fields.
|
|
99
|
+
*
|
|
100
|
+
* All common fields default to `true`, so set any you want to skip to
|
|
101
|
+
* `false`.
|
|
102
|
+
*
|
|
103
|
+
* @returns `this` for fluent builder
|
|
104
|
+
*/
|
|
105
|
+
commonWitnessFields({
|
|
106
|
+
data,
|
|
107
|
+
allowPrimitiveArgs = true,
|
|
108
|
+
catchAllErrors = true,
|
|
109
|
+
persistOptsAndResultIbGibs = true,
|
|
110
|
+
trace = true,
|
|
111
|
+
version = true,
|
|
112
|
+
}: {
|
|
113
|
+
data: WitnessData_V1,
|
|
114
|
+
allowPrimitiveArgs?: boolean,
|
|
115
|
+
catchAllErrors?: boolean,
|
|
116
|
+
persistOptsAndResultIbGibs?: boolean,
|
|
117
|
+
trace?: boolean,
|
|
118
|
+
version?: boolean,
|
|
119
|
+
}): WitnessFormBuilder {
|
|
120
|
+
if (allowPrimitiveArgs) { this.allowPrimitiveArgs({ of: data.allowPrimitiveArgs }); }
|
|
121
|
+
if (catchAllErrors) { this.catchAllErrors({ of: data.catchAllErrors }); }
|
|
122
|
+
if (persistOptsAndResultIbGibs) { this.persistOptsAndResultIbGibs({ of: data.persistOptsAndResultIbGibs }); }
|
|
123
|
+
if (trace) { this.trace({ of: data.trace }); }
|
|
124
|
+
if (version) { this.version({ of: data.version }); }
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
}
|