@superdurable/connector-chuanglan 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 +10 -2
- package/dex-connector.json +52 -0
- package/dist/chunk-VQ37BYHS.js +117 -0
- package/dist/connection-DB1-91Dj.d.ts +70 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +221 -0
- package/dist/mock.d.ts +33 -0
- package/dist/mock.js +66 -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,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Chuanglan 253 connector for Dex TypeScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@superdurable/connector-chuanglan` implements the read-only `getBalance` Query. It sends `POST https://smssh1.253.com/msg/balance/json` with the connected domestic SMS API account and password in a JSON request body, following the [official balance API](https://doc.chuanglan.com/docs/4XVHFKRMBD6M4T9C). It returns only `{remainingMessages}`; credentials and provider error text are excluded from Flow state, results, receipts, and logs.
|
|
4
|
+
|
|
5
|
+
Create a Dex Web connection named `chuanglan`. Open <https://zz.253.com>, then **产品概览 > API 接口信息** and copy the domestic SMS API account and API password into the two secret connection fields. Set `baseUrl` to the HTTPS origin assigned to that account when it differs from the East China default. The connection guide also covers outbound IP allowlisting. `timeout` and `maxResponseBytes` have safe defaults and can be left blank.
|
|
6
|
+
|
|
7
|
+
A successful provider `code` of numeric or string `0` selects `fetched` with a nonnegative count. A definite provider rejection selects the optional `providerRejected` branch. Malformed or oversized responses select `invalidResponse`; missing credentials select `defect` without a request. HTTP 408, 429, 5xx, and transport errors Retry through Dex. Unwired optional branches fail the Flow.
|
|
8
|
+
|
|
9
|
+
[Run the balance Flow](examples/balance/README.md). Its real Dex integration test exercises a provider 503 followed by success and verifies persistence. Eleven Go-recorded [conformance scenarios](../../../conformance/connectors/chuanglan/scenarios.json) check exact requests and outcomes. A real Chuanglan account and live balance lookup have not been verified.
|
|
10
|
+
|
|
11
|
+
The TypeScript `remainingMessages` field uses a JavaScript number. Counts above `Number.MAX_SAFE_INTEGER` select `invalidResponse` to prevent rounding.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "chuanglan",
|
|
3
|
+
"releaseTag": "connectors/chuanglan/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-chuanglan",
|
|
7
|
+
"version": "0.1.1"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newGetBalanceStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "getBalance",
|
|
14
|
+
"inputType": "GetBalanceInput",
|
|
15
|
+
"description": "Read the number of domestic SMS messages remaining for the connected API account.",
|
|
16
|
+
"fields": {
|
|
17
|
+
"stepType": "stepType",
|
|
18
|
+
"annotations": "annotations",
|
|
19
|
+
"connectionName": "connectionName",
|
|
20
|
+
"resultAttribute": "resultAttribute"
|
|
21
|
+
},
|
|
22
|
+
"branches": [
|
|
23
|
+
{
|
|
24
|
+
"id": "fetched",
|
|
25
|
+
"field": "fetched",
|
|
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": "GetBalanceInput has no fields because the connected domestic SMS account identifies the balance.",
|
|
47
|
+
"properties": {},
|
|
48
|
+
"type": "object"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -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
|
+
"baseUrl": z.string().optional(),
|
|
6
|
+
"timeoutMs": z.number().int().optional(),
|
|
7
|
+
"maxResponseBytes": z.number().int().optional()
|
|
8
|
+
});
|
|
9
|
+
var CredentialMaterialError = class extends TypeError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "CredentialMaterialError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
16
|
+
"project credential decoding failed",
|
|
17
|
+
"shared project credential decoding failed",
|
|
18
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
19
|
+
]);
|
|
20
|
+
function isCredentialMaterialError(error) {
|
|
21
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
22
|
+
}
|
|
23
|
+
function decodeCredentials(value) {
|
|
24
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
25
|
+
const fields = value;
|
|
26
|
+
const allowed = /* @__PURE__ */ new Set(["account", "password"]);
|
|
27
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
28
|
+
if (fields["account"] != null && !(typeof fields["account"] === "string")) throw new CredentialMaterialError("credential account has an invalid type");
|
|
29
|
+
if (fields["password"] != null && !(typeof fields["password"] === "string")) throw new CredentialMaterialError("credential password has an invalid type");
|
|
30
|
+
const credentials = {};
|
|
31
|
+
if (!fields["account"]) throw new CredentialMaterialError("credential account is required");
|
|
32
|
+
credentials.account = new SecretString(fields["account"] ?? "");
|
|
33
|
+
if (!fields["password"]) throw new CredentialMaterialError("credential password is required");
|
|
34
|
+
credentials.password = new SecretString(fields["password"] ?? "");
|
|
35
|
+
return credentials;
|
|
36
|
+
}
|
|
37
|
+
var GetBalanceInputSchema = z.strictObject({});
|
|
38
|
+
var GetBalanceOutputSchema = z.strictObject({
|
|
39
|
+
"remainingMessages": z.number().int()
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// src/generated/definitions.ts
|
|
43
|
+
var ConnectorID = "chuanglan";
|
|
44
|
+
var ProviderID = "chuanglan";
|
|
45
|
+
var GetBalanceBranch = {
|
|
46
|
+
Fetched: "fetched",
|
|
47
|
+
ProviderRejected: "providerRejected",
|
|
48
|
+
InvalidResponse: "invalidResponse",
|
|
49
|
+
Defect: "defect"
|
|
50
|
+
};
|
|
51
|
+
var GetBalanceBranchFetched = GetBalanceBranch.Fetched;
|
|
52
|
+
var GetBalanceBranchProviderRejected = GetBalanceBranch.ProviderRejected;
|
|
53
|
+
var GetBalanceBranchInvalidResponse = GetBalanceBranch.InvalidResponse;
|
|
54
|
+
var GetBalanceBranchDefect = GetBalanceBranch.Defect;
|
|
55
|
+
var GetBalanceDefinition = {
|
|
56
|
+
operation: { connectorId: ConnectorID, operationId: "getBalance" },
|
|
57
|
+
branches: [
|
|
58
|
+
{ id: "fetched", description: "Chuanglan returned the remaining SMS count." },
|
|
59
|
+
{ id: "providerRejected", description: "Chuanglan rejected the account, password, node, or request.", optional: true },
|
|
60
|
+
{ id: "invalidResponse", description: "Chuanglan returned malformed or oversized data.", optional: true },
|
|
61
|
+
{ id: "defect", description: "Connection credentials are missing or invalid.", optional: true }
|
|
62
|
+
],
|
|
63
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
64
|
+
};
|
|
65
|
+
var GetBalanceMetadata = { 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
|
+
GetBalanceInputSchema,
|
|
103
|
+
GetBalanceOutputSchema,
|
|
104
|
+
ConnectorID,
|
|
105
|
+
ProviderID,
|
|
106
|
+
GetBalanceBranch,
|
|
107
|
+
GetBalanceBranchFetched,
|
|
108
|
+
GetBalanceBranchProviderRejected,
|
|
109
|
+
GetBalanceBranchInvalidResponse,
|
|
110
|
+
GetBalanceBranchDefect,
|
|
111
|
+
GetBalanceDefinition,
|
|
112
|
+
GetBalanceMetadata,
|
|
113
|
+
Connection,
|
|
114
|
+
newConnection,
|
|
115
|
+
newConnectionWithOperations,
|
|
116
|
+
newProjectConnection
|
|
117
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
/** HTTPS origin for the domestic SMS account node, without a path. Leave blank for the displayed East China node; override with the account-assigned node shown at https://zz.253.com in the SMS API interface settings. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Maximum time for one balance lookup as a positive Go duration such as 5s or 1m. Leave blank for the displayed default; increase only for a slow approved proxy. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Maximum balance response size in bytes as a positive integer. Leave blank for the displayed default; raise only if a valid provider response exceeds it. */
|
|
11
|
+
maxResponseBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Runtime schema for manifest configuration. */
|
|
14
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
15
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
16
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/** Private connector credentials resolved by the host. */
|
|
20
|
+
interface Credentials {
|
|
21
|
+
/** Secret domestic SMS API account from https://zz.253.com > 产品概览 > API 接口信息. Copy its exact account identifier, such as an N-prefixed ID; blank prevents requests. This is sent in the JSON request body. */
|
|
22
|
+
account: SecretString;
|
|
23
|
+
/** Secret API password for the same account from https://zz.253.com > 产品概览 > API 接口信息. Copy the exact password; blank prevents requests. This is sent in the JSON request body, never Flow input. */
|
|
24
|
+
password: SecretString;
|
|
25
|
+
}
|
|
26
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
27
|
+
declare class CredentialMaterialError extends TypeError {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
31
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
32
|
+
/** Decode private credential fields for the connector. */
|
|
33
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
34
|
+
/** Host-owned source of private connector credentials. */
|
|
35
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
36
|
+
/** GetBalanceInput has no fields because the connected domestic SMS account identifies the balance. */
|
|
37
|
+
interface GetBalanceInput {
|
|
38
|
+
}
|
|
39
|
+
/** GetBalanceOutput reports the remaining number of domestic SMS messages. */
|
|
40
|
+
interface GetBalanceOutput {
|
|
41
|
+
/** RemainingMessages is the nonnegative message count returned by Chuanglan. */
|
|
42
|
+
"remainingMessages": number;
|
|
43
|
+
}
|
|
44
|
+
/** Runtime validator for GetBalanceInput. */
|
|
45
|
+
declare const GetBalanceInputSchema: z.ZodObject<{}, z.core.$strict>;
|
|
46
|
+
/** Runtime validator for GetBalanceOutput. */
|
|
47
|
+
declare const GetBalanceOutputSchema: z.ZodObject<{
|
|
48
|
+
remainingMessages: z.ZodNumber;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
|
|
51
|
+
/** Typed operations supplied by a client or mock. */
|
|
52
|
+
interface Operations {
|
|
53
|
+
/** Invoke getBalance through this connection. */
|
|
54
|
+
getBalance(): Query<GetBalanceInput, GetBalanceOutput>;
|
|
55
|
+
}
|
|
56
|
+
/** Named connector connection kept outside Flow state. */
|
|
57
|
+
declare class Connection<BoundOperations = Operations> {
|
|
58
|
+
/** Stable provider and connection name. */
|
|
59
|
+
readonly reference: ConnectionRef;
|
|
60
|
+
/** Bound provider operations. */
|
|
61
|
+
readonly operations: BoundOperations;
|
|
62
|
+
/** Validate a reference and bind operations. */
|
|
63
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
64
|
+
}
|
|
65
|
+
/** Bind a client to a named connection. */
|
|
66
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
67
|
+
/** Bind scripted operations to a named connection. */
|
|
68
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
69
|
+
|
|
70
|
+
export { Connection as C, type GetBalanceInput as G, type Operations as O, type GetBalanceOutput as a, type Config as b, type Credentials as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, GetBalanceInputSchema as g, GetBalanceOutputSchema as h, decodeCredentials as i, isCredentialMaterialError as j, newConnectionWithOperations as k, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { G as GetBalanceInput, a as GetBalanceOutput, C as Connection, b as Config, c as Credentials, O as Operations } from './connection-DB1-91Dj.js';
|
|
2
|
+
export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as GetBalanceInputSchema, h as GetBalanceOutputSchema, i as decodeCredentials, j as isCredentialMaterialError, n as newConnection, k as newConnectionWithOperations } from './connection-DB1-91Dj.js';
|
|
3
|
+
import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt, Failure } 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 = "chuanglan";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "chuanglan";
|
|
13
|
+
/** Branch IDs for getBalance. */
|
|
14
|
+
declare const GetBalanceBranch: {
|
|
15
|
+
readonly Fetched: "fetched";
|
|
16
|
+
readonly ProviderRejected: "providerRejected";
|
|
17
|
+
readonly InvalidResponse: "invalidResponse";
|
|
18
|
+
readonly Defect: "defect";
|
|
19
|
+
};
|
|
20
|
+
/** Chuanglan returned the remaining SMS count. */
|
|
21
|
+
declare const GetBalanceBranchFetched: "fetched";
|
|
22
|
+
/** Chuanglan rejected the account, password, node, or request. */
|
|
23
|
+
declare const GetBalanceBranchProviderRejected: "providerRejected";
|
|
24
|
+
/** Chuanglan returned malformed or oversized data. */
|
|
25
|
+
declare const GetBalanceBranchInvalidResponse: "invalidResponse";
|
|
26
|
+
/** Connection credentials are missing or invalid. */
|
|
27
|
+
declare const GetBalanceBranchDefect: "defect";
|
|
28
|
+
/** Manifest definition for getBalance. */
|
|
29
|
+
declare const GetBalanceDefinition: QueryDefinition;
|
|
30
|
+
/** Manifest metadata for getBalance. */
|
|
31
|
+
declare const GetBalanceMetadata: {
|
|
32
|
+
readonly kind: "query";
|
|
33
|
+
readonly idempotency: "none";
|
|
34
|
+
readonly authorization: "required";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Configuration for the getBalance connector Step. */
|
|
38
|
+
interface GetBalanceStepConfig<StepInput, OperationInput = GetBalanceInput, OperationOutput = GetBalanceOutput> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
39
|
+
/** Named connection supplying this operation. */
|
|
40
|
+
connection: Connection<{
|
|
41
|
+
getBalance(): Query<OperationInput, OperationOutput>;
|
|
42
|
+
}>;
|
|
43
|
+
/** Name matching the bound connection. */
|
|
44
|
+
connectionName: string;
|
|
45
|
+
/** Chuanglan returned the remaining SMS count. */
|
|
46
|
+
fetched: StepTarget<QueryResult<OperationOutput>>;
|
|
47
|
+
/** Chuanglan rejected the account, password, node, or request. */
|
|
48
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
49
|
+
/** Chuanglan returned malformed or oversized data. */
|
|
50
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
51
|
+
/** Connection credentials are missing or invalid. */
|
|
52
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
53
|
+
}
|
|
54
|
+
/** Build the getBalance Step from a named connection. */
|
|
55
|
+
declare function newGetBalanceStep<StepInput, OperationInput = GetBalanceInput, OperationOutput = GetBalanceOutput>(configuration: GetBalanceStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
56
|
+
|
|
57
|
+
/** Provider HTTP sender, injectable for deterministic tests. */
|
|
58
|
+
type ChuanglanRequestSender = (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
59
|
+
/** Client dependencies for tests and approved transports. */
|
|
60
|
+
interface ChuanglanClientOptions {
|
|
61
|
+
/** SDK transport when omitted. */ send?: ChuanglanRequestSender;
|
|
62
|
+
/** Clock used to interpret HTTP Retry-After dates. */ now?: () => Date;
|
|
63
|
+
}
|
|
64
|
+
/** Authenticated Chuanglan domestic SMS balance client. */
|
|
65
|
+
declare class ChuanglanClient {
|
|
66
|
+
private readonly credentials;
|
|
67
|
+
private readonly baseURL;
|
|
68
|
+
private readonly timeoutMs;
|
|
69
|
+
private readonly maxResponseBytes;
|
|
70
|
+
private readonly send;
|
|
71
|
+
private readonly now;
|
|
72
|
+
/** Validate settings without contacting the provider; credentials resolve for each call. */
|
|
73
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: ChuanglanClientOptions);
|
|
74
|
+
/** Bind the read-only getBalance Query. */ getBalance(): GetBalanceOperation;
|
|
75
|
+
/** Resolve private credentials and send one bounded balance request. */
|
|
76
|
+
lookup(call: Call): Promise<{
|
|
77
|
+
response: ProviderResponse;
|
|
78
|
+
} | {
|
|
79
|
+
failure: Failure;
|
|
80
|
+
retry?: true;
|
|
81
|
+
retryAfterMs?: number;
|
|
82
|
+
branch?: string;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
/** Read the number of domestic SMS messages remaining. */
|
|
86
|
+
declare class GetBalanceOperation implements Query<GetBalanceInput, GetBalanceOutput> {
|
|
87
|
+
private readonly client;
|
|
88
|
+
/** Bind the provider client. */ constructor(client: ChuanglanClient);
|
|
89
|
+
/** Generated Query definition. */ definition(): QueryDefinition;
|
|
90
|
+
/** Send one read-only request and classify its result. */
|
|
91
|
+
invoke(call: Call, input: GetBalanceInput): Promise<QueryAttempt<GetBalanceOutput>>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Bind a static Chuanglan connection from Dex project configuration. */
|
|
95
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string, options?: ChuanglanClientOptions): Connection<Operations>;
|
|
96
|
+
|
|
97
|
+
export { ChuanglanClient, type ChuanglanClientOptions, type ChuanglanRequestSender, Config, Connection, ConnectorID, Credentials, GetBalanceBranch, GetBalanceBranchDefect, GetBalanceBranchFetched, GetBalanceBranchInvalidResponse, GetBalanceBranchProviderRejected, GetBalanceDefinition, GetBalanceInput, GetBalanceMetadata, GetBalanceOperation, GetBalanceOutput, type GetBalanceStepConfig, ProviderID, newGetBalanceStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
6
|
+
GetBalanceBranch,
|
|
7
|
+
GetBalanceBranchDefect,
|
|
8
|
+
GetBalanceBranchFetched,
|
|
9
|
+
GetBalanceBranchInvalidResponse,
|
|
10
|
+
GetBalanceBranchProviderRejected,
|
|
11
|
+
GetBalanceDefinition,
|
|
12
|
+
GetBalanceInputSchema,
|
|
13
|
+
GetBalanceMetadata,
|
|
14
|
+
GetBalanceOutputSchema,
|
|
15
|
+
ProviderID,
|
|
16
|
+
decodeCredentials,
|
|
17
|
+
isCredentialMaterialError,
|
|
18
|
+
newConnection,
|
|
19
|
+
newConnectionWithOperations,
|
|
20
|
+
newProjectConnection
|
|
21
|
+
} from "./chunk-VQ37BYHS.js";
|
|
22
|
+
|
|
23
|
+
// src/generated/steps.ts
|
|
24
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
25
|
+
function newGetBalanceStep(configuration) {
|
|
26
|
+
const { connection, connectionName, fetched, 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.getBalance(), connection: connection.reference, branches: [
|
|
29
|
+
goToBranch("fetched", fetched),
|
|
30
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
31
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
32
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/project.ts
|
|
37
|
+
import { z } from "zod";
|
|
38
|
+
|
|
39
|
+
// src/client.ts
|
|
40
|
+
import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
41
|
+
import { BodyTooLargeError, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
42
|
+
var emptyBalance = () => ({ remainingMessages: 0 });
|
|
43
|
+
var ChuanglanClient = class {
|
|
44
|
+
/** Validate settings without contacting the provider; credentials resolve for each call. */
|
|
45
|
+
constructor(config, credentials, options = {}) {
|
|
46
|
+
this.credentials = credentials;
|
|
47
|
+
if (!config || !credentials) throw new TypeError("Chuanglan configuration and credentials are required");
|
|
48
|
+
this.baseURL = validateBaseURL(config.baseUrl || "https://smssh1.253.com").replace(/\/$/, "");
|
|
49
|
+
this.timeoutMs = config.timeoutMs ?? 1e4;
|
|
50
|
+
this.maxResponseBytes = config.maxResponseBytes ?? 65536;
|
|
51
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0)
|
|
52
|
+
throw new TypeError("Chuanglan timeout and maxResponseBytes must be positive whole numbers");
|
|
53
|
+
this.send = options.send ?? sendProviderRequest;
|
|
54
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
55
|
+
}
|
|
56
|
+
credentials;
|
|
57
|
+
baseURL;
|
|
58
|
+
timeoutMs;
|
|
59
|
+
maxResponseBytes;
|
|
60
|
+
send;
|
|
61
|
+
now;
|
|
62
|
+
/** Bind the read-only getBalance Query. */
|
|
63
|
+
getBalance() {
|
|
64
|
+
return new GetBalanceOperation(this);
|
|
65
|
+
}
|
|
66
|
+
/** Resolve private credentials and send one bounded balance request. */
|
|
67
|
+
async lookup(call) {
|
|
68
|
+
let account;
|
|
69
|
+
let password;
|
|
70
|
+
try {
|
|
71
|
+
const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
72
|
+
account = credentials.account instanceof SecretString ? credentials.account.reveal() : "";
|
|
73
|
+
password = credentials.password instanceof SecretString ? credentials.password.reveal() : "";
|
|
74
|
+
} catch {
|
|
75
|
+
return { branch: "defect", failure: failure("AUTHENTICATION", "connection credentials are unavailable or invalid") };
|
|
76
|
+
}
|
|
77
|
+
if (!validCredential(account) || !validCredential(password)) return { branch: "defect", failure: failure("AUTHENTICATION", "connection credentials are unavailable or invalid") };
|
|
78
|
+
const request = {
|
|
79
|
+
url: `${this.baseURL}/msg/balance/json`,
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
82
|
+
body: new TextEncoder().encode(JSON.stringify({ account, password })),
|
|
83
|
+
timeoutMs: this.timeoutMs,
|
|
84
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
85
|
+
addressPolicy: this.baseURL.startsWith("https://") ? "publicHTTPS" : "privateNetworkHTTP",
|
|
86
|
+
signal: call.context.cancellationSignal
|
|
87
|
+
};
|
|
88
|
+
let response;
|
|
89
|
+
try {
|
|
90
|
+
response = await this.send(request);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0) {
|
|
93
|
+
if (error.status === 429 || error.status === 408 || error.status >= 500) return statusOutcome(error.status, error.headers ?? {}, this.now());
|
|
94
|
+
return { branch: "invalidResponse", failure: failure("RESPONSE_TOO_LARGE", "Chuanglan response exceeded the configured limit") };
|
|
95
|
+
}
|
|
96
|
+
return { retry: true, failure: failure("AVAILABILITY", "Chuanglan request failed") };
|
|
97
|
+
}
|
|
98
|
+
if (response.status === 429 || response.status === 408 || response.status >= 500) return statusOutcome(response.status, response.headers, this.now());
|
|
99
|
+
if (response.body.length > this.maxResponseBytes) return { branch: "invalidResponse", failure: failure("RESPONSE_TOO_LARGE", "Chuanglan response exceeded the configured limit") };
|
|
100
|
+
return { response };
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var GetBalanceOperation = class {
|
|
104
|
+
/** Bind the provider client. */
|
|
105
|
+
constructor(client) {
|
|
106
|
+
this.client = client;
|
|
107
|
+
}
|
|
108
|
+
client;
|
|
109
|
+
/** Generated Query definition. */
|
|
110
|
+
definition() {
|
|
111
|
+
return GetBalanceDefinition;
|
|
112
|
+
}
|
|
113
|
+
/** Send one read-only request and classify its result. */
|
|
114
|
+
async invoke(call, input) {
|
|
115
|
+
if (!input || Object.keys(input).length !== 0) return terminal("defect", "VALIDATION", "balance input must be empty");
|
|
116
|
+
const exchange = await this.client.lookup(call);
|
|
117
|
+
if ("failure" in exchange) return exchange.retry ? newQueryRetry(exchange.failure, exchange.retryAfterMs ?? 0) : newQueryBranch(exchange.branch, emptyBalance(), {}, exchange.failure);
|
|
118
|
+
const response = exchange.response;
|
|
119
|
+
if (response.status !== 200) return terminal("providerRejected", httpFailureKind(response.status), "Chuanglan rejected the balance lookup");
|
|
120
|
+
let wire;
|
|
121
|
+
try {
|
|
122
|
+
wire = JSON.parse(Buffer.from(response.body).toString("utf8"), (name, value, context) => {
|
|
123
|
+
if (name.toLowerCase() === "code") return context?.source?.replace(/^"+|"+$/g, "");
|
|
124
|
+
if (value && typeof value === "object" && !Array.isArray(value)) return Object.fromEntries(Object.entries(value).map(([key, field]) => [key.toLowerCase(), field]));
|
|
125
|
+
return value;
|
|
126
|
+
});
|
|
127
|
+
} catch {
|
|
128
|
+
return terminal("invalidResponse", "PROTOCOL", "Chuanglan returned an invalid balance response");
|
|
129
|
+
}
|
|
130
|
+
if (!wire || typeof wire !== "object" || Array.isArray(wire)) return terminal("invalidResponse", "PROTOCOL", "Invalid balance envelope");
|
|
131
|
+
const fields = wire;
|
|
132
|
+
const code = parseCount(fields.code);
|
|
133
|
+
if (code === void 0 || fields.balance != null && typeof fields.balance !== "string") return terminal("invalidResponse", "PROTOCOL", "Invalid Chuanglan response fields");
|
|
134
|
+
if (fields.code !== "0") return terminal("providerRejected", "PROVIDER_REJECTION", "Chuanglan rejected the balance lookup");
|
|
135
|
+
const count = parseCount(fields.balance);
|
|
136
|
+
if (count === void 0 || count < 0n || count > BigInt(Number.MAX_SAFE_INTEGER)) return terminal("invalidResponse", "PROTOCOL", "Invalid remaining-message count");
|
|
137
|
+
const remainingMessages = Number(count);
|
|
138
|
+
return newQueryBranch("fetched", { remainingMessages });
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
function parseCount(value) {
|
|
142
|
+
if (typeof value !== "string" || !/^[+-]?[0-9]+$/.test(value)) return void 0;
|
|
143
|
+
const count = BigInt(value);
|
|
144
|
+
return count >= -(1n << 63n) && count < 1n << 63n ? count : void 0;
|
|
145
|
+
}
|
|
146
|
+
function validCredential(value) {
|
|
147
|
+
return value.length > 0 && value.length <= 512 && /^[!-~]+$/.test(value);
|
|
148
|
+
}
|
|
149
|
+
function failure(kind, message) {
|
|
150
|
+
return { kind, provider: "chuanglan", operation: "getBalance", message };
|
|
151
|
+
}
|
|
152
|
+
function terminal(branch, kind, message) {
|
|
153
|
+
return newQueryBranch(branch, emptyBalance(), {}, failure(kind, message));
|
|
154
|
+
}
|
|
155
|
+
function httpFailureKind(status) {
|
|
156
|
+
return status === 401 || status === 403 ? "AUTHENTICATION" : status === 400 ? "VALIDATION" : "PROVIDER_REJECTION";
|
|
157
|
+
}
|
|
158
|
+
function statusOutcome(status, headers, now) {
|
|
159
|
+
const entry = Object.entries(headers).find(([name]) => name.toLowerCase() === "retry-after")?.[1];
|
|
160
|
+
const retryAfter = Array.isArray(entry) ? entry[0] ?? "" : entry ?? "";
|
|
161
|
+
return { retry: true, retryAfterMs: parseRetryAfter(retryAfter, now), failure: status === 429 ? failure("RATE_LIMIT", "Chuanglan rate limit reached") : failure("AVAILABILITY", "Chuanglan is temporarily unavailable") };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/project.ts
|
|
165
|
+
function newProjectConnection2(project, connectionName, options = {}) {
|
|
166
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
167
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "chuanglan" && entry.connectionName === name);
|
|
168
|
+
if (!selected) throw new TypeError("Chuanglan project connection is not configured");
|
|
169
|
+
const fields = z.strictObject({ baseUrl: z.string().optional(), timeout: z.union([z.string(), z.number().int()]).optional(), maxResponseBytes: z.number().int().optional() }).parse(selected.configuration);
|
|
170
|
+
const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
|
|
171
|
+
const config = {
|
|
172
|
+
...fields.baseUrl ? { baseUrl: fields.baseUrl } : {},
|
|
173
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
174
|
+
...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
|
|
175
|
+
};
|
|
176
|
+
const credentials = {
|
|
177
|
+
async resolve(_call, signal) {
|
|
178
|
+
const privateFields = await loadedProject.resolveCredential("chuanglan", name, signal);
|
|
179
|
+
return decodeCredentials(z.record(z.string(), z.unknown()).parse(privateFields));
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
return new ChuanglanClient(config, credentials, options);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function parseDurationMilliseconds(value) {
|
|
186
|
+
let remaining = value;
|
|
187
|
+
let milliseconds = 0;
|
|
188
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
189
|
+
while (remaining) {
|
|
190
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
191
|
+
if (!part) throw new TypeError("Chuanglan timeout must be a positive Go duration");
|
|
192
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
193
|
+
remaining = remaining.slice(part[0].length);
|
|
194
|
+
}
|
|
195
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Chuanglan timeout must resolve to positive whole milliseconds");
|
|
196
|
+
return milliseconds;
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
ChuanglanClient,
|
|
200
|
+
ConfigSchema,
|
|
201
|
+
Connection,
|
|
202
|
+
ConnectorID,
|
|
203
|
+
CredentialMaterialError,
|
|
204
|
+
GetBalanceBranch,
|
|
205
|
+
GetBalanceBranchDefect,
|
|
206
|
+
GetBalanceBranchFetched,
|
|
207
|
+
GetBalanceBranchInvalidResponse,
|
|
208
|
+
GetBalanceBranchProviderRejected,
|
|
209
|
+
GetBalanceDefinition,
|
|
210
|
+
GetBalanceInputSchema,
|
|
211
|
+
GetBalanceMetadata,
|
|
212
|
+
GetBalanceOperation,
|
|
213
|
+
GetBalanceOutputSchema,
|
|
214
|
+
ProviderID,
|
|
215
|
+
decodeCredentials,
|
|
216
|
+
isCredentialMaterialError,
|
|
217
|
+
newConnection,
|
|
218
|
+
newConnectionWithOperations,
|
|
219
|
+
newGetBalanceStep,
|
|
220
|
+
newProjectConnection2 as newProjectConnection
|
|
221
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, C as Connection, G as GetBalanceInput, a as GetBalanceOutput } from './connection-DB1-91Dj.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for GetBalanceInput in scripted cases. */
|
|
7
|
+
declare const emptyGetBalanceInput: GetBalanceInput;
|
|
8
|
+
/** Go zero value for GetBalanceOutput in scripted cases. */
|
|
9
|
+
declare const emptyGetBalanceOutput: GetBalanceOutput;
|
|
10
|
+
/** Script the fetched branch. */
|
|
11
|
+
declare function getBalanceFetched(value: GetBalanceOutput, failure?: Failure): Case<GetBalanceOutput>;
|
|
12
|
+
/** Script the providerRejected branch. */
|
|
13
|
+
declare function getBalanceProviderRejected(value: GetBalanceOutput, failure?: Failure): Case<GetBalanceOutput>;
|
|
14
|
+
/** Script the invalidResponse branch. */
|
|
15
|
+
declare function getBalanceInvalidResponse(value: GetBalanceOutput, failure?: Failure): Case<GetBalanceOutput>;
|
|
16
|
+
/** Script the defect branch. */
|
|
17
|
+
declare function getBalanceDefect(value: GetBalanceOutput, failure?: Failure): Case<GetBalanceOutput>;
|
|
18
|
+
/** Script a safe retry of getBalance. */
|
|
19
|
+
declare function getBalanceRetry(failure: Failure, retryAfterMs?: number): Case<GetBalanceOutput>;
|
|
20
|
+
/** Manifest scenario sampleBalance for getBalance. */
|
|
21
|
+
declare function getBalanceSampleBalance(): Case<GetBalanceOutput>;
|
|
22
|
+
/** Default getBalance scenario. */
|
|
23
|
+
declare function getBalanceDefault(): Case<GetBalanceOutput>;
|
|
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
|
+
getBalance(): MockQuery<GetBalanceInput, GetBalanceOutput>;
|
|
30
|
+
assertNoFailures(): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { GeneratedMock, GeneratedMock as Mock, emptyGetBalanceInput, emptyGetBalanceOutput, getBalanceDefault, getBalanceDefect, getBalanceFetched, getBalanceInvalidResponse, getBalanceProviderRejected, getBalanceRetry, getBalanceSampleBalance };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GetBalanceDefinition,
|
|
3
|
+
GetBalanceInputSchema,
|
|
4
|
+
GetBalanceOutputSchema,
|
|
5
|
+
ProviderID,
|
|
6
|
+
newConnectionWithOperations
|
|
7
|
+
} from "./chunk-VQ37BYHS.js";
|
|
8
|
+
|
|
9
|
+
// src/generated/mock.ts
|
|
10
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
11
|
+
var emptyGetBalanceInput = GetBalanceInputSchema.parse({});
|
|
12
|
+
var emptyGetBalanceOutput = GetBalanceOutputSchema.parse({
|
|
13
|
+
"remainingMessages": 0
|
|
14
|
+
});
|
|
15
|
+
function getBalanceFetched(value, failure) {
|
|
16
|
+
return branchCase("fetched", value, failure);
|
|
17
|
+
}
|
|
18
|
+
function getBalanceProviderRejected(value, failure) {
|
|
19
|
+
return branchCase("providerRejected", value, failure);
|
|
20
|
+
}
|
|
21
|
+
function getBalanceInvalidResponse(value, failure) {
|
|
22
|
+
return branchCase("invalidResponse", value, failure);
|
|
23
|
+
}
|
|
24
|
+
function getBalanceDefect(value, failure) {
|
|
25
|
+
return branchCase("defect", value, failure);
|
|
26
|
+
}
|
|
27
|
+
function getBalanceRetry(failure, retryAfterMs = 0) {
|
|
28
|
+
return retryCase(failure, retryAfterMs);
|
|
29
|
+
}
|
|
30
|
+
function getBalanceSampleBalance() {
|
|
31
|
+
const value = GetBalanceOutputSchema.parse({ "remainingMessages": 953 });
|
|
32
|
+
return branchCase("fetched", value);
|
|
33
|
+
}
|
|
34
|
+
function getBalanceDefault() {
|
|
35
|
+
return getBalanceSampleBalance();
|
|
36
|
+
}
|
|
37
|
+
var GeneratedMock = class {
|
|
38
|
+
#getBalance;
|
|
39
|
+
#connection;
|
|
40
|
+
constructor(connectionName) {
|
|
41
|
+
this.#getBalance = newQuery(GetBalanceDefinition).default(getBalanceDefault());
|
|
42
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
43
|
+
}
|
|
44
|
+
connection() {
|
|
45
|
+
return this.#connection;
|
|
46
|
+
}
|
|
47
|
+
getBalance() {
|
|
48
|
+
return this.#getBalance;
|
|
49
|
+
}
|
|
50
|
+
assertNoFailures() {
|
|
51
|
+
this.#getBalance.assertNoFailures();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
GeneratedMock,
|
|
56
|
+
GeneratedMock as Mock,
|
|
57
|
+
emptyGetBalanceInput,
|
|
58
|
+
emptyGetBalanceOutput,
|
|
59
|
+
getBalanceDefault,
|
|
60
|
+
getBalanceDefect,
|
|
61
|
+
getBalanceFetched,
|
|
62
|
+
getBalanceInvalidResponse,
|
|
63
|
+
getBalanceProviderRejected,
|
|
64
|
+
getBalanceRetry,
|
|
65
|
+
getBalanceSampleBalance
|
|
66
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-chuanglan",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Chuanglan 253 SMS balance connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/chuanglan/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": "npm run build && vitest run test/integration/*.integration.test.ts",
|
|
41
|
+
"example:worker": "tsx examples/balance/worker.ts",
|
|
42
|
+
"example:start": "tsx examples/balance/start.ts",
|
|
43
|
+
"check": "npm run typecheck && npm run lint && npm test && npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@superdurable/connectors-sdk": "0.11.0",
|
|
47
|
+
"@superdurable/dex": ">=1.45.4",
|
|
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
|
+
}
|