@pc-nexus/async 0.8.0-next.10

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/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ # 0.8.0-next.10 (2026-08-27)
6
+
7
+ # 0.8.0-next.9 (2026-08-25)
8
+
9
+ # 0.8.0-next.8 (2026-08-14)
10
+
11
+ # 0.8.0-next.7 (2026-08-12)
12
+
13
+ # 0.8.0-next.6 (2026-08-07)
14
+
15
+ ### Bug Fixes
16
+
17
+ - #NEXUS-4058 public SDK 发布配置补上 @pc-nexus/async (#1396) 5b6c4dd, closes #NEXUS-4058 #1396
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { queue, type QueuePushResult } from "./lib/queue.js";
2
+ export type { ConsumerHandler, QueueTask, QueueConsumer } from "./lib/consumer.js";
3
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { queue } from "./lib/queue.js";
@@ -0,0 +1,15 @@
1
+ import type { AsyncConsumerHandler, AsyncConsumerInfo, AsyncConsumerTask } from "@pc-nexus/internal";
2
+ /** 处理该任务的消费者信息 */
3
+ export type QueueConsumer = AsyncConsumerInfo;
4
+ /**
5
+ * 队列消费者收到的任务。
6
+ *
7
+ * 投递语义是 at-least-once,handler 必须幂等——去重要用 `task_id`(单条任务)而不是 `job_id`(一次 push 内共享)。
8
+ */
9
+ export type QueueTask<T = unknown> = AsyncConsumerTask<T>;
10
+ /**
11
+ * 队列消费者处理函数。第二个参数直接是任务本身——消费者不是事件,
12
+ * 不套 `event.payload` 那层包装。
13
+ */
14
+ export type ConsumerHandler<T = unknown> = AsyncConsumerHandler<T>;
15
+ //# sourceMappingURL=consumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../src/lib/consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAErG,kBAAkB;AAClB,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,OAAO,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/lib/queue.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ export interface QueuePushResult {
2
+ /** 服务端生成,一次 push 一个;批量推送时所有任务共享 */
3
+ jobId: string;
4
+ }
5
+ export interface QueuePushOptions {
6
+ /**
7
+ * 延时投递:入队后至少延迟该秒数才可被消费(延时任务)。
8
+ * 不传或传 0 表示尽快投递。批量推送时对本次所有任务生效。
9
+ */
10
+ delay?: number;
11
+ }
12
+ declare class Queue {
13
+ /**
14
+ * 把一条或多条任务推入队列。调用只保证入队,不等待消费者执行。
15
+ *
16
+ * @param key 队列名,必须等于 manifest 中某个 `async.queues` 条目的 `key`
17
+ * @param payload 单条载荷或载荷数组
18
+ * @param options 可选项;`delay` 指定延时投递的秒数
19
+ */
20
+ push<T = unknown>(key: string, payload: T | T[], options?: QueuePushOptions): Promise<QueuePushResult>;
21
+ }
22
+ export declare const queue: Queue;
23
+ export {};
24
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/lib/queue.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC5B,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,cAAM,KAAK;IACP;;;;;;OAMG;IACU,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;CAUtH;AAED,eAAO,MAAM,KAAK,OAAc,CAAC"}
package/lib/queue.js ADDED
@@ -0,0 +1,21 @@
1
+ import { invoke } from "@pc-nexus/internal";
2
+ class Queue {
3
+ /**
4
+ * 把一条或多条任务推入队列。调用只保证入队,不等待消费者执行。
5
+ *
6
+ * @param key 队列名,必须等于 manifest 中某个 `async.queues` 条目的 `key`
7
+ * @param payload 单条载荷或载荷数组
8
+ * @param options 可选项;`delay` 指定延时投递的秒数
9
+ */
10
+ async push(key, payload, options) {
11
+ const payloads = Array.isArray(payload) ? payload : [payload];
12
+ const response = await invoke("async", "queue/push", {
13
+ queue_key: key,
14
+ payloads,
15
+ delay: options?.delay,
16
+ });
17
+ const result = (await response.json());
18
+ return result.value;
19
+ }
20
+ }
21
+ export const queue = new Queue();
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@pc-nexus/async",
3
+ "version": "0.8.0-next.10",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "pub:alpha": "cd dist && npm publish --access public --tag alpha",
9
+ "pub": "cd dist && npm publish --access public --tag latest",
10
+ "pub-next": "cd dist && npm publish --access public --tag next"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/atinc/pc-nexus.git"
15
+ },
16
+ "author": "",
17
+ "license": "ISC",
18
+ "directories": {
19
+ "test": "test",
20
+ "lib": "dist"
21
+ },
22
+ "types": "index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "default": "./index.js",
26
+ "types": "./index.d.ts"
27
+ }
28
+ },
29
+ "type": "module",
30
+ "dependencies": {
31
+ "@pc-nexus/internal": "0.8.0-next.10"
32
+ },
33
+ "devDependencies": {},
34
+ "peerDependencies": {}
35
+ }