@superdurable/connector-emq 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 +52 -0
- package/dist/chunk-MF2GOS7K.js +131 -0
- package/dist/connection-BgrPERee.d.ts +121 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.js +203 -0
- package/dist/mock.d.ts +35 -0
- package/dist/mock.js +80 -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
|
+
# EMQX Cloud TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@superdurable/connector-emq` provides `listDeployments`, a read-only Query for EMQX Cloud deployments in the Platform API key's project scope. It returns bounded deployment metadata and omits private provider fields.
|
|
4
|
+
|
|
5
|
+
In [EMQX Cloud Console](https://cloud.emqx.com/console/), open **Settings > Platform API Key**, create a key with Deployment Management and the required project scopes, then save its key and secret as Dex secret credentials. Copy the Platform API endpoint ending in `/public_api/v1` to the connection's `platformEndpoint`. Blank credentials or endpoint prevent requests; leave timeout and maxResponseBytes blank for their displayed defaults.
|
|
6
|
+
|
|
7
|
+
The [runnable Flow](examples/basic/) uses static connection name `emq`. `npm run check` replays the Go-recorded provider scenarios, including errors and retries. Live authorization and deployment data remain unverified without a user-controlled connection.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "emq",
|
|
3
|
+
"releaseTag": "connectors/emq/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-emq",
|
|
7
|
+
"version": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newListDeploymentsStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "listDeployments",
|
|
14
|
+
"inputType": "ListDeploymentsInput",
|
|
15
|
+
"description": "List deployments within the Platform API key's selected project scope.",
|
|
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": "ListDeploymentsInput has no operation parameters; the key's project scope selects deployments.",
|
|
47
|
+
"properties": {},
|
|
48
|
+
"type": "object"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var ConfigSchema = z.object({
|
|
5
|
+
"platformEndpoint": z.string(),
|
|
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(["platform_api_key", "platform_api_secret"]);
|
|
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["platform_api_key"] != null && !(typeof fields["platform_api_key"] === "string")) throw new CredentialMaterialError("credential platform_api_key has an invalid type");
|
|
29
|
+
if (fields["platform_api_secret"] != null && !(typeof fields["platform_api_secret"] === "string")) throw new CredentialMaterialError("credential platform_api_secret has an invalid type");
|
|
30
|
+
const credentials = {};
|
|
31
|
+
if (!fields["platform_api_key"]) throw new CredentialMaterialError("credential platform_api_key is required");
|
|
32
|
+
credentials.platformApiKey = new SecretString(fields["platform_api_key"] ?? "");
|
|
33
|
+
if (!fields["platform_api_secret"]) throw new CredentialMaterialError("credential platform_api_secret is required");
|
|
34
|
+
credentials.platformApiSecret = new SecretString(fields["platform_api_secret"] ?? "");
|
|
35
|
+
return credentials;
|
|
36
|
+
}
|
|
37
|
+
var ListDeploymentsInputSchema = z.strictObject({});
|
|
38
|
+
var DeploymentSchema = z.strictObject({
|
|
39
|
+
"deploymentId": z.string(),
|
|
40
|
+
"deploymentName": z.string(),
|
|
41
|
+
"deploymentType": z.string(),
|
|
42
|
+
"projectName": z.string(),
|
|
43
|
+
"region": z.string(),
|
|
44
|
+
"status": z.string(),
|
|
45
|
+
"version": z.string(),
|
|
46
|
+
"platform": z.string(),
|
|
47
|
+
"connections": z.number().int(),
|
|
48
|
+
"tps": z.number().int(),
|
|
49
|
+
"createdAt": z.string()
|
|
50
|
+
});
|
|
51
|
+
var ListDeploymentsOutputSchema = z.strictObject({
|
|
52
|
+
"deployments": z.array(DeploymentSchema).nullable()
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// src/generated/definitions.ts
|
|
56
|
+
var ConnectorID = "emq";
|
|
57
|
+
var ProviderID = "emq";
|
|
58
|
+
var ListDeploymentsBranch = {
|
|
59
|
+
Listed: "listed",
|
|
60
|
+
ProviderRejected: "providerRejected",
|
|
61
|
+
InvalidResponse: "invalidResponse",
|
|
62
|
+
Defect: "defect"
|
|
63
|
+
};
|
|
64
|
+
var ListDeploymentsBranchListed = ListDeploymentsBranch.Listed;
|
|
65
|
+
var ListDeploymentsBranchProviderRejected = ListDeploymentsBranch.ProviderRejected;
|
|
66
|
+
var ListDeploymentsBranchInvalidResponse = ListDeploymentsBranch.InvalidResponse;
|
|
67
|
+
var ListDeploymentsBranchDefect = ListDeploymentsBranch.Defect;
|
|
68
|
+
var ListDeploymentsDefinition = {
|
|
69
|
+
operation: { connectorId: ConnectorID, operationId: "listDeployments" },
|
|
70
|
+
branches: [
|
|
71
|
+
{ id: "listed", description: "EMQX Cloud returned zero or more deployments." },
|
|
72
|
+
{ id: "providerRejected", description: "EMQX Cloud rejected the key or request.", optional: true },
|
|
73
|
+
{ id: "invalidResponse", description: "EMQX Cloud returned malformed or oversized data.", optional: true },
|
|
74
|
+
{ id: "defect", description: "Local connection settings are invalid.", optional: true }
|
|
75
|
+
],
|
|
76
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
77
|
+
};
|
|
78
|
+
var ListDeploymentsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
79
|
+
|
|
80
|
+
// src/generated/connection.ts
|
|
81
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
82
|
+
var Connection = class {
|
|
83
|
+
/** Stable provider and connection name. */
|
|
84
|
+
reference;
|
|
85
|
+
/** Bound provider operations. */
|
|
86
|
+
operations;
|
|
87
|
+
/** Validate a reference and bind operations. */
|
|
88
|
+
constructor(reference, operations) {
|
|
89
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
90
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
91
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
92
|
+
this.operations = operations;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
function newConnection(client, reference) {
|
|
96
|
+
if (!client) throw new TypeError("connector client is required");
|
|
97
|
+
return new Connection(reference, client);
|
|
98
|
+
}
|
|
99
|
+
function newConnectionWithOperations(operations, reference) {
|
|
100
|
+
return new Connection(reference, operations);
|
|
101
|
+
}
|
|
102
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
103
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
104
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
105
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
106
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
107
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
ConfigSchema,
|
|
112
|
+
CredentialMaterialError,
|
|
113
|
+
isCredentialMaterialError,
|
|
114
|
+
decodeCredentials,
|
|
115
|
+
ListDeploymentsInputSchema,
|
|
116
|
+
DeploymentSchema,
|
|
117
|
+
ListDeploymentsOutputSchema,
|
|
118
|
+
ConnectorID,
|
|
119
|
+
ProviderID,
|
|
120
|
+
ListDeploymentsBranch,
|
|
121
|
+
ListDeploymentsBranchListed,
|
|
122
|
+
ListDeploymentsBranchProviderRejected,
|
|
123
|
+
ListDeploymentsBranchInvalidResponse,
|
|
124
|
+
ListDeploymentsBranchDefect,
|
|
125
|
+
ListDeploymentsDefinition,
|
|
126
|
+
ListDeploymentsMetadata,
|
|
127
|
+
Connection,
|
|
128
|
+
newConnection,
|
|
129
|
+
newConnectionWithOperations,
|
|
130
|
+
newProjectConnection
|
|
131
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
/** Platform API endpoint copied from EMQX Cloud Console https://cloud.emqx.com/console/ > Settings > Platform API Key. Enter its absolute HTTPS URL ending in /public_api/v1, without a trailing slash, URL credentials, query, or fragment. The endpoint identifies the account and region and is not secret. Blank prevents requests. */
|
|
7
|
+
platformEndpoint: string;
|
|
8
|
+
/** Maximum time for one deployment-list request as a positive Go duration such as 5s or 1m. Blank uses the displayed default; raise only for a slow approved proxy. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Maximum deployment-list response size in bytes as a positive integer. Blank uses the displayed default; raise only for a legitimate larger deployment list. */
|
|
11
|
+
maxResponseBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Runtime schema for manifest configuration. */
|
|
14
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
15
|
+
platformEndpoint: 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
|
+
/** Platform API Key from https://cloud.emqx.com/console/ > Settings > Platform API Key > Create New Key. Copy the opaque key shown after selecting Deployment Management and project scopes. Dex stores it as a secret credential and sends it only as the HTTP Basic username to the configured Platform API endpoint. Blank prevents requests. */
|
|
22
|
+
platformApiKey: SecretString;
|
|
23
|
+
/** Platform API Secret shown once with the key at https://cloud.emqx.com/console/ > Settings > Platform API Key > Create New Key. Copy its opaque value when created; it cannot be retrieved later. Dex stores it as a secret credential and sends it only as the HTTP Basic password. Blank prevents requests. */
|
|
24
|
+
platformApiSecret: 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
|
+
/** ListDeploymentsInput has no operation parameters; the key's project scope selects deployments. */
|
|
37
|
+
interface ListDeploymentsInput {
|
|
38
|
+
}
|
|
39
|
+
/** Deployment is a bounded view of one EMQX Cloud deployment. */
|
|
40
|
+
interface Deployment {
|
|
41
|
+
/** DeploymentID is the provider's stable deployment identifier. */
|
|
42
|
+
"deploymentId": string;
|
|
43
|
+
/** DeploymentName is the console display name. */
|
|
44
|
+
"deploymentName": string;
|
|
45
|
+
/** DeploymentType identifies the serverless or dedicated plan. */
|
|
46
|
+
"deploymentType": string;
|
|
47
|
+
/** ProjectName is the containing project name. */
|
|
48
|
+
"projectName": string;
|
|
49
|
+
/** Region is the provider's region label. */
|
|
50
|
+
"region": string;
|
|
51
|
+
/** Status is the provider-reported lifecycle state. */
|
|
52
|
+
"status": string;
|
|
53
|
+
/** Version is the EMQX major version label. */
|
|
54
|
+
"version": string;
|
|
55
|
+
/** Platform is the cloud provider label. */
|
|
56
|
+
"platform": string;
|
|
57
|
+
/** Connections is the deployment's connection capacity. */
|
|
58
|
+
"connections": number;
|
|
59
|
+
/** TPS is the deployment's transactions-per-second capacity. */
|
|
60
|
+
"tps": number;
|
|
61
|
+
/** CreatedAt is the provider's creation time string. */
|
|
62
|
+
"createdAt": string;
|
|
63
|
+
}
|
|
64
|
+
/** ListDeploymentsOutput contains zero or more scoped deployments. */
|
|
65
|
+
interface ListDeploymentsOutput {
|
|
66
|
+
/** Deployments is empty when the key can access no deployments. */
|
|
67
|
+
"deployments": Array<Deployment> | null;
|
|
68
|
+
}
|
|
69
|
+
/** Runtime validator for ListDeploymentsInput. */
|
|
70
|
+
declare const ListDeploymentsInputSchema: z.ZodObject<{}, z.core.$strict>;
|
|
71
|
+
/** Runtime validator for Deployment. */
|
|
72
|
+
declare const DeploymentSchema: z.ZodObject<{
|
|
73
|
+
deploymentId: z.ZodString;
|
|
74
|
+
deploymentName: z.ZodString;
|
|
75
|
+
deploymentType: z.ZodString;
|
|
76
|
+
projectName: z.ZodString;
|
|
77
|
+
region: z.ZodString;
|
|
78
|
+
status: z.ZodString;
|
|
79
|
+
version: z.ZodString;
|
|
80
|
+
platform: z.ZodString;
|
|
81
|
+
connections: z.ZodNumber;
|
|
82
|
+
tps: z.ZodNumber;
|
|
83
|
+
createdAt: z.ZodString;
|
|
84
|
+
}, z.core.$strict>;
|
|
85
|
+
/** Runtime validator for ListDeploymentsOutput. */
|
|
86
|
+
declare const ListDeploymentsOutputSchema: z.ZodObject<{
|
|
87
|
+
deployments: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
88
|
+
deploymentId: z.ZodString;
|
|
89
|
+
deploymentName: z.ZodString;
|
|
90
|
+
deploymentType: z.ZodString;
|
|
91
|
+
projectName: z.ZodString;
|
|
92
|
+
region: z.ZodString;
|
|
93
|
+
status: z.ZodString;
|
|
94
|
+
version: z.ZodString;
|
|
95
|
+
platform: z.ZodString;
|
|
96
|
+
connections: z.ZodNumber;
|
|
97
|
+
tps: z.ZodNumber;
|
|
98
|
+
createdAt: z.ZodString;
|
|
99
|
+
}, z.core.$strict>>>;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
|
|
102
|
+
/** Typed operations supplied by a client or mock. */
|
|
103
|
+
interface Operations {
|
|
104
|
+
/** Invoke listDeployments through this connection. */
|
|
105
|
+
listDeployments(): Query<ListDeploymentsInput, ListDeploymentsOutput>;
|
|
106
|
+
}
|
|
107
|
+
/** Named connector connection kept outside Flow state. */
|
|
108
|
+
declare class Connection<BoundOperations = Operations> {
|
|
109
|
+
/** Stable provider and connection name. */
|
|
110
|
+
readonly reference: ConnectionRef;
|
|
111
|
+
/** Bound provider operations. */
|
|
112
|
+
readonly operations: BoundOperations;
|
|
113
|
+
/** Validate a reference and bind operations. */
|
|
114
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
115
|
+
}
|
|
116
|
+
/** Bind a client to a named connection. */
|
|
117
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
118
|
+
/** Bind scripted operations to a named connection. */
|
|
119
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
120
|
+
|
|
121
|
+
export { Connection as C, type Deployment as D, type ListDeploymentsInput as L, type Operations as O, type ListDeploymentsOutput as a, type Config as b, type Credentials as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, DeploymentSchema as g, ListDeploymentsInputSchema as h, ListDeploymentsOutputSchema as i, decodeCredentials as j, isCredentialMaterialError as k, newConnectionWithOperations as l, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { L as ListDeploymentsInput, a as ListDeploymentsOutput, C as Connection, O as Operations, b as Config, c as Credentials } from './connection-BgrPERee.js';
|
|
2
|
+
export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, D as Deployment, g as DeploymentSchema, h as ListDeploymentsInputSchema, i as ListDeploymentsOutputSchema, j as decodeCredentials, k as isCredentialMaterialError, n as newConnection, l as newConnectionWithOperations } from './connection-BgrPERee.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 = "emq";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "emq";
|
|
13
|
+
/** Branch IDs for listDeployments. */
|
|
14
|
+
declare const ListDeploymentsBranch: {
|
|
15
|
+
readonly Listed: "listed";
|
|
16
|
+
readonly ProviderRejected: "providerRejected";
|
|
17
|
+
readonly InvalidResponse: "invalidResponse";
|
|
18
|
+
readonly Defect: "defect";
|
|
19
|
+
};
|
|
20
|
+
/** EMQX Cloud returned zero or more deployments. */
|
|
21
|
+
declare const ListDeploymentsBranchListed: "listed";
|
|
22
|
+
/** EMQX Cloud rejected the key or request. */
|
|
23
|
+
declare const ListDeploymentsBranchProviderRejected: "providerRejected";
|
|
24
|
+
/** EMQX Cloud returned malformed or oversized data. */
|
|
25
|
+
declare const ListDeploymentsBranchInvalidResponse: "invalidResponse";
|
|
26
|
+
/** Local connection settings are invalid. */
|
|
27
|
+
declare const ListDeploymentsBranchDefect: "defect";
|
|
28
|
+
/** Manifest definition for listDeployments. */
|
|
29
|
+
declare const ListDeploymentsDefinition: QueryDefinition;
|
|
30
|
+
/** Manifest metadata for listDeployments. */
|
|
31
|
+
declare const ListDeploymentsMetadata: {
|
|
32
|
+
readonly kind: "query";
|
|
33
|
+
readonly idempotency: "none";
|
|
34
|
+
readonly authorization: "required";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Configuration for the listDeployments connector Step. */
|
|
38
|
+
interface ListDeploymentsStepConfig<StepInput, OperationInput = ListDeploymentsInput, OperationOutput = ListDeploymentsOutput> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
39
|
+
/** Named connection supplying this operation. */
|
|
40
|
+
connection: Connection<{
|
|
41
|
+
listDeployments(): Query<OperationInput, OperationOutput>;
|
|
42
|
+
}>;
|
|
43
|
+
/** Name matching the bound connection. */
|
|
44
|
+
connectionName: string;
|
|
45
|
+
/** EMQX Cloud returned zero or more deployments. */
|
|
46
|
+
listed: StepTarget<QueryResult<OperationOutput>>;
|
|
47
|
+
/** EMQX Cloud rejected the key or request. */
|
|
48
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
49
|
+
/** EMQX Cloud returned malformed or oversized data. */
|
|
50
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
51
|
+
/** Local connection settings are invalid. */
|
|
52
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
53
|
+
}
|
|
54
|
+
/** Build the listDeployments Step from a named connection. */
|
|
55
|
+
declare function newListDeploymentsStep<StepInput, OperationInput = ListDeploymentsInput, OperationOutput = ListDeploymentsOutput>(configuration: ListDeploymentsStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
56
|
+
|
|
57
|
+
/** Open one named Emq connection from Dex project configuration. */
|
|
58
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
59
|
+
|
|
60
|
+
/** Optional provider sender for isolated conformance replay. */
|
|
61
|
+
interface EmqClientOptions {
|
|
62
|
+
/** Sender; omitted uses the SDK HTTPS transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
63
|
+
}
|
|
64
|
+
/** Read deployments scoped by an EMQX Cloud Platform key. */
|
|
65
|
+
declare class EmqClient {
|
|
66
|
+
private readonly credentials;
|
|
67
|
+
private readonly endpoint;
|
|
68
|
+
private readonly timeoutMs;
|
|
69
|
+
private readonly maxResponseBytes;
|
|
70
|
+
private readonly send;
|
|
71
|
+
/** Validate local settings without contacting EMQX Cloud. */
|
|
72
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: EmqClientOptions);
|
|
73
|
+
/** Bind the scoped deployment Query. */ listDeployments(): ListDeploymentsOperation;
|
|
74
|
+
/** Send one bounded deployment-list request. */
|
|
75
|
+
readDeployments(call: Call): Promise<{
|
|
76
|
+
response?: ProviderResponse;
|
|
77
|
+
error?: 'credential' | 'transport' | 'tooLarge';
|
|
78
|
+
retryAfterMs: number;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
/** List deployments accessible to the configured Platform key. */
|
|
82
|
+
declare class ListDeploymentsOperation implements Query<ListDeploymentsInput, ListDeploymentsOutput> {
|
|
83
|
+
private readonly client;
|
|
84
|
+
/** Bind the provider client. */ constructor(client: EmqClient);
|
|
85
|
+
/** Return the generated Query definition. */ definition(): QueryDefinition;
|
|
86
|
+
/** Classify one deployment-list request according to the Go contract. */
|
|
87
|
+
invoke(call: Call, input: ListDeploymentsInput): Promise<QueryAttempt<ListDeploymentsOutput>>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { Config, Connection, ConnectorID, Credentials, EmqClient, type EmqClientOptions, ListDeploymentsBranch, ListDeploymentsBranchDefect, ListDeploymentsBranchInvalidResponse, ListDeploymentsBranchListed, ListDeploymentsBranchProviderRejected, ListDeploymentsDefinition, ListDeploymentsInput, ListDeploymentsMetadata, ListDeploymentsOutput, type ListDeploymentsStepConfig, ProviderID, newListDeploymentsStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
6
|
+
DeploymentSchema,
|
|
7
|
+
ListDeploymentsBranch,
|
|
8
|
+
ListDeploymentsBranchDefect,
|
|
9
|
+
ListDeploymentsBranchInvalidResponse,
|
|
10
|
+
ListDeploymentsBranchListed,
|
|
11
|
+
ListDeploymentsBranchProviderRejected,
|
|
12
|
+
ListDeploymentsDefinition,
|
|
13
|
+
ListDeploymentsInputSchema,
|
|
14
|
+
ListDeploymentsMetadata,
|
|
15
|
+
ListDeploymentsOutputSchema,
|
|
16
|
+
ProviderID,
|
|
17
|
+
decodeCredentials,
|
|
18
|
+
isCredentialMaterialError,
|
|
19
|
+
newConnection,
|
|
20
|
+
newConnectionWithOperations,
|
|
21
|
+
newProjectConnection
|
|
22
|
+
} from "./chunk-MF2GOS7K.js";
|
|
23
|
+
|
|
24
|
+
// src/generated/steps.ts
|
|
25
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
26
|
+
function newListDeploymentsStep(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.listDeployments(), 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/client.ts
|
|
38
|
+
import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
39
|
+
import { BodyTooLargeError, parseRetryAfter, sendProviderRequest } from "@superdurable/connectors-sdk/providerhttp";
|
|
40
|
+
var emptyOutput = { deployments: [] };
|
|
41
|
+
var EmqClient = class {
|
|
42
|
+
/** Validate local settings without contacting EMQX Cloud. */
|
|
43
|
+
constructor(config, credentials, options = {}) {
|
|
44
|
+
this.credentials = credentials;
|
|
45
|
+
if (!config || !credentials) throw new TypeError("EMQX Cloud configuration and credentials are required");
|
|
46
|
+
const selectedEndpoint = config.platformEndpoint;
|
|
47
|
+
let endpoint;
|
|
48
|
+
try {
|
|
49
|
+
endpoint = new URL(selectedEndpoint);
|
|
50
|
+
} catch {
|
|
51
|
+
throw new TypeError("EMQX Cloud Platform endpoint is invalid");
|
|
52
|
+
}
|
|
53
|
+
if (!["https:", "http:"].includes(endpoint.protocol) || endpoint.protocol === "http:" && !["localhost", "127.0.0.1", "[::1]"].includes(endpoint.hostname) || !endpoint.hostname || endpoint.username || endpoint.password || endpoint.search || endpoint.hash || endpoint.pathname !== "/public_api/v1" || selectedEndpoint.endsWith("/")) throw new TypeError("EMQX Cloud Platform endpoint is invalid");
|
|
54
|
+
this.endpoint = selectedEndpoint;
|
|
55
|
+
this.timeoutMs = config.timeoutMs || 1e4;
|
|
56
|
+
this.maxResponseBytes = config.maxResponseBytes || 1048576;
|
|
57
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0 || this.maxResponseBytes > 16 << 20) throw new TypeError("EMQX Cloud request limits are invalid");
|
|
58
|
+
this.send = options.send ?? sendProviderRequest;
|
|
59
|
+
}
|
|
60
|
+
credentials;
|
|
61
|
+
endpoint;
|
|
62
|
+
timeoutMs;
|
|
63
|
+
maxResponseBytes;
|
|
64
|
+
send;
|
|
65
|
+
/** Bind the scoped deployment Query. */
|
|
66
|
+
listDeployments() {
|
|
67
|
+
return new ListDeploymentsOperation(this);
|
|
68
|
+
}
|
|
69
|
+
/** Send one bounded deployment-list request. */
|
|
70
|
+
async readDeployments(call) {
|
|
71
|
+
let key = "", secret = "";
|
|
72
|
+
try {
|
|
73
|
+
const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
74
|
+
key = credentials.platformApiKey instanceof SecretString ? credentials.platformApiKey.reveal() : "";
|
|
75
|
+
secret = credentials.platformApiSecret instanceof SecretString ? credentials.platformApiSecret.reveal() : "";
|
|
76
|
+
} catch {
|
|
77
|
+
return { error: "credential", retryAfterMs: 0 };
|
|
78
|
+
}
|
|
79
|
+
if (!validBasicCredential(key) || !validBasicCredential(secret) || key.includes(":")) return { error: "credential", retryAfterMs: 0 };
|
|
80
|
+
const request = { url: this.endpoint + "/deployments", method: "GET", headers: { Authorization: "Basic " + Buffer.from(key + ":" + secret).toString("base64"), Accept: "application/json" }, timeoutMs: this.timeoutMs, maxResponseBytes: this.maxResponseBytes, addressPolicy: "publicHTTPS", signal: call.context.cancellationSignal };
|
|
81
|
+
let response;
|
|
82
|
+
try {
|
|
83
|
+
response = await this.send(request);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0) return { response: { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() }, error: "tooLarge", retryAfterMs: 0 };
|
|
86
|
+
return { error: "transport", retryAfterMs: 0 };
|
|
87
|
+
}
|
|
88
|
+
return { response, error: response.body.length > this.maxResponseBytes ? "tooLarge" : void 0, retryAfterMs: parseRetryAfter(header(response.headers, "retry-after")) };
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var ListDeploymentsOperation = class {
|
|
92
|
+
/** Bind the provider client. */
|
|
93
|
+
constructor(client) {
|
|
94
|
+
this.client = client;
|
|
95
|
+
}
|
|
96
|
+
client;
|
|
97
|
+
/** Return the generated Query definition. */
|
|
98
|
+
definition() {
|
|
99
|
+
return ListDeploymentsDefinition;
|
|
100
|
+
}
|
|
101
|
+
/** Classify one deployment-list request according to the Go contract. */
|
|
102
|
+
async invoke(call, input) {
|
|
103
|
+
void input;
|
|
104
|
+
const exchange = await this.client.readDeployments(call);
|
|
105
|
+
if (exchange.error === "credential") return branch("defect", "AUTHENTICATION");
|
|
106
|
+
if (exchange.error === "transport" || !exchange.response) return retry("AVAILABILITY");
|
|
107
|
+
const { status, body } = exchange.response;
|
|
108
|
+
if (status === 429) return retry("RATE_LIMIT", exchange.retryAfterMs);
|
|
109
|
+
if (status === 408 || status >= 500) return retry("AVAILABILITY", exchange.retryAfterMs);
|
|
110
|
+
if (status !== 200) return branch("providerRejected", status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : "PROVIDER_REJECTION");
|
|
111
|
+
if (exchange.error === "tooLarge") return branch("invalidResponse", "RESPONSE_TOO_LARGE");
|
|
112
|
+
let wire;
|
|
113
|
+
try {
|
|
114
|
+
wire = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
|
|
115
|
+
} catch {
|
|
116
|
+
return branch("invalidResponse", "PROTOCOL");
|
|
117
|
+
}
|
|
118
|
+
if (!Array.isArray(wire)) return branch("invalidResponse", "PROTOCOL");
|
|
119
|
+
const deployments = [];
|
|
120
|
+
for (const item of wire) {
|
|
121
|
+
if (!isRecord(item) || !nonempty(item.deploymentID) || !nonempty(item.deploymentName) || !nonempty(item.deploymentType) || !nonempty(item.status) || !Number.isSafeInteger(item.connections) || !Number.isSafeInteger(item.tps) || item.connections < 0 || item.tps < 0) return branch("invalidResponse", "PROTOCOL");
|
|
122
|
+
deployments.push({ deploymentId: item.deploymentID, deploymentName: item.deploymentName, deploymentType: item.deploymentType, projectName: String(item.projectName ?? ""), region: String(item.region ?? ""), status: item.status, version: String(item.version ?? ""), platform: String(item.platform ?? ""), connections: item.connections, tps: item.tps, createdAt: String(item.createAt ?? "") });
|
|
123
|
+
}
|
|
124
|
+
return newQueryBranch("listed", { deployments }, {});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
function validBasicCredential(value) {
|
|
128
|
+
return !!value && value.length <= 512 && !/[^\x21-\x7e]/.test(value);
|
|
129
|
+
}
|
|
130
|
+
function isRecord(value) {
|
|
131
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
132
|
+
}
|
|
133
|
+
function nonempty(value) {
|
|
134
|
+
return typeof value === "string" && value.length > 0;
|
|
135
|
+
}
|
|
136
|
+
function header(headers, name) {
|
|
137
|
+
const value = Object.entries(headers).find(([key]) => key.toLowerCase() === name)?.[1];
|
|
138
|
+
return Array.isArray(value) ? value[0] ?? "" : value ?? "";
|
|
139
|
+
}
|
|
140
|
+
function failure(kind) {
|
|
141
|
+
return { provider: "emq", operation: "listDeployments", kind, message: "EMQX Cloud deployment query failed" };
|
|
142
|
+
}
|
|
143
|
+
function branch(name, kind) {
|
|
144
|
+
return newQueryBranch(name, emptyOutput, {}, failure(kind));
|
|
145
|
+
}
|
|
146
|
+
function retry(kind, delay = 0) {
|
|
147
|
+
return newQueryRetry(failure(kind), delay);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/project.ts
|
|
151
|
+
function newProjectConnection2(project, connectionName) {
|
|
152
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
153
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "emq" && entry.connectionName === name);
|
|
154
|
+
if (!selected) throw new TypeError("Emq project connection is not configured");
|
|
155
|
+
const fields = selected.configuration;
|
|
156
|
+
const config = ConfigSchema.parse({ ...fields, ...fields.timeout !== void 0 ? { timeoutMs: parseDurationMilliseconds(fields.timeout) } : {} });
|
|
157
|
+
const credentials = {
|
|
158
|
+
async resolve(_call, signal) {
|
|
159
|
+
return decodeCredentials(await loadedProject.resolveCredential("emq", name, signal));
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return new EmqClient(config, credentials);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function parseDurationMilliseconds(value) {
|
|
166
|
+
if (typeof value === "number") return Math.ceil(value / 1e6);
|
|
167
|
+
if (typeof value !== "string") throw new TypeError("timeout must be a duration");
|
|
168
|
+
let remaining = value;
|
|
169
|
+
let milliseconds = 0;
|
|
170
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
171
|
+
while (remaining) {
|
|
172
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
173
|
+
if (!part) throw new TypeError("timeout must be a positive Go duration");
|
|
174
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
175
|
+
remaining = remaining.slice(part[0].length);
|
|
176
|
+
}
|
|
177
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("timeout must resolve to positive whole milliseconds");
|
|
178
|
+
return milliseconds;
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
ConfigSchema,
|
|
182
|
+
Connection,
|
|
183
|
+
ConnectorID,
|
|
184
|
+
CredentialMaterialError,
|
|
185
|
+
DeploymentSchema,
|
|
186
|
+
EmqClient,
|
|
187
|
+
ListDeploymentsBranch,
|
|
188
|
+
ListDeploymentsBranchDefect,
|
|
189
|
+
ListDeploymentsBranchInvalidResponse,
|
|
190
|
+
ListDeploymentsBranchListed,
|
|
191
|
+
ListDeploymentsBranchProviderRejected,
|
|
192
|
+
ListDeploymentsDefinition,
|
|
193
|
+
ListDeploymentsInputSchema,
|
|
194
|
+
ListDeploymentsMetadata,
|
|
195
|
+
ListDeploymentsOutputSchema,
|
|
196
|
+
ProviderID,
|
|
197
|
+
decodeCredentials,
|
|
198
|
+
isCredentialMaterialError,
|
|
199
|
+
newConnection,
|
|
200
|
+
newConnectionWithOperations,
|
|
201
|
+
newListDeploymentsStep,
|
|
202
|
+
newProjectConnection2 as newProjectConnection
|
|
203
|
+
};
|
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 ListDeploymentsInput, a as ListDeploymentsOutput, D as Deployment } from './connection-BgrPERee.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for ListDeploymentsInput in scripted cases. */
|
|
7
|
+
declare const emptyListDeploymentsInput: ListDeploymentsInput;
|
|
8
|
+
/** Go zero value for Deployment in scripted cases. */
|
|
9
|
+
declare const emptyDeployment: Deployment;
|
|
10
|
+
/** Go zero value for ListDeploymentsOutput in scripted cases. */
|
|
11
|
+
declare const emptyListDeploymentsOutput: ListDeploymentsOutput;
|
|
12
|
+
/** Script the listed branch. */
|
|
13
|
+
declare function listDeploymentsListed(value: ListDeploymentsOutput, failure?: Failure): Case<ListDeploymentsOutput>;
|
|
14
|
+
/** Script the providerRejected branch. */
|
|
15
|
+
declare function listDeploymentsProviderRejected(value: ListDeploymentsOutput, failure?: Failure): Case<ListDeploymentsOutput>;
|
|
16
|
+
/** Script the invalidResponse branch. */
|
|
17
|
+
declare function listDeploymentsInvalidResponse(value: ListDeploymentsOutput, failure?: Failure): Case<ListDeploymentsOutput>;
|
|
18
|
+
/** Script the defect branch. */
|
|
19
|
+
declare function listDeploymentsDefect(value: ListDeploymentsOutput, failure?: Failure): Case<ListDeploymentsOutput>;
|
|
20
|
+
/** Script a safe retry of listDeployments. */
|
|
21
|
+
declare function listDeploymentsRetry(failure: Failure, retryAfterMs?: number): Case<ListDeploymentsOutput>;
|
|
22
|
+
/** Manifest scenario twoDeployments for listDeployments. */
|
|
23
|
+
declare function listDeploymentsTwoDeployments(): Case<ListDeploymentsOutput>;
|
|
24
|
+
/** Default listDeployments scenario. */
|
|
25
|
+
declare function listDeploymentsDefault(): Case<ListDeploymentsOutput>;
|
|
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
|
+
listDeployments(): MockQuery<ListDeploymentsInput, ListDeploymentsOutput>;
|
|
32
|
+
assertNoFailures(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { GeneratedMock, emptyDeployment, emptyListDeploymentsInput, emptyListDeploymentsOutput, listDeploymentsDefault, listDeploymentsDefect, listDeploymentsInvalidResponse, listDeploymentsListed, listDeploymentsProviderRejected, listDeploymentsRetry, listDeploymentsTwoDeployments };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeploymentSchema,
|
|
3
|
+
ListDeploymentsDefinition,
|
|
4
|
+
ListDeploymentsInputSchema,
|
|
5
|
+
ListDeploymentsOutputSchema,
|
|
6
|
+
ProviderID,
|
|
7
|
+
newConnectionWithOperations
|
|
8
|
+
} from "./chunk-MF2GOS7K.js";
|
|
9
|
+
|
|
10
|
+
// src/generated/mock.ts
|
|
11
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
12
|
+
var emptyListDeploymentsInput = ListDeploymentsInputSchema.parse({});
|
|
13
|
+
var emptyDeployment = DeploymentSchema.parse({
|
|
14
|
+
"deploymentId": "",
|
|
15
|
+
"deploymentName": "",
|
|
16
|
+
"deploymentType": "",
|
|
17
|
+
"projectName": "",
|
|
18
|
+
"region": "",
|
|
19
|
+
"status": "",
|
|
20
|
+
"version": "",
|
|
21
|
+
"platform": "",
|
|
22
|
+
"connections": 0,
|
|
23
|
+
"tps": 0,
|
|
24
|
+
"createdAt": ""
|
|
25
|
+
});
|
|
26
|
+
var emptyListDeploymentsOutput = ListDeploymentsOutputSchema.parse({
|
|
27
|
+
"deployments": []
|
|
28
|
+
});
|
|
29
|
+
function listDeploymentsListed(value, failure) {
|
|
30
|
+
return branchCase("listed", value, failure);
|
|
31
|
+
}
|
|
32
|
+
function listDeploymentsProviderRejected(value, failure) {
|
|
33
|
+
return branchCase("providerRejected", value, failure);
|
|
34
|
+
}
|
|
35
|
+
function listDeploymentsInvalidResponse(value, failure) {
|
|
36
|
+
return branchCase("invalidResponse", value, failure);
|
|
37
|
+
}
|
|
38
|
+
function listDeploymentsDefect(value, failure) {
|
|
39
|
+
return branchCase("defect", value, failure);
|
|
40
|
+
}
|
|
41
|
+
function listDeploymentsRetry(failure, retryAfterMs = 0) {
|
|
42
|
+
return retryCase(failure, retryAfterMs);
|
|
43
|
+
}
|
|
44
|
+
function listDeploymentsTwoDeployments() {
|
|
45
|
+
const value = ListDeploymentsOutputSchema.parse({ "deployments": [{ "connections": 1e3, "createdAt": "2024-11-21 02:51", "deploymentId": "mdfba81f", "deploymentName": "deployment-mdfba81f", "deploymentType": "serverless", "platform": "AWS", "projectName": "default", "region": "N. Virginia (us-east-1)", "status": "stopped", "tps": 1e3, "version": "v5" }, { "connections": 1e3, "createdAt": "2025-04-17 08:36", "deploymentId": "b1f77113", "deploymentName": "deployment-b1f77113", "deploymentType": "dedicatedFlex", "platform": "AWS", "projectName": "test", "region": "N. Virginia (us-east-1)", "status": "running", "tps": 1e3, "version": "v5" }] });
|
|
46
|
+
return branchCase("listed", value);
|
|
47
|
+
}
|
|
48
|
+
function listDeploymentsDefault() {
|
|
49
|
+
return listDeploymentsTwoDeployments();
|
|
50
|
+
}
|
|
51
|
+
var GeneratedMock = class {
|
|
52
|
+
#listDeployments;
|
|
53
|
+
#connection;
|
|
54
|
+
constructor(connectionName) {
|
|
55
|
+
this.#listDeployments = newQuery(ListDeploymentsDefinition).default(listDeploymentsDefault());
|
|
56
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
57
|
+
}
|
|
58
|
+
connection() {
|
|
59
|
+
return this.#connection;
|
|
60
|
+
}
|
|
61
|
+
listDeployments() {
|
|
62
|
+
return this.#listDeployments;
|
|
63
|
+
}
|
|
64
|
+
assertNoFailures() {
|
|
65
|
+
this.#listDeployments.assertNoFailures();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export {
|
|
69
|
+
GeneratedMock,
|
|
70
|
+
emptyDeployment,
|
|
71
|
+
emptyListDeploymentsInput,
|
|
72
|
+
emptyListDeploymentsOutput,
|
|
73
|
+
listDeploymentsDefault,
|
|
74
|
+
listDeploymentsDefect,
|
|
75
|
+
listDeploymentsInvalidResponse,
|
|
76
|
+
listDeploymentsListed,
|
|
77
|
+
listDeploymentsProviderRejected,
|
|
78
|
+
listDeploymentsRetry,
|
|
79
|
+
listDeploymentsTwoDeployments
|
|
80
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-emq",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "EMQX Cloud Platform deployment connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/emq/typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
14
|
+
},
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./mock": {
|
|
23
|
+
"types": "./dist/mock.d.ts",
|
|
24
|
+
"import": "./dist/mock.js"
|
|
25
|
+
},
|
|
26
|
+
"./dex-connector.json": "./dex-connector.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"dex-connector.json"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"prepack": "npm run build",
|
|
36
|
+
"build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"lint": "eslint src test examples",
|
|
39
|
+
"test": "vitest run --exclude test/integration/**",
|
|
40
|
+
"test:integration": "vitest run test/integration/*.integration.test.ts",
|
|
41
|
+
"example:worker": "tsx examples/basic/worker.ts",
|
|
42
|
+
"example:start": "tsx examples/basic/start.ts",
|
|
43
|
+
"check": "npm run typecheck && npm run lint && npm test && npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@superdurable/connectors-sdk": "0.1.1",
|
|
47
|
+
"@superdurable/dex": ">=1.28.0",
|
|
48
|
+
"zod": "^4.1.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@eslint/js": "^9.0.0",
|
|
52
|
+
"@types/node": "^22.0.0",
|
|
53
|
+
"eslint": "^9.0.0",
|
|
54
|
+
"tsup": "^8.0.0",
|
|
55
|
+
"tsx": "^4.23.15",
|
|
56
|
+
"typescript": "^5.9.0",
|
|
57
|
+
"typescript-eslint": "^8.0.0",
|
|
58
|
+
"vitest": "^3.0.0",
|
|
59
|
+
"yaml": "^2.9.1"
|
|
60
|
+
}
|
|
61
|
+
}
|