@serverkit-lib/logic-module-client v0.0.87
logic-module-client
소개
이 모듈(logic-module-client)은 Built-in 모듈 및 노드(metadata)를 추출하고, 관련된 인터페이스를 제공하는 기능을 담고 있습니다. 아래에서는 export된 주요 요소인 IBuiltInModule, IBuiltInNode, getMetadata 함수에 대한 설명과 사용법을 다룹니다.
인터페이스
IBuiltInModule
설명: Built-in 모듈을 표현하는 인터페이스입니다. modules/builtInModules 디렉토리에 위치한 .js 파일들을 스캔하여 관련 정보를 추출하고, 이를 구조화하여 제공합니다.
프로퍼티:
_id:string
모듈을 식별할 수 있는 고유 ID (일반적으로 파일명에서 확장자를 제외한 값)category:string[]
모듈의 카테고리를 나타내는 문자열 배열. 예를 들어math.add.js파일의 경우["math"]가 카테고리가 될 수 있습니다.explain:IExplainI18n
국제화 모듈(i18n)을 위한 다양한 언어로 구성된 설명문 객체. 모듈의 용도나 기능에 대한 정보가 담겨 있습니다.templateSignature:string[]
모듈에 정의된 제네릭 템플릿 시그니처를 담는 배열. 템플릿 파라미터 등의 타입 정보가 포함될 수 있습니다.param:IBuiltInModuleParamReturn[]
모듈에 대한 파라미터 정보 배열. 파라미터의 이름, 타입, 설명 등이 포함됩니다.return:IBuiltInModuleParamReturn[]
모듈 실행 결과로 반환되는 값에 대한 정보 배열. 반환값의 타입 및 설명 등이 포함됩니다.callback:string[]
모듈 실행 중 호출되는 콜백 함수 목록. 콜백 관련 정보가 문자열 배열 형태로 담겨집니다.
예제:
const module: IBuiltInModule = {
_id: "array.app",
category: ["Array"],
explain: {
ko: "주어진 배열값의 특정 index에 해당하는 값을 가져옵니다.",
en: "Retrieves the value at a specific index in a given array."
},
templateSignature: ["<T extends number>"],
param: [
{ name: "array", type: { for: "array", signature: "T" } },
{ name: "index", type: "number" }
],
return: [{ name: "result", type: { signature: "T" } }],
callback: []
};IBuiltInNode
설명:modules/builtInNodes 디렉토리에 위치한 .xml 파일로부터 노드 메타데이터를 추출하고, 이를 JSON 형태로 제공하는 인터페이스입니다.
프로퍼티:
_id:string
노드를 식별할 수 있는 고유 ID (노드 파일명에서 확장자를 제외한 값)explain:IExplainI18n
국제화 모듈(i18n)을 위한 다양한 언어로 구성된 설명문 객체. 노드의 용도나 기능에 대한 정보가 담겨 있습니다.Node:Record<string, any>
XML 파일 파싱 결과를 담고 있는 객체로, 노드의 속성 및 구조적인 정보가 포함됩니다.
예시:
const node: IBuiltInNode = {
_id: "exampleNode",
explain: {
ko: "예시 노드입니다.",
en: "This is example Node."
},
Node: {
Node: {
$: { type: "action" },
Property: [{ $: { name: "speed", value: "10" } }]
}
}
};getMetadata
설명:getMetadata() 함수는 modules/builtInModules 및 modules/builtInNodes 디렉토리 내의 .js, .xml 파일을 스캔하여 Built-in 모듈 및 노드의 메타데이터를 추출하는 비동기 함수입니다. 이 함수는 모든 메타데이터를 수집한 뒤, 모듈과 노드에 대한 배열 형태의 결과를 반환합니다.
시그니처:
async function getMetadata(): Promise<{ modules: IBuiltInModule[]; nodes: IBuiltInNode[] }>;반환값:
modules:IBuiltInModule[]
modules/builtInModules 디렉토리에서 추출한 모든 Built-in 모듈 메타데이터를 담은 배열입니다.nodes:IBuiltInNode[]
modules/builtInNodes 디렉토리에서 추출한 모든 Built-in 노드 메타데이터를 담은 배열입니다.
(async () => {
const { modules, nodes } = await getMetadata();
// 모듈 정보 출력
modules.forEach(mod => {
console.log(`Module ID: ${mod._id}`);
console.log(`Category: ${mod.category.join(", ")}`);
console.log(`Description: ${mod.explain}`);
});
// 노드 정보 출력
nodes.forEach(node => {
console.log(`Node ID: ${node._id}`);
console.log("Node Content:", node.Node);
});
})();9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago