@brix-sdk/platform-shared 1.0.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/README.md +58 -0
- package/dist/chunk-4CV4JOE5.js +24 -0
- package/dist/chunk-4CV4JOE5.js.map +1 -0
- package/dist/chunk-5CQ3FANY.js +162 -0
- package/dist/chunk-5CQ3FANY.js.map +1 -0
- package/dist/chunk-DJX6ASLI.js +143 -0
- package/dist/chunk-DJX6ASLI.js.map +1 -0
- package/dist/chunk-GNCIKXWI.js +3 -0
- package/dist/chunk-GNCIKXWI.js.map +1 -0
- package/dist/chunk-OGZE7TFO.js +509 -0
- package/dist/chunk-OGZE7TFO.js.map +1 -0
- package/dist/constants/index.d.ts +325 -0
- package/dist/constants/index.js +4 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +4 -0
- package/dist/http/index.js.map +1 -0
- package/dist/id/index.d.ts +57 -0
- package/dist/id/index.js +64 -0
- package/dist/id/index.js.map +1 -0
- package/dist/id-BFKGN254.d.ts +178 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +174 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +795 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/id/index.ts"],"names":["generateUUID","generateShortId","generateNanoId","generateTimestampId"],"mappings":";;;;;AAiCA,OAAA,EAAA;AAqEO,SAAS,kBAAkB,MAAA,EAAyC;AACzE,EAAA,MAAM,EAAE,UAAU,MAAA,GAAS,EAAA,EAAI,gBAAgB,CAAA,EAAG,YAAA,GAAe,IAAG,GAAI,MAAA;AAGxE,EAAA,MAAM;AAAA,IACJ,YAAA,EAAAA,aAAAA;AAAA,IACA,eAAA,EAAAC,gBAAAA;AAAA,IACA,cAAA,EAAAC,eAAAA;AAAA,IACA,mBAAA,EAAAC,oBAAAA;AAAA,IACA;AAAA,GACF,IAAI,OAAA,EAAA,EAAA,YAAA,CAAA,UAAA,CAAA,CAAA;AAEJ,EAAA,QAAQ,QAAA;AAAU,IAChB,KAAK,MAAA;AACH,MAAA,OAAO,MAAM,CAAA,EAAG,MAAM,CAAA,EAAGH,eAAc,CAAA,CAAA;AAAA,IACzC,KAAK,OAAA;AACH,MAAA,OAAO,MAAM,CAAA,EAAG,MAAM,CAAA,EAAGC,gBAAAA,CAAgB,aAAa,CAAC,CAAA,CAAA;AAAA,IACzD,KAAK,MAAA;AACH,MAAA,OAAO,MAAM,CAAA,EAAG,MAAM,CAAA,EAAGC,eAAAA,CAAe,YAAY,CAAC,CAAA,CAAA;AAAA,IACvD,KAAK,WAAA;AACH,MAAA,OAAO,MAAM,CAAA,EAAG,MAAM,CAAA,EAAGC,sBAAqB,CAAA,CAAA;AAAA,IAChD,KAAK,WAAA,EAAa;AAChB,MAAA,MAAM,SAAA,GAAY,IAAI,oBAAA,EAAqB;AAC3C,MAAA,OAAO,MAAM,CAAA,EAAG,MAAM,CAAA,EAAG,SAAA,CAAU,QAAQ,CAAA,CAAA;AAAA,IAC7C;AAAA,IACA;AACE,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,qBAAA,EAAwB,QAAQ,CAAA,CAAE,CAAA;AAAA;AAExD","file":"index.js","sourcesContent":["/**\r\n * @file ID 生成器模块入口\r\n * @description 独立的 ID 生成器子包 - 提供各种 ID 生成策略\r\n * @module @brix/platform-shared/id\r\n * @version 3.1.0\r\n * \r\n * 【模块说明】\r\n * 本模块从 @brix/platform-shared/utils 拆分而来,\r\n * 提供独立的 ID 生成器子包,支持更好的 tree-shaking。\r\n * \r\n * 【选择建议】\r\n * - UUID:需要全球唯一且标准格式时使用\r\n * - ShortId:用于 URL、临时标识等需要短 ID 的场景\r\n * - NanoId:URL 安全的短 ID,比 ShortId 更随机\r\n * - TimestampId:需要按时间排序的场景\r\n * - SnowflakeId:高并发分布式系统(需配合节点 ID)\r\n * \r\n * 【使用方式】\r\n * ```typescript\r\n * // 推荐:直接从子包导入(更好的 tree-shaking)\r\n * import { generateUUID, SnowflakeIdGenerator } from '@brix/platform-shared/id';\r\n * \r\n * // 兼容:从主包导入(会加载所有工具)\r\n * import { generateUUID } from '@brix/platform-shared';\r\n * ```\r\n * \r\n * @license Apache-2.0\r\n */\r\n\r\n// ============================================================================\r\n// 从 utils/id.ts 重新导出所有 ID 生成相关功能\r\n// ============================================================================\r\n\r\nexport {\r\n // UUID\r\n generateUUID,\r\n isValidUUID,\r\n \r\n // 短 ID\r\n generateShortId,\r\n generateNanoId,\r\n \r\n // 时间戳 ID\r\n generateTimestampId,\r\n extractTimestampFromId,\r\n \r\n // 雪花 ID\r\n SimpleSnowflake,\r\n generateSnowflakeId,\r\n \r\n // 序列 ID 生成器\r\n createSequenceIdGenerator,\r\n createDailySequenceIdGenerator,\r\n} from '../utils/id';\r\n\r\n// ============================================================================\r\n// 类型导出\r\n// ============================================================================\r\n\r\n/**\r\n * ID 生成策略类型\r\n */\r\nexport type IdStrategy = 'uuid' | 'short' | 'nano' | 'timestamp' | 'snowflake';\r\n\r\n/**\r\n * ID 生成器配置\r\n */\r\nexport interface IdGeneratorConfig {\r\n /** ID 生成策略 */\r\n strategy: IdStrategy;\r\n /** ID 前缀(可选) */\r\n prefix?: string;\r\n /** 短 ID 长度(默认 8) */\r\n shortIdLength?: number;\r\n /** NanoID 长度(默认 21) */\r\n nanoIdLength?: number;\r\n}\r\n\r\n/**\r\n * 创建配置化的 ID 生成器\r\n * \r\n * 【功能说明】\r\n * 根据配置创建 ID 生成器函数,支持多种 ID 策略。\r\n * \r\n * @param config ID 生成器配置\r\n * @returns ID 生成函数\r\n * \r\n * @example\r\n * ```typescript\r\n * // 创建 UUID 生成器\r\n * const genUUID = createIdGenerator({ strategy: 'uuid' });\r\n * genUUID(); // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'\r\n * \r\n * // 创建带前缀的短 ID 生成器\r\n * const genOrderId = createIdGenerator({ \r\n * strategy: 'short', \r\n * prefix: 'ORD-',\r\n * shortIdLength: 12,\r\n * });\r\n * genOrderId(); // 'ORD-a1B2c3D4e5F6'\r\n * ```\r\n */\r\nexport function createIdGenerator(config: IdGeneratorConfig): () => string {\r\n const { strategy, prefix = '', shortIdLength = 8, nanoIdLength = 21 } = config;\r\n \r\n // 动态导入避免循环依赖\r\n const {\r\n generateUUID,\r\n generateShortId,\r\n generateNanoId,\r\n generateTimestampId,\r\n SnowflakeIdGenerator,\r\n } = require('../utils/id');\r\n \r\n switch (strategy) {\r\n case 'uuid':\r\n return () => `${prefix}${generateUUID()}`;\r\n case 'short':\r\n return () => `${prefix}${generateShortId(shortIdLength)}`;\r\n case 'nano':\r\n return () => `${prefix}${generateNanoId(nanoIdLength)}`;\r\n case 'timestamp':\r\n return () => `${prefix}${generateTimestampId()}`;\r\n case 'snowflake': {\r\n const generator = new SnowflakeIdGenerator();\r\n return () => `${prefix}${generator.nextId()}`;\r\n }\r\n default:\r\n throw new Error(`Unknown ID strategy: ${strategy}`);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file id.ts
|
|
3
|
+
* @description ID 生成工具函数�? * @module @brix-sdk/utils/id
|
|
4
|
+
* @version 3.0.0
|
|
5
|
+
*
|
|
6
|
+
* 【模块说明�? * 提供各种 ID 生成工具,包�?UUID、短 ID、NanoID、时间戳 ID、雪�?ID 等�? * 不同场景可选择不同�?ID 生成策略�? *
|
|
7
|
+
* 【选择建议�? * - UUID:需要全球唯一且标准格式时使用
|
|
8
|
+
* - ShortId:用�?URL、临时标识等需要短 ID 的场�? * - NanoId:URL 安全的短 ID,比 ShortId 更随�? * - TimestampId:需要按时间排序的场�? * - SnowflakeId:高并发分布式系统(需配合节点 ID�? *
|
|
9
|
+
* @license Apache-2.0
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* 生成 UUID v4
|
|
13
|
+
*
|
|
14
|
+
* 【功能说明�? * 生成符合 RFC 4122 v4 标准�?UUID�? * 优先使用原生 crypto.randomUUID(),降级使用随机数生成�? *
|
|
15
|
+
* 【特点�? * - 全球唯一
|
|
16
|
+
* - 标准格式,便于跨系统交互
|
|
17
|
+
* - 36字符(含连字符)
|
|
18
|
+
*
|
|
19
|
+
* @returns UUID 字符�? *
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* generateUUID(); // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
|
|
23
|
+
* generateUUID(); // '7c9e6679-7425-40de-944b-e07fc1f90ae7'
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function generateUUID(): string;
|
|
27
|
+
/**
|
|
28
|
+
* 验证 UUID 格式
|
|
29
|
+
*
|
|
30
|
+
* 【功能说明�? * 验证字符串是否为有效�?UUID 格式(v1-v5)�? *
|
|
31
|
+
* @param uuid UUID 字符�? * @returns 是否为有�?UUID
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* isValidUUID('f47ac10b-58cc-4372-a567-0e02b2c3d479'); // true
|
|
36
|
+
* isValidUUID('not-a-uuid'); // false
|
|
37
|
+
* isValidUUID('f47ac10b58cc4372a5670e02b2c3d479'); // false(缺少连字符�? * ```
|
|
38
|
+
*/
|
|
39
|
+
declare function isValidUUID(uuid: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* 生成�?ID
|
|
42
|
+
*
|
|
43
|
+
* 【功能说明�? * 生成指定长度的随�?ID,默认使用字母数字字符集�? * 适用�?URL 路径、临时标识等场景�? *
|
|
44
|
+
* 【碰撞概率�? * 8位默认字符集约有 218 万亿种组合(62^8�? *
|
|
45
|
+
* @param length ID 长度(默�?8�? * @param charset 字符集(默认字母数字�? * @returns �?ID 字符�? *
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* generateShortId(); // 'a1B2c3D4'
|
|
49
|
+
* generateShortId(12); // 'a1B2c3D4e5F6'
|
|
50
|
+
* generateShortId(6, '0123456789'); // '123456'(纯数字�? * ```
|
|
51
|
+
*/
|
|
52
|
+
declare function generateShortId(length?: number, charset?: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* 生成 NanoID 风格�?ID
|
|
55
|
+
*
|
|
56
|
+
* 【功能说明�? * 生成 NanoID 风格的随�?ID,使�?URL 安全字符集�? * �?UUID 更短,比 ShortId 更随机�? *
|
|
57
|
+
* 【特点�? * - URL 安全(无需编码�? * - 默认21位,碰撞概率极低
|
|
58
|
+
* - �?UUID 更短
|
|
59
|
+
*
|
|
60
|
+
* @param length ID 长度(默�?21�? * @returns NanoID 字符�? *
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* generateNanoId(); // 'V1StGXR8_Z5jdHi6B-myT'
|
|
64
|
+
* generateNanoId(10); // 'IRFa-VaY2b'
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare function generateNanoId(length?: number): string;
|
|
68
|
+
/**
|
|
69
|
+
* 生成基于时间戳的 ID
|
|
70
|
+
*
|
|
71
|
+
* 【功能说明�? * 生成包含时间信息�?ID,格式为:时间戳(base36) + 随机串�? * 适用于需要按时间排序或提取时间信息的场景�? *
|
|
72
|
+
* 【优势�? * - 按创建时间自然排�? * - 可以�?ID 中提取创建时�? * - �?UUID 更短
|
|
73
|
+
*
|
|
74
|
+
* @param randomLength 随机部分长度(默�?6�? * @returns 时间�?ID
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* generateTimestampId(); // 'lnjhgk4xabcdef'
|
|
79
|
+
* generateTimestampId(10); // 'lnjhgk4xabcdefghij'
|
|
80
|
+
*
|
|
81
|
+
* // ID 可按时间排序
|
|
82
|
+
* const ids = [id1, id2, id3].sort(); // 按创建时间排�? * ```
|
|
83
|
+
*/
|
|
84
|
+
declare function generateTimestampId(randomLength?: number): string;
|
|
85
|
+
/**
|
|
86
|
+
* 从时间戳 ID 中提取时�? *
|
|
87
|
+
* 【功能说明�? * 尝试从时间戳 ID 中提取创建时间�? * 仅适用�?generateTimestampId 生成�?ID�? *
|
|
88
|
+
* @param id 时间�?ID
|
|
89
|
+
* @returns Date 对象,解析失败返�?null
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const id = generateTimestampId();
|
|
94
|
+
* const date = extractTimestampFromId(id);
|
|
95
|
+
* console.log(date); // 2024-01-01T12:00:00.000Z
|
|
96
|
+
*
|
|
97
|
+
* extractTimestampFromId('invalid'); // null
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare function extractTimestampFromId(id: string): Date | null;
|
|
101
|
+
/**
|
|
102
|
+
* 创建序列 ID 生成�? *
|
|
103
|
+
* 【功能说明�? * 创建一个自增序�?ID 生成器,每次调用返回递增�?ID�? * 适用于单机环境下的唯一 ID 生成�? *
|
|
104
|
+
* 【注意�? * - 仅在单进程内唯一
|
|
105
|
+
* - 重启后计数器重置
|
|
106
|
+
* - 不适合分布式环�? *
|
|
107
|
+
* @param prefix ID 前缀(可选)
|
|
108
|
+
* @param start 起始值(默认 1�? * @returns 生成器函�? *
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const genOrderId = createSequenceIdGenerator('ORD-', 1000);
|
|
112
|
+
* genOrderId(); // 'ORD-1000'
|
|
113
|
+
* genOrderId(); // 'ORD-1001'
|
|
114
|
+
* genOrderId(); // 'ORD-1002'
|
|
115
|
+
*
|
|
116
|
+
* const genId = createSequenceIdGenerator();
|
|
117
|
+
* genId(); // '1'
|
|
118
|
+
* genId(); // '2'
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
declare function createSequenceIdGenerator(prefix?: string, start?: number): () => string;
|
|
122
|
+
/**
|
|
123
|
+
* 创建带日期前缀的序�?ID 生成�? *
|
|
124
|
+
* 【功能说明�? * 创建按日自增的序�?ID 生成器�? * 格式:前缀 + 日期(YYYYMMDD) + 序号(6�?�? * 每天计数器自动重置�? *
|
|
125
|
+
* 【适用场景�? * - 订单�? * - 流水�? * - 工单�? *
|
|
126
|
+
* @param prefix ID 前缀(可选)
|
|
127
|
+
* @returns 生成器函�? *
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const genOrderId = createDailySequenceIdGenerator('ORD');
|
|
131
|
+
* genOrderId(); // 'ORD20240101000001'
|
|
132
|
+
* genOrderId(); // 'ORD20240101000002'
|
|
133
|
+
*
|
|
134
|
+
* // 第二�? * genOrderId(); // 'ORD20240102000001'(计数器重置�? * ```
|
|
135
|
+
*/
|
|
136
|
+
declare function createDailySequenceIdGenerator(prefix?: string): () => string;
|
|
137
|
+
/**
|
|
138
|
+
* 简化版雪花 ID 生成�? *
|
|
139
|
+
* 【功能说明�? * 生成类似 Twitter Snowflake �?64 位唯一 ID�? * 此为简化实现,不含 workerId/datacenterId�? *
|
|
140
|
+
* 【ID 结构�? * - 时间戳(41位):可用约69�? * - 序列号(12位):每毫秒可生�?4096 �?ID
|
|
141
|
+
* - 随机数(10位):增加随机�? *
|
|
142
|
+
* 【注意�? * - 简化版适用于单节点或对全局唯一性要求不高的场景
|
|
143
|
+
* - 生产环境分布式部署建议使用服务端生成
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const snowflake = new SimpleSnowflake();
|
|
148
|
+
* snowflake.generate(); // '7123456789012345678'
|
|
149
|
+
* snowflake.generate(); // '7123456789012345679'
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare class SimpleSnowflake {
|
|
153
|
+
/** 当前序列�?*/
|
|
154
|
+
private sequence;
|
|
155
|
+
/** 上次生成时间�?*/
|
|
156
|
+
private lastTimestamp;
|
|
157
|
+
/**
|
|
158
|
+
* 生成雪花 ID
|
|
159
|
+
*
|
|
160
|
+
* @returns 雪花 ID 字符�? */
|
|
161
|
+
generate(): string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 生成雪花 ID
|
|
165
|
+
*
|
|
166
|
+
* 【功能说明�? * 使用默认生成器实例生成雪�?ID�? * 便捷函数,无需手动创建实例�? *
|
|
167
|
+
* @returns 雪花 ID 字符�? *
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* generateSnowflakeId(); // '7123456789012345678'
|
|
171
|
+
* generateSnowflakeId(); // '7123456789012345679'
|
|
172
|
+
*
|
|
173
|
+
* // 可按数值排序(时间有序�? * BigInt(id1) < BigInt(id2); // true(id1 先生成)
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
declare function generateSnowflakeId(): string;
|
|
177
|
+
|
|
178
|
+
export { SimpleSnowflake as S, createSequenceIdGenerator as a, generateShortId as b, createDailySequenceIdGenerator as c, generateSnowflakeId as d, extractTimestampFromId as e, generateTimestampId as f, generateNanoId as g, generateUUID as h, isValidUUID as i };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AsyncResult, LogLevel, PaginatedResult, PaginationParams, PlatformConfig, PlatformError, PlatformType, RuntimeEnvironment } from './types/index.js';
|
|
2
|
+
export { BaseEvent, EventMetadata, EventPriority, EventPublishOptions, EventSubscriptionOptions, MetadataEvent, PluginMetadata } from '@brix-sdk/runtime-sdk-api-web';
|
|
3
|
+
export { AUTH_ERROR_CODES, CAPABILITY_PREFIX, COMMON_ERROR_CODES, DEFAULT_RETRY_COUNT, DEFAULT_RETRY_DELAY, DEFAULT_TIMEOUT, ERROR_CODES, HTTP_METHODS, HTTP_STATUS, MAX_EVENT_HISTORY, NAVIGATION_ERROR_CODES, PLATFORM_VERSION, PLUGIN_ERROR_CODES, STORAGE_KEYS, STORAGE_KEY_PREFIX } from './constants/index.js';
|
|
4
|
+
export { PasswordStrength, PasswordStrengthResult, assert, assertNotNull, camelCase, cancelableDelay, capitalize, checkPasswordStrength, debounce, deepClone, deepMerge, delay, delayWith, formatCurrency, formatDate, formatDuration, formatFileSize, formatNumber, formatPercent, formatRelativeTime, isArray, isBoolean, isEmpty, isFunction, isInRange, isInteger, isNotNullOrUndefined, isNullOrUndefined, isNumber, isNumeric, isObject, isPositive, isPromise, isString, isValidBankCard, isValidEmail, isValidIPv4, isValidIdCard, isValidJSON, isValidPhone, isValidUnifiedCreditCode, isValidUrl, kebabCase, nextTick, parseFileSize, requestIdleCallback, throttle, truncate, withTimeout } from './utils/index.js';
|
|
5
|
+
export { S as SimpleSnowflake, c as createDailySequenceIdGenerator, a as createSequenceIdGenerator, e as extractTimestampFromId, g as generateNanoId, b as generateShortId, d as generateSnowflakeId, f as generateTimestampId, h as generateUUID, i as isValidUUID } from './id-BFKGN254.js';
|
|
6
|
+
export { CacheOptions, DEFAULT_CACHE_OPTIONS, DEFAULT_RETRY_OPTIONS, HttpError, HttpErrorCode, HttpErrorCodeType, HttpMethod, InterceptorManager, RETRYABLE_NETWORK_ERRORS, RETRYABLE_STATUS_CODES, RequestConfig, RequestInterceptor, ResponseInterceptor, RetryOptions, SimpleCache, calculateBackoffDelay, createRetryable, generateCacheKey, delay as httpDelay, shouldRetry, withCache, withRetry } from '@brix-sdk/infra-adapter-http-web';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AUTH_ERROR_CODES, CAPABILITY_PREFIX, COMMON_ERROR_CODES, DEFAULT_RETRY_COUNT, DEFAULT_RETRY_DELAY, DEFAULT_TIMEOUT, ERROR_CODES, HTTP_METHODS, HTTP_STATUS, MAX_EVENT_HISTORY, NAVIGATION_ERROR_CODES, PLATFORM_VERSION, PLUGIN_ERROR_CODES, STORAGE_KEYS, STORAGE_KEY_PREFIX } from './chunk-5CQ3FANY.js';
|
|
2
|
+
export { DEFAULT_CACHE_OPTIONS, DEFAULT_RETRY_OPTIONS, HttpError, HttpErrorCode, RETRYABLE_NETWORK_ERRORS, RETRYABLE_STATUS_CODES, SimpleCache, calculateBackoffDelay, createRetryable, generateCacheKey, delay as httpDelay, shouldRetry, withCache, withRetry } from './chunk-GNCIKXWI.js';
|
|
3
|
+
export { assert, assertNotNull, camelCase, cancelableDelay, capitalize, checkPasswordStrength, debounce, deepClone, deepMerge, delay, delayWith, formatCurrency, formatDate, formatDuration, formatFileSize, formatNumber, formatPercent, formatRelativeTime, isArray, isBoolean, isEmpty, isFunction, isInRange, isInteger, isNotNullOrUndefined, isNullOrUndefined, isNumber, isNumeric, isObject, isPositive, isPromise, isString, isValidBankCard, isValidEmail, isValidIPv4, isValidIdCard, isValidJSON, isValidPhone, isValidUnifiedCreditCode, isValidUrl, kebabCase, nextTick, parseFileSize, requestIdleCallback, throttle, truncate, withTimeout } from './chunk-OGZE7TFO.js';
|
|
4
|
+
export { SimpleSnowflake, createDailySequenceIdGenerator, createSequenceIdGenerator, extractTimestampFromId, generateNanoId, generateShortId, generateSnowflakeId, generateTimestampId, generateUUID, isValidUUID } from './chunk-DJX6ASLI.js';
|
|
5
|
+
import './chunk-4CV4JOE5.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export { BaseEvent, EventMetadata, EventPriority, EventPublishOptions, EventSubscriptionOptions, MetadataEvent, PluginMetadata } from '@brix-sdk/runtime-sdk-api-web';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright 2026 Brix Platform Authors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @file Platform common type definitions
|
|
20
|
+
* @description Cross-platform shared type definitions
|
|
21
|
+
* @module @brix-sdk/platform-shared/types/platform
|
|
22
|
+
* @version 3.1.0
|
|
23
|
+
*
|
|
24
|
+
* 【架构说明�? * v3.1.0 重构:PluginMetadata 现在�?@brix-sdk/runtime-sdk-api-web 重新导出�? * 消除类型并行定义问题。runtime-sdk-api-web 是权威定义位置�? *
|
|
25
|
+
* Architecture Note:
|
|
26
|
+
* v3.1.0 refactoring: PluginMetadata is now re-exported from @brix-sdk/runtime-sdk-api-web,
|
|
27
|
+
* eliminating parallel type definition issues. runtime-sdk-api-web is the authoritative source.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Re-export PluginMetadata from the authoritative source.
|
|
31
|
+
*
|
|
32
|
+
* 从权威定义位置重新导�?PluginMetadata 类型�? * @see {@link https://github.com/brix-framework/runtime-sdk | @brix-sdk/runtime-sdk-api-web}
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Platform type.
|
|
37
|
+
*/
|
|
38
|
+
type PlatformType = 'web' | 'mobile' | 'desktop';
|
|
39
|
+
/**
|
|
40
|
+
* Runtime environment.
|
|
41
|
+
*/
|
|
42
|
+
type RuntimeEnvironment = 'development' | 'staging' | 'production';
|
|
43
|
+
/**
|
|
44
|
+
* Log level.
|
|
45
|
+
*/
|
|
46
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
47
|
+
/**
|
|
48
|
+
* Platform configuration.
|
|
49
|
+
*/
|
|
50
|
+
interface PlatformConfig {
|
|
51
|
+
/**
|
|
52
|
+
* Platform type
|
|
53
|
+
*/
|
|
54
|
+
platform: PlatformType;
|
|
55
|
+
/**
|
|
56
|
+
* Runtime environment
|
|
57
|
+
*/
|
|
58
|
+
environment: RuntimeEnvironment;
|
|
59
|
+
/**
|
|
60
|
+
* Log level
|
|
61
|
+
*/
|
|
62
|
+
logLevel: LogLevel;
|
|
63
|
+
/**
|
|
64
|
+
* Whether debug mode is enabled
|
|
65
|
+
*/
|
|
66
|
+
debug: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Version number
|
|
69
|
+
*/
|
|
70
|
+
version: string;
|
|
71
|
+
/**
|
|
72
|
+
* Build time
|
|
73
|
+
*/
|
|
74
|
+
buildTime?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Git commit hash
|
|
77
|
+
*/
|
|
78
|
+
commitHash?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Error information
|
|
82
|
+
*/
|
|
83
|
+
interface PlatformError {
|
|
84
|
+
/**
|
|
85
|
+
* Error code
|
|
86
|
+
*/
|
|
87
|
+
code: string;
|
|
88
|
+
/**
|
|
89
|
+
* Error message
|
|
90
|
+
*/
|
|
91
|
+
message: string;
|
|
92
|
+
/**
|
|
93
|
+
* Detailed information
|
|
94
|
+
*/
|
|
95
|
+
details?: unknown;
|
|
96
|
+
/**
|
|
97
|
+
* Stack trace
|
|
98
|
+
*/
|
|
99
|
+
stack?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Timestamp
|
|
102
|
+
*/
|
|
103
|
+
timestamp: number;
|
|
104
|
+
/**
|
|
105
|
+
* Source module
|
|
106
|
+
*/
|
|
107
|
+
source?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Async operation result
|
|
111
|
+
*/
|
|
112
|
+
type AsyncResult<T, E = PlatformError> = {
|
|
113
|
+
success: true;
|
|
114
|
+
data: T;
|
|
115
|
+
} | {
|
|
116
|
+
success: false;
|
|
117
|
+
error: E;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Pagination parameters
|
|
121
|
+
*/
|
|
122
|
+
interface PaginationParams {
|
|
123
|
+
/**
|
|
124
|
+
* Current page number (starts from 1)
|
|
125
|
+
*/
|
|
126
|
+
page: number;
|
|
127
|
+
/**
|
|
128
|
+
* Page size
|
|
129
|
+
*/
|
|
130
|
+
pageSize: number;
|
|
131
|
+
/**
|
|
132
|
+
* Sort field
|
|
133
|
+
*/
|
|
134
|
+
sortBy?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Sort direction
|
|
137
|
+
*/
|
|
138
|
+
sortOrder?: 'asc' | 'desc';
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Paginated result
|
|
142
|
+
*/
|
|
143
|
+
interface PaginatedResult<T> {
|
|
144
|
+
/**
|
|
145
|
+
* Data list
|
|
146
|
+
*/
|
|
147
|
+
items: T[];
|
|
148
|
+
/**
|
|
149
|
+
* Total count
|
|
150
|
+
*/
|
|
151
|
+
total: number;
|
|
152
|
+
/**
|
|
153
|
+
* Current page number
|
|
154
|
+
*/
|
|
155
|
+
page: number;
|
|
156
|
+
/**
|
|
157
|
+
* Page size
|
|
158
|
+
*/
|
|
159
|
+
pageSize: number;
|
|
160
|
+
/**
|
|
161
|
+
* Total pages
|
|
162
|
+
*/
|
|
163
|
+
totalPages: number;
|
|
164
|
+
/**
|
|
165
|
+
* Has next page
|
|
166
|
+
*/
|
|
167
|
+
hasNext: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Has previous page
|
|
170
|
+
*/
|
|
171
|
+
hasPrev: boolean;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export type { AsyncResult, LogLevel, PaginatedResult, PaginationParams, PlatformConfig, PlatformError, PlatformType, RuntimeEnvironment };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|