@superdurable/connector-fastgpt 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +4 -2
- package/dex-connector.json +60 -0
- package/dist/chunk-RZBY4SGC.js +119 -0
- package/dist/connection-D5kKKQzT.d.ts +81 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.js +253 -0
- package/dist/mock.d.ts +33 -0
- package/dist/mock.js +70 -0
- package/package.json +59 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Super Durable
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# FastGPT TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read one knowledge base title, type, and status without content.
|
|
4
|
+
|
|
5
|
+
Install `@superdurable/connector-fastgpt` and use `newProjectConnection` with the static connection name in the runnable [`examples/basic`](examples/basic) Flow. Configure the connection and provider credentials in Dex Web Connections. The operation `getDatasetDetails` resolves credentials for each call. Local conformance tests replay the Go provider scenarios; live provider authorization has not been verified.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "fastgpt",
|
|
3
|
+
"releaseTag": "connectors/fastgpt/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-fastgpt",
|
|
7
|
+
"version": "0.1.1"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newGetDatasetDetailsStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "getDatasetDetails",
|
|
14
|
+
"inputType": "GetDatasetDetailsInput",
|
|
15
|
+
"description": "Read metadata of one accessible knowledge base.",
|
|
16
|
+
"fields": {
|
|
17
|
+
"stepType": "stepType",
|
|
18
|
+
"annotations": "annotations",
|
|
19
|
+
"connectionName": "connectionName",
|
|
20
|
+
"resultAttribute": "resultAttribute"
|
|
21
|
+
},
|
|
22
|
+
"branches": [
|
|
23
|
+
{
|
|
24
|
+
"id": "found",
|
|
25
|
+
"field": "found",
|
|
26
|
+
"optional": false
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "providerRejected",
|
|
30
|
+
"field": "providerRejected",
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "invalidResponse",
|
|
35
|
+
"field": "invalidResponse",
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "defect",
|
|
40
|
+
"field": "defect",
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"inputSchema": {
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"description": "GetDatasetDetailsInput identifies one knowledge base visible to the personal API Key.",
|
|
47
|
+
"properties": {
|
|
48
|
+
"id": {
|
|
49
|
+
"description": "ID is the knowledge base identifier copied from its FastGPT URL.",
|
|
50
|
+
"type": "string"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": [
|
|
54
|
+
"id"
|
|
55
|
+
],
|
|
56
|
+
"type": "object"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var ConfigSchema = z.object({
|
|
5
|
+
"baseUrl": z.string().optional(),
|
|
6
|
+
"timeoutMs": z.number().int().optional(),
|
|
7
|
+
"maxResponseBytes": z.number().int().optional()
|
|
8
|
+
});
|
|
9
|
+
var CredentialMaterialError = class extends TypeError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "CredentialMaterialError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
16
|
+
"project credential decoding failed",
|
|
17
|
+
"shared project credential decoding failed",
|
|
18
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
19
|
+
]);
|
|
20
|
+
function isCredentialMaterialError(error) {
|
|
21
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
22
|
+
}
|
|
23
|
+
function decodeCredentials(value) {
|
|
24
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
25
|
+
const fields = value;
|
|
26
|
+
const allowed = /* @__PURE__ */ new Set(["api_key"]);
|
|
27
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
28
|
+
if (fields["api_key"] != null && !(typeof fields["api_key"] === "string")) throw new CredentialMaterialError("credential api_key has an invalid type");
|
|
29
|
+
const credentials = {};
|
|
30
|
+
if (!fields["api_key"]) throw new CredentialMaterialError("credential api_key is required");
|
|
31
|
+
credentials.apiKey = new SecretString(fields["api_key"] ?? "");
|
|
32
|
+
return credentials;
|
|
33
|
+
}
|
|
34
|
+
var GetDatasetDetailsInputSchema = z.strictObject({
|
|
35
|
+
"id": z.string()
|
|
36
|
+
});
|
|
37
|
+
var GetDatasetDetailsOutputSchema = z.strictObject({
|
|
38
|
+
"id": z.string(),
|
|
39
|
+
"name": z.string(),
|
|
40
|
+
"type": z.string(),
|
|
41
|
+
"status": z.string()
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// src/generated/definitions.ts
|
|
45
|
+
var ConnectorID = "fastgpt";
|
|
46
|
+
var ProviderID = "fastgpt";
|
|
47
|
+
var GetDatasetDetailsBranch = {
|
|
48
|
+
Found: "found",
|
|
49
|
+
ProviderRejected: "providerRejected",
|
|
50
|
+
InvalidResponse: "invalidResponse",
|
|
51
|
+
Defect: "defect"
|
|
52
|
+
};
|
|
53
|
+
var GetDatasetDetailsBranchFound = GetDatasetDetailsBranch.Found;
|
|
54
|
+
var GetDatasetDetailsBranchProviderRejected = GetDatasetDetailsBranch.ProviderRejected;
|
|
55
|
+
var GetDatasetDetailsBranchInvalidResponse = GetDatasetDetailsBranch.InvalidResponse;
|
|
56
|
+
var GetDatasetDetailsBranchDefect = GetDatasetDetailsBranch.Defect;
|
|
57
|
+
var GetDatasetDetailsDefinition = {
|
|
58
|
+
operation: { connectorId: ConnectorID, operationId: "getDatasetDetails" },
|
|
59
|
+
branches: [
|
|
60
|
+
{ id: "found", description: "FastGPT returned the knowledge base metadata." },
|
|
61
|
+
{ id: "providerRejected", description: "FastGPT rejected access or the knowledge base ID.", optional: true },
|
|
62
|
+
{ id: "invalidResponse", description: "FastGPT returned malformed or oversized data.", optional: true },
|
|
63
|
+
{ id: "defect", description: "Local credentials or knowledge base ID are invalid.", optional: true }
|
|
64
|
+
],
|
|
65
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
66
|
+
};
|
|
67
|
+
var GetDatasetDetailsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
68
|
+
|
|
69
|
+
// src/generated/connection.ts
|
|
70
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
71
|
+
var Connection = class {
|
|
72
|
+
/** Stable provider and connection name. */
|
|
73
|
+
reference;
|
|
74
|
+
/** Bound provider operations. */
|
|
75
|
+
operations;
|
|
76
|
+
/** Validate a reference and bind operations. */
|
|
77
|
+
constructor(reference, operations) {
|
|
78
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
79
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
80
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
81
|
+
this.operations = operations;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
function newConnection(client, reference) {
|
|
85
|
+
if (!client) throw new TypeError("connector client is required");
|
|
86
|
+
return new Connection(reference, client);
|
|
87
|
+
}
|
|
88
|
+
function newConnectionWithOperations(operations, reference) {
|
|
89
|
+
return new Connection(reference, operations);
|
|
90
|
+
}
|
|
91
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
92
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
93
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
94
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
95
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
96
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
ConfigSchema,
|
|
101
|
+
CredentialMaterialError,
|
|
102
|
+
isCredentialMaterialError,
|
|
103
|
+
decodeCredentials,
|
|
104
|
+
GetDatasetDetailsInputSchema,
|
|
105
|
+
GetDatasetDetailsOutputSchema,
|
|
106
|
+
ConnectorID,
|
|
107
|
+
ProviderID,
|
|
108
|
+
GetDatasetDetailsBranch,
|
|
109
|
+
GetDatasetDetailsBranchFound,
|
|
110
|
+
GetDatasetDetailsBranchProviderRejected,
|
|
111
|
+
GetDatasetDetailsBranchInvalidResponse,
|
|
112
|
+
GetDatasetDetailsBranchDefect,
|
|
113
|
+
GetDatasetDetailsDefinition,
|
|
114
|
+
GetDatasetDetailsMetadata,
|
|
115
|
+
Connection,
|
|
116
|
+
newConnection,
|
|
117
|
+
newConnectionWithOperations,
|
|
118
|
+
newProjectConnection
|
|
119
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { CredentialProvider, SecretString, Query, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** HTTPS address of your FastGPT instance as opened in the browser, including any sub-path prefix the deployment was built with through NEXT_PUBLIC_BASE_URL, such as /fastgpt, but without /api. Leave blank for the displayed China cloud origin; override only for your organization's approved HTTPS private deployment or a local loopback test server. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Maximum time for one knowledge-base detail request as a positive Go duration such as 5s or 1m. Leave blank for the displayed default; raise only for a slow approved proxy. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Maximum knowledge-base detail response size in bytes as a positive integer. Leave blank for the displayed default; raise only if a legitimate response exceeds it. */
|
|
11
|
+
maxResponseBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Runtime schema for manifest configuration. */
|
|
14
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
15
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
16
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/** Private connector credentials resolved by the host. */
|
|
20
|
+
interface Credentials {
|
|
21
|
+
/** Personal API Key from https://cloud.fastgpt.cn/ > 账号 > API 密钥; see https://doc.fastgpt.cn/zh-CN/openapi/intro for the page path. Create a key as a member with read access to the target knowledge base; application-scoped chat keys cannot read it. Dex stores it only as a credential. Blank prevents requests. */
|
|
22
|
+
apiKey: SecretString;
|
|
23
|
+
}
|
|
24
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
25
|
+
declare class CredentialMaterialError extends TypeError {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
29
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
30
|
+
/** Decode private credential fields for the connector. */
|
|
31
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
32
|
+
/** Host-owned source of private connector credentials. */
|
|
33
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
34
|
+
/** GetDatasetDetailsInput identifies one knowledge base visible to the personal API Key. */
|
|
35
|
+
interface GetDatasetDetailsInput {
|
|
36
|
+
/** ID is the knowledge base identifier copied from its FastGPT URL. */
|
|
37
|
+
"id": string;
|
|
38
|
+
}
|
|
39
|
+
/** GetDatasetDetailsOutput contains only knowledge base metadata, excluding models and content. */
|
|
40
|
+
interface GetDatasetDetailsOutput {
|
|
41
|
+
/** ID is the provider's knowledge base identifier. */
|
|
42
|
+
"id": string;
|
|
43
|
+
/** Name is the knowledge base title. */
|
|
44
|
+
"name": string;
|
|
45
|
+
/** Type is the provider's knowledge base type. */
|
|
46
|
+
"type": string;
|
|
47
|
+
/** Status is the provider's knowledge base status. */
|
|
48
|
+
"status": string;
|
|
49
|
+
}
|
|
50
|
+
/** Runtime validator for GetDatasetDetailsInput. */
|
|
51
|
+
declare const GetDatasetDetailsInputSchema: z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
}, z.core.$strict>;
|
|
54
|
+
/** Runtime validator for GetDatasetDetailsOutput. */
|
|
55
|
+
declare const GetDatasetDetailsOutputSchema: z.ZodObject<{
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
name: z.ZodString;
|
|
58
|
+
type: z.ZodString;
|
|
59
|
+
status: z.ZodString;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
|
|
62
|
+
/** Typed operations supplied by a client or mock. */
|
|
63
|
+
interface Operations {
|
|
64
|
+
/** Invoke getDatasetDetails through this connection. */
|
|
65
|
+
getDatasetDetails(): Query<GetDatasetDetailsInput, GetDatasetDetailsOutput>;
|
|
66
|
+
}
|
|
67
|
+
/** Named connector connection kept outside Flow state. */
|
|
68
|
+
declare class Connection<BoundOperations = Operations> {
|
|
69
|
+
/** Stable provider and connection name. */
|
|
70
|
+
readonly reference: ConnectionRef;
|
|
71
|
+
/** Bound provider operations. */
|
|
72
|
+
readonly operations: BoundOperations;
|
|
73
|
+
/** Validate a reference and bind operations. */
|
|
74
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
75
|
+
}
|
|
76
|
+
/** Bind a client to a named connection. */
|
|
77
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
78
|
+
/** Bind scripted operations to a named connection. */
|
|
79
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
80
|
+
|
|
81
|
+
export { Connection as C, type GetDatasetDetailsInput as G, type Operations as O, type GetDatasetDetailsOutput as a, type Config as b, type Credentials as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, GetDatasetDetailsInputSchema as g, GetDatasetDetailsOutputSchema as h, decodeCredentials as i, isCredentialMaterialError as j, newConnectionWithOperations as k, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { G as GetDatasetDetailsInput, a as GetDatasetDetailsOutput, C as Connection, O as Operations, b as Config, c as Credentials } from './connection-D5kKKQzT.js';
|
|
2
|
+
export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as GetDatasetDetailsInputSchema, h as GetDatasetDetailsOutputSchema, i as decodeCredentials, j as isCredentialMaterialError, n as newConnection, k as newConnectionWithOperations } from './connection-D5kKKQzT.js';
|
|
3
|
+
import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt } from '@superdurable/connectors-sdk';
|
|
4
|
+
import { StepTarget } from '@superdurable/dex';
|
|
5
|
+
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
6
|
+
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
/** Stable connector identity. */
|
|
10
|
+
declare const ConnectorID = "fastgpt";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "fastgpt";
|
|
13
|
+
/** Branch IDs for getDatasetDetails. */
|
|
14
|
+
declare const GetDatasetDetailsBranch: {
|
|
15
|
+
readonly Found: "found";
|
|
16
|
+
readonly ProviderRejected: "providerRejected";
|
|
17
|
+
readonly InvalidResponse: "invalidResponse";
|
|
18
|
+
readonly Defect: "defect";
|
|
19
|
+
};
|
|
20
|
+
/** FastGPT returned the knowledge base metadata. */
|
|
21
|
+
declare const GetDatasetDetailsBranchFound: "found";
|
|
22
|
+
/** FastGPT rejected access or the knowledge base ID. */
|
|
23
|
+
declare const GetDatasetDetailsBranchProviderRejected: "providerRejected";
|
|
24
|
+
/** FastGPT returned malformed or oversized data. */
|
|
25
|
+
declare const GetDatasetDetailsBranchInvalidResponse: "invalidResponse";
|
|
26
|
+
/** Local credentials or knowledge base ID are invalid. */
|
|
27
|
+
declare const GetDatasetDetailsBranchDefect: "defect";
|
|
28
|
+
/** Manifest definition for getDatasetDetails. */
|
|
29
|
+
declare const GetDatasetDetailsDefinition: QueryDefinition;
|
|
30
|
+
/** Manifest metadata for getDatasetDetails. */
|
|
31
|
+
declare const GetDatasetDetailsMetadata: {
|
|
32
|
+
readonly kind: "query";
|
|
33
|
+
readonly idempotency: "none";
|
|
34
|
+
readonly authorization: "required";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Configuration for the getDatasetDetails connector Step. */
|
|
38
|
+
interface GetDatasetDetailsStepConfig<StepInput, OperationInput = GetDatasetDetailsInput, OperationOutput = GetDatasetDetailsOutput> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
39
|
+
/** Named connection supplying this operation. */
|
|
40
|
+
connection: Connection<{
|
|
41
|
+
getDatasetDetails(): Query<OperationInput, OperationOutput>;
|
|
42
|
+
}>;
|
|
43
|
+
/** Name matching the bound connection. */
|
|
44
|
+
connectionName: string;
|
|
45
|
+
/** FastGPT returned the knowledge base metadata. */
|
|
46
|
+
found: StepTarget<QueryResult<OperationOutput>>;
|
|
47
|
+
/** FastGPT rejected access or the knowledge base ID. */
|
|
48
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
49
|
+
/** FastGPT returned malformed or oversized data. */
|
|
50
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
51
|
+
/** Local credentials or knowledge base ID are invalid. */
|
|
52
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
53
|
+
}
|
|
54
|
+
/** Build the getDatasetDetails Step from a named connection. */
|
|
55
|
+
declare function newGetDatasetDetailsStep<StepInput, OperationInput = GetDatasetDetailsInput, OperationOutput = GetDatasetDetailsOutput>(configuration: GetDatasetDetailsStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
56
|
+
|
|
57
|
+
/** Open one named FastGPT connection from Dex project configuration. */
|
|
58
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
59
|
+
|
|
60
|
+
/** Optional provider transport for local tests. */
|
|
61
|
+
interface FastGPTClientOptions {
|
|
62
|
+
/** Sender; omitted uses the SDK HTTP transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
63
|
+
}
|
|
64
|
+
/** Read FastGPT knowledge base metadata with per-call credentials. */
|
|
65
|
+
declare class FastGPTClient {
|
|
66
|
+
private readonly credentials;
|
|
67
|
+
private readonly baseURL;
|
|
68
|
+
private readonly timeoutMs;
|
|
69
|
+
private readonly maxResponseBytes;
|
|
70
|
+
private readonly send;
|
|
71
|
+
/** Validate settings without contacting FastGPT. */
|
|
72
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: FastGPTClientOptions);
|
|
73
|
+
/** Bind the knowledge base detail Query. */ getDatasetDetails(): GetDatasetDetailsOperation;
|
|
74
|
+
/** Send one bounded detail request. */
|
|
75
|
+
get(call: Call, id: string): Promise<{
|
|
76
|
+
response?: ProviderResponse;
|
|
77
|
+
error?: 'credential' | 'validation' | 'transport' | 'tooLarge';
|
|
78
|
+
retryAfterMs: number;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
/** Return one FastGPT knowledge base's metadata. */
|
|
82
|
+
declare class GetDatasetDetailsOperation implements Query<GetDatasetDetailsInput, GetDatasetDetailsOutput> {
|
|
83
|
+
private readonly client;
|
|
84
|
+
/** Bind the provider client. */ constructor(client: FastGPTClient);
|
|
85
|
+
/** Return the generated Query definition. */ definition(): QueryDefinition;
|
|
86
|
+
/** Classify one provider result using the Go contract. */
|
|
87
|
+
invoke(call: Call, input: GetDatasetDetailsInput): Promise<QueryAttempt<GetDatasetDetailsOutput>>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { Config, Connection, ConnectorID, Credentials, FastGPTClient, type FastGPTClientOptions, GetDatasetDetailsBranch, GetDatasetDetailsBranchDefect, GetDatasetDetailsBranchFound, GetDatasetDetailsBranchInvalidResponse, GetDatasetDetailsBranchProviderRejected, GetDatasetDetailsDefinition, GetDatasetDetailsInput, GetDatasetDetailsMetadata, GetDatasetDetailsOutput, type GetDatasetDetailsStepConfig, ProviderID, newGetDatasetDetailsStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
6
|
+
GetDatasetDetailsBranch,
|
|
7
|
+
GetDatasetDetailsBranchDefect,
|
|
8
|
+
GetDatasetDetailsBranchFound,
|
|
9
|
+
GetDatasetDetailsBranchInvalidResponse,
|
|
10
|
+
GetDatasetDetailsBranchProviderRejected,
|
|
11
|
+
GetDatasetDetailsDefinition,
|
|
12
|
+
GetDatasetDetailsInputSchema,
|
|
13
|
+
GetDatasetDetailsMetadata,
|
|
14
|
+
GetDatasetDetailsOutputSchema,
|
|
15
|
+
ProviderID,
|
|
16
|
+
decodeCredentials,
|
|
17
|
+
isCredentialMaterialError,
|
|
18
|
+
newConnection,
|
|
19
|
+
newConnectionWithOperations,
|
|
20
|
+
newProjectConnection
|
|
21
|
+
} from "./chunk-RZBY4SGC.js";
|
|
22
|
+
|
|
23
|
+
// src/generated/steps.ts
|
|
24
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
25
|
+
function newGetDatasetDetailsStep(configuration) {
|
|
26
|
+
const { connection, connectionName, found, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
27
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
28
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getDatasetDetails(), connection: connection.reference, branches: [
|
|
29
|
+
goToBranch("found", found),
|
|
30
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
31
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
32
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/client.ts
|
|
37
|
+
import {
|
|
38
|
+
SecretString,
|
|
39
|
+
newQueryBranch,
|
|
40
|
+
newQueryRetry
|
|
41
|
+
} from "@superdurable/connectors-sdk";
|
|
42
|
+
import {
|
|
43
|
+
BodyTooLargeError,
|
|
44
|
+
parseRetryAfter,
|
|
45
|
+
sendProviderRequest,
|
|
46
|
+
validateBaseURL
|
|
47
|
+
} from "@superdurable/connectors-sdk/providerhttp";
|
|
48
|
+
var FastGPTClient = class {
|
|
49
|
+
/** Validate settings without contacting FastGPT. */
|
|
50
|
+
constructor(config, credentials, options = {}) {
|
|
51
|
+
this.credentials = credentials;
|
|
52
|
+
if (!config || !credentials) throw new TypeError("FastGPT configuration and credentials are required");
|
|
53
|
+
this.baseURL = validateBaseURL(config.baseUrl || "https://cloud.fastgpt.cn");
|
|
54
|
+
this.timeoutMs = config.timeoutMs || 1e4;
|
|
55
|
+
this.maxResponseBytes = config.maxResponseBytes || 2097152;
|
|
56
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0)
|
|
57
|
+
throw new TypeError("FastGPT request limits must be positive integers");
|
|
58
|
+
this.send = options.send ?? sendProviderRequest;
|
|
59
|
+
}
|
|
60
|
+
credentials;
|
|
61
|
+
baseURL;
|
|
62
|
+
timeoutMs;
|
|
63
|
+
maxResponseBytes;
|
|
64
|
+
send;
|
|
65
|
+
/** Bind the knowledge base detail Query. */
|
|
66
|
+
getDatasetDetails() {
|
|
67
|
+
return new GetDatasetDetailsOperation(this);
|
|
68
|
+
}
|
|
69
|
+
/** Send one bounded detail request. */
|
|
70
|
+
async get(call, id) {
|
|
71
|
+
let apiKey = "";
|
|
72
|
+
try {
|
|
73
|
+
const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
74
|
+
apiKey = credentials.apiKey instanceof SecretString ? credentials.apiKey.reveal() : "";
|
|
75
|
+
} catch {
|
|
76
|
+
return { error: "credential", retryAfterMs: 0 };
|
|
77
|
+
}
|
|
78
|
+
if (!apiKey || apiKey.length > 512 || /[^\x21-\x7e]/.test(apiKey))
|
|
79
|
+
return { error: "credential", retryAfterMs: 0 };
|
|
80
|
+
if (typeof id !== "string" || !id || Buffer.byteLength(id) > 128 || /^\p{White_Space}|\p{White_Space}$/u.test(id) || /[/?#&]/.test(id))
|
|
81
|
+
return { error: "validation", retryAfterMs: 0 };
|
|
82
|
+
const request = {
|
|
83
|
+
url: `${this.baseURL}/api/core/dataset/detail?${new URLSearchParams({ id }).toString().replace(/\*/g, "%2A").replace(/%7E/g, "~")}`,
|
|
84
|
+
method: "GET",
|
|
85
|
+
headers: { Accept: "application/json", Authorization: `Bearer ${apiKey}` },
|
|
86
|
+
timeoutMs: this.timeoutMs,
|
|
87
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
88
|
+
addressPolicy: this.baseURL.startsWith("https://") ? "publicHTTPS" : "privateNetworkHTTP",
|
|
89
|
+
signal: call.context.cancellationSignal
|
|
90
|
+
};
|
|
91
|
+
let response;
|
|
92
|
+
try {
|
|
93
|
+
response = await this.send(request);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0)
|
|
96
|
+
return {
|
|
97
|
+
response: { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() },
|
|
98
|
+
error: "tooLarge",
|
|
99
|
+
retryAfterMs: parseRetryAfter(header(error.headers ?? {}, "retry-after"))
|
|
100
|
+
};
|
|
101
|
+
return { error: "transport", retryAfterMs: 0 };
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
response,
|
|
105
|
+
error: response.body.length > this.maxResponseBytes ? "tooLarge" : void 0,
|
|
106
|
+
retryAfterMs: parseRetryAfter(header(response.headers, "retry-after"))
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var GetDatasetDetailsOperation = class {
|
|
111
|
+
/** Bind the provider client. */
|
|
112
|
+
constructor(client) {
|
|
113
|
+
this.client = client;
|
|
114
|
+
}
|
|
115
|
+
client;
|
|
116
|
+
/** Return the generated Query definition. */
|
|
117
|
+
definition() {
|
|
118
|
+
return GetDatasetDetailsDefinition;
|
|
119
|
+
}
|
|
120
|
+
/** Classify one provider result using the Go contract. */
|
|
121
|
+
async invoke(call, input) {
|
|
122
|
+
const id = input?.id;
|
|
123
|
+
const exchange = await this.client.get(call, id);
|
|
124
|
+
if (exchange.error === "validation") return branch("defect", "VALIDATION");
|
|
125
|
+
if (exchange.error === "credential") return branch("defect", "AUTHENTICATION");
|
|
126
|
+
if (exchange.error === "transport" || !exchange.response) return retry("AVAILABILITY");
|
|
127
|
+
const { status, body } = exchange.response;
|
|
128
|
+
if (status === 429) return retry("RATE_LIMIT", exchange.retryAfterMs);
|
|
129
|
+
if (status === 408 || status >= 500) return retry("AVAILABILITY", exchange.retryAfterMs);
|
|
130
|
+
if (exchange.error === "tooLarge") return branch("invalidResponse", "RESPONSE_TOO_LARGE");
|
|
131
|
+
if (status !== 200)
|
|
132
|
+
return branch(
|
|
133
|
+
"providerRejected",
|
|
134
|
+
status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : "PROVIDER_REJECTION"
|
|
135
|
+
);
|
|
136
|
+
const wire = providerRecord(body);
|
|
137
|
+
if (!wire || typeof wire.code !== "bigint") return branch("invalidResponse", "PROTOCOL");
|
|
138
|
+
const detail = wire.data;
|
|
139
|
+
if (detail != null && (!isObject(detail) || ["_id", "name", "type", "status"].some((k) => detail[k] != null && typeof detail[k] !== "string")))
|
|
140
|
+
return branch("invalidResponse", "PROTOCOL");
|
|
141
|
+
if (wire.code === 429n) return retry("RATE_LIMIT", exchange.retryAfterMs);
|
|
142
|
+
if (wire.code >= 500n) return retry("AVAILABILITY", exchange.retryAfterMs);
|
|
143
|
+
if (wire.code !== 200n)
|
|
144
|
+
return branch(
|
|
145
|
+
"providerRejected",
|
|
146
|
+
wire.code === 401n ? "AUTHENTICATION" : wire.code === 403n ? "AUTHORIZATION" : "PROVIDER_REJECTION"
|
|
147
|
+
);
|
|
148
|
+
if (!isObject(detail) || detail._id !== id || !valid(detail.name, 512) || !valid(detail.type, 128) || !valid(detail.status, 128))
|
|
149
|
+
return branch("invalidResponse", "PROTOCOL");
|
|
150
|
+
return newQueryBranch("found", { id, name: detail.name, type: detail.type, status: detail.status });
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
function valid(value, max) {
|
|
154
|
+
return typeof value === "string" && value.length > 0 && Buffer.byteLength(value) <= max;
|
|
155
|
+
}
|
|
156
|
+
function isObject(value) {
|
|
157
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
158
|
+
}
|
|
159
|
+
function header(headers, name) {
|
|
160
|
+
const value = Object.entries(headers).find(([key]) => key.toLowerCase() === name)?.[1];
|
|
161
|
+
return Array.isArray(value) ? value[0] ?? "" : value ?? "";
|
|
162
|
+
}
|
|
163
|
+
function failure(kind) {
|
|
164
|
+
return {
|
|
165
|
+
provider: "fastgpt",
|
|
166
|
+
operation: "getDatasetDetails",
|
|
167
|
+
kind,
|
|
168
|
+
message: "FastGPT knowledge base query failed"
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function branch(name, kind) {
|
|
172
|
+
return newQueryBranch(name, { id: "", name: "", type: "", status: "" }, {}, failure(kind));
|
|
173
|
+
}
|
|
174
|
+
function retry(kind, delay = 0) {
|
|
175
|
+
return newQueryRetry(failure(kind), delay);
|
|
176
|
+
}
|
|
177
|
+
function providerRecord(body) {
|
|
178
|
+
try {
|
|
179
|
+
const wire = JSON.parse(
|
|
180
|
+
new TextDecoder().decode(body),
|
|
181
|
+
(_key, value, context) => {
|
|
182
|
+
if (typeof value === "number") {
|
|
183
|
+
const token = context?.source;
|
|
184
|
+
if (!token || token.length > 20 || !/^-?(?:0|[1-9][0-9]*)$/.test(token)) return value;
|
|
185
|
+
const integer = BigInt(token);
|
|
186
|
+
return integer >= -(1n << 63n) && integer < 1n << 63n ? integer : value;
|
|
187
|
+
}
|
|
188
|
+
if (isObject(value))
|
|
189
|
+
return Object.fromEntries(
|
|
190
|
+
Object.entries(value).map(([key, field]) => [key.toLowerCase().replace(/ſ/g, "s"), field])
|
|
191
|
+
);
|
|
192
|
+
return value;
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
return isObject(wire) ? wire : void 0;
|
|
196
|
+
} catch {
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/project.ts
|
|
202
|
+
function newProjectConnection2(project, connectionName) {
|
|
203
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
204
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "fastgpt" && entry.connectionName === name);
|
|
205
|
+
if (!selected) throw new TypeError("FastGPT project connection is not configured");
|
|
206
|
+
const fields = selected.configuration;
|
|
207
|
+
const config = ConfigSchema.parse({ ...fields, ...fields.timeout !== void 0 ? { timeoutMs: parseDurationMilliseconds(fields.timeout) } : {} });
|
|
208
|
+
const credentials = {
|
|
209
|
+
async resolve(_call, signal) {
|
|
210
|
+
return decodeCredentials(await loadedProject.resolveCredential("fastgpt", name, signal));
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
return new FastGPTClient(config, credentials);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function parseDurationMilliseconds(value) {
|
|
217
|
+
if (typeof value === "number") return Math.ceil(value / 1e6);
|
|
218
|
+
if (typeof value !== "string") throw new TypeError("timeout must be a duration");
|
|
219
|
+
let remaining = value;
|
|
220
|
+
let milliseconds = 0;
|
|
221
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
222
|
+
while (remaining) {
|
|
223
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
224
|
+
if (!part) throw new TypeError("timeout must be a positive Go duration");
|
|
225
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
226
|
+
remaining = remaining.slice(part[0].length);
|
|
227
|
+
}
|
|
228
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("timeout must resolve to positive whole milliseconds");
|
|
229
|
+
return milliseconds;
|
|
230
|
+
}
|
|
231
|
+
export {
|
|
232
|
+
ConfigSchema,
|
|
233
|
+
Connection,
|
|
234
|
+
ConnectorID,
|
|
235
|
+
CredentialMaterialError,
|
|
236
|
+
FastGPTClient,
|
|
237
|
+
GetDatasetDetailsBranch,
|
|
238
|
+
GetDatasetDetailsBranchDefect,
|
|
239
|
+
GetDatasetDetailsBranchFound,
|
|
240
|
+
GetDatasetDetailsBranchInvalidResponse,
|
|
241
|
+
GetDatasetDetailsBranchProviderRejected,
|
|
242
|
+
GetDatasetDetailsDefinition,
|
|
243
|
+
GetDatasetDetailsInputSchema,
|
|
244
|
+
GetDatasetDetailsMetadata,
|
|
245
|
+
GetDatasetDetailsOutputSchema,
|
|
246
|
+
ProviderID,
|
|
247
|
+
decodeCredentials,
|
|
248
|
+
isCredentialMaterialError,
|
|
249
|
+
newConnection,
|
|
250
|
+
newConnectionWithOperations,
|
|
251
|
+
newGetDatasetDetailsStep,
|
|
252
|
+
newProjectConnection2 as newProjectConnection
|
|
253
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, C as Connection, G as GetDatasetDetailsInput, a as GetDatasetDetailsOutput } from './connection-D5kKKQzT.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for GetDatasetDetailsInput in scripted cases. */
|
|
7
|
+
declare const emptyGetDatasetDetailsInput: GetDatasetDetailsInput;
|
|
8
|
+
/** Go zero value for GetDatasetDetailsOutput in scripted cases. */
|
|
9
|
+
declare const emptyGetDatasetDetailsOutput: GetDatasetDetailsOutput;
|
|
10
|
+
/** Script the found branch. */
|
|
11
|
+
declare function getDatasetDetailsFound(value: GetDatasetDetailsOutput, failure?: Failure): Case<GetDatasetDetailsOutput>;
|
|
12
|
+
/** Script the providerRejected branch. */
|
|
13
|
+
declare function getDatasetDetailsProviderRejected(value: GetDatasetDetailsOutput, failure?: Failure): Case<GetDatasetDetailsOutput>;
|
|
14
|
+
/** Script the invalidResponse branch. */
|
|
15
|
+
declare function getDatasetDetailsInvalidResponse(value: GetDatasetDetailsOutput, failure?: Failure): Case<GetDatasetDetailsOutput>;
|
|
16
|
+
/** Script the defect branch. */
|
|
17
|
+
declare function getDatasetDetailsDefect(value: GetDatasetDetailsOutput, failure?: Failure): Case<GetDatasetDetailsOutput>;
|
|
18
|
+
/** Script a safe retry of getDatasetDetails. */
|
|
19
|
+
declare function getDatasetDetailsRetry(failure: Failure, retryAfterMs?: number): Case<GetDatasetDetailsOutput>;
|
|
20
|
+
/** Manifest scenario sampleDataset for getDatasetDetails. */
|
|
21
|
+
declare function getDatasetDetailsSampleDataset(): Case<GetDatasetDetailsOutput>;
|
|
22
|
+
/** Default getDatasetDetails scenario. */
|
|
23
|
+
declare function getDatasetDetailsDefault(): Case<GetDatasetDetailsOutput>;
|
|
24
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
25
|
+
declare class GeneratedMock implements Operations {
|
|
26
|
+
#private;
|
|
27
|
+
constructor(connectionName: string);
|
|
28
|
+
connection(): Connection;
|
|
29
|
+
getDatasetDetails(): MockQuery<GetDatasetDetailsInput, GetDatasetDetailsOutput>;
|
|
30
|
+
assertNoFailures(): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { GeneratedMock, emptyGetDatasetDetailsInput, emptyGetDatasetDetailsOutput, getDatasetDetailsDefault, getDatasetDetailsDefect, getDatasetDetailsFound, getDatasetDetailsInvalidResponse, getDatasetDetailsProviderRejected, getDatasetDetailsRetry, getDatasetDetailsSampleDataset };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GetDatasetDetailsDefinition,
|
|
3
|
+
GetDatasetDetailsInputSchema,
|
|
4
|
+
GetDatasetDetailsOutputSchema,
|
|
5
|
+
ProviderID,
|
|
6
|
+
newConnectionWithOperations
|
|
7
|
+
} from "./chunk-RZBY4SGC.js";
|
|
8
|
+
|
|
9
|
+
// src/generated/mock.ts
|
|
10
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
11
|
+
var emptyGetDatasetDetailsInput = GetDatasetDetailsInputSchema.parse({
|
|
12
|
+
"id": ""
|
|
13
|
+
});
|
|
14
|
+
var emptyGetDatasetDetailsOutput = GetDatasetDetailsOutputSchema.parse({
|
|
15
|
+
"id": "",
|
|
16
|
+
"name": "",
|
|
17
|
+
"type": "",
|
|
18
|
+
"status": ""
|
|
19
|
+
});
|
|
20
|
+
function getDatasetDetailsFound(value, failure) {
|
|
21
|
+
return branchCase("found", value, failure);
|
|
22
|
+
}
|
|
23
|
+
function getDatasetDetailsProviderRejected(value, failure) {
|
|
24
|
+
return branchCase("providerRejected", value, failure);
|
|
25
|
+
}
|
|
26
|
+
function getDatasetDetailsInvalidResponse(value, failure) {
|
|
27
|
+
return branchCase("invalidResponse", value, failure);
|
|
28
|
+
}
|
|
29
|
+
function getDatasetDetailsDefect(value, failure) {
|
|
30
|
+
return branchCase("defect", value, failure);
|
|
31
|
+
}
|
|
32
|
+
function getDatasetDetailsRetry(failure, retryAfterMs = 0) {
|
|
33
|
+
return retryCase(failure, retryAfterMs);
|
|
34
|
+
}
|
|
35
|
+
function getDatasetDetailsSampleDataset() {
|
|
36
|
+
const value = GetDatasetDetailsOutputSchema.parse({ "id": "65abc9bd9d1448617cba5e6c", "name": "Example Knowledge Base", "status": "active", "type": "dataset" });
|
|
37
|
+
return branchCase("found", value);
|
|
38
|
+
}
|
|
39
|
+
function getDatasetDetailsDefault() {
|
|
40
|
+
return getDatasetDetailsSampleDataset();
|
|
41
|
+
}
|
|
42
|
+
var GeneratedMock = class {
|
|
43
|
+
#getDatasetDetails;
|
|
44
|
+
#connection;
|
|
45
|
+
constructor(connectionName) {
|
|
46
|
+
this.#getDatasetDetails = newQuery(GetDatasetDetailsDefinition).default(getDatasetDetailsDefault());
|
|
47
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
48
|
+
}
|
|
49
|
+
connection() {
|
|
50
|
+
return this.#connection;
|
|
51
|
+
}
|
|
52
|
+
getDatasetDetails() {
|
|
53
|
+
return this.#getDatasetDetails;
|
|
54
|
+
}
|
|
55
|
+
assertNoFailures() {
|
|
56
|
+
this.#getDatasetDetails.assertNoFailures();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
GeneratedMock,
|
|
61
|
+
emptyGetDatasetDetailsInput,
|
|
62
|
+
emptyGetDatasetDetailsOutput,
|
|
63
|
+
getDatasetDetailsDefault,
|
|
64
|
+
getDatasetDetailsDefect,
|
|
65
|
+
getDatasetDetailsFound,
|
|
66
|
+
getDatasetDetailsInvalidResponse,
|
|
67
|
+
getDatasetDetailsProviderRejected,
|
|
68
|
+
getDatasetDetailsRetry,
|
|
69
|
+
getDatasetDetailsSampleDataset
|
|
70
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-fastgpt",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "fastgpt connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/fastgpt/typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
14
|
+
},
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./mock": {
|
|
23
|
+
"types": "./dist/mock.d.ts",
|
|
24
|
+
"import": "./dist/mock.js"
|
|
25
|
+
},
|
|
26
|
+
"./dex-connector.json": "./dex-connector.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"dex-connector.json"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"prepack": "npm run build",
|
|
36
|
+
"build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"lint": "eslint src test examples",
|
|
39
|
+
"test": "vitest run --exclude test/integration/**",
|
|
40
|
+
"test:integration": "vitest run test/integration/*.integration.test.ts",
|
|
41
|
+
"example:worker": "tsx examples/basic/worker.ts",
|
|
42
|
+
"example:start": "tsx examples/basic/start.ts",
|
|
43
|
+
"check": "npm run typecheck && npm run lint && npm test && npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@superdurable/connectors-sdk": "0.1.1",
|
|
47
|
+
"@superdurable/dex": ">=1.28.0",
|
|
48
|
+
"zod": "^4.1.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@eslint/js": "^9.0.0",
|
|
52
|
+
"@types/node": "^22.0.0",
|
|
53
|
+
"eslint": "^9.0.0",
|
|
54
|
+
"tsup": "^8.0.0",
|
|
55
|
+
"tsx": "^4.23.15",
|
|
56
|
+
"typescript": "^5.9.0",
|
|
57
|
+
"typescript-eslint": "^8.0.0",
|
|
58
|
+
"vitest": "^3.0.0",
|
|
59
|
+
"yaml": "^2.9.1"
|
|
60
|
+
}
|
|
61
|
+
}
|