@cloudpss/message-stream 0.5.31 → 0.5.33
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 +7 -7
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +8 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Tagged, Simplify } from 'type-fest';
|
|
2
2
|
/** UUID */
|
|
3
3
|
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
4
4
|
/**
|
|
5
5
|
* 标识流的读权限
|
|
6
6
|
*/
|
|
7
|
-
export type StreamId =
|
|
7
|
+
export type StreamId = Tagged<UUID, 'StreamId'>;
|
|
8
8
|
/** 表示一个空白的流 ID,读取此 ID 对应的流会得到不包含消息的且已冻结的空白流 */
|
|
9
|
-
export declare const EMPTY_STREAM_ID:
|
|
9
|
+
export declare const EMPTY_STREAM_ID: Tagged<"00000000-0000-0000-0000-000000000000", "StreamId">;
|
|
10
10
|
/**
|
|
11
11
|
* 标识流的写权限
|
|
12
12
|
*/
|
|
13
|
-
export type StreamToken =
|
|
13
|
+
export type StreamToken = Tagged<UUID, 'StreamToken'>;
|
|
14
14
|
/** 表示一个空白的流 Token,写入此 Token 的消息会被直接丢弃,不会产生错误 */
|
|
15
|
-
export declare const EMPTY_STREAM_TOKEN:
|
|
15
|
+
export declare const EMPTY_STREAM_TOKEN: Tagged<"00000000-0000-0000-0000-000000000000", "StreamToken">;
|
|
16
16
|
export declare const StreamType: readonly ["object", "binary"];
|
|
17
17
|
/**
|
|
18
18
|
* 流中消息的类型
|
|
@@ -25,7 +25,7 @@ export type StreamType = (typeof StreamType)[number];
|
|
|
25
25
|
*/
|
|
26
26
|
export type StreamState = 'inactive' | 'active' | 'frozen';
|
|
27
27
|
/** 记录调用 `open` 操作的控制器,对应的 `close` 只能由相同的控制器调用 */
|
|
28
|
-
export type StreamWriteHandler =
|
|
28
|
+
export type StreamWriteHandler = Tagged<string, 'StreamWriteHandler'>;
|
|
29
29
|
/**
|
|
30
30
|
* 消息流,需要使用 {@link StreamToken} 查询
|
|
31
31
|
*/
|
|
@@ -56,7 +56,7 @@ export type StreamInfo = Omit<Stream, 'token' | 'handler'>;
|
|
|
56
56
|
/** 创建流需要的数据 */
|
|
57
57
|
export type StreamArgs = Simplify<Pick<Stream, 'type'> & Partial<Pick<Stream, 'comment' | 'durability'>>>;
|
|
58
58
|
/** 消息 ID */
|
|
59
|
-
export type MessageId =
|
|
59
|
+
export type MessageId = Tagged<UUID, 'MessageId'>;
|
|
60
60
|
/** 原始消息 */
|
|
61
61
|
export interface RawMessage {
|
|
62
62
|
/** 消息 ID */
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,aAAa;AACb,MAAM,QAAQ,GAAG,sCAA+C,CAAC;AAKjE,+CAA+C;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,QAAwC,CAAC;AAMxE,gDAAgD;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAA2C,CAAC;AAC9E,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAU,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,aAAa;AACb,4EAA4E;AAC5E,MAAM,QAAQ,GAAG,sCAA+C,CAAC;AAKjE,+CAA+C;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,QAAwC,CAAC;AAMxE,gDAAgD;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAA2C,CAAC;AAC9E,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAU,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Tagged, Simplify } from 'type-fest';
|
|
2
2
|
|
|
3
3
|
/** UUID */
|
|
4
4
|
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
@@ -6,20 +6,21 @@ type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
|
6
6
|
/** 空 UUID */
|
|
7
7
|
type NIL_UUID = typeof NIL_UUID;
|
|
8
8
|
/** 空 UUID */
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
9
10
|
const NIL_UUID = '00000000-0000-0000-0000-000000000000' as const;
|
|
10
11
|
/**
|
|
11
12
|
* 标识流的读权限
|
|
12
13
|
*/
|
|
13
|
-
export type StreamId =
|
|
14
|
+
export type StreamId = Tagged<UUID, 'StreamId'>;
|
|
14
15
|
/** 表示一个空白的流 ID,读取此 ID 对应的流会得到不包含消息的且已冻结的空白流 */
|
|
15
|
-
export const EMPTY_STREAM_ID = NIL_UUID as
|
|
16
|
+
export const EMPTY_STREAM_ID = NIL_UUID as Tagged<NIL_UUID, 'StreamId'>;
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* 标识流的写权限
|
|
19
20
|
*/
|
|
20
|
-
export type StreamToken =
|
|
21
|
+
export type StreamToken = Tagged<UUID, 'StreamToken'>;
|
|
21
22
|
/** 表示一个空白的流 Token,写入此 Token 的消息会被直接丢弃,不会产生错误 */
|
|
22
|
-
export const EMPTY_STREAM_TOKEN = NIL_UUID as
|
|
23
|
+
export const EMPTY_STREAM_TOKEN = NIL_UUID as Tagged<NIL_UUID, 'StreamToken'>;
|
|
23
24
|
export const StreamType = Object.freeze(['object', 'binary'] as const);
|
|
24
25
|
/**
|
|
25
26
|
* 流中消息的类型
|
|
@@ -32,7 +33,7 @@ export type StreamType = (typeof StreamType)[number];
|
|
|
32
33
|
*/
|
|
33
34
|
export type StreamState = 'inactive' | 'active' | 'frozen';
|
|
34
35
|
/** 记录调用 `open` 操作的控制器,对应的 `close` 只能由相同的控制器调用 */
|
|
35
|
-
export type StreamWriteHandler =
|
|
36
|
+
export type StreamWriteHandler = Tagged<string, 'StreamWriteHandler'>;
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* 消息流,需要使用 {@link StreamToken} 查询
|
|
@@ -68,7 +69,7 @@ export type StreamInfo = Omit<Stream, 'token' | 'handler'>;
|
|
|
68
69
|
export type StreamArgs = Simplify<Pick<Stream, 'type'> & Partial<Pick<Stream, 'comment' | 'durability'>>>;
|
|
69
70
|
|
|
70
71
|
/** 消息 ID */
|
|
71
|
-
export type MessageId =
|
|
72
|
+
export type MessageId = Tagged<UUID, 'MessageId'>;
|
|
72
73
|
|
|
73
74
|
/** 原始消息 */
|
|
74
75
|
export interface RawMessage {
|