@cabloy/utils 2.0.17 → 2.0.19
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.js +16 -1
- package/dist/utils.d.ts +7 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -217,6 +217,7 @@ function combineQueries(pagePath, queries) {
|
|
|
217
217
|
const PATH_PARAM_RE = /\{([^{}/]+)\}/g;
|
|
218
218
|
const PATH_PARAM_RE2 = /:([^/]+)/g;
|
|
219
219
|
function defaultPathSerializer(pathName, pathParams) {
|
|
220
|
+
if (!pathName) return undefined;
|
|
220
221
|
pathParams = pathParams ?? {};
|
|
221
222
|
for (const item of [PATH_PARAM_RE, PATH_PARAM_RE2]) {
|
|
222
223
|
pathName = pathName.replace(item, (_, _part) => {
|
|
@@ -264,6 +265,20 @@ function forEachSync(arr, order, fn) {
|
|
|
264
265
|
}
|
|
265
266
|
}
|
|
266
267
|
|
|
268
|
+
// for hold on CustomRefImpl
|
|
269
|
+
function objectAssign(...args) {
|
|
270
|
+
const target = args[0];
|
|
271
|
+
for (let i = 1; i < args.length; i++) {
|
|
272
|
+
const source = args[i];
|
|
273
|
+
const keys = Object.getOwnPropertyNames(source);
|
|
274
|
+
for (const key of keys) {
|
|
275
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
276
|
+
target[key] = desc?.value;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return target;
|
|
280
|
+
}
|
|
281
|
+
|
|
267
282
|
const celEnvBase = new Environment({
|
|
268
283
|
unlistedVariablesAreDyn: true,
|
|
269
284
|
enableOptionalTypes: true,
|
|
@@ -496,4 +511,4 @@ function zodCustomError(path, message) {
|
|
|
496
511
|
return error;
|
|
497
512
|
}
|
|
498
513
|
|
|
499
|
-
export { StringPrefixCel, StringPrefixRaw, StringPrefixRegexp, addLeadingSlash, catchError, catchErrorSync, cel, celEnvBase, checkMeta, combineApiPath, combineApiPathControllerAndAction, combineApiPathControllerAndActionRaw, combineParamsAndQuery, combineQueries, combineResourceName, combineResourceNameParts, createFunction, defaultPathSerializer, deprecated, ensureArray, evaluate, evaluateExpressions, evaluateSimple, forEach, forEachSync, getProperty, getPropertyObject, getRandomInt, hasProperty, hashkey, isClass, isClassStrict, isConstructor, isEmpty, isEmptyObject, isFunction, isNil, isNilOrEmptyString, isNumber, isObject, isPlainObject, isPromise, isString, isSymbol, isUndefined, matchSelector, normalizePath, parse, raw, regexp, replaceTemplate, safeBoolean, setProperty, sleep, stringLazy, stripEndSlash, zodCustomError };
|
|
514
|
+
export { StringPrefixCel, StringPrefixRaw, StringPrefixRegexp, addLeadingSlash, catchError, catchErrorSync, cel, celEnvBase, checkMeta, combineApiPath, combineApiPathControllerAndAction, combineApiPathControllerAndActionRaw, combineParamsAndQuery, combineQueries, combineResourceName, combineResourceNameParts, createFunction, defaultPathSerializer, deprecated, ensureArray, evaluate, evaluateExpressions, evaluateSimple, forEach, forEachSync, getProperty, getPropertyObject, getRandomInt, hasProperty, hashkey, isClass, isClassStrict, isConstructor, isEmpty, isEmptyObject, isFunction, isNil, isNilOrEmptyString, isNumber, isObject, isPlainObject, isPromise, isString, isSymbol, isUndefined, matchSelector, normalizePath, objectAssign, parse, raw, regexp, replaceTemplate, safeBoolean, setProperty, sleep, stringLazy, stripEndSlash, zodCustomError };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export interface IParamsAndQuery {
|
|
2
|
+
params?: Record<string, any>;
|
|
3
|
+
query?: Record<string, any>;
|
|
4
|
+
}
|
|
1
5
|
export declare function deprecated(oldUsage: any, newUsage: any): void;
|
|
2
6
|
export declare function catchError<T>(fnMethod: (...args: any[]) => Promise<T>): Promise<[T, undefined] | [undefined, Error]>;
|
|
3
7
|
export declare function catchErrorSync<T>(fnMethod: (...args: any[]) => T): [T, undefined] | [undefined, Error];
|
|
@@ -8,15 +12,13 @@ export declare function hasProperty(obj: object | undefined, name: string, sep?:
|
|
|
8
12
|
export declare function getProperty<T>(obj: object | undefined, name: string, sep?: string): T | undefined;
|
|
9
13
|
export declare function getPropertyObject<T>(obj: object | undefined, name: string, sep?: string): T | undefined;
|
|
10
14
|
export declare function getRandomInt(size: number, start?: number): number;
|
|
11
|
-
export declare function combineParamsAndQuery(path
|
|
12
|
-
params?: object;
|
|
13
|
-
query?: object;
|
|
14
|
-
}): string;
|
|
15
|
+
export declare function combineParamsAndQuery(path?: string, options?: IParamsAndQuery): string;
|
|
15
16
|
export declare function combineQueries(pagePath?: string, queries?: Record<string, any>): string;
|
|
16
|
-
export declare function defaultPathSerializer(pathName
|
|
17
|
+
export declare function defaultPathSerializer<T extends string | undefined>(pathName?: T, pathParams?: Record<string, any>): T extends string ? string : undefined;
|
|
17
18
|
export declare function ensureArray(arr: any, sep?: string): any[] | undefined;
|
|
18
19
|
export declare function stringLazy(fn: () => string): {
|
|
19
20
|
toString: () => string;
|
|
20
21
|
};
|
|
21
22
|
export declare function forEach<T>(arr: T[], order: boolean, fn: (item: T, index: number) => Promise<void>): Promise<void>;
|
|
22
23
|
export declare function forEachSync<T>(arr: T[], order: boolean, fn: (item: T, index: number) => void): void;
|
|
24
|
+
export declare function objectAssign<T = any>(...args: any[]): T;
|