@superdurable/connector-apifox 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 +15 -2
- package/dex-connector.json +60 -0
- package/dist/chunk-7EOB2Y6V.js +117 -0
- package/dist/connection-DHKKRFFZ.d.ts +75 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +232 -0
- package/dist/mock.d.ts +35 -0
- package/dist/mock.js +75 -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,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Apifox TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@superdurable/connector-apifox` implements the read-only `getProjectAPISummary`
|
|
4
|
+
operation. It exports an accessible project's OpenAPI 3.1 document and returns
|
|
5
|
+
only the title, version, and HTTP endpoint count. The full document and access
|
|
6
|
+
token do not enter Dex Flow state.
|
|
7
|
+
|
|
8
|
+
[Apifox's export API](https://apifox-openapi.apifox.cn/api-173411997) documents
|
|
9
|
+
the endpoint, request body, and API version header. Create a personal access
|
|
10
|
+
token through [account settings](https://docs.apifox.com/api-access-token),
|
|
11
|
+
then configure the `apifox` connection in Dex Web Connections. Find the decimal
|
|
12
|
+
project ID in the target project's basic settings.
|
|
13
|
+
|
|
14
|
+
The [runnable project-summary Flow](examples/project-summary/) contains Worker
|
|
15
|
+
and Client entrypoints. Its integration test uses a fake provider and real Dex
|
|
16
|
+
Worker/Client. Real Apifox authorization and export responses remain unverified.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "apifox",
|
|
3
|
+
"releaseTag": "connectors/apifox/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-apifox",
|
|
7
|
+
"version": "0.1.1"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newGetProjectAPISummaryStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "getProjectAPISummary",
|
|
14
|
+
"inputType": "GetProjectAPISummaryInput",
|
|
15
|
+
"description": "Read only a summary of one accessible project's OpenAPI document.",
|
|
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": "GetProjectAPISummaryInput identifies one Apifox project by positive decimal ID.",
|
|
47
|
+
"properties": {
|
|
48
|
+
"projectID": {
|
|
49
|
+
"description": "ProjectID is the decimal ID shown in Apifox Project Settings.",
|
|
50
|
+
"type": "string"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": [
|
|
54
|
+
"projectID"
|
|
55
|
+
],
|
|
56
|
+
"type": "object"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var ConfigSchema = z.object({
|
|
5
|
+
"timeoutMs": z.number().int().optional(),
|
|
6
|
+
"maxResponseBytes": z.number().int().optional()
|
|
7
|
+
});
|
|
8
|
+
var CredentialMaterialError = class extends TypeError {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "CredentialMaterialError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
15
|
+
"project credential decoding failed",
|
|
16
|
+
"shared project credential decoding failed",
|
|
17
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
18
|
+
]);
|
|
19
|
+
function isCredentialMaterialError(error) {
|
|
20
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
21
|
+
}
|
|
22
|
+
function decodeCredentials(value) {
|
|
23
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
24
|
+
const fields = value;
|
|
25
|
+
const allowed = /* @__PURE__ */ new Set(["accessToken"]);
|
|
26
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
27
|
+
if (fields["accessToken"] != null && !(typeof fields["accessToken"] === "string")) throw new CredentialMaterialError("credential accessToken has an invalid type");
|
|
28
|
+
const credentials = {};
|
|
29
|
+
if (!fields["accessToken"]) throw new CredentialMaterialError("credential accessToken is required");
|
|
30
|
+
credentials.accessToken = new SecretString(fields["accessToken"] ?? "");
|
|
31
|
+
return credentials;
|
|
32
|
+
}
|
|
33
|
+
var GetProjectAPISummaryInputSchema = z.strictObject({
|
|
34
|
+
"projectID": z.string()
|
|
35
|
+
});
|
|
36
|
+
var GetProjectAPISummaryOutputSchema = z.strictObject({
|
|
37
|
+
"title": z.string(),
|
|
38
|
+
"version": z.string(),
|
|
39
|
+
"endpointCount": z.number().int()
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// src/generated/definitions.ts
|
|
43
|
+
var ConnectorID = "apifox";
|
|
44
|
+
var ProviderID = "apifox";
|
|
45
|
+
var GetProjectAPISummaryBranch = {
|
|
46
|
+
Found: "found",
|
|
47
|
+
ProviderRejected: "providerRejected",
|
|
48
|
+
InvalidResponse: "invalidResponse",
|
|
49
|
+
Defect: "defect"
|
|
50
|
+
};
|
|
51
|
+
var GetProjectAPISummaryBranchFound = GetProjectAPISummaryBranch.Found;
|
|
52
|
+
var GetProjectAPISummaryBranchProviderRejected = GetProjectAPISummaryBranch.ProviderRejected;
|
|
53
|
+
var GetProjectAPISummaryBranchInvalidResponse = GetProjectAPISummaryBranch.InvalidResponse;
|
|
54
|
+
var GetProjectAPISummaryBranchDefect = GetProjectAPISummaryBranch.Defect;
|
|
55
|
+
var GetProjectAPISummaryDefinition = {
|
|
56
|
+
operation: { connectorId: ConnectorID, operationId: "getProjectAPISummary" },
|
|
57
|
+
branches: [
|
|
58
|
+
{ id: "found", description: "Apifox exported the project definition." },
|
|
59
|
+
{ id: "providerRejected", description: "Apifox rejected the token, project, version, or permission.", optional: true },
|
|
60
|
+
{ id: "invalidResponse", description: "Apifox returned malformed or oversized OpenAPI data.", optional: true },
|
|
61
|
+
{ id: "defect", description: "The local token or project ID is invalid.", optional: true }
|
|
62
|
+
],
|
|
63
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
64
|
+
};
|
|
65
|
+
var GetProjectAPISummaryMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
66
|
+
|
|
67
|
+
// src/generated/connection.ts
|
|
68
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
69
|
+
var Connection = class {
|
|
70
|
+
/** Stable provider and connection name. */
|
|
71
|
+
reference;
|
|
72
|
+
/** Bound provider operations. */
|
|
73
|
+
operations;
|
|
74
|
+
/** Validate a reference and bind operations. */
|
|
75
|
+
constructor(reference, operations) {
|
|
76
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
77
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
78
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
79
|
+
this.operations = operations;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
function newConnection(client, reference) {
|
|
83
|
+
if (!client) throw new TypeError("connector client is required");
|
|
84
|
+
return new Connection(reference, client);
|
|
85
|
+
}
|
|
86
|
+
function newConnectionWithOperations(operations, reference) {
|
|
87
|
+
return new Connection(reference, operations);
|
|
88
|
+
}
|
|
89
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
90
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
91
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
92
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
93
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
94
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
ConfigSchema,
|
|
99
|
+
CredentialMaterialError,
|
|
100
|
+
isCredentialMaterialError,
|
|
101
|
+
decodeCredentials,
|
|
102
|
+
GetProjectAPISummaryInputSchema,
|
|
103
|
+
GetProjectAPISummaryOutputSchema,
|
|
104
|
+
ConnectorID,
|
|
105
|
+
ProviderID,
|
|
106
|
+
GetProjectAPISummaryBranch,
|
|
107
|
+
GetProjectAPISummaryBranchFound,
|
|
108
|
+
GetProjectAPISummaryBranchProviderRejected,
|
|
109
|
+
GetProjectAPISummaryBranchInvalidResponse,
|
|
110
|
+
GetProjectAPISummaryBranchDefect,
|
|
111
|
+
GetProjectAPISummaryDefinition,
|
|
112
|
+
GetProjectAPISummaryMetadata,
|
|
113
|
+
Connection,
|
|
114
|
+
newConnection,
|
|
115
|
+
newConnectionWithOperations,
|
|
116
|
+
newProjectConnection
|
|
117
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { SecretString, CredentialProvider, Query, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** Maximum duration of one project export request as a positive Go duration such as 5s or 1m. Blank uses the displayed default; increase only for large approved projects. Runtime value in milliseconds. */
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
/** Maximum exported OpenAPI response size in bytes as a positive integer. Blank uses the displayed default; increase only for a verified larger project, up to 16 MiB. */
|
|
9
|
+
maxResponseBytes?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Runtime schema for manifest configuration. */
|
|
12
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
13
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
/** Private connector credentials resolved by the host. */
|
|
17
|
+
interface Credentials {
|
|
18
|
+
/** Secret Apifox personal API access token from https://app.apifox.com > avatar > 账号设置 > API 访问令牌. Copy it when created; blank prevents requests. */
|
|
19
|
+
accessToken: SecretString;
|
|
20
|
+
}
|
|
21
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
22
|
+
declare class CredentialMaterialError extends TypeError {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
26
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
27
|
+
/** Decode private credential fields for the connector. */
|
|
28
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
29
|
+
/** Host-owned source of private connector credentials. */
|
|
30
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
31
|
+
/** GetProjectAPISummaryInput identifies one Apifox project by positive decimal ID. */
|
|
32
|
+
interface GetProjectAPISummaryInput {
|
|
33
|
+
/** ProjectID is the decimal ID shown in Apifox Project Settings. */
|
|
34
|
+
"projectID": string;
|
|
35
|
+
}
|
|
36
|
+
/** GetProjectAPISummaryOutput excludes the exported API document and endpoint details. */
|
|
37
|
+
interface GetProjectAPISummaryOutput {
|
|
38
|
+
/** Title is the exported OpenAPI info title. */
|
|
39
|
+
"title": string;
|
|
40
|
+
/** Version is the exported OpenAPI info version. */
|
|
41
|
+
"version": string;
|
|
42
|
+
/** EndpointCount counts HTTP methods across the exported paths. */
|
|
43
|
+
"endpointCount": number;
|
|
44
|
+
}
|
|
45
|
+
/** Runtime validator for GetProjectAPISummaryInput. */
|
|
46
|
+
declare const GetProjectAPISummaryInputSchema: z.ZodObject<{
|
|
47
|
+
projectID: z.ZodString;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
/** Runtime validator for GetProjectAPISummaryOutput. */
|
|
50
|
+
declare const GetProjectAPISummaryOutputSchema: z.ZodObject<{
|
|
51
|
+
title: z.ZodString;
|
|
52
|
+
version: z.ZodString;
|
|
53
|
+
endpointCount: z.ZodNumber;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
|
|
56
|
+
/** Typed operations supplied by a client or mock. */
|
|
57
|
+
interface Operations {
|
|
58
|
+
/** Invoke getProjectAPISummary through this connection. */
|
|
59
|
+
getProjectAPISummary(): Query<GetProjectAPISummaryInput, GetProjectAPISummaryOutput>;
|
|
60
|
+
}
|
|
61
|
+
/** Named connector connection kept outside Flow state. */
|
|
62
|
+
declare class Connection<BoundOperations = Operations> {
|
|
63
|
+
/** Stable provider and connection name. */
|
|
64
|
+
readonly reference: ConnectionRef;
|
|
65
|
+
/** Bound provider operations. */
|
|
66
|
+
readonly operations: BoundOperations;
|
|
67
|
+
/** Validate a reference and bind operations. */
|
|
68
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
69
|
+
}
|
|
70
|
+
/** Bind a client to a named connection. */
|
|
71
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
72
|
+
/** Bind scripted operations to a named connection. */
|
|
73
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
74
|
+
|
|
75
|
+
export { Connection as C, type GetProjectAPISummaryInput as G, type Operations as O, type GetProjectAPISummaryOutput as a, type Credentials as b, type Config as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, GetProjectAPISummaryInputSchema as g, GetProjectAPISummaryOutputSchema as h, decodeCredentials as i, isCredentialMaterialError as j, newConnectionWithOperations as k, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { G as GetProjectAPISummaryInput, a as GetProjectAPISummaryOutput, C as Connection, O as Operations, b as Credentials, c as Config } from './connection-DHKKRFFZ.js';
|
|
2
|
+
export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as GetProjectAPISummaryInputSchema, h as GetProjectAPISummaryOutputSchema, i as decodeCredentials, j as isCredentialMaterialError, n as newConnection, k as newConnectionWithOperations } from './connection-DHKKRFFZ.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 = "apifox";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "apifox";
|
|
13
|
+
/** Branch IDs for getProjectAPISummary. */
|
|
14
|
+
declare const GetProjectAPISummaryBranch: {
|
|
15
|
+
readonly Found: "found";
|
|
16
|
+
readonly ProviderRejected: "providerRejected";
|
|
17
|
+
readonly InvalidResponse: "invalidResponse";
|
|
18
|
+
readonly Defect: "defect";
|
|
19
|
+
};
|
|
20
|
+
/** Apifox exported the project definition. */
|
|
21
|
+
declare const GetProjectAPISummaryBranchFound: "found";
|
|
22
|
+
/** Apifox rejected the token, project, version, or permission. */
|
|
23
|
+
declare const GetProjectAPISummaryBranchProviderRejected: "providerRejected";
|
|
24
|
+
/** Apifox returned malformed or oversized OpenAPI data. */
|
|
25
|
+
declare const GetProjectAPISummaryBranchInvalidResponse: "invalidResponse";
|
|
26
|
+
/** The local token or project ID is invalid. */
|
|
27
|
+
declare const GetProjectAPISummaryBranchDefect: "defect";
|
|
28
|
+
/** Manifest definition for getProjectAPISummary. */
|
|
29
|
+
declare const GetProjectAPISummaryDefinition: QueryDefinition;
|
|
30
|
+
/** Manifest metadata for getProjectAPISummary. */
|
|
31
|
+
declare const GetProjectAPISummaryMetadata: {
|
|
32
|
+
readonly kind: "query";
|
|
33
|
+
readonly idempotency: "none";
|
|
34
|
+
readonly authorization: "required";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Configuration for the getProjectAPISummary connector Step. */
|
|
38
|
+
interface GetProjectAPISummaryStepConfig<StepInput, OperationInput = GetProjectAPISummaryInput, OperationOutput = GetProjectAPISummaryOutput> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
39
|
+
/** Named connection supplying this operation. */
|
|
40
|
+
connection: Connection<{
|
|
41
|
+
getProjectAPISummary(): Query<OperationInput, OperationOutput>;
|
|
42
|
+
}>;
|
|
43
|
+
/** Name matching the bound connection. */
|
|
44
|
+
connectionName: string;
|
|
45
|
+
/** Apifox exported the project definition. */
|
|
46
|
+
found: StepTarget<QueryResult<OperationOutput>>;
|
|
47
|
+
/** Apifox rejected the token, project, version, or permission. */
|
|
48
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
49
|
+
/** Apifox returned malformed or oversized OpenAPI data. */
|
|
50
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
51
|
+
/** The local token or project ID is invalid. */
|
|
52
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
53
|
+
}
|
|
54
|
+
/** Build the getProjectAPISummary Step from a named connection. */
|
|
55
|
+
declare function newGetProjectAPISummaryStep<StepInput, OperationInput = GetProjectAPISummaryInput, OperationOutput = GetProjectAPISummaryOutput>(configuration: GetProjectAPISummaryStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
56
|
+
|
|
57
|
+
/** Open one named Apifox connection from Dex project configuration. */
|
|
58
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
59
|
+
|
|
60
|
+
/** Send one Apifox provider request through a caller-owned transport. */
|
|
61
|
+
type ApifoxRequestSender = (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
62
|
+
/** Optional transport dependency for provider tests and approved proxies. */
|
|
63
|
+
interface ApifoxClientOptions {
|
|
64
|
+
/** Request sender; production uses the Connector SDK's bounded HTTP transport. */
|
|
65
|
+
send?: ApifoxRequestSender;
|
|
66
|
+
}
|
|
67
|
+
/** Resolve Apifox credentials for each read-only project export. */
|
|
68
|
+
declare class ApifoxClient {
|
|
69
|
+
readonly credentials: CredentialProvider<Credentials>;
|
|
70
|
+
readonly maxResponseBytes: number;
|
|
71
|
+
readonly timeoutMs: number;
|
|
72
|
+
readonly send: ApifoxRequestSender;
|
|
73
|
+
/** Validate settings without contacting Apifox. */
|
|
74
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: ApifoxClientOptions);
|
|
75
|
+
/** Bind the project-summary Query to this client. */
|
|
76
|
+
getProjectAPISummary(): GetProjectAPISummaryOperation;
|
|
77
|
+
}
|
|
78
|
+
/** Read an accessible OpenAPI export while retaining only a bounded summary. */
|
|
79
|
+
declare class GetProjectAPISummaryOperation implements Query<GetProjectAPISummaryInput, GetProjectAPISummaryOutput> {
|
|
80
|
+
readonly client: ApifoxClient;
|
|
81
|
+
constructor(client: ApifoxClient);
|
|
82
|
+
/** Return the generated Query identity and retry policy. */
|
|
83
|
+
definition(): QueryDefinition;
|
|
84
|
+
/** Make one provider request and classify its observed result. */
|
|
85
|
+
invoke(call: Call, input: GetProjectAPISummaryInput): Promise<QueryAttempt<GetProjectAPISummaryOutput>>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { ApifoxClient, type ApifoxClientOptions, type ApifoxRequestSender, Config, Connection, ConnectorID, Credentials, GetProjectAPISummaryBranch, GetProjectAPISummaryBranchDefect, GetProjectAPISummaryBranchFound, GetProjectAPISummaryBranchInvalidResponse, GetProjectAPISummaryBranchProviderRejected, GetProjectAPISummaryDefinition, GetProjectAPISummaryInput, GetProjectAPISummaryMetadata, GetProjectAPISummaryOperation, GetProjectAPISummaryOutput, type GetProjectAPISummaryStepConfig, ProviderID, newGetProjectAPISummaryStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
6
|
+
GetProjectAPISummaryBranch,
|
|
7
|
+
GetProjectAPISummaryBranchDefect,
|
|
8
|
+
GetProjectAPISummaryBranchFound,
|
|
9
|
+
GetProjectAPISummaryBranchInvalidResponse,
|
|
10
|
+
GetProjectAPISummaryBranchProviderRejected,
|
|
11
|
+
GetProjectAPISummaryDefinition,
|
|
12
|
+
GetProjectAPISummaryInputSchema,
|
|
13
|
+
GetProjectAPISummaryMetadata,
|
|
14
|
+
GetProjectAPISummaryOutputSchema,
|
|
15
|
+
ProviderID,
|
|
16
|
+
decodeCredentials,
|
|
17
|
+
isCredentialMaterialError,
|
|
18
|
+
newConnection,
|
|
19
|
+
newConnectionWithOperations,
|
|
20
|
+
newProjectConnection
|
|
21
|
+
} from "./chunk-7EOB2Y6V.js";
|
|
22
|
+
|
|
23
|
+
// src/generated/steps.ts
|
|
24
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
25
|
+
function newGetProjectAPISummaryStep(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.getProjectAPISummary(), 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/project.ts
|
|
37
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
38
|
+
import { z } from "zod";
|
|
39
|
+
|
|
40
|
+
// src/client.ts
|
|
41
|
+
import { newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
42
|
+
import { BodyTooLargeError, ProviderStalledError, ProviderTransportError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest } from "@superdurable/connectors-sdk/providerhttp";
|
|
43
|
+
var endpointRoot = "https://api.apifox.com/v1/projects/";
|
|
44
|
+
var exportBody = Buffer.from('{"scope":{"type":"ALL"},"oasVersion":"3.1","exportFormat":"JSON"}', "utf8");
|
|
45
|
+
var httpMethods = /* @__PURE__ */ new Set(["get", "post", "put", "patch", "delete", "head", "options", "trace"]);
|
|
46
|
+
var emptyOutput = { title: "", version: "", endpointCount: 0 };
|
|
47
|
+
var ApifoxClient = class {
|
|
48
|
+
/** Validate settings without contacting Apifox. */
|
|
49
|
+
constructor(config, credentials, options = {}) {
|
|
50
|
+
this.credentials = credentials;
|
|
51
|
+
if (!credentials) throw new TypeError("Apifox credential source is required");
|
|
52
|
+
this.timeoutMs = config.timeoutMs ?? 2e4;
|
|
53
|
+
this.maxResponseBytes = config.maxResponseBytes ?? 1048576;
|
|
54
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0 || this.maxResponseBytes > 16 * 1024 * 1024) {
|
|
55
|
+
throw new TypeError("Apifox configuration is invalid");
|
|
56
|
+
}
|
|
57
|
+
this.send = options.send ?? sendProviderRequest;
|
|
58
|
+
}
|
|
59
|
+
credentials;
|
|
60
|
+
maxResponseBytes;
|
|
61
|
+
timeoutMs;
|
|
62
|
+
send;
|
|
63
|
+
/** Bind the project-summary Query to this client. */
|
|
64
|
+
getProjectAPISummary() {
|
|
65
|
+
return new GetProjectAPISummaryOperation(this);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var GetProjectAPISummaryOperation = class {
|
|
69
|
+
constructor(client) {
|
|
70
|
+
this.client = client;
|
|
71
|
+
if (!client) throw new TypeError("Apifox client is required");
|
|
72
|
+
}
|
|
73
|
+
client;
|
|
74
|
+
/** Return the generated Query identity and retry policy. */
|
|
75
|
+
definition() {
|
|
76
|
+
return GetProjectAPISummaryDefinition;
|
|
77
|
+
}
|
|
78
|
+
/** Make one provider request and classify its observed result. */
|
|
79
|
+
async invoke(call, input) {
|
|
80
|
+
if (!isValidProjectID(input?.projectID)) return branch("defect", "VALIDATION", "Apifox project ID must be a positive decimal string");
|
|
81
|
+
let token;
|
|
82
|
+
try {
|
|
83
|
+
const credentials = await this.client.credentials.resolve(call, call.context.cancellationSignal);
|
|
84
|
+
token = credentials.accessToken.reveal();
|
|
85
|
+
if (!isValidAccessToken(token)) throw new TypeError("invalid Apifox token");
|
|
86
|
+
} catch {
|
|
87
|
+
return branch("defect", "AUTHENTICATION", "Apifox access token is unavailable or invalid");
|
|
88
|
+
}
|
|
89
|
+
const request = {
|
|
90
|
+
url: `${endpointRoot}${input.projectID}/export-openapi`,
|
|
91
|
+
method: "POST",
|
|
92
|
+
headers: {
|
|
93
|
+
Authorization: `Bearer ${token}`,
|
|
94
|
+
"X-Apifox-Api-Version": "2024-03-28",
|
|
95
|
+
"Content-Type": "application/json",
|
|
96
|
+
Accept: "application/json"
|
|
97
|
+
},
|
|
98
|
+
body: exportBody,
|
|
99
|
+
maxResponseBytes: this.client.maxResponseBytes,
|
|
100
|
+
maxErrorResponseBytes: 4096,
|
|
101
|
+
timeoutMs: this.client.timeoutMs,
|
|
102
|
+
addressPolicy: "publicHTTPS",
|
|
103
|
+
signal: call.context.cancellationSignal
|
|
104
|
+
};
|
|
105
|
+
let response;
|
|
106
|
+
try {
|
|
107
|
+
response = await this.client.send(request);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (error instanceof BodyTooLargeError || error instanceof ProviderTransportError || error instanceof ProviderStalledError) {
|
|
110
|
+
const status = error.status;
|
|
111
|
+
const retryAfterMs2 = headerRetryAfter(error.headers);
|
|
112
|
+
if (status === 429) return retry("RATE_LIMIT", "Apifox rate limited the project request", retryAfterMs2);
|
|
113
|
+
if (status === 408 || status !== void 0 && status >= 500) return retry("AVAILABILITY", "Apifox project export is temporarily unavailable", retryAfterMs2);
|
|
114
|
+
if (status !== void 0 && status !== 200) return classifyHTTPStatus(status);
|
|
115
|
+
if (error instanceof BodyTooLargeError) return branch("invalidResponse", "RESPONSE_TOO_LARGE", "Apifox export exceeded the configured limit");
|
|
116
|
+
return retry("AVAILABILITY", "Apifox export was interrupted");
|
|
117
|
+
}
|
|
118
|
+
return retry("AVAILABILITY", "Apifox project request failed");
|
|
119
|
+
}
|
|
120
|
+
const retryAfterMs = headerRetryAfter(response.headers);
|
|
121
|
+
if (response.status === 429) return retry("RATE_LIMIT", "Apifox rate limited the project request", retryAfterMs);
|
|
122
|
+
if (response.status === 408 || response.status >= 500) return retry("AVAILABILITY", "Apifox project export is temporarily unavailable", retryAfterMs);
|
|
123
|
+
if (response.status !== 200) return classifyHTTPStatus(response.status);
|
|
124
|
+
let document;
|
|
125
|
+
try {
|
|
126
|
+
document = JSON.parse(Buffer.from(response.body).toString("utf8"));
|
|
127
|
+
} catch {
|
|
128
|
+
return branch("invalidResponse", "PROTOCOL", "Apifox returned invalid OpenAPI data");
|
|
129
|
+
}
|
|
130
|
+
const summary = decodeProjectSummary(document, token);
|
|
131
|
+
if (!summary) return branch("invalidResponse", "PROTOCOL", "Apifox returned invalid OpenAPI data");
|
|
132
|
+
return newQueryBranch("found", summary);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
function headerRetryAfter(headers) {
|
|
136
|
+
const header = headers?.["retry-after"];
|
|
137
|
+
return parseRetryAfter(Array.isArray(header) ? header[0] ?? "" : header ?? "");
|
|
138
|
+
}
|
|
139
|
+
function isRecord(value) {
|
|
140
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
141
|
+
}
|
|
142
|
+
function isValidProjectID(value) {
|
|
143
|
+
return typeof value === "string" && /^[1-9][0-9]{0,19}$/.test(value);
|
|
144
|
+
}
|
|
145
|
+
function isValidAccessToken(value) {
|
|
146
|
+
return typeof value === "string" && value.length <= 1024 && isHeaderSafeCredential(value);
|
|
147
|
+
}
|
|
148
|
+
function classifyHTTPStatus(status) {
|
|
149
|
+
const kind = status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : "PROVIDER_REJECTION";
|
|
150
|
+
return branch("providerRejected", kind, `Apifox rejected project export with HTTP ${status}`);
|
|
151
|
+
}
|
|
152
|
+
function decodeProjectSummary(value, token) {
|
|
153
|
+
if (!isRecord(value)) return void 0;
|
|
154
|
+
const document = Object.fromEntries(Object.entries(value).map(([key, field]) => [key.toLowerCase(), field]));
|
|
155
|
+
if (typeof document.openapi !== "string" || !document.openapi.startsWith("3.1") || !isRecord(document.info) || !isRecord(document.paths)) return void 0;
|
|
156
|
+
const info = Object.fromEntries(Object.entries(document.info).map(([key, field]) => [key.toLowerCase(), field]));
|
|
157
|
+
const title = info.title;
|
|
158
|
+
const version = info.version;
|
|
159
|
+
if (typeof title !== "string" || typeof version !== "string" || !title || !version || Buffer.byteLength(title, "utf8") > 256 || Buffer.byteLength(version, "utf8") > 64 || /[\r\n\0]/.test(title + version) || (title + version).includes(token)) return void 0;
|
|
160
|
+
let endpointCount = 0;
|
|
161
|
+
for (const methods of Object.values(document.paths)) {
|
|
162
|
+
if (methods !== null && !isRecord(methods)) return void 0;
|
|
163
|
+
if (methods === null) continue;
|
|
164
|
+
for (const method of Object.keys(methods)) if (httpMethods.has(method.toLowerCase())) endpointCount++;
|
|
165
|
+
}
|
|
166
|
+
return { title, version, endpointCount };
|
|
167
|
+
}
|
|
168
|
+
function branch(id, kind, message) {
|
|
169
|
+
return newQueryBranch(id, emptyOutput, {}, { provider: "apifox", operation: "getProjectAPISummary", kind, message });
|
|
170
|
+
}
|
|
171
|
+
function retry(kind, message, delayMs = 0) {
|
|
172
|
+
return newQueryRetry({ provider: "apifox", operation: "getProjectAPISummary", kind, message }, delayMs);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/project.ts
|
|
176
|
+
function newProjectConnection2(project, connectionName) {
|
|
177
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
178
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "apifox" && entry.connectionName === name);
|
|
179
|
+
if (!selected) throw new TypeError("Apifox project connection is not configured");
|
|
180
|
+
const fields = z.strictObject({ timeout: z.union([z.string(), z.number().int()]).optional(), maxResponseBytes: z.number().int().optional() }).parse(selected.configuration);
|
|
181
|
+
const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
|
|
182
|
+
const config = {
|
|
183
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
184
|
+
...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
|
|
185
|
+
};
|
|
186
|
+
const credentials = {
|
|
187
|
+
async resolve(_call, signal) {
|
|
188
|
+
const privateFields = await loadedProject.resolveCredential("apifox", name, signal);
|
|
189
|
+
if (typeof privateFields.accessToken !== "string") throw new TypeError("Apifox token is unavailable");
|
|
190
|
+
return { accessToken: new SecretString(privateFields.accessToken) };
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
return new ApifoxClient(config, credentials);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function parseDurationMilliseconds(value) {
|
|
197
|
+
let remaining = value;
|
|
198
|
+
let milliseconds = 0;
|
|
199
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
200
|
+
while (remaining) {
|
|
201
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
202
|
+
if (!part) throw new TypeError("Apifox timeout must be a positive Go duration");
|
|
203
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
204
|
+
remaining = remaining.slice(part[0].length);
|
|
205
|
+
}
|
|
206
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Apifox timeout must resolve to positive whole milliseconds");
|
|
207
|
+
return milliseconds;
|
|
208
|
+
}
|
|
209
|
+
export {
|
|
210
|
+
ApifoxClient,
|
|
211
|
+
ConfigSchema,
|
|
212
|
+
Connection,
|
|
213
|
+
ConnectorID,
|
|
214
|
+
CredentialMaterialError,
|
|
215
|
+
GetProjectAPISummaryBranch,
|
|
216
|
+
GetProjectAPISummaryBranchDefect,
|
|
217
|
+
GetProjectAPISummaryBranchFound,
|
|
218
|
+
GetProjectAPISummaryBranchInvalidResponse,
|
|
219
|
+
GetProjectAPISummaryBranchProviderRejected,
|
|
220
|
+
GetProjectAPISummaryDefinition,
|
|
221
|
+
GetProjectAPISummaryInputSchema,
|
|
222
|
+
GetProjectAPISummaryMetadata,
|
|
223
|
+
GetProjectAPISummaryOperation,
|
|
224
|
+
GetProjectAPISummaryOutputSchema,
|
|
225
|
+
ProviderID,
|
|
226
|
+
decodeCredentials,
|
|
227
|
+
isCredentialMaterialError,
|
|
228
|
+
newConnection,
|
|
229
|
+
newConnectionWithOperations,
|
|
230
|
+
newGetProjectAPISummaryStep,
|
|
231
|
+
newProjectConnection2 as newProjectConnection
|
|
232
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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 GetProjectAPISummaryInput, a as GetProjectAPISummaryOutput } from './connection-DHKKRFFZ.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for GetProjectAPISummaryInput in scripted cases. */
|
|
7
|
+
declare const emptyGetProjectAPISummaryInput: GetProjectAPISummaryInput;
|
|
8
|
+
/** Go zero value for GetProjectAPISummaryOutput in scripted cases. */
|
|
9
|
+
declare const emptyGetProjectAPISummaryOutput: GetProjectAPISummaryOutput;
|
|
10
|
+
/** Script the found branch. */
|
|
11
|
+
declare function getProjectAPISummaryFound(value: GetProjectAPISummaryOutput, failure?: Failure): Case<GetProjectAPISummaryOutput>;
|
|
12
|
+
/** Script the providerRejected branch. */
|
|
13
|
+
declare function getProjectAPISummaryProviderRejected(value: GetProjectAPISummaryOutput, failure?: Failure): Case<GetProjectAPISummaryOutput>;
|
|
14
|
+
/** Script the invalidResponse branch. */
|
|
15
|
+
declare function getProjectAPISummaryInvalidResponse(value: GetProjectAPISummaryOutput, failure?: Failure): Case<GetProjectAPISummaryOutput>;
|
|
16
|
+
/** Script the defect branch. */
|
|
17
|
+
declare function getProjectAPISummaryDefect(value: GetProjectAPISummaryOutput, failure?: Failure): Case<GetProjectAPISummaryOutput>;
|
|
18
|
+
/** Script a safe retry of getProjectAPISummary. */
|
|
19
|
+
declare function getProjectAPISummaryRetry(failure: Failure, retryAfterMs?: number): Case<GetProjectAPISummaryOutput>;
|
|
20
|
+
/** Manifest scenario oneEndpoint for getProjectAPISummary. */
|
|
21
|
+
declare function getProjectAPISummaryOneEndpoint(): Case<GetProjectAPISummaryOutput>;
|
|
22
|
+
/** Default getProjectAPISummary scenario. */
|
|
23
|
+
declare function getProjectAPISummaryDefault(): Case<GetProjectAPISummaryOutput>;
|
|
24
|
+
/** Manifest scenario emptyProject for getProjectAPISummary. */
|
|
25
|
+
declare function getProjectAPISummaryEmptyProject(): Case<GetProjectAPISummaryOutput>;
|
|
26
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
27
|
+
declare class GeneratedMock implements Operations {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(connectionName: string);
|
|
30
|
+
connection(): Connection;
|
|
31
|
+
getProjectAPISummary(): MockQuery<GetProjectAPISummaryInput, GetProjectAPISummaryOutput>;
|
|
32
|
+
assertNoFailures(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { GeneratedMock, GeneratedMock as Mock, emptyGetProjectAPISummaryInput, emptyGetProjectAPISummaryOutput, getProjectAPISummaryDefault, getProjectAPISummaryDefect, getProjectAPISummaryEmptyProject, getProjectAPISummaryFound, getProjectAPISummaryInvalidResponse, getProjectAPISummaryOneEndpoint, getProjectAPISummaryProviderRejected, getProjectAPISummaryRetry };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GetProjectAPISummaryDefinition,
|
|
3
|
+
GetProjectAPISummaryInputSchema,
|
|
4
|
+
GetProjectAPISummaryOutputSchema,
|
|
5
|
+
ProviderID,
|
|
6
|
+
newConnectionWithOperations
|
|
7
|
+
} from "./chunk-7EOB2Y6V.js";
|
|
8
|
+
|
|
9
|
+
// src/generated/mock.ts
|
|
10
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
11
|
+
var emptyGetProjectAPISummaryInput = GetProjectAPISummaryInputSchema.parse({
|
|
12
|
+
"projectID": ""
|
|
13
|
+
});
|
|
14
|
+
var emptyGetProjectAPISummaryOutput = GetProjectAPISummaryOutputSchema.parse({
|
|
15
|
+
"title": "",
|
|
16
|
+
"version": "",
|
|
17
|
+
"endpointCount": 0
|
|
18
|
+
});
|
|
19
|
+
function getProjectAPISummaryFound(value, failure) {
|
|
20
|
+
return branchCase("found", value, failure);
|
|
21
|
+
}
|
|
22
|
+
function getProjectAPISummaryProviderRejected(value, failure) {
|
|
23
|
+
return branchCase("providerRejected", value, failure);
|
|
24
|
+
}
|
|
25
|
+
function getProjectAPISummaryInvalidResponse(value, failure) {
|
|
26
|
+
return branchCase("invalidResponse", value, failure);
|
|
27
|
+
}
|
|
28
|
+
function getProjectAPISummaryDefect(value, failure) {
|
|
29
|
+
return branchCase("defect", value, failure);
|
|
30
|
+
}
|
|
31
|
+
function getProjectAPISummaryRetry(failure, retryAfterMs = 0) {
|
|
32
|
+
return retryCase(failure, retryAfterMs);
|
|
33
|
+
}
|
|
34
|
+
function getProjectAPISummaryOneEndpoint() {
|
|
35
|
+
const value = GetProjectAPISummaryOutputSchema.parse({ "endpointCount": 1, "title": "Example API", "version": "1.0.0" });
|
|
36
|
+
return branchCase("found", value);
|
|
37
|
+
}
|
|
38
|
+
function getProjectAPISummaryDefault() {
|
|
39
|
+
return getProjectAPISummaryOneEndpoint();
|
|
40
|
+
}
|
|
41
|
+
function getProjectAPISummaryEmptyProject() {
|
|
42
|
+
const value = GetProjectAPISummaryOutputSchema.parse({ "endpointCount": 0, "title": "Empty API", "version": "1.0.0" });
|
|
43
|
+
return branchCase("found", value);
|
|
44
|
+
}
|
|
45
|
+
var GeneratedMock = class {
|
|
46
|
+
#getProjectAPISummary;
|
|
47
|
+
#connection;
|
|
48
|
+
constructor(connectionName) {
|
|
49
|
+
this.#getProjectAPISummary = newQuery(GetProjectAPISummaryDefinition).default(getProjectAPISummaryDefault());
|
|
50
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
51
|
+
}
|
|
52
|
+
connection() {
|
|
53
|
+
return this.#connection;
|
|
54
|
+
}
|
|
55
|
+
getProjectAPISummary() {
|
|
56
|
+
return this.#getProjectAPISummary;
|
|
57
|
+
}
|
|
58
|
+
assertNoFailures() {
|
|
59
|
+
this.#getProjectAPISummary.assertNoFailures();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
GeneratedMock,
|
|
64
|
+
GeneratedMock as Mock,
|
|
65
|
+
emptyGetProjectAPISummaryInput,
|
|
66
|
+
emptyGetProjectAPISummaryOutput,
|
|
67
|
+
getProjectAPISummaryDefault,
|
|
68
|
+
getProjectAPISummaryDefect,
|
|
69
|
+
getProjectAPISummaryEmptyProject,
|
|
70
|
+
getProjectAPISummaryFound,
|
|
71
|
+
getProjectAPISummaryInvalidResponse,
|
|
72
|
+
getProjectAPISummaryOneEndpoint,
|
|
73
|
+
getProjectAPISummaryProviderRejected,
|
|
74
|
+
getProjectAPISummaryRetry
|
|
75
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-apifox",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Apifox connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/apifox/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
|
+
"check": "npm run typecheck && npm run lint && npm test && npm run build",
|
|
42
|
+
"example:worker": "tsx examples/project-summary/worker.ts",
|
|
43
|
+
"example:start": "tsx examples/project-summary/start.ts"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@superdurable/connectors-sdk": "0.11.0",
|
|
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
|
+
}
|