@things-factory/integration-data-go-kr 10.1.234 → 10.1.236
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-server/engine/connector/data-go-kr-client.d.ts +1 -1
- package/dist-server/engine/connector/data-go-kr-client.js +17 -0
- package/dist-server/engine/connector/data-go-kr-client.js.map +1 -1
- package/dist-server/engine/connector/data-go-kr-connector.js +1 -1
- package/dist-server/engine/connector/data-go-kr-connector.js.map +1 -1
- package/dist-server/engine/spec/index.d.ts +1 -0
- package/dist-server/engine/spec/index.js +3 -0
- package/dist-server/engine/spec/index.js.map +1 -1
- package/dist-server/engine/spec/special-day/index.d.ts +4 -0
- package/dist-server/engine/spec/special-day/index.js +9 -0
- package/dist-server/engine/spec/special-day/index.js.map +1 -0
- package/dist-server/engine/spec/special-day/special-day.d.ts +7 -0
- package/dist-server/engine/spec/special-day/special-day.js +28 -0
- package/dist-server/engine/spec/special-day/special-day.js.map +1 -0
- package/dist-server/engine/task/index.d.ts +1 -0
- package/dist-server/engine/task/index.js +1 -0
- package/dist-server/engine/task/index.js.map +1 -1
- package/dist-server/engine/task/special-day/index.d.ts +26 -0
- package/dist-server/engine/task/special-day/index.js +32 -0
- package/dist-server/engine/task/special-day/index.js.map +1 -0
- package/dist-server/engine/task/special-day/rest-days.d.ts +12 -0
- package/dist-server/engine/task/special-day/rest-days.js +26 -0
- package/dist-server/engine/task/special-day/rest-days.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/server/engine/connector/data-go-kr-client.ts +23 -1
- package/server/engine/connector/data-go-kr-connector.ts +1 -1
- package/server/engine/spec/index.ts +3 -0
- package/server/engine/spec/special-day/index.ts +4 -0
- package/server/engine/spec/special-day/special-day.ts +26 -0
- package/server/engine/task/index.ts +1 -0
- package/server/engine/task/special-day/index.ts +38 -0
- package/server/engine/task/special-day/rest-days.ts +19 -0
- package/test/data-go-kr-client.test.ts +43 -0
- package/test/rest-days.test.ts +20 -0
- package/translations/en.json +1 -1
- package/translations/es.json +1 -1
- package/translations/ja.json +1 -1
- package/translations/ko.json +1 -1
- package/translations/ms.json +1 -1
- package/translations/zh.json +1 -1
|
@@ -22,6 +22,15 @@ class DataGoKrClient {
|
|
|
22
22
|
/* Encoding 키(%2B 포함)를 붙여넣어도 Decoding 키처럼 동작하도록 정규화.
|
|
23
23
|
base64 키는 `%` 를 포함하지 않으므로 raw Decoding 키는 영향 없음. */
|
|
24
24
|
this.serviceKey = normalizeServiceKey(options.serviceKey.trim());
|
|
25
|
+
/*
|
|
26
|
+
* A service key is letters, digits and + / = (the Decoding key; the Encoding key decodes to it). Anything else - a
|
|
27
|
+
* JSON answer or a page pasted whole - is said at connect, not later as 「등록되지 않은 서비스키」 (the user,
|
|
28
|
+
* 2026-10-31). The value itself is never said.
|
|
29
|
+
*/
|
|
30
|
+
if (!/^[A-Za-z0-9+/=]+$/.test(this.serviceKey)) {
|
|
31
|
+
throw new Error(`the data.go.kr service key is not a key (${this.serviceKey.length} characters, with characters a key does not have) - ` +
|
|
32
|
+
`paste only the general authentication key (Decoding or Encoding) from data.go.kr My Page`);
|
|
33
|
+
}
|
|
25
34
|
this.origin = resolveOrigin(options.origin);
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
@@ -52,6 +61,14 @@ class DataGoKrClient {
|
|
|
52
61
|
.filter(([, v]) => v !== undefined && v !== null && v !== '')
|
|
53
62
|
.map(([k, v]) => `${k}=${v}`)
|
|
54
63
|
.join(' ');
|
|
64
|
+
/*
|
|
65
|
+
* A web page is not an Open API answer: the endpoint names a site (https://data.go.kr is the portal), not the API
|
|
66
|
+
* origin. Said as that, not as the page's HTML (the user, 2026-10-31).
|
|
67
|
+
*/
|
|
68
|
+
if (/^\s*<(!doctype html|html)/i.test(raw)) {
|
|
69
|
+
throw new Error(`data.go.kr ${servicePath}: ${this.origin} answered a web page (${response.status}), not the Open API - ` +
|
|
70
|
+
`leave the connection's endpoint empty or set it to ${DEFAULT_ORIGIN}`);
|
|
71
|
+
}
|
|
55
72
|
if (!response.ok) {
|
|
56
73
|
throw new Error(`data.go.kr ${servicePath} failed (${response.status}): ${raw.slice(0, 300)} — params: ${nonSensitiveParams}`);
|
|
57
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-go-kr-client.js","sourceRoot":"","sources":["../../../server/engine/connector/data-go-kr-client.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AAEH,MAAM,cAAc,GAAG,yBAAyB,CAAA;AAQhD,MAAa,cAAc;IAIzB,YAAY,OAA8B;QACxC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;QACvD,CAAC;QACD;8DACsD;QACtD,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAA;QAChE,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAI,WAAmB,EAAE,MAA2B;QAC3D,MAAM,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAA;QAC1E,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC,CAAA;QAC5C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;QACnD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QACrC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;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CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACrE,OAAO,QAAQ,IAAI,QAAQ,GAAG,SAAS,IAAI,EAAE,CAAA;AAC/C,CAAC","sourcesContent":["import { DataGoKrResponse } from '../types'\n\n/**\n * 공공데이터포털(data.go.kr) 공용 HTTP 클라이언트.\n *\n * 모든 data.go.kr Open API 는 아래 공통 규약을 따른다:\n * - URL: `https://apis.data.go.kr/<agency>/<service>/<operation>`\n * - 인증: `serviceKey` 쿼리 파라미터 (Encoding/Decoding 두 형태 모두 수용)\n * - 포맷: `_type=json` 없으면 XML\n * - 에러: `<OpenAPI_ServiceResponse>` XML 또는 `response.header.resultCode !== '00'`\n *\n * 본 클라이언트는 서비스·오퍼레이션에 독립적으로 동작하며, 경로를 파라미터로 받는다.\n * 서비스별 도메인 로직(파라미터 검증, 응답 매핑) 은 task 레이어에서 처리.\n */\n\nconst DEFAULT_ORIGIN = 'https://apis.data.go.kr'\n\nexport interface DataGoKrClientOptions {\n serviceKey: string\n /** 오리진 오버라이드 (모의 서버/사설 프록시 용도). 기본 `https://apis.data.go.kr`. */\n origin?: string\n}\n\nexport class DataGoKrClient {\n private readonly serviceKey: string\n private readonly origin: string\n\n constructor(options: DataGoKrClientOptions) {\n if (!options.serviceKey) {\n throw new Error('DataGoKrClient requires serviceKey')\n }\n /* Encoding 키(%2B 포함)를 붙여넣어도 Decoding 키처럼 동작하도록 정규화.\n base64 키는 `%` 를 포함하지 않으므로 raw Decoding 키는 영향 없음. */\n this.serviceKey = normalizeServiceKey(options.serviceKey.trim())\n this.origin = resolveOrigin(options.origin)\n }\n\n /**\n * 범용 GET 호출.\n *\n * @param servicePath `<agency>/<service>/<operation>` (예: `1613000/BldRgstHubService/getBrTitleInfo`)\n * @param params 쿼리 파라미터 (serviceKey / _type 은 자동 추가)\n */\n async get<T>(servicePath: string, params: Record<string, any>): Promise<DataGoKrResponse<T>> {\n const path = servicePath.startsWith('/') ? servicePath : `/${servicePath}`\n const url = new URL(`${this.origin}${path}`)\n url.searchParams.set('serviceKey', this.serviceKey)\n url.searchParams.set('_type', 'json')\n for (const [k, v] of Object.entries(params)) {\n if (v === undefined || v === null || v === '') continue\n url.searchParams.set(k, String(v))\n }\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'User-Agent': '@things-factory/integration-data-go-kr',\n Accept: 'application/json'\n }\n })\n const raw = await response.text()\n\n const nonSensitiveParams = Object.entries(params)\n .filter(([, v]) => v !== undefined && v !== null && v !== '')\n .map(([k, v]) => `${k}=${v}`)\n .join(' ')\n\n if (!response.ok) {\n throw new Error(\n `data.go.kr ${servicePath} failed (${response.status}): ${raw.slice(0, 300)} — params: ${nonSensitiveParams}`\n )\n }\n\n let parsed: DataGoKrResponse<T>\n try {\n parsed = JSON.parse(raw) as DataGoKrResponse<T>\n } catch (err) {\n if (raw.includes('<OpenAPI_ServiceResponse') || raw.includes('<returnReasonCode>')) {\n throw new Error(`data.go.kr ${servicePath}: ${parseOpenApiError(raw)} — params: ${nonSensitiveParams}`)\n }\n throw new Error(\n `data.go.kr ${servicePath}: non-JSON response: ${raw.slice(0, 300)} — params: ${nonSensitiveParams}`\n )\n }\n\n const header = parsed?.response?.header\n if (!header) {\n throw new Error(`data.go.kr ${servicePath}: response missing header — body: ${raw.slice(0, 300)}`)\n }\n if (header.resultCode !== '00') {\n throw new Error(\n `data.go.kr ${servicePath}: resultCode=${header.resultCode} msg=${header.resultMsg} — params: ${nonSensitiveParams}`\n )\n }\n\n return parsed\n }\n\n /**\n * 단건 또는 복수 items 를 배열로 정규화해서 반환한다.\n *\n * data.go.kr 공통 특성으로, body.items 가 아래 세 가지 형태로 올 수 있다:\n * - `\"\"` (빈 문자열, 결과 없음)\n * - `{ item: { ... } }` (단건)\n * - `{ item: [ ... ] }` (복수)\n */\n async getItems<T>(servicePath: string, params: Record<string, any>): Promise<T[]> {\n const response = await this.get<T>(servicePath, params)\n const items = response.response?.body?.items\n if (!items) return []\n const arr = (items as any).item\n if (!arr) return []\n return Array.isArray(arr) ? arr : [arr]\n }\n}\n\n/**\n * Connection.endpoint 값을 검증하여 유효한 origin URL 로 정규화한다.\n *\n * - 비어있거나 공백만: 기본 오리진 사용\n * - 유효한 절대 URL: trailing slash 제거 후 사용\n * - 유효하지 않은 값: 친절한 에러 throw (단순 오타·누락 방지)\n */\nfunction resolveOrigin(value: string | undefined): string {\n if (!value || !value.trim()) return DEFAULT_ORIGIN\n const trimmed = value.trim()\n try {\n const parsed = new URL(trimmed)\n if (!parsed.protocol.startsWith('http')) {\n throw new Error('protocol must be http or https')\n }\n return trimmed.replace(/\\/$/, '')\n } catch (err) {\n throw new Error(\n `Invalid Connection.endpoint value '${value}': must be a full URL (예: https://apis.data.go.kr) ` +\n `or empty (기본값 ${DEFAULT_ORIGIN} 사용). Reason: ${(err as Error).message}`\n )\n }\n}\n\n/** Encoding 키(%2B) 를 붙여넣어도 Decoding 키로 정규화. */\nfunction normalizeServiceKey(key: string): string {\n if (!key.includes('%')) return key\n try {\n return decodeURIComponent(key)\n } catch {\n return key\n }\n}\n\n/** data.go.kr 공용 OpenAPI 에러 XML 에서 원인 추출. */\nfunction parseOpenApiError(xml: string): string {\n const code = /<returnReasonCode>([^<]+)<\\/returnReasonCode>/.exec(xml)?.[1]\n const msg = /<errMsg>([^<]+)<\\/errMsg>/.exec(xml)?.[1]\n const auth = /<returnAuthMsg>([^<]+)<\\/returnAuthMsg>/.exec(xml)?.[1]\n return `code=${code} msg=${msg} auth=${auth}`\n}\n"]}
|
|
1
|
+
{"version":3,"file":"data-go-kr-client.js","sourceRoot":"","sources":["../../../server/engine/connector/data-go-kr-client.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AAEH,MAAM,cAAc,GAAG,yBAAyB,CAAA;AAQhD,MAAa,cAAc;IAIzB,YAAY,OAA8B;QACxC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAA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C,CAAA;IACrE,OAAO,QAAQ,IAAI,QAAQ,GAAG,SAAS,IAAI,EAAE,CAAA;AAC/C,CAAC","sourcesContent":["import type { DataGoKrResponse } from '../types'\n\n/**\n * 공공데이터포털(data.go.kr) 공용 HTTP 클라이언트.\n *\n * 모든 data.go.kr Open API 는 아래 공통 규약을 따른다:\n * - URL: `https://apis.data.go.kr/<agency>/<service>/<operation>`\n * - 인증: `serviceKey` 쿼리 파라미터 (Encoding/Decoding 두 형태 모두 수용)\n * - 포맷: `_type=json` 없으면 XML\n * - 에러: `<OpenAPI_ServiceResponse>` XML 또는 `response.header.resultCode !== '00'`\n *\n * 본 클라이언트는 서비스·오퍼레이션에 독립적으로 동작하며, 경로를 파라미터로 받는다.\n * 서비스별 도메인 로직(파라미터 검증, 응답 매핑) 은 task 레이어에서 처리.\n */\n\nconst DEFAULT_ORIGIN = 'https://apis.data.go.kr'\n\nexport interface DataGoKrClientOptions {\n serviceKey: string\n /** 오리진 오버라이드 (모의 서버/사설 프록시 용도). 기본 `https://apis.data.go.kr`. */\n origin?: string\n}\n\nexport class DataGoKrClient {\n private readonly serviceKey: string\n private readonly origin: string\n\n constructor(options: DataGoKrClientOptions) {\n if (!options.serviceKey) {\n throw new Error('DataGoKrClient requires serviceKey')\n }\n /* Encoding 키(%2B 포함)를 붙여넣어도 Decoding 키처럼 동작하도록 정규화.\n base64 키는 `%` 를 포함하지 않으므로 raw Decoding 키는 영향 없음. */\n this.serviceKey = normalizeServiceKey(options.serviceKey.trim())\n /*\n * A service key is letters, digits and + / = (the Decoding key; the Encoding key decodes to it). Anything else - a\n * JSON answer or a page pasted whole - is said at connect, not later as 「등록되지 않은 서비스키」 (the user,\n * 2026-10-31). The value itself is never said.\n */\n if (!/^[A-Za-z0-9+/=]+$/.test(this.serviceKey)) {\n throw new Error(\n `the data.go.kr service key is not a key (${this.serviceKey.length} characters, with characters a key does not have) - ` +\n `paste only the general authentication key (Decoding or Encoding) from data.go.kr My Page`\n )\n }\n this.origin = resolveOrigin(options.origin)\n }\n\n /**\n * 범용 GET 호출.\n *\n * @param servicePath `<agency>/<service>/<operation>` (예: `1613000/BldRgstHubService/getBrTitleInfo`)\n * @param params 쿼리 파라미터 (serviceKey / _type 은 자동 추가)\n */\n async get<T>(servicePath: string, params: Record<string, any>): Promise<DataGoKrResponse<T>> {\n const path = servicePath.startsWith('/') ? servicePath : `/${servicePath}`\n const url = new URL(`${this.origin}${path}`)\n url.searchParams.set('serviceKey', this.serviceKey)\n url.searchParams.set('_type', 'json')\n for (const [k, v] of Object.entries(params)) {\n if (v === undefined || v === null || v === '') continue\n url.searchParams.set(k, String(v))\n }\n\n const response = await fetch(url.toString(), {\n method: 'GET',\n headers: {\n 'User-Agent': '@things-factory/integration-data-go-kr',\n Accept: 'application/json'\n }\n })\n const raw = await response.text()\n\n const nonSensitiveParams = Object.entries(params)\n .filter(([, v]) => v !== undefined && v !== null && v !== '')\n .map(([k, v]) => `${k}=${v}`)\n .join(' ')\n\n /*\n * A web page is not an Open API answer: the endpoint names a site (https://data.go.kr is the portal), not the API\n * origin. Said as that, not as the page's HTML (the user, 2026-10-31).\n */\n if (/^\\s*<(!doctype html|html)/i.test(raw)) {\n throw new Error(\n `data.go.kr ${servicePath}: ${this.origin} answered a web page (${response.status}), not the Open API - ` +\n `leave the connection's endpoint empty or set it to ${DEFAULT_ORIGIN}`\n )\n }\n\n if (!response.ok) {\n throw new Error(\n `data.go.kr ${servicePath} failed (${response.status}): ${raw.slice(0, 300)} — params: ${nonSensitiveParams}`\n )\n }\n\n let parsed: DataGoKrResponse<T>\n try {\n parsed = JSON.parse(raw) as DataGoKrResponse<T>\n } catch (err) {\n if (raw.includes('<OpenAPI_ServiceResponse') || raw.includes('<returnReasonCode>')) {\n throw new Error(`data.go.kr ${servicePath}: ${parseOpenApiError(raw)} — params: ${nonSensitiveParams}`)\n }\n throw new Error(\n `data.go.kr ${servicePath}: non-JSON response: ${raw.slice(0, 300)} — params: ${nonSensitiveParams}`\n )\n }\n\n const header = parsed?.response?.header\n if (!header) {\n throw new Error(`data.go.kr ${servicePath}: response missing header — body: ${raw.slice(0, 300)}`)\n }\n if (header.resultCode !== '00') {\n throw new Error(\n `data.go.kr ${servicePath}: resultCode=${header.resultCode} msg=${header.resultMsg} — params: ${nonSensitiveParams}`\n )\n }\n\n return parsed\n }\n\n /**\n * 단건 또는 복수 items 를 배열로 정규화해서 반환한다.\n *\n * data.go.kr 공통 특성으로, body.items 가 아래 세 가지 형태로 올 수 있다:\n * - `\"\"` (빈 문자열, 결과 없음)\n * - `{ item: { ... } }` (단건)\n * - `{ item: [ ... ] }` (복수)\n */\n async getItems<T>(servicePath: string, params: Record<string, any>): Promise<T[]> {\n const response = await this.get<T>(servicePath, params)\n const items = response.response?.body?.items\n if (!items) return []\n const arr = (items as any).item\n if (!arr) return []\n return Array.isArray(arr) ? arr : [arr]\n }\n}\n\n/**\n * Connection.endpoint 값을 검증하여 유효한 origin URL 로 정규화한다.\n *\n * - 비어있거나 공백만: 기본 오리진 사용\n * - 유효한 절대 URL: trailing slash 제거 후 사용\n * - 유효하지 않은 값: 친절한 에러 throw (단순 오타·누락 방지)\n */\nfunction resolveOrigin(value: string | undefined): string {\n if (!value || !value.trim()) return DEFAULT_ORIGIN\n const trimmed = value.trim()\n try {\n const parsed = new URL(trimmed)\n if (!parsed.protocol.startsWith('http')) {\n throw new Error('protocol must be http or https')\n }\n return trimmed.replace(/\\/$/, '')\n } catch (err) {\n throw new Error(\n `Invalid Connection.endpoint value '${value}': must be a full URL (예: https://apis.data.go.kr) ` +\n `or empty (기본값 ${DEFAULT_ORIGIN} 사용). Reason: ${(err as Error).message}`\n )\n }\n}\n\n/** Encoding 키(%2B) 를 붙여넣어도 Decoding 키로 정규화. */\nfunction normalizeServiceKey(key: string): string {\n if (!key.includes('%')) return key\n try {\n return decodeURIComponent(key)\n } catch {\n return key\n }\n}\n\n/** data.go.kr 공용 OpenAPI 에러 XML 에서 원인 추출. */\nfunction parseOpenApiError(xml: string): string {\n const code = /<returnReasonCode>([^<]+)<\\/returnReasonCode>/.exec(xml)?.[1]\n const msg = /<errMsg>([^<]+)<\\/errMsg>/.exec(xml)?.[1]\n const auth = /<returnAuthMsg>([^<]+)<\\/returnAuthMsg>/.exec(xml)?.[1]\n return `code=${code} msg=${msg} auth=${auth}`\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-go-kr-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/data-go-kr-connector.ts"],"names":[],"mappings":";;;AAAA,uEAA+E;AAE/E,2DAAoD;AAgBpD,MAAa,iBAAiB;IAC5B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjE,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;IAC7E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAU;QACtB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;QACvC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,kCAAc,CAAC;gBAChC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,MAAM,EAAE,QAAQ;aACjB,CAAC,CAAA;YACF,MAAM,QAAQ,GAA+B,EAAE,MAAM,EAAE,CAAA;YACvD,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC7D,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAC3B,mCAAmC,UAAU,CAAC,IAAI,6BAA6B,QAAQ,IAAI,WAAW,GAAG,CAC1G,CAAA;QACH,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,oCAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,UAAU,CAAC,IAAI,UAAU,EAAE,EAAE,CAAC,CAAA;YAChG,MAAM,EAAE,CAAA;QACV,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAU;QACzB,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QACtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAmC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACtG,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"data-go-kr-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/data-go-kr-connector.ts"],"names":[],"mappings":";;;AAAA,uEAA+E;AAE/E,2DAAoD;AAgBpD,MAAa,iBAAiB;IAC5B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjE,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;IAC7E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAU;QACtB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;QACvC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,kCAAc,CAAC;gBAChC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,MAAM,EAAE,QAAQ;aACjB,CAAC,CAAA;YACF,MAAM,QAAQ,GAA+B,EAAE,MAAM,EAAE,CAAA;YACvD,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC7D,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAC3B,mCAAmC,UAAU,CAAC,IAAI,6BAA6B,QAAQ,IAAI,WAAW,GAAG,CAC1G,CAAA;QACH,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,oCAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,UAAU,CAAC,IAAI,UAAU,EAAE,EAAE,CAAC,CAAA;YAChG,MAAM,EAAE,CAAA;QACV,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAU;QACzB,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QACtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAmC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACtG,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,aAAa;gBACpB,kBAAkB,EAAE,IAAI;aACzB;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,YAAY,CAAC,CAAA;IACvB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,4CAA4C,CAAA;IACrD,CAAC;IAED,IAAI,WAAW;QACb,OAAO,kDAAkD,CAAA;IAC3D,CAAC;CACF;AAnDD,8CAmDC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,IAAI,iBAAiB,EAAE,CAAC,CAAA","sourcesContent":["import { ConnectionManager, Connector } from '@things-factory/integration-base'\n\nimport { DataGoKrClient } from './data-go-kr-client'\n\n/**\n * 공공데이터포털(data.go.kr) Open API 커넥터.\n *\n * 하나의 ServiceKey 로 data.go.kr 산하 **모든 오퍼레이션** 을 호출할 수 있으므로,\n * 사용자는 Connection 을 보통 한 개만 만들고 (앱·법인별로 1개) 여러 태스크에서 재사용한다.\n *\n * Connection 의 `endpoint` 필드를 API 오리진(host) 으로 사용한다. 비워두면 기본값\n * `https://apis.data.go.kr` 가 사용되며, 모의 서버/사설 프록시로 라우팅하려면\n * 해당 오리진을 endpoint 에 입력한다.\n */\nexport interface DataGoKrConnectionInstance {\n client: DataGoKrClient\n}\n\nexport class DataGoKrConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n ConnectionManager.logger.info('data-go-kr-connector connections are ready')\n }\n\n async connect(connection) {\n const { endpoint, params } = connection\n try {\n const client = new DataGoKrClient({\n serviceKey: params.serviceKey,\n origin: endpoint\n })\n const instance: DataGoKrConnectionInstance = { client }\n ConnectionManager.addConnectionInstance(connection, instance)\n ConnectionManager.logger.info(\n `data-go-kr-connector connection(${connection.name}) is connected (endpoint: ${endpoint || '(default)'})`\n )\n } catch (ex) {\n ConnectionManager.logger.error(`data-go-kr-connector connection(${connection.name}) failed`, ex)\n throw ex\n }\n }\n\n async disconnect(connection) {\n ConnectionManager.removeConnectionInstance(connection)\n ConnectionManager.logger.info(`data-go-kr-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'secret',\n name: 'serviceKey',\n label: 'service-key',\n useDomainAttribute: true\n }\n ]\n }\n\n get taskPrefixes() {\n return ['data-go-kr']\n }\n\n get help() {\n return 'integration/connector/data-go-kr-connector'\n }\n\n get description() {\n return 'Korean Public Data Portal (data.go.kr) Connector'\n }\n}\n\nConnectionManager.registerConnector('data-go-kr-connector', new DataGoKrConnector())\n"]}
|
|
@@ -4,6 +4,7 @@ export * from './building-ledger';
|
|
|
4
4
|
export * from './building-permit';
|
|
5
5
|
export * from './housing-permit';
|
|
6
6
|
export * from './weather';
|
|
7
|
+
export * from './special-day';
|
|
7
8
|
export declare const SpecRegistry: {
|
|
8
9
|
/** 등록된 모든 서비스 스펙을 반환. */
|
|
9
10
|
listServices(): ServiceSpec[];
|
|
@@ -8,11 +8,13 @@ const buildingLedger = tslib_1.__importStar(require("./building-ledger"));
|
|
|
8
8
|
const buildingPermit = tslib_1.__importStar(require("./building-permit"));
|
|
9
9
|
const housingPermit = tslib_1.__importStar(require("./housing-permit"));
|
|
10
10
|
const weather = tslib_1.__importStar(require("./weather"));
|
|
11
|
+
const specialDay = tslib_1.__importStar(require("./special-day"));
|
|
11
12
|
tslib_1.__exportStar(require("./types"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./building-ledger"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./building-permit"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./housing-permit"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./weather"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./special-day"), exports);
|
|
16
18
|
const services = new Map();
|
|
17
19
|
function registerService(spec) {
|
|
18
20
|
services.set(spec.serviceId, spec);
|
|
@@ -35,6 +37,7 @@ registerDomain(buildingLedger);
|
|
|
35
37
|
registerDomain(buildingPermit);
|
|
36
38
|
registerDomain(housingPermit);
|
|
37
39
|
registerDomain(weather);
|
|
40
|
+
registerDomain(specialDay);
|
|
38
41
|
exports.SpecRegistry = {
|
|
39
42
|
/** 등록된 모든 서비스 스펙을 반환. */
|
|
40
43
|
listServices() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/spec/index.ts"],"names":[],"mappings":";;;;AAAA,mCAAuE;AAEvE,mDAAmD;AACnD,0EAAmD;AACnD,0EAAmD;AACnD,wEAAiD;AACjD,2DAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/spec/index.ts"],"names":[],"mappings":";;;;AAAA,mCAAuE;AAEvE,mDAAmD;AACnD,0EAAmD;AACnD,0EAAmD;AACnD,wEAAiD;AACjD,2DAAoC;AACpC,kEAA2C;AAE3C,kDAAuB;AACvB,4DAAiC;AACjC,4DAAiC;AACjC,2DAAgC;AAChC,oDAAyB;AACzB,wDAA6B;AAE7B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAA;AAE/C,SAAS,eAAe,CAAC,IAAiB;IACxC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;AACpC,CA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AC,SAAS;YAAE,OAAO,SAAS,CAAA;QAChC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;IAC/B,CAAC;IAED,gCAAgC;IAChC,QAAQ,CAAC,IAAiB;QACxB,eAAe,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;CACF,CAAA","sourcesContent":["import { OperationSpec, ServiceSpec, parseOperationRef } from './types'\n\n/* 도메인별 서비스 스펙 — 새 도메인 추가 시 폴더 추가 + 본 import 한 줄 */\nimport * as buildingLedger from './building-ledger'\nimport * as buildingPermit from './building-permit'\nimport * as housingPermit from './housing-permit'\nimport * as weather from './weather'\nimport * as specialDay from './special-day'\n\nexport * from './types'\nexport * from './building-ledger'\nexport * from './building-permit'\nexport * from './housing-permit'\nexport * from './weather'\nexport * from './special-day'\n\nconst services = new Map<string, ServiceSpec>()\n\nfunction registerService(spec: ServiceSpec) {\n services.set(spec.serviceId, spec)\n}\n\n/* 도메인 모듈에서 export 된 모든 ServiceSpec 인스턴스를 자동 등록.\n 추가 도메인 import 만 늘리면 이하 코드는 그대로. */\nfunction registerDomain(domain: Record<string, unknown>) {\n for (const value of Object.values(domain)) {\n if (isServiceSpec(value)) registerService(value)\n }\n}\nfunction isServiceSpec(value: unknown): value is ServiceSpec {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as any).serviceId === 'string' &&\n typeof (value as any).operations === 'object'\n )\n}\n\nregisterDomain(buildingLedger)\nregisterDomain(buildingPermit)\nregisterDomain(housingPermit)\nregisterDomain(weather)\nregisterDomain(specialDay)\n\nexport const SpecRegistry = {\n /** 등록된 모든 서비스 스펙을 반환. */\n listServices(): ServiceSpec[] {\n return Array.from(services.values())\n },\n\n /** 서비스 ID 로 서비스 스펙 조회. */\n getService(serviceId: string): ServiceSpec | undefined {\n return services.get(serviceId)\n },\n\n /** `<serviceId>.<operationId>` 참조 문자열로 오퍼레이션 스펙 조회. */\n resolve(operationRef: string): { service: ServiceSpec; operation: OperationSpec } | undefined {\n const parts = parseOperationRef(operationRef)\n if (!parts) return undefined\n const service = services.get(parts.serviceId)\n if (!service) return undefined\n const operation = service.operations[parts.operationId]\n if (!operation) return undefined\n return { service, operation }\n },\n\n /** (확장용) 외부에서 서비스 스펙을 추가 등록. */\n register(spec: ServiceSpec) {\n registerService(spec)\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KasiSpecialDayService = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 한국천문연구원(KASI) 특일 정보 서비스 스펙 묶음.
|
|
6
|
+
*/
|
|
7
|
+
var special_day_1 = require("./special-day");
|
|
8
|
+
Object.defineProperty(exports, "KasiSpecialDayService", { enumerable: true, get: function () { return special_day_1.KasiSpecialDayService; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/engine/spec/special-day/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,6CAAqD;AAA5C,oHAAA,qBAAqB,OAAA","sourcesContent":["/**\n * 한국천문연구원(KASI) 특일 정보 서비스 스펙 묶음.\n */\nexport { KasiSpecialDayService } from './special-day'\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KasiSpecialDayService = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 한국천문연구원_특일 정보 (data.go.kr 데이터셋 15012690).
|
|
6
|
+
*
|
|
7
|
+
* 공휴일(`getRestDeInfo`)은 대체공휴일 · 임시공휴일을 포함한다. 근무일 캘린더가 이것으로 국가 공휴일을 채운다(ADR-0179).
|
|
8
|
+
*/
|
|
9
|
+
exports.KasiSpecialDayService = {
|
|
10
|
+
serviceId: 'B090041/openapi/service/SpcdeInfoService',
|
|
11
|
+
label: '한국천문연구원_특일 정보',
|
|
12
|
+
description: '공휴일 · 국경일 · 기념일 · 24절기 · 잡절. 연도(와 월) 기준.',
|
|
13
|
+
homepage: 'https://www.data.go.kr/data/15012690/openapi.do',
|
|
14
|
+
operations: {
|
|
15
|
+
getRestDeInfo: {
|
|
16
|
+
operationId: 'getRestDeInfo',
|
|
17
|
+
label: '공휴일 정보 조회',
|
|
18
|
+
description: '그 해(와 월)의 공휴일. 대체공휴일 · 임시공휴일 포함.',
|
|
19
|
+
params: [
|
|
20
|
+
{ name: 'solYear', label: 'label.year', required: true, length: 4, description: '연도 YYYY', example: '2026' },
|
|
21
|
+
{ name: 'solMonth', label: 'label.month', pad: 2, description: '월 MM. 비우면 그 해 전체', example: '10' }
|
|
22
|
+
],
|
|
23
|
+
responseNotes: 'items.item: { dateKind, dateName, isHoliday: "Y"|"N", locdate: YYYYMMDD(number), seq }. numOfRows 를 50 이상으로 잡는다.',
|
|
24
|
+
externalDocsUrl: 'https://www.data.go.kr/data/15012690/openapi.do'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=special-day.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"special-day.js","sourceRoot":"","sources":["../../../../server/engine/spec/special-day/special-day.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACU,QAAA,qBAAqB,GAAgB;IAChD,SAAS,EAAE,0CAA0C;IACrD,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,0CAA0C;IACvD,QAAQ,EAAE,iDAAiD;IAC3D,UAAU,EAAE;QACV,aAAa,EAAE;YACb,WAAW,EAAE,eAAe;YAC5B,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,kCAAkC;YAC/C,MAAM,EAAE;gBACN,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE;gBAC5G,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE;aACnG;YACD,aAAa,EAAE,kHAAkH;YACjI,eAAe,EAAE,iDAAiD;SACnE;KACF;CACF,CAAA","sourcesContent":["import { ServiceSpec } from '../types'\n\n/**\n * 한국천문연구원_특일 정보 (data.go.kr 데이터셋 15012690).\n *\n * 공휴일(`getRestDeInfo`)은 대체공휴일 · 임시공휴일을 포함한다. 근무일 캘린더가 이것으로 국가 공휴일을 채운다(ADR-0179).\n */\nexport const KasiSpecialDayService: ServiceSpec = {\n serviceId: 'B090041/openapi/service/SpcdeInfoService',\n label: '한국천문연구원_특일 정보',\n description: '공휴일 · 국경일 · 기념일 · 24절기 · 잡절. 연도(와 월) 기준.',\n homepage: 'https://www.data.go.kr/data/15012690/openapi.do',\n operations: {\n getRestDeInfo: {\n operationId: 'getRestDeInfo',\n label: '공휴일 정보 조회',\n description: '그 해(와 월)의 공휴일. 대체공휴일 · 임시공휴일 포함.',\n params: [\n { name: 'solYear', label: 'label.year', required: true, length: 4, description: '연도 YYYY', example: '2026' },\n { name: 'solMonth', label: 'label.month', pad: 2, description: '월 MM. 비우면 그 해 전체', example: '10' }\n ],\n responseNotes: 'items.item: { dateKind, dateName, isHoliday: \"Y\"|\"N\", locdate: YYYYMMDD(number), seq }. numOfRows 를 50 이상으로 잡는다.',\n externalDocsUrl: 'https://www.data.go.kr/data/15012690/openapi.do'\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,kBAAe;AACf,6BAA0B;AAC1B,6BAA0B;AAC1B,4BAAyB;AACzB,2BAAwB;AACxB,qBAAkB","sourcesContent":["/**\n * 태스크 배럴.\n *\n * 구성 규약:\n * - 범용 태스크 (여러 서비스에 공통 적용) 는 이 폴더 **최상단** 에 파일로 배치\n * 예) call.ts → data-go-kr-call\n *\n * - 특정 도메인/서비스의 전용 태스크는 **도메인 이름 폴더** 아래 배치\n * 예) building-ledger/ , (향후) property-trade/ , address/ ...\n *\n * 새 서비스 지원 우선순위:\n * 1) 먼저 SpecRegistry 에 서비스 스펙을 등록 → `data-go-kr-call` 로 즉시 호출 가능\n * 2) 그래도 불충분한 경우(입력 폼 필요, 응답 구조가 비표준, 도메인 가공 필수 등)만\n * 도메인 폴더를 새로 만들고 전용 태스크 작성\n *\n * 즉 이 폴더에 새 파일/폴더가 추가되는 것은 \"공통 경로로 풀 수 없는 예외\" 뿐이다.\n */\nimport './call'\nimport './building-ledger'\nimport './building-permit'\nimport './housing-permit'\nimport './building-info'\nimport './weather'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,kBAAe;AACf,6BAA0B;AAC1B,6BAA0B;AAC1B,4BAAyB;AACzB,2BAAwB;AACxB,qBAAkB;AAClB,yBAAsB","sourcesContent":["/**\n * 태스크 배럴.\n *\n * 구성 규약:\n * - 범용 태스크 (여러 서비스에 공통 적용) 는 이 폴더 **최상단** 에 파일로 배치\n * 예) call.ts → data-go-kr-call\n *\n * - 특정 도메인/서비스의 전용 태스크는 **도메인 이름 폴더** 아래 배치\n * 예) building-ledger/ , (향후) property-trade/ , address/ ...\n *\n * 새 서비스 지원 우선순위:\n * 1) 먼저 SpecRegistry 에 서비스 스펙을 등록 → `data-go-kr-call` 로 즉시 호출 가능\n * 2) 그래도 불충분한 경우(입력 폼 필요, 응답 구조가 비표준, 도메인 가공 필수 등)만\n * 도메인 폴더를 새로 만들고 전용 태스크 작성\n *\n * 즉 이 폴더에 새 파일/폴더가 추가되는 것은 \"공통 경로로 풀 수 없는 예외\" 뿐이다.\n */\nimport './call'\nimport './building-ledger'\nimport './building-permit'\nimport './housing-permit'\nimport './building-info'\nimport './weather'\nimport './special-day'\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Context } from '@things-factory/integration-base';
|
|
2
|
+
/**
|
|
3
|
+
* 한 해의 국가 공휴일 (`getRestDeInfo`) — 근무일 캘린더가 받는 모양 `{ year, days: [{ day, name }] }` 으로 준다(ADR-0179).
|
|
4
|
+
*
|
|
5
|
+
* 입력: `year` (비우면 올해). 시나리오는 다음 단계에서 `local-graphql-mutate` 로 calendar 의
|
|
6
|
+
* `savePublicHolidays(year, days)` 를 부른다.
|
|
7
|
+
*/
|
|
8
|
+
declare function RestDaysTask(step: any, context: Context): Promise<{
|
|
9
|
+
data: {
|
|
10
|
+
year: number;
|
|
11
|
+
days: {
|
|
12
|
+
day: string;
|
|
13
|
+
name: string;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
declare namespace RestDaysTask {
|
|
18
|
+
var parameterSpec: {
|
|
19
|
+
type: string;
|
|
20
|
+
name: string;
|
|
21
|
+
label: string;
|
|
22
|
+
placeholder: string;
|
|
23
|
+
}[];
|
|
24
|
+
var help: string;
|
|
25
|
+
}
|
|
26
|
+
export default RestDaysTask;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const integration_base_1 = require("@things-factory/integration-base");
|
|
4
|
+
const special_day_1 = require("../../spec/special-day/special-day");
|
|
5
|
+
const rest_days_1 = require("./rest-days");
|
|
6
|
+
/**
|
|
7
|
+
* 한 해의 국가 공휴일 (`getRestDeInfo`) — 근무일 캘린더가 받는 모양 `{ year, days: [{ day, name }] }` 으로 준다(ADR-0179).
|
|
8
|
+
*
|
|
9
|
+
* 입력: `year` (비우면 올해). 시나리오는 다음 단계에서 `local-graphql-mutate` 로 calendar 의
|
|
10
|
+
* `savePublicHolidays(year, days)` 를 부른다.
|
|
11
|
+
*/
|
|
12
|
+
async function RestDaysTask(step, context) {
|
|
13
|
+
const { connection: connectionName, params } = step;
|
|
14
|
+
const { domain, user, data, variables, lng, logger } = context;
|
|
15
|
+
const instance = await integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
|
16
|
+
if (!instance?.client)
|
|
17
|
+
throw new Error(`data-go-kr connection '${connectionName}' is not established.`);
|
|
18
|
+
const scope = { domain, user, lng, data, variables, console };
|
|
19
|
+
const given = params?.year === undefined || params?.year === null || params?.year === '' ? '' : String((0, integration_base_1.evaluateTemplate)(String(params.year), scope)).trim();
|
|
20
|
+
const year = given ? Number(given) : new Date().getFullYear();
|
|
21
|
+
if (!Number.isInteger(year) || year < 1900 || year > 2999)
|
|
22
|
+
throw new Error(`data-go-kr-rest-days: '${given}' is not a year`);
|
|
23
|
+
const servicePath = `${special_day_1.KasiSpecialDayService.serviceId}/getRestDeInfo`;
|
|
24
|
+
logger?.info?.(`[data-go-kr] ${servicePath} solYear=${year}`);
|
|
25
|
+
const items = await instance.client.getItems(servicePath, { solYear: year, numOfRows: 100, pageNo: 1 });
|
|
26
|
+
return { data: { year, days: (0, rest_days_1.restDaysOf)(items, year) } };
|
|
27
|
+
}
|
|
28
|
+
RestDaysTask.parameterSpec = [{ type: 'string', name: 'year', label: 'label.year', placeholder: '예) 2026 — 비우면 올해' }];
|
|
29
|
+
RestDaysTask.help = 'integration/task/data-go-kr-rest-days';
|
|
30
|
+
integration_base_1.TaskRegistry.registerTaskHandler('data-go-kr-rest-days', RestDaysTask);
|
|
31
|
+
exports.default = RestDaysTask;
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/engine/task/special-day/index.ts"],"names":[],"mappings":";;AAAA,uEAA6G;AAG7G,oEAA0E;AAC1E,2CAAwC;AAExC;;;;;GAKG;AACH,KAAK,U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IAAI,EAAE,CAAC,CAAA;IAC7D,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAM,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;IAE5G,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAA,sBAAU,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAA;AAC1D,CAAC;AAED,YAAY,CAAC,aAAa,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC,CAAA;AAErH,YAAY,CAAC,IAAI,GAAG,uCAAuC,CAAA;AAE3D,+BAAY,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAA;AAEtE,kBAAe,YAAY,CAAA","sourcesContent":["import { ConnectionManager, Context, TaskRegistry, evaluateTemplate } from '@things-factory/integration-base'\n\nimport { DataGoKrConnectionInstance } from '../../connector/data-go-kr-connector'\nimport { KasiSpecialDayService } from '../../spec/special-day/special-day'\nimport { restDaysOf } from './rest-days'\n\n/**\n * 한 해의 국가 공휴일 (`getRestDeInfo`) — 근무일 캘린더가 받는 모양 `{ year, days: [{ day, name }] }` 으로 준다(ADR-0179).\n *\n * 입력: `year` (비우면 올해). 시나리오는 다음 단계에서 `local-graphql-mutate` 로 calendar 의\n * `savePublicHolidays(year, days)` 를 부른다.\n */\nasync function RestDaysTask(step, context: Context): Promise<{ data: { year: number; days: { day: string; name: string }[] } }> {\n const { connection: connectionName, params } = step\n const { domain, user, data, variables, lng, logger } = context\n\n const instance: DataGoKrConnectionInstance = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!instance?.client) throw new Error(`data-go-kr connection '${connectionName}' is not established.`)\n\n const scope = { domain, user, lng, data, variables, console }\n const given = params?.year === undefined || params?.year === null || params?.year === '' ? '' : String(evaluateTemplate(String(params.year), scope)).trim()\n const year = given ? Number(given) : new Date().getFullYear()\n if (!Number.isInteger(year) || year < 1900 || year > 2999) throw new Error(`data-go-kr-rest-days: '${given}' is not a year`)\n\n const servicePath = `${KasiSpecialDayService.serviceId}/getRestDeInfo`\n logger?.info?.(`[data-go-kr] ${servicePath} solYear=${year}`)\n const items = await instance.client.getItems<any>(servicePath, { solYear: year, numOfRows: 100, pageNo: 1 })\n\n return { data: { year, days: restDaysOf(items, year) } }\n}\n\nRestDaysTask.parameterSpec = [{ type: 'string', name: 'year', label: 'label.year', placeholder: '예) 2026 — 비우면 올해' }]\n\nRestDaysTask.help = 'integration/task/data-go-kr-rest-days'\n\nTaskRegistry.registerTaskHandler('data-go-kr-rest-days', RestDaysTask)\n\nexport default RestDaysTask\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The holidays of a `getRestDeInfo` answer, as a calendar takes them (calendar `savePublicHolidays`, ADR-0179):
|
|
3
|
+
* the days marked as holidays, each once a name, in day order. Pure: the test loads it bare.
|
|
4
|
+
*/
|
|
5
|
+
export declare function restDaysOf(items: readonly {
|
|
6
|
+
locdate?: number | string;
|
|
7
|
+
dateName?: string;
|
|
8
|
+
isHoliday?: string;
|
|
9
|
+
}[], year: number): {
|
|
10
|
+
day: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.restDaysOf = restDaysOf;
|
|
4
|
+
/**
|
|
5
|
+
* The holidays of a `getRestDeInfo` answer, as a calendar takes them (calendar `savePublicHolidays`, ADR-0179):
|
|
6
|
+
* the days marked as holidays, each once a name, in day order. Pure: the test loads it bare.
|
|
7
|
+
*/
|
|
8
|
+
function restDaysOf(items, year) {
|
|
9
|
+
const seen = new Set();
|
|
10
|
+
const days = [];
|
|
11
|
+
for (const item of items) {
|
|
12
|
+
if (item.isHoliday !== 'Y')
|
|
13
|
+
continue;
|
|
14
|
+
const text = String(item.locdate ?? '');
|
|
15
|
+
if (!/^\d{8}$/.test(text) || !text.startsWith(String(year)))
|
|
16
|
+
continue;
|
|
17
|
+
const day = `${text.slice(0, 4)}-${text.slice(4, 6)}-${text.slice(6, 8)}`;
|
|
18
|
+
const name = String(item.dateName ?? '').trim();
|
|
19
|
+
if (!name || seen.has(`${day} ${name}`))
|
|
20
|
+
continue;
|
|
21
|
+
seen.add(`${day} ${name}`);
|
|
22
|
+
days.push({ day, name });
|
|
23
|
+
}
|
|
24
|
+
return days.sort((a, b) => a.day.localeCompare(b.day));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=rest-days.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest-days.js","sourceRoot":"","sources":["../../../../server/engine/task/special-day/rest-days.ts"],"names":[],"mappings":";;AAIA,gCAcC;AAlBD;;;GAGG;AACH,SAAgB,UAAU,CAAC,KAAsF,EAAE,IAAY;IAC7H,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,MAAM,IAAI,GAAoC,EAAE,CAAA;IAChD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,SAAS,KAAK,GAAG;YAAE,SAAQ;QACpC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;QACvC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAAE,SAAQ;QACrE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;QACzE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;QAC/C,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YAAE,SAAQ;QACjD,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,CAAA;QAC1B,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1B,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACxD,CAAC","sourcesContent":["/**\n * The holidays of a `getRestDeInfo` answer, as a calendar takes them (calendar `savePublicHolidays`, ADR-0179):\n * the days marked as holidays, each once a name, in day order. Pure: the test loads it bare.\n */\nexport function restDaysOf(items: readonly { locdate?: number | string; dateName?: string; isHoliday?: string }[], year: number): { day: string; name: string }[] {\n const seen = new Set<string>()\n const days: { day: string; name: string }[] = []\n for (const item of items) {\n if (item.isHoliday !== 'Y') continue\n const text = String(item.locdate ?? '')\n if (!/^\\d{8}$/.test(text) || !text.startsWith(String(year))) continue\n const day = `${text.slice(0, 4)}-${text.slice(4, 6)}-${text.slice(6, 8)}`\n const name = String(item.dateName ?? '').trim()\n if (!name || seen.has(`${day} ${name}`)) continue\n seen.add(`${day} ${name}`)\n days.push({ day, name })\n }\n return days.sort((a, b) => a.day.localeCompare(b.day))\n}\n"]}
|