@tier0/sdk-v2 0.6.2 → 0.7.2
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 +26 -17
- package/dist/cjs/capabilities.d.ts +20 -4
- package/dist/cjs/capabilities.js +66 -6
- package/dist/cjs/capabilities.js.map +1 -1
- package/dist/cjs/client.d.ts +9 -7
- package/dist/cjs/client.js +0 -2
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/cloud-transport.d.ts +3 -2
- package/dist/cjs/cloud-transport.js +8 -7
- package/dist/cjs/cloud-transport.js.map +1 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/openapi/api.generated.d.ts +9 -5
- package/dist/cjs/openapi/codecs.generated.d.ts +943 -684
- package/dist/cjs/openapi/codecs.generated.js +1 -1
- package/dist/cjs/openapi/codecs.generated.js.map +1 -1
- package/dist/cjs/openapi/types.generated.d.ts +638 -508
- package/dist/cjs/openapi/types.generated.js.map +1 -1
- package/dist/cjs/uns-v2/client.js +2 -2
- package/dist/cjs/uns-v2/client.js.map +1 -1
- package/dist/cjs/uns-v2/generated.d.ts +190 -274
- package/dist/cjs/uns-v2/generated.js +24 -48
- package/dist/cjs/uns-v2/generated.js.map +1 -1
- package/dist/esm/capabilities.d.ts +20 -4
- package/dist/esm/capabilities.js +66 -6
- package/dist/esm/capabilities.js.map +1 -1
- package/dist/esm/client.d.ts +9 -7
- package/dist/esm/client.js +0 -2
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/cloud-transport.d.ts +3 -2
- package/dist/esm/cloud-transport.js +8 -7
- package/dist/esm/cloud-transport.js.map +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/openapi/api.generated.d.ts +9 -5
- package/dist/esm/openapi/codecs.generated.d.ts +943 -684
- package/dist/esm/openapi/codecs.generated.js +1 -1
- package/dist/esm/openapi/codecs.generated.js.map +1 -1
- package/dist/esm/openapi/types.generated.d.ts +638 -508
- package/dist/esm/openapi/types.generated.js.map +1 -1
- package/dist/esm/uns-v2/client.js +2 -2
- package/dist/esm/uns-v2/client.js.map +1 -1
- package/dist/esm/uns-v2/generated.d.ts +190 -274
- package/dist/esm/uns-v2/generated.js +24 -48
- package/dist/esm/uns-v2/generated.js.map +1 -1
- package/package.json +5 -8
- package/skills/tier0-sdk-v2/SKILL.md +8 -7
- package/skills/tier0-sdk-v2/tier0-sdk-v2-agent/SKILL.md +0 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/SKILL.md +2 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/SKILL.md +1 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/delete.md +1 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/download.md +1 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/multipart.md +1 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/upload.md +2 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-members/SKILL.md +1 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-members/references/platform-members.md +1 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/SKILL.md +2 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/references/quickstart.md +3 -3
- package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/SKILL.md +2 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/references/send.md +2 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/SKILL.md +3 -3
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/create.md +11 -7
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/protocols.md +4 -4
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/read.md +1 -1
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/SKILL.md +7 -7
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/create.md +15 -12
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/delete.md +9 -16
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/deploy.md +20 -18
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/http-server.md +2 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/lifecycle.md +2 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/read.md +4 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/update.md +5 -7
- package/skills/tier0-sdk-v2/tier0-sdk-v2-system/SKILL.md +7 -4
- package/skills/tier0-sdk-v2/tier0-sdk-v2-system/references/info.md +0 -2
- package/skills/tier0-sdk-v2/tier0-sdk-v2-system/references/whoami.md +1 -1
- package/dist/cjs/controls.d.ts +0 -105
- package/dist/cjs/controls.js +0 -172
- package/dist/cjs/controls.js.map +0 -1
- package/dist/esm/controls.d.ts +0 -105
- package/dist/esm/controls.js +0 -166
- package/dist/esm/controls.js.map +0 -1
- package/docs/acceptance-2026-10-22.md +0 -90
- package/skills/tier0-sdk-v2/tier0-sdk-v2-controls/SKILL.md +0 -65
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
| --- | --- |
|
|
15
15
|
| revision | 草稿修订;传给下次写入的 expectedRevision,冲突时显式处理 |
|
|
16
16
|
| activeVersion | 不可变发布版本 ID;回滚的 versionId 使用这个 ID,不使用发布序号 |
|
|
17
|
-
| activeRelease | 本次事务记录的正整数发布序号;与 runs.list 中的 release
|
|
17
|
+
| activeRelease | 本次事务记录的正整数发布序号;与 runs.list 中的 release 对照;无活跃发布或回执未记录时省略 |
|
|
18
18
|
|
|
19
|
-
programs 回执的 activeVersion:'0'
|
|
19
|
+
programs 回执的 activeVersion:'0' 表示无活跃版本;programs 的 activeRelease 此时省略;documents 的 activeRelease 此时为 0。
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
import { createClient, type Tier0Client, type CloudStreamDocumentView } from '@tier0/sdk-v2';
|
|
22
|
+
import { createClient, type Tier0Client, type CloudStreamDocumentView, type CloudStreamStopView } from '@tier0/sdk-v2';
|
|
23
23
|
|
|
24
24
|
export async function deployStream(current: CloudStreamDocumentView, intentKey: string, client: Tier0Client = createClient()) {
|
|
25
25
|
const sources = current.document.sources ?? [];
|
|
@@ -35,40 +35,42 @@ export async function deployStream(current: CloudStreamDocumentView, intentKey:
|
|
|
35
35
|
}
|
|
36
36
|
const release = receipt.data.activeRelease;
|
|
37
37
|
if (release === undefined || BigInt(String(release)) <= 0n) {
|
|
38
|
-
throw new Error('
|
|
38
|
+
throw new Error('回执缺少发布编号;保留原请求,不用当前发布编号替代');
|
|
39
39
|
}
|
|
40
40
|
return { receipt, release };
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export async function disableStream(
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
export async function disableStream(
|
|
44
|
+
current: Pick<CloudStreamStopView, 'id' | 'revision' | 'activeRelease'>,
|
|
45
|
+
intentKey: string, client: Tier0Client = createClient(),
|
|
46
|
+
) {
|
|
47
|
+
if (BigInt(String(current.activeRelease)) <= 0n) throw new Error('没有活跃发布可停用');
|
|
46
48
|
const receipt = await client.stream.documents.disable({
|
|
47
|
-
id, expectedRevision: current.revision, expectedActiveRelease: current.activeRelease,
|
|
49
|
+
id: current.id, expectedRevision: current.revision, expectedActiveRelease: current.activeRelease,
|
|
48
50
|
dryRun: false, idempotencyKey: intentKey,
|
|
49
51
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
if (!('id' in receipt.data) || String(receipt.data.activeRelease) !== '0') {
|
|
53
|
+
throw new Error('未返回停用回执');
|
|
54
|
+
}
|
|
55
|
+
return { receipt, current: receipt.data };
|
|
53
56
|
}
|
|
54
57
|
```
|
|
55
58
|
|
|
56
|
-
将创建或更新回执的 current 传给 deployStream,只发一次发布请求。只有手上没有草稿快照时才先 documents.get。使用 [按发布号查询运行记录](read.md#观察本次发布)
|
|
59
|
+
将创建或更新回执的 current 传给 deployStream,只发一次发布请求。只有手上没有草稿快照时才先 documents.get。使用 [按发布号查询运行记录](read.md#观察本次发布) 才能观察这次发布,观察窗口汇总不能证明该版本运行。发布成功不表示外部连接健康或执行成功。停用使用已确认的 id/revision/activeRelease(可来自发布回执),返回的 current 可直接用于删除;不需要前后各 get。停用保留草稿。仅修改草稿的任务不额外发布/停用。
|
|
57
60
|
|
|
58
61
|
## 回滚到明确版本
|
|
59
62
|
|
|
60
63
|
```ts
|
|
61
|
-
import { createClient, type Tier0Client } from '@tier0/sdk-v2';
|
|
64
|
+
import { createClient, type Tier0Client, type CloudStreamStopView } from '@tier0/sdk-v2';
|
|
62
65
|
|
|
63
66
|
export async function rollbackStream(
|
|
64
|
-
|
|
67
|
+
current: Pick<CloudStreamStopView, 'id' | 'revision'>, versionId: string, intentKey: string, client: Tier0Client = createClient(),
|
|
65
68
|
) {
|
|
66
|
-
// versionId
|
|
67
|
-
const { data: current } = await client.stream.documents.get({ id });
|
|
69
|
+
// versionId 使用已知发布回执的 activeVersion,或从 programs.versions.list 选定。
|
|
68
70
|
return client.stream.programs.rollback({
|
|
69
|
-
id, versionId, expectedRevision: current.revision, dryRun: false, idempotencyKey: intentKey,
|
|
71
|
+
id: current.id, versionId, expectedRevision: current.revision, dryRun: false, idempotencyKey: intentKey,
|
|
70
72
|
});
|
|
71
73
|
}
|
|
72
74
|
```
|
|
73
75
|
|
|
74
|
-
检查回执 activeVersion 与 activeRelease。超时或 UnsV2OutcomeUnknownError
|
|
76
|
+
检查回执 activeVersion 与 activeRelease。超时或 UnsV2OutcomeUnknownError 时保留原路由、载荷和幂等键;允许恢复时原样重发以取得原回执,不用新键再次发布。回执缺少 activeRelease 时不能用当前 head 替代本次请求的发布编号。相同草稿使用不同键仍会创建新发布,expectedRevision 仅保护草稿修订。预览用 dryRun=true,返回 validated/sideEffects,不保证稍后的实际发布一定成功。
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## 保存原生程序草稿
|
|
8
8
|
|
|
9
|
-
使用完整原生 `document`:script 是 `{code,timeoutMs}`,sources 使用 alias。这与 `program` 的 script
|
|
9
|
+
使用完整原生 `document`:script 是 `{code,timeoutMs}`,sources 使用 alias。这与 `program` 的 script 字符串形态不同。
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
import { createClient, type Tier0Client, type CloudStreamDocument } from '@tier0/sdk-v2';
|
|
@@ -84,6 +84,6 @@ export async function createHttpServerEarlyReplyStream(
|
|
|
84
84
|
}
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
`ctx.reply` 只用于 HTTP `api.stream.onRequest`,一次执行只回复一次;不要在 `every
|
|
87
|
+
`ctx.reply` 只用于 HTTP `api.stream.onRequest`,一次执行只回复一次;不要在 `every`或普通事件 handler 中调用,也不增加 npm App API 或公开 HTTP endpoint。示例先发 202 再写 Record,202 表示已回复接受,不能报告写入或提交成功;失败通过 Stream 运行记录检查,不能再发送第二份响应。
|
|
88
88
|
|
|
89
89
|
回复后的处理仍受 Stream timeout(本例 5000 ms)、并发上限和实时权限约束。客户端断线不会取消已回复后的执行,服务 shutdown 仍可取消。进程崩溃不保证重放;业务若需持久投递、去重或恢复,必须另行设计,不能把 `ctx.reply` 当作持久队列。凭据和权限均沿用现有 Source/Stream 合同。
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
创建并发布时,将 [创建](create.md) 或 [修改](update.md) 回执中的草稿直接交给 [发布](deploy.md),再用发布回执的 activeRelease [观察运行](read.md#观察本次发布),无需在发布前后各 get 一次。只有缺少当前草稿、处理版本冲突或需要最新状态时才 [查询](read.md)。停用、回滚和 [删除](delete.md) 按任务选择,不自动执行整套生命周期。
|
|
4
4
|
|
|
5
|
+
HTTP 采集的常规顺序是选定或创建 Source → 用 Source 回执绑定并保存 Stream → 发布 → 观察该发布的真实采集。Source 保存基址和认证,Stream 指定 method/path/query。预检按需使用;静态校验只能发现可确定的问题,脚本动态请求仍需通过代表性实际运行验证,不能把配置通过、网络可达或样例通过等同于采集成功。
|
|
6
|
+
|
|
5
7
|
## 原生文档样例测试
|
|
6
8
|
|
|
7
9
|
方法:stream.sampleTest;输入 document、entryId、input。document 来自 documents.get 的完整草稿,entryId 必须在该文档注册的 entries 内。
|
|
@@ -53,3 +53,7 @@ export async function readPublishedRuns(
|
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
此函数只读一页。items 为空但 nextCursor 非空时,下一页仍可能有匹配记录;达到调用方的观察时限就报告“尚未观察到”。匹配记录也要检查 status、entryId 和时间,不能把存在记录当成执行成功。历史幂等回执若缺少 activeRelease,应保留为未确认,不能用当前 head 的发布号代替。
|
|
56
|
+
|
|
57
|
+
失败或结果未知的运行可带 `error:{code,stage,message,repair,sourceRequest?}` 安全诊断。`SOURCE_TARGET_SCOPE_MISMATCH`、`stage:validate_binding` 表示请求超出 Source 凭据范围,应检查绑定基址与实际 method/path/query,保留原授权限制。`sourceRequest:notDispatched` 只证明失败的这一次 Source 请求未发送,不能推断整个 Stream 未开始或此前没有写入。
|
|
58
|
+
|
|
59
|
+
`EXECUTION_FAILED` 和 `RESULT_UNKNOWN` 是安全通用诊断,分别保留失败和结果未知的区别。按 code/stage 判断,展示服务端 message/repair;没有 error 的旧记录仍按 status 解释,不补造原因,也不因可重试猜测而自动重新执行。运行诊断不包含 token、凭据引用或完整请求 URL。
|
|
@@ -6,23 +6,21 @@
|
|
|
6
6
|
| --- | --- | --- | --- |
|
|
7
7
|
| id | string | 是 | 十进制字符串 |
|
|
8
8
|
| document | CloudStreamDocument | 是 | name、model、script、sources、entries 完整文档 |
|
|
9
|
-
| expectedRevision | integer | 建议始终提供 |
|
|
9
|
+
| expectedRevision | integer | 建议始终提供 | 当前回执或查询的修订,防止覆盖他人修改 |
|
|
10
10
|
| dryRun | boolean | 是 | true 预检;false 保存 |
|
|
11
11
|
| idempotencyKey | string | 否 | 本次更新独立意图键 |
|
|
12
12
|
|
|
13
13
|
## 示例:更新描述,保持脚本和绑定
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import { createClient, type Tier0Client, type CloudStreamDocument } from '@tier0/sdk-v2';
|
|
16
|
+
import { createClient, type Tier0Client, type CloudStreamDocument, type CloudStreamDocumentView } from '@tier0/sdk-v2';
|
|
17
17
|
|
|
18
18
|
export async function updateStreamDescription(
|
|
19
|
-
|
|
19
|
+
current: CloudStreamDocumentView, description: string, intentKey: string, client: Tier0Client = createClient(),
|
|
20
20
|
) {
|
|
21
|
-
const { data: current } = await client.stream.documents.get({ id, view: 'full' });
|
|
22
|
-
if (!('document' in current)) throw new Error('需要完整 Stream 文档');
|
|
23
21
|
const document: CloudStreamDocument = { ...current.document, description };
|
|
24
22
|
const saved = await client.stream.documents.update({
|
|
25
|
-
id, expectedRevision: current.revision, document, dryRun: false, idempotencyKey: intentKey,
|
|
23
|
+
id: current.id, expectedRevision: current.revision, document, dryRun: false, idempotencyKey: intentKey,
|
|
26
24
|
});
|
|
27
25
|
if (!('id' in saved.data)) throw new Error('未返回已保存文档');
|
|
28
26
|
return { receipt: saved, current: saved.data };
|
|
@@ -31,4 +29,4 @@ export async function updateStreamDescription(
|
|
|
31
29
|
|
|
32
30
|
代码应用可直接用 documents.update({id, expectedRevision, program, dryRun:false, idempotencyKey}),由服务端编译入口和绑定。编辑完整文档时保留 script.code/timeoutMs,并同步 entries/sources;写入本身执行校验,只有需要提前展示问题时才单独 validate。不要对documents.get 的 summary 做展开更新。
|
|
33
31
|
|
|
34
|
-
响应是完整 CloudStreamDocumentView 或预检结果;把 saved.data 直接传给下一步[发布示例](deploy.md),无需为了 revision
|
|
32
|
+
响应是完整 CloudStreamDocumentView 或预检结果;把 saved.data 直接传给下一步[发布示例](deploy.md),无需为了 revision 再读取。示例复用创建/更新回执;只有缺少完整文档时才先 get({id,view:"full"}) 并确认 document 存在。保存草稿不会自动部署,activeDocument 可能仍是旧发布版本。VERSION_CONFLICT 后重新读取、比较并决策;不无条件覆盖。
|
|
@@ -10,8 +10,6 @@ description: 使用 @tier0/sdk-v2 查询 Tier0 凭证身份、平台版本、MQT
|
|
|
10
10
|
| 诊断 Key 所属 Workspace 和权限 | [whoami](references/whoami.md) |
|
|
11
11
|
| 查看平台版本、解析 Broker 地址 | [info](references/info.md) |
|
|
12
12
|
|
|
13
|
-
v1 的内部 reload 接口不属于 v2 公共 SDK,不能在普通诊断时调用。
|
|
14
|
-
|
|
15
13
|
使用服务端 `createClient()` 或显式传入 apiHost/apiKey。系统排查从只读信息开始,不因功能不可用自动创建 Key、修改权限或部署服务。
|
|
16
14
|
|
|
17
15
|
## 最小诊断
|
|
@@ -45,13 +43,18 @@ info 返回 name/version/mqttBroker/capabilities,字段可能省略。MQTT bro
|
|
|
45
43
|
| 字段/状态 | 判断 |
|
|
46
44
|
| --- | --- |
|
|
47
45
|
| releaseEnabled | 平台/Workspace 发布开关,不代表运行时已准备好 |
|
|
48
|
-
| allowed |
|
|
46
|
+
| allowed | 当前身份的授权摘要,不是某个具体操作的执行许可 |
|
|
49
47
|
| enabled、state=ready | 服务端评估就绪 |
|
|
50
48
|
| availability=available | 能力可用性,不是设备在线、业务执行或 ACK |
|
|
51
49
|
| disabled / not_supported / unavailable | 展示具体不可用原因,不强制调用 |
|
|
52
50
|
| readiness_unknown | 保留未知状态,不能按成功处理 |
|
|
51
|
+
| operations | Source / Stream 各操作独立判断;整体不可用不等于读取或安全停用不可用 |
|
|
52
|
+
| reasonCode / checkedAt / validUntil | 保留服务端原因及证明时间,过期后重新发现,不把旧证明当成持续就绪 |
|
|
53
|
+
| requiresResourceCheck | 实际调用仍要检查具体资源的权限、配置和依赖 |
|
|
54
|
+
|
|
55
|
+
本数据 SDK 的能力目录识别 namespace.v2、source、stream;其他 SDK 的可选交互能力按各自合同处理,不阻断 Namespace 发现。Source/Stream 的 contractVersions 使用 openapi/v2,不要求或返回解释器版本。contractVersions、apiContractVersions、sdkContractVersions 是契约标签,不是 npm 包版本;productVersion 未配置时可缺省。顶层要求受支持的核心 OpenAPI v2 合同,已识别能力也必须满足其合同;不要求全局交互 SDK 标签,不把未知能力投影为已支持。
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
发现统一使用 `POST /openapi/v2/capabilities/discover`,请求为 `{}`,不接受 Workspace 参数。Cloud / Enterprise 返回同一合同;此 SDK 只消费 Namespace、Source、Stream 管理能力;App 交互域由 App SDK 提供,其版本不作为管理接口的前置条件。SDK 只投影已知操作与公开诊断字段;未知扩展不被解释为就绪,不自动重试。
|
|
55
58
|
|
|
56
59
|
## 定位问题
|
|
57
60
|
|
|
@@ -19,5 +19,3 @@ export async function inspectService(client: Tier0Client = createClient()) {
|
|
|
19
19
|
返回已解包对象,name/version/capabilities/mqttBroker 均可能省略。mqttBroker 是连接串,可能裸 host、host:port、tcp://host:1883 或完整 ws/wss,不能直接拼 wss:// 前缀。toWebSocketUrl 保留已有 WebSocket URL;TCP 端口不直接复用为 WebSocket 端口。实际端口/路径由环境决定。
|
|
20
20
|
|
|
21
21
|
info.capabilities 的简略字符串列表不是就绪证明。进一步读取 client.capabilities.discover 的 releaseEnabled、allowed、state、availability,区分开关、授权与运行能力;详见[系统 Skill](../SKILL.md)。
|
|
22
|
-
|
|
23
|
-
v1 的 /gw/reload 是内部管理操作,未纳入 v2 公共 SDK,不复制旧 reload 示例,也不在连通性诊断中尝试重载服务。
|
|
@@ -14,7 +14,7 @@ export async function inspectCredential(client: Tier0Client = createClient()) {
|
|
|
14
14
|
}
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
返回已解包的 userID/userName/email/workspaceID/workspaceName/apiKeyName/keyPrefix/permissions/roles/keyType
|
|
17
|
+
返回已解包的 userID/userName/email/workspaceID/workspaceName/apiKeyName/keyPrefix/permissions/roles/keyType。大整数保留 number|bigint;需要字符串时用 String,不先转 Number。
|
|
18
18
|
|
|
19
19
|
App Key 是共享业务凭证,不代表访问 App 的自然人。whoami 不能用于登录、当前用户、操作人审计或选择通知收件人;当前人来自应用认证会话,收件人从成员数据解析。
|
|
20
20
|
|
package/dist/cjs/controls.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { type HttpClient, type ClientConfig } from './openapi/client.js';
|
|
2
|
-
import { type CloudTransportConfig } from './cloud-transport.js';
|
|
3
|
-
import { type UnsV2Execution, type UnsV2Retry } from './uns-v2/client.js';
|
|
4
|
-
import type { UnsV2JSONValue } from './uns-v2/generated.js';
|
|
5
|
-
/** Control convenience API over the canonical UNS v2 routes. Exact numbers are preserved. */
|
|
6
|
-
export type ControlJSON = UnsV2JSONValue;
|
|
7
|
-
export interface PublicControl {
|
|
8
|
-
code: string;
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
contractVersion: string;
|
|
12
|
-
inputSchema: Record<string, ControlJSON>;
|
|
13
|
-
outputSchema: Record<string, ControlJSON>;
|
|
14
|
-
sideEffect: 'read' | 'write';
|
|
15
|
-
idempotency: 'none' | 'optional' | 'required';
|
|
16
|
-
timeoutMs: number;
|
|
17
|
-
status: string;
|
|
18
|
-
}
|
|
19
|
-
export interface ControlDiscoverOptions {
|
|
20
|
-
page?: number;
|
|
21
|
-
size?: number;
|
|
22
|
-
search?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface ControlDiscoverResponse {
|
|
25
|
-
total: number;
|
|
26
|
-
list: PublicControl[];
|
|
27
|
-
}
|
|
28
|
-
/** Shared HTTP settings. The server still resolves the Control binding and authorization. */
|
|
29
|
-
export interface ControlTransportConfig extends CloudTransportConfig {
|
|
30
|
-
}
|
|
31
|
-
export interface CloudClientConfig extends ClientConfig, ControlTransportConfig {
|
|
32
|
-
}
|
|
33
|
-
export declare const DEFAULT_CONTROL_TRANSPORT_TIMEOUT_MS = 60000;
|
|
34
|
-
export interface ControlInvokeOptions {
|
|
35
|
-
/** Stable caller-owned key for one business intent, at most 128 UTF-8 bytes. Never generated or retried by the SDK. */
|
|
36
|
-
idempotencyKey?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface ControlInvokeResponse<Result = ControlJSON> {
|
|
39
|
-
code: string;
|
|
40
|
-
contractVersion: string;
|
|
41
|
-
result: Result;
|
|
42
|
-
runID: string;
|
|
43
|
-
status: string;
|
|
44
|
-
/** True only when the server explicitly reports an idempotent replay. */
|
|
45
|
-
replayed: boolean;
|
|
46
|
-
}
|
|
47
|
-
export interface ControlErrorInfo {
|
|
48
|
-
/** HTTP status, absent when no HTTP response was received. */
|
|
49
|
-
status?: number;
|
|
50
|
-
/** Canonical UNS error.code, or an SDK-local CONTROL_* transport/protocol code. */
|
|
51
|
-
errorCode: string;
|
|
52
|
-
runID?: string;
|
|
53
|
-
contractVersion?: string;
|
|
54
|
-
runStatus?: string;
|
|
55
|
-
replayed?: boolean;
|
|
56
|
-
requestId?: string;
|
|
57
|
-
execution?: UnsV2Execution;
|
|
58
|
-
retry?: UnsV2Retry;
|
|
59
|
-
reason?: string;
|
|
60
|
-
details?: Record<string, unknown>[];
|
|
61
|
-
data?: unknown;
|
|
62
|
-
}
|
|
63
|
-
/** No Control error is automatically retried, including authentication failures. */
|
|
64
|
-
export declare class ControlError extends Error {
|
|
65
|
-
readonly status?: number;
|
|
66
|
-
readonly errorCode: string;
|
|
67
|
-
readonly runID?: string;
|
|
68
|
-
readonly contractVersion?: string;
|
|
69
|
-
readonly runStatus?: string;
|
|
70
|
-
readonly replayed?: boolean;
|
|
71
|
-
readonly requestId?: string;
|
|
72
|
-
readonly execution?: UnsV2Execution;
|
|
73
|
-
readonly retry?: UnsV2Retry;
|
|
74
|
-
readonly reason?: string;
|
|
75
|
-
readonly details?: Record<string, unknown>[];
|
|
76
|
-
readonly data?: unknown;
|
|
77
|
-
readonly retryable = false;
|
|
78
|
-
constructor(message: string, info: ControlErrorInfo);
|
|
79
|
-
}
|
|
80
|
-
/** Execution may have happened. Reconcile run information; any deliberate replay must reuse the same key. */
|
|
81
|
-
export declare class ControlResultUnknownError extends ControlError {
|
|
82
|
-
readonly outcomeUnknown = true;
|
|
83
|
-
constructor(info: ControlErrorInfo);
|
|
84
|
-
}
|
|
85
|
-
export interface ControlHandle<Input = ControlJSON, Result = ControlJSON> {
|
|
86
|
-
describe(): Promise<PublicControl>;
|
|
87
|
-
/**
|
|
88
|
-
* One POST only. Input is opaque business JSON, including fields named streamId,
|
|
89
|
-
* entryId, deploymentVersion or timeoutMs. Only the server chooses binding/version/timeout.
|
|
90
|
-
* Generic types are caller assertions; the server validates the contract schemas.
|
|
91
|
-
*/
|
|
92
|
-
invoke(input: Input, options?: ControlInvokeOptions): Promise<ControlInvokeResponse<Result>>;
|
|
93
|
-
}
|
|
94
|
-
export declare class ControlsClient {
|
|
95
|
-
private readonly uns;
|
|
96
|
-
constructor(resolveClient?: () => HttpClient, config?: ControlTransportConfig);
|
|
97
|
-
private post;
|
|
98
|
-
/** Discover visible contracts; defaults and authorization are resolved by the server. */
|
|
99
|
-
discover(options?: ControlDiscoverOptions): Promise<ControlDiscoverResponse>;
|
|
100
|
-
use<Input = ControlJSON, Result = ControlJSON>(selector: {
|
|
101
|
-
code: string;
|
|
102
|
-
}): ControlHandle<Input, Result>;
|
|
103
|
-
}
|
|
104
|
-
/** Uses configureClient()/TIER0_API_HOST/TIER0_API_KEY, resolved for every call. */
|
|
105
|
-
export declare const controls: ControlsClient;
|
package/dist/cjs/controls.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.controls = exports.ControlsClient = exports.ControlResultUnknownError = exports.ControlError = exports.DEFAULT_CONTROL_TRANSPORT_TIMEOUT_MS = void 0;
|
|
4
|
-
const client_js_1 = require("./openapi/client.js");
|
|
5
|
-
const cloud_transport_js_1 = require("./cloud-transport.js");
|
|
6
|
-
const client_js_2 = require("./uns-v2/client.js");
|
|
7
|
-
const codec_js_1 = require("./uns-v2/codec.js");
|
|
8
|
-
exports.DEFAULT_CONTROL_TRANSPORT_TIMEOUT_MS = cloud_transport_js_1.DEFAULT_CLOUD_TRANSPORT_TIMEOUT_MS;
|
|
9
|
-
/** No Control error is automatically retried, including authentication failures. */
|
|
10
|
-
class ControlError extends Error {
|
|
11
|
-
status;
|
|
12
|
-
errorCode;
|
|
13
|
-
runID;
|
|
14
|
-
contractVersion;
|
|
15
|
-
runStatus;
|
|
16
|
-
replayed;
|
|
17
|
-
requestId;
|
|
18
|
-
execution;
|
|
19
|
-
retry;
|
|
20
|
-
reason;
|
|
21
|
-
details;
|
|
22
|
-
data;
|
|
23
|
-
retryable = false;
|
|
24
|
-
constructor(message, info) {
|
|
25
|
-
super(message);
|
|
26
|
-
this.name = 'ControlError';
|
|
27
|
-
this.status = info.status;
|
|
28
|
-
this.errorCode = info.errorCode;
|
|
29
|
-
this.runID = info.runID;
|
|
30
|
-
this.contractVersion = info.contractVersion;
|
|
31
|
-
this.runStatus = info.runStatus;
|
|
32
|
-
this.replayed = info.replayed;
|
|
33
|
-
this.requestId = info.requestId;
|
|
34
|
-
this.execution = info.execution;
|
|
35
|
-
this.retry = info.retry;
|
|
36
|
-
this.reason = info.reason;
|
|
37
|
-
this.details = info.details;
|
|
38
|
-
this.data = info.data;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.ControlError = ControlError;
|
|
42
|
-
/** Execution may have happened. Reconcile run information; any deliberate replay must reuse the same key. */
|
|
43
|
-
class ControlResultUnknownError extends ControlError {
|
|
44
|
-
outcomeUnknown = true;
|
|
45
|
-
constructor(info) {
|
|
46
|
-
super('Control result is unknown; execution may have occurred. Do not automatically retry.', info);
|
|
47
|
-
this.name = 'ControlResultUnknownError';
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.ControlResultUnknownError = ControlResultUnknownError;
|
|
51
|
-
function record(value) {
|
|
52
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
53
|
-
}
|
|
54
|
-
function keys(value, allowed) {
|
|
55
|
-
if (!record(value) || Reflect.ownKeys(value).some(key => typeof key !== 'string' || !allowed.includes(key))) {
|
|
56
|
-
throw new TypeError('Tier0 SDK: unsupported Control option.');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function json(value, seen = new Set()) {
|
|
60
|
-
if (value === null || typeof value === 'string' || typeof value === 'boolean' || value instanceof codec_js_1.UnsV2RawNumber)
|
|
61
|
-
return true;
|
|
62
|
-
if (typeof value === 'number')
|
|
63
|
-
return Number.isFinite(value);
|
|
64
|
-
if (typeof value !== 'object' || seen.has(value))
|
|
65
|
-
return false;
|
|
66
|
-
if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
seen.add(value);
|
|
70
|
-
const valid = (Array.isArray(value) ? Array.from(value) : Object.values(value)).every(item => json(item, seen));
|
|
71
|
-
seen.delete(value);
|
|
72
|
-
return valid;
|
|
73
|
-
}
|
|
74
|
-
function definition(value) {
|
|
75
|
-
if (!record(value))
|
|
76
|
-
return false;
|
|
77
|
-
return ['code', 'name', 'description', 'contractVersion', 'status'].every(key => typeof value[key] === 'string') &&
|
|
78
|
-
value.code !== '' && value.contractVersion !== '' && record(value.inputSchema) && record(value.outputSchema) &&
|
|
79
|
-
['read', 'write'].includes(value.sideEffect) &&
|
|
80
|
-
['none', 'optional', 'required'].includes(value.idempotency) &&
|
|
81
|
-
typeof value.timeoutMs === 'number' && Number.isSafeInteger(value.timeoutMs) && value.timeoutMs > 0;
|
|
82
|
-
}
|
|
83
|
-
function runInfo(value) {
|
|
84
|
-
if (!record(value))
|
|
85
|
-
return {};
|
|
86
|
-
return {
|
|
87
|
-
runID: typeof value.runId === 'string' ? value.runId : undefined,
|
|
88
|
-
contractVersion: typeof value.contractVersion === 'string' ? value.contractVersion : undefined,
|
|
89
|
-
runStatus: typeof value.status === 'string' ? value.status : undefined,
|
|
90
|
-
replayed: typeof value.replayed === 'boolean' ? value.replayed : undefined,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
class ControlsClient {
|
|
94
|
-
uns;
|
|
95
|
-
constructor(resolveClient = client_js_1.getClient, config = {}) {
|
|
96
|
-
this.uns = new client_js_2.UnsV2ClientCore(resolveClient, config);
|
|
97
|
-
}
|
|
98
|
-
async post(operation, body) {
|
|
99
|
-
try {
|
|
100
|
-
const response = await this.uns.call(operation, body);
|
|
101
|
-
return { value: response.data, status: 200 };
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (!(error instanceof client_js_2.UnsV2Error))
|
|
105
|
-
throw error;
|
|
106
|
-
const info = {
|
|
107
|
-
...runInfo(error.data), status: error.status,
|
|
108
|
-
errorCode: error.code.replace(/^UNS_V2_/, 'CONTROL_'),
|
|
109
|
-
requestId: error.requestId, execution: error.execution, retry: error.retry,
|
|
110
|
-
reason: error.reason, details: error.details, data: error.data,
|
|
111
|
-
};
|
|
112
|
-
if (error.outcomeUnknown)
|
|
113
|
-
throw new ControlResultUnknownError(info);
|
|
114
|
-
throw new ControlError(error.message, info);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/** Discover visible contracts; defaults and authorization are resolved by the server. */
|
|
118
|
-
async discover(options = {}) {
|
|
119
|
-
keys(options, ['page', 'size', 'search']);
|
|
120
|
-
if ((options.page !== undefined && (!Number.isSafeInteger(options.page) || options.page < 1)) ||
|
|
121
|
-
(options.size !== undefined && (!Number.isSafeInteger(options.size) || options.size < 1 || options.size > 200)) ||
|
|
122
|
-
(options.search !== undefined && typeof options.search !== 'string')) {
|
|
123
|
-
throw new TypeError('Tier0 SDK: invalid Control discovery options.');
|
|
124
|
-
}
|
|
125
|
-
const { value, status } = await this.post('controlDiscover', options);
|
|
126
|
-
if (!record(value) || !Number.isSafeInteger(value.total) || value.total < 0 ||
|
|
127
|
-
!Array.isArray(value.list) || !value.list.every(definition)) {
|
|
128
|
-
throw new ControlError('Invalid Control discovery response.', { status, errorCode: 'CONTROL_PROTOCOL_ERROR' });
|
|
129
|
-
}
|
|
130
|
-
return { total: value.total, list: value.list };
|
|
131
|
-
}
|
|
132
|
-
use(selector) {
|
|
133
|
-
keys(selector, ['code']);
|
|
134
|
-
const code = selector.code;
|
|
135
|
-
if (typeof code !== 'string' || code.length > 128 || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(code)) {
|
|
136
|
-
throw new TypeError('Tier0 SDK: invalid Control code.');
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
describe: async () => {
|
|
140
|
-
const { value, status } = await this.post('controlDescribe', { code });
|
|
141
|
-
if (!definition(value) || value.code !== code) {
|
|
142
|
-
throw new ControlError('Invalid Control description.', { status, errorCode: 'CONTROL_PROTOCOL_ERROR' });
|
|
143
|
-
}
|
|
144
|
-
return value;
|
|
145
|
-
},
|
|
146
|
-
invoke: async (input, options = {}) => {
|
|
147
|
-
keys(options, ['idempotencyKey']);
|
|
148
|
-
const key = options.idempotencyKey;
|
|
149
|
-
if (key !== undefined && (typeof key !== 'string' || !key || key.trim() !== key || new TextEncoder().encode(key).length > 128)) {
|
|
150
|
-
throw new TypeError('Tier0 SDK: invalid Control idempotency key.');
|
|
151
|
-
}
|
|
152
|
-
if (!json(input))
|
|
153
|
-
throw new TypeError('Tier0 SDK: Control input must be JSON.');
|
|
154
|
-
const { value, status } = await this.post('controlInvoke', {
|
|
155
|
-
code, input: input, ...(key === undefined ? {} : { idempotencyKey: key }),
|
|
156
|
-
});
|
|
157
|
-
if (!record(value) || value.code !== code || typeof value.contractVersion !== 'string' || !value.contractVersion ||
|
|
158
|
-
!Object.prototype.hasOwnProperty.call(value, 'result') || typeof value.runId !== 'string' || !value.runId ||
|
|
159
|
-
typeof value.status !== 'string' || !value.status || ['accepted', 'queued', 'pending', 'running'].includes(value.status) ||
|
|
160
|
-
typeof value.replayed !== 'boolean') {
|
|
161
|
-
throw new ControlResultUnknownError({ ...runInfo(value), status, errorCode: 'CONTROL_PROTOCOL_ERROR' });
|
|
162
|
-
}
|
|
163
|
-
return { code: value.code, contractVersion: value.contractVersion, result: value.result,
|
|
164
|
-
runID: value.runId, status: value.status, replayed: value.replayed };
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
exports.ControlsClient = ControlsClient;
|
|
170
|
-
/** Uses configureClient()/TIER0_API_HOST/TIER0_API_KEY, resolved for every call. */
|
|
171
|
-
exports.controls = new ControlsClient();
|
|
172
|
-
//# sourceMappingURL=controls.js.map
|
package/dist/cjs/controls.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../src/controls.ts"],"names":[],"mappings":";;;AAAA,mDAAoF;AACpF,6DAAqG;AACrG,kDAAuG;AACvG,gDAAmD;AAmCtC,QAAA,oCAAoC,GAAG,uDAAkC,CAAC;AAkCvF,oFAAoF;AACpF,MAAa,YAAa,SAAQ,KAAK;IAC5B,MAAM,CAAU;IAChB,SAAS,CAAS;IAClB,KAAK,CAAU;IACf,eAAe,CAAU;IACzB,SAAS,CAAU;IACnB,QAAQ,CAAW;IACnB,SAAS,CAAU;IACnB,SAAS,CAAkB;IAC3B,KAAK,CAAc;IACnB,MAAM,CAAU;IAChB,OAAO,CAA6B;IACpC,IAAI,CAAW;IACf,SAAS,GAAG,KAAK,CAAC;IAE3B,YAAY,OAAe,EAAE,IAAsB;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,I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UD_TRANSPORT_TIMEOUT_MS, type CloudTransportConfig } from './cloud-transport.js';\nimport { UnsV2ClientCore, UnsV2Error, type UnsV2Execution, type UnsV2Retry } from './uns-v2/client.js';\nimport { UnsV2RawNumber } from './uns-v2/codec.js';\nimport type { UnsV2JSONValue, UnsV2Request } from './uns-v2/generated.js';\n\n/** Control convenience API over the canonical UNS v2 routes. Exact numbers are preserved. */\nexport type ControlJSON = UnsV2JSONValue;\n\nexport interface PublicControl {\n code: string;\n name: string;\n description: string;\n contractVersion: string;\n inputSchema: Record<string, ControlJSON>;\n outputSchema: Record<string, ControlJSON>;\n sideEffect: 'read' | 'write';\n idempotency: 'none' | 'optional' | 'required';\n timeoutMs: number;\n status: string;\n}\n\nexport interface ControlDiscoverOptions {\n page?: number;\n size?: number;\n search?: string;\n}\n\nexport interface ControlDiscoverResponse {\n total: number;\n list: PublicControl[];\n}\n\n/** Shared HTTP settings. The server still resolves the Control binding and authorization. */\nexport interface ControlTransportConfig extends CloudTransportConfig {}\n\nexport interface CloudClientConfig extends ClientConfig, ControlTransportConfig {}\n\nexport const DEFAULT_CONTROL_TRANSPORT_TIMEOUT_MS = DEFAULT_CLOUD_TRANSPORT_TIMEOUT_MS;\n\nexport interface ControlInvokeOptions {\n /** Stable caller-owned key for one business intent, at most 128 UTF-8 bytes. Never generated or retried by the SDK. */\n idempotencyKey?: string;\n}\n\nexport interface ControlInvokeResponse<Result = ControlJSON> {\n code: string;\n contractVersion: string;\n result: Result;\n runID: string;\n status: string;\n /** True only when the server explicitly reports an idempotent replay. */\n replayed: boolean;\n}\n\nexport interface ControlErrorInfo {\n /** HTTP status, absent when no HTTP response was received. */\n status?: number;\n /** Canonical UNS error.code, or an SDK-local CONTROL_* transport/protocol code. */\n errorCode: string;\n runID?: string;\n contractVersion?: string;\n runStatus?: string;\n replayed?: boolean;\n requestId?: string;\n execution?: UnsV2Execution;\n retry?: UnsV2Retry;\n reason?: string;\n details?: Record<string, unknown>[];\n data?: unknown;\n}\n\n/** No Control error is automatically retried, including authentication failures. */\nexport class ControlError extends Error {\n readonly status?: number;\n readonly errorCode: string;\n readonly runID?: string;\n readonly contractVersion?: string;\n readonly runStatus?: string;\n readonly replayed?: boolean;\n readonly requestId?: string;\n readonly execution?: UnsV2Execution;\n readonly retry?: UnsV2Retry;\n readonly reason?: string;\n readonly details?: Record<string, unknown>[];\n readonly data?: unknown;\n readonly retryable = false;\n\n constructor(message: string, info: ControlErrorInfo) {\n super(message);\n this.name = 'ControlError';\n this.status = info.status;\n this.errorCode = info.errorCode;\n this.runID = info.runID;\n this.contractVersion = info.contractVersion;\n this.runStatus = info.runStatus;\n this.replayed = info.replayed;\n this.requestId = info.requestId;\n this.execution = info.execution;\n this.retry = info.retry;\n this.reason = info.reason;\n this.details = info.details;\n this.data = info.data;\n }\n}\n\n/** Execution may have happened. Reconcile run information; any deliberate replay must reuse the same key. */\nexport class ControlResultUnknownError extends ControlError {\n readonly outcomeUnknown = true;\n\n constructor(info: ControlErrorInfo) {\n super('Control result is unknown; execution may have occurred. Do not automatically retry.', info);\n this.name = 'ControlResultUnknownError';\n }\n}\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction keys(value: unknown, allowed: string[]): void {\n if (!record(value) || Reflect.ownKeys(value).some(key => typeof key !== 'string' || !allowed.includes(key))) {\n throw new TypeError('Tier0 SDK: unsupported Control option.');\n }\n}\n\nfunction json(value: unknown, seen = new Set<unknown>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean' || value instanceof UnsV2RawNumber) return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || seen.has(value)) return false;\n if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {\n return false;\n }\n seen.add(value);\n const valid = (Array.isArray(value) ? Array.from(value) : Object.values(value)).every(item => json(item, seen));\n seen.delete(value);\n return valid;\n}\n\nfunction definition(value: unknown): value is PublicControl {\n if (!record(value)) return false;\n return ['code', 'name', 'description', 'contractVersion', 'status'].every(key => typeof value[key] === 'string') &&\n value.code !== '' && value.contractVersion !== '' && record(value.inputSchema) && record(value.outputSchema) &&\n ['read', 'write'].includes(value.sideEffect as string) &&\n ['none', 'optional', 'required'].includes(value.idempotency as string) &&\n typeof value.timeoutMs === 'number' && Number.isSafeInteger(value.timeoutMs) && value.timeoutMs > 0;\n}\n\nfunction runInfo(value: unknown): Partial<ControlErrorInfo> {\n if (!record(value)) return {};\n return {\n runID: typeof value.runId === 'string' ? value.runId : undefined,\n contractVersion: typeof value.contractVersion === 'string' ? value.contractVersion : undefined,\n runStatus: typeof value.status === 'string' ? value.status : undefined,\n replayed: typeof value.replayed === 'boolean' ? value.replayed : undefined,\n };\n}\n\nexport interface ControlHandle<Input = ControlJSON, Result = ControlJSON> {\n describe(): Promise<PublicControl>;\n /**\n * One POST only. Input is opaque business JSON, including fields named streamId,\n * entryId, deploymentVersion or timeoutMs. Only the server chooses binding/version/timeout.\n * Generic types are caller assertions; the server validates the contract schemas.\n */\n invoke(input: Input, options?: ControlInvokeOptions): Promise<ControlInvokeResponse<Result>>;\n}\n\nexport class ControlsClient {\n private readonly uns: UnsV2ClientCore;\n\n constructor(resolveClient: () => HttpClient = getClient, config: ControlTransportConfig = {}) {\n this.uns = new UnsV2ClientCore(resolveClient, config);\n }\n\n private async post<Name extends 'controlDiscover' | 'controlDescribe' | 'controlInvoke'>(\n operation: Name, body: UnsV2Request<Name>,\n ): Promise<{ value: unknown; status: number }> {\n try {\n const response = await this.uns.call(operation, body);\n return { value: response.data, status: 200 };\n } catch (error) {\n if (!(error instanceof UnsV2Error)) throw error;\n const info: ControlErrorInfo = {\n ...runInfo(error.data), status: error.status,\n errorCode: error.code.replace(/^UNS_V2_/, 'CONTROL_'),\n requestId: error.requestId, execution: error.execution, retry: error.retry,\n reason: error.reason, details: error.details, data: error.data,\n };\n if (error.outcomeUnknown) throw new ControlResultUnknownError(info);\n throw new ControlError(error.message, info);\n }\n }\n\n /** Discover visible contracts; defaults and authorization are resolved by the server. */\n async discover(options: ControlDiscoverOptions = {}): Promise<ControlDiscoverResponse> {\n keys(options, ['page', 'size', 'search']);\n if ((options.page !== undefined && (!Number.isSafeInteger(options.page) || options.page < 1)) ||\n (options.size !== undefined && (!Number.isSafeInteger(options.size) || options.size < 1 || options.size > 200)) ||\n (options.search !== undefined && typeof options.search !== 'string')) {\n throw new TypeError('Tier0 SDK: invalid Control discovery options.');\n }\n const { value, status } = await this.post('controlDiscover', options);\n if (!record(value) || !Number.isSafeInteger(value.total) || (value.total as number) < 0 ||\n !Array.isArray(value.list) || !value.list.every(definition)) {\n throw new ControlError('Invalid Control discovery response.', { status, errorCode: 'CONTROL_PROTOCOL_ERROR' });\n }\n return { total: value.total as number, list: value.list as PublicControl[] };\n }\n\n use<Input = ControlJSON, Result = ControlJSON>(selector: { code: string }): ControlHandle<Input, Result> {\n keys(selector, ['code']);\n const code = selector.code;\n if (typeof code !== 'string' || code.length > 128 || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(code)) {\n throw new TypeError('Tier0 SDK: invalid Control code.');\n }\n return {\n describe: async () => {\n const { value, status } = await this.post('controlDescribe', { code });\n if (!definition(value) || value.code !== code) {\n throw new ControlError('Invalid Control description.', { status, errorCode: 'CONTROL_PROTOCOL_ERROR' });\n }\n return value;\n },\n invoke: async (input, options = {}) => {\n keys(options, ['idempotencyKey']);\n const key = options.idempotencyKey;\n if (key !== undefined && (typeof key !== 'string' || !key || key.trim() !== key || new TextEncoder().encode(key).length > 128)) {\n throw new TypeError('Tier0 SDK: invalid Control idempotency key.');\n }\n if (!json(input)) throw new TypeError('Tier0 SDK: Control input must be JSON.');\n const { value, status } = await this.post('controlInvoke', {\n code, input: input as ControlJSON, ...(key === undefined ? {} : { idempotencyKey: key }),\n });\n if (!record(value) || value.code !== code || typeof value.contractVersion !== 'string' || !value.contractVersion ||\n !Object.prototype.hasOwnProperty.call(value, 'result') || typeof value.runId !== 'string' || !value.runId ||\n typeof value.status !== 'string' || !value.status || ['accepted', 'queued', 'pending', 'running'].includes(value.status) ||\n typeof value.replayed !== 'boolean') {\n throw new ControlResultUnknownError({ ...runInfo(value), status, errorCode: 'CONTROL_PROTOCOL_ERROR' });\n }\n return { code: value.code, contractVersion: value.contractVersion, result: value.result as Result,\n runID: value.runId, status: value.status, replayed: value.replayed };\n },\n };\n }\n}\n\n/** Uses configureClient()/TIER0_API_HOST/TIER0_API_KEY, resolved for every call. */\nexport const controls = new ControlsClient();\n"]}
|
package/dist/esm/controls.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { type HttpClient, type ClientConfig } from './openapi/client.js';
|
|
2
|
-
import { type CloudTransportConfig } from './cloud-transport.js';
|
|
3
|
-
import { type UnsV2Execution, type UnsV2Retry } from './uns-v2/client.js';
|
|
4
|
-
import type { UnsV2JSONValue } from './uns-v2/generated.js';
|
|
5
|
-
/** Control convenience API over the canonical UNS v2 routes. Exact numbers are preserved. */
|
|
6
|
-
export type ControlJSON = UnsV2JSONValue;
|
|
7
|
-
export interface PublicControl {
|
|
8
|
-
code: string;
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
contractVersion: string;
|
|
12
|
-
inputSchema: Record<string, ControlJSON>;
|
|
13
|
-
outputSchema: Record<string, ControlJSON>;
|
|
14
|
-
sideEffect: 'read' | 'write';
|
|
15
|
-
idempotency: 'none' | 'optional' | 'required';
|
|
16
|
-
timeoutMs: number;
|
|
17
|
-
status: string;
|
|
18
|
-
}
|
|
19
|
-
export interface ControlDiscoverOptions {
|
|
20
|
-
page?: number;
|
|
21
|
-
size?: number;
|
|
22
|
-
search?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface ControlDiscoverResponse {
|
|
25
|
-
total: number;
|
|
26
|
-
list: PublicControl[];
|
|
27
|
-
}
|
|
28
|
-
/** Shared HTTP settings. The server still resolves the Control binding and authorization. */
|
|
29
|
-
export interface ControlTransportConfig extends CloudTransportConfig {
|
|
30
|
-
}
|
|
31
|
-
export interface CloudClientConfig extends ClientConfig, ControlTransportConfig {
|
|
32
|
-
}
|
|
33
|
-
export declare const DEFAULT_CONTROL_TRANSPORT_TIMEOUT_MS = 60000;
|
|
34
|
-
export interface ControlInvokeOptions {
|
|
35
|
-
/** Stable caller-owned key for one business intent, at most 128 UTF-8 bytes. Never generated or retried by the SDK. */
|
|
36
|
-
idempotencyKey?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface ControlInvokeResponse<Result = ControlJSON> {
|
|
39
|
-
code: string;
|
|
40
|
-
contractVersion: string;
|
|
41
|
-
result: Result;
|
|
42
|
-
runID: string;
|
|
43
|
-
status: string;
|
|
44
|
-
/** True only when the server explicitly reports an idempotent replay. */
|
|
45
|
-
replayed: boolean;
|
|
46
|
-
}
|
|
47
|
-
export interface ControlErrorInfo {
|
|
48
|
-
/** HTTP status, absent when no HTTP response was received. */
|
|
49
|
-
status?: number;
|
|
50
|
-
/** Canonical UNS error.code, or an SDK-local CONTROL_* transport/protocol code. */
|
|
51
|
-
errorCode: string;
|
|
52
|
-
runID?: string;
|
|
53
|
-
contractVersion?: string;
|
|
54
|
-
runStatus?: string;
|
|
55
|
-
replayed?: boolean;
|
|
56
|
-
requestId?: string;
|
|
57
|
-
execution?: UnsV2Execution;
|
|
58
|
-
retry?: UnsV2Retry;
|
|
59
|
-
reason?: string;
|
|
60
|
-
details?: Record<string, unknown>[];
|
|
61
|
-
data?: unknown;
|
|
62
|
-
}
|
|
63
|
-
/** No Control error is automatically retried, including authentication failures. */
|
|
64
|
-
export declare class ControlError extends Error {
|
|
65
|
-
readonly status?: number;
|
|
66
|
-
readonly errorCode: string;
|
|
67
|
-
readonly runID?: string;
|
|
68
|
-
readonly contractVersion?: string;
|
|
69
|
-
readonly runStatus?: string;
|
|
70
|
-
readonly replayed?: boolean;
|
|
71
|
-
readonly requestId?: string;
|
|
72
|
-
readonly execution?: UnsV2Execution;
|
|
73
|
-
readonly retry?: UnsV2Retry;
|
|
74
|
-
readonly reason?: string;
|
|
75
|
-
readonly details?: Record<string, unknown>[];
|
|
76
|
-
readonly data?: unknown;
|
|
77
|
-
readonly retryable = false;
|
|
78
|
-
constructor(message: string, info: ControlErrorInfo);
|
|
79
|
-
}
|
|
80
|
-
/** Execution may have happened. Reconcile run information; any deliberate replay must reuse the same key. */
|
|
81
|
-
export declare class ControlResultUnknownError extends ControlError {
|
|
82
|
-
readonly outcomeUnknown = true;
|
|
83
|
-
constructor(info: ControlErrorInfo);
|
|
84
|
-
}
|
|
85
|
-
export interface ControlHandle<Input = ControlJSON, Result = ControlJSON> {
|
|
86
|
-
describe(): Promise<PublicControl>;
|
|
87
|
-
/**
|
|
88
|
-
* One POST only. Input is opaque business JSON, including fields named streamId,
|
|
89
|
-
* entryId, deploymentVersion or timeoutMs. Only the server chooses binding/version/timeout.
|
|
90
|
-
* Generic types are caller assertions; the server validates the contract schemas.
|
|
91
|
-
*/
|
|
92
|
-
invoke(input: Input, options?: ControlInvokeOptions): Promise<ControlInvokeResponse<Result>>;
|
|
93
|
-
}
|
|
94
|
-
export declare class ControlsClient {
|
|
95
|
-
private readonly uns;
|
|
96
|
-
constructor(resolveClient?: () => HttpClient, config?: ControlTransportConfig);
|
|
97
|
-
private post;
|
|
98
|
-
/** Discover visible contracts; defaults and authorization are resolved by the server. */
|
|
99
|
-
discover(options?: ControlDiscoverOptions): Promise<ControlDiscoverResponse>;
|
|
100
|
-
use<Input = ControlJSON, Result = ControlJSON>(selector: {
|
|
101
|
-
code: string;
|
|
102
|
-
}): ControlHandle<Input, Result>;
|
|
103
|
-
}
|
|
104
|
-
/** Uses configureClient()/TIER0_API_HOST/TIER0_API_KEY, resolved for every call. */
|
|
105
|
-
export declare const controls: ControlsClient;
|