@aicloud360/dsh-cloud-disk-api-provider 0.1.1-alpha.2 → 0.1.1-alpha.3

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/lib/index.js CHANGED
@@ -2,12 +2,214 @@ import { createHash } from "node:crypto";
2
2
  import z from "@deepseek-ai/schemastery";
3
3
  import { credentialRef } from "@deepseek-ai/dsh-credentials";
4
4
  import CloudDiskRuntime, { CloudDiskError } from "@aicloud360/dsh-cloud-disk";
5
+ //#region lib/types/cloud-disk-rpc.js
6
+ /** Private Connection RPC for the CloudDisk browser workspace. */
7
+ const CHANNEL = "/cloud-disk";
8
+ const API_KEY_REF = credentialRef("CLOUD_DISK_API_KEY");
9
+ const SIGNING_SECRET_REF = credentialRef("CLOUD_DISK_SIGNING_SECRET");
10
+ const credentialKindSchema = z.union([z.const("apiKey"), z.const("signingSecret")]);
11
+ const listSchema = z.object({
12
+ parentId: z.string(),
13
+ cursor: z.string(),
14
+ limit: z.number().step(1).min(1)
15
+ });
16
+ const searchSchema = z.object({
17
+ query: z.string().required(),
18
+ cursor: z.string(),
19
+ limit: z.number().step(1).min(1)
20
+ });
21
+ const credentialSetSchema = z.object({
22
+ kind: credentialKindSchema.required(),
23
+ value: z.string().min(1).required()
24
+ });
25
+ const credentialUnsetSchema = z.object({ kind: credentialKindSchema.required() });
26
+ const CLOUD_DISK_FAILURE_CODES = new Set([
27
+ "CLOUD_DISK_PROVIDER_CONFIGURED_MISSING",
28
+ "CLOUD_DISK_PROVIDER_CONFIGURED_UNAVAILABLE",
29
+ "CLOUD_DISK_PROVIDER_UNAVAILABLE",
30
+ "CLOUD_DISK_PROVIDER_AMBIGUOUS",
31
+ "CLOUD_DISK_CREDENTIAL_MISSING",
32
+ "CLOUD_DISK_SIGNING_SECRET_MISSING",
33
+ "CLOUD_DISK_AUTHENTICATION_FAILED",
34
+ "CLOUD_DISK_NETWORK_FAILED",
35
+ "CLOUD_DISK_INVALID_REQUEST",
36
+ "CLOUD_DISK_PROVIDER_FAILED"
37
+ ]);
38
+ function credentialFor(kind) {
39
+ return kind === "apiKey" ? API_KEY_REF : SIGNING_SECRET_REF;
40
+ }
41
+ function parse(schema, payload) {
42
+ try {
43
+ return schema(payload);
44
+ } catch {
45
+ return;
46
+ }
47
+ }
48
+ function badRequest(message) {
49
+ return {
50
+ ok: false,
51
+ error: {
52
+ code: "bad-request",
53
+ message,
54
+ details: { issues: [] }
55
+ }
56
+ };
57
+ }
58
+ function internalFailure(message) {
59
+ return {
60
+ ok: false,
61
+ error: {
62
+ code: "internal",
63
+ message,
64
+ details: {}
65
+ }
66
+ };
67
+ }
68
+ function cancelled() {
69
+ return {
70
+ ok: false,
71
+ error: {
72
+ code: "cancelled",
73
+ message: "cloud disk request was aborted",
74
+ details: {}
75
+ }
76
+ };
77
+ }
78
+ function failureCode(error) {
79
+ if (!(error instanceof CloudDiskError) || !CLOUD_DISK_FAILURE_CODES.has(error.code)) return void 0;
80
+ return error.code;
81
+ }
82
+ function pageView(page) {
83
+ return {
84
+ nodes: page.nodes.map((node) => ({
85
+ id: node.id,
86
+ kind: node.kind,
87
+ name: node.name,
88
+ ...node.parentId === void 0 ? {} : { parentId: node.parentId },
89
+ ...node.size === void 0 ? {} : { size: node.size },
90
+ ...node.updatedAt === void 0 ? {} : { updatedAt: node.updatedAt }
91
+ })),
92
+ ...page.nextCursor === void 0 ? {} : { nextCursor: page.nextCursor }
93
+ };
94
+ }
95
+ /**
96
+ * Register the CloudDisk browser RPC channel. Credential endpoints only address
97
+ * the two CloudDisk references, so this plugin cannot become a general
98
+ * credential-inspection surface.
99
+ * @param ctx - Host context with the selected CloudDisk provider and credentials.
100
+ */
101
+ function installCloudDiskRpc(ctx) {
102
+ ctx.connection.rpc.handle(CHANNEL, async (endpoint, payload, signal) => {
103
+ if (signal.aborted) return cancelled();
104
+ switch (endpoint) {
105
+ case "status":
106
+ if (parse(z.object({}), payload) === void 0) return badRequest("invalid cloud disk status request");
107
+ try {
108
+ return {
109
+ ok: true,
110
+ value: {
111
+ available: true,
112
+ user: await ctx.cloudDisk.getUser(signal)
113
+ }
114
+ };
115
+ } catch (error) {
116
+ const errorCode = failureCode(error);
117
+ return {
118
+ ok: true,
119
+ value: {
120
+ available: false,
121
+ ...errorCode === void 0 ? {} : { errorCode }
122
+ }
123
+ };
124
+ }
125
+ case "credentials/describe": {
126
+ if (parse(z.object({}), payload) === void 0) return badRequest("invalid cloud disk credential request");
127
+ const [apiKey, signingSecret] = await Promise.all([ctx.credentials.describe(API_KEY_REF), ctx.credentials.describe(SIGNING_SECRET_REF)]);
128
+ return {
129
+ ok: true,
130
+ value: {
131
+ apiKey,
132
+ signingSecret
133
+ }
134
+ };
135
+ }
136
+ case "credentials/set": {
137
+ const parsed = parse(credentialSetSchema, payload);
138
+ if (parsed === void 0) return badRequest("invalid cloud disk credential request");
139
+ try {
140
+ await ctx.credentials.set(credentialFor(parsed.kind), parsed.value);
141
+ return {
142
+ ok: true,
143
+ value: {}
144
+ };
145
+ } catch {
146
+ return internalFailure("cloud disk credential could not be saved");
147
+ }
148
+ }
149
+ case "credentials/unset": {
150
+ const parsed = parse(credentialUnsetSchema, payload);
151
+ if (parsed === void 0) return badRequest("invalid cloud disk credential request");
152
+ try {
153
+ await ctx.credentials.unset(credentialFor(parsed.kind));
154
+ return {
155
+ ok: true,
156
+ value: {}
157
+ };
158
+ } catch {
159
+ return internalFailure("cloud disk credential could not be removed");
160
+ }
161
+ }
162
+ case "browse/list": {
163
+ const parsed = parse(listSchema, payload);
164
+ if (parsed === void 0) return badRequest("invalid cloud disk list request");
165
+ try {
166
+ const page = await ctx.cloudDisk.list({
167
+ ...parsed.parentId === void 0 ? {} : { parentId: parsed.parentId },
168
+ ...parsed.cursor === void 0 ? {} : { cursor: parsed.cursor },
169
+ ...parsed.limit === void 0 ? {} : { limit: parsed.limit }
170
+ }, signal);
171
+ if (signal.aborted) return cancelled();
172
+ return {
173
+ ok: true,
174
+ value: pageView(page)
175
+ };
176
+ } catch {
177
+ return signal.aborted ? cancelled() : internalFailure("cloud disk listing failed");
178
+ }
179
+ }
180
+ case "browse/search": {
181
+ const parsed = parse(searchSchema, payload);
182
+ if (parsed === void 0 || parsed.query.trim() === "") return badRequest("invalid cloud disk search request");
183
+ try {
184
+ const page = await ctx.cloudDisk.search({
185
+ query: parsed.query.trim(),
186
+ ...parsed.cursor === void 0 ? {} : { cursor: parsed.cursor },
187
+ ...parsed.limit === void 0 ? {} : { limit: parsed.limit }
188
+ }, signal);
189
+ if (signal.aborted) return cancelled();
190
+ return {
191
+ ok: true,
192
+ value: pageView(page)
193
+ };
194
+ } catch {
195
+ return signal.aborted ? cancelled() : internalFailure("cloud disk search failed");
196
+ }
197
+ }
198
+ default: return badRequest("unknown cloud disk endpoint");
199
+ }
200
+ }, { authority: "loopback" });
201
+ }
202
+ //#endregion
5
203
  //#region lib/types/index.js
6
204
  /** Direct Host-side adapter for the audited 360 CloudDisk OpenAPI. */
7
205
  /** Cordis loader name for the direct CloudDisk Provider plugin. */
8
206
  const name = "cloud-disk-api-provider";
9
207
  /** Host services required to register and operate the direct Provider. */
10
- const inject = ["cloudDisk", "credentials"];
208
+ const inject = [
209
+ "cloudDisk",
210
+ "credentials",
211
+ "connection"
212
+ ];
11
213
  /** Runtime schema for the complete, explicit Provider configuration. */
12
214
  const Config = z.object({
13
215
  endpoint: z.string().required(),
@@ -264,6 +466,7 @@ function apply(ctx, config) {
264
466
  timeoutMs: config.timeoutMs,
265
467
  maxRetries: config.maxRetries
266
468
  });
469
+ installCloudDiskRpc(ctx);
267
470
  }
268
471
  function isRecord(value) {
269
472
  return value !== null && typeof value === "object" && !Array.isArray(value);
@@ -0,0 +1,10 @@
1
+ /** Private Connection RPC for the CloudDisk browser workspace. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ /**
4
+ * Register the CloudDisk browser RPC channel. Credential endpoints only address
5
+ * the two CloudDisk references, so this plugin cannot become a general
6
+ * credential-inspection surface.
7
+ * @param ctx - Host context with the selected CloudDisk provider and credentials.
8
+ */
9
+ export declare function installCloudDiskRpc(ctx: Context): void;
10
+ //# sourceMappingURL=cloud-disk-rpc.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aicloud360/dsh-cloud-disk-api-provider",
3
3
  "description": "Direct Host-side HTTP provider adapter for the native CloudDisk capability seam",
4
- "version": "0.1.1-alpha.2",
4
+ "version": "0.1.1-alpha.3",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org"
@@ -21,6 +21,7 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "peerDependencies": {
24
+ "@deepseek-ai/dsh-client-connection": "0.1.1-rc.2",
24
25
  "@deepseek-ai/dsh-credentials": "0.1.1-rc.2",
25
26
  "@deepseek-ai/dsh-invariants": "0.1.1-rc.2",
26
27
  "@deepseek-ai/schemastery": "^3.18.1",
@@ -38,6 +39,6 @@
38
39
  "./package.json": "./package.json"
39
40
  },
40
41
  "dependencies": {
41
- "@aicloud360/dsh-cloud-disk": "0.1.1-alpha.2"
42
+ "@aicloud360/dsh-cloud-disk": "0.1.1-alpha.3"
42
43
  }
43
- }
44
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 DeepSeek
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.