@gooddata/util 11.53.0 → 11.54.0-alpha.1
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/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/testUtils.d.ts +16 -0
- package/esm/testUtils.d.ts.map +1 -1
- package/esm/testUtils.js +37 -0
- package/esm/util.d.ts +17 -0
- package/package.json +3 -3
package/esm/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export { shallowEqualObjects } from "./objectUtils.js";
|
|
|
11
11
|
export { type IShortenTextOptions, hashCodeString, randomString, shortenText, escapeRegExp, simplifyText, parseStringToArray, } from "./stringUtils.js";
|
|
12
12
|
export { removeMetadata, sanitizeLocaleForMoment } from "./translationUtils.js";
|
|
13
13
|
export { type GuardType, type EmptyObject, combineGuards } from "./typesUtils.js";
|
|
14
|
-
export { type MatcherFunction, type ConsoleFunction, type Matcher, type SpecificMatcherFunction, type ConsoleType, type WaitForFn, delay, suppressConsole, createTightWaitFor, } from "./testUtils.js";
|
|
14
|
+
export { type MatcherFunction, type ConsoleFunction, type Matcher, type SpecificMatcherFunction, type ConsoleType, type WaitForFn, delay, strictBarrel, suppressConsole, createTightWaitFor, } from "./testUtils.js";
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACH,KAAK,mBAAmB,EACxB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,kBAAkB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,EACL,eAAe,EACf,kBAAkB,GACrB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACH,KAAK,mBAAmB,EACxB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,kBAAkB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,EACL,YAAY,EACZ,eAAe,EACf,kBAAkB,GACrB,MAAM,gBAAgB,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -13,4 +13,4 @@ export { shallowEqualObjects } from "./objectUtils.js";
|
|
|
13
13
|
export { hashCodeString, randomString, shortenText, escapeRegExp, simplifyText, parseStringToArray, } from "./stringUtils.js";
|
|
14
14
|
export { removeMetadata, sanitizeLocaleForMoment } from "./translationUtils.js";
|
|
15
15
|
export { combineGuards } from "./typesUtils.js";
|
|
16
|
-
export { delay, suppressConsole, createTightWaitFor, } from "./testUtils.js";
|
|
16
|
+
export { delay, strictBarrel, suppressConsole, createTightWaitFor, } from "./testUtils.js";
|
package/esm/testUtils.d.ts
CHANGED
|
@@ -5,6 +5,22 @@
|
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
7
|
export declare function delay(timeout?: number): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Guards a hand-assembled stand-in for a package's barrel so that reaching for an export it does not
|
|
10
|
+
* carry throws on the spot, naming the package and what is missing.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* A test setup can cut a suite's import time by replacing a large barrel with the handful of real modules
|
|
14
|
+
* it actually uses, reached directly. Left unguarded such a stand-in degrades silently: the day someone
|
|
15
|
+
* imports something new out of that package the import resolves to `undefined`, and the failure surfaces
|
|
16
|
+
* somewhere else entirely, in a test that has nothing to do with the change.
|
|
17
|
+
*
|
|
18
|
+
* @param packageName - name of the package whose barrel is being stood in for
|
|
19
|
+
* @param exports - the exports the stand-in carries
|
|
20
|
+
* @returns the exports, guarded against reads of anything they do not carry
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function strictBarrel<T extends object>(packageName: string, exports: T): T;
|
|
8
24
|
/**
|
|
9
25
|
* A matcher for suppressConsole
|
|
10
26
|
*
|
package/esm/testUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,OAAO,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhD;AAED;;;;GAIG;AACH,MAAM,MAAM,OAAO,GACb;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,YAAY,CAAC;IAAC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B,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACxB,IAAI,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,EAClC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,uBAAuB,GAC/C,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAElB;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAyCzG;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,EACtB,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC9B,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,KAChD,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhB;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAC9B,OAAO,EAAE,SAAS,EAClB,QAAQ,GAAE,MAAU,GACrB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAEnD"}
|
package/esm/testUtils.js
CHANGED
|
@@ -13,6 +13,43 @@ export function delay(timeout = 0) {
|
|
|
13
13
|
}, timeout);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Property reads that the module plumbing (a mock registry, `await import(...)`, React, ...) performs on
|
|
18
|
+
* a namespace object without meaning to read an export. They must answer `undefined` rather than trip
|
|
19
|
+
* the guard in {@link strictBarrel}.
|
|
20
|
+
*/
|
|
21
|
+
const NAMESPACE_PROBES = new Set(["then", "default", "__esModule", "$$typeof", "toJSON", "constructor"]);
|
|
22
|
+
/**
|
|
23
|
+
* Guards a hand-assembled stand-in for a package's barrel so that reaching for an export it does not
|
|
24
|
+
* carry throws on the spot, naming the package and what is missing.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* A test setup can cut a suite's import time by replacing a large barrel with the handful of real modules
|
|
28
|
+
* it actually uses, reached directly. Left unguarded such a stand-in degrades silently: the day someone
|
|
29
|
+
* imports something new out of that package the import resolves to `undefined`, and the failure surfaces
|
|
30
|
+
* somewhere else entirely, in a test that has nothing to do with the change.
|
|
31
|
+
*
|
|
32
|
+
* @param packageName - name of the package whose barrel is being stood in for
|
|
33
|
+
* @param exports - the exports the stand-in carries
|
|
34
|
+
* @returns the exports, guarded against reads of anything they do not carry
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export function strictBarrel(packageName, exports) {
|
|
38
|
+
return new Proxy(exports, {
|
|
39
|
+
get(target, property, receiver) {
|
|
40
|
+
// Own properties only: a real module namespace inherits from nothing, so anything reached
|
|
41
|
+
// through the stand-in's prototype (`toString`, `valueOf`, ...) is not an export it carries.
|
|
42
|
+
if (typeof property !== "string" ||
|
|
43
|
+
Object.hasOwn(target, property) ||
|
|
44
|
+
NAMESPACE_PROBES.has(property)) {
|
|
45
|
+
return Reflect.get(target, property, receiver);
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`"${packageName}" is routed around its barrel in the test setup to keep the suite's ` +
|
|
48
|
+
`import time down, and the stand-in does not export "${property}". Add it to the ` +
|
|
49
|
+
`stand-in, importing it from its own module inside the package rather than from the barrel.`);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
16
53
|
function suppressConsoleBase(fn, matcherFn) {
|
|
17
54
|
const types = ["error", "warn", "log", "debug", "info"];
|
|
18
55
|
const originals = {};
|
package/esm/util.d.ts
CHANGED
|
@@ -192,6 +192,23 @@ export declare function simplifyText(value: string | number | null): string;
|
|
|
192
192
|
*/
|
|
193
193
|
export declare type SpecificMatcherFunction = (message: string) => boolean;
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Guards a hand-assembled stand-in for a package's barrel so that reaching for an export it does not
|
|
197
|
+
* carry throws on the spot, naming the package and what is missing.
|
|
198
|
+
*
|
|
199
|
+
* @remarks
|
|
200
|
+
* A test setup can cut a suite's import time by replacing a large barrel with the handful of real modules
|
|
201
|
+
* it actually uses, reached directly. Left unguarded such a stand-in degrades silently: the day someone
|
|
202
|
+
* imports something new out of that package the import resolves to `undefined`, and the failure surfaces
|
|
203
|
+
* somewhere else entirely, in a test that has nothing to do with the change.
|
|
204
|
+
*
|
|
205
|
+
* @param packageName - name of the package whose barrel is being stood in for
|
|
206
|
+
* @param exports - the exports the stand-in carries
|
|
207
|
+
* @returns the exports, guarded against reads of anything they do not carry
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
210
|
+
export declare function strictBarrel<T extends object>(packageName: string, exports: T): T;
|
|
211
|
+
|
|
195
212
|
/**
|
|
196
213
|
* Suppresses certain console outputs
|
|
197
214
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/util",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.54.0-alpha.1",
|
|
4
4
|
"description": "GoodData Utility Functions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "GoodData",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"oxlint-tsgolint": "0.15.0",
|
|
48
48
|
"typescript": "5.9.3",
|
|
49
49
|
"vitest": "4.1.8",
|
|
50
|
-
"@gooddata/eslint-config": "11.
|
|
51
|
-
"@gooddata/oxlint-config": "11.
|
|
50
|
+
"@gooddata/eslint-config": "11.54.0-alpha.1",
|
|
51
|
+
"@gooddata/oxlint-config": "11.54.0-alpha.1"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"_phase:build": "npm run build",
|