@coralai/sps-plugin-api 0.9.0 → 0.10.0

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 CHANGED
@@ -254,6 +254,30 @@ export interface SpsNotifier {
254
254
  send(message: string, level?: 'info' | 'success' | 'warning' | 'error'): Promise<void>;
255
255
  };
256
256
  }
257
+ export interface SpsStorageObject {
258
+ key: string;
259
+ /** **内容判据**(单段上传时等于 md5)。不看时间。 */
260
+ etag: string;
261
+ size: number;
262
+ }
263
+ /**
264
+ * 对象存储(读 / 列 / 写)。桶是共享面 —— 多节点下 studio 和工作区不在同一台机器上。
265
+ *
266
+ * 🔴 **它只搬字节,不做账。** id / 索引 / 缩略图 / 分类 / 配额 / 计费都在平台侧。
267
+ *
268
+ * ⚠️ **权限按前缀分,而且很紧**(单写方规则)。
269
+ * 读不了的前缀会**抛**,不会回空 —— "库是空的"和"我没权限"混成一个,
270
+ * 人会去补素材而不是去补策略。
271
+ * ⚠️ 桶没配时三个方法都抛 ⇒ **先用 `configured()` 问一句**,别拿异常当分支。
272
+ */
273
+ export interface SpsStorage {
274
+ configured(): boolean;
275
+ /** 不存在 ⇒ `null`;连不上/没权限 ⇒ **抛**。 */
276
+ get(key: string): Promise<Buffer | null>;
277
+ list(prefix: string): Promise<SpsStorageObject[]>;
278
+ /** ⚠️ `contentType` 自己决定 —— 桶是直连的,缺省会让预览变成一次下载。 */
279
+ put(key: string, bytes: Buffer, contentType?: string): Promise<void>;
280
+ }
257
281
  /** 与 `SpsAsyncPoll` 同形 —— async 能力的 `poll` 可以**直接透传**。 */
258
282
  export type SpsJobStatus = SpsAsyncPoll;
259
283
  /**
@@ -479,6 +503,7 @@ export declare const SPS_SERVICES: {
479
503
  readonly projects: "sps.projects";
480
504
  readonly cards: "sps.cards";
481
505
  readonly jobs: "sps.jobs";
506
+ readonly storage: "sps.storage";
482
507
  readonly subprocess: "sps.subprocess";
483
508
  readonly attachments: "sps.attachments";
484
509
  readonly media: "sps.media";
@@ -501,6 +526,7 @@ export interface SpsPluginContext {
501
526
  'sps.projects': SpsProjects;
502
527
  'sps.cards': SpsCards;
503
528
  'sps.jobs': SpsJobs;
529
+ 'sps.storage': SpsStorage;
504
530
  'sps.capabilities': SpsCapabilities;
505
531
  'sps.media': SpsMedia;
506
532
  'sps.im': SpsRegistryByKey;
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ export const SPS_SERVICES = {
24
24
  projects: 'sps.projects',
25
25
  cards: 'sps.cards',
26
26
  jobs: 'sps.jobs',
27
+ storage: 'sps.storage',
27
28
  subprocess: 'sps.subprocess',
28
29
  attachments: 'sps.attachments',
29
30
  media: 'sps.media',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralai/sps-plugin-api",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "sps 宿主半区的插件契约:ctx 上那些服务的方法签名。插件装它拿类型。",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",