@superdurable/connector-yuandian 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/dex-connector.json +65 -0
- package/dist/chunk-XGEQ4YA2.js +124 -0
- package/dist/connection-DBwHl966.d.ts +84 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +182 -0
- package/dist/mock.d.ts +37 -0
- package/dist/mock.js +82 -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,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Yuandian TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@superdurable/connector-yuandian` implements the read-only `getCompanyProfile` Query. It accepts a unified social credit code and returns selected company registration facts. An API Key is resolved from Dex Connections and sent to Yuandian over HTTPS; the Key never enters Flow state or results.
|
|
4
|
+
|
|
5
|
+
Obtain a key through the provider account and API guidance linked in the [connector authorization guide](../connector.yaml). Leave timeout and maxResponseBytes blank for manifest defaults. Temporary transport and HTTP 408/429/5xx responses retry; provider refusals, malformed responses, and invalid local input select optional failure branches.
|
|
6
|
+
|
|
7
|
+
`examples/basic/` is a runnable Dex Flow, Worker, and Client. `npm run check` replays Go-recorded provider scenarios. `npm run test:integration` against `dexcli dev -open=false` verifies retry and persistence. Live provider authorization remains unverified without a user-controlled connection.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "yuandian",
|
|
3
|
+
"releaseTag": "connectors/yuandian/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-yuandian",
|
|
7
|
+
"version": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newGetCompanyProfileStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "getCompanyProfile",
|
|
14
|
+
"inputType": "GetCompanyProfileInput",
|
|
15
|
+
"description": "Read selected company registration facts by unified social credit code.",
|
|
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": "noData",
|
|
30
|
+
"field": "noData",
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "providerRejected",
|
|
35
|
+
"field": "providerRejected",
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "invalidResponse",
|
|
40
|
+
"field": "invalidResponse",
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "defect",
|
|
45
|
+
"field": "defect",
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"inputSchema": {
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"description": "GetCompanyProfileInput identifies one company by its unified social credit code.",
|
|
52
|
+
"properties": {
|
|
53
|
+
"creditCode": {
|
|
54
|
+
"description": "CreditCode is the 18-character uppercase unified social credit code.",
|
|
55
|
+
"type": "string"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"required": [
|
|
59
|
+
"creditCode"
|
|
60
|
+
],
|
|
61
|
+
"type": "object"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
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(["apiKey"]);
|
|
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["apiKey"] != null && !(typeof fields["apiKey"] === "string")) throw new CredentialMaterialError("credential apiKey has an invalid type");
|
|
28
|
+
const credentials = {};
|
|
29
|
+
if (!fields["apiKey"]) throw new CredentialMaterialError("credential apiKey is required");
|
|
30
|
+
credentials.apiKey = new SecretString(fields["apiKey"] ?? "");
|
|
31
|
+
return credentials;
|
|
32
|
+
}
|
|
33
|
+
var GetCompanyProfileInputSchema = z.strictObject({
|
|
34
|
+
"creditCode": z.string()
|
|
35
|
+
});
|
|
36
|
+
var GetCompanyProfileOutputSchema = z.strictObject({
|
|
37
|
+
"companyID": z.string(),
|
|
38
|
+
"name": z.string(),
|
|
39
|
+
"creditCode": z.string(),
|
|
40
|
+
"registrationStatus": z.string(),
|
|
41
|
+
"industry": z.string(),
|
|
42
|
+
"companyType": z.string()
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// src/generated/definitions.ts
|
|
46
|
+
var ConnectorID = "yuandian";
|
|
47
|
+
var ProviderID = "yuandian";
|
|
48
|
+
var GetCompanyProfileBranch = {
|
|
49
|
+
Found: "found",
|
|
50
|
+
NoData: "noData",
|
|
51
|
+
ProviderRejected: "providerRejected",
|
|
52
|
+
InvalidResponse: "invalidResponse",
|
|
53
|
+
Defect: "defect"
|
|
54
|
+
};
|
|
55
|
+
var GetCompanyProfileBranchFound = GetCompanyProfileBranch.Found;
|
|
56
|
+
var GetCompanyProfileBranchNoData = GetCompanyProfileBranch.NoData;
|
|
57
|
+
var GetCompanyProfileBranchProviderRejected = GetCompanyProfileBranch.ProviderRejected;
|
|
58
|
+
var GetCompanyProfileBranchInvalidResponse = GetCompanyProfileBranch.InvalidResponse;
|
|
59
|
+
var GetCompanyProfileBranchDefect = GetCompanyProfileBranch.Defect;
|
|
60
|
+
var GetCompanyProfileDefinition = {
|
|
61
|
+
operation: { connectorId: ConnectorID, operationId: "getCompanyProfile" },
|
|
62
|
+
branches: [
|
|
63
|
+
{ id: "found", description: "Yuandian returned one company profile." },
|
|
64
|
+
{ id: "noData", description: "Yuandian found no company for the credit code.", optional: true },
|
|
65
|
+
{ id: "providerRejected", description: "Yuandian rejected the key, permission, or query.", optional: true },
|
|
66
|
+
{ id: "invalidResponse", description: "Yuandian returned malformed or oversized data.", optional: true },
|
|
67
|
+
{ id: "defect", description: "The local key or credit code is invalid.", optional: true }
|
|
68
|
+
],
|
|
69
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: { initialIntervalMs: 2e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 3, totalDurationMs: 3e5 } }
|
|
70
|
+
};
|
|
71
|
+
var GetCompanyProfileMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
72
|
+
|
|
73
|
+
// src/generated/connection.ts
|
|
74
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
75
|
+
var Connection = class {
|
|
76
|
+
/** Stable provider and connection name. */
|
|
77
|
+
reference;
|
|
78
|
+
/** Bound provider operations. */
|
|
79
|
+
operations;
|
|
80
|
+
/** Validate a reference and bind operations. */
|
|
81
|
+
constructor(reference, operations) {
|
|
82
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
83
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
84
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
85
|
+
this.operations = operations;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function newConnection(client, reference) {
|
|
89
|
+
if (!client) throw new TypeError("connector client is required");
|
|
90
|
+
return new Connection(reference, client);
|
|
91
|
+
}
|
|
92
|
+
function newConnectionWithOperations(operations, reference) {
|
|
93
|
+
return new Connection(reference, operations);
|
|
94
|
+
}
|
|
95
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
96
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
97
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
98
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
99
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
100
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
ConfigSchema,
|
|
105
|
+
CredentialMaterialError,
|
|
106
|
+
isCredentialMaterialError,
|
|
107
|
+
decodeCredentials,
|
|
108
|
+
GetCompanyProfileInputSchema,
|
|
109
|
+
GetCompanyProfileOutputSchema,
|
|
110
|
+
ConnectorID,
|
|
111
|
+
ProviderID,
|
|
112
|
+
GetCompanyProfileBranch,
|
|
113
|
+
GetCompanyProfileBranchFound,
|
|
114
|
+
GetCompanyProfileBranchNoData,
|
|
115
|
+
GetCompanyProfileBranchProviderRejected,
|
|
116
|
+
GetCompanyProfileBranchInvalidResponse,
|
|
117
|
+
GetCompanyProfileBranchDefect,
|
|
118
|
+
GetCompanyProfileDefinition,
|
|
119
|
+
GetCompanyProfileMetadata,
|
|
120
|
+
Connection,
|
|
121
|
+
newConnection,
|
|
122
|
+
newConnectionWithOperations,
|
|
123
|
+
newProjectConnection
|
|
124
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
/** Maximum duration of one HTTPS company lookup as a positive Go duration such as 5s or 1m. Blank uses the displayed default; increase only for a slow approved network. Runtime value in milliseconds. */
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
/** Maximum provider response size in bytes as a positive integer. Blank uses the displayed default; increase only when a legitimate company record exceeds it. */
|
|
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 API Key from https://open.chineselaw.com > 个人中心 > API Key 管理. Create or select a key and copy it into this secret field; blank prevents requests. */
|
|
19
|
+
apiKey: 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
|
+
/** GetCompanyProfileInput identifies one company by its unified social credit code. */
|
|
32
|
+
interface GetCompanyProfileInput {
|
|
33
|
+
/** CreditCode is the 18-character uppercase unified social credit code. */
|
|
34
|
+
"creditCode": string;
|
|
35
|
+
}
|
|
36
|
+
/** GetCompanyProfileOutput retains selected company registration facts only. */
|
|
37
|
+
interface GetCompanyProfileOutput {
|
|
38
|
+
/** CompanyID is the provider's company identifier. */
|
|
39
|
+
"companyID": string;
|
|
40
|
+
/** Name is the registered company name. */
|
|
41
|
+
"name": string;
|
|
42
|
+
/** CreditCode is the unified social credit code. */
|
|
43
|
+
"creditCode": string;
|
|
44
|
+
/** RegistrationStatus is the registered operating status. */
|
|
45
|
+
"registrationStatus": string;
|
|
46
|
+
/** Industry is the provider's industry classification. */
|
|
47
|
+
"industry": string;
|
|
48
|
+
/** CompanyType is the registered organization type. */
|
|
49
|
+
"companyType": string;
|
|
50
|
+
}
|
|
51
|
+
/** Runtime validator for GetCompanyProfileInput. */
|
|
52
|
+
declare const GetCompanyProfileInputSchema: z.ZodObject<{
|
|
53
|
+
creditCode: z.ZodString;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
/** Runtime validator for GetCompanyProfileOutput. */
|
|
56
|
+
declare const GetCompanyProfileOutputSchema: z.ZodObject<{
|
|
57
|
+
companyID: z.ZodString;
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
creditCode: z.ZodString;
|
|
60
|
+
registrationStatus: z.ZodString;
|
|
61
|
+
industry: z.ZodString;
|
|
62
|
+
companyType: z.ZodString;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
|
|
65
|
+
/** Typed operations supplied by a client or mock. */
|
|
66
|
+
interface Operations {
|
|
67
|
+
/** Invoke getCompanyProfile through this connection. */
|
|
68
|
+
getCompanyProfile(): Query<GetCompanyProfileInput, GetCompanyProfileOutput>;
|
|
69
|
+
}
|
|
70
|
+
/** Named connector connection kept outside Flow state. */
|
|
71
|
+
declare class Connection<BoundOperations = Operations> {
|
|
72
|
+
/** Stable provider and connection name. */
|
|
73
|
+
readonly reference: ConnectionRef;
|
|
74
|
+
/** Bound provider operations. */
|
|
75
|
+
readonly operations: BoundOperations;
|
|
76
|
+
/** Validate a reference and bind operations. */
|
|
77
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
78
|
+
}
|
|
79
|
+
/** Bind a client to a named connection. */
|
|
80
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
81
|
+
/** Bind scripted operations to a named connection. */
|
|
82
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
83
|
+
|
|
84
|
+
export { Connection as C, type GetCompanyProfileInput as G, type Operations as O, type GetCompanyProfileOutput as a, type Credentials as b, type Config as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, GetCompanyProfileInputSchema as g, GetCompanyProfileOutputSchema as h, decodeCredentials as i, isCredentialMaterialError as j, newConnectionWithOperations as k, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { G as GetCompanyProfileInput, a as GetCompanyProfileOutput, C as Connection, O as Operations, b as Credentials, c as Config } from './connection-DBwHl966.js';
|
|
2
|
+
export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as GetCompanyProfileInputSchema, h as GetCompanyProfileOutputSchema, i as decodeCredentials, j as isCredentialMaterialError, n as newConnection, k as newConnectionWithOperations } from './connection-DBwHl966.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 = "yuandian";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "yuandian";
|
|
13
|
+
/** Branch IDs for getCompanyProfile. */
|
|
14
|
+
declare const GetCompanyProfileBranch: {
|
|
15
|
+
readonly Found: "found";
|
|
16
|
+
readonly NoData: "noData";
|
|
17
|
+
readonly ProviderRejected: "providerRejected";
|
|
18
|
+
readonly InvalidResponse: "invalidResponse";
|
|
19
|
+
readonly Defect: "defect";
|
|
20
|
+
};
|
|
21
|
+
/** Yuandian returned one company profile. */
|
|
22
|
+
declare const GetCompanyProfileBranchFound: "found";
|
|
23
|
+
/** Yuandian found no company for the credit code. */
|
|
24
|
+
declare const GetCompanyProfileBranchNoData: "noData";
|
|
25
|
+
/** Yuandian rejected the key, permission, or query. */
|
|
26
|
+
declare const GetCompanyProfileBranchProviderRejected: "providerRejected";
|
|
27
|
+
/** Yuandian returned malformed or oversized data. */
|
|
28
|
+
declare const GetCompanyProfileBranchInvalidResponse: "invalidResponse";
|
|
29
|
+
/** The local key or credit code is invalid. */
|
|
30
|
+
declare const GetCompanyProfileBranchDefect: "defect";
|
|
31
|
+
/** Manifest definition for getCompanyProfile. */
|
|
32
|
+
declare const GetCompanyProfileDefinition: QueryDefinition;
|
|
33
|
+
/** Manifest metadata for getCompanyProfile. */
|
|
34
|
+
declare const GetCompanyProfileMetadata: {
|
|
35
|
+
readonly kind: "query";
|
|
36
|
+
readonly idempotency: "none";
|
|
37
|
+
readonly authorization: "required";
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Configuration for the getCompanyProfile connector Step. */
|
|
41
|
+
interface GetCompanyProfileStepConfig<StepInput, OperationInput = GetCompanyProfileInput, OperationOutput = GetCompanyProfileOutput> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
42
|
+
/** Named connection supplying this operation. */
|
|
43
|
+
connection: Connection<{
|
|
44
|
+
getCompanyProfile(): Query<OperationInput, OperationOutput>;
|
|
45
|
+
}>;
|
|
46
|
+
/** Name matching the bound connection. */
|
|
47
|
+
connectionName: string;
|
|
48
|
+
/** Yuandian returned one company profile. */
|
|
49
|
+
found: StepTarget<QueryResult<OperationOutput>>;
|
|
50
|
+
/** Yuandian found no company for the credit code. */
|
|
51
|
+
noData?: StepTarget<QueryResult<OperationOutput>>;
|
|
52
|
+
/** Yuandian rejected the key, permission, or query. */
|
|
53
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
54
|
+
/** Yuandian returned malformed or oversized data. */
|
|
55
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
56
|
+
/** The local key or credit code is invalid. */
|
|
57
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
58
|
+
}
|
|
59
|
+
/** Build the getCompanyProfile Step from a named connection. */
|
|
60
|
+
declare function newGetCompanyProfileStep<StepInput, OperationInput = GetCompanyProfileInput, OperationOutput = GetCompanyProfileOutput>(configuration: GetCompanyProfileStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
61
|
+
|
|
62
|
+
/** Open one named Yuandian connection from Dex project configuration. */
|
|
63
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
64
|
+
|
|
65
|
+
/** Optional provider sender for deterministic tests. */
|
|
66
|
+
interface YuandianClientOptions {
|
|
67
|
+
send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
68
|
+
}
|
|
69
|
+
/** Resolve the API Key for each read-only company profile Query. */
|
|
70
|
+
declare class YuandianClient {
|
|
71
|
+
readonly credentials: CredentialProvider<Credentials>;
|
|
72
|
+
readonly timeoutMs: number;
|
|
73
|
+
readonly maxResponseBytes: number;
|
|
74
|
+
readonly send: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
75
|
+
/** Validate request limits without contacting the provider. */
|
|
76
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: YuandianClientOptions);
|
|
77
|
+
/** Bind the company profile Query. */
|
|
78
|
+
getCompanyProfile(): GetCompanyProfileOperation;
|
|
79
|
+
}
|
|
80
|
+
/** Read selected registration facts by unified social credit code. */
|
|
81
|
+
declare class GetCompanyProfileOperation implements Query<GetCompanyProfileInput, GetCompanyProfileOutput> {
|
|
82
|
+
private readonly client;
|
|
83
|
+
/** Bind a validated provider client. */ constructor(client: YuandianClient);
|
|
84
|
+
/** Return the generated Query contract. */ definition(): QueryDefinition;
|
|
85
|
+
/** Classify one provider attempt and retain only selected facts. */
|
|
86
|
+
invoke(call: Call, input: GetCompanyProfileInput): Promise<QueryAttempt<GetCompanyProfileOutput>>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { Config, Connection, ConnectorID, Credentials, GetCompanyProfileBranch, GetCompanyProfileBranchDefect, GetCompanyProfileBranchFound, GetCompanyProfileBranchInvalidResponse, GetCompanyProfileBranchNoData, GetCompanyProfileBranchProviderRejected, GetCompanyProfileDefinition, GetCompanyProfileInput, GetCompanyProfileMetadata, GetCompanyProfileOutput, type GetCompanyProfileStepConfig, ProviderID, YuandianClient, type YuandianClientOptions, newGetCompanyProfileStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
6
|
+
GetCompanyProfileBranch,
|
|
7
|
+
GetCompanyProfileBranchDefect,
|
|
8
|
+
GetCompanyProfileBranchFound,
|
|
9
|
+
GetCompanyProfileBranchInvalidResponse,
|
|
10
|
+
GetCompanyProfileBranchNoData,
|
|
11
|
+
GetCompanyProfileBranchProviderRejected,
|
|
12
|
+
GetCompanyProfileDefinition,
|
|
13
|
+
GetCompanyProfileInputSchema,
|
|
14
|
+
GetCompanyProfileMetadata,
|
|
15
|
+
GetCompanyProfileOutputSchema,
|
|
16
|
+
ProviderID,
|
|
17
|
+
decodeCredentials,
|
|
18
|
+
isCredentialMaterialError,
|
|
19
|
+
newConnection,
|
|
20
|
+
newConnectionWithOperations,
|
|
21
|
+
newProjectConnection
|
|
22
|
+
} from "./chunk-XGEQ4YA2.js";
|
|
23
|
+
|
|
24
|
+
// src/generated/steps.ts
|
|
25
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
26
|
+
function newGetCompanyProfileStep(configuration) {
|
|
27
|
+
const { connection, connectionName, found, noData, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
28
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
29
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getCompanyProfile(), connection: connection.reference, branches: [
|
|
30
|
+
goToBranch("found", found),
|
|
31
|
+
...noData ? [goToBranch("noData", noData)] : [],
|
|
32
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
33
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
34
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
35
|
+
] });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/client.ts
|
|
39
|
+
import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
40
|
+
import { BodyTooLargeError, parseRetryAfter, sendProviderRequest } from "@superdurable/connectors-sdk/providerhttp";
|
|
41
|
+
var endpoint = "https://open.chineselaw.com/open/rh_company_detail";
|
|
42
|
+
var emptyOutput = { companyID: "", name: "", creditCode: "", registrationStatus: "", industry: "", companyType: "" };
|
|
43
|
+
var YuandianClient = class {
|
|
44
|
+
/** Validate request limits without contacting the provider. */
|
|
45
|
+
constructor(config, credentials, options = {}) {
|
|
46
|
+
this.credentials = credentials;
|
|
47
|
+
if (!config || !credentials) throw new TypeError("Yuandian configuration and credentials are required");
|
|
48
|
+
this.timeoutMs = config.timeoutMs ?? 1e4;
|
|
49
|
+
this.maxResponseBytes = config.maxResponseBytes ?? 1048576;
|
|
50
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0 || this.maxResponseBytes > 16 << 20) throw new TypeError("Yuandian request limits are invalid");
|
|
51
|
+
this.send = options.send ?? sendProviderRequest;
|
|
52
|
+
}
|
|
53
|
+
credentials;
|
|
54
|
+
timeoutMs;
|
|
55
|
+
maxResponseBytes;
|
|
56
|
+
send;
|
|
57
|
+
/** Bind the company profile Query. */
|
|
58
|
+
getCompanyProfile() {
|
|
59
|
+
return new GetCompanyProfileOperation(this);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var GetCompanyProfileOperation = class {
|
|
63
|
+
/** Bind a validated provider client. */
|
|
64
|
+
constructor(client) {
|
|
65
|
+
this.client = client;
|
|
66
|
+
}
|
|
67
|
+
client;
|
|
68
|
+
/** Return the generated Query contract. */
|
|
69
|
+
definition() {
|
|
70
|
+
return GetCompanyProfileDefinition;
|
|
71
|
+
}
|
|
72
|
+
/** Classify one provider attempt and retain only selected facts. */
|
|
73
|
+
async invoke(call, input) {
|
|
74
|
+
if (!input || typeof input.creditCode !== "string" || !/^[0-9A-Z]{18}$/.test(input.creditCode)) return branch("defect", "VALIDATION");
|
|
75
|
+
let apiKey = "";
|
|
76
|
+
try {
|
|
77
|
+
const fields = await this.client.credentials.resolve(call, call.context.cancellationSignal);
|
|
78
|
+
apiKey = fields.apiKey instanceof SecretString ? fields.apiKey.reveal() : "";
|
|
79
|
+
} catch {
|
|
80
|
+
return branch("defect", "AUTHENTICATION");
|
|
81
|
+
}
|
|
82
|
+
if (!apiKey || apiKey.length > 1024 || !/^[!-~]+$/.test(apiKey)) return branch("defect", "AUTHENTICATION");
|
|
83
|
+
const url = new URL(endpoint);
|
|
84
|
+
url.searchParams.set("tyshxydm", input.creditCode);
|
|
85
|
+
let response;
|
|
86
|
+
let tooLarge = false;
|
|
87
|
+
try {
|
|
88
|
+
response = await this.client.send({ url: url.toString(), method: "GET", headers: { "X-API-Key": apiKey, Accept: "application/json" }, timeoutMs: this.client.timeoutMs, maxResponseBytes: this.client.maxResponseBytes, addressPolicy: "publicHTTPS", signal: call.context.cancellationSignal });
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (!(error instanceof BodyTooLargeError) || error.status === void 0) return retry("AVAILABILITY");
|
|
91
|
+
response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
|
|
92
|
+
tooLarge = true;
|
|
93
|
+
}
|
|
94
|
+
const retryAfterValue = Object.entries(response.headers).find(([key]) => key.toLowerCase() === "retry-after")?.[1];
|
|
95
|
+
const retryAfterMs = parseRetryAfter(Array.isArray(retryAfterValue) ? retryAfterValue[0] ?? "" : retryAfterValue ?? "");
|
|
96
|
+
if (response.status === 429) return retry("RATE_LIMIT", retryAfterMs);
|
|
97
|
+
if (response.status === 408 || response.status >= 500) return retry("AVAILABILITY", retryAfterMs);
|
|
98
|
+
if (response.status !== 200) return branch("providerRejected", response.status === 401 ? "AUTHENTICATION" : response.status === 403 ? "AUTHORIZATION" : "PROVIDER_REJECTION");
|
|
99
|
+
if (tooLarge || response.body.length > this.client.maxResponseBytes) return branch("invalidResponse", "RESPONSE_TOO_LARGE");
|
|
100
|
+
let document;
|
|
101
|
+
try {
|
|
102
|
+
document = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(response.body));
|
|
103
|
+
} catch {
|
|
104
|
+
return branch("invalidResponse", "PROTOCOL");
|
|
105
|
+
}
|
|
106
|
+
if (!isRecord(document) || typeof document.code !== "number" || !Number.isInteger(document.code)) return branch("invalidResponse", "PROTOCOL");
|
|
107
|
+
if (document.code === 429) return retry("RATE_LIMIT", retryAfterMs);
|
|
108
|
+
if (document.code >= 500) return retry("AVAILABILITY", retryAfterMs);
|
|
109
|
+
if (document.code !== 200) return branch("providerRejected", document.code === 401 ? "AUTHENTICATION" : document.code === 403 ? "AUTHORIZATION" : "PROVIDER_REJECTION");
|
|
110
|
+
if (!isRecord(document.data)) return typeof document.message === "string" && document.message.includes("\u672A\u67E5\u8BE2\u5230") ? branch("noData", "NOT_FOUND") : branch("invalidResponse", "PROTOCOL");
|
|
111
|
+
const data = document.data;
|
|
112
|
+
if (typeof data["\u4F01\u4E1AID"] !== "string" || !data["\u4F01\u4E1AID"] || Buffer.byteLength(data["\u4F01\u4E1AID"], "utf8") > 255 || typeof data["\u4F01\u4E1A\u540D\u79F0"] !== "string" || !data["\u4F01\u4E1A\u540D\u79F0"] || Buffer.byteLength(data["\u4F01\u4E1A\u540D\u79F0"], "utf8") > 255 || data["\u7EDF\u4E00\u793E\u4F1A\u4FE1\u7528\u4EE3\u7801"] !== input.creditCode || typeof data["\u7ECF\u8425\u72B6\u6001"] !== "string" || Buffer.byteLength(data["\u7ECF\u8425\u72B6\u6001"], "utf8") > 100 || typeof data["\u884C\u4E1A"] !== "string" || Buffer.byteLength(data["\u884C\u4E1A"], "utf8") > 255 || typeof data["\u4F01\u4E1A\u7C7B\u578B"] !== "string" || Buffer.byteLength(data["\u4F01\u4E1A\u7C7B\u578B"], "utf8") > 255) return branch("invalidResponse", "PROTOCOL");
|
|
113
|
+
return newQueryBranch("found", { companyID: data["\u4F01\u4E1AID"], name: data["\u4F01\u4E1A\u540D\u79F0"], creditCode: input.creditCode, registrationStatus: data["\u7ECF\u8425\u72B6\u6001"], industry: data["\u884C\u4E1A"], companyType: data["\u4F01\u4E1A\u7C7B\u578B"] });
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function isRecord(value) {
|
|
117
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
118
|
+
}
|
|
119
|
+
function failure(kind) {
|
|
120
|
+
return { provider: "yuandian", operation: "getCompanyProfile", kind, message: "Yuandian company profile failed" };
|
|
121
|
+
}
|
|
122
|
+
function branch(name, kind) {
|
|
123
|
+
return newQueryBranch(name, emptyOutput, {}, failure(kind));
|
|
124
|
+
}
|
|
125
|
+
function retry(kind, delay = 0) {
|
|
126
|
+
return newQueryRetry(failure(kind), delay);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// src/project.ts
|
|
130
|
+
function newProjectConnection2(project, connectionName) {
|
|
131
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
132
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "yuandian" && entry.connectionName === name);
|
|
133
|
+
if (!selected) throw new TypeError("Yuandian project connection is not configured");
|
|
134
|
+
const fields = selected.configuration;
|
|
135
|
+
const config = ConfigSchema.parse({ ...fields, ...fields.timeout !== void 0 ? { timeoutMs: parseDurationMilliseconds(fields.timeout) } : {} });
|
|
136
|
+
const credentials = {
|
|
137
|
+
async resolve(_call, signal) {
|
|
138
|
+
return decodeCredentials(await loadedProject.resolveCredential("yuandian", name, signal));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
return new YuandianClient(config, credentials);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function parseDurationMilliseconds(value) {
|
|
145
|
+
if (typeof value === "number") return Math.ceil(value / 1e6);
|
|
146
|
+
if (typeof value !== "string") throw new TypeError("timeout must be a duration");
|
|
147
|
+
let remaining = value;
|
|
148
|
+
let milliseconds = 0;
|
|
149
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
150
|
+
while (remaining) {
|
|
151
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
152
|
+
if (!part) throw new TypeError("timeout must be a positive Go duration");
|
|
153
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
154
|
+
remaining = remaining.slice(part[0].length);
|
|
155
|
+
}
|
|
156
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("timeout must resolve to positive whole milliseconds");
|
|
157
|
+
return milliseconds;
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
ConfigSchema,
|
|
161
|
+
Connection,
|
|
162
|
+
ConnectorID,
|
|
163
|
+
CredentialMaterialError,
|
|
164
|
+
GetCompanyProfileBranch,
|
|
165
|
+
GetCompanyProfileBranchDefect,
|
|
166
|
+
GetCompanyProfileBranchFound,
|
|
167
|
+
GetCompanyProfileBranchInvalidResponse,
|
|
168
|
+
GetCompanyProfileBranchNoData,
|
|
169
|
+
GetCompanyProfileBranchProviderRejected,
|
|
170
|
+
GetCompanyProfileDefinition,
|
|
171
|
+
GetCompanyProfileInputSchema,
|
|
172
|
+
GetCompanyProfileMetadata,
|
|
173
|
+
GetCompanyProfileOutputSchema,
|
|
174
|
+
ProviderID,
|
|
175
|
+
YuandianClient,
|
|
176
|
+
decodeCredentials,
|
|
177
|
+
isCredentialMaterialError,
|
|
178
|
+
newConnection,
|
|
179
|
+
newConnectionWithOperations,
|
|
180
|
+
newGetCompanyProfileStep,
|
|
181
|
+
newProjectConnection2 as newProjectConnection
|
|
182
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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 GetCompanyProfileInput, a as GetCompanyProfileOutput } from './connection-DBwHl966.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for GetCompanyProfileInput in scripted cases. */
|
|
7
|
+
declare const emptyGetCompanyProfileInput: GetCompanyProfileInput;
|
|
8
|
+
/** Go zero value for GetCompanyProfileOutput in scripted cases. */
|
|
9
|
+
declare const emptyGetCompanyProfileOutput: GetCompanyProfileOutput;
|
|
10
|
+
/** Script the found branch. */
|
|
11
|
+
declare function getCompanyProfileFound(value: GetCompanyProfileOutput, failure?: Failure): Case<GetCompanyProfileOutput>;
|
|
12
|
+
/** Script the noData branch. */
|
|
13
|
+
declare function getCompanyProfileNoData(value: GetCompanyProfileOutput, failure?: Failure): Case<GetCompanyProfileOutput>;
|
|
14
|
+
/** Script the providerRejected branch. */
|
|
15
|
+
declare function getCompanyProfileProviderRejected(value: GetCompanyProfileOutput, failure?: Failure): Case<GetCompanyProfileOutput>;
|
|
16
|
+
/** Script the invalidResponse branch. */
|
|
17
|
+
declare function getCompanyProfileInvalidResponse(value: GetCompanyProfileOutput, failure?: Failure): Case<GetCompanyProfileOutput>;
|
|
18
|
+
/** Script the defect branch. */
|
|
19
|
+
declare function getCompanyProfileDefect(value: GetCompanyProfileOutput, failure?: Failure): Case<GetCompanyProfileOutput>;
|
|
20
|
+
/** Script a safe retry of getCompanyProfile. */
|
|
21
|
+
declare function getCompanyProfileRetry(failure: Failure, retryAfterMs?: number): Case<GetCompanyProfileOutput>;
|
|
22
|
+
/** Manifest scenario sampleCompany for getCompanyProfile. */
|
|
23
|
+
declare function getCompanyProfileSampleCompany(): Case<GetCompanyProfileOutput>;
|
|
24
|
+
/** Default getCompanyProfile scenario. */
|
|
25
|
+
declare function getCompanyProfileDefault(): Case<GetCompanyProfileOutput>;
|
|
26
|
+
/** Manifest scenario noCompany for getCompanyProfile. */
|
|
27
|
+
declare function getCompanyProfileNoCompany(): Case<GetCompanyProfileOutput>;
|
|
28
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
29
|
+
declare class GeneratedMock implements Operations {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(connectionName: string);
|
|
32
|
+
connection(): Connection;
|
|
33
|
+
getCompanyProfile(): MockQuery<GetCompanyProfileInput, GetCompanyProfileOutput>;
|
|
34
|
+
assertNoFailures(): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { GeneratedMock, emptyGetCompanyProfileInput, emptyGetCompanyProfileOutput, getCompanyProfileDefault, getCompanyProfileDefect, getCompanyProfileFound, getCompanyProfileInvalidResponse, getCompanyProfileNoCompany, getCompanyProfileNoData, getCompanyProfileProviderRejected, getCompanyProfileRetry, getCompanyProfileSampleCompany };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConnectorID,
|
|
3
|
+
GetCompanyProfileDefinition,
|
|
4
|
+
GetCompanyProfileInputSchema,
|
|
5
|
+
GetCompanyProfileOutputSchema,
|
|
6
|
+
ProviderID,
|
|
7
|
+
newConnectionWithOperations
|
|
8
|
+
} from "./chunk-XGEQ4YA2.js";
|
|
9
|
+
|
|
10
|
+
// src/generated/mock.ts
|
|
11
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
12
|
+
var emptyGetCompanyProfileInput = GetCompanyProfileInputSchema.parse({
|
|
13
|
+
"creditCode": ""
|
|
14
|
+
});
|
|
15
|
+
var emptyGetCompanyProfileOutput = GetCompanyProfileOutputSchema.parse({
|
|
16
|
+
"companyID": "",
|
|
17
|
+
"name": "",
|
|
18
|
+
"creditCode": "",
|
|
19
|
+
"registrationStatus": "",
|
|
20
|
+
"industry": "",
|
|
21
|
+
"companyType": ""
|
|
22
|
+
});
|
|
23
|
+
function getCompanyProfileFound(value, failure) {
|
|
24
|
+
return branchCase("found", value, failure);
|
|
25
|
+
}
|
|
26
|
+
function getCompanyProfileNoData(value, failure) {
|
|
27
|
+
return branchCase("noData", value, failure);
|
|
28
|
+
}
|
|
29
|
+
function getCompanyProfileProviderRejected(value, failure) {
|
|
30
|
+
return branchCase("providerRejected", value, failure);
|
|
31
|
+
}
|
|
32
|
+
function getCompanyProfileInvalidResponse(value, failure) {
|
|
33
|
+
return branchCase("invalidResponse", value, failure);
|
|
34
|
+
}
|
|
35
|
+
function getCompanyProfileDefect(value, failure) {
|
|
36
|
+
return branchCase("defect", value, failure);
|
|
37
|
+
}
|
|
38
|
+
function getCompanyProfileRetry(failure, retryAfterMs = 0) {
|
|
39
|
+
return retryCase(failure, retryAfterMs);
|
|
40
|
+
}
|
|
41
|
+
function getCompanyProfileSampleCompany() {
|
|
42
|
+
const value = GetCompanyProfileOutputSchema.parse({ "companyID": "sample-id", "companyType": "\u6709\u9650\u8D23\u4EFB\u516C\u53F8", "creditCode": "91110108MA0074PN30", "industry": "\u5546\u52A1\u670D\u52A1\u4E1A", "name": "\u793A\u4F8B\u4F01\u4E1A\u6709\u9650\u516C\u53F8", "registrationStatus": "\u5B58\u7EED" });
|
|
43
|
+
return branchCase("found", value);
|
|
44
|
+
}
|
|
45
|
+
function getCompanyProfileDefault() {
|
|
46
|
+
return getCompanyProfileSampleCompany();
|
|
47
|
+
}
|
|
48
|
+
function getCompanyProfileNoCompany() {
|
|
49
|
+
const value = emptyGetCompanyProfileOutput;
|
|
50
|
+
return branchCase("noData", value, { kind: "NOT_FOUND", provider: ConnectorID, operation: "getCompanyProfile", message: "Yuandian found no matching company." });
|
|
51
|
+
}
|
|
52
|
+
var GeneratedMock = class {
|
|
53
|
+
#getCompanyProfile;
|
|
54
|
+
#connection;
|
|
55
|
+
constructor(connectionName) {
|
|
56
|
+
this.#getCompanyProfile = newQuery(GetCompanyProfileDefinition).default(getCompanyProfileDefault());
|
|
57
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
58
|
+
}
|
|
59
|
+
connection() {
|
|
60
|
+
return this.#connection;
|
|
61
|
+
}
|
|
62
|
+
getCompanyProfile() {
|
|
63
|
+
return this.#getCompanyProfile;
|
|
64
|
+
}
|
|
65
|
+
assertNoFailures() {
|
|
66
|
+
this.#getCompanyProfile.assertNoFailures();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
GeneratedMock,
|
|
71
|
+
emptyGetCompanyProfileInput,
|
|
72
|
+
emptyGetCompanyProfileOutput,
|
|
73
|
+
getCompanyProfileDefault,
|
|
74
|
+
getCompanyProfileDefect,
|
|
75
|
+
getCompanyProfileFound,
|
|
76
|
+
getCompanyProfileInvalidResponse,
|
|
77
|
+
getCompanyProfileNoCompany,
|
|
78
|
+
getCompanyProfileNoData,
|
|
79
|
+
getCompanyProfileProviderRejected,
|
|
80
|
+
getCompanyProfileRetry,
|
|
81
|
+
getCompanyProfileSampleCompany
|
|
82
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-yuandian",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Yuandian IP-location connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/yuandian/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
|
+
}
|