@bluecopa/core 0.1.74 → 0.1.75
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/index.es.js +260 -35
- package/dist/index.es.js.map +1 -1
- package/dist/utils/applySolutionBindings.d.ts +36 -0
- package/package.json +2 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BindableDefinitionType } from '../../../models/src/lib/utils/definitionBindingsUtil';
|
|
2
|
+
/**
|
|
3
|
+
* Mirrors the binding-application step in
|
|
4
|
+
* `packages/models/src/lib/utils/definitionApiUtil.ts:getDefinition()` for
|
|
5
|
+
* SDK consumers (useMetric, useWorkbook, etc).
|
|
6
|
+
*
|
|
7
|
+
* The BFF route `/api/v1/solution/bindings` reads the request's solution
|
|
8
|
+
* headers (auto-attached by `apiClient` from `copaSetConfig`), fetches the
|
|
9
|
+
* appropriate bindings server-side, and returns `{ bindings }`.
|
|
10
|
+
*
|
|
11
|
+
* `applySolutionBindings(fileRead)` does fetch + apply in one shot. When
|
|
12
|
+
* applying to multiple files in the same request lifecycle (e.g. both
|
|
13
|
+
* `definitionModel` and `customModel` inside `hydrateWorksheet`), call
|
|
14
|
+
* `fetchSolutionBindings()` once and pass the result to
|
|
15
|
+
* `applyBindings(fileRead, bindings, type?)` to avoid duplicate fetches.
|
|
16
|
+
*
|
|
17
|
+
* Returns the input unchanged when no solution context is active or the
|
|
18
|
+
* fetch fails — fail-open, same as the shell's `getDefinition` path.
|
|
19
|
+
*/
|
|
20
|
+
type Bindings = Record<string, unknown>;
|
|
21
|
+
/** Fetch the bindings map once. Returns `{}` on any failure or invalid shape. */
|
|
22
|
+
export declare function fetchSolutionBindings(): Promise<Bindings>;
|
|
23
|
+
/**
|
|
24
|
+
* Apply pre-fetched bindings to a file. Use this when you've already
|
|
25
|
+
* fetched bindings (e.g., once at the top of a flow) and want to apply
|
|
26
|
+
* them to multiple JSONs without re-fetching.
|
|
27
|
+
*/
|
|
28
|
+
export declare function applyBindings<T>(fileRead: T, bindings: Bindings, definitionType?: BindableDefinitionType): T;
|
|
29
|
+
/**
|
|
30
|
+
* Convenience wrapper: fetch bindings + apply in one call. Each invocation
|
|
31
|
+
* triggers its own `/solution/bindings` request, so prefer
|
|
32
|
+
* `fetchSolutionBindings` + `applyBindings` when applying to multiple
|
|
33
|
+
* files in the same flow.
|
|
34
|
+
*/
|
|
35
|
+
export declare function applySolutionBindings<T>(fileRead: T, definitionType?: BindableDefinitionType): Promise<T>;
|
|
36
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluecopa/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.75",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.es.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=18.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"axios": "1.15.
|
|
42
|
+
"axios": "1.15.2",
|
|
43
43
|
"centrifuge": "5.2.2",
|
|
44
44
|
"lodash": "4.18.1",
|
|
45
45
|
"pusher-js": "^8.3.0",
|