@wandzai/utils 1.0.37 → 1.0.38-WANDZ-1758-affinities-feature-2
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/package.json +1 -1
- package/src/common.d.ts +3 -0
- package/src/common.js +14 -1
- package/src/common.js.map +1 -1
- package/src/logger.d.ts +12 -0
- package/src/logger.js +46 -0
- package/src/logger.js.map +1 -0
- package/src/wandz.d.ts +4 -0
- package/src/wandz.js +13 -1
- package/src/wandz.js.map +1 -1
package/package.json
CHANGED
package/src/common.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export declare const fakeDelay: (milliSec: number) => Promise<unknown>;
|
|
2
|
+
export declare const convertCamelCaeToUnderscore: (term: string) => string;
|
|
3
|
+
export declare const convertUnderscoreToCamelCase: (underscoreString: string) => string;
|
|
4
|
+
export declare const kebabToDisplayName: (kebabCase: string) => string;
|
package/src/common.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fakeDelay = void 0;
|
|
3
|
+
exports.kebabToDisplayName = exports.convertUnderscoreToCamelCase = exports.convertCamelCaeToUnderscore = exports.fakeDelay = void 0;
|
|
4
4
|
const fakeDelay = (milliSec) => new Promise((resolve) => {
|
|
5
5
|
setTimeout(resolve, milliSec);
|
|
6
6
|
});
|
|
7
7
|
exports.fakeDelay = fakeDelay;
|
|
8
|
+
const convertCamelCaeToUnderscore = (term) => term.split(/\.?(?=[A-Z])/).join('_').toLowerCase();
|
|
9
|
+
exports.convertCamelCaeToUnderscore = convertCamelCaeToUnderscore;
|
|
10
|
+
const convertUnderscoreToCamelCase = (underscoreString) => {
|
|
11
|
+
return underscoreString.replace(/_([a-z])/g, (_match, group) => {
|
|
12
|
+
return group.toUpperCase();
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
exports.convertUnderscoreToCamelCase = convertUnderscoreToCamelCase;
|
|
16
|
+
const kebabToDisplayName = (kebabCase) => kebabCase
|
|
17
|
+
.split('-')
|
|
18
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
19
|
+
.join(' ');
|
|
20
|
+
exports.kebabToDisplayName = kebabToDisplayName;
|
|
8
21
|
//# sourceMappingURL=common.js.map
|
package/src/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../libs/utils/src/common.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,EAAE,CAC7C,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACvB,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAHS,QAAA,SAAS,aAGlB"}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../libs/utils/src/common.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,EAAE,CAC7C,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACvB,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAHS,QAAA,SAAS,aAGlB;AAGG,MAAM,2BAA2B,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AAA3G,QAAA,2BAA2B,+BAAgF;AACjH,MAAM,4BAA4B,GAAG,CAAC,gBAAwB,EAAU,EAAE;IAChF,OAAO,gBAAgB,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,MAAc,EAAE,KAAK,EAAE,EAAE;QACtE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;AACJ,CAAC,CAAA;AAJY,QAAA,4BAA4B,gCAIxC;AAEM,MAAM,kBAAkB,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,SAAS;KAChE,KAAK,CAAC,GAAG,CAAC;KACV,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACzD,IAAI,CAAC,GAAG,CAAC,CAAC;AAHC,QAAA,kBAAkB,sBAGnB"}
|
package/src/logger.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Logger } from 'winston';
|
|
2
|
+
export interface IMeta {
|
|
3
|
+
clientTag?: string;
|
|
4
|
+
domain?: string;
|
|
5
|
+
campaignId?: string;
|
|
6
|
+
userId?: string;
|
|
7
|
+
trackingGuid?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface IEnrichedLogger extends Logger {
|
|
10
|
+
createChildLogger(meta?: IMeta): Logger;
|
|
11
|
+
}
|
|
12
|
+
export declare function customLogger(serviceName: string): IEnrichedLogger;
|
package/src/logger.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customLogger = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const winston = require("winston");
|
|
6
|
+
const { createLogger, format, transports } = winston;
|
|
7
|
+
const createEnrichedLogger = (serviceName) => {
|
|
8
|
+
const logger = createLogger({
|
|
9
|
+
level: 'debug',
|
|
10
|
+
defaultMeta: { service: serviceName },
|
|
11
|
+
transports: [
|
|
12
|
+
process.env.NX_LOG_READABLE === 'true'
|
|
13
|
+
? new transports.Console({
|
|
14
|
+
format: format.simple(),
|
|
15
|
+
})
|
|
16
|
+
: new transports.Console({
|
|
17
|
+
format: format.json(),
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
getLogger: () => {
|
|
23
|
+
return logger;
|
|
24
|
+
},
|
|
25
|
+
createChildLogger: (meta) => {
|
|
26
|
+
let combinedMeta = { trackingGuid: (0, uuid_1.v4)() };
|
|
27
|
+
if (meta)
|
|
28
|
+
combinedMeta = { ...combinedMeta, ...meta };
|
|
29
|
+
return logger.child(combinedMeta);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
function customLogger(serviceName) {
|
|
34
|
+
const enrichedLogger = createEnrichedLogger(serviceName);
|
|
35
|
+
const handler = {
|
|
36
|
+
get: function (target, prop, receiver) {
|
|
37
|
+
if (prop === 'createChildLogger') {
|
|
38
|
+
return target.createChildLogger;
|
|
39
|
+
}
|
|
40
|
+
return target.getLogger()[prop];
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return new Proxy(enrichedLogger, handler);
|
|
44
|
+
}
|
|
45
|
+
exports.customLogger = customLogger;
|
|
46
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../libs/utils/src/logger.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAClC,mCAAmC;AAGnC,MAAM,EAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAC,GAAG,OAAO,CAAC;AAcnD,MAAM,oBAAoB,GAAG,CAAC,WAAmB,EAAE,EAAE;IACjD,MAAM,MAAM,GAAG,YAAY,CAAC;QACxB,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,EAAC,OAAO,EAAE,WAAW,EAAC;QACnC,UAAU,EAAE;YACR,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,MAAM;gBAClC,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC;oBACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;iBAC1B,CAAC;gBACF,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC;oBACrB,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;iBACxB,CAAC;SACT;KACJ,CAAC,CAAC;IAEH,OAAO;QACH,SAAS,EAAE,GAAG,EAAE;YACZ,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,iBAAiB,EAAE,CAAC,IAAY,EAAE,EAAE;YAChC,IAAI,YAAY,GAAG,EAAC,YAAY,EAAE,IAAA,SAAM,GAAE,EAAC,CAAC;YAC5C,IAAI,IAAI;gBAAE,YAAY,GAAG,EAAC,GAAG,YAAY,EAAE,GAAG,IAAI,EAAC,CAAC;YACpD,OAAO,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACtC,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,SAAgB,YAAY,CAAC,WAAmB;IAC5C,MAAM,cAAc,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG;QACZ,GAAG,EAAE,UAAU,MAAM,EAAE,IAAI,EAAE,QAAQ;YACjC,IAAI,IAAI,KAAK,mBAAmB,EAAE,CAAC;gBAC/B,OAAO,MAAM,CAAC,iBAAiB,CAAC;YACpC,CAAC;YAED,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;KACJ,CAAC;IAEF,OAAO,IAAI,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAbD,oCAaC"}
|
package/src/wandz.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
+
import { ICustomAiFeature, IEventBasedCustomAiFeatureConfig, IAffinityBasedCustomAiFeatureConfig, IStorageBasedCustomAiFeatureConfig } from '@wandzai/wandz-interfaces';
|
|
1
2
|
export declare const entityTechNameBuilder: (entityName: string) => string;
|
|
3
|
+
export declare function isAffinityBasedCustomAiFeature(feature: ICustomAiFeature): feature is IAffinityBasedCustomAiFeatureConfig;
|
|
4
|
+
export declare function isStorageBasedCustomAiFeature(feature: ICustomAiFeature): feature is IStorageBasedCustomAiFeatureConfig;
|
|
5
|
+
export declare function isEventBasedCustomAiFeature(feature: ICustomAiFeature): feature is IEventBasedCustomAiFeatureConfig;
|
package/src/wandz.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.entityTechNameBuilder = void 0;
|
|
3
|
+
exports.isEventBasedCustomAiFeature = exports.isStorageBasedCustomAiFeature = exports.isAffinityBasedCustomAiFeature = exports.entityTechNameBuilder = void 0;
|
|
4
4
|
const entityTechNameBuilder = (entityName) => {
|
|
5
5
|
return entityName
|
|
6
6
|
.toLowerCase()
|
|
@@ -8,4 +8,16 @@ const entityTechNameBuilder = (entityName) => {
|
|
|
8
8
|
.replace(/[^\w_.]+/g, '');
|
|
9
9
|
};
|
|
10
10
|
exports.entityTechNameBuilder = entityTechNameBuilder;
|
|
11
|
+
function isAffinityBasedCustomAiFeature(feature) {
|
|
12
|
+
return (feature.affinityType !== null);
|
|
13
|
+
}
|
|
14
|
+
exports.isAffinityBasedCustomAiFeature = isAffinityBasedCustomAiFeature;
|
|
15
|
+
function isStorageBasedCustomAiFeature(feature) {
|
|
16
|
+
return (feature.storageLogic !== null);
|
|
17
|
+
}
|
|
18
|
+
exports.isStorageBasedCustomAiFeature = isStorageBasedCustomAiFeature;
|
|
19
|
+
function isEventBasedCustomAiFeature(feature) {
|
|
20
|
+
return feature.eventLogic !== null;
|
|
21
|
+
}
|
|
22
|
+
exports.isEventBasedCustomAiFeature = isEventBasedCustomAiFeature;
|
|
11
23
|
//# sourceMappingURL=wandz.js.map
|
package/src/wandz.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wandz.js","sourceRoot":"","sources":["../../../../libs/utils/src/wandz.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"wandz.js","sourceRoot":"","sources":["../../../../libs/utils/src/wandz.ts"],"names":[],"mappings":";;;AAMO,MAAM,qBAAqB,GAAG,CAAC,UAAkB,EAAE,EAAE;IAK3D,OAAO,UAAU;SACf,WAAW,EAAE;SACb,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;SAClB,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC,CAAC;AATW,QAAA,qBAAqB,yBAShC;AAEF,SAAgB,8BAA8B,CAC7C,OAAyB;IAEzB,OAAO,CACL,OAA+C,CAAC,YAAY,KAAK,IAAI,CACtE,CAAC;AACH,CAAC;AAND,wEAMC;AAED,SAAgB,6BAA6B,CAC5C,OAAyB;IAEzB,OAAO,CACL,OAA8C,CAAC,YAAY,KAAK,IAAI,CACrE,CAAC;AACH,CAAC;AAND,sEAMC;AAED,SAAgB,2BAA2B,CAC1C,OAAyB;IAEzB,OAAQ,OAA4C,CAAC,UAAU,KAAK,IAAI,CAAC;AAC1E,CAAC;AAJD,kEAIC"}
|