@things-factory/shell 8.0.55 → 8.0.63

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,5 @@
1
+ import { ValueTransformer } from 'typeorm';
2
+ /**
3
+ * DB 저장/로드 시 월 숫자만 0-기반↔1-기반으로 상호 변환하는 트랜스포머
4
+ */
5
+ export declare const cronMonthZeroBasedTransformer: ValueTransformer;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cronMonthZeroBasedTransformer = void 0;
4
+ /**
5
+ * 크론 표현식의 월 필드(5필드=분-시-일-월-요일 / 6필드=초-분-시-일-월-요일)만 숫자일 때 ±1 시프트한다.
6
+ * - 리스트(1,3,12), 범위(3-5), 스텝(3/2, 3-9/2)에서 숫자에 한해 변환
7
+ * - 영문(JAN-DEC), '*', '?' 등은 그대로 둔다.
8
+ */
9
+ function shiftMonthNumbersInCronExpression(expression, delta) {
10
+ if (!expression)
11
+ return expression;
12
+ const parts = expression.trim().split(/\s+/);
13
+ if (parts.length !== 5 && parts.length !== 6)
14
+ return expression;
15
+ const monthIndex = parts.length === 6 ? 4 : 3;
16
+ const monthToken = parts[monthIndex];
17
+ const isNumeric = (s) => /^\d+$/.test(s);
18
+ const isAlpha = (s) => /^[A-Za-z]+$/.test(s);
19
+ const passthrough = (s) => s === '*' || s === '?';
20
+ const shiftNum = (nStr) => (isNumeric(nStr) ? String(parseInt(nStr, 10) + delta) : nStr);
21
+ const shiftPrimary = (primary) => {
22
+ const p = primary.trim();
23
+ if (p.includes('-')) {
24
+ const [a, b] = p.split('-');
25
+ return `${shiftNum(a.trim())}-${shiftNum(b.trim())}`;
26
+ }
27
+ return shiftNum(p);
28
+ };
29
+ const shiftedMonth = monthToken
30
+ .split(',')
31
+ .map(seg => {
32
+ const part = seg.trim();
33
+ if (!part)
34
+ return part;
35
+ if (passthrough(part) || isAlpha(part))
36
+ return part;
37
+ const [primary, step] = part.split('/');
38
+ const shifted = shiftPrimary(primary);
39
+ return step ? `${shifted}/${step}` : shifted;
40
+ })
41
+ .join(',');
42
+ parts[monthIndex] = shiftedMonth;
43
+ return parts.join(' ');
44
+ }
45
+ /**
46
+ * DB 저장/로드 시 월 숫자만 0-기반↔1-기반으로 상호 변환하는 트랜스포머
47
+ */
48
+ exports.cronMonthZeroBasedTransformer = {
49
+ to(value) {
50
+ if (value == null)
51
+ return value;
52
+ return shiftMonthNumbersInCronExpression(value, -1);
53
+ },
54
+ from(value) {
55
+ if (value == null)
56
+ return value;
57
+ return shiftMonthNumbersInCronExpression(value, +1);
58
+ }
59
+ };
60
+ //# sourceMappingURL=cron-month-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron-month-transform.js","sourceRoot":"","sources":["../../server/typeorm/cron-month-transform.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,SAAS,iCAAiC,CAAC,UAAkB,EAAE,KAAa;IAC1E,IAAI,CAAC,UAAU;QAAE,OAAO,UAAU,CAAA;IAClC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAC5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,UAAU,CAAA;IAC/D,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAA;IAEpC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChD,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACpD,MAAM,WAAW,GAAG,CAAC,C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,CAAC,CAAC,OAAO,CAAA;IAC9C,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAA;IAEZ,KAAK,CAAC,UAAU,CAAC,GAAG,YAAY,CAAA;IAChC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC;AAED;;GAEG;AACU,QAAA,6BAA6B,GAAqB;IAC7D,EAAE,CAAC,KAAgC;QACjC,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,KAAY,CAAA;QACtC,OAAO,iCAAiC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IACrD,CAAC;IACD,IAAI,CAAC,KAAgC;QACnC,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,KAAY,CAAA;QACtC,OAAO,iCAAiC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IACrD,CAAC;CACF,CAAA","sourcesContent":["import { ValueTransformer } from 'typeorm'\n\n/**\n * 크론 표현식의 월 필드(5필드=분-시-일-월-요일 / 6필드=초-분-시-일-월-요일)만 숫자일 때 ±1 시프트한다.\n * - 리스트(1,3,12), 범위(3-5), 스텝(3/2, 3-9/2)에서 숫자에 한해 변환\n * - 영문(JAN-DEC), '*', '?' 등은 그대로 둔다.\n */\nfunction shiftMonthNumbersInCronExpression(expression: string, delta: number): string {\n if (!expression) return expression\n const parts = expression.trim().split(/\\s+/)\n if (parts.length !== 5 && parts.length !== 6) return expression\n const monthIndex = parts.length === 6 ? 4 : 3\n const monthToken = parts[monthIndex]\n\n const isNumeric = (s: string) => /^\\d+$/.test(s)\n const isAlpha = (s: string) => /^[A-Za-z]+$/.test(s)\n const passthrough = (s: string) => s === '*' || s === '?'\n\n const shiftNum = (nStr: string) => (isNumeric(nStr) ? String(parseInt(nStr, 10) + delta) : nStr)\n\n const shiftPrimary = (primary: string) => {\n const p = primary.trim()\n if (p.includes('-')) {\n const [a, b] = p.split('-')\n return `${shiftNum(a.trim())}-${shiftNum(b.trim())}`\n }\n return shiftNum(p)\n }\n\n const shiftedMonth = monthToken\n .split(',')\n .map(seg => {\n const part = seg.trim()\n if (!part) return part\n if (passthrough(part) || isAlpha(part)) return part\n const [primary, step] = part.split('/')\n const shifted = shiftPrimary(primary)\n return step ? `${shifted}/${step}` : shifted\n })\n .join(',')\n\n parts[monthIndex] = shiftedMonth\n return parts.join(' ')\n}\n\n/**\n * DB 저장/로드 시 월 숫자만 0-기반↔1-기반으로 상호 변환하는 트랜스포머\n */\nexport const cronMonthZeroBasedTransformer: ValueTransformer = {\n to(value: string | null | undefined) {\n if (value == null) return value as any\n return shiftMonthNumbersInCronExpression(value, -1)\n },\n from(value: string | null | undefined) {\n if (value == null) return value as any\n return shiftMonthNumbersInCronExpression(value, +1)\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/shell",
3
- "version": "8.0.55",
3
+ "version": "8.0.63",
4
4
  "description": "Core module for framework",
5
5
  "bin": {
6
6
  "things-factory": "bin/things-factory",
@@ -134,5 +134,5 @@
134
134
  "pg": "^8.7.3",
135
135
  "sqlite3": "^5.0.8"
136
136
  },
137
- "gitHead": "172e2730c2e249faa839070c1b21d81bb4b6c946"
137
+ "gitHead": "24ba37efe2e871175a9e4fd816d02d9807491b91"
138
138
  }
package/server/index.ts CHANGED
@@ -11,3 +11,4 @@ export * from './service'
11
11
  export * from './typeorm/encrypt-transform'
12
12
  export * from './typeorm/json5-transform'
13
13
  export * from './typeorm/round-transform'
14
+ export * from './typeorm/cron-month-transform.js'
@@ -139,7 +139,7 @@ const bootstrap = async () => {
139
139
  })
140
140
 
141
141
  var subscriptionMiddleware = []
142
- process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware)
142
+ process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware as any)
143
143
 
144
144
  const builtSchema = await schema()
145
145
 
@@ -253,7 +253,7 @@ const bootstrap = async () => {
253
253
 
254
254
  /* routers */
255
255
  const ssoMiddlewares = []
256
- process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares)
256
+ process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares as any)
257
257
  app.ssoMiddlewares = ssoMiddlewares
258
258
 
259
259
  process.emit('bootstrap-module-global-public-route' as any, app, globalPublicRouter)
package/server/server.ts CHANGED
@@ -115,7 +115,7 @@ const bootstrap = async () => {
115
115
  })
116
116
 
117
117
  var subscriptionMiddleware = []
118
- process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware)
118
+ process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware as any)
119
119
 
120
120
  const builtSchema = await schema()
121
121
 
@@ -223,7 +223,7 @@ const bootstrap = async () => {
223
223
 
224
224
  /* routers */
225
225
  const ssoMiddlewares = []
226
- process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares)
226
+ process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares as any)
227
227
  app.ssoMiddlewares = ssoMiddlewares
228
228
 
229
229
  process.emit('bootstrap-module-global-public-route' as any, app, globalPublicRouter)
@@ -0,0 +1,58 @@
1
+ import { ValueTransformer } from 'typeorm'
2
+
3
+ /**
4
+ * 크론 표현식의 월 필드(5필드=분-시-일-월-요일 / 6필드=초-분-시-일-월-요일)만 숫자일 때 ±1 시프트한다.
5
+ * - 리스트(1,3,12), 범위(3-5), 스텝(3/2, 3-9/2)에서 숫자에 한해 변환
6
+ * - 영문(JAN-DEC), '*', '?' 등은 그대로 둔다.
7
+ */
8
+ function shiftMonthNumbersInCronExpression(expression: string, delta: number): string {
9
+ if (!expression) return expression
10
+ const parts = expression.trim().split(/\s+/)
11
+ if (parts.length !== 5 && parts.length !== 6) return expression
12
+ const monthIndex = parts.length === 6 ? 4 : 3
13
+ const monthToken = parts[monthIndex]
14
+
15
+ const isNumeric = (s: string) => /^\d+$/.test(s)
16
+ const isAlpha = (s: string) => /^[A-Za-z]+$/.test(s)
17
+ const passthrough = (s: string) => s === '*' || s === '?'
18
+
19
+ const shiftNum = (nStr: string) => (isNumeric(nStr) ? String(parseInt(nStr, 10) + delta) : nStr)
20
+
21
+ const shiftPrimary = (primary: string) => {
22
+ const p = primary.trim()
23
+ if (p.includes('-')) {
24
+ const [a, b] = p.split('-')
25
+ return `${shiftNum(a.trim())}-${shiftNum(b.trim())}`
26
+ }
27
+ return shiftNum(p)
28
+ }
29
+
30
+ const shiftedMonth = monthToken
31
+ .split(',')
32
+ .map(seg => {
33
+ const part = seg.trim()
34
+ if (!part) return part
35
+ if (passthrough(part) || isAlpha(part)) return part
36
+ const [primary, step] = part.split('/')
37
+ const shifted = shiftPrimary(primary)
38
+ return step ? `${shifted}/${step}` : shifted
39
+ })
40
+ .join(',')
41
+
42
+ parts[monthIndex] = shiftedMonth
43
+ return parts.join(' ')
44
+ }
45
+
46
+ /**
47
+ * DB 저장/로드 시 월 숫자만 0-기반↔1-기반으로 상호 변환하는 트랜스포머
48
+ */
49
+ export const cronMonthZeroBasedTransformer: ValueTransformer = {
50
+ to(value: string | null | undefined) {
51
+ if (value == null) return value as any
52
+ return shiftMonthNumbersInCronExpression(value, -1)
53
+ },
54
+ from(value: string | null | undefined) {
55
+ if (value == null) return value as any
56
+ return shiftMonthNumbersInCronExpression(value, +1)
57
+ }
58
+ }