@superdurable/connector-alapi 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 +6 -2
- package/dex-connector.json +60 -0
- package/dist/chunk-5QZHXYLQ.js +119 -0
- package/dist/connection-4ZHjh9Jy.d.ts +81 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +225 -0
- package/dist/mock.d.ts +33 -0
- package/dist/mock.js +72 -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
|
+
# ALAPI TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@superdurable/connector-alapi` provides the `lookupIPLocation` read-only Dex Step. It accepts one public IPv4 address and returns coarse country, province, city, district, and network operator fields. Its request follows the [ALAPI IP address API](https://www.alapi.cn/api/23/api_document).
|
|
4
|
+
|
|
5
|
+
Use the [runnable Flow and Worker](examples/ip-location/) with a named `alapi` connection. In Dex Web Connections, enable IP地址查询, then add the secret token from ALAPI 控制台 > 数据中心 > token管理. The timeout and maximum response size have safe defaults in the connector manifest. Credentials are resolved for each call and never enter Flow state.
|
|
6
|
+
|
|
7
|
+
The checked-in conformance scenarios replay Go-recorded provider requests and every declared branch. The example's integration test exercises a real Dex Worker and Client with a local provider that returns 503 before succeeding. Real ALAPI authorization, quota usage, and live responses remain unverified without a user-controlled token.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "alapi",
|
|
3
|
+
"releaseTag": "connectors/alapi/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-alapi",
|
|
7
|
+
"version": "0.1.1"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newLookupIPLocationStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "lookupIPLocation",
|
|
14
|
+
"inputType": "LookupIPLocationInput",
|
|
15
|
+
"description": "Look up country, province, city, district, and operator for one public IPv4 address.",
|
|
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": "LookupIPLocationInput identifies one public IPv4 address.",
|
|
47
|
+
"properties": {
|
|
48
|
+
"ipAddress": {
|
|
49
|
+
"description": "IPAddress is an IPv4 address, not a hostname or CIDR range.",
|
|
50
|
+
"type": "string"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": [
|
|
54
|
+
"ipAddress"
|
|
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
|
+
"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(["token"]);
|
|
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["token"] != null && !(typeof fields["token"] === "string")) throw new CredentialMaterialError("credential token has an invalid type");
|
|
28
|
+
const credentials = {};
|
|
29
|
+
if (!fields["token"]) throw new CredentialMaterialError("credential token is required");
|
|
30
|
+
credentials.token = new SecretString(fields["token"] ?? "");
|
|
31
|
+
return credentials;
|
|
32
|
+
}
|
|
33
|
+
var LookupIPLocationInputSchema = z.strictObject({
|
|
34
|
+
"ipAddress": z.string()
|
|
35
|
+
});
|
|
36
|
+
var LookupIPLocationOutputSchema = z.strictObject({
|
|
37
|
+
"country": z.string(),
|
|
38
|
+
"province": z.string(),
|
|
39
|
+
"city": z.string(),
|
|
40
|
+
"district": z.string(),
|
|
41
|
+
"operator": z.string()
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// src/generated/definitions.ts
|
|
45
|
+
var ConnectorID = "alapi";
|
|
46
|
+
var ProviderID = "alapi";
|
|
47
|
+
var LookupIPLocationBranch = {
|
|
48
|
+
Found: "found",
|
|
49
|
+
ProviderRejected: "providerRejected",
|
|
50
|
+
InvalidResponse: "invalidResponse",
|
|
51
|
+
Defect: "defect"
|
|
52
|
+
};
|
|
53
|
+
var LookupIPLocationBranchFound = LookupIPLocationBranch.Found;
|
|
54
|
+
var LookupIPLocationBranchProviderRejected = LookupIPLocationBranch.ProviderRejected;
|
|
55
|
+
var LookupIPLocationBranchInvalidResponse = LookupIPLocationBranch.InvalidResponse;
|
|
56
|
+
var LookupIPLocationBranchDefect = LookupIPLocationBranch.Defect;
|
|
57
|
+
var LookupIPLocationDefinition = {
|
|
58
|
+
operation: { connectorId: ConnectorID, operationId: "lookupIPLocation" },
|
|
59
|
+
branches: [
|
|
60
|
+
{ id: "found", description: "ALAPI returned the IP location." },
|
|
61
|
+
{ id: "providerRejected", description: "ALAPI rejected credentials, quota, or the query.", optional: true },
|
|
62
|
+
{ id: "invalidResponse", description: "ALAPI returned malformed or oversized data.", optional: true },
|
|
63
|
+
{ id: "defect", description: "The local credentials or IP address are invalid.", optional: true }
|
|
64
|
+
],
|
|
65
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: { initialIntervalMs: 2e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 3, totalDurationMs: 3e5 } }
|
|
66
|
+
};
|
|
67
|
+
var LookupIPLocationMetadata = { 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
|
+
LookupIPLocationInputSchema,
|
|
105
|
+
LookupIPLocationOutputSchema,
|
|
106
|
+
ConnectorID,
|
|
107
|
+
ProviderID,
|
|
108
|
+
LookupIPLocationBranch,
|
|
109
|
+
LookupIPLocationBranchFound,
|
|
110
|
+
LookupIPLocationBranchProviderRejected,
|
|
111
|
+
LookupIPLocationBranchInvalidResponse,
|
|
112
|
+
LookupIPLocationBranchDefect,
|
|
113
|
+
LookupIPLocationDefinition,
|
|
114
|
+
LookupIPLocationMetadata,
|
|
115
|
+
Connection,
|
|
116
|
+
newConnection,
|
|
117
|
+
newConnectionWithOperations,
|
|
118
|
+
newProjectConnection
|
|
119
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
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 HTTPS IP 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 response size in bytes as a positive integer. Blank uses the displayed default; increase only if a valid IP lookup response grows beyond 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 token from https://www.alapi.cn/ > 控制台 > 数据中心 > token管理 after enabling IP地址查询. Copy its opaque value; Dex stores it as a credential and sends it in the token header. Blank prevents requests. */
|
|
19
|
+
token: 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
|
+
/** LookupIPLocationInput identifies one public IPv4 address. */
|
|
32
|
+
interface LookupIPLocationInput {
|
|
33
|
+
/** IPAddress is an IPv4 address, not a hostname or CIDR range. */
|
|
34
|
+
"ipAddress": string;
|
|
35
|
+
}
|
|
36
|
+
/** LookupIPLocationOutput contains only coarse location and network fields. */
|
|
37
|
+
interface LookupIPLocationOutput {
|
|
38
|
+
/** Country is the country name when returned by ALAPI. */
|
|
39
|
+
"country": string;
|
|
40
|
+
/** Province is the province name. */
|
|
41
|
+
"province": string;
|
|
42
|
+
/** City is the city name. */
|
|
43
|
+
"city": string;
|
|
44
|
+
/** District is the district name. */
|
|
45
|
+
"district": string;
|
|
46
|
+
/** Operator is the network operator name. */
|
|
47
|
+
"operator": string;
|
|
48
|
+
}
|
|
49
|
+
/** Runtime validator for LookupIPLocationInput. */
|
|
50
|
+
declare const LookupIPLocationInputSchema: z.ZodObject<{
|
|
51
|
+
ipAddress: z.ZodString;
|
|
52
|
+
}, z.core.$strict>;
|
|
53
|
+
/** Runtime validator for LookupIPLocationOutput. */
|
|
54
|
+
declare const LookupIPLocationOutputSchema: z.ZodObject<{
|
|
55
|
+
country: z.ZodString;
|
|
56
|
+
province: z.ZodString;
|
|
57
|
+
city: z.ZodString;
|
|
58
|
+
district: z.ZodString;
|
|
59
|
+
operator: z.ZodString;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
|
|
62
|
+
/** Typed operations supplied by a client or mock. */
|
|
63
|
+
interface Operations {
|
|
64
|
+
/** Invoke lookupIPLocation through this connection. */
|
|
65
|
+
lookupIPLocation(): Query<LookupIPLocationInput, LookupIPLocationOutput>;
|
|
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 LookupIPLocationInput as L, type Operations as O, type LookupIPLocationOutput as a, type Credentials as b, type Config as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, LookupIPLocationInputSchema as g, LookupIPLocationOutputSchema 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 { L as LookupIPLocationInput, a as LookupIPLocationOutput, C as Connection, O as Operations, b as Credentials, c as Config } from './connection-4ZHjh9Jy.js';
|
|
2
|
+
export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as LookupIPLocationInputSchema, h as LookupIPLocationOutputSchema, i as decodeCredentials, j as isCredentialMaterialError, n as newConnection, k as newConnectionWithOperations } from './connection-4ZHjh9Jy.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 = "alapi";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "alapi";
|
|
13
|
+
/** Branch IDs for lookupIPLocation. */
|
|
14
|
+
declare const LookupIPLocationBranch: {
|
|
15
|
+
readonly Found: "found";
|
|
16
|
+
readonly ProviderRejected: "providerRejected";
|
|
17
|
+
readonly InvalidResponse: "invalidResponse";
|
|
18
|
+
readonly Defect: "defect";
|
|
19
|
+
};
|
|
20
|
+
/** ALAPI returned the IP location. */
|
|
21
|
+
declare const LookupIPLocationBranchFound: "found";
|
|
22
|
+
/** ALAPI rejected credentials, quota, or the query. */
|
|
23
|
+
declare const LookupIPLocationBranchProviderRejected: "providerRejected";
|
|
24
|
+
/** ALAPI returned malformed or oversized data. */
|
|
25
|
+
declare const LookupIPLocationBranchInvalidResponse: "invalidResponse";
|
|
26
|
+
/** The local credentials or IP address are invalid. */
|
|
27
|
+
declare const LookupIPLocationBranchDefect: "defect";
|
|
28
|
+
/** Manifest definition for lookupIPLocation. */
|
|
29
|
+
declare const LookupIPLocationDefinition: QueryDefinition;
|
|
30
|
+
/** Manifest metadata for lookupIPLocation. */
|
|
31
|
+
declare const LookupIPLocationMetadata: {
|
|
32
|
+
readonly kind: "query";
|
|
33
|
+
readonly idempotency: "none";
|
|
34
|
+
readonly authorization: "required";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Configuration for the lookupIPLocation connector Step. */
|
|
38
|
+
interface LookupIPLocationStepConfig<StepInput, OperationInput = LookupIPLocationInput, OperationOutput = LookupIPLocationOutput> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
39
|
+
/** Named connection supplying this operation. */
|
|
40
|
+
connection: Connection<{
|
|
41
|
+
lookupIPLocation(): Query<OperationInput, OperationOutput>;
|
|
42
|
+
}>;
|
|
43
|
+
/** Name matching the bound connection. */
|
|
44
|
+
connectionName: string;
|
|
45
|
+
/** ALAPI returned the IP location. */
|
|
46
|
+
found: StepTarget<QueryResult<OperationOutput>>;
|
|
47
|
+
/** ALAPI rejected credentials, quota, or the query. */
|
|
48
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
49
|
+
/** ALAPI returned malformed or oversized data. */
|
|
50
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
51
|
+
/** The local credentials or IP address are invalid. */
|
|
52
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
53
|
+
}
|
|
54
|
+
/** Build the lookupIPLocation Step from a named connection. */
|
|
55
|
+
declare function newLookupIPLocationStep<StepInput, OperationInput = LookupIPLocationInput, OperationOutput = LookupIPLocationOutput>(configuration: LookupIPLocationStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
56
|
+
|
|
57
|
+
/** Open one named ALAPI connection from Dex project configuration. */
|
|
58
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
59
|
+
|
|
60
|
+
/** Send one ALAPI request through a caller-owned transport. */
|
|
61
|
+
type ALAPIRequestSender = (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
62
|
+
/** Optional ALAPI transport dependency for local provider tests. */
|
|
63
|
+
interface ALAPIClientOptions {
|
|
64
|
+
/** Request sender; production uses the Connector SDK transport. */
|
|
65
|
+
send?: ALAPIRequestSender;
|
|
66
|
+
}
|
|
67
|
+
/** Resolve ALAPI credentials for each read-only IP lookup. */
|
|
68
|
+
declare class ALAPIClient {
|
|
69
|
+
readonly credentials: CredentialProvider<Credentials>;
|
|
70
|
+
readonly maxResponseBytes: number;
|
|
71
|
+
readonly timeoutMs: number;
|
|
72
|
+
readonly send: ALAPIRequestSender;
|
|
73
|
+
/** Validate settings without contacting ALAPI. */
|
|
74
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: ALAPIClientOptions);
|
|
75
|
+
/** Bind the public IPv4 location Query. */
|
|
76
|
+
lookupIPLocation(): LookupIPLocationOperation;
|
|
77
|
+
}
|
|
78
|
+
/** Read one public IPv4 address without storing provider credentials in Flow state. */
|
|
79
|
+
declare class LookupIPLocationOperation implements Query<LookupIPLocationInput, LookupIPLocationOutput> {
|
|
80
|
+
private readonly client;
|
|
81
|
+
/** Bind an authenticated ALAPI client. */
|
|
82
|
+
constructor(client: ALAPIClient);
|
|
83
|
+
/** Return the stable generated Query contract. */
|
|
84
|
+
definition(): QueryDefinition;
|
|
85
|
+
/** Send one provider request and classify its result. */
|
|
86
|
+
invoke(call: Call, input: LookupIPLocationInput): Promise<QueryAttempt<LookupIPLocationOutput>>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { ALAPIClient, type ALAPIClientOptions, type ALAPIRequestSender, Config, Connection, ConnectorID, Credentials, LookupIPLocationBranch, LookupIPLocationBranchDefect, LookupIPLocationBranchFound, LookupIPLocationBranchInvalidResponse, LookupIPLocationBranchProviderRejected, LookupIPLocationDefinition, LookupIPLocationInput, LookupIPLocationMetadata, LookupIPLocationOperation, LookupIPLocationOutput, type LookupIPLocationStepConfig, ProviderID, newLookupIPLocationStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
6
|
+
LookupIPLocationBranch,
|
|
7
|
+
LookupIPLocationBranchDefect,
|
|
8
|
+
LookupIPLocationBranchFound,
|
|
9
|
+
LookupIPLocationBranchInvalidResponse,
|
|
10
|
+
LookupIPLocationBranchProviderRejected,
|
|
11
|
+
LookupIPLocationDefinition,
|
|
12
|
+
LookupIPLocationInputSchema,
|
|
13
|
+
LookupIPLocationMetadata,
|
|
14
|
+
LookupIPLocationOutputSchema,
|
|
15
|
+
ProviderID,
|
|
16
|
+
decodeCredentials,
|
|
17
|
+
isCredentialMaterialError,
|
|
18
|
+
newConnection,
|
|
19
|
+
newConnectionWithOperations,
|
|
20
|
+
newProjectConnection
|
|
21
|
+
} from "./chunk-5QZHXYLQ.js";
|
|
22
|
+
|
|
23
|
+
// src/generated/steps.ts
|
|
24
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
25
|
+
function newLookupIPLocationStep(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.lookupIPLocation(), 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 as SecretString2 } from "@superdurable/connectors-sdk";
|
|
38
|
+
import { z } from "zod";
|
|
39
|
+
|
|
40
|
+
// src/client.ts
|
|
41
|
+
import { isIP } from "net";
|
|
42
|
+
import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
43
|
+
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest } from "@superdurable/connectors-sdk/providerhttp";
|
|
44
|
+
var endpoint = "https://v3.alapi.cn/api/ip";
|
|
45
|
+
var emptyOutput = { country: "", province: "", city: "", district: "", operator: "" };
|
|
46
|
+
var ALAPIClient = class {
|
|
47
|
+
/** Validate settings without contacting ALAPI. */
|
|
48
|
+
constructor(config, credentials, options = {}) {
|
|
49
|
+
this.credentials = credentials;
|
|
50
|
+
if (!credentials) throw new TypeError("ALAPI credential source is required");
|
|
51
|
+
this.timeoutMs = config.timeoutMs ?? 1e4;
|
|
52
|
+
this.maxResponseBytes = config.maxResponseBytes ?? 65536;
|
|
53
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0 || this.maxResponseBytes > 16 * 1024 * 1024) {
|
|
54
|
+
throw new TypeError("ALAPI configuration is invalid");
|
|
55
|
+
}
|
|
56
|
+
this.send = options.send ?? sendProviderRequest;
|
|
57
|
+
}
|
|
58
|
+
credentials;
|
|
59
|
+
maxResponseBytes;
|
|
60
|
+
timeoutMs;
|
|
61
|
+
send;
|
|
62
|
+
/** Bind the public IPv4 location Query. */
|
|
63
|
+
lookupIPLocation() {
|
|
64
|
+
return new LookupIPLocationOperation(this);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var LookupIPLocationOperation = class {
|
|
68
|
+
/** Bind an authenticated ALAPI client. */
|
|
69
|
+
constructor(client) {
|
|
70
|
+
this.client = client;
|
|
71
|
+
}
|
|
72
|
+
client;
|
|
73
|
+
/** Return the stable generated Query contract. */
|
|
74
|
+
definition() {
|
|
75
|
+
return LookupIPLocationDefinition;
|
|
76
|
+
}
|
|
77
|
+
/** Send one provider request and classify its result. */
|
|
78
|
+
async invoke(call, input) {
|
|
79
|
+
const address = publicIPv4(input.ipAddress);
|
|
80
|
+
if (!address) return branch("defect", "VALIDATION", "ALAPI requires one public IPv4 address");
|
|
81
|
+
let token;
|
|
82
|
+
try {
|
|
83
|
+
const resolved = await this.client.credentials.resolve(call, call.context.cancellationSignal);
|
|
84
|
+
token = resolved.token instanceof SecretString ? resolved.token.reveal() : "";
|
|
85
|
+
} catch {
|
|
86
|
+
return branch("defect", "AUTHENTICATION", "ALAPI credentials are unavailable or invalid");
|
|
87
|
+
}
|
|
88
|
+
if (!token || token.length > 1024 || !/^[!-~]+$/.test(token) || !isHeaderSafeCredential(token)) {
|
|
89
|
+
return branch("defect", "AUTHENTICATION", "ALAPI credentials are unavailable or invalid");
|
|
90
|
+
}
|
|
91
|
+
let response;
|
|
92
|
+
try {
|
|
93
|
+
response = await this.client.send({
|
|
94
|
+
url: endpoint,
|
|
95
|
+
method: "POST",
|
|
96
|
+
headers: { Accept: "application/json", "Content-Type": "application/json", token },
|
|
97
|
+
body: Buffer.from(JSON.stringify({ ip: address }), "utf8"),
|
|
98
|
+
maxResponseBytes: this.client.maxResponseBytes,
|
|
99
|
+
maxErrorResponseBytes: 4096,
|
|
100
|
+
timeoutMs: this.client.timeoutMs,
|
|
101
|
+
addressPolicy: "publicHTTPS",
|
|
102
|
+
signal: call.context.cancellationSignal
|
|
103
|
+
});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (error instanceof BodyTooLargeError && error.status === 200) return branch("invalidResponse", "RESPONSE_TOO_LARGE", "ALAPI response exceeded the configured limit");
|
|
106
|
+
return retry("AVAILABILITY", "ALAPI lookup request failed");
|
|
107
|
+
}
|
|
108
|
+
const retryAfterHeader = response.headers["retry-after"];
|
|
109
|
+
const retryAfterMs = parseRetryAfter(Array.isArray(retryAfterHeader) ? retryAfterHeader[0] ?? "" : retryAfterHeader ?? "");
|
|
110
|
+
if (response.status === 429) return retry("RATE_LIMIT", "ALAPI rate limited the lookup", retryAfterMs);
|
|
111
|
+
if (response.status === 408 || response.status >= 500) return retry("AVAILABILITY", "ALAPI lookup service is temporarily unavailable", retryAfterMs);
|
|
112
|
+
if (response.status !== 200) return branch("providerRejected", response.status === 401 ? "AUTHENTICATION" : response.status === 403 ? "AUTHORIZATION" : "PROVIDER_REJECTION", `ALAPI rejected lookup with HTTP ${response.status}`);
|
|
113
|
+
let document;
|
|
114
|
+
try {
|
|
115
|
+
document = lowercaseFields(JSON.parse(Buffer.from(response.body).toString("utf8")));
|
|
116
|
+
} catch {
|
|
117
|
+
return branch("invalidResponse", "PROTOCOL", "ALAPI returned invalid lookup data");
|
|
118
|
+
}
|
|
119
|
+
if (!isRecord(document) || !Number.isInteger(document.code) || typeof document.success !== "boolean") return branch("invalidResponse", "PROTOCOL", "ALAPI returned invalid lookup data");
|
|
120
|
+
const data = lowercaseFields(document.data);
|
|
121
|
+
if (data != null && (!isRecord(data) || ["country", "province", "city", "district", "isp"].some((field) => data[field] != null && typeof data[field] !== "string"))) {
|
|
122
|
+
return branch("invalidResponse", "PROTOCOL", "ALAPI returned invalid lookup data");
|
|
123
|
+
}
|
|
124
|
+
const code = document.code;
|
|
125
|
+
if (code === 429) return retry("RATE_LIMIT", "ALAPI rate limited the lookup", retryAfterMs);
|
|
126
|
+
if (code !== 200 || !document.success) {
|
|
127
|
+
const kind = [10001, 10002, 10008].includes(code) ? "AUTHENTICATION" : [10004, 10009].includes(code) ? "AUTHORIZATION" : [10005, 10010].includes(code) ? "QUOTA_EXHAUSTED" : "PROVIDER_REJECTION";
|
|
128
|
+
return branch("providerRejected", kind, `ALAPI rejected lookup with code ${code}`);
|
|
129
|
+
}
|
|
130
|
+
if (!isRecord(data) || typeof data.country !== "string" || !data.country.trim() || typeof data.city !== "string" || !data.city.trim()) {
|
|
131
|
+
return branch("invalidResponse", "PROTOCOL", "ALAPI returned incomplete location data");
|
|
132
|
+
}
|
|
133
|
+
return newQueryBranch("found", { country: data.country, province: String(data.province ?? ""), city: data.city, district: String(data.district ?? ""), operator: String(data.isp ?? "") });
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
function isRecord(value) {
|
|
137
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
138
|
+
}
|
|
139
|
+
function lowercaseFields(value) {
|
|
140
|
+
return isRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, field]) => [key.toLowerCase(), field])) : value;
|
|
141
|
+
}
|
|
142
|
+
function publicIPv4(value) {
|
|
143
|
+
if (typeof value !== "string" || value.includes("%")) return void 0;
|
|
144
|
+
const version = isIP(value);
|
|
145
|
+
let address = value;
|
|
146
|
+
if (version === 6) {
|
|
147
|
+
const mapped = /^\[::ffff:([a-f0-9]+):([a-f0-9]+)\]$/.exec(new URL("http://[" + value + "]").hostname);
|
|
148
|
+
if (!mapped) return void 0;
|
|
149
|
+
const high = parseInt(mapped[1], 16);
|
|
150
|
+
const low = parseInt(mapped[2], 16);
|
|
151
|
+
address = [high >>> 8, high & 255, low >>> 8, low & 255].join(".");
|
|
152
|
+
} else if (version !== 4) return void 0;
|
|
153
|
+
const parts = address.split(".");
|
|
154
|
+
const first = Number(parts[0]);
|
|
155
|
+
const second = Number(parts[1]);
|
|
156
|
+
return !parts.every((part) => part === "0") && first !== 10 && first !== 127 && !(first >= 224 && first <= 239) && !(first === 169 && second === 254) && !(first === 172 && second >= 16 && second <= 31) && !(first === 192 && second === 168) ? address : void 0;
|
|
157
|
+
}
|
|
158
|
+
function failure(kind, message) {
|
|
159
|
+
return { provider: "alapi", operation: "lookupIPLocation", kind, message };
|
|
160
|
+
}
|
|
161
|
+
function branch(id, kind, message) {
|
|
162
|
+
return newQueryBranch(id, emptyOutput, {}, failure(kind, message));
|
|
163
|
+
}
|
|
164
|
+
function retry(kind, message, delayMs = 0) {
|
|
165
|
+
return newQueryRetry(failure(kind, message), delayMs);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/project.ts
|
|
169
|
+
function newProjectConnection2(project, connectionName) {
|
|
170
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
171
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "alapi" && entry.connectionName === name);
|
|
172
|
+
if (!selected) throw new TypeError("ALAPI project connection is not configured");
|
|
173
|
+
const fields = z.strictObject({ timeout: z.union([z.string(), z.number().int()]).optional(), maxResponseBytes: z.number().int().optional() }).parse(selected.configuration);
|
|
174
|
+
const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
|
|
175
|
+
const config = {
|
|
176
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
177
|
+
...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
|
|
178
|
+
};
|
|
179
|
+
const credentials = {
|
|
180
|
+
async resolve(_call, signal) {
|
|
181
|
+
const privateFields = await loadedProject.resolveCredential("alapi", name, signal);
|
|
182
|
+
if (typeof privateFields.token !== "string") throw new TypeError("ALAPI token is unavailable");
|
|
183
|
+
return { token: new SecretString2(privateFields.token) };
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
return new ALAPIClient(config, credentials);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function parseDurationMilliseconds(value) {
|
|
190
|
+
let remaining = value;
|
|
191
|
+
let milliseconds = 0;
|
|
192
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
193
|
+
while (remaining) {
|
|
194
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
195
|
+
if (!part) throw new TypeError("ALAPI timeout must be a positive Go duration");
|
|
196
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
197
|
+
remaining = remaining.slice(part[0].length);
|
|
198
|
+
}
|
|
199
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("ALAPI timeout must resolve to positive whole milliseconds");
|
|
200
|
+
return milliseconds;
|
|
201
|
+
}
|
|
202
|
+
export {
|
|
203
|
+
ALAPIClient,
|
|
204
|
+
ConfigSchema,
|
|
205
|
+
Connection,
|
|
206
|
+
ConnectorID,
|
|
207
|
+
CredentialMaterialError,
|
|
208
|
+
LookupIPLocationBranch,
|
|
209
|
+
LookupIPLocationBranchDefect,
|
|
210
|
+
LookupIPLocationBranchFound,
|
|
211
|
+
LookupIPLocationBranchInvalidResponse,
|
|
212
|
+
LookupIPLocationBranchProviderRejected,
|
|
213
|
+
LookupIPLocationDefinition,
|
|
214
|
+
LookupIPLocationInputSchema,
|
|
215
|
+
LookupIPLocationMetadata,
|
|
216
|
+
LookupIPLocationOperation,
|
|
217
|
+
LookupIPLocationOutputSchema,
|
|
218
|
+
ProviderID,
|
|
219
|
+
decodeCredentials,
|
|
220
|
+
isCredentialMaterialError,
|
|
221
|
+
newConnection,
|
|
222
|
+
newConnectionWithOperations,
|
|
223
|
+
newLookupIPLocationStep,
|
|
224
|
+
newProjectConnection2 as newProjectConnection
|
|
225
|
+
};
|
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, L as LookupIPLocationInput, a as LookupIPLocationOutput } from './connection-4ZHjh9Jy.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for LookupIPLocationInput in scripted cases. */
|
|
7
|
+
declare const emptyLookupIPLocationInput: LookupIPLocationInput;
|
|
8
|
+
/** Go zero value for LookupIPLocationOutput in scripted cases. */
|
|
9
|
+
declare const emptyLookupIPLocationOutput: LookupIPLocationOutput;
|
|
10
|
+
/** Script the found branch. */
|
|
11
|
+
declare function lookupIPLocationFound(value: LookupIPLocationOutput, failure?: Failure): Case<LookupIPLocationOutput>;
|
|
12
|
+
/** Script the providerRejected branch. */
|
|
13
|
+
declare function lookupIPLocationProviderRejected(value: LookupIPLocationOutput, failure?: Failure): Case<LookupIPLocationOutput>;
|
|
14
|
+
/** Script the invalidResponse branch. */
|
|
15
|
+
declare function lookupIPLocationInvalidResponse(value: LookupIPLocationOutput, failure?: Failure): Case<LookupIPLocationOutput>;
|
|
16
|
+
/** Script the defect branch. */
|
|
17
|
+
declare function lookupIPLocationDefect(value: LookupIPLocationOutput, failure?: Failure): Case<LookupIPLocationOutput>;
|
|
18
|
+
/** Script a safe retry of lookupIPLocation. */
|
|
19
|
+
declare function lookupIPLocationRetry(failure: Failure, retryAfterMs?: number): Case<LookupIPLocationOutput>;
|
|
20
|
+
/** Manifest scenario shenzhen for lookupIPLocation. */
|
|
21
|
+
declare function lookupIPLocationShenzhen(): Case<LookupIPLocationOutput>;
|
|
22
|
+
/** Default lookupIPLocation scenario. */
|
|
23
|
+
declare function lookupIPLocationDefault(): Case<LookupIPLocationOutput>;
|
|
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
|
+
lookupIPLocation(): MockQuery<LookupIPLocationInput, LookupIPLocationOutput>;
|
|
30
|
+
assertNoFailures(): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { GeneratedMock, GeneratedMock as Mock, emptyLookupIPLocationInput, emptyLookupIPLocationOutput, lookupIPLocationDefault, lookupIPLocationDefect, lookupIPLocationFound, lookupIPLocationInvalidResponse, lookupIPLocationProviderRejected, lookupIPLocationRetry, lookupIPLocationShenzhen };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LookupIPLocationDefinition,
|
|
3
|
+
LookupIPLocationInputSchema,
|
|
4
|
+
LookupIPLocationOutputSchema,
|
|
5
|
+
ProviderID,
|
|
6
|
+
newConnectionWithOperations
|
|
7
|
+
} from "./chunk-5QZHXYLQ.js";
|
|
8
|
+
|
|
9
|
+
// src/generated/mock.ts
|
|
10
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
11
|
+
var emptyLookupIPLocationInput = LookupIPLocationInputSchema.parse({
|
|
12
|
+
"ipAddress": ""
|
|
13
|
+
});
|
|
14
|
+
var emptyLookupIPLocationOutput = LookupIPLocationOutputSchema.parse({
|
|
15
|
+
"country": "",
|
|
16
|
+
"province": "",
|
|
17
|
+
"city": "",
|
|
18
|
+
"district": "",
|
|
19
|
+
"operator": ""
|
|
20
|
+
});
|
|
21
|
+
function lookupIPLocationFound(value, failure) {
|
|
22
|
+
return branchCase("found", value, failure);
|
|
23
|
+
}
|
|
24
|
+
function lookupIPLocationProviderRejected(value, failure) {
|
|
25
|
+
return branchCase("providerRejected", value, failure);
|
|
26
|
+
}
|
|
27
|
+
function lookupIPLocationInvalidResponse(value, failure) {
|
|
28
|
+
return branchCase("invalidResponse", value, failure);
|
|
29
|
+
}
|
|
30
|
+
function lookupIPLocationDefect(value, failure) {
|
|
31
|
+
return branchCase("defect", value, failure);
|
|
32
|
+
}
|
|
33
|
+
function lookupIPLocationRetry(failure, retryAfterMs = 0) {
|
|
34
|
+
return retryCase(failure, retryAfterMs);
|
|
35
|
+
}
|
|
36
|
+
function lookupIPLocationShenzhen() {
|
|
37
|
+
const value = LookupIPLocationOutputSchema.parse({ "city": "\u6DF1\u5733", "country": "\u4E2D\u56FD", "district": "\u9F99\u5C97\u533A", "operator": "\u79FB\u52A8", "province": "\u5E7F\u4E1C" });
|
|
38
|
+
return branchCase("found", value);
|
|
39
|
+
}
|
|
40
|
+
function lookupIPLocationDefault() {
|
|
41
|
+
return lookupIPLocationShenzhen();
|
|
42
|
+
}
|
|
43
|
+
var GeneratedMock = class {
|
|
44
|
+
#lookupIPLocation;
|
|
45
|
+
#connection;
|
|
46
|
+
constructor(connectionName) {
|
|
47
|
+
this.#lookupIPLocation = newQuery(LookupIPLocationDefinition).default(lookupIPLocationDefault());
|
|
48
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
49
|
+
}
|
|
50
|
+
connection() {
|
|
51
|
+
return this.#connection;
|
|
52
|
+
}
|
|
53
|
+
lookupIPLocation() {
|
|
54
|
+
return this.#lookupIPLocation;
|
|
55
|
+
}
|
|
56
|
+
assertNoFailures() {
|
|
57
|
+
this.#lookupIPLocation.assertNoFailures();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
GeneratedMock,
|
|
62
|
+
GeneratedMock as Mock,
|
|
63
|
+
emptyLookupIPLocationInput,
|
|
64
|
+
emptyLookupIPLocationOutput,
|
|
65
|
+
lookupIPLocationDefault,
|
|
66
|
+
lookupIPLocationDefect,
|
|
67
|
+
lookupIPLocationFound,
|
|
68
|
+
lookupIPLocationInvalidResponse,
|
|
69
|
+
lookupIPLocationProviderRejected,
|
|
70
|
+
lookupIPLocationRetry,
|
|
71
|
+
lookupIPLocationShenzhen
|
|
72
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-alapi",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Alapi connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/alapi/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/ip-location/worker.ts",
|
|
43
|
+
"example:start": "tsx examples/ip-location/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
|
+
}
|