@modelprofile.com/flexharness 10.15.1 → 10.16.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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.codesandbox.js +6 -2
- package/dist_ts/classes.flexharness.d.ts +33 -0
- package/dist_ts/classes.flexharness.js +328 -45
- package/dist_ts/classes.stores.d.ts +3 -1
- package/dist_ts/classes.stores.js +59 -1
- package/dist_ts/classes.toolcatalog.d.ts +9 -1
- package/dist_ts/classes.toolcatalog.js +82 -11
- package/dist_ts/interfaces.d.ts +59 -0
- package/dist_ts/interfaces.js +9 -1
- package/dist_ts/plugins.d.ts +3 -3
- package/dist_ts/plugins.js +3 -3
- package/dist_ts/utils.json.d.ts +5 -0
- package/dist_ts/utils.json.js +35 -1
- package/dist_ts/utils.results.d.ts +21 -0
- package/dist_ts/utils.results.js +158 -0
- package/dist_ts/utils.tooloutput.d.ts +5 -2
- package/dist_ts/utils.tooloutput.js +10 -3
- package/dist_ts_stores_nosqldb/classes.nosqldbstores.d.ts +2 -1
- package/dist_ts_stores_nosqldb/classes.nosqldbstores.js +37 -4
- package/dist_ts_stores_nosqldb/classes.recordstore.d.ts +4 -3
- package/dist_ts_stores_nosqldb/classes.recordstore.js +2 -2
- package/package.json +3 -3
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.codesandbox.ts +5 -1
- package/ts/classes.flexharness.ts +382 -44
- package/ts/classes.stores.ts +66 -0
- package/ts/classes.toolcatalog.ts +87 -7
- package/ts/interfaces.ts +60 -0
- package/ts/plugins.ts +3 -0
- package/ts/utils.json.ts +30 -0
- package/ts/utils.results.ts +164 -0
- package/ts/utils.tooloutput.ts +9 -2
- package/ts_stores_nosqldb/classes.nosqldbstores.ts +39 -2
- package/ts_stores_nosqldb/classes.recordstore.ts +6 -4
|
@@ -11,16 +11,19 @@ import type {
|
|
|
11
11
|
IFlexProjectManagementWriteContext,
|
|
12
12
|
IFlexProjectionSnapshotV3,
|
|
13
13
|
IFlexProjectionStore,
|
|
14
|
+
IFlexResultStore,
|
|
14
15
|
IFlexScopeSnapshot,
|
|
15
16
|
IFlexScopeStore,
|
|
16
17
|
IFlexToolJobStoreProvider,
|
|
17
18
|
TFlexProjectionSnapshot,
|
|
18
19
|
TFlexProjectManagementRecord,
|
|
20
|
+
TJsonValue,
|
|
19
21
|
} from '../ts/interfaces.js';
|
|
20
22
|
import {
|
|
21
23
|
assertFlexPermissionSnapshot,
|
|
22
24
|
assertFlexProjectionSnapshot,
|
|
23
25
|
assertFlexScopeSnapshot,
|
|
26
|
+
assertJsonSerializable,
|
|
24
27
|
} from '../ts/utils.json.js';
|
|
25
28
|
import {
|
|
26
29
|
assertFlexProjectManagementRecord,
|
|
@@ -297,7 +300,7 @@ class NoSqlAgentEventStore implements plugins.IAgentEventStoreV2 {
|
|
|
297
300
|
domain: 'agentEventArchive' as const,
|
|
298
301
|
storageKey: this.storageKey,
|
|
299
302
|
sessionId: this.sessionId,
|
|
300
|
-
|
|
303
|
+
entryId: archive.archiveId,
|
|
301
304
|
};
|
|
302
305
|
await this.records.mutate(address, {
|
|
303
306
|
validate: (value) => validateAgentEventArchive(value, this.sessionId, archive.archiveId),
|
|
@@ -318,7 +321,7 @@ class NoSqlAgentEventStore implements plugins.IAgentEventStoreV2 {
|
|
|
318
321
|
this.assertSession(sessionId);
|
|
319
322
|
validateIdentifier(archiveId, 'archiveId');
|
|
320
323
|
return this.records.read(
|
|
321
|
-
{ domain: 'agentEventArchive', storageKey: this.storageKey, sessionId, archiveId },
|
|
324
|
+
{ domain: 'agentEventArchive', storageKey: this.storageKey, sessionId, entryId: archiveId },
|
|
322
325
|
(value) => validateAgentEventArchive(value, this.sessionId, archiveId),
|
|
323
326
|
);
|
|
324
327
|
}
|
|
@@ -428,6 +431,38 @@ export interface INoSqlFlexHarnessStoresOptions {
|
|
|
428
431
|
operationTimeoutMs?: number;
|
|
429
432
|
}
|
|
430
433
|
|
|
434
|
+
class NoSqlResultStore implements IFlexResultStore {
|
|
435
|
+
constructor(private readonly records: FlexRecordStore) {}
|
|
436
|
+
|
|
437
|
+
public async save(storageKey: string, sessionId: string, handle: string, value: TJsonValue): Promise<void> {
|
|
438
|
+
validateIdentifier(handle, 'handle');
|
|
439
|
+
assertJsonSerializable(value);
|
|
440
|
+
const conflict = () => new FlexHarnessStoreConflictError(`${providerKey(storageKey, sessionId)}:${handle}`, 0, 1);
|
|
441
|
+
await this.records.mutate({ domain: 'result', storageKey, sessionId, entryId: handle }, {
|
|
442
|
+
validate: validateResult,
|
|
443
|
+
decide: (current) => {
|
|
444
|
+
if (current !== undefined) throw conflict();
|
|
445
|
+
return { revision: 1, value };
|
|
446
|
+
},
|
|
447
|
+
contention: conflict,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
public load(storageKey: string, sessionId: string, handle: string): Promise<TJsonValue | undefined> {
|
|
452
|
+
validateIdentifier(handle, 'handle');
|
|
453
|
+
return this.records.read({ domain: 'result', storageKey, sessionId, entryId: handle }, validateResult);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
public deleteSession(storageKey: string, sessionId: string): Promise<void> {
|
|
457
|
+
return this.records.deleteOwner(storageKey, sessionId, ['result']);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function validateResult(value: unknown): TJsonValue {
|
|
462
|
+
assertJsonSerializable(value);
|
|
463
|
+
return value as TJsonValue;
|
|
464
|
+
}
|
|
465
|
+
|
|
431
466
|
/**
|
|
432
467
|
* Every FlexHarness persistence domain on `@lossless.org/client/nosqldb`, with compare-and-swap
|
|
433
468
|
* that holds across processes. Records live in `flexharness_records`; payloads longer than one
|
|
@@ -440,6 +475,7 @@ export class NoSqlFlexHarnessStores implements IFlexHarnessStores {
|
|
|
440
475
|
public readonly projectManagement: IFlexProjectManagementStore;
|
|
441
476
|
public readonly agentEvents: IFlexAgentEventStoreProvider;
|
|
442
477
|
public readonly jobs: IFlexToolJobStoreProvider;
|
|
478
|
+
public readonly results: IFlexResultStore;
|
|
443
479
|
private readonly records: FlexRecordStore;
|
|
444
480
|
|
|
445
481
|
constructor(options: INoSqlFlexHarnessStoresOptions) {
|
|
@@ -453,6 +489,7 @@ export class NoSqlFlexHarnessStores implements IFlexHarnessStores {
|
|
|
453
489
|
this.projectManagement = new NoSqlProjectManagementStore(this.records);
|
|
454
490
|
this.agentEvents = new NoSqlAgentEventStoreProvider(this.records);
|
|
455
491
|
this.jobs = new NoSqlToolJobStoreProvider(this.records);
|
|
492
|
+
this.results = new NoSqlResultStore(this.records);
|
|
456
493
|
}
|
|
457
494
|
|
|
458
495
|
/**
|
|
@@ -12,14 +12,16 @@ export type TFlexRecordDomain =
|
|
|
12
12
|
| 'projectManagement'
|
|
13
13
|
| 'agentEvents'
|
|
14
14
|
| 'agentEventArchive'
|
|
15
|
-
| 'jobs'
|
|
15
|
+
| 'jobs'
|
|
16
|
+
| 'result';
|
|
16
17
|
|
|
17
|
-
/** Names one record: a domain snapshot of a storage key
|
|
18
|
+
/** Names one record: a domain snapshot of a storage key or a session, or one entry of a session. */
|
|
18
19
|
export interface IFlexRecordAddress {
|
|
19
20
|
domain: TFlexRecordDomain;
|
|
20
21
|
storageKey: string;
|
|
21
22
|
sessionId?: string;
|
|
22
|
-
|
|
23
|
+
/** The archive or result the record holds. */
|
|
24
|
+
entryId?: string;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/** The next stored value a mutation decided on. */
|
|
@@ -256,7 +258,7 @@ export class FlexRecordStore {
|
|
|
256
258
|
address.domain,
|
|
257
259
|
address.storageKey,
|
|
258
260
|
address.sessionId ?? null,
|
|
259
|
-
address.
|
|
261
|
+
address.entryId ?? null,
|
|
260
262
|
]));
|
|
261
263
|
return {
|
|
262
264
|
recordId,
|