@polintpro/proposit-core 0.7.3 → 0.8.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/README.md +64 -20
- package/dist/extensions/basics/schemata.d.ts +0 -5
- package/dist/extensions/basics/schemata.d.ts.map +1 -1
- package/dist/lib/consts.d.ts.map +1 -1
- package/dist/lib/consts.js +2 -21
- package/dist/lib/consts.js.map +1 -1
- package/dist/lib/core/argument-engine.d.ts +1 -14
- package/dist/lib/core/argument-engine.d.ts.map +1 -1
- package/dist/lib/core/argument-engine.js +0 -128
- package/dist/lib/core/argument-engine.js.map +1 -1
- package/dist/lib/core/argument-library.d.ts +84 -0
- package/dist/lib/core/argument-library.d.ts.map +1 -0
- package/dist/lib/core/argument-library.js +122 -0
- package/dist/lib/core/argument-library.js.map +1 -0
- package/dist/lib/core/diff.d.ts +0 -10
- package/dist/lib/core/diff.d.ts.map +1 -1
- package/dist/lib/core/diff.js +0 -31
- package/dist/lib/core/diff.js.map +1 -1
- package/dist/lib/core/fork-library.d.ts +17 -0
- package/dist/lib/core/fork-library.d.ts.map +1 -0
- package/dist/lib/core/fork-library.js +62 -0
- package/dist/lib/core/fork-library.js.map +1 -0
- package/dist/lib/core/fork-namespace.d.ts +19 -0
- package/dist/lib/core/fork-namespace.d.ts.map +1 -0
- package/dist/lib/core/fork-namespace.js +86 -0
- package/dist/lib/core/fork-namespace.js.map +1 -0
- package/dist/lib/core/fork.d.ts +30 -0
- package/dist/lib/core/fork.d.ts.map +1 -0
- package/dist/lib/core/fork.js +125 -0
- package/dist/lib/core/fork.js.map +1 -0
- package/dist/lib/core/interfaces/index.d.ts +1 -1
- package/dist/lib/core/interfaces/index.d.ts.map +1 -1
- package/dist/lib/core/interfaces/library.interfaces.d.ts +61 -0
- package/dist/lib/core/interfaces/library.interfaces.d.ts.map +1 -1
- package/dist/lib/core/proposit-core.d.ts +110 -0
- package/dist/lib/core/proposit-core.d.ts.map +1 -0
- package/dist/lib/core/proposit-core.js +357 -0
- package/dist/lib/core/proposit-core.js.map +1 -0
- package/dist/lib/index.d.ts +11 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +8 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/schemata/argument.d.ts +0 -2
- package/dist/lib/schemata/argument.d.ts.map +1 -1
- package/dist/lib/schemata/argument.js +0 -6
- package/dist/lib/schemata/argument.js.map +1 -1
- package/dist/lib/schemata/fork.d.ts +76 -0
- package/dist/lib/schemata/fork.d.ts.map +1 -0
- package/dist/lib/schemata/fork.js +55 -0
- package/dist/lib/schemata/fork.js.map +1 -0
- package/dist/lib/schemata/index.d.ts +1 -0
- package/dist/lib/schemata/index.d.ts.map +1 -1
- package/dist/lib/schemata/index.js +1 -0
- package/dist/lib/schemata/index.js.map +1 -1
- package/dist/lib/schemata/propositional.d.ts +0 -39
- package/dist/lib/schemata/propositional.d.ts.map +1 -1
- package/dist/lib/schemata/propositional.js +0 -30
- package/dist/lib/schemata/propositional.js.map +1 -1
- package/dist/lib/types/fork.d.ts +0 -7
- package/dist/lib/types/fork.d.ts.map +1 -1
- package/dist/lib/types/validation.d.ts +2 -1
- package/dist/lib/types/validation.d.ts.map +1 -1
- package/dist/lib/types/validation.js +2 -0
- package/dist/lib/types/validation.js.map +1 -1
- package/dist/lib/utils/changeset.d.ts +124 -0
- package/dist/lib/utils/changeset.d.ts.map +1 -0
- package/dist/lib/utils/changeset.js +221 -0
- package/dist/lib/utils/changeset.js.map +1 -0
- package/dist/lib/utils/lookup.d.ts +47 -0
- package/dist/lib/utils/lookup.d.ts.map +1 -0
- package/dist/lib/utils/lookup.js +62 -0
- package/dist/lib/utils/lookup.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { TClaimLookup, TSourceLookup, TClaimSourceLookup } from "../core/interfaces/library.interfaces.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a keyed lookup from an array of items. Items are indexed by a
|
|
4
|
+
* composite string key (typically `"id:version"`), and the returned object
|
|
5
|
+
* exposes a `get(id, version)` method that reconstructs the same key
|
|
6
|
+
* internally.
|
|
7
|
+
*
|
|
8
|
+
* Use this to build the `TClaimLookup` or `TSourceLookup` required by
|
|
9
|
+
* `ArgumentEngine`'s constructor from flat arrays (e.g. database query
|
|
10
|
+
* results).
|
|
11
|
+
*
|
|
12
|
+
* @param items - The array of items to index.
|
|
13
|
+
* @param getKey - A function that produces the composite key for each item.
|
|
14
|
+
* Must return a string of the form `"id:version"` so that the returned
|
|
15
|
+
* `get(id, version)` method can reconstruct it.
|
|
16
|
+
* @returns An object with a `get(id, version)` method that looks up items
|
|
17
|
+
* by reconstructing the composite key. Returns `undefined` if no item
|
|
18
|
+
* matches.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const claimLookup = createLookup(claims, (c) => `${c.id}:${c.version}`)
|
|
23
|
+
* const sourceLookup = createLookup(sources, (s) => `${s.id}:${s.version}`)
|
|
24
|
+
* const engine = new ArgumentEngine(arg, claimLookup, sourceLookup, ...)
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function createLookup<T>(items: T[], getKey: (item: T) => string): {
|
|
28
|
+
get(id: string, version: number): T | undefined;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* A no-op claim lookup that always returns `undefined`. Use this when the
|
|
32
|
+
* consumer does not use claims (e.g. an argument with no claim-bound
|
|
33
|
+
* variables).
|
|
34
|
+
*/
|
|
35
|
+
export declare const EMPTY_CLAIM_LOOKUP: TClaimLookup;
|
|
36
|
+
/**
|
|
37
|
+
* A no-op source lookup that always returns `undefined`. Use this when the
|
|
38
|
+
* consumer does not use sources.
|
|
39
|
+
*/
|
|
40
|
+
export declare const EMPTY_SOURCE_LOOKUP: TSourceLookup;
|
|
41
|
+
/**
|
|
42
|
+
* A no-op claim-source association lookup that always returns `undefined`
|
|
43
|
+
* or empty arrays. Use this when the consumer does not use claim-source
|
|
44
|
+
* associations.
|
|
45
|
+
*/
|
|
46
|
+
export declare const EMPTY_CLAIM_SOURCE_LOOKUP: TClaimSourceLookup;
|
|
47
|
+
//# sourceMappingURL=lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,YAAY,EACZ,aAAa,EACb,kBAAkB,EACrB,MAAM,0CAA0C,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC1B,KAAK,EAAE,CAAC,EAAE,EACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAC5B;IAAE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAA;CAAE,CAUrD;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,YAEhC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAEjC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,kBAIvC,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a keyed lookup from an array of items. Items are indexed by a
|
|
3
|
+
* composite string key (typically `"id:version"`), and the returned object
|
|
4
|
+
* exposes a `get(id, version)` method that reconstructs the same key
|
|
5
|
+
* internally.
|
|
6
|
+
*
|
|
7
|
+
* Use this to build the `TClaimLookup` or `TSourceLookup` required by
|
|
8
|
+
* `ArgumentEngine`'s constructor from flat arrays (e.g. database query
|
|
9
|
+
* results).
|
|
10
|
+
*
|
|
11
|
+
* @param items - The array of items to index.
|
|
12
|
+
* @param getKey - A function that produces the composite key for each item.
|
|
13
|
+
* Must return a string of the form `"id:version"` so that the returned
|
|
14
|
+
* `get(id, version)` method can reconstruct it.
|
|
15
|
+
* @returns An object with a `get(id, version)` method that looks up items
|
|
16
|
+
* by reconstructing the composite key. Returns `undefined` if no item
|
|
17
|
+
* matches.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const claimLookup = createLookup(claims, (c) => `${c.id}:${c.version}`)
|
|
22
|
+
* const sourceLookup = createLookup(sources, (s) => `${s.id}:${s.version}`)
|
|
23
|
+
* const engine = new ArgumentEngine(arg, claimLookup, sourceLookup, ...)
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function createLookup(items, getKey) {
|
|
27
|
+
const map = new Map();
|
|
28
|
+
for (const item of items) {
|
|
29
|
+
map.set(getKey(item), item);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
get(id, version) {
|
|
33
|
+
return map.get(`${id}:${version}`);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A no-op claim lookup that always returns `undefined`. Use this when the
|
|
39
|
+
* consumer does not use claims (e.g. an argument with no claim-bound
|
|
40
|
+
* variables).
|
|
41
|
+
*/
|
|
42
|
+
export const EMPTY_CLAIM_LOOKUP = {
|
|
43
|
+
get: () => undefined,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A no-op source lookup that always returns `undefined`. Use this when the
|
|
47
|
+
* consumer does not use sources.
|
|
48
|
+
*/
|
|
49
|
+
export const EMPTY_SOURCE_LOOKUP = {
|
|
50
|
+
get: () => undefined,
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* A no-op claim-source association lookup that always returns `undefined`
|
|
54
|
+
* or empty arrays. Use this when the consumer does not use claim-source
|
|
55
|
+
* associations.
|
|
56
|
+
*/
|
|
57
|
+
export const EMPTY_CLAIM_SOURCE_LOOKUP = {
|
|
58
|
+
getForClaim: () => [],
|
|
59
|
+
getForSource: () => [],
|
|
60
|
+
get: () => undefined,
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=lookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../../src/lib/utils/lookup.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,YAAY,CACxB,KAAU,EACV,MAA2B;IAE3B,MAAM,GAAG,GAAG,IAAI,GAAG,EAAa,CAAA;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;IAC/B,CAAC;IACD,OAAO;QACH,GAAG,CAAC,EAAU,EAAE,OAAe;YAC3B,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,OAAO,EAAE,CAAC,CAAA;QACtC,CAAC;KACJ,CAAA;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC5C,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;CACvB,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAkB;IAC9C,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;CACvB,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAuB;IACzD,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,YAAY,EAAE,GAAG,EAAE,CAAC,EAAE;IACtB,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;CACvB,CAAA"}
|