@adep/runtime 0.3.16 → 0.3.17

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.js CHANGED
@@ -47,10 +47,15 @@ var REALTIME_CAPABILITY_CODES = {
47
47
  subscriptionNotFound: "REALTIME_SUBSCRIPTION_NOT_FOUND",
48
48
  tooManySubscriptions: "REALTIME_TOO_MANY_SUBSCRIPTIONS",
49
49
  /** 线上独有:订阅授权策略(RT-002 `SubscriptionPolicy`)拒绝该 channel。 */
50
- channelDenied: "REALTIME_CHANNEL_DENIED"
50
+ channelDenied: "REALTIME_CHANNEL_DENIED",
51
+ /** 线上独有(RT-008):签票入参不合法(subject 缺失 / channels 非字符串数组 / TTL 越界)。 */
52
+ invalidArg: "REALTIME_INVALID_ARG",
53
+ /** 线上独有(RT-008):函数级签票超频(按项目固定窗口限流)。 */
54
+ ticketRateLimited: "REALTIME_TICKET_RATE_LIMITED"
51
55
  };
52
56
  var REALTIME_CAPABILITY_METHODS = [
53
57
  "publish",
58
+ "issueTicket",
54
59
  "subscribe",
55
60
  "receive",
56
61
  "unsubscribe"
@@ -3080,6 +3085,33 @@ function createSimRealtimeCapability() {
3080
3085
  const [channel, data] = args;
3081
3086
  return sim.publish(channel, data);
3082
3087
  }
3088
+ case "issueTicket": {
3089
+ const [input] = args;
3090
+ if (typeof input !== "object" || input === null) {
3091
+ throw realtimeError(
3092
+ REALTIME_CODES.invalidArg,
3093
+ "\u7B7E\u53D1\u7968\u636E\u9700\u8981\u4E00\u4E2A\u8F93\u5165\u5BF9\u8C61 { subject, channels, ttlSeconds? }"
3094
+ );
3095
+ }
3096
+ const subject = input.subject;
3097
+ const channels = input.channels;
3098
+ if (typeof subject !== "string" || subject.length === 0) {
3099
+ throw realtimeError(
3100
+ REALTIME_CODES.invalidArg,
3101
+ "\u7B7E\u53D1\u7968\u636E\u5FC5\u987B\u5E26 subject\uFF08\u5E94\u7528\u4FA7\u7528\u6237\u6807\u8BC6\uFF09"
3102
+ );
3103
+ }
3104
+ if (!Array.isArray(channels) || channels.length === 0 || channels.some((c) => typeof c !== "string")) {
3105
+ throw realtimeError(
3106
+ REALTIME_CODES.invalidArg,
3107
+ "\u7B7E\u53D1\u7968\u636E\u5FC5\u987B\u5E26\u975E\u7A7A channels \u5B57\u7B26\u4E32\u6570\u7EC4\uFF08\u5E94\u7528\u7528\u6237\u7684\u7CBE\u786E\u8BA2\u9605\u767D\u540D\u5355\uFF09"
3108
+ );
3109
+ }
3110
+ throw realtimeError(
3111
+ REALTIME_CODES.unsupportedArg,
3112
+ "\u672C\u5730 sim \u4E0D\u7B7E\u53D1\u5B9E\u65F6\u7968\u636E\uFF08\u65E0 WS \u63E1\u624B\u9762\uFF0C\u7968\u636E\u65E0\u5904\u53EF\u7528\uFF09\uFF1B\u8BF7\u5728\u7EBF\u4E0A\u7684\u51FD\u6570\u6267\u884C\u9762\u4F7F\u7528 cloud.realtime.issueTicket"
3113
+ );
3114
+ }
3083
3115
  case "subscribe": {
3084
3116
  if (buffers.size >= MAX_SUBSCRIPTIONS) {
3085
3117
  throw realtimeError(
@@ -41,7 +41,11 @@ export declare const REALTIME_CAPABILITY_CODES: {
41
41
  readonly tooManySubscriptions: "REALTIME_TOO_MANY_SUBSCRIPTIONS";
42
42
  /** 线上独有:订阅授权策略(RT-002 `SubscriptionPolicy`)拒绝该 channel。 */
43
43
  readonly channelDenied: "REALTIME_CHANNEL_DENIED";
44
+ /** 线上独有(RT-008):签票入参不合法(subject 缺失 / channels 非字符串数组 / TTL 越界)。 */
45
+ readonly invalidArg: "REALTIME_INVALID_ARG";
46
+ /** 线上独有(RT-008):函数级签票超频(按项目固定窗口限流)。 */
47
+ readonly ticketRateLimited: "REALTIME_TICKET_RATE_LIMITED";
44
48
  };
45
49
  /** 命令通道可派发的 realtime 方法名(未知方法一律 fail loud)。 */
46
- export declare const REALTIME_CAPABILITY_METHODS: readonly ["publish", "subscribe", "receive", "unsubscribe"];
50
+ export declare const REALTIME_CAPABILITY_METHODS: readonly ["publish", "issueTicket", "subscribe", "receive", "unsubscribe"];
47
51
  export type RealtimeCapabilityMethod = (typeof REALTIME_CAPABILITY_METHODS)[number];
@@ -39,6 +39,8 @@ export declare const REALTIME_CODES: {
39
39
  readonly subscriptionNotFound: "REALTIME_SUBSCRIPTION_NOT_FOUND";
40
40
  readonly tooManySubscriptions: "REALTIME_TOO_MANY_SUBSCRIPTIONS";
41
41
  readonly channelDenied: "REALTIME_CHANNEL_DENIED";
42
+ readonly invalidArg: "REALTIME_INVALID_ARG";
43
+ readonly ticketRateLimited: "REALTIME_TICKET_RATE_LIMITED";
42
44
  };
43
45
  /** `subscribe` 的回执(函数侧只拿到订阅号,拿不到监听器 / 总线内部对象)。 */
44
46
  export interface SimRealtimeSubscription {
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "homepage": "https://adep.top",
9
9
  "bugs": "https://gitcode.com/yunqiang_wu/ai-yunke/issues",
10
- "version": "0.3.16",
10
+ "version": "0.3.17",
11
11
  "private": false,
12
12
  "type": "module",
13
13
  "sideEffects": false,
@@ -32,7 +32,7 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@adep/types": "0.4.5"
35
+ "@adep/types": "0.4.6"
36
36
  },
37
37
  "scripts": {
38
38
  "test": "vitest run",