@superdurable/connector-seventeentrack 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 +60 -0
- package/dist/chunk-SM5FCJAA.js +125 -0
- package/dist/connection-CPhUGy7l.d.ts +101 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +199 -0
- package/dist/mock.d.ts +35 -0
- package/dist/mock.js +78 -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
|
+
# 17TRACK TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@superdurable/connector-seventeentrack` implements the read-only `listTrackedShipments` Step. It calls `POST /track/v2.4/gettracklist` to list registered shipment numbers and tracking statuses without contacts or addresses.
|
|
4
|
+
|
|
5
|
+
Use the [authorization guide](../README.md#authorization) to configure the static `seventeentrack` connection in Dex Web. The [runnable Flow and Worker](examples/shipment-list/) use that connection. The API key stays outside Flow state and is sent only in the `17token` header.
|
|
6
|
+
|
|
7
|
+
Go-recorded conformance tests check provider outcomes and exact requests. The integration test runs a real Dex Worker and Client with a local provider that returns 503 once before success. Authorization against a real 17TRACK account remains unverified.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "seventeentrack",
|
|
3
|
+
"releaseTag": "connectors/seventeentrack/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-seventeentrack",
|
|
7
|
+
"version": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newListTrackedShipmentsStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "listTrackedShipments",
|
|
14
|
+
"inputType": "ListTrackedShipmentsInput",
|
|
15
|
+
"description": "Page through registered shipment numbers and tracking statuses, omitting contacts, addresses, and raw events.",
|
|
16
|
+
"fields": {
|
|
17
|
+
"stepType": "stepType",
|
|
18
|
+
"annotations": "annotations",
|
|
19
|
+
"connectionName": "connectionName",
|
|
20
|
+
"resultAttribute": "resultAttribute"
|
|
21
|
+
},
|
|
22
|
+
"branches": [
|
|
23
|
+
{
|
|
24
|
+
"id": "listed",
|
|
25
|
+
"field": "listed",
|
|
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": "ListTrackedShipmentsInput selects a 40-record page of already registered shipments.",
|
|
47
|
+
"properties": {
|
|
48
|
+
"pageNumber": {
|
|
49
|
+
"description": "PageNumber is one-based; zero selects the first page.",
|
|
50
|
+
"type": "integer"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": [
|
|
54
|
+
"pageNumber"
|
|
55
|
+
],
|
|
56
|
+
"type": "object"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var ConfigSchema = z.object({
|
|
5
|
+
"baseUrl": z.string().optional(),
|
|
6
|
+
"timeoutMs": z.number().int().optional(),
|
|
7
|
+
"maxResponseBytes": z.number().int().optional()
|
|
8
|
+
});
|
|
9
|
+
var CredentialMaterialError = class extends TypeError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "CredentialMaterialError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
16
|
+
"project credential decoding failed",
|
|
17
|
+
"shared project credential decoding failed",
|
|
18
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
19
|
+
]);
|
|
20
|
+
function isCredentialMaterialError(error) {
|
|
21
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
22
|
+
}
|
|
23
|
+
function decodeCredentials(value) {
|
|
24
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
25
|
+
const fields = value;
|
|
26
|
+
const allowed = /* @__PURE__ */ new Set(["api_key"]);
|
|
27
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
28
|
+
if (fields["api_key"] != null && !(typeof fields["api_key"] === "string")) throw new CredentialMaterialError("credential api_key has an invalid type");
|
|
29
|
+
const credentials = {};
|
|
30
|
+
if (!fields["api_key"]) throw new CredentialMaterialError("credential api_key is required");
|
|
31
|
+
credentials.apiKey = new SecretString(fields["api_key"] ?? "");
|
|
32
|
+
return credentials;
|
|
33
|
+
}
|
|
34
|
+
var ListTrackedShipmentsInputSchema = z.strictObject({
|
|
35
|
+
"pageNumber": z.number().int()
|
|
36
|
+
});
|
|
37
|
+
var TrackedShipmentSchema = z.strictObject({
|
|
38
|
+
"number": z.string(),
|
|
39
|
+
"carrier": z.number().int(),
|
|
40
|
+
"packageStatus": z.string(),
|
|
41
|
+
"trackingStatus": z.string()
|
|
42
|
+
});
|
|
43
|
+
var TrackedShipmentPageSchema = z.strictObject({
|
|
44
|
+
"pageNumber": z.number().int(),
|
|
45
|
+
"total": z.number().int(),
|
|
46
|
+
"shipments": z.array(TrackedShipmentSchema).nullable()
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// src/generated/definitions.ts
|
|
50
|
+
var ConnectorID = "seventeentrack";
|
|
51
|
+
var ProviderID = "seventeentrack";
|
|
52
|
+
var ListTrackedShipmentsBranch = {
|
|
53
|
+
Listed: "listed",
|
|
54
|
+
ProviderRejected: "providerRejected",
|
|
55
|
+
InvalidResponse: "invalidResponse",
|
|
56
|
+
Defect: "defect"
|
|
57
|
+
};
|
|
58
|
+
var ListTrackedShipmentsBranchListed = ListTrackedShipmentsBranch.Listed;
|
|
59
|
+
var ListTrackedShipmentsBranchProviderRejected = ListTrackedShipmentsBranch.ProviderRejected;
|
|
60
|
+
var ListTrackedShipmentsBranchInvalidResponse = ListTrackedShipmentsBranch.InvalidResponse;
|
|
61
|
+
var ListTrackedShipmentsBranchDefect = ListTrackedShipmentsBranch.Defect;
|
|
62
|
+
var ListTrackedShipmentsDefinition = {
|
|
63
|
+
operation: { connectorId: ConnectorID, operationId: "listTrackedShipments" },
|
|
64
|
+
branches: [
|
|
65
|
+
{ id: "listed", description: "17TRACK returned a page of registered shipments, possibly empty." },
|
|
66
|
+
{ id: "providerRejected", description: "17TRACK rejected the key or request.", optional: true },
|
|
67
|
+
{ id: "invalidResponse", description: "17TRACK returned malformed or oversized tracking data.", optional: true },
|
|
68
|
+
{ id: "defect", description: "Local page number or key is invalid.", optional: true }
|
|
69
|
+
],
|
|
70
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
71
|
+
};
|
|
72
|
+
var ListTrackedShipmentsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
73
|
+
|
|
74
|
+
// src/generated/connection.ts
|
|
75
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
76
|
+
var Connection = class {
|
|
77
|
+
/** Stable provider and connection name. */
|
|
78
|
+
reference;
|
|
79
|
+
/** Bound provider operations. */
|
|
80
|
+
operations;
|
|
81
|
+
/** Validate a reference and bind operations. */
|
|
82
|
+
constructor(reference, operations) {
|
|
83
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
84
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
85
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
86
|
+
this.operations = operations;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
function newConnection(client, reference) {
|
|
90
|
+
if (!client) throw new TypeError("connector client is required");
|
|
91
|
+
return new Connection(reference, client);
|
|
92
|
+
}
|
|
93
|
+
function newConnectionWithOperations(operations, reference) {
|
|
94
|
+
return new Connection(reference, operations);
|
|
95
|
+
}
|
|
96
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
97
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
98
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
99
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
100
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
101
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
ConfigSchema,
|
|
106
|
+
CredentialMaterialError,
|
|
107
|
+
isCredentialMaterialError,
|
|
108
|
+
decodeCredentials,
|
|
109
|
+
ListTrackedShipmentsInputSchema,
|
|
110
|
+
TrackedShipmentSchema,
|
|
111
|
+
TrackedShipmentPageSchema,
|
|
112
|
+
ConnectorID,
|
|
113
|
+
ProviderID,
|
|
114
|
+
ListTrackedShipmentsBranch,
|
|
115
|
+
ListTrackedShipmentsBranchListed,
|
|
116
|
+
ListTrackedShipmentsBranchProviderRejected,
|
|
117
|
+
ListTrackedShipmentsBranchInvalidResponse,
|
|
118
|
+
ListTrackedShipmentsBranchDefect,
|
|
119
|
+
ListTrackedShipmentsDefinition,
|
|
120
|
+
ListTrackedShipmentsMetadata,
|
|
121
|
+
Connection,
|
|
122
|
+
newConnection,
|
|
123
|
+
newConnectionWithOperations,
|
|
124
|
+
newProjectConnection
|
|
125
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CredentialProvider, SecretString, Query, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** HTTPS origin of the 17TRACK Tracking API. Leave blank for the displayed production endpoint; override only for a trusted test server or provider-approved proxy. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Maximum duration of one tracking-list query as a positive Go duration such as 30s or 1m. Leave blank for the displayed default; raise it only when the provider responds slowly from your network. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Maximum tracking-list response size in bytes as a positive integer. Leave blank for the displayed default; raise only if 40 records exceed 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 Tracking API key from https://api.17track.net/zh-cn/ > sign in > Settings > Key. Copy the key without a prefix; blank prevents requests. Update this connection after rotation. */
|
|
22
|
+
apiKey: SecretString;
|
|
23
|
+
}
|
|
24
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
25
|
+
declare class CredentialMaterialError extends TypeError {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
29
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
30
|
+
/** Decode private credential fields for the connector. */
|
|
31
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
32
|
+
/** Host-owned source of private connector credentials. */
|
|
33
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
34
|
+
/** ListTrackedShipmentsInput selects a 40-record page of already registered shipments. */
|
|
35
|
+
interface ListTrackedShipmentsInput {
|
|
36
|
+
/** PageNumber is one-based; zero selects the first page. */
|
|
37
|
+
"pageNumber": number;
|
|
38
|
+
}
|
|
39
|
+
/** TrackedShipment contains only a registered number and tracking statuses. */
|
|
40
|
+
interface TrackedShipment {
|
|
41
|
+
/** Number is the registered tracking number. */
|
|
42
|
+
"number": string;
|
|
43
|
+
/** Carrier is the 17TRACK carrier code. */
|
|
44
|
+
"carrier": number;
|
|
45
|
+
/** PackageStatus is the latest package status. */
|
|
46
|
+
"packageStatus": string;
|
|
47
|
+
/** TrackingStatus says whether tracking is active or stopped. */
|
|
48
|
+
"trackingStatus": string;
|
|
49
|
+
}
|
|
50
|
+
/** TrackedShipmentPage contains a bounded tracking-list page and pagination metadata. */
|
|
51
|
+
interface TrackedShipmentPage {
|
|
52
|
+
/** PageNumber is the provider's one-based page number. */
|
|
53
|
+
"pageNumber": number;
|
|
54
|
+
/** Total is the provider's count of matching shipments. */
|
|
55
|
+
"total": number;
|
|
56
|
+
/** Shipments contains at most 40 registered shipments. */
|
|
57
|
+
"shipments": Array<TrackedShipment> | null;
|
|
58
|
+
}
|
|
59
|
+
/** Runtime validator for ListTrackedShipmentsInput. */
|
|
60
|
+
declare const ListTrackedShipmentsInputSchema: z.ZodObject<{
|
|
61
|
+
pageNumber: z.ZodNumber;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
/** Runtime validator for TrackedShipment. */
|
|
64
|
+
declare const TrackedShipmentSchema: z.ZodObject<{
|
|
65
|
+
number: z.ZodString;
|
|
66
|
+
carrier: z.ZodNumber;
|
|
67
|
+
packageStatus: z.ZodString;
|
|
68
|
+
trackingStatus: z.ZodString;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
/** Runtime validator for TrackedShipmentPage. */
|
|
71
|
+
declare const TrackedShipmentPageSchema: z.ZodObject<{
|
|
72
|
+
pageNumber: z.ZodNumber;
|
|
73
|
+
total: z.ZodNumber;
|
|
74
|
+
shipments: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
75
|
+
number: z.ZodString;
|
|
76
|
+
carrier: z.ZodNumber;
|
|
77
|
+
packageStatus: z.ZodString;
|
|
78
|
+
trackingStatus: z.ZodString;
|
|
79
|
+
}, z.core.$strict>>>;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
|
|
82
|
+
/** Typed operations supplied by a client or mock. */
|
|
83
|
+
interface Operations {
|
|
84
|
+
/** Invoke listTrackedShipments through this connection. */
|
|
85
|
+
listTrackedShipments(): Query<ListTrackedShipmentsInput, TrackedShipmentPage>;
|
|
86
|
+
}
|
|
87
|
+
/** Named connector connection kept outside Flow state. */
|
|
88
|
+
declare class Connection<BoundOperations = Operations> {
|
|
89
|
+
/** Stable provider and connection name. */
|
|
90
|
+
readonly reference: ConnectionRef;
|
|
91
|
+
/** Bound provider operations. */
|
|
92
|
+
readonly operations: BoundOperations;
|
|
93
|
+
/** Validate a reference and bind operations. */
|
|
94
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
95
|
+
}
|
|
96
|
+
/** Bind a client to a named connection. */
|
|
97
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
98
|
+
/** Bind scripted operations to a named connection. */
|
|
99
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
100
|
+
|
|
101
|
+
export { Connection as C, type ListTrackedShipmentsInput as L, type Operations as O, type TrackedShipmentPage as T, type Credentials as a, type Config as b, ConfigSchema as c, CredentialMaterialError as d, type CredentialSource as e, ListTrackedShipmentsInputSchema as f, type TrackedShipment as g, TrackedShipmentPageSchema as h, TrackedShipmentSchema as i, decodeCredentials as j, isCredentialMaterialError as k, newConnectionWithOperations as l, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { L as ListTrackedShipmentsInput, T as TrackedShipmentPage, C as Connection, O as Operations, a as Credentials, b as Config } from './connection-CPhUGy7l.js';
|
|
2
|
+
export { c as ConfigSchema, d as CredentialMaterialError, e as CredentialSource, f as ListTrackedShipmentsInputSchema, g as TrackedShipment, h as TrackedShipmentPageSchema, i as TrackedShipmentSchema, j as decodeCredentials, k as isCredentialMaterialError, n as newConnection, l as newConnectionWithOperations } from './connection-CPhUGy7l.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 = "seventeentrack";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "seventeentrack";
|
|
13
|
+
/** Branch IDs for listTrackedShipments. */
|
|
14
|
+
declare const ListTrackedShipmentsBranch: {
|
|
15
|
+
readonly Listed: "listed";
|
|
16
|
+
readonly ProviderRejected: "providerRejected";
|
|
17
|
+
readonly InvalidResponse: "invalidResponse";
|
|
18
|
+
readonly Defect: "defect";
|
|
19
|
+
};
|
|
20
|
+
/** 17TRACK returned a page of registered shipments, possibly empty. */
|
|
21
|
+
declare const ListTrackedShipmentsBranchListed: "listed";
|
|
22
|
+
/** 17TRACK rejected the key or request. */
|
|
23
|
+
declare const ListTrackedShipmentsBranchProviderRejected: "providerRejected";
|
|
24
|
+
/** 17TRACK returned malformed or oversized tracking data. */
|
|
25
|
+
declare const ListTrackedShipmentsBranchInvalidResponse: "invalidResponse";
|
|
26
|
+
/** Local page number or key is invalid. */
|
|
27
|
+
declare const ListTrackedShipmentsBranchDefect: "defect";
|
|
28
|
+
/** Manifest definition for listTrackedShipments. */
|
|
29
|
+
declare const ListTrackedShipmentsDefinition: QueryDefinition;
|
|
30
|
+
/** Manifest metadata for listTrackedShipments. */
|
|
31
|
+
declare const ListTrackedShipmentsMetadata: {
|
|
32
|
+
readonly kind: "query";
|
|
33
|
+
readonly idempotency: "none";
|
|
34
|
+
readonly authorization: "required";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Configuration for the listTrackedShipments connector Step. */
|
|
38
|
+
interface ListTrackedShipmentsStepConfig<StepInput, OperationInput = ListTrackedShipmentsInput, OperationOutput = TrackedShipmentPage> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
39
|
+
/** Named connection supplying this operation. */
|
|
40
|
+
connection: Connection<{
|
|
41
|
+
listTrackedShipments(): Query<OperationInput, OperationOutput>;
|
|
42
|
+
}>;
|
|
43
|
+
/** Name matching the bound connection. */
|
|
44
|
+
connectionName: string;
|
|
45
|
+
/** 17TRACK returned a page of registered shipments, possibly empty. */
|
|
46
|
+
listed: StepTarget<QueryResult<OperationOutput>>;
|
|
47
|
+
/** 17TRACK rejected the key or request. */
|
|
48
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
49
|
+
/** 17TRACK returned malformed or oversized tracking data. */
|
|
50
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
51
|
+
/** Local page number or key is invalid. */
|
|
52
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
53
|
+
}
|
|
54
|
+
/** Build the listTrackedShipments Step from a named connection. */
|
|
55
|
+
declare function newListTrackedShipmentsStep<StepInput, OperationInput = ListTrackedShipmentsInput, OperationOutput = TrackedShipmentPage>(configuration: ListTrackedShipmentsStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
56
|
+
|
|
57
|
+
/** Open one named SeventeenTrack connection from Dex project configuration. */
|
|
58
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
59
|
+
|
|
60
|
+
/** Optional transport dependency for provider tests. */
|
|
61
|
+
interface SeventeenTrackClientOptions {
|
|
62
|
+
/** Request sender; production uses the Connector SDK transport. */
|
|
63
|
+
send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
64
|
+
}
|
|
65
|
+
/** Read existing 17TRACK shipments with bounded provider responses. */
|
|
66
|
+
declare class SeventeenTrackClient {
|
|
67
|
+
readonly credentials: CredentialProvider<Credentials>;
|
|
68
|
+
readonly baseURL: string;
|
|
69
|
+
readonly timeoutMs: number;
|
|
70
|
+
readonly maxResponseBytes: number;
|
|
71
|
+
readonly send: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
72
|
+
/** Validate settings and bind the rotating credential source. */
|
|
73
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: SeventeenTrackClientOptions);
|
|
74
|
+
/** Bind the tracking-list Query. */
|
|
75
|
+
listTrackedShipments(): ListTrackedShipmentsOperation;
|
|
76
|
+
}
|
|
77
|
+
/** Read one page of already registered tracking statuses. */
|
|
78
|
+
declare class ListTrackedShipmentsOperation implements Query<ListTrackedShipmentsInput, TrackedShipmentPage> {
|
|
79
|
+
private readonly client;
|
|
80
|
+
/** Bind an authenticated 17TRACK client. */
|
|
81
|
+
constructor(client: SeventeenTrackClient);
|
|
82
|
+
/** Return the stable generated Query contract. */
|
|
83
|
+
definition(): QueryDefinition;
|
|
84
|
+
/** Request and classify one tracking-list page. */
|
|
85
|
+
invoke(call: Call, input: ListTrackedShipmentsInput): Promise<QueryAttempt<TrackedShipmentPage>>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { Config, Connection, ConnectorID, Credentials, ListTrackedShipmentsBranch, ListTrackedShipmentsBranchDefect, ListTrackedShipmentsBranchInvalidResponse, ListTrackedShipmentsBranchListed, ListTrackedShipmentsBranchProviderRejected, ListTrackedShipmentsDefinition, ListTrackedShipmentsInput, ListTrackedShipmentsMetadata, ListTrackedShipmentsOperation, type ListTrackedShipmentsStepConfig, ProviderID, SeventeenTrackClient, type SeventeenTrackClientOptions, TrackedShipmentPage, newListTrackedShipmentsStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
6
|
+
ListTrackedShipmentsBranch,
|
|
7
|
+
ListTrackedShipmentsBranchDefect,
|
|
8
|
+
ListTrackedShipmentsBranchInvalidResponse,
|
|
9
|
+
ListTrackedShipmentsBranchListed,
|
|
10
|
+
ListTrackedShipmentsBranchProviderRejected,
|
|
11
|
+
ListTrackedShipmentsDefinition,
|
|
12
|
+
ListTrackedShipmentsInputSchema,
|
|
13
|
+
ListTrackedShipmentsMetadata,
|
|
14
|
+
ProviderID,
|
|
15
|
+
TrackedShipmentPageSchema,
|
|
16
|
+
TrackedShipmentSchema,
|
|
17
|
+
decodeCredentials,
|
|
18
|
+
isCredentialMaterialError,
|
|
19
|
+
newConnection,
|
|
20
|
+
newConnectionWithOperations,
|
|
21
|
+
newProjectConnection
|
|
22
|
+
} from "./chunk-SM5FCJAA.js";
|
|
23
|
+
|
|
24
|
+
// src/generated/steps.ts
|
|
25
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
26
|
+
function newListTrackedShipmentsStep(configuration) {
|
|
27
|
+
const { connection, connectionName, listed, 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.listTrackedShipments(), connection: connection.reference, branches: [
|
|
30
|
+
goToBranch("listed", listed),
|
|
31
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
32
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
33
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
34
|
+
] });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/project.ts
|
|
38
|
+
import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
39
|
+
import { z } from "zod";
|
|
40
|
+
|
|
41
|
+
// src/client.ts
|
|
42
|
+
import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
43
|
+
import { BodyTooLargeError, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
44
|
+
var emptyPage = { pageNumber: 0, total: 0, shipments: [] };
|
|
45
|
+
var requestPath = "/track/v2.4/gettracklist";
|
|
46
|
+
var SeventeenTrackClient = class {
|
|
47
|
+
/** Validate settings and bind the rotating credential source. */
|
|
48
|
+
constructor(config, credentials, options = {}) {
|
|
49
|
+
this.credentials = credentials;
|
|
50
|
+
if (!config || !credentials) throw new TypeError("17TRACK configuration and credential source are required");
|
|
51
|
+
this.baseURL = validateBaseURL(config.baseUrl ?? "https://api.17track.net").replace(/\/$/, "");
|
|
52
|
+
this.timeoutMs = config.timeoutMs ?? 15e3;
|
|
53
|
+
this.maxResponseBytes = config.maxResponseBytes ?? 1048576;
|
|
54
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0 || this.maxResponseBytes > 16 << 20) throw new TypeError("17TRACK configuration is invalid");
|
|
55
|
+
this.send = options.send ?? sendProviderRequest;
|
|
56
|
+
}
|
|
57
|
+
credentials;
|
|
58
|
+
baseURL;
|
|
59
|
+
timeoutMs;
|
|
60
|
+
maxResponseBytes;
|
|
61
|
+
send;
|
|
62
|
+
/** Bind the tracking-list Query. */
|
|
63
|
+
listTrackedShipments() {
|
|
64
|
+
return new ListTrackedShipmentsOperation(this);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var ListTrackedShipmentsOperation = class {
|
|
68
|
+
/** Bind an authenticated 17TRACK client. */
|
|
69
|
+
constructor(client) {
|
|
70
|
+
this.client = client;
|
|
71
|
+
}
|
|
72
|
+
client;
|
|
73
|
+
/** Return the stable generated Query contract. */
|
|
74
|
+
definition() {
|
|
75
|
+
return ListTrackedShipmentsDefinition;
|
|
76
|
+
}
|
|
77
|
+
/** Request and classify one tracking-list page. */
|
|
78
|
+
async invoke(call, input) {
|
|
79
|
+
if (!input || !Number.isSafeInteger(input.pageNumber) || input.pageNumber < 0 || input.pageNumber > 1e5) return branch("defect", "VALIDATION", "17TRACK page number must be between 1 and 100000");
|
|
80
|
+
let credentials;
|
|
81
|
+
try {
|
|
82
|
+
credentials = await this.client.credentials.resolve(call, call.context.cancellationSignal);
|
|
83
|
+
} catch {
|
|
84
|
+
return branch("defect", "AUTHENTICATION", "17TRACK API key is unavailable or invalid");
|
|
85
|
+
}
|
|
86
|
+
const apiKey = credentials.apiKey instanceof SecretString ? credentials.apiKey.reveal() : "";
|
|
87
|
+
if (!apiKey || apiKey.length > 2048 || !/^[!-~]+$/.test(apiKey)) return branch("defect", "AUTHENTICATION", "17TRACK API key is unavailable or invalid");
|
|
88
|
+
let response;
|
|
89
|
+
try {
|
|
90
|
+
response = await this.client.send({ url: this.client.baseURL + requestPath, method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", "17token": apiKey }, body: new TextEncoder().encode(JSON.stringify({ page_no: input.pageNumber || 1 })), timeoutMs: this.client.timeoutMs, maxResponseBytes: this.client.maxResponseBytes, addressPolicy: "publicHTTPS", signal: call.context.cancellationSignal });
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error instanceof BodyTooLargeError && error.status === 200) return branch("invalidResponse", "RESPONSE_TOO_LARGE", "17TRACK response exceeded the configured limit");
|
|
93
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0) return classifyStatus(error.status, error.headers ?? {});
|
|
94
|
+
return retry("AVAILABILITY", "17TRACK tracking-list request failed");
|
|
95
|
+
}
|
|
96
|
+
if (response.status === 429 || response.status === 408 || response.status >= 500) return classifyStatus(response.status, response.headers);
|
|
97
|
+
let document;
|
|
98
|
+
try {
|
|
99
|
+
document = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(response.body));
|
|
100
|
+
} catch {
|
|
101
|
+
return branch("invalidResponse", "PROTOCOL", "17TRACK returned an invalid tracking-list response");
|
|
102
|
+
}
|
|
103
|
+
if (response.status !== 200) return classifyStatus(response.status, response.headers);
|
|
104
|
+
if (!isRecord(document) || !Number.isSafeInteger(document.code)) return branch("invalidResponse", "PROTOCOL", "17TRACK returned an invalid tracking-list response");
|
|
105
|
+
if (document.code !== 0) return branch("providerRejected", "PROVIDER_REJECTION", "17TRACK rejected tracking-list query");
|
|
106
|
+
if (!isRecord(document.data)) return branch("invalidResponse", "PROTOCOL", "17TRACK returned an invalid tracking-list response");
|
|
107
|
+
if (Array.isArray(document.data.errors) && document.data.errors.length > 0) return branch("providerRejected", "PROVIDER_REJECTION", "17TRACK rejected tracking-list query");
|
|
108
|
+
const page = document.page;
|
|
109
|
+
const accepted = document.data.accepted;
|
|
110
|
+
if (!isRecord(page) || !Number.isSafeInteger(page.page_no) || page.page_no < 0 || !Number.isSafeInteger(page.data_total) || page.data_total < 0 || !Number.isSafeInteger(page.page_size) || page.page_size > 40 || !Array.isArray(accepted) || accepted.length > 40) return branch("invalidResponse", "PROTOCOL", "17TRACK returned an invalid tracking-list response");
|
|
111
|
+
const shipments = [];
|
|
112
|
+
for (const item of accepted) {
|
|
113
|
+
if (!isRecord(item) || typeof item.number !== "string" || !item.number || !Number.isSafeInteger(item.carrier) || item.carrier <= 0) return branch("invalidResponse", "PROTOCOL", "17TRACK returned an invalid tracking-list response");
|
|
114
|
+
shipments.push({ number: item.number, carrier: item.carrier, packageStatus: typeof item.package_status === "string" ? item.package_status : "", trackingStatus: typeof item.tracking_status === "string" ? item.tracking_status : "" });
|
|
115
|
+
}
|
|
116
|
+
return newQueryBranch("listed", { pageNumber: page.page_no, total: page.data_total, shipments });
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
function classifyStatus(status, headers) {
|
|
120
|
+
const retryAfterHeader = headers["retry-after"];
|
|
121
|
+
const retryAfterMs = parseRetryAfter(Array.isArray(retryAfterHeader) ? retryAfterHeader[0] ?? "" : retryAfterHeader ?? "");
|
|
122
|
+
if (status === 429) return retry("RATE_LIMIT", "17TRACK rate limited tracking-list query", retryAfterMs);
|
|
123
|
+
if (status === 408 || status >= 500) return retry("AVAILABILITY", "17TRACK tracking API is temporarily unavailable", retryAfterMs);
|
|
124
|
+
const kind = status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : [400, 404, 412].includes(status) ? "VALIDATION" : "PROVIDER_REJECTION";
|
|
125
|
+
return branch("providerRejected", kind, `17TRACK rejected tracking-list query with HTTP ${status}`);
|
|
126
|
+
}
|
|
127
|
+
function isRecord(value) {
|
|
128
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
129
|
+
}
|
|
130
|
+
function failure(kind, message) {
|
|
131
|
+
return { provider: "seventeentrack", operation: "listTrackedShipments", kind, message };
|
|
132
|
+
}
|
|
133
|
+
function branch(id, kind, message) {
|
|
134
|
+
return newQueryBranch(id, emptyPage, {}, failure(kind, message));
|
|
135
|
+
}
|
|
136
|
+
function retry(kind, message, delayMs = 0) {
|
|
137
|
+
return newQueryRetry(failure(kind, message), delayMs);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/project.ts
|
|
141
|
+
function newProjectConnection2(project, connectionName) {
|
|
142
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
143
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "seventeentrack" && entry.connectionName === name);
|
|
144
|
+
if (!selected) throw new TypeError("SeventeenTrack project connection is not configured");
|
|
145
|
+
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);
|
|
146
|
+
const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
|
|
147
|
+
const config = {
|
|
148
|
+
...fields.baseUrl !== void 0 ? { baseUrl: fields.baseUrl } : {},
|
|
149
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
150
|
+
...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
|
|
151
|
+
};
|
|
152
|
+
const credentials = {
|
|
153
|
+
async resolve(_call, signal) {
|
|
154
|
+
const privateFields = await loadedProject.resolveCredential("seventeentrack", name, signal);
|
|
155
|
+
if (typeof privateFields.api_key !== "string") throw new TypeError("SeventeenTrack Key is unavailable");
|
|
156
|
+
return { apiKey: new SecretString2(privateFields.api_key) };
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
return new SeventeenTrackClient(config, credentials);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function parseDurationMilliseconds(value) {
|
|
163
|
+
let remaining = value;
|
|
164
|
+
let milliseconds = 0;
|
|
165
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
166
|
+
while (remaining) {
|
|
167
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
168
|
+
if (!part) throw new TypeError("SeventeenTrack timeout must be a positive Go duration");
|
|
169
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
170
|
+
remaining = remaining.slice(part[0].length);
|
|
171
|
+
}
|
|
172
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("SeventeenTrack timeout must resolve to positive whole milliseconds");
|
|
173
|
+
return milliseconds;
|
|
174
|
+
}
|
|
175
|
+
export {
|
|
176
|
+
ConfigSchema,
|
|
177
|
+
Connection,
|
|
178
|
+
ConnectorID,
|
|
179
|
+
CredentialMaterialError,
|
|
180
|
+
ListTrackedShipmentsBranch,
|
|
181
|
+
ListTrackedShipmentsBranchDefect,
|
|
182
|
+
ListTrackedShipmentsBranchInvalidResponse,
|
|
183
|
+
ListTrackedShipmentsBranchListed,
|
|
184
|
+
ListTrackedShipmentsBranchProviderRejected,
|
|
185
|
+
ListTrackedShipmentsDefinition,
|
|
186
|
+
ListTrackedShipmentsInputSchema,
|
|
187
|
+
ListTrackedShipmentsMetadata,
|
|
188
|
+
ListTrackedShipmentsOperation,
|
|
189
|
+
ProviderID,
|
|
190
|
+
SeventeenTrackClient,
|
|
191
|
+
TrackedShipmentPageSchema,
|
|
192
|
+
TrackedShipmentSchema,
|
|
193
|
+
decodeCredentials,
|
|
194
|
+
isCredentialMaterialError,
|
|
195
|
+
newConnection,
|
|
196
|
+
newConnectionWithOperations,
|
|
197
|
+
newListTrackedShipmentsStep,
|
|
198
|
+
newProjectConnection2 as newProjectConnection
|
|
199
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, C as Connection, L as ListTrackedShipmentsInput, T as TrackedShipmentPage, g as TrackedShipment } from './connection-CPhUGy7l.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for ListTrackedShipmentsInput in scripted cases. */
|
|
7
|
+
declare const emptyListTrackedShipmentsInput: ListTrackedShipmentsInput;
|
|
8
|
+
/** Go zero value for TrackedShipment in scripted cases. */
|
|
9
|
+
declare const emptyTrackedShipment: TrackedShipment;
|
|
10
|
+
/** Go zero value for TrackedShipmentPage in scripted cases. */
|
|
11
|
+
declare const emptyTrackedShipmentPage: TrackedShipmentPage;
|
|
12
|
+
/** Script the listed branch. */
|
|
13
|
+
declare function listTrackedShipmentsListed(value: TrackedShipmentPage, failure?: Failure): Case<TrackedShipmentPage>;
|
|
14
|
+
/** Script the providerRejected branch. */
|
|
15
|
+
declare function listTrackedShipmentsProviderRejected(value: TrackedShipmentPage, failure?: Failure): Case<TrackedShipmentPage>;
|
|
16
|
+
/** Script the invalidResponse branch. */
|
|
17
|
+
declare function listTrackedShipmentsInvalidResponse(value: TrackedShipmentPage, failure?: Failure): Case<TrackedShipmentPage>;
|
|
18
|
+
/** Script the defect branch. */
|
|
19
|
+
declare function listTrackedShipmentsDefect(value: TrackedShipmentPage, failure?: Failure): Case<TrackedShipmentPage>;
|
|
20
|
+
/** Script a safe retry of listTrackedShipments. */
|
|
21
|
+
declare function listTrackedShipmentsRetry(failure: Failure, retryAfterMs?: number): Case<TrackedShipmentPage>;
|
|
22
|
+
/** Manifest scenario listedShipment for listTrackedShipments. */
|
|
23
|
+
declare function listTrackedShipmentsListedShipment(): Case<TrackedShipmentPage>;
|
|
24
|
+
/** Default listTrackedShipments scenario. */
|
|
25
|
+
declare function listTrackedShipmentsDefault(): Case<TrackedShipmentPage>;
|
|
26
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
27
|
+
declare class GeneratedMock implements Operations {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(connectionName: string);
|
|
30
|
+
connection(): Connection;
|
|
31
|
+
listTrackedShipments(): MockQuery<ListTrackedShipmentsInput, TrackedShipmentPage>;
|
|
32
|
+
assertNoFailures(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { GeneratedMock, GeneratedMock as Mock, emptyListTrackedShipmentsInput, emptyTrackedShipment, emptyTrackedShipmentPage, listTrackedShipmentsDefault, listTrackedShipmentsDefect, listTrackedShipmentsInvalidResponse, listTrackedShipmentsListed, listTrackedShipmentsListedShipment, listTrackedShipmentsProviderRejected, listTrackedShipmentsRetry };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ListTrackedShipmentsDefinition,
|
|
3
|
+
ListTrackedShipmentsInputSchema,
|
|
4
|
+
ProviderID,
|
|
5
|
+
TrackedShipmentPageSchema,
|
|
6
|
+
TrackedShipmentSchema,
|
|
7
|
+
newConnectionWithOperations
|
|
8
|
+
} from "./chunk-SM5FCJAA.js";
|
|
9
|
+
|
|
10
|
+
// src/generated/mock.ts
|
|
11
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
12
|
+
var emptyListTrackedShipmentsInput = ListTrackedShipmentsInputSchema.parse({
|
|
13
|
+
"pageNumber": 0
|
|
14
|
+
});
|
|
15
|
+
var emptyTrackedShipment = TrackedShipmentSchema.parse({
|
|
16
|
+
"number": "",
|
|
17
|
+
"carrier": 0,
|
|
18
|
+
"packageStatus": "",
|
|
19
|
+
"trackingStatus": ""
|
|
20
|
+
});
|
|
21
|
+
var emptyTrackedShipmentPage = TrackedShipmentPageSchema.parse({
|
|
22
|
+
"pageNumber": 0,
|
|
23
|
+
"total": 0,
|
|
24
|
+
"shipments": []
|
|
25
|
+
});
|
|
26
|
+
function listTrackedShipmentsListed(value, failure) {
|
|
27
|
+
return branchCase("listed", value, failure);
|
|
28
|
+
}
|
|
29
|
+
function listTrackedShipmentsProviderRejected(value, failure) {
|
|
30
|
+
return branchCase("providerRejected", value, failure);
|
|
31
|
+
}
|
|
32
|
+
function listTrackedShipmentsInvalidResponse(value, failure) {
|
|
33
|
+
return branchCase("invalidResponse", value, failure);
|
|
34
|
+
}
|
|
35
|
+
function listTrackedShipmentsDefect(value, failure) {
|
|
36
|
+
return branchCase("defect", value, failure);
|
|
37
|
+
}
|
|
38
|
+
function listTrackedShipmentsRetry(failure, retryAfterMs = 0) {
|
|
39
|
+
return retryCase(failure, retryAfterMs);
|
|
40
|
+
}
|
|
41
|
+
function listTrackedShipmentsListedShipment() {
|
|
42
|
+
const value = TrackedShipmentPageSchema.parse({ "pageNumber": 1, "shipments": [{ "carrier": 3011, "number": "RR123456789CN", "packageStatus": "InTransit", "trackingStatus": "Tracking" }], "total": 1 });
|
|
43
|
+
return branchCase("listed", value);
|
|
44
|
+
}
|
|
45
|
+
function listTrackedShipmentsDefault() {
|
|
46
|
+
return listTrackedShipmentsListedShipment();
|
|
47
|
+
}
|
|
48
|
+
var GeneratedMock = class {
|
|
49
|
+
#listTrackedShipments;
|
|
50
|
+
#connection;
|
|
51
|
+
constructor(connectionName) {
|
|
52
|
+
this.#listTrackedShipments = newQuery(ListTrackedShipmentsDefinition).default(listTrackedShipmentsDefault());
|
|
53
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
54
|
+
}
|
|
55
|
+
connection() {
|
|
56
|
+
return this.#connection;
|
|
57
|
+
}
|
|
58
|
+
listTrackedShipments() {
|
|
59
|
+
return this.#listTrackedShipments;
|
|
60
|
+
}
|
|
61
|
+
assertNoFailures() {
|
|
62
|
+
this.#listTrackedShipments.assertNoFailures();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
GeneratedMock,
|
|
67
|
+
GeneratedMock as Mock,
|
|
68
|
+
emptyListTrackedShipmentsInput,
|
|
69
|
+
emptyTrackedShipment,
|
|
70
|
+
emptyTrackedShipmentPage,
|
|
71
|
+
listTrackedShipmentsDefault,
|
|
72
|
+
listTrackedShipmentsDefect,
|
|
73
|
+
listTrackedShipmentsInvalidResponse,
|
|
74
|
+
listTrackedShipmentsListed,
|
|
75
|
+
listTrackedShipmentsListedShipment,
|
|
76
|
+
listTrackedShipmentsProviderRejected,
|
|
77
|
+
listTrackedShipmentsRetry
|
|
78
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-seventeentrack",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "SeventeenTrack shipment list connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/seventeentrack/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/shipment-list/worker.ts",
|
|
43
|
+
"example:start": "tsx examples/shipment-list/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
|
+
}
|