@alanszp/core 17.0.0 → 17.1.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.
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ presets: [
3
+ ["@babel/preset-env", { targets: { node: "current" } }],
4
+ "@babel/preset-typescript",
5
+ ],
6
+ };
@@ -1 +1,5 @@
1
+ export declare function appName(): string;
2
+ export declare function roleName(): string | undefined;
3
+ export declare function appEnv(): string;
1
4
  export declare function appIdentifier(): string;
5
+ export declare function concatLifecycleChain(previous: string | undefined | null, currentIdentifier: string): string;
@@ -1,19 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appName = appName;
4
+ exports.roleName = roleName;
5
+ exports.appEnv = appEnv;
3
6
  exports.appIdentifier = appIdentifier;
7
+ exports.concatLifecycleChain = concatLifecycleChain;
4
8
  const shortEnvName = {
5
9
  production: "prd",
6
10
  staging: "stg",
7
11
  development: "dev",
8
12
  test: "tst",
9
13
  };
10
- function appIdentifier() {
11
- var _a, _b, _c;
12
- const appName = (_b = (_a = process.env.SERVICE_NAME) !== null && _a !== void 0 ? _a : process.env.API_ORIGIN_NAME) !== null && _b !== void 0 ? _b : "undef";
13
- const roleName = process.env.ROLE_NAME;
14
- const env = process.env.NODE_ENV
15
- ? (_c = shortEnvName[process.env.NODE_ENV]) !== null && _c !== void 0 ? _c : process.env.NODE_ENV
14
+ function appName() {
15
+ var _a, _b;
16
+ return (_b = (_a = process.env.SERVICE_NAME) !== null && _a !== void 0 ? _a : process.env.API_ORIGIN_NAME) !== null && _b !== void 0 ? _b : "undef";
17
+ }
18
+ function roleName() {
19
+ return process.env.ROLE_NAME;
20
+ }
21
+ function appEnv() {
22
+ var _a;
23
+ return process.env.NODE_ENV
24
+ ? (_a = shortEnvName[process.env.NODE_ENV]) !== null && _a !== void 0 ? _a : process.env.NODE_ENV
16
25
  : "dev";
17
- return `${roleName ? `${appName}:${roleName}` : appName}:${env}`;
26
+ }
27
+ function appIdentifier() {
28
+ const name = appName();
29
+ const role = roleName();
30
+ const env = appEnv();
31
+ return `${role ? `${name}:${role}` : name}:${env}`;
32
+ }
33
+ const LIFECYCLE_CHAIN_REGEX = /^(.*?)(X(\d+))?$/;
34
+ function concatLifecycleChain(previous, currentIdentifier) {
35
+ if (!previous) {
36
+ return currentIdentifier;
37
+ }
38
+ const parts = previous.split(",");
39
+ const lastPart = parts[parts.length - 1];
40
+ const match = lastPart.match(LIFECYCLE_CHAIN_REGEX);
41
+ if (match) {
42
+ const [, base, , countStr] = match;
43
+ if (base === currentIdentifier) {
44
+ const count = countStr ? parseInt(countStr, 10) : 1;
45
+ parts[parts.length - 1] = `${currentIdentifier}X${count + 1}`;
46
+ return parts.join(",");
47
+ }
48
+ }
49
+ return `${previous},${currentIdentifier}`;
18
50
  }
19
51
  //# sourceMappingURL=appIdentifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"appIdentifier.js","sourceRoot":"","sources":["../../src/app/appIdentifier.ts"],"names":[],"mappings":";;AAOA,sCAWC;AAlBD,MAAM,YAAY,GAA2B;IAC3C,UAAU,EAAE,KAAK;IACjB,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,IAAI,EAAE,KAAK;CACZ,CAAC;AAEF,SAAgB,aAAa;;IAC3B,MAAM,OAAO,GACX,MAAA,MAAA,OAAO,CAAC,GAAG,CAAC,YAAY,mCAAI,OAAO,CAAC,GAAG,CAAC,eAAe,mCAAI,OAAO,CAAC;IAErE,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAEvC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ;QAC9B,CAAC,CAAC,MAAA,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,mCAAI,OAAO,CAAC,GAAG,CAAC,QAAQ;QAC5D,CAAC,CAAC,KAAK,CAAC;IAEV,OAAO,GAA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,EAAE,CAAC;QACd,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEzC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACpD,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,EAAE,IAAI,EAAE,AAAD,EAAG,QAAQ,CAAC,GAAG,KAAK,CAAC;QACnC,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC/B,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,iBAAiB,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YAC9D,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,GAAG,QAAQ,IAAI,iBAAiB,EAAE,CAAC;AAC5C,CAAC"}
package/jest.config.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ transform: {
3
+ "^.+\\.(ts|tsx)$": "babel-jest",
4
+ },
5
+ testEnvironment: "node",
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alanszp/core",
3
- "version": "17.0.0",
3
+ "version": "17.1.1",
4
4
  "description": "Alan's core TS/JS lib.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,10 +13,17 @@
13
13
  "compile-watch": "tsc -w",
14
14
  "build": "yarn run compile",
15
15
  "prepack": "yarn run build",
16
- "yalc-publish": "yarn run yalc publish"
16
+ "yalc-publish": "yarn run yalc publish",
17
+ "test": "jest",
18
+ "test--watch": "yarn run test --watch"
17
19
  },
18
20
  "devDependencies": {
19
- "@types/node": "^20.11.17"
21
+ "@babel/core": "^7.23.9",
22
+ "@babel/preset-env": "^7.23.9",
23
+ "@babel/preset-typescript": "^7.23.3",
24
+ "@types/jest": "^29.5.12",
25
+ "@types/node": "^20.11.17",
26
+ "jest": "^29.7.0"
20
27
  },
21
- "gitHead": "db3463706e4b0b7fc97aa74e95cc7d6572c5d74b"
28
+ "gitHead": "6e31796ce37adcafc64671694660ce63461d548c"
22
29
  }
package/tsconfig.json CHANGED
@@ -11,5 +11,5 @@
11
11
  "alwaysStrict": true,
12
12
  "strictNullChecks": true
13
13
  },
14
- "exclude": ["node_modules"]
14
+ "exclude": ["node_modules", "**/*.test.ts"]
15
15
  }