@cobol-ts/plan_graph 0.0.0-stage → 0.0.16
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 +65 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/src/always.planner.d.ts +3 -0
- package/dist/src/always.planner.js +18 -0
- package/dist/src/always.planner.js.map +1 -0
- package/dist/src/always.planner.spec.d.ts +1 -0
- package/dist/src/always.planner.spec.js +32 -0
- package/dist/src/always.planner.spec.js.map +1 -0
- package/dist/src/batch.planner.d.ts +7 -0
- package/dist/src/batch.planner.js +18 -0
- package/dist/src/batch.planner.js.map +1 -0
- package/dist/src/batch.planner.spec.d.ts +1 -0
- package/dist/src/batch.planner.spec.js +49 -0
- package/dist/src/batch.planner.spec.js.map +1 -0
- package/dist/src/downstream.d.ts +7 -0
- package/dist/src/downstream.js +9 -0
- package/dist/src/downstream.js.map +1 -0
- package/dist/src/downstream.spec.d.ts +1 -0
- package/dist/src/downstream.spec.js +32 -0
- package/dist/src/downstream.spec.js.map +1 -0
- package/dist/src/plan.d.ts +13 -0
- package/dist/src/plan.factory.d.ts +18 -0
- package/dist/src/plan.factory.js +23 -0
- package/dist/src/plan.factory.js.map +1 -0
- package/dist/src/plan.factory.spec.d.ts +1 -0
- package/dist/src/plan.factory.spec.js +49 -0
- package/dist/src/plan.factory.spec.js.map +1 -0
- package/dist/src/plan.js +25 -0
- package/dist/src/plan.js.map +1 -0
- package/dist/src/plan.spec.d.ts +1 -0
- package/dist/src/plan.spec.js +46 -0
- package/dist/src/plan.spec.js.map +1 -0
- package/dist/src/planner.d.ts +5 -0
- package/dist/src/planner.js +3 -0
- package/dist/src/planner.js.map +1 -0
- package/package.json +57 -3
package/README.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cobol-ts/plan_graph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Initial execution plans and activation helpers for an already sorted and numbered Planned Graph. The package is independent of CEL, accumulator storage and graph execution.
|
|
4
|
+
|
|
5
|
+
## Quick orientation
|
|
6
|
+
|
|
7
|
+
**Responsibility.** Represent mutable execution bitsets, choose initial activation policies and propagate material changes to downstream nodes.
|
|
8
|
+
|
|
9
|
+
**Boundary.** The initial plan is a template; each record gets its own copy, while dependency-based activation runs during evaluation.
|
|
10
|
+
|
|
11
|
+
**Public modules.** [plan.ts](./src/plan.ts), [planner.ts](./src/planner.ts), [batch.planner.ts](./src/batch.planner.ts), [downstream.ts](./src/downstream.ts), [plan.factory.ts](./src/plan.factory.ts) (and 1 more exports in [`index.ts`](index.ts)).
|
|
12
|
+
|
|
13
|
+
**Tests.** [always.planner.spec.ts](src/always.planner.spec.ts), [batch.planner.spec.ts](src/batch.planner.spec.ts), [downstream.spec.ts](src/downstream.spec.ts) (+2 more)
|
|
14
|
+
|
|
15
|
+
**Related packages.** [@cobol-ts/planned_graph](../planned_graph/README.md) · [@cobol-ts/graph-executor](../../execution/graph_executor/README.md).
|
|
16
|
+
|
|
17
|
+
## Plan and initial template
|
|
18
|
+
|
|
19
|
+
`Plan` is a `Uint8Array` with one byte per Planned Graph node. Zero means inactive; one means active. Each RecordCursor owns a reusable mutable Plan.
|
|
20
|
+
|
|
21
|
+
`InitialPlan` stores a private copy of the activation flags. A Planner constructs it once for a graph and strategy. Before each entity, reuse the RecordCursor's Plan by calling `initial.copyInto(plan)`, which checks the length and uses the native typed-array `set()` operation. The initial template is never exposed for mutation. A Plan must be associated with the correct Planned Graph by its owner; matching lengths alone do not establish graph identity.
|
|
22
|
+
|
|
23
|
+
## Planner and Batch Planner
|
|
24
|
+
|
|
25
|
+
`Planner<Node>.plan(generations)` constructs an `InitialPlan` in flattened topological node order. `createBatchPlanner(tc)` uses the injected `BatchPlannerTC<Node>.dependsOnInput(node)` activation predicate. The CEL adapter marks nodes reading batch `input` **or** `prev`, because previous-value readers may need to run before another node updates the same accumulator. This selection happens at graph preparation, not per entity.
|
|
26
|
+
|
|
27
|
+
The CEL adapter is implemented by `createDirectInputCelPlanner()` in `@cobol-ts/cel-graph-runtime`; it checks canonical `input` **and `variables`** dependencies and the existing CEL expression for `prev` reads. Ordinary `now` dependencies are activated by downstream material-change propagation, not by the initial batch-input predicate. Do not implement a new adapter using only `path[0] === 'input'`, as that omits variable-dependent and previous-value readers.
|
|
28
|
+
|
|
29
|
+
This package's Plan remains independent of CEL and of accumulator storage. Other strategies can supply different activation policies. Missing accumulator values and their defaults are handled outside the planner.
|
|
30
|
+
|
|
31
|
+
## Downstream activation
|
|
32
|
+
|
|
33
|
+
`activateDownstream(node, plan, tc)` marks the node's immediate numeric downstream indices as active. It is idempotent and does not decide whether a change was material. The eventual Executor calls it after the accumulator reports a material change.
|
|
34
|
+
|
|
35
|
+
This package does not include the Executor, modify CEL, or introduce a session.
|
|
36
|
+
|
|
37
|
+
## Control-loop Plan creation
|
|
38
|
+
|
|
39
|
+
`PlanFactory` provides `empty()`, `copy()` and `copyInto(plan)` without exposing the
|
|
40
|
+
initial template. `DefaultPlanFactory` is constructed once from the Planner's
|
|
41
|
+
`InitialPlan`. `empty()` creates a zeroed Plan of the right size; `copy()` creates
|
|
42
|
+
a **new** Plan prefilled from the immutable initial pattern. When a RecordCursor
|
|
43
|
+
already owns a Plan, prefer `copyInto(plan)` at the beginning of each entity:
|
|
44
|
+
it reuses the existing bytes and avoids a new allocation.
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
const factory: PlanFactory = new DefaultPlanFactory(batchPlanner.plan(plannedGraph))
|
|
48
|
+
const working = factory.empty() // once per RecordCursor
|
|
49
|
+
|
|
50
|
+
// At each entity:
|
|
51
|
+
factory.copyInto(working)
|
|
52
|
+
// ... use working for execution and downstream activation
|
|
53
|
+
|
|
54
|
+
// Or when a new owned Plan is required:
|
|
55
|
+
const independent = factory.copy()
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Each factory is associated with one initial template and thus one particular
|
|
59
|
+
Planned Graph; association with the correct graph is established by its owner.
|
|
60
|
+
|
|
61
|
+
### Always Planner
|
|
62
|
+
|
|
63
|
+
`createAlwaysPlanner<Node>()` produces an immutable `InitialPlan` with every node
|
|
64
|
+
active, including nodes without input dependencies. This is useful for unconditional
|
|
65
|
+
execution and regression testing. Initialise a working `Plan` with
|
|
66
|
+
`new DefaultPlanFactory(initial).copy()` or reuse it with `copyInto()`.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src/plan"), exports);
|
|
18
|
+
__exportStar(require("./src/planner"), exports);
|
|
19
|
+
__exportStar(require("./src/batch.planner"), exports);
|
|
20
|
+
__exportStar(require("./src/downstream"), exports);
|
|
21
|
+
__exportStar(require("./src/plan.factory"), exports);
|
|
22
|
+
__exportStar(require("./src/always.planner"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,gDAA6B;AAC7B,sDAAmC;AACnC,mDAAgC;AAChC,qDAAkC;AAClC,uDAAoC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAlwaysPlanner = createAlwaysPlanner;
|
|
4
|
+
const plan_1 = require("./plan");
|
|
5
|
+
/** Initialises every node as active, independently of its representation. */
|
|
6
|
+
function createAlwaysPlanner() {
|
|
7
|
+
return {
|
|
8
|
+
plan(generations) {
|
|
9
|
+
const flags = [];
|
|
10
|
+
for (const generation of generations) {
|
|
11
|
+
for (const _node of generation)
|
|
12
|
+
flags.push(true);
|
|
13
|
+
}
|
|
14
|
+
return new plan_1.InitialPlan(flags);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=always.planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"always.planner.js","sourceRoot":"","sources":["../../src/always.planner.ts"],"names":[],"mappings":";;AAIA,kDAUC;AAdD,iCAAkC;AAGlC,6EAA6E;AAC7E,SAAgB,mBAAmB;IAC/B,OAAO;QACH,IAAI,CAAC,WAAW;YACZ,MAAM,KAAK,GAAc,EAAE,CAAA;YAC3B,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACnC,KAAK,MAAM,KAAK,IAAI,UAAU;oBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACpD,CAAC;YACD,OAAO,IAAI,kBAAW,CAAC,KAAK,CAAC,CAAA;QACjC,CAAC;KACJ,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const always_planner_1 = require("./always.planner");
|
|
4
|
+
const plan_factory_1 = require("./plan.factory");
|
|
5
|
+
describe('Always Planner', () => {
|
|
6
|
+
it('activates every node across generations', () => {
|
|
7
|
+
const initial = (0, always_planner_1.createAlwaysPlanner)().plan([['a', 'b'], [], ['c']]);
|
|
8
|
+
const factory = new plan_factory_1.DefaultPlanFactory(initial);
|
|
9
|
+
expect([...factory.copy()]).toEqual([1, 1, 1]);
|
|
10
|
+
});
|
|
11
|
+
it('creates an empty plan for no nodes', () => {
|
|
12
|
+
const initial = (0, always_planner_1.createAlwaysPlanner)().plan([[], []]);
|
|
13
|
+
expect([...new plan_factory_1.DefaultPlanFactory(initial).copy()]).toEqual([]);
|
|
14
|
+
});
|
|
15
|
+
it('reuses an immutable initial pattern after the working plan changes', () => {
|
|
16
|
+
const factory = new plan_factory_1.DefaultPlanFactory((0, always_planner_1.createAlwaysPlanner)().plan([['a'], ['b']]));
|
|
17
|
+
const working = factory.empty();
|
|
18
|
+
factory.copyInto(working);
|
|
19
|
+
working[0] = 0;
|
|
20
|
+
expect([...working]).toEqual([0, 1]);
|
|
21
|
+
factory.copyInto(working);
|
|
22
|
+
expect([...working]).toEqual([1, 1]);
|
|
23
|
+
expect([...factory.copy()]).toEqual([1, 1]);
|
|
24
|
+
});
|
|
25
|
+
it('is independent of a node typeclass and node values', () => {
|
|
26
|
+
const initial = (0, always_planner_1.createAlwaysPlanner)().plan([[{ id: 8 }, { id: 9 }]]);
|
|
27
|
+
const actual = new Uint8Array(2);
|
|
28
|
+
initial.copyInto(actual);
|
|
29
|
+
expect([...actual]).toEqual([1, 1]);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=always.planner.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"always.planner.spec.js","sourceRoot":"","sources":["../../src/always.planner.spec.ts"],"names":[],"mappings":";;AAAA,qDAAoD;AACpD,iDAAiD;AAEjD,QAAQ,CAAC,gBAAgB,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AQ,CAAC,OAAO,CAAC,CAAA;QACzB,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACpC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC/C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC1D,MAAM,OAAO,GAAG,IAAA,oCAAmB,GAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,EAAE,EAAE,CAAC,EAAC,EAAE,EAAC,EAAE,EAAE,CAAC,EAAC,CAAC,CAAC,CAAC,CAAA;QAC9E,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;QAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACxB,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Planner } from './planner';
|
|
2
|
+
/** The caller determines which dependency roots represent new batch inputs. */
|
|
3
|
+
export interface BatchPlannerTC<Node> {
|
|
4
|
+
dependsOnInput(node: Node): boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Creates an initial Plan once; does not inspect input records or parse CEL. */
|
|
7
|
+
export declare function createBatchPlanner<Node>(tc: BatchPlannerTC<Node>): Planner<Node>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBatchPlanner = createBatchPlanner;
|
|
4
|
+
const plan_1 = require("./plan");
|
|
5
|
+
/** Creates an initial Plan once; does not inspect input records or parse CEL. */
|
|
6
|
+
function createBatchPlanner(tc) {
|
|
7
|
+
return {
|
|
8
|
+
plan(generations) {
|
|
9
|
+
const flags = [];
|
|
10
|
+
for (const generation of generations) {
|
|
11
|
+
for (const node of generation)
|
|
12
|
+
flags.push(tc.dependsOnInput(node));
|
|
13
|
+
}
|
|
14
|
+
return new plan_1.InitialPlan(flags);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=batch.planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.planner.js","sourceRoot":"","sources":["../../src/batch.planner.ts"],"names":[],"mappings":";;AASA,gDAUC;AAnBD,iCAAkC;AAQlC,iFAAiF;AACjF,SAAgB,kBAAkB,CAAO,EAAwB;IAC7D,OAAO;QACH,IAAI,CAAC,WAAW;YACZ,MAAM,KAAK,GAAc,EAAE,CAAA;YAC3B,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACnC,KAAK,MAAM,IAAI,IAAI,UAAU;oBAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;YACtE,CAAC;YACD,OAAO,IAAI,kBAAW,CAAC,KAAK,CAAC,CAAA;QACjC,CAAC;KACJ,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const batch_planner_1 = require("./batch.planner");
|
|
4
|
+
const planner = (0, batch_planner_1.createBatchPlanner)({ dependsOnInput: node => node.input });
|
|
5
|
+
describe('Batch Planner', () => {
|
|
6
|
+
it('marks direct input users, preserving topological numbering', () => {
|
|
7
|
+
const initial = planner.plan([
|
|
8
|
+
[{ id: 'a', input: true }, { id: 'b', input: false }],
|
|
9
|
+
[{ id: 'c', input: false }, { id: 'd', input: true }]
|
|
10
|
+
]);
|
|
11
|
+
const actual = new Uint8Array(4);
|
|
12
|
+
initial.copyInto(actual);
|
|
13
|
+
expect([...actual]).toEqual([1, 0, 0, 1]);
|
|
14
|
+
});
|
|
15
|
+
it('does not activate derived-only nodes', () => {
|
|
16
|
+
const initial = planner.plan([[{ id: 'a', input: false }], [{ id: 'b', input: false }]]);
|
|
17
|
+
const actual = new Uint8Array(2);
|
|
18
|
+
initial.copyInto(actual);
|
|
19
|
+
expect([...actual]).toEqual([0, 0]);
|
|
20
|
+
});
|
|
21
|
+
it('handles an empty and a partly empty generation list', () => {
|
|
22
|
+
const empty = planner.plan([]);
|
|
23
|
+
const one = planner.plan([[], [{ id: 'a', input: true }], []]);
|
|
24
|
+
const none = new Uint8Array(0);
|
|
25
|
+
const single = new Uint8Array(1);
|
|
26
|
+
empty.copyInto(none);
|
|
27
|
+
one.copyInto(single);
|
|
28
|
+
expect([...none]).toEqual([]);
|
|
29
|
+
expect([...single]).toEqual([1]);
|
|
30
|
+
});
|
|
31
|
+
it('works against a second unrelated node type', () => {
|
|
32
|
+
const other = (0, batch_planner_1.createBatchPlanner)({ dependsOnInput: name => name === 'input' });
|
|
33
|
+
const actual = new Uint8Array(3);
|
|
34
|
+
other.plan([['input', 'acc'], ['variables']]).copyInto(actual);
|
|
35
|
+
expect([...actual]).toEqual([1, 0, 0]);
|
|
36
|
+
});
|
|
37
|
+
it('creates one reusable immutable initial plan without rereading nodes for each copy', () => {
|
|
38
|
+
let calls = 0;
|
|
39
|
+
const counting = (0, batch_planner_1.createBatchPlanner)({ dependsOnInput(node) { calls++; return node.input; } });
|
|
40
|
+
const initial = counting.plan([[{ id: 'a', input: true }, { id: 'b', input: false }]]);
|
|
41
|
+
const actual = new Uint8Array(2);
|
|
42
|
+
initial.copyInto(actual);
|
|
43
|
+
actual[1] = 1;
|
|
44
|
+
initial.copyInto(actual);
|
|
45
|
+
expect([...actual]).toEqual([1, 0]);
|
|
46
|
+
expect(calls).toEqual(2);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=batch.planner.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.planner.spec.js","sourceRoot":"","sources":["../../src/batch.planner.spec.ts"],"names":[],"mappings":";;AAAA,mDAAkD;AAGlD,MAAM,OAAO,GAAG,IAAA,kCAAkB,EAAO,EAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAC,CAAC,CAAA;AAE9E,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QAClE,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;YACzB,CAAC,EAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,EAAE,EAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC;YACjD,CAAC,EAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,EAAE,EAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;SACpD,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;QAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACxB,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,EAAE,CAAC,EAAC,EAAE,EAAE,GAAG,EAAE,KA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planned Graph node. */
|
|
3
|
+
export interface DownstreamTC<Node> {
|
|
4
|
+
downstream(node: Node): readonly number[];
|
|
5
|
+
}
|
|
6
|
+
/** OR-activate immediate downstream nodes. Does not calculate materiality. */
|
|
7
|
+
export declare function activateDownstream<Node>(node: Node, plan: Plan, tc: DownstreamTC<Node>): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activateDownstream = activateDownstream;
|
|
4
|
+
/** OR-activate immediate downstream nodes. Does not calculate materiality. */
|
|
5
|
+
function activateDownstream(node, plan, tc) {
|
|
6
|
+
for (const index of tc.downstream(node))
|
|
7
|
+
plan[index] = 1;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=downstream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"downstream.js","sourceRoot":"","sources":["../../src/downstream.ts"],"names":[],"mappings":";;AAQA,gDAEC;AAHD,8EAA8E;AAC9E,SAAgB,kBAAkB,CAAO,IAAU,EAAE,IAAU,EAAE,EAAsB;IACnF,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAC5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const downstream_1 = require("./downstream");
|
|
4
|
+
const plan_1 = require("./plan");
|
|
5
|
+
const tc = { downstream: (node) => node.edges };
|
|
6
|
+
describe('activateDownstream', () => {
|
|
7
|
+
it('marks all immediate downstream indices, including cross-generation edges', () => {
|
|
8
|
+
const flags = new Uint8Array([1, 0, 0, 0, 0]);
|
|
9
|
+
(0, downstream_1.activateDownstream)({ name: 'a', edges: [2, 4] }, flags, tc);
|
|
10
|
+
expect([...flags]).toEqual([1, 0, 1, 0, 1]);
|
|
11
|
+
});
|
|
12
|
+
it('ORs existing flags and tolerates repeated edges', () => {
|
|
13
|
+
const flags = new Uint8Array([0, 1, 0]);
|
|
14
|
+
(0, downstream_1.activateDownstream)({ name: 'a', edges: [1, 1, 2] }, flags, tc);
|
|
15
|
+
expect([...flags]).toEqual([0, 1, 1]);
|
|
16
|
+
});
|
|
17
|
+
it('does nothing for a leaf', () => {
|
|
18
|
+
const flags = new Uint8Array([0, 1]);
|
|
19
|
+
(0, downstream_1.activateDownstream)({ name: 'leaf', edges: [] }, flags, tc);
|
|
20
|
+
expect([...flags]).toEqual([0, 1]);
|
|
21
|
+
});
|
|
22
|
+
it('does not alter the immutable initial plan', () => {
|
|
23
|
+
const initial = new plan_1.InitialPlan([true, false, false]);
|
|
24
|
+
const flags = new Uint8Array(3);
|
|
25
|
+
initial.copyInto(flags);
|
|
26
|
+
(0, downstream_1.activateDownstream)({ name: 'a', edges: [1, 2] }, flags, tc);
|
|
27
|
+
expect([...flags]).toEqual([1, 1, 1]);
|
|
28
|
+
initial.copyInto(flags);
|
|
29
|
+
expect([...flags]).toEqual([1, 0, 0]);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=downstream.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"downstream.spec.js","sourceRoot":"","sources":["../../src/downstream.spec.ts"],"names":[],"mappings":";;AAAA,6CAA+C;AAC/C,iCAAkC;AAGlC,MAAM,EAAE,GAAG,EAAC,UAAU,EAAE,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAC,CAAA;AAEnD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;QAChF,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,C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W,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;QACrD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;QAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACvB,IAAA,+BAAkB,EAAC,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;QACzD,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACvB,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Mutable execution flags, indexed by the associated Planned Graph. */
|
|
2
|
+
export type Plan = Uint8Array;
|
|
3
|
+
/**
|
|
4
|
+
* Owns an initial activation pattern without exposing its mutable storage.
|
|
5
|
+
* Construct once during planning; copy to the RecordCursor's Plan per entity.
|
|
6
|
+
*/
|
|
7
|
+
export declare class InitialPlan {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(flags: readonly boolean[]);
|
|
10
|
+
get length(): number;
|
|
11
|
+
/** Reuses the destination storage; always clears previous activations. */
|
|
12
|
+
copyInto(plan: Plan): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InitialPlan, type Plan } from './plan';
|
|
2
|
+
/** Creates working Plans for one immutable initial activation pattern. */
|
|
3
|
+
export interface PlanFactory {
|
|
4
|
+
/** A new, inactive Plan with one entry per node. */
|
|
5
|
+
empty(): Plan;
|
|
6
|
+
/** A new Plan initialised from the Planner's template. */
|
|
7
|
+
copy(): Plan;
|
|
8
|
+
/** Reset an existing Plan without allocating another one. */
|
|
9
|
+
copyInto(plan: Plan): void;
|
|
10
|
+
}
|
|
11
|
+
/** Default Uint8Array-backed Plan factory. */
|
|
12
|
+
export declare class DefaultPlanFactory implements PlanFactory {
|
|
13
|
+
private readonly initial;
|
|
14
|
+
constructor(initial: InitialPlan);
|
|
15
|
+
empty(): Plan;
|
|
16
|
+
copy(): Plan;
|
|
17
|
+
copyInto(plan: Plan): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultPlanFactory = void 0;
|
|
4
|
+
/** Default Uint8Array-backed Plan factory. */
|
|
5
|
+
class DefaultPlanFactory {
|
|
6
|
+
initial;
|
|
7
|
+
constructor(initial) {
|
|
8
|
+
this.initial = initial;
|
|
9
|
+
}
|
|
10
|
+
empty() {
|
|
11
|
+
return new Uint8Array(this.initial.length);
|
|
12
|
+
}
|
|
13
|
+
copy() {
|
|
14
|
+
const result = this.empty();
|
|
15
|
+
this.copyInto(result);
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
copyInto(plan) {
|
|
19
|
+
this.initial.copyInto(plan);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.DefaultPlanFactory = DefaultPlanFactory;
|
|
23
|
+
//# sourceMappingURL=plan.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.factory.js","sourceRoot":"","sources":["../../src/plan.factory.ts"],"names":[],"mappings":";;;AAcA,8CAA8C;AAC9C,MAAa,kBAAkB;IACE;IAA7B,YAA6B,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IAAG,CAAC;IAErD,KAAK;QACD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI;QACA,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAA;QAC3B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACrB,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,QAAQ,CAAC,IAAU;QACf,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;CACJ;AAhBD,gDAgBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const plan_factory_1 = require("./plan.factory");
|
|
4
|
+
const plan_1 = require("./plan");
|
|
5
|
+
describe('DefaultPlanFactory', () => {
|
|
6
|
+
const initial = new plan_1.InitialPlan([true, false, true, false]);
|
|
7
|
+
const factory = new plan_factory_1.DefaultPlanFactory(initial);
|
|
8
|
+
it('creates an empty Plan of the correct size', () => {
|
|
9
|
+
expect([...factory.empty()]).toEqual([0, 0, 0, 0]);
|
|
10
|
+
});
|
|
11
|
+
it('copies the initial Plan into a new Plan', () => {
|
|
12
|
+
expect([...factory.copy()]).toEqual([1, 0, 1, 0]);
|
|
13
|
+
});
|
|
14
|
+
it('returns independent working Plans', () => {
|
|
15
|
+
const first = factory.copy();
|
|
16
|
+
const second = factory.copy();
|
|
17
|
+
first[0] = 0;
|
|
18
|
+
first[1] = 1;
|
|
19
|
+
expect([...first]).toEqual([0, 1, 1, 0]);
|
|
20
|
+
expect([...second]).toEqual([1, 0, 1, 0]);
|
|
21
|
+
expect([...factory.copy()]).toEqual([1, 0, 1, 0]);
|
|
22
|
+
});
|
|
23
|
+
it('does not expose the initial template through empty', () => {
|
|
24
|
+
const empty = factory.empty();
|
|
25
|
+
empty[1] = 1;
|
|
26
|
+
expect([...factory.copy()]).toEqual([1, 0, 1, 0]);
|
|
27
|
+
});
|
|
28
|
+
it('reinitialises the same Plan in place for a subsequent entity', () => {
|
|
29
|
+
const working = factory.empty();
|
|
30
|
+
factory.copyInto(working);
|
|
31
|
+
working[1] = 1;
|
|
32
|
+
working[2] = 0;
|
|
33
|
+
expect([...working]).toEqual([1, 1, 0, 0]);
|
|
34
|
+
factory.copyInto(working);
|
|
35
|
+
expect([...working]).toEqual([1, 0, 1, 0]);
|
|
36
|
+
});
|
|
37
|
+
it('rejects a mismatched destination length', () => {
|
|
38
|
+
expect(() => factory.copyInto(new Uint8Array(3))).toThrow('Plan length 3 does not match initial plan length 4');
|
|
39
|
+
});
|
|
40
|
+
it('handles an empty graph', () => {
|
|
41
|
+
const emptyFactory = new plan_factory_1.DefaultPlanFactory(new plan_1.InitialPlan([]));
|
|
42
|
+
expect([...emptyFactory.empty()]).toEqual([]);
|
|
43
|
+
expect([...emptyFactory.copy()]).toEqual([]);
|
|
44
|
+
const working = emptyFactory.empty();
|
|
45
|
+
emptyFactory.copyInto(working);
|
|
46
|
+
expect([...working]).toEqual([]);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=plan.factory.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.factory.spec.js","sourceRoot":"","sources":["../../src/plan.factory.spec.ts"],"names":[],"mappings":";;AAAA,iDAAmE;AACnE,iCAAkC;AAElC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,IAAI,kBAAW,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IAC3D,MAAM,OAAO,GAAgB,IAAI,iCAAkB,CAAC,OAAO,CAAC,CAAA;IAE5D,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACjD,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EA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Y,CAAC,KAAK,EAAE,CAAA;QACpC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC9B,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
package/dist/src/plan.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InitialPlan = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Owns an initial activation pattern without exposing its mutable storage.
|
|
6
|
+
* Construct once during planning; copy to the RecordCursor's Plan per entity.
|
|
7
|
+
*/
|
|
8
|
+
class InitialPlan {
|
|
9
|
+
#initial;
|
|
10
|
+
constructor(flags) {
|
|
11
|
+
this.#initial = Uint8Array.from(flags, flag => flag ? 1 : 0);
|
|
12
|
+
}
|
|
13
|
+
get length() {
|
|
14
|
+
return this.#initial.length;
|
|
15
|
+
}
|
|
16
|
+
/** Reuses the destination storage; always clears previous activations. */
|
|
17
|
+
copyInto(plan) {
|
|
18
|
+
if (plan.length !== this.#initial.length) {
|
|
19
|
+
throw new Error(`Plan length ${plan.length} does not match initial plan length ${this.#initial.length}`);
|
|
20
|
+
}
|
|
21
|
+
plan.set(this.#initial);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.InitialPlan = InitialPlan;
|
|
25
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/plan.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH,MAAa,WAAW;IACX,QAAQ,CAAY;IAE7B,YAAY,KAAyB;QACjC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAChE,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAA;IAC/B,CAAC;IAED,0EAA0E;IAC1E,QAAQ,CAAC,IAAU;QACf,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,CAAC,MAAM,uCAAuC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;QAC5G,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3B,CAAC;CACJ;AAlBD,kCAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const plan_1 = require("./plan");
|
|
4
|
+
describe('InitialPlan', () => {
|
|
5
|
+
it('copies exact initial flags', () => {
|
|
6
|
+
const initial = new plan_1.InitialPlan([true, false, true, false]);
|
|
7
|
+
const actual = new Uint8Array(4);
|
|
8
|
+
initial.copyInto(actual);
|
|
9
|
+
expect([...actual]).toEqual([1, 0, 1, 0]);
|
|
10
|
+
expect(initial.length).toEqual(4);
|
|
11
|
+
});
|
|
12
|
+
it('resets a reused plan rather than OR-ing stale flags', () => {
|
|
13
|
+
const initial = new plan_1.InitialPlan([true, false, false]);
|
|
14
|
+
const actual = new Uint8Array([1, 1, 1]);
|
|
15
|
+
initial.copyInto(actual);
|
|
16
|
+
expect([...actual]).toEqual([1, 0, 0]);
|
|
17
|
+
actual[1] = 1;
|
|
18
|
+
initial.copyInto(actual);
|
|
19
|
+
expect([...actual]).toEqual([1, 0, 0]);
|
|
20
|
+
});
|
|
21
|
+
it('does not expose or mutate its template when the working plan changes', () => {
|
|
22
|
+
const flags = [true, false];
|
|
23
|
+
const initial = new plan_1.InitialPlan(flags);
|
|
24
|
+
flags[0] = false;
|
|
25
|
+
flags[1] = true;
|
|
26
|
+
const actual = new Uint8Array(2);
|
|
27
|
+
initial.copyInto(actual);
|
|
28
|
+
expect([...actual]).toEqual([1, 0]);
|
|
29
|
+
actual[0] = 0;
|
|
30
|
+
actual[1] = 1;
|
|
31
|
+
initial.copyInto(actual);
|
|
32
|
+
expect([...actual]).toEqual([1, 0]);
|
|
33
|
+
});
|
|
34
|
+
it('supports an empty graph', () => {
|
|
35
|
+
const initial = new plan_1.InitialPlan([]);
|
|
36
|
+
const actual = new Uint8Array(0);
|
|
37
|
+
initial.copyInto(actual);
|
|
38
|
+
expect([...actual]).toEqual([]);
|
|
39
|
+
});
|
|
40
|
+
it('rejects destination lengths that do not match the graph', () => {
|
|
41
|
+
const initial = new plan_1.InitialPlan([true, false]);
|
|
42
|
+
expect(() => initial.copyInto(new Uint8Array(3))).toThrow('Plan length 3 does not match initial plan length 2');
|
|
43
|
+
expect(() => initial.copyInto(new Uint8Array(1))).toThrow('Plan length 1 does not match initial plan length 2');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=plan.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.spec.js","sourceRoot":"","sources":["../../src/plan.spec.ts"],"names":[],"mappings":";;AAAA,iCAA6C;AAE7C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAClC,MAAM,OAAO,GAAG,IAAI,kBAAW,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;QAC3D,MAAM,MAAM,GAAS,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;QACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACxB,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,C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ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/plan_graph",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Initial execution plans, batch planning, and downstream activation",
|
|
4
|
+
"version": "0.0.16",
|
|
5
|
+
"main": "dist/index",
|
|
6
|
+
"types": "dist/index",
|
|
7
|
+
"browserslist": {
|
|
8
|
+
"development": [
|
|
9
|
+
"last 1 chrome version",
|
|
10
|
+
"last 1 firefox version",
|
|
11
|
+
"last 1 safari version"
|
|
12
|
+
],
|
|
13
|
+
"production": [
|
|
14
|
+
">0.2%",
|
|
15
|
+
"not dead",
|
|
16
|
+
"not op_mini all"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.2.2",
|
|
22
|
+
"@testing-library/jest-dom": "^6.1.4",
|
|
23
|
+
"@types/jest": "^29.0.0",
|
|
24
|
+
"@types/node": "^14.0.0",
|
|
25
|
+
"jest": "^29.0.0",
|
|
26
|
+
"ts-jest": "^29.0.0"
|
|
27
|
+
},
|
|
28
|
+
"eslintConfig": {
|
|
29
|
+
"extends": [
|
|
30
|
+
"react-app",
|
|
31
|
+
"react-app/jest"
|
|
32
|
+
],
|
|
33
|
+
"overrides": [
|
|
34
|
+
{
|
|
35
|
+
"files": [
|
|
36
|
+
"**/*.stories.*"
|
|
37
|
+
],
|
|
38
|
+
"rules": {
|
|
39
|
+
"import/no-anonymous-default-export": "off"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist/index.js",
|
|
46
|
+
"dist/index.d.ts",
|
|
47
|
+
"dist/src/",
|
|
48
|
+
"build/",
|
|
49
|
+
"dist/**/*"
|
|
50
|
+
],
|
|
51
|
+
"keywords": [
|
|
52
|
+
"indexing"
|
|
53
|
+
],
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"repository": "git@github.com:intellimaintain/intellimaintain.git",
|
|
56
|
+
"scripts": {
|
|
57
|
+
"test": "jest --config jest.config.json --env node",
|
|
58
|
+
"test:watch": "npm run test -- --watch"
|
|
59
|
+
}
|
|
6
60
|
}
|