@superdurable/connector-amazon-redshift 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 +2 -2
- package/dex-connector.json +68 -0
- package/dist/chunk-OEV6UKQQ.js +113 -0
- package/dist/connection-BikiyVDi.d.ts +77 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +275 -0
- package/dist/mock.d.ts +35 -0
- package/dist/mock.js +75 -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 keyation 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,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Amazon Redshift TypeScript package
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`AmazonRedshiftClient.getStatementResult()` binds the signed result-page Query. `GetStatementResultInput` holds `statementId` and `nextToken` (blank for the first page). `StatementResultPage` contains `records`, `totalNumRows`, and `nextToken`. See the [connector guide](../README.md) for configuration and IAM permissions. The [runnable Flow](examples/statement-results/README.md) exercises a real Dex Worker with a local provider fixture. Live AWS access has not been verified.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "amazon-redshift",
|
|
3
|
+
"releaseTag": "connectors/amazon/redshift/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-amazon-redshift",
|
|
7
|
+
"version": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newGetStatementResultStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "getStatementResult",
|
|
14
|
+
"inputType": "GetStatementResultInput",
|
|
15
|
+
"description": "Fetch one JSON result page by Redshift Data API statement UUID and optional page token.",
|
|
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": "missing",
|
|
30
|
+
"field": "missing",
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "providerRejected",
|
|
35
|
+
"field": "providerRejected",
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "invalidResponse",
|
|
40
|
+
"field": "invalidResponse",
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "defect",
|
|
45
|
+
"field": "defect",
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"inputSchema": {
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"description": "GetStatementResultInput identifies a JSON result page by statement UUID and optional token.",
|
|
52
|
+
"properties": {
|
|
53
|
+
"nextToken": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
},
|
|
56
|
+
"statementId": {
|
|
57
|
+
"type": "string"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"required": [
|
|
61
|
+
"nextToken",
|
|
62
|
+
"statementId"
|
|
63
|
+
],
|
|
64
|
+
"type": "object"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var ConfigSchema = z.object({
|
|
5
|
+
"region": z.string().optional(),
|
|
6
|
+
"endpoint": z.string().optional(),
|
|
7
|
+
"timeoutMs": z.number().int().optional(),
|
|
8
|
+
"maxResponseBytes": z.number().int().optional()
|
|
9
|
+
});
|
|
10
|
+
function decodeCredentials(value) {
|
|
11
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
12
|
+
const fields = value;
|
|
13
|
+
const allowed = /* @__PURE__ */ new Set(["access_key_id", "secret_access_key", "session_token"]);
|
|
14
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
15
|
+
if (fields["access_key_id"] != null && !(typeof fields["access_key_id"] === "string")) throw new TypeError("credential access_key_id has an invalid type");
|
|
16
|
+
if (fields["secret_access_key"] != null && !(typeof fields["secret_access_key"] === "string")) throw new TypeError("credential secret_access_key has an invalid type");
|
|
17
|
+
if (fields["session_token"] != null && !(typeof fields["session_token"] === "string")) throw new TypeError("credential session_token has an invalid type");
|
|
18
|
+
const credentials = {};
|
|
19
|
+
if (!fields["access_key_id"]) throw new TypeError("credential access_key_id is required");
|
|
20
|
+
credentials.accessKeyId = new SecretString(fields["access_key_id"] ?? "");
|
|
21
|
+
if (!fields["secret_access_key"]) throw new TypeError("credential secret_access_key is required");
|
|
22
|
+
credentials.secretAccessKey = new SecretString(fields["secret_access_key"] ?? "");
|
|
23
|
+
credentials.sessionToken = new SecretString(fields["session_token"] ?? "");
|
|
24
|
+
return credentials;
|
|
25
|
+
}
|
|
26
|
+
var GetStatementResultInputSchema = z.strictObject({
|
|
27
|
+
"statementId": z.string(),
|
|
28
|
+
"nextToken": z.string()
|
|
29
|
+
});
|
|
30
|
+
var StatementResultPageSchema = z.strictObject({
|
|
31
|
+
"records": z.array(z.unknown().nullable()).nullable(),
|
|
32
|
+
"nextToken": z.string(),
|
|
33
|
+
"totalNumRows": z.number().int()
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// src/generated/definitions.ts
|
|
37
|
+
var ConnectorID = "amazon-redshift";
|
|
38
|
+
var ProviderID = "amazon-redshift";
|
|
39
|
+
var GetStatementResultBranch = {
|
|
40
|
+
Fetched: "fetched",
|
|
41
|
+
Missing: "missing",
|
|
42
|
+
ProviderRejected: "providerRejected",
|
|
43
|
+
InvalidResponse: "invalidResponse",
|
|
44
|
+
Defect: "defect"
|
|
45
|
+
};
|
|
46
|
+
var GetStatementResultBranchFetched = GetStatementResultBranch.Fetched;
|
|
47
|
+
var GetStatementResultBranchMissing = GetStatementResultBranch.Missing;
|
|
48
|
+
var GetStatementResultBranchProviderRejected = GetStatementResultBranch.ProviderRejected;
|
|
49
|
+
var GetStatementResultBranchInvalidResponse = GetStatementResultBranch.InvalidResponse;
|
|
50
|
+
var GetStatementResultBranchDefect = GetStatementResultBranch.Defect;
|
|
51
|
+
var GetStatementResultDefinition = {
|
|
52
|
+
operation: { connectorId: ConnectorID, operationId: "getStatementResult" },
|
|
53
|
+
branches: [
|
|
54
|
+
{ id: "fetched", description: "Redshift returned the statement result page." },
|
|
55
|
+
{ id: "missing", description: "Redshift does not retain the specified statement result.", optional: true },
|
|
56
|
+
{ id: "providerRejected", description: "Redshift conclusively rejected the lookup or credentials.", optional: true },
|
|
57
|
+
{ id: "invalidResponse", description: "Redshift returned malformed or oversized result JSON.", optional: true },
|
|
58
|
+
{ id: "defect", description: "The statement ID, endpoint, Region, or credentials are invalid.", optional: true }
|
|
59
|
+
],
|
|
60
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
61
|
+
};
|
|
62
|
+
var GetStatementResultMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
63
|
+
|
|
64
|
+
// src/generated/connection.ts
|
|
65
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
66
|
+
var Connection = class {
|
|
67
|
+
/** Stable provider and connection name. */
|
|
68
|
+
reference;
|
|
69
|
+
/** Bound provider operations. */
|
|
70
|
+
operations;
|
|
71
|
+
/** Validate a reference and bind operations. */
|
|
72
|
+
constructor(reference, operations) {
|
|
73
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
74
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
75
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
76
|
+
this.operations = operations;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
function newConnection(client, reference) {
|
|
80
|
+
if (!client) throw new TypeError("connector client is required");
|
|
81
|
+
return new Connection(reference, client);
|
|
82
|
+
}
|
|
83
|
+
function newConnectionWithOperations(operations, reference) {
|
|
84
|
+
return new Connection(reference, operations);
|
|
85
|
+
}
|
|
86
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
87
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
88
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
89
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
90
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
91
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
ConfigSchema,
|
|
96
|
+
decodeCredentials,
|
|
97
|
+
GetStatementResultInputSchema,
|
|
98
|
+
StatementResultPageSchema,
|
|
99
|
+
ConnectorID,
|
|
100
|
+
ProviderID,
|
|
101
|
+
GetStatementResultBranch,
|
|
102
|
+
GetStatementResultBranchFetched,
|
|
103
|
+
GetStatementResultBranchMissing,
|
|
104
|
+
GetStatementResultBranchProviderRejected,
|
|
105
|
+
GetStatementResultBranchInvalidResponse,
|
|
106
|
+
GetStatementResultBranchDefect,
|
|
107
|
+
GetStatementResultDefinition,
|
|
108
|
+
GetStatementResultMetadata,
|
|
109
|
+
Connection,
|
|
110
|
+
newConnection,
|
|
111
|
+
newConnectionWithOperations,
|
|
112
|
+
newProjectConnection
|
|
113
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
/** AWS Region code containing the statement, such as eu-west-1. In https://console.aws.amazon.com/redshiftv2 > Query editor v2, use the console Region selector; blank uses the displayed default. */
|
|
7
|
+
region?: string;
|
|
8
|
+
/** Optional Redshift Data API root. Blank derives the regional AWS endpoint from region. Override only for a trusted compatible endpoint; local tests may use loopback HTTP. */
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
/** Maximum duration of one result-page request as a positive Go duration such as 15s. Blank uses the displayed default; increase only for a slow network. Runtime value in milliseconds. */
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
/** Maximum complete result page in bytes. Blank uses the displayed default; increase only for a known large page. */
|
|
13
|
+
maxResponseBytes?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Runtime schema for manifest configuration. */
|
|
16
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
17
|
+
region: z.ZodOptional<z.ZodString>;
|
|
18
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
19
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
/** Private connector credentials resolved by the host. */
|
|
23
|
+
interface Credentials {
|
|
24
|
+
/** Secret-stored AWS access key ID from https://console.aws.amazon.com/iam > Users > selected user > Security credentials > Access keys > Create access key. Long-term IDs start AKIA and temporary IDs start ASIA. Blank prevents signing. */
|
|
25
|
+
accessKeyId: SecretString;
|
|
26
|
+
/** Secret access key paired with access_key_id, shown once on the IAM Retrieve access keys page. Copy the Value, never the key ID. Blank prevents signing; rotate through IAM. */
|
|
27
|
+
secretAccessKey: SecretString;
|
|
28
|
+
/** Secret session token for temporary ASIA credentials, from AWS STS. Blank means long-term IAM user credentials. Temporary credentials expire; replace all three fields before expiry. */
|
|
29
|
+
sessionToken?: SecretString;
|
|
30
|
+
}
|
|
31
|
+
/** Decode private credential fields for the connector. */
|
|
32
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
33
|
+
/** Host-owned source of private connector credentials. */
|
|
34
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
35
|
+
/** GetStatementResultInput identifies a JSON result page by statement UUID and optional token. */
|
|
36
|
+
interface GetStatementResultInput {
|
|
37
|
+
"statementId": string;
|
|
38
|
+
"nextToken": string;
|
|
39
|
+
}
|
|
40
|
+
/** StatementResultPage holds one page of Redshift Field rows and a token for the next page. */
|
|
41
|
+
interface StatementResultPage {
|
|
42
|
+
"records": Array<unknown | null> | null;
|
|
43
|
+
"nextToken": string;
|
|
44
|
+
"totalNumRows": number;
|
|
45
|
+
}
|
|
46
|
+
/** Runtime validator for GetStatementResultInput. */
|
|
47
|
+
declare const GetStatementResultInputSchema: z.ZodObject<{
|
|
48
|
+
statementId: z.ZodString;
|
|
49
|
+
nextToken: z.ZodString;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
/** Runtime validator for StatementResultPage. */
|
|
52
|
+
declare const StatementResultPageSchema: z.ZodObject<{
|
|
53
|
+
records: z.ZodNullable<z.ZodArray<z.ZodNullable<z.ZodUnknown>>>;
|
|
54
|
+
nextToken: z.ZodString;
|
|
55
|
+
totalNumRows: z.ZodNumber;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
|
|
58
|
+
/** Typed operations supplied by a client or mock. */
|
|
59
|
+
interface Operations {
|
|
60
|
+
/** Invoke getStatementResult through this connection. */
|
|
61
|
+
getStatementResult(): Query<GetStatementResultInput, StatementResultPage>;
|
|
62
|
+
}
|
|
63
|
+
/** Named connector connection kept outside Flow state. */
|
|
64
|
+
declare class Connection<BoundOperations = Operations> {
|
|
65
|
+
/** Stable provider and connection name. */
|
|
66
|
+
readonly reference: ConnectionRef;
|
|
67
|
+
/** Bound provider operations. */
|
|
68
|
+
readonly operations: BoundOperations;
|
|
69
|
+
/** Validate a reference and bind operations. */
|
|
70
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
71
|
+
}
|
|
72
|
+
/** Bind a client to a named connection. */
|
|
73
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
74
|
+
/** Bind scripted operations to a named connection. */
|
|
75
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
76
|
+
|
|
77
|
+
export { Connection as C, type GetStatementResultInput as G, type Operations as O, type StatementResultPage as S, type Config as a, type Credentials as b, ConfigSchema as c, type CredentialSource as d, GetStatementResultInputSchema as e, StatementResultPageSchema as f, decodeCredentials as g, newConnectionWithOperations as h, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { G as GetStatementResultInput, S as StatementResultPage, C as Connection, O as Operations, a as Config, b as Credentials } from './connection-BikiyVDi.js';
|
|
2
|
+
export { c as ConfigSchema, d as CredentialSource, e as GetStatementResultInputSchema, f as StatementResultPageSchema, g as decodeCredentials, n as newConnection, h as newConnectionWithOperations } from './connection-BikiyVDi.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 = "amazon-redshift";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "amazon-redshift";
|
|
13
|
+
/** Branch IDs for getStatementResult. */
|
|
14
|
+
declare const GetStatementResultBranch: {
|
|
15
|
+
readonly Fetched: "fetched";
|
|
16
|
+
readonly Missing: "missing";
|
|
17
|
+
readonly ProviderRejected: "providerRejected";
|
|
18
|
+
readonly InvalidResponse: "invalidResponse";
|
|
19
|
+
readonly Defect: "defect";
|
|
20
|
+
};
|
|
21
|
+
/** Redshift returned the statement result page. */
|
|
22
|
+
declare const GetStatementResultBranchFetched: "fetched";
|
|
23
|
+
/** Redshift does not retain the specified statement result. */
|
|
24
|
+
declare const GetStatementResultBranchMissing: "missing";
|
|
25
|
+
/** Redshift conclusively rejected the lookup or credentials. */
|
|
26
|
+
declare const GetStatementResultBranchProviderRejected: "providerRejected";
|
|
27
|
+
/** Redshift returned malformed or oversized result JSON. */
|
|
28
|
+
declare const GetStatementResultBranchInvalidResponse: "invalidResponse";
|
|
29
|
+
/** The statement ID, endpoint, Region, or credentials are invalid. */
|
|
30
|
+
declare const GetStatementResultBranchDefect: "defect";
|
|
31
|
+
/** Manifest definition for getStatementResult. */
|
|
32
|
+
declare const GetStatementResultDefinition: QueryDefinition;
|
|
33
|
+
/** Manifest metadata for getStatementResult. */
|
|
34
|
+
declare const GetStatementResultMetadata: {
|
|
35
|
+
readonly kind: "query";
|
|
36
|
+
readonly idempotency: "none";
|
|
37
|
+
readonly authorization: "required";
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Configuration for the getStatementResult connector Step. */
|
|
41
|
+
interface GetStatementResultStepConfig<StepInput, OperationInput = GetStatementResultInput, OperationOutput = StatementResultPage> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
42
|
+
/** Named connection supplying this operation. */
|
|
43
|
+
connection: Connection<{
|
|
44
|
+
getStatementResult(): Query<OperationInput, OperationOutput>;
|
|
45
|
+
}>;
|
|
46
|
+
/** Name matching the bound connection. */
|
|
47
|
+
connectionName: string;
|
|
48
|
+
/** Redshift returned the statement result page. */
|
|
49
|
+
fetched: StepTarget<QueryResult<OperationOutput>>;
|
|
50
|
+
/** Redshift does not retain the specified statement result. */
|
|
51
|
+
missing?: StepTarget<QueryResult<OperationOutput>>;
|
|
52
|
+
/** Redshift conclusively rejected the lookup or credentials. */
|
|
53
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
54
|
+
/** Redshift returned malformed or oversized result JSON. */
|
|
55
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
56
|
+
/** The statement ID, endpoint, Region, or credentials are invalid. */
|
|
57
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
58
|
+
}
|
|
59
|
+
/** Build the getStatementResult Step from a named connection. */
|
|
60
|
+
declare function newGetStatementResultStep<StepInput, OperationInput = GetStatementResultInput, OperationOutput = StatementResultPage>(configuration: GetStatementResultStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
61
|
+
|
|
62
|
+
/** Open one named Amazon Redshift connection from Dex project configuration. */
|
|
63
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
64
|
+
|
|
65
|
+
/** Injectable transport and clock for tests and local applications. */
|
|
66
|
+
interface AmazonRedshiftClientOptions {
|
|
67
|
+
/** Provider sender; omitted uses the SDK transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
68
|
+
/** Signing clock; omitted uses the current time. */ now?: () => Date;
|
|
69
|
+
}
|
|
70
|
+
interface Exchange {
|
|
71
|
+
status: number;
|
|
72
|
+
body: Uint8Array;
|
|
73
|
+
retryAfterMs: number;
|
|
74
|
+
error?: 'credential' | 'request' | 'tooLarge';
|
|
75
|
+
}
|
|
76
|
+
/** Authenticated Redshift client for signed GetStatementResult requests. */
|
|
77
|
+
declare class AmazonRedshiftClient {
|
|
78
|
+
private readonly credentials;
|
|
79
|
+
private readonly endpoint;
|
|
80
|
+
private readonly region;
|
|
81
|
+
private readonly timeoutMs;
|
|
82
|
+
private readonly maxResponseBytes;
|
|
83
|
+
private readonly send;
|
|
84
|
+
private readonly now;
|
|
85
|
+
/** Validate the Region, endpoint, and limits without contacting AWS. */
|
|
86
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: AmazonRedshiftClientOptions);
|
|
87
|
+
/** Bind the getStatementResult Query. */ getStatementResult(): GetStatementResultOperation;
|
|
88
|
+
/** Sign and send one bounded GetStatementResult request. */
|
|
89
|
+
readStatementResult(call: Call, body: Buffer): Promise<Exchange>;
|
|
90
|
+
}
|
|
91
|
+
/** Fetch one cached SQL result page by statement UUID. */
|
|
92
|
+
declare class GetStatementResultOperation implements Query<GetStatementResultInput, StatementResultPage> {
|
|
93
|
+
private readonly client;
|
|
94
|
+
/** Bind the provider client. */ constructor(client: AmazonRedshiftClient);
|
|
95
|
+
/** Return the generated Query contract. */ definition(): QueryDefinition;
|
|
96
|
+
/** Classify provider outcomes consistently with the Go implementation. */
|
|
97
|
+
invoke(call: Call, input: GetStatementResultInput): Promise<QueryAttempt<StatementResultPage>>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { AmazonRedshiftClient, type AmazonRedshiftClientOptions, Config, Connection, ConnectorID, Credentials, GetStatementResultBranch, GetStatementResultBranchDefect, GetStatementResultBranchFetched, GetStatementResultBranchInvalidResponse, GetStatementResultBranchMissing, GetStatementResultBranchProviderRejected, GetStatementResultDefinition, GetStatementResultInput, GetStatementResultMetadata, GetStatementResultOperation, type GetStatementResultStepConfig, ProviderID, StatementResultPage, newGetStatementResultStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
GetStatementResultBranch,
|
|
6
|
+
GetStatementResultBranchDefect,
|
|
7
|
+
GetStatementResultBranchFetched,
|
|
8
|
+
GetStatementResultBranchInvalidResponse,
|
|
9
|
+
GetStatementResultBranchMissing,
|
|
10
|
+
GetStatementResultBranchProviderRejected,
|
|
11
|
+
GetStatementResultDefinition,
|
|
12
|
+
GetStatementResultInputSchema,
|
|
13
|
+
GetStatementResultMetadata,
|
|
14
|
+
ProviderID,
|
|
15
|
+
StatementResultPageSchema,
|
|
16
|
+
decodeCredentials,
|
|
17
|
+
newConnection,
|
|
18
|
+
newConnectionWithOperations,
|
|
19
|
+
newProjectConnection
|
|
20
|
+
} from "./chunk-OEV6UKQQ.js";
|
|
21
|
+
|
|
22
|
+
// src/generated/steps.ts
|
|
23
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
24
|
+
function newGetStatementResultStep(configuration) {
|
|
25
|
+
const { connection, connectionName, fetched, missing, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
26
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
27
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getStatementResult(), connection: connection.reference, branches: [
|
|
28
|
+
goToBranch("fetched", fetched),
|
|
29
|
+
...missing ? [goToBranch("missing", missing)] : [],
|
|
30
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
31
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
32
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/project.ts
|
|
37
|
+
import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
38
|
+
import { z } from "zod";
|
|
39
|
+
|
|
40
|
+
// src/client.ts
|
|
41
|
+
import { createHash, createHmac } from "crypto";
|
|
42
|
+
import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
43
|
+
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
44
|
+
var emptyPage = () => ({ records: [], nextToken: "", totalNumRows: 0 });
|
|
45
|
+
var regionPattern = /^[a-z]{2}(?:-gov)?-[a-z]+-[0-9]+$/;
|
|
46
|
+
var statementIDPattern = /^[a-z0-9]{8}(?:-[a-z0-9]{4}){3}-[a-z0-9]{12}(?::[0-9]{1,2})?$/;
|
|
47
|
+
var AmazonRedshiftClient = class {
|
|
48
|
+
/** Validate the Region, endpoint, and limits without contacting AWS. */
|
|
49
|
+
constructor(config, credentials, options = {}) {
|
|
50
|
+
this.credentials = credentials;
|
|
51
|
+
if (!config || !credentials) throw new TypeError("Redshift configuration and credentials are required");
|
|
52
|
+
this.region = config.region || "us-east-1";
|
|
53
|
+
if (!regionPattern.test(this.region)) throw new TypeError("Redshift Region is invalid");
|
|
54
|
+
this.endpoint = validateBaseURL(config.endpoint || `https://redshift-data.${this.region}.amazonaws.com`).replace(/\/+$/, "");
|
|
55
|
+
this.timeoutMs = config.timeoutMs || 15e3;
|
|
56
|
+
this.maxResponseBytes = config.maxResponseBytes || 2097152;
|
|
57
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0)
|
|
58
|
+
throw new TypeError("Redshift request limits must be positive integers");
|
|
59
|
+
this.send = options.send ?? sendProviderRequest;
|
|
60
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
61
|
+
}
|
|
62
|
+
credentials;
|
|
63
|
+
endpoint;
|
|
64
|
+
region;
|
|
65
|
+
timeoutMs;
|
|
66
|
+
maxResponseBytes;
|
|
67
|
+
send;
|
|
68
|
+
now;
|
|
69
|
+
/** Bind the getStatementResult Query. */
|
|
70
|
+
getStatementResult() {
|
|
71
|
+
return new GetStatementResultOperation(this);
|
|
72
|
+
}
|
|
73
|
+
/** Sign and send one bounded GetStatementResult request. */
|
|
74
|
+
async readStatementResult(call, body) {
|
|
75
|
+
let accessKey;
|
|
76
|
+
let secretKey;
|
|
77
|
+
let sessionToken;
|
|
78
|
+
try {
|
|
79
|
+
const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
80
|
+
accessKey = credentials.accessKeyId instanceof SecretString ? credentials.accessKeyId.reveal() : "";
|
|
81
|
+
secretKey = credentials.secretAccessKey instanceof SecretString ? credentials.secretAccessKey.reveal() : "";
|
|
82
|
+
sessionToken = credentials.sessionToken instanceof SecretString ? credentials.sessionToken.reveal() : "";
|
|
83
|
+
} catch {
|
|
84
|
+
return emptyExchange("credential");
|
|
85
|
+
}
|
|
86
|
+
if (!accessKey || !secretKey || !isHeaderSafeCredential(accessKey) || !isHeaderSafeCredential(secretKey) || sessionToken && !isHeaderSafeCredential(sessionToken)) return emptyExchange("credential");
|
|
87
|
+
const url = `${this.endpoint}/`;
|
|
88
|
+
const timestamp = this.now().toISOString().replace(/[-:]|\.\d{3}/g, "");
|
|
89
|
+
const day = timestamp.slice(0, 8);
|
|
90
|
+
const headersForSignature = {
|
|
91
|
+
"content-length": String(body.length),
|
|
92
|
+
"content-type": "application/x-amz-json-1.1",
|
|
93
|
+
host: new URL(url).host,
|
|
94
|
+
"x-amz-date": timestamp,
|
|
95
|
+
"x-amz-target": "RedshiftData.GetStatementResult"
|
|
96
|
+
};
|
|
97
|
+
if (sessionToken) headersForSignature["x-amz-security-token"] = sessionToken;
|
|
98
|
+
const signedHeaders = Object.keys(headersForSignature).sort().join(";");
|
|
99
|
+
const canonicalHeaders = Object.entries(headersForSignature).sort(([left], [right]) => left.localeCompare(right)).map(([name, value]) => `${name}:${value.trim()}
|
|
100
|
+
`).join("");
|
|
101
|
+
const payloadHash = createHash("sha256").update(body).digest("hex");
|
|
102
|
+
const canonicalRequest = `POST
|
|
103
|
+
/
|
|
104
|
+
|
|
105
|
+
${canonicalHeaders}
|
|
106
|
+
${signedHeaders}
|
|
107
|
+
${payloadHash}`;
|
|
108
|
+
const scope = `${day}/${this.region}/redshift-data/aws4_request`;
|
|
109
|
+
const stringToSign = `AWS4-HMAC-SHA256
|
|
110
|
+
${timestamp}
|
|
111
|
+
${scope}
|
|
112
|
+
${createHash("sha256").update(canonicalRequest).digest("hex")}`;
|
|
113
|
+
const hmac = (key, value) => createHmac("sha256", key).update(value).digest();
|
|
114
|
+
const signingKey = hmac(hmac(hmac(hmac(`AWS4${secretKey}`, day), this.region), "redshift-data"), "aws4_request");
|
|
115
|
+
const signature = createHmac("sha256", signingKey).update(stringToSign).digest("hex");
|
|
116
|
+
const headers = {
|
|
117
|
+
"Content-Type": headersForSignature["content-type"],
|
|
118
|
+
"X-Amz-Date": timestamp,
|
|
119
|
+
"X-Amz-Target": headersForSignature["x-amz-target"],
|
|
120
|
+
Authorization: `AWS4-HMAC-SHA256 Credential=${accessKey}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
|
|
121
|
+
};
|
|
122
|
+
if (sessionToken) headers["X-Amz-Security-Token"] = sessionToken;
|
|
123
|
+
const request = {
|
|
124
|
+
url,
|
|
125
|
+
method: "POST",
|
|
126
|
+
headers,
|
|
127
|
+
body,
|
|
128
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
129
|
+
timeoutMs: this.timeoutMs,
|
|
130
|
+
addressPolicy: this.endpoint.startsWith("https://") ? "publicHTTPS" : "privateNetworkHTTP",
|
|
131
|
+
signal: call.context.cancellationSignal
|
|
132
|
+
};
|
|
133
|
+
let response;
|
|
134
|
+
let isTooLarge = false;
|
|
135
|
+
try {
|
|
136
|
+
response = await this.send(request);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0) {
|
|
139
|
+
response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
|
|
140
|
+
isTooLarge = true;
|
|
141
|
+
} else return emptyExchange("request");
|
|
142
|
+
}
|
|
143
|
+
const retryAfterMs = parseRetryAfter(header(response.headers, "retry-after"));
|
|
144
|
+
if (isTooLarge || response.body.length > this.maxResponseBytes)
|
|
145
|
+
return { status: response.status, body: new Uint8Array(), retryAfterMs, error: "tooLarge" };
|
|
146
|
+
if ([accessKey, secretKey, sessionToken].some((secret) => secret && Buffer.from(response.body).includes(secret)))
|
|
147
|
+
return { ...emptyExchange("credential"), status: response.status, retryAfterMs };
|
|
148
|
+
return { status: response.status, body: response.body, retryAfterMs };
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var GetStatementResultOperation = class {
|
|
152
|
+
/** Bind the provider client. */
|
|
153
|
+
constructor(client) {
|
|
154
|
+
this.client = client;
|
|
155
|
+
}
|
|
156
|
+
client;
|
|
157
|
+
/** Return the generated Query contract. */
|
|
158
|
+
definition() {
|
|
159
|
+
return GetStatementResultDefinition;
|
|
160
|
+
}
|
|
161
|
+
/** Classify provider outcomes consistently with the Go implementation. */
|
|
162
|
+
async invoke(call, input) {
|
|
163
|
+
if (!input || typeof input.statementId !== "string" || !statementIDPattern.test(input.statementId) || typeof input.nextToken !== "string" || input.nextToken.length > 4096 || [...input.nextToken].some((character) => character.charCodeAt(0) === 0 || character === "\r" || character === "\n"))
|
|
164
|
+
return terminal("defect", "VALIDATION", "Redshift statement ID or page token is invalid");
|
|
165
|
+
const body = Buffer.from(JSON.stringify({ Id: input.statementId, ...input.nextToken ? { NextToken: input.nextToken } : {} }));
|
|
166
|
+
const exchange = await this.client.readStatementResult(call, body);
|
|
167
|
+
if (exchange.error === "credential") return terminal("defect", "AUTHENTICATION", "Redshift credentials are unavailable or invalid");
|
|
168
|
+
if (exchange.error === "request") return retry("TRANSPORT", "Redshift request failed");
|
|
169
|
+
if (exchange.status === 429 || exchange.status !== 200 && isThrottled(exchange.body)) return retry("RATE_LIMIT", "Redshift rate limited the request", exchange.retryAfterMs);
|
|
170
|
+
if (exchange.status === 408 || exchange.status >= 500) return retry("AVAILABILITY", "Redshift is temporarily unavailable", exchange.retryAfterMs);
|
|
171
|
+
if (exchange.status === 404 || exchange.status === 400 && hasErrorCode(exchange.body, "ResourceNotFoundException"))
|
|
172
|
+
return newQueryBranch("missing", emptyPage());
|
|
173
|
+
if (exchange.status !== 200) return terminal("providerRejected", "PROVIDER_REJECTION", `Redshift rejected HTTP ${exchange.status}`);
|
|
174
|
+
if (exchange.error === "tooLarge") return terminal("invalidResponse", "RESPONSE_TOO_LARGE", "Redshift response exceeded the configured limit");
|
|
175
|
+
let document;
|
|
176
|
+
try {
|
|
177
|
+
document = JSON.parse(Buffer.from(exchange.body).toString("utf8"));
|
|
178
|
+
} catch {
|
|
179
|
+
return terminal("invalidResponse", "PROTOCOL", "Redshift returned invalid result JSON");
|
|
180
|
+
}
|
|
181
|
+
if (!isObject(document) || !Array.isArray(document.Records) || document.NextToken !== void 0 && typeof document.NextToken !== "string" || document.TotalNumRows !== void 0 && (typeof document.TotalNumRows !== "number" || !Number.isSafeInteger(document.TotalNumRows) || document.TotalNumRows < 0) || document.Records.some((row) => !Array.isArray(row) || row.some((field) => !isObject(field) || Object.keys(field).length !== 1)))
|
|
182
|
+
return terminal("invalidResponse", "PROTOCOL", "Redshift returned invalid result JSON");
|
|
183
|
+
return newQueryBranch("fetched", { records: document.Records, nextToken: document.NextToken ?? "", totalNumRows: document.TotalNumRows ?? 0 });
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
function isObject(value) {
|
|
187
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
188
|
+
}
|
|
189
|
+
function hasErrorCode(body, expected) {
|
|
190
|
+
try {
|
|
191
|
+
const document = JSON.parse(Buffer.from(body).toString("utf8"));
|
|
192
|
+
return isObject(document) && typeof document.__type === "string" && document.__type.split("#").at(-1) === expected;
|
|
193
|
+
} catch {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function isThrottled(body) {
|
|
198
|
+
return ["ThrottlingException", "ActiveStatementsExceededException", "ActiveSessionsExceededException"].some((code) => hasErrorCode(body, code));
|
|
199
|
+
}
|
|
200
|
+
function emptyExchange(error) {
|
|
201
|
+
return { status: 0, body: new Uint8Array(), retryAfterMs: 0, error };
|
|
202
|
+
}
|
|
203
|
+
function failure(kind, message) {
|
|
204
|
+
return { provider: "amazon-redshift", operation: "getStatementResult", kind, message };
|
|
205
|
+
}
|
|
206
|
+
function terminal(branch, kind, message) {
|
|
207
|
+
return newQueryBranch(branch, emptyPage(), {}, failure(kind, message));
|
|
208
|
+
}
|
|
209
|
+
function retry(kind, message, delay = 0) {
|
|
210
|
+
return newQueryRetry(failure(kind, message), delay);
|
|
211
|
+
}
|
|
212
|
+
function header(headers, name) {
|
|
213
|
+
const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
214
|
+
return Array.isArray(entry) ? entry[0] ?? "" : entry ?? "";
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/project.ts
|
|
218
|
+
function newProjectConnection2(project, connectionName) {
|
|
219
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
220
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "amazon-redshift" && entry.connectionName === name);
|
|
221
|
+
if (!selected) throw new TypeError("Amazon Redshift project connection is not configured");
|
|
222
|
+
const fields = z.strictObject({ region: z.string().optional(), endpoint: z.string().optional(), timeout: z.union([z.string(), z.number().int()]).optional(), maxResponseBytes: z.number().int().optional() }).parse(selected.configuration);
|
|
223
|
+
const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
|
|
224
|
+
const config = {
|
|
225
|
+
...fields.region ? { region: fields.region } : {},
|
|
226
|
+
...fields.endpoint ? { endpoint: fields.endpoint } : {},
|
|
227
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
228
|
+
...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
|
|
229
|
+
};
|
|
230
|
+
const credentials = {
|
|
231
|
+
async resolve(_call, signal) {
|
|
232
|
+
const privateFields = await loadedProject.resolveCredential("amazon-redshift", name, signal);
|
|
233
|
+
if (typeof privateFields.access_key_id !== "string" || typeof privateFields.secret_access_key !== "string") throw new TypeError("Amazon Redshift credentials are unavailable");
|
|
234
|
+
return { accessKeyId: new SecretString2(privateFields.access_key_id), secretAccessKey: new SecretString2(privateFields.secret_access_key), sessionToken: new SecretString2(typeof privateFields.session_token === "string" ? privateFields.session_token : "") };
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
return new AmazonRedshiftClient(config, credentials);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
function parseDurationMilliseconds(value) {
|
|
241
|
+
let remaining = value;
|
|
242
|
+
let milliseconds = 0;
|
|
243
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
244
|
+
while (remaining) {
|
|
245
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
246
|
+
if (!part) throw new TypeError("Amazon Redshift timeout must be a positive Go duration");
|
|
247
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
248
|
+
remaining = remaining.slice(part[0].length);
|
|
249
|
+
}
|
|
250
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Amazon Redshift timeout must resolve to positive whole milliseconds");
|
|
251
|
+
return milliseconds;
|
|
252
|
+
}
|
|
253
|
+
export {
|
|
254
|
+
AmazonRedshiftClient,
|
|
255
|
+
ConfigSchema,
|
|
256
|
+
Connection,
|
|
257
|
+
ConnectorID,
|
|
258
|
+
GetStatementResultBranch,
|
|
259
|
+
GetStatementResultBranchDefect,
|
|
260
|
+
GetStatementResultBranchFetched,
|
|
261
|
+
GetStatementResultBranchInvalidResponse,
|
|
262
|
+
GetStatementResultBranchMissing,
|
|
263
|
+
GetStatementResultBranchProviderRejected,
|
|
264
|
+
GetStatementResultDefinition,
|
|
265
|
+
GetStatementResultInputSchema,
|
|
266
|
+
GetStatementResultMetadata,
|
|
267
|
+
GetStatementResultOperation,
|
|
268
|
+
ProviderID,
|
|
269
|
+
StatementResultPageSchema,
|
|
270
|
+
decodeCredentials,
|
|
271
|
+
newConnection,
|
|
272
|
+
newConnectionWithOperations,
|
|
273
|
+
newGetStatementResultStep,
|
|
274
|
+
newProjectConnection2 as newProjectConnection
|
|
275
|
+
};
|
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, G as GetStatementResultInput, S as StatementResultPage } from './connection-BikiyVDi.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for GetStatementResultInput in scripted cases. */
|
|
7
|
+
declare const emptyGetStatementResultInput: GetStatementResultInput;
|
|
8
|
+
/** Go zero value for StatementResultPage in scripted cases. */
|
|
9
|
+
declare const emptyStatementResultPage: StatementResultPage;
|
|
10
|
+
/** Script the fetched branch. */
|
|
11
|
+
declare function getStatementResultFetched(value: StatementResultPage, failure?: Failure): Case<StatementResultPage>;
|
|
12
|
+
/** Script the missing branch. */
|
|
13
|
+
declare function getStatementResultMissing(value: StatementResultPage, failure?: Failure): Case<StatementResultPage>;
|
|
14
|
+
/** Script the providerRejected branch. */
|
|
15
|
+
declare function getStatementResultProviderRejected(value: StatementResultPage, failure?: Failure): Case<StatementResultPage>;
|
|
16
|
+
/** Script the invalidResponse branch. */
|
|
17
|
+
declare function getStatementResultInvalidResponse(value: StatementResultPage, failure?: Failure): Case<StatementResultPage>;
|
|
18
|
+
/** Script the defect branch. */
|
|
19
|
+
declare function getStatementResultDefect(value: StatementResultPage, failure?: Failure): Case<StatementResultPage>;
|
|
20
|
+
/** Script a safe retry of getStatementResult. */
|
|
21
|
+
declare function getStatementResultRetry(failure: Failure, retryAfterMs?: number): Case<StatementResultPage>;
|
|
22
|
+
/** Manifest scenario fetchedDefault for getStatementResult. */
|
|
23
|
+
declare function getStatementResultFetchedDefault(): Case<StatementResultPage>;
|
|
24
|
+
/** Default getStatementResult scenario. */
|
|
25
|
+
declare function getStatementResultDefault(): Case<StatementResultPage>;
|
|
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
|
+
getStatementResult(): MockQuery<GetStatementResultInput, StatementResultPage>;
|
|
32
|
+
assertNoFailures(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { GeneratedMock, GeneratedMock as Mock, emptyGetStatementResultInput, emptyStatementResultPage, getStatementResultDefault, getStatementResultDefect, getStatementResultFetched, getStatementResultFetchedDefault, getStatementResultInvalidResponse, getStatementResultMissing, getStatementResultProviderRejected, getStatementResultRetry };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GetStatementResultDefinition,
|
|
3
|
+
GetStatementResultInputSchema,
|
|
4
|
+
ProviderID,
|
|
5
|
+
StatementResultPageSchema,
|
|
6
|
+
newConnectionWithOperations
|
|
7
|
+
} from "./chunk-OEV6UKQQ.js";
|
|
8
|
+
|
|
9
|
+
// src/generated/mock.ts
|
|
10
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
11
|
+
var emptyGetStatementResultInput = GetStatementResultInputSchema.parse({
|
|
12
|
+
"statementId": "",
|
|
13
|
+
"nextToken": ""
|
|
14
|
+
});
|
|
15
|
+
var emptyStatementResultPage = StatementResultPageSchema.parse({
|
|
16
|
+
"records": [],
|
|
17
|
+
"nextToken": "",
|
|
18
|
+
"totalNumRows": 0
|
|
19
|
+
});
|
|
20
|
+
function getStatementResultFetched(value, failure) {
|
|
21
|
+
return branchCase("fetched", value, failure);
|
|
22
|
+
}
|
|
23
|
+
function getStatementResultMissing(value, failure) {
|
|
24
|
+
return branchCase("missing", value, failure);
|
|
25
|
+
}
|
|
26
|
+
function getStatementResultProviderRejected(value, failure) {
|
|
27
|
+
return branchCase("providerRejected", value, failure);
|
|
28
|
+
}
|
|
29
|
+
function getStatementResultInvalidResponse(value, failure) {
|
|
30
|
+
return branchCase("invalidResponse", value, failure);
|
|
31
|
+
}
|
|
32
|
+
function getStatementResultDefect(value, failure) {
|
|
33
|
+
return branchCase("defect", value, failure);
|
|
34
|
+
}
|
|
35
|
+
function getStatementResultRetry(failure, retryAfterMs = 0) {
|
|
36
|
+
return retryCase(failure, retryAfterMs);
|
|
37
|
+
}
|
|
38
|
+
function getStatementResultFetchedDefault() {
|
|
39
|
+
const value = StatementResultPageSchema.parse({ "nextToken": "", "records": [[{ "stringValue": "example" }]], "totalNumRows": 1 });
|
|
40
|
+
return branchCase("fetched", value);
|
|
41
|
+
}
|
|
42
|
+
function getStatementResultDefault() {
|
|
43
|
+
return getStatementResultFetchedDefault();
|
|
44
|
+
}
|
|
45
|
+
var GeneratedMock = class {
|
|
46
|
+
#getStatementResult;
|
|
47
|
+
#connection;
|
|
48
|
+
constructor(connectionName) {
|
|
49
|
+
this.#getStatementResult = newQuery(GetStatementResultDefinition).default(getStatementResultDefault());
|
|
50
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
51
|
+
}
|
|
52
|
+
connection() {
|
|
53
|
+
return this.#connection;
|
|
54
|
+
}
|
|
55
|
+
getStatementResult() {
|
|
56
|
+
return this.#getStatementResult;
|
|
57
|
+
}
|
|
58
|
+
assertNoFailures() {
|
|
59
|
+
this.#getStatementResult.assertNoFailures();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
GeneratedMock,
|
|
64
|
+
GeneratedMock as Mock,
|
|
65
|
+
emptyGetStatementResultInput,
|
|
66
|
+
emptyStatementResultPage,
|
|
67
|
+
getStatementResultDefault,
|
|
68
|
+
getStatementResultDefect,
|
|
69
|
+
getStatementResultFetched,
|
|
70
|
+
getStatementResultFetchedDefault,
|
|
71
|
+
getStatementResultInvalidResponse,
|
|
72
|
+
getStatementResultMissing,
|
|
73
|
+
getStatementResultProviderRejected,
|
|
74
|
+
getStatementResultRetry
|
|
75
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-amazon-redshift",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Amazon Redshift connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/amazon/redshift/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/statement-results/worker.ts",
|
|
42
|
+
"example:start": "tsx examples/statement-results/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
|
+
}
|