@toolproof-core/lib 1.0.33 → 1.0.36
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/integrations/firebase/createStep.d.ts +2 -3
- package/dist/integrations/firebase/createStep.js +7 -33
- package/dist/integrations/firebase/createThreadedStrategy.d.ts +2 -0
- package/dist/integrations/firebase/createThreadedStrategy.js +8 -0
- package/dist/integrations/firebase/firebaseAdminHelpers.d.ts +4 -10
- package/dist/integrations/firebase/firebaseAdminHelpers.js +43 -136
- package/dist/integrations/firebase/firebaseAdminInit.d.ts +0 -1
- package/dist/integrations/firebase/firebaseAdminInit.js +0 -1
- package/dist/lookups/lookups.d.ts +221 -0
- package/dist/lookups/lookups.js +23 -0
- package/dist/types/types.d.ts +8 -12
- package/dist/types/types.js +2 -3
- package/dist/utils/creation/resourceCreation.d.ts +18 -18
- package/dist/utils/creation/resourceCreation.js +49 -48
- package/dist/utils/creation/stepCreation.d.ts +7 -48
- package/dist/utils/creation/stepCreation.js +16 -42
- package/dist/utils/creation/threadedStrategyCreation.d.ts +18 -0
- package/dist/utils/creation/threadedStrategyCreation.js +16 -0
- package/dist/utils/extractData.d.ts +9 -10
- package/dist/utils/extractData.js +29 -25
- package/dist/utils/parallelizeSteps.d.ts +1 -2
- package/dist/utils/parallelizeSteps.js +52 -37
- package/dist/utils/resolveStrategyStateChain.d.ts +20 -0
- package/dist/utils/{resolveResourceChain.js → resolveStrategyStateChain.js} +6 -11
- package/dist/utils/roleSpec.d.ts +7 -3
- package/dist/utils/roleSpec.js +0 -1
- package/dist/utils/strategyState.d.ts +11 -6
- package/dist/utils/strategyState.js +41 -12
- package/dist/utils_2/threadedStrategyCreation.d.ts +5 -0
- package/dist/utils_2/threadedStrategyCreation.js +12 -0
- package/package.json +15 -15
- package/src/integrations/firebase/createStep.ts +9 -39
- package/src/integrations/firebase/createThreadedStrategy.ts +19 -0
- package/src/integrations/firebase/firebaseAdminHelpers.ts +61 -163
- package/src/lookups/lookups.ts +25 -0
- package/src/types/types.ts +9 -12
- package/src/utils/creation/resourceCreation.ts +140 -121
- package/src/utils/creation/stepCreation.ts +25 -95
- package/src/utils/creation/threadedStrategyCreation.ts +42 -0
- package/src/utils/extractData.ts +46 -38
- package/src/utils/parallelizeSteps.ts +92 -40
- package/src/utils/resolveStrategyStateChain.ts +58 -0
- package/src/utils/roleSpec.ts +7 -3
- package/src/utils/strategyState.ts +99 -27
- package/src/utils_2/threadedStrategyCreation.ts +19 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/artifacts/artifacts.d.ts +0 -175
- package/dist/artifacts/artifacts.d.ts.map +0 -1
- package/dist/artifacts/artifacts.js +0 -48
- package/dist/artifacts/artifacts.js.map +0 -1
- package/dist/integrations/firebase/createRunnableStrategy.d.ts +0 -3
- package/dist/integrations/firebase/createRunnableStrategy.d.ts.map +0 -1
- package/dist/integrations/firebase/createRunnableStrategy.js +0 -9
- package/dist/integrations/firebase/createRunnableStrategy.js.map +0 -1
- package/dist/integrations/firebase/createStep.d.ts.map +0 -1
- package/dist/integrations/firebase/createStep.js.map +0 -1
- package/dist/integrations/firebase/firebaseAdminHelpers.d.ts.map +0 -1
- package/dist/integrations/firebase/firebaseAdminHelpers.js.map +0 -1
- package/dist/integrations/firebase/firebaseAdminInit.d.ts.map +0 -1
- package/dist/integrations/firebase/firebaseAdminInit.js.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js.map +0 -1
- package/dist/utils/bindInputRoleToResource.d.ts +0 -6
- package/dist/utils/bindInputRoleToResource.d.ts.map +0 -1
- package/dist/utils/bindInputRoleToResource.js +0 -25
- package/dist/utils/bindInputRoleToResource.js.map +0 -1
- package/dist/utils/creation/resourceCreation.d.ts.map +0 -1
- package/dist/utils/creation/resourceCreation.js.map +0 -1
- package/dist/utils/creation/runnableStrategyCreation.d.ts +0 -4
- package/dist/utils/creation/runnableStrategyCreation.d.ts.map +0 -1
- package/dist/utils/creation/runnableStrategyCreation.js +0 -17
- package/dist/utils/creation/runnableStrategyCreation.js.map +0 -1
- package/dist/utils/creation/stepCreation.d.ts.map +0 -1
- package/dist/utils/creation/stepCreation.js.map +0 -1
- package/dist/utils/extractData.d.ts.map +0 -1
- package/dist/utils/extractData.js.map +0 -1
- package/dist/utils/parallelizeSteps.d.ts.map +0 -1
- package/dist/utils/parallelizeSteps.js.map +0 -1
- package/dist/utils/resolveResourceChain.d.ts +0 -19
- package/dist/utils/resolveResourceChain.d.ts.map +0 -1
- package/dist/utils/resolveResourceChain.js.map +0 -1
- package/dist/utils/roleSpec.d.ts.map +0 -1
- package/dist/utils/roleSpec.js.map +0 -1
- package/dist/utils/strategyState.d.ts.map +0 -1
- package/dist/utils/strategyState.js.map +0 -1
- package/src/artifacts/artifacts.ts +0 -49
- package/src/integrations/firebase/createRunnableStrategy.ts +0 -18
- package/src/utils/bindInputRoleToResource.ts +0 -53
- package/src/utils/creation/runnableStrategyCreation.ts +0 -28
- package/src/utils/resolveResourceChain.ts +0 -52
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CreationContext,
|
|
3
|
-
Resource,
|
|
4
|
-
ReferenceInput,
|
|
5
|
-
ValueInput,
|
|
6
|
-
} from '@toolproof-core/schema';
|
|
7
|
-
import {
|
|
8
|
-
clearStrategyStateEntry,
|
|
9
|
-
getStrategyStateEntry,
|
|
10
|
-
setStrategyStateEntry,
|
|
11
|
-
type StrategyState,
|
|
12
|
-
} from './strategyState.js';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export function bindInputResInStrategyState(
|
|
16
|
-
strategyState: StrategyState,
|
|
17
|
-
target: CreationContext,
|
|
18
|
-
resource: Resource
|
|
19
|
-
): StrategyState {
|
|
20
|
-
const entry: ValueInput = {
|
|
21
|
-
strategyStateInputKind: 'valueInput',
|
|
22
|
-
resourceTypeId: resource.resourceTypeId,
|
|
23
|
-
nucleus: resource.nucleus,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return setStrategyStateEntry(strategyState, target, entry);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function bindInputRefInStrategyState(
|
|
30
|
-
strategyState: StrategyState,
|
|
31
|
-
target: CreationContext,
|
|
32
|
-
source: CreationContext
|
|
33
|
-
): StrategyState {
|
|
34
|
-
const sourceEntry = getStrategyStateEntry(strategyState, source);
|
|
35
|
-
if (!sourceEntry) {
|
|
36
|
-
throw new Error(`resourceEntry not found for source (${source.toolStepPath}, ${source.roleName})`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const entry: ReferenceInput = {
|
|
40
|
-
strategyStateInputKind: 'referenceInput',
|
|
41
|
-
toolStepPath: source.toolStepPath,
|
|
42
|
-
roleName: source.roleName,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return setStrategyStateEntry(strategyState, target, entry);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function clearInputBindingInStrategyState(
|
|
49
|
-
strategyState: StrategyState,
|
|
50
|
-
target: CreationContext
|
|
51
|
-
): StrategyState {
|
|
52
|
-
return clearStrategyStateEntry(strategyState, target);
|
|
53
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Step,
|
|
3
|
-
Strategy,
|
|
4
|
-
StrategyId,
|
|
5
|
-
} from '@toolproof-core/schema';
|
|
6
|
-
import { getIndependentThreads } from '../parallelizeSteps.js';
|
|
7
|
-
import { CONSTANTS } from '../../artifacts/artifacts.js';
|
|
8
|
-
|
|
9
|
-
export function getRunnableStrategyThreadGroups(rawStrategy: Strategy): Step[][] {
|
|
10
|
-
if ('steps' in rawStrategy) {
|
|
11
|
-
return getIndependentThreads(rawStrategy.steps, rawStrategy.strategyState as any);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return rawStrategy.stepsByThreadIndex;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function buildRunnableStrategy(
|
|
18
|
-
threadStepGroups: Step[][],
|
|
19
|
-
runnableStrategyId: StrategyId,
|
|
20
|
-
rawStrategy: Strategy,
|
|
21
|
-
): Strategy {
|
|
22
|
-
return {
|
|
23
|
-
id: runnableStrategyId,
|
|
24
|
-
strategyKind: CONSTANTS.Enums.StrategyKind.threaded,
|
|
25
|
-
stepsByThreadIndex: threadStepGroups,
|
|
26
|
-
strategyState: rawStrategy.strategyState,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CreationContext,
|
|
3
|
-
ExternalInput,
|
|
4
|
-
ReferenceInput,
|
|
5
|
-
StrategyStateInputEntry,
|
|
6
|
-
ValueInput,
|
|
7
|
-
} from '@toolproof-core/schema';
|
|
8
|
-
import { getStrategyStateEntry, type StrategyState } from './strategyState.js';
|
|
9
|
-
|
|
10
|
-
export type ResolveResult =
|
|
11
|
-
| { status: 'valueInput'; entry: ValueInput; path: CreationContext[] }
|
|
12
|
-
| { status: 'externalInput'; entry: ExternalInput; path: CreationContext[] }
|
|
13
|
-
| { status: 'unresolved'; reason: 'not-found' | 'cycle' | 'depth-exceeded'; path: CreationContext[] };
|
|
14
|
-
|
|
15
|
-
export function resolveResourceChain(
|
|
16
|
-
strategyState: StrategyState,
|
|
17
|
-
start: CreationContext,
|
|
18
|
-
opts?: { maxDepth?: number }
|
|
19
|
-
): ResolveResult {
|
|
20
|
-
const maxDepth = opts?.maxDepth ?? 50;
|
|
21
|
-
const visited = new Set<string>();
|
|
22
|
-
const path: CreationContext[] = [];
|
|
23
|
-
let current: CreationContext = start;
|
|
24
|
-
|
|
25
|
-
for (let depth = 0; depth <= maxDepth; depth++) {
|
|
26
|
-
path.push(current);
|
|
27
|
-
const visitKey = `${current.toolStepPath}::${current.roleName}`;
|
|
28
|
-
if (visited.has(visitKey)) {
|
|
29
|
-
return { status: 'unresolved', reason: 'cycle', path };
|
|
30
|
-
}
|
|
31
|
-
visited.add(visitKey);
|
|
32
|
-
|
|
33
|
-
const entry = getStrategyStateEntry(strategyState, current) as StrategyStateInputEntry | undefined;
|
|
34
|
-
if (!entry) return { status: 'unresolved', reason: 'not-found', path };
|
|
35
|
-
|
|
36
|
-
if (entry.strategyStateInputKind === 'valueInput') {
|
|
37
|
-
return { status: 'valueInput', entry: entry, path };
|
|
38
|
-
}
|
|
39
|
-
if (entry.strategyStateInputKind === 'externalInput') {
|
|
40
|
-
return { status: 'externalInput', entry: entry, path };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
current = {
|
|
44
|
-
toolStepPath: (entry as ReferenceInput).toolStepPath,
|
|
45
|
-
roleName: (entry as ReferenceInput).roleName,
|
|
46
|
-
};
|
|
47
|
-
continue;
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return { status: 'unresolved', reason: 'depth-exceeded', path };
|
|
52
|
-
}
|