@adep/runtime 0.3.13 → 0.3.15

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.
@@ -1,13 +1,23 @@
1
+ import type { ChainSpec } from '@adep/types';
1
2
  import type { CapabilityBundle } from '@adep/types';
2
3
  import type { ProjectDriver } from '../../db/project-driver';
3
4
  export interface CreateDbCapabilityOptions {
4
5
  /**
5
- * 写终端(insert / insertMany / update / delete)执行前的项目级配额钩子(BILL-005,§2.7.3)。
6
+ * 写终端(insert / insertMany / update / delete / upsert)执行前的项目级配额钩子(BILL-005,§2.7.3)。
6
7
  * 由 provider 绑定 projectId + dataDir 注入(方言无关 usageStats 量当前用量,超限抛 429 拒写)。
7
8
  * 缺省不注入 → 不做写前配额门(fail-open 过渡)。
8
9
  */
9
10
  beforeWrite?: (driver: ProjectDriver) => Promise<void>;
10
11
  }
12
+ /** 链式能力的装配规格:FN worker 只按方法名清单构造客户端,不感知 db 细节。 */
13
+ export declare const CLOUD_DB_SPEC: ChainSpec;
14
+ /**
15
+ * 写终端:这些终值方法在事务期间必须走事务句柄(否则 `DB_UNSAFE_OP`),也是配额钩子
16
+ * `beforeWrite` 的判定集合。必须与 `CLOUD_DB_SPEC.terminalMethods` 里的写方法一一对应——
17
+ * DB-010 新增 `upsert` 时只登记了规格清单、漏了这里(提交说明声称已补但 diff 没改),
18
+ * 于是 upsert 绕过事务外写拒绝与 BILL-005 配额门。防漂移门 spec-drift.test.ts 用例 ④ 钉住它。
19
+ */
20
+ export declare const WRITE_TERMINALS: ReadonlySet<string>;
11
21
  /**
12
22
  * 按驱动产出一组 `cloud.db` 能力。驱动已绑定项目库(连接层隔离,DB-001);
13
23
  * `projectId` 在装配期绑定,函数侧不可感知。内部无共享可变状态污染跨项目调用。
package/dist/index.js CHANGED
@@ -1139,13 +1139,23 @@ function createCloudDb(driver, options = {}) {
1139
1139
  var CLOUD_DB_SPEC = {
1140
1140
  kind: "cloud-db",
1141
1141
  rootMethod: "table",
1142
- stepMethods: ["select", "where", "orderBy", "limit", "offset"],
1143
- terminalMethods: ["get", "first", "count", "insert", "insertMany", "update", "delete"],
1142
+ // 规格清单必须与构建器公开方法面一致(防漂移门 spec-drift.test.ts 双向咬合):
1143
+ // - owned:DB-006 的 owned 声明(step);
1144
+ // - execute:BUG-4 统一执行入口(direct,宿主侧 DB_RPC.execute 分支早已在);
1145
+ // - upsert:DB-010 终端(漏登记过一次,真机 500,见 spec-drift.test.ts 头注释)。
1146
+ stepMethods: ["select", "where", "orderBy", "limit", "offset", "owned"],
1147
+ terminalMethods: ["get", "first", "count", "insert", "insertMany", "update", "delete", "upsert"],
1144
1148
  // CF-013:writeQuery 是 D1 shim 的写路径(INSERT/UPDATE/DELETE),与 query 并列直通方法。
1145
- directMethods: ["query", "writeQuery", "changes"],
1149
+ directMethods: ["query", "writeQuery", "execute", "changes"],
1146
1150
  transactionMethod: "transaction"
1147
1151
  };
1148
- var WRITE_TERMINALS = /* @__PURE__ */ new Set(["insert", "insertMany", "update", "delete"]);
1152
+ var WRITE_TERMINALS = /* @__PURE__ */ new Set([
1153
+ "insert",
1154
+ "insertMany",
1155
+ "update",
1156
+ "delete",
1157
+ "upsert"
1158
+ ]);
1149
1159
  function errorWithCode(error) {
1150
1160
  if (error instanceof Error) {
1151
1161
  const sqlite = /no such table: (\S+)/.exec(error.message);
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.13",
10
+ "version": "0.3.15",
11
11
  "private": false,
12
12
  "type": "module",
13
13
  "sideEffects": false,