@nahisaho/katashiro-core 0.1.0
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/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +41 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +79 -0
- package/dist/logger.js.map +1 -0
- package/dist/result.d.ts +42 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +32 -0
- package/dist/result.js.map +1 -0
- package/dist/types.d.ts +98 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +22 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +39 -0
- package/dist/utils.js.map +1 -0
- package/package.json +41 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nahisaho/katashiro-core
|
|
3
|
+
* 共通型・ユーティリティ
|
|
4
|
+
*
|
|
5
|
+
* @requirement REQ-NFR-006, REQ-NFR-007
|
|
6
|
+
* @design DES-KATASHIRO-001 §2.2
|
|
7
|
+
* @task TSK-001
|
|
8
|
+
*/
|
|
9
|
+
export type { Result, Ok, Err } from './result.js';
|
|
10
|
+
export { ok, err, isOk, isErr } from './result.js';
|
|
11
|
+
export type { ID, Timestamp, URL, SearchQuery, SearchResult, SearchOptions, Source, SourceMetadata, Content, ContentType, KatashiroError, ErrorCode, } from './types.js';
|
|
12
|
+
export { generateId, formatTimestamp, validateUrl } from './utils.js';
|
|
13
|
+
export type { LogLevel, LogEntry } from './logger.js';
|
|
14
|
+
export { Logger, createLogger } from './logger.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGnD,YAAY,EAEV,EAAE,EACF,SAAS,EACT,GAAG,EAEH,WAAW,EACX,YAAY,EACZ,aAAa,EAEb,MAAM,EACN,cAAc,EAEd,OAAO,EACP,WAAW,EAEX,cAAc,EACd,SAAS,GACV,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGtE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nahisaho/katashiro-core
|
|
3
|
+
* 共通型・ユーティリティ
|
|
4
|
+
*
|
|
5
|
+
* @requirement REQ-NFR-006, REQ-NFR-007
|
|
6
|
+
* @design DES-KATASHIRO-001 §2.2
|
|
7
|
+
* @task TSK-001
|
|
8
|
+
*/
|
|
9
|
+
export { ok, err, isOk, isErr } from './result.js';
|
|
10
|
+
// ユーティリティ
|
|
11
|
+
export { generateId, formatTimestamp, validateUrl } from './utils.js';
|
|
12
|
+
export { Logger, createLogger } from './logger.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAuBnD,UAAU;AACV,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAItE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ロガー
|
|
3
|
+
*
|
|
4
|
+
* @requirement REQ-NFR-006
|
|
5
|
+
* @design DES-KATASHIRO-001 §2.2
|
|
6
|
+
* @task TSK-001
|
|
7
|
+
*/
|
|
8
|
+
import type { Timestamp } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* ログレベル
|
|
11
|
+
*/
|
|
12
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
13
|
+
/**
|
|
14
|
+
* ログエントリ
|
|
15
|
+
*/
|
|
16
|
+
export interface LogEntry {
|
|
17
|
+
readonly level: LogLevel;
|
|
18
|
+
readonly message: string;
|
|
19
|
+
readonly context?: Record<string, unknown>;
|
|
20
|
+
readonly timestamp: Timestamp;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* ロガーインターフェース
|
|
24
|
+
*/
|
|
25
|
+
export interface Logger {
|
|
26
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
27
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
28
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
29
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* ロガーを作成
|
|
33
|
+
*/
|
|
34
|
+
export declare function createLogger(name: string, minLevel?: LogLevel): Logger;
|
|
35
|
+
/**
|
|
36
|
+
* デフォルトロガー
|
|
37
|
+
*/
|
|
38
|
+
export declare const Logger: {
|
|
39
|
+
create: typeof createLogger;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"A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-001 §2.2
|
|
6
|
+
* @task TSK-001
|
|
7
|
+
*/
|
|
8
|
+
import { formatTimestamp } from './utils.js';
|
|
9
|
+
/**
|
|
10
|
+
* ロガー実装
|
|
11
|
+
*/
|
|
12
|
+
class LoggerImpl {
|
|
13
|
+
name;
|
|
14
|
+
minLevel;
|
|
15
|
+
constructor(name, minLevel = 'info') {
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.minLevel = minLevel;
|
|
18
|
+
}
|
|
19
|
+
levelPriority = {
|
|
20
|
+
debug: 0,
|
|
21
|
+
info: 1,
|
|
22
|
+
warn: 2,
|
|
23
|
+
error: 3,
|
|
24
|
+
};
|
|
25
|
+
shouldLog(level) {
|
|
26
|
+
return this.levelPriority[level] >= this.levelPriority[this.minLevel];
|
|
27
|
+
}
|
|
28
|
+
log(level, message, context) {
|
|
29
|
+
if (!this.shouldLog(level))
|
|
30
|
+
return;
|
|
31
|
+
const entry = {
|
|
32
|
+
level,
|
|
33
|
+
message,
|
|
34
|
+
context,
|
|
35
|
+
timestamp: formatTimestamp(),
|
|
36
|
+
};
|
|
37
|
+
const prefix = `[${entry.timestamp}] [${level.toUpperCase()}] [${this.name}]`;
|
|
38
|
+
const contextStr = context ? ` ${JSON.stringify(context)}` : '';
|
|
39
|
+
switch (level) {
|
|
40
|
+
case 'debug':
|
|
41
|
+
console.debug(`${prefix} ${message}${contextStr}`);
|
|
42
|
+
break;
|
|
43
|
+
case 'info':
|
|
44
|
+
console.info(`${prefix} ${message}${contextStr}`);
|
|
45
|
+
break;
|
|
46
|
+
case 'warn':
|
|
47
|
+
console.warn(`${prefix} ${message}${contextStr}`);
|
|
48
|
+
break;
|
|
49
|
+
case 'error':
|
|
50
|
+
console.error(`${prefix} ${message}${contextStr}`);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
debug(message, context) {
|
|
55
|
+
this.log('debug', message, context);
|
|
56
|
+
}
|
|
57
|
+
info(message, context) {
|
|
58
|
+
this.log('info', message, context);
|
|
59
|
+
}
|
|
60
|
+
warn(message, context) {
|
|
61
|
+
this.log('warn', message, context);
|
|
62
|
+
}
|
|
63
|
+
error(message, context) {
|
|
64
|
+
this.log('error', message, context);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* ロガーを作成
|
|
69
|
+
*/
|
|
70
|
+
export function createLogger(name, minLevel) {
|
|
71
|
+
return new LoggerImpl(name, minLevel);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* デフォルトロガー
|
|
75
|
+
*/
|
|
76
|
+
export const Logger = {
|
|
77
|
+
create: createLogger,
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA4B7C;;GAEG;AACH,MAAM,UAAU;IAEK;IACA;IAFnB,YACmB,IAAY,EACZ,WAAqB,MAAM;QAD3B,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAmB;IAC3C,CAAC;IAEa,aAAa,GAA6B;QACzD,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;KACT,CAAC;IAEM,SAAS,CAAC,KAAe;QAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC;IAEO,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,OAAiC;QAC7E,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAAE,OAAO;QAEnC,MAAM,KAAK,GAAa;YACtB,KAAK;YACL,OAAO;YACP,OAAO;YACP,SAAS,EAAE,eAAe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AAC,CAAC;IACtC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,QAAmB;IAC5D,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,MAAM,EAAE,YAAY;CACrB,CAAC"}
|
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result型 - 失敗可能な操作の結果を表現
|
|
3
|
+
*
|
|
4
|
+
* @requirement REQ-NFR-006
|
|
5
|
+
* @design DES-KATASHIRO-001 §2.2
|
|
6
|
+
* @task TSK-001
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 成功結果
|
|
10
|
+
*/
|
|
11
|
+
export interface Ok<T> {
|
|
12
|
+
readonly _tag: 'Ok';
|
|
13
|
+
readonly value: T;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 失敗結果
|
|
17
|
+
*/
|
|
18
|
+
export interface Err<E> {
|
|
19
|
+
readonly _tag: 'Err';
|
|
20
|
+
readonly error: E;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Result型 - 成功または失敗を表現
|
|
24
|
+
*/
|
|
25
|
+
export type Result<T, E> = Ok<T> | Err<E>;
|
|
26
|
+
/**
|
|
27
|
+
* 成功結果を作成
|
|
28
|
+
*/
|
|
29
|
+
export declare function ok<T>(value: T): Ok<T>;
|
|
30
|
+
/**
|
|
31
|
+
* 失敗結果を作成
|
|
32
|
+
*/
|
|
33
|
+
export declare function err<E>(error: E): Err<E>;
|
|
34
|
+
/**
|
|
35
|
+
* 成功かどうかを判定
|
|
36
|
+
*/
|
|
37
|
+
export declare function isOk<T, E>(result: Result<T, E>): result is Ok<T>;
|
|
38
|
+
/**
|
|
39
|
+
* 失敗かどうかを判定
|
|
40
|
+
*/
|
|
41
|
+
export declare function isErr<T, E>(result: Result<T, E>): result is Err<E>;
|
|
42
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAE1C;;GAEG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAErC;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAEvC;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAEhE;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAElE"}
|
package/dist/result.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result型 - 失敗可能な操作の結果を表現
|
|
3
|
+
*
|
|
4
|
+
* @requirement REQ-NFR-006
|
|
5
|
+
* @design DES-KATASHIRO-001 §2.2
|
|
6
|
+
* @task TSK-001
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 成功結果を作成
|
|
10
|
+
*/
|
|
11
|
+
export function ok(value) {
|
|
12
|
+
return { _tag: 'Ok', value };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 失敗結果を作成
|
|
16
|
+
*/
|
|
17
|
+
export function err(error) {
|
|
18
|
+
return { _tag: 'Err', error };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 成功かどうかを判定
|
|
22
|
+
*/
|
|
23
|
+
export function isOk(result) {
|
|
24
|
+
return result._tag === 'Ok';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 失敗かどうかを判定
|
|
28
|
+
*/
|
|
29
|
+
export function isErr(result) {
|
|
30
|
+
return result._tag === 'Err';
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuBH;;GAEG;AACH,MAAM,UAAU,EAAE,CAAI,KAAQ;IAC5B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAI,KAAQ;IAC7B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAO,MAAoB;IAC7C,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAO,MAAoB;IAC9C,OAAO,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC;AAC/B,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 共通型定義
|
|
3
|
+
*
|
|
4
|
+
* @requirement REQ-NFR-006
|
|
5
|
+
* @design DES-KATASHIRO-001 §2.2
|
|
6
|
+
* @task TSK-001
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 識別子型
|
|
10
|
+
*/
|
|
11
|
+
export type ID = string;
|
|
12
|
+
/**
|
|
13
|
+
* タイムスタンプ型 (ISO 8601形式)
|
|
14
|
+
*/
|
|
15
|
+
export type Timestamp = string;
|
|
16
|
+
/**
|
|
17
|
+
* URL型
|
|
18
|
+
*/
|
|
19
|
+
export type URL = string;
|
|
20
|
+
/**
|
|
21
|
+
* 検索クエリ
|
|
22
|
+
*/
|
|
23
|
+
export interface SearchQuery {
|
|
24
|
+
readonly query: string;
|
|
25
|
+
readonly language?: string;
|
|
26
|
+
readonly region?: string;
|
|
27
|
+
readonly maxResults?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 検索オプション
|
|
31
|
+
*/
|
|
32
|
+
export interface SearchOptions {
|
|
33
|
+
readonly timeout?: number;
|
|
34
|
+
readonly retryCount?: number;
|
|
35
|
+
readonly proxy?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 検索結果
|
|
39
|
+
*/
|
|
40
|
+
export interface SearchResult {
|
|
41
|
+
readonly id: ID;
|
|
42
|
+
readonly title: string;
|
|
43
|
+
readonly url: URL;
|
|
44
|
+
readonly snippet: string;
|
|
45
|
+
readonly source: string;
|
|
46
|
+
readonly timestamp: Timestamp;
|
|
47
|
+
readonly relevanceScore?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* ソースメタデータ
|
|
51
|
+
*/
|
|
52
|
+
export interface SourceMetadata {
|
|
53
|
+
readonly title: string;
|
|
54
|
+
readonly author?: string;
|
|
55
|
+
readonly publishedAt?: Timestamp;
|
|
56
|
+
readonly lastModified?: Timestamp;
|
|
57
|
+
readonly language?: string;
|
|
58
|
+
readonly credibilityScore?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* ソース情報
|
|
62
|
+
*/
|
|
63
|
+
export interface Source {
|
|
64
|
+
readonly id: ID;
|
|
65
|
+
readonly url: URL;
|
|
66
|
+
readonly metadata: SourceMetadata;
|
|
67
|
+
readonly fetchedAt: Timestamp;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* コンテンツタイプ
|
|
71
|
+
*/
|
|
72
|
+
export type ContentType = 'article' | 'report' | 'summary' | 'outline' | 'translation' | 'chart' | 'podcast';
|
|
73
|
+
/**
|
|
74
|
+
* コンテンツ
|
|
75
|
+
*/
|
|
76
|
+
export interface Content {
|
|
77
|
+
readonly id: ID;
|
|
78
|
+
readonly type: ContentType;
|
|
79
|
+
readonly title: string;
|
|
80
|
+
readonly body: string;
|
|
81
|
+
readonly sources: Source[];
|
|
82
|
+
readonly createdAt: Timestamp;
|
|
83
|
+
readonly updatedAt: Timestamp;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* エラーコード
|
|
87
|
+
*/
|
|
88
|
+
export type ErrorCode = 'NETWORK_ERROR' | 'TIMEOUT_ERROR' | 'RATE_LIMIT_ERROR' | 'AUTH_ERROR' | 'PARSE_ERROR' | 'VALIDATION_ERROR' | 'NOT_FOUND_ERROR' | 'INTERNAL_ERROR';
|
|
89
|
+
/**
|
|
90
|
+
* KATASHIROエラー基底型
|
|
91
|
+
*/
|
|
92
|
+
export interface KatashiroError {
|
|
93
|
+
readonly code: ErrorCode;
|
|
94
|
+
readonly message: string;
|
|
95
|
+
readonly cause?: unknown;
|
|
96
|
+
readonly timestamp: Timestamp;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH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AMG"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ユーティリティ関数
|
|
3
|
+
*
|
|
4
|
+
* @requirement REQ-NFR-006
|
|
5
|
+
* @design DES-KATASHIRO-001 §2.2
|
|
6
|
+
* @task TSK-001
|
|
7
|
+
*/
|
|
8
|
+
import type { ID, Timestamp, URL } from './types.js';
|
|
9
|
+
import { Result } from './result.js';
|
|
10
|
+
/**
|
|
11
|
+
* ユニークIDを生成
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateId(prefix?: string): ID;
|
|
14
|
+
/**
|
|
15
|
+
* 現在時刻をISO 8601形式でフォーマット
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatTimestamp(date?: Date): Timestamp;
|
|
18
|
+
/**
|
|
19
|
+
* URLの妥当性を検証
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateUrl(url: string): Result<URL, string>;
|
|
22
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,MAAM,EAAW,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,CAK9C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAEtD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAU5D"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ユーティリティ関数
|
|
3
|
+
*
|
|
4
|
+
* @requirement REQ-NFR-006
|
|
5
|
+
* @design DES-KATASHIRO-001 §2.2
|
|
6
|
+
* @task TSK-001
|
|
7
|
+
*/
|
|
8
|
+
import { ok, err } from './result.js';
|
|
9
|
+
/**
|
|
10
|
+
* ユニークIDを生成
|
|
11
|
+
*/
|
|
12
|
+
export function generateId(prefix) {
|
|
13
|
+
const timestamp = Date.now().toString(36);
|
|
14
|
+
const random = Math.random().toString(36).substring(2, 8);
|
|
15
|
+
const id = `${timestamp}-${random}`;
|
|
16
|
+
return prefix ? `${prefix}-${id}` : id;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 現在時刻をISO 8601形式でフォーマット
|
|
20
|
+
*/
|
|
21
|
+
export function formatTimestamp(date) {
|
|
22
|
+
return (date ?? new Date()).toISOString();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* URLの妥当性を検証
|
|
26
|
+
*/
|
|
27
|
+
export function validateUrl(url) {
|
|
28
|
+
try {
|
|
29
|
+
const parsed = new globalThis.URL(url);
|
|
30
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
31
|
+
return err('URL must use http or https protocol');
|
|
32
|
+
}
|
|
33
|
+
return ok(url);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return err('Invalid URL format');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAU,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAAe;IACxC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,MAAM,EAAE,GAAG,GAAG,SAAS,IAAI,MAAM,EAAE,CAAC;IACpC,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAW;IACzC,OAAO,CAAC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChE,OAAO,GAAG,CAAC,qCAAqC,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nahisaho/katashiro-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "KATASHIRO Core - 共通型・ユーティリティ",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"clean": "rm -rf dist",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:watch": "vitest"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"katashiro",
|
|
25
|
+
"core"
|
|
26
|
+
],
|
|
27
|
+
"author": "nahisaho",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/nahisaho/katashiro.git",
|
|
32
|
+
"directory": "packages/core"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/nahisaho/katashiro#readme",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/nahisaho/katashiro/issues"
|
|
40
|
+
}
|
|
41
|
+
}
|