@lark-apaas/miaoda-connections-sdk 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 +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.mjs +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateParam.cjs +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateParam.mjs +8 -0
- package/dist/client.cjs +64 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.mjs +64 -0
- package/dist/client.mjs.map +1 -0
- package/dist/create-client.cjs +9 -0
- package/dist/create-client.cjs.map +1 -0
- package/dist/create-client.d.cts +7 -0
- package/dist/create-client.d.cts.map +1 -0
- package/dist/create-client.d.mts +7 -0
- package/dist/create-client.d.mts.map +1 -0
- package/dist/create-client.mjs +9 -0
- package/dist/create-client.mjs.map +1 -0
- package/dist/envelope.cjs +52 -0
- package/dist/envelope.cjs.map +1 -0
- package/dist/envelope.mjs +51 -0
- package/dist/envelope.mjs.map +1 -0
- package/dist/errors.cjs +19 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +19 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +19 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +19 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +13 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +4 -0
- package/dist/nestjs.cjs +48 -0
- package/dist/nestjs.cjs.map +1 -0
- package/dist/nestjs.d.cts +11 -0
- package/dist/nestjs.d.cts.map +1 -0
- package/dist/nestjs.d.mts +11 -0
- package/dist/nestjs.d.mts.map +1 -0
- package/dist/nestjs.mjs +42 -0
- package/dist/nestjs.mjs.map +1 -0
- package/dist/platform-http-client.cjs +96 -0
- package/dist/platform-http-client.cjs.map +1 -0
- package/dist/platform-http-client.mjs +96 -0
- package/dist/platform-http-client.mjs.map +1 -0
- package/dist/redaction.cjs +36 -0
- package/dist/redaction.cjs.map +1 -0
- package/dist/redaction.mjs +34 -0
- package/dist/redaction.mjs.map +1 -0
- package/dist/types.d.cts +79 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +79 -0
- package/dist/types.d.mts.map +1 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Lark Technologies Pte. Ltd. and/or its affiliates
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
8
|
+
IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
|
|
9
|
+
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
|
10
|
+
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
|
11
|
+
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
12
|
+
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
13
|
+
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/decorate.js
|
|
2
|
+
function __decorate(decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.__decorate = __decorate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/decorate.js
|
|
2
|
+
function __decorate(decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { __decorate };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/decorateMetadata.js
|
|
2
|
+
function __decorateMetadata(k, v) {
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4
|
+
}
|
|
5
|
+
//#endregion
|
|
6
|
+
exports.__decorateMetadata = __decorateMetadata;
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const require_errors = require("./errors.cjs");
|
|
2
|
+
const require_envelope = require("./envelope.cjs");
|
|
3
|
+
const require_redaction = require("./redaction.cjs");
|
|
4
|
+
//#region src/client.ts
|
|
5
|
+
var ConnectionsClientImpl = class {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
async getConnection(input) {
|
|
10
|
+
const connectionName = typeof input === "string" ? input : input.connectionName;
|
|
11
|
+
return this.fetchConnection(connectionName);
|
|
12
|
+
}
|
|
13
|
+
async fetchConnection(name) {
|
|
14
|
+
const normalizedName = normalizeConnectionName(name);
|
|
15
|
+
const path = `/v1/integration/credentials/${encodeURIComponent(normalizedName)}`;
|
|
16
|
+
try {
|
|
17
|
+
this.logConnectionEvent("connections.getConnection.request", {
|
|
18
|
+
method: "GET",
|
|
19
|
+
path: path.replace(encodeURIComponent(normalizedName), require_redaction.redactConnectionName(normalizedName))
|
|
20
|
+
});
|
|
21
|
+
const envelope = await this.options.transport.request({
|
|
22
|
+
method: "GET",
|
|
23
|
+
path,
|
|
24
|
+
timeoutMs: this.options.timeoutMs
|
|
25
|
+
});
|
|
26
|
+
const result = require_envelope.unwrapEnvelope(envelope);
|
|
27
|
+
require_envelope.assertConnectionResult(result);
|
|
28
|
+
this.logConnectionEvent("connections.getConnection.response", {
|
|
29
|
+
method: "GET",
|
|
30
|
+
status_code: envelope.status_code,
|
|
31
|
+
state: result.state,
|
|
32
|
+
connectionType: result.state === "connected" ? result.value.type : void 0
|
|
33
|
+
});
|
|
34
|
+
return result;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
const sdkError = error;
|
|
37
|
+
if (error instanceof require_errors.ConnectionsSDKError || sdkError.name === "ConnectionsSDKError") throw error;
|
|
38
|
+
throw new require_errors.ConnectionsSDKError({
|
|
39
|
+
code: error instanceof DOMException && error.name === "TimeoutError" ? "TIMEOUT" : "REQUEST_FAILED",
|
|
40
|
+
message: "Connection request failed",
|
|
41
|
+
cause: require_redaction.sanitizeCause(error)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
logConnectionEvent(message, meta) {
|
|
46
|
+
this.options.logger?.debug(message, meta);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function normalizeConnectionName(name) {
|
|
50
|
+
if (typeof name !== "string") throw new require_errors.ConnectionsSDKError({
|
|
51
|
+
code: "INVALID_CONNECTION_NAME",
|
|
52
|
+
message: "Connection name must be a string"
|
|
53
|
+
});
|
|
54
|
+
const normalizedName = name.trim();
|
|
55
|
+
if (!normalizedName) throw new require_errors.ConnectionsSDKError({
|
|
56
|
+
code: "INVALID_CONNECTION_NAME",
|
|
57
|
+
message: "Connection name must not be empty"
|
|
58
|
+
});
|
|
59
|
+
return normalizedName;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
exports.ConnectionsClientImpl = ConnectionsClientImpl;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.cjs","names":["redactConnectionName","unwrapEnvelope","ConnectionsSDKError","sanitizeCause"],"sources":["../src/client.ts"],"sourcesContent":["import { assertConnectionResult, unwrapEnvelope } from './envelope';\nimport { ConnectionsSDKError } from './errors';\nimport { redactConnectionName, sanitizeCause } from './redaction';\nimport type {\n ApiEnvelope,\n ConnectionResult,\n ConnectionsClient,\n CreateConnectionsClientOptions,\n GetConnectionOptions,\n} from './types';\n\nexport class ConnectionsClientImpl implements ConnectionsClient {\n constructor(\n private readonly options: Required<\n Pick<CreateConnectionsClientOptions, 'transport'>\n > &\n Omit<CreateConnectionsClientOptions, 'transport'>\n ) {}\n\n async getConnection(name: string): Promise<ConnectionResult>;\n async getConnection(options: GetConnectionOptions): Promise<ConnectionResult>;\n async getConnection(\n input: string | GetConnectionOptions\n ): Promise<ConnectionResult> {\n const connectionName =\n typeof input === 'string' ? input : input.connectionName;\n return this.fetchConnection(connectionName);\n }\n\n private async fetchConnection(name: string): Promise<ConnectionResult> {\n const normalizedName = normalizeConnectionName(name);\n const path = `/v1/integration/credentials/${encodeURIComponent(normalizedName)}`;\n\n try {\n this.logConnectionEvent('connections.getConnection.request', {\n method: 'GET',\n path: path.replace(\n encodeURIComponent(normalizedName),\n redactConnectionName(normalizedName)\n ),\n });\n\n const envelope = await this.options.transport.request<\n ApiEnvelope<ConnectionResult>\n >({\n method: 'GET',\n path,\n timeoutMs: this.options.timeoutMs,\n });\n const result = unwrapEnvelope(envelope);\n assertConnectionResult(result);\n\n this.logConnectionEvent('connections.getConnection.response', {\n method: 'GET',\n status_code: envelope.status_code,\n state: result.state,\n connectionType:\n result.state === 'connected' ? result.value.type : undefined,\n });\n\n return result;\n } catch (error) {\n const sdkError = error as ConnectionsSDKError;\n if (\n error instanceof ConnectionsSDKError ||\n sdkError.name === 'ConnectionsSDKError'\n ) {\n throw error;\n }\n\n throw new ConnectionsSDKError({\n code:\n error instanceof DOMException && error.name === 'TimeoutError'\n ? 'TIMEOUT'\n : 'REQUEST_FAILED',\n message: 'Connection request failed',\n cause: sanitizeCause(error),\n });\n }\n }\n\n private logConnectionEvent(\n message: string,\n meta: Record<string, unknown>\n ): void {\n this.options.logger?.debug(message, meta);\n }\n}\n\nexport function normalizeConnectionName(name: string): string {\n if (typeof name !== 'string') {\n throw new ConnectionsSDKError({\n code: 'INVALID_CONNECTION_NAME',\n message: 'Connection name must be a string',\n });\n }\n\n const normalizedName = name.trim();\n if (!normalizedName) {\n throw new ConnectionsSDKError({\n code: 'INVALID_CONNECTION_NAME',\n message: 'Connection name must not be empty',\n });\n }\n\n return normalizedName;\n}\n"],"mappings":";;;;AAWA,IAAa,wBAAb,MAAgE;CAC9D,YACE,SAIA;AAJiB,OAAA,UAAA;;CAQnB,MAAM,cACJ,OAC2B;EAC3B,MAAM,iBACJ,OAAO,UAAU,WAAW,QAAQ,MAAM;AAC5C,SAAO,KAAK,gBAAgB,eAAe;;CAG7C,MAAc,gBAAgB,MAAyC;EACrE,MAAM,iBAAiB,wBAAwB,KAAK;EACpD,MAAM,OAAO,+BAA+B,mBAAmB,eAAe;AAE9E,MAAI;AACF,QAAK,mBAAmB,qCAAqC;IAC3D,QAAQ;IACR,MAAM,KAAK,QACT,mBAAmB,eAAe,EAClCA,kBAAAA,qBAAqB,eAAe,CACrC;IACF,CAAC;GAEF,MAAM,WAAW,MAAM,KAAK,QAAQ,UAAU,QAE5C;IACA,QAAQ;IACR;IACA,WAAW,KAAK,QAAQ;IACzB,CAAC;GACF,MAAM,SAASC,iBAAAA,eAAe,SAAS;AACvC,oBAAA,uBAAuB,OAAO;AAE9B,QAAK,mBAAmB,sCAAsC;IAC5D,QAAQ;IACR,aAAa,SAAS;IACtB,OAAO,OAAO;IACd,gBACE,OAAO,UAAU,cAAc,OAAO,MAAM,OAAO,KAAA;IACtD,CAAC;AAEF,UAAO;WACA,OAAO;GACd,MAAM,WAAW;AACjB,OACE,iBAAiBC,eAAAA,uBACjB,SAAS,SAAS,sBAElB,OAAM;AAGR,SAAM,IAAIA,eAAAA,oBAAoB;IAC5B,MACE,iBAAiB,gBAAgB,MAAM,SAAS,iBAC5C,YACA;IACN,SAAS;IACT,OAAOC,kBAAAA,cAAc,MAAM;IAC5B,CAAC;;;CAIN,mBACE,SACA,MACM;AACN,OAAK,QAAQ,QAAQ,MAAM,SAAS,KAAK;;;AAI7C,SAAgB,wBAAwB,MAAsB;AAC5D,KAAI,OAAO,SAAS,SAClB,OAAM,IAAID,eAAAA,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC;CAGJ,MAAM,iBAAiB,KAAK,MAAM;AAClC,KAAI,CAAC,eACH,OAAM,IAAIA,eAAAA,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC;AAGJ,QAAO"}
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ConnectionsSDKError } from "./errors.mjs";
|
|
2
|
+
import { assertConnectionResult, unwrapEnvelope } from "./envelope.mjs";
|
|
3
|
+
import { redactConnectionName, sanitizeCause } from "./redaction.mjs";
|
|
4
|
+
//#region src/client.ts
|
|
5
|
+
var ConnectionsClientImpl = class {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
async getConnection(input) {
|
|
10
|
+
const connectionName = typeof input === "string" ? input : input.connectionName;
|
|
11
|
+
return this.fetchConnection(connectionName);
|
|
12
|
+
}
|
|
13
|
+
async fetchConnection(name) {
|
|
14
|
+
const normalizedName = normalizeConnectionName(name);
|
|
15
|
+
const path = `/v1/integration/credentials/${encodeURIComponent(normalizedName)}`;
|
|
16
|
+
try {
|
|
17
|
+
this.logConnectionEvent("connections.getConnection.request", {
|
|
18
|
+
method: "GET",
|
|
19
|
+
path: path.replace(encodeURIComponent(normalizedName), redactConnectionName(normalizedName))
|
|
20
|
+
});
|
|
21
|
+
const envelope = await this.options.transport.request({
|
|
22
|
+
method: "GET",
|
|
23
|
+
path,
|
|
24
|
+
timeoutMs: this.options.timeoutMs
|
|
25
|
+
});
|
|
26
|
+
const result = unwrapEnvelope(envelope);
|
|
27
|
+
assertConnectionResult(result);
|
|
28
|
+
this.logConnectionEvent("connections.getConnection.response", {
|
|
29
|
+
method: "GET",
|
|
30
|
+
status_code: envelope.status_code,
|
|
31
|
+
state: result.state,
|
|
32
|
+
connectionType: result.state === "connected" ? result.value.type : void 0
|
|
33
|
+
});
|
|
34
|
+
return result;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
const sdkError = error;
|
|
37
|
+
if (error instanceof ConnectionsSDKError || sdkError.name === "ConnectionsSDKError") throw error;
|
|
38
|
+
throw new ConnectionsSDKError({
|
|
39
|
+
code: error instanceof DOMException && error.name === "TimeoutError" ? "TIMEOUT" : "REQUEST_FAILED",
|
|
40
|
+
message: "Connection request failed",
|
|
41
|
+
cause: sanitizeCause(error)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
logConnectionEvent(message, meta) {
|
|
46
|
+
this.options.logger?.debug(message, meta);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function normalizeConnectionName(name) {
|
|
50
|
+
if (typeof name !== "string") throw new ConnectionsSDKError({
|
|
51
|
+
code: "INVALID_CONNECTION_NAME",
|
|
52
|
+
message: "Connection name must be a string"
|
|
53
|
+
});
|
|
54
|
+
const normalizedName = name.trim();
|
|
55
|
+
if (!normalizedName) throw new ConnectionsSDKError({
|
|
56
|
+
code: "INVALID_CONNECTION_NAME",
|
|
57
|
+
message: "Connection name must not be empty"
|
|
58
|
+
});
|
|
59
|
+
return normalizedName;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { ConnectionsClientImpl };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import { assertConnectionResult, unwrapEnvelope } from './envelope';\nimport { ConnectionsSDKError } from './errors';\nimport { redactConnectionName, sanitizeCause } from './redaction';\nimport type {\n ApiEnvelope,\n ConnectionResult,\n ConnectionsClient,\n CreateConnectionsClientOptions,\n GetConnectionOptions,\n} from './types';\n\nexport class ConnectionsClientImpl implements ConnectionsClient {\n constructor(\n private readonly options: Required<\n Pick<CreateConnectionsClientOptions, 'transport'>\n > &\n Omit<CreateConnectionsClientOptions, 'transport'>\n ) {}\n\n async getConnection(name: string): Promise<ConnectionResult>;\n async getConnection(options: GetConnectionOptions): Promise<ConnectionResult>;\n async getConnection(\n input: string | GetConnectionOptions\n ): Promise<ConnectionResult> {\n const connectionName =\n typeof input === 'string' ? input : input.connectionName;\n return this.fetchConnection(connectionName);\n }\n\n private async fetchConnection(name: string): Promise<ConnectionResult> {\n const normalizedName = normalizeConnectionName(name);\n const path = `/v1/integration/credentials/${encodeURIComponent(normalizedName)}`;\n\n try {\n this.logConnectionEvent('connections.getConnection.request', {\n method: 'GET',\n path: path.replace(\n encodeURIComponent(normalizedName),\n redactConnectionName(normalizedName)\n ),\n });\n\n const envelope = await this.options.transport.request<\n ApiEnvelope<ConnectionResult>\n >({\n method: 'GET',\n path,\n timeoutMs: this.options.timeoutMs,\n });\n const result = unwrapEnvelope(envelope);\n assertConnectionResult(result);\n\n this.logConnectionEvent('connections.getConnection.response', {\n method: 'GET',\n status_code: envelope.status_code,\n state: result.state,\n connectionType:\n result.state === 'connected' ? result.value.type : undefined,\n });\n\n return result;\n } catch (error) {\n const sdkError = error as ConnectionsSDKError;\n if (\n error instanceof ConnectionsSDKError ||\n sdkError.name === 'ConnectionsSDKError'\n ) {\n throw error;\n }\n\n throw new ConnectionsSDKError({\n code:\n error instanceof DOMException && error.name === 'TimeoutError'\n ? 'TIMEOUT'\n : 'REQUEST_FAILED',\n message: 'Connection request failed',\n cause: sanitizeCause(error),\n });\n }\n }\n\n private logConnectionEvent(\n message: string,\n meta: Record<string, unknown>\n ): void {\n this.options.logger?.debug(message, meta);\n }\n}\n\nexport function normalizeConnectionName(name: string): string {\n if (typeof name !== 'string') {\n throw new ConnectionsSDKError({\n code: 'INVALID_CONNECTION_NAME',\n message: 'Connection name must be a string',\n });\n }\n\n const normalizedName = name.trim();\n if (!normalizedName) {\n throw new ConnectionsSDKError({\n code: 'INVALID_CONNECTION_NAME',\n message: 'Connection name must not be empty',\n });\n }\n\n return normalizedName;\n}\n"],"mappings":";;;;AAWA,IAAa,wBAAb,MAAgE;CAC9D,YACE,SAIA;AAJiB,OAAA,UAAA;;CAQnB,MAAM,cACJ,OAC2B;EAC3B,MAAM,iBACJ,OAAO,UAAU,WAAW,QAAQ,MAAM;AAC5C,SAAO,KAAK,gBAAgB,eAAe;;CAG7C,MAAc,gBAAgB,MAAyC;EACrE,MAAM,iBAAiB,wBAAwB,KAAK;EACpD,MAAM,OAAO,+BAA+B,mBAAmB,eAAe;AAE9E,MAAI;AACF,QAAK,mBAAmB,qCAAqC;IAC3D,QAAQ;IACR,MAAM,KAAK,QACT,mBAAmB,eAAe,EAClC,qBAAqB,eAAe,CACrC;IACF,CAAC;GAEF,MAAM,WAAW,MAAM,KAAK,QAAQ,UAAU,QAE5C;IACA,QAAQ;IACR;IACA,WAAW,KAAK,QAAQ;IACzB,CAAC;GACF,MAAM,SAAS,eAAe,SAAS;AACvC,0BAAuB,OAAO;AAE9B,QAAK,mBAAmB,sCAAsC;IAC5D,QAAQ;IACR,aAAa,SAAS;IACtB,OAAO,OAAO;IACd,gBACE,OAAO,UAAU,cAAc,OAAO,MAAM,OAAO,KAAA;IACtD,CAAC;AAEF,UAAO;WACA,OAAO;GACd,MAAM,WAAW;AACjB,OACE,iBAAiB,uBACjB,SAAS,SAAS,sBAElB,OAAM;AAGR,SAAM,IAAI,oBAAoB;IAC5B,MACE,iBAAiB,gBAAgB,MAAM,SAAS,iBAC5C,YACA;IACN,SAAS;IACT,OAAO,cAAc,MAAM;IAC5B,CAAC;;;CAIN,mBACE,SACA,MACM;AACN,OAAK,QAAQ,QAAQ,MAAM,SAAS,KAAK;;;AAI7C,SAAgB,wBAAwB,MAAsB;AAC5D,KAAI,OAAO,SAAS,SAClB,OAAM,IAAI,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC;CAGJ,MAAM,iBAAiB,KAAK,MAAM;AAClC,KAAI,CAAC,eACH,OAAM,IAAI,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC;AAGJ,QAAO"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_client = require("./client.cjs");
|
|
2
|
+
//#region src/create-client.ts
|
|
3
|
+
function createConnectionsClient(options) {
|
|
4
|
+
return new require_client.ConnectionsClientImpl({ ...options });
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
exports.createConnectionsClient = createConnectionsClient;
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=create-client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-client.cjs","names":["ConnectionsClientImpl"],"sources":["../src/create-client.ts"],"sourcesContent":["import { ConnectionsClientImpl } from './client';\nimport type {\n ConnectionsClient,\n CreateConnectionsClientOptions,\n} from './types';\n\nexport function createConnectionsClient(\n options: CreateConnectionsClientOptions\n): ConnectionsClient {\n return new ConnectionsClientImpl({\n ...options,\n });\n}\n"],"mappings":";;AAMA,SAAgB,wBACd,SACmB;AACnB,QAAO,IAAIA,eAAAA,sBAAsB,EAC/B,GAAG,SACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConnectionsClient, CreateConnectionsClientOptions } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/create-client.d.ts
|
|
4
|
+
declare function createConnectionsClient(options: CreateConnectionsClientOptions): ConnectionsClient;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { createConnectionsClient };
|
|
7
|
+
//# sourceMappingURL=create-client.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-client.d.cts","names":[],"sources":["../src/create-client.ts"],"mappings":";;;iBAMgB,uBAAA,CACd,OAAA,EAAS,8BAAA,GACR,iBAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConnectionsClient, CreateConnectionsClientOptions } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/create-client.d.ts
|
|
4
|
+
declare function createConnectionsClient(options: CreateConnectionsClientOptions): ConnectionsClient;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { createConnectionsClient };
|
|
7
|
+
//# sourceMappingURL=create-client.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-client.d.mts","names":[],"sources":["../src/create-client.ts"],"mappings":";;;iBAMgB,uBAAA,CACd,OAAA,EAAS,8BAAA,GACR,iBAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConnectionsClientImpl } from "./client.mjs";
|
|
2
|
+
//#region src/create-client.ts
|
|
3
|
+
function createConnectionsClient(options) {
|
|
4
|
+
return new ConnectionsClientImpl({ ...options });
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createConnectionsClient };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=create-client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-client.mjs","names":[],"sources":["../src/create-client.ts"],"sourcesContent":["import { ConnectionsClientImpl } from './client';\nimport type {\n ConnectionsClient,\n CreateConnectionsClientOptions,\n} from './types';\n\nexport function createConnectionsClient(\n options: CreateConnectionsClientOptions\n): ConnectionsClient {\n return new ConnectionsClientImpl({\n ...options,\n });\n}\n"],"mappings":";;AAMA,SAAgB,wBACd,SACmB;AACnB,QAAO,IAAI,sBAAsB,EAC/B,GAAG,SACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const require_errors = require("./errors.cjs");
|
|
2
|
+
//#region src/envelope.ts
|
|
3
|
+
const CONNECTION_TYPES = new Set([
|
|
4
|
+
"oauth2",
|
|
5
|
+
"api_key",
|
|
6
|
+
"basic",
|
|
7
|
+
"rdb",
|
|
8
|
+
"custom"
|
|
9
|
+
]);
|
|
10
|
+
function unwrapEnvelope(envelope) {
|
|
11
|
+
const statusCode = envelope.status_code;
|
|
12
|
+
if (typeof statusCode !== "string") throw new require_errors.ConnectionsSDKError({
|
|
13
|
+
code: "INVALID_RESPONSE",
|
|
14
|
+
message: "Invalid connection response: missing status_code"
|
|
15
|
+
});
|
|
16
|
+
if (statusCode !== "0") throw new require_errors.ConnectionsSDKError({
|
|
17
|
+
code: "BUSINESS_ERROR",
|
|
18
|
+
message: envelope.error_msg || `Connection service returned ${statusCode}`
|
|
19
|
+
});
|
|
20
|
+
if (envelope.data === void 0 || envelope.data === null) throw new require_errors.ConnectionsSDKError({
|
|
21
|
+
code: "MISSING_DATA",
|
|
22
|
+
message: "Invalid connection response: missing data"
|
|
23
|
+
});
|
|
24
|
+
return envelope.data;
|
|
25
|
+
}
|
|
26
|
+
function assertConnectionResult(value) {
|
|
27
|
+
if (typeof value !== "object" || value === null) throwInvalidConnectionResult();
|
|
28
|
+
const result = value;
|
|
29
|
+
if (result.state === "connected") {
|
|
30
|
+
const connected = result;
|
|
31
|
+
const connectionValue = connected.value;
|
|
32
|
+
if (typeof connected.issuedAt !== "string" || typeof connected.issuanceId !== "string" || typeof connectionValue?.type !== "string" || !CONNECTION_TYPES.has(connectionValue.type)) throwInvalidConnectionResult();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (result.state === "not_connected") {
|
|
36
|
+
const notConnected = result;
|
|
37
|
+
if (typeof notConnected.reason !== "string" || typeof notConnected.recoveryHint !== "string") throwInvalidConnectionResult();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
throwInvalidConnectionResult();
|
|
41
|
+
}
|
|
42
|
+
function throwInvalidConnectionResult() {
|
|
43
|
+
throw new require_errors.ConnectionsSDKError({
|
|
44
|
+
code: "INVALID_RESPONSE",
|
|
45
|
+
message: "Invalid connection response: unexpected data shape"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.assertConnectionResult = assertConnectionResult;
|
|
50
|
+
exports.unwrapEnvelope = unwrapEnvelope;
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=envelope.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.cjs","names":["ConnectionsSDKError"],"sources":["../src/envelope.ts"],"sourcesContent":["import { ConnectionsSDKError } from './errors';\nimport type { ApiEnvelope, ConnectionResult } from './types';\n\nconst CONNECTION_TYPES = new Set([\n 'oauth2',\n 'api_key',\n 'basic',\n 'rdb',\n 'custom',\n]);\n\nexport function unwrapEnvelope<T>(envelope: ApiEnvelope<T>): T {\n const statusCode = envelope.status_code;\n\n if (typeof statusCode !== 'string') {\n throw new ConnectionsSDKError({\n code: 'INVALID_RESPONSE',\n message: 'Invalid connection response: missing status_code',\n });\n }\n\n if (statusCode !== '0') {\n throw new ConnectionsSDKError({\n code: 'BUSINESS_ERROR',\n message:\n envelope.error_msg || `Connection service returned ${statusCode}`,\n });\n }\n\n if (envelope.data === undefined || envelope.data === null) {\n throw new ConnectionsSDKError({\n code: 'MISSING_DATA',\n message: 'Invalid connection response: missing data',\n });\n }\n\n return envelope.data;\n}\n\nexport function assertConnectionResult(\n value: unknown\n): asserts value is ConnectionResult {\n if (typeof value !== 'object' || value === null) {\n throwInvalidConnectionResult();\n }\n\n const result = value as Partial<ConnectionResult>;\n if (result.state === 'connected') {\n const connected = result as Partial<\n Extract<ConnectionResult, { state: 'connected' }>\n >;\n const connectionValue = connected.value as { type?: unknown } | undefined;\n if (\n typeof connected.issuedAt !== 'string' ||\n typeof connected.issuanceId !== 'string' ||\n typeof connectionValue?.type !== 'string' ||\n !CONNECTION_TYPES.has(connectionValue.type)\n ) {\n throwInvalidConnectionResult();\n }\n return;\n }\n\n if (result.state === 'not_connected') {\n const notConnected = result as Partial<\n Extract<ConnectionResult, { state: 'not_connected' }>\n >;\n if (\n typeof notConnected.reason !== 'string' ||\n typeof notConnected.recoveryHint !== 'string'\n ) {\n throwInvalidConnectionResult();\n }\n return;\n }\n\n throwInvalidConnectionResult();\n}\n\nfunction throwInvalidConnectionResult(): never {\n throw new ConnectionsSDKError({\n code: 'INVALID_RESPONSE',\n message: 'Invalid connection response: unexpected data shape',\n });\n}\n"],"mappings":";;AAGA,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAgB,eAAkB,UAA6B;CAC7D,MAAM,aAAa,SAAS;AAE5B,KAAI,OAAO,eAAe,SACxB,OAAM,IAAIA,eAAAA,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC;AAGJ,KAAI,eAAe,IACjB,OAAM,IAAIA,eAAAA,oBAAoB;EAC5B,MAAM;EACN,SACE,SAAS,aAAa,+BAA+B;EACxD,CAAC;AAGJ,KAAI,SAAS,SAAS,KAAA,KAAa,SAAS,SAAS,KACnD,OAAM,IAAIA,eAAAA,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC;AAGJ,QAAO,SAAS;;AAGlB,SAAgB,uBACd,OACmC;AACnC,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,+BAA8B;CAGhC,MAAM,SAAS;AACf,KAAI,OAAO,UAAU,aAAa;EAChC,MAAM,YAAY;EAGlB,MAAM,kBAAkB,UAAU;AAClC,MACE,OAAO,UAAU,aAAa,YAC9B,OAAO,UAAU,eAAe,YAChC,OAAO,iBAAiB,SAAS,YACjC,CAAC,iBAAiB,IAAI,gBAAgB,KAAK,CAE3C,+BAA8B;AAEhC;;AAGF,KAAI,OAAO,UAAU,iBAAiB;EACpC,MAAM,eAAe;AAGrB,MACE,OAAO,aAAa,WAAW,YAC/B,OAAO,aAAa,iBAAiB,SAErC,+BAA8B;AAEhC;;AAGF,+BAA8B;;AAGhC,SAAS,+BAAsC;AAC7C,OAAM,IAAIA,eAAAA,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ConnectionsSDKError } from "./errors.mjs";
|
|
2
|
+
//#region src/envelope.ts
|
|
3
|
+
const CONNECTION_TYPES = new Set([
|
|
4
|
+
"oauth2",
|
|
5
|
+
"api_key",
|
|
6
|
+
"basic",
|
|
7
|
+
"rdb",
|
|
8
|
+
"custom"
|
|
9
|
+
]);
|
|
10
|
+
function unwrapEnvelope(envelope) {
|
|
11
|
+
const statusCode = envelope.status_code;
|
|
12
|
+
if (typeof statusCode !== "string") throw new ConnectionsSDKError({
|
|
13
|
+
code: "INVALID_RESPONSE",
|
|
14
|
+
message: "Invalid connection response: missing status_code"
|
|
15
|
+
});
|
|
16
|
+
if (statusCode !== "0") throw new ConnectionsSDKError({
|
|
17
|
+
code: "BUSINESS_ERROR",
|
|
18
|
+
message: envelope.error_msg || `Connection service returned ${statusCode}`
|
|
19
|
+
});
|
|
20
|
+
if (envelope.data === void 0 || envelope.data === null) throw new ConnectionsSDKError({
|
|
21
|
+
code: "MISSING_DATA",
|
|
22
|
+
message: "Invalid connection response: missing data"
|
|
23
|
+
});
|
|
24
|
+
return envelope.data;
|
|
25
|
+
}
|
|
26
|
+
function assertConnectionResult(value) {
|
|
27
|
+
if (typeof value !== "object" || value === null) throwInvalidConnectionResult();
|
|
28
|
+
const result = value;
|
|
29
|
+
if (result.state === "connected") {
|
|
30
|
+
const connected = result;
|
|
31
|
+
const connectionValue = connected.value;
|
|
32
|
+
if (typeof connected.issuedAt !== "string" || typeof connected.issuanceId !== "string" || typeof connectionValue?.type !== "string" || !CONNECTION_TYPES.has(connectionValue.type)) throwInvalidConnectionResult();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (result.state === "not_connected") {
|
|
36
|
+
const notConnected = result;
|
|
37
|
+
if (typeof notConnected.reason !== "string" || typeof notConnected.recoveryHint !== "string") throwInvalidConnectionResult();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
throwInvalidConnectionResult();
|
|
41
|
+
}
|
|
42
|
+
function throwInvalidConnectionResult() {
|
|
43
|
+
throw new ConnectionsSDKError({
|
|
44
|
+
code: "INVALID_RESPONSE",
|
|
45
|
+
message: "Invalid connection response: unexpected data shape"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { assertConnectionResult, unwrapEnvelope };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=envelope.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.mjs","names":[],"sources":["../src/envelope.ts"],"sourcesContent":["import { ConnectionsSDKError } from './errors';\nimport type { ApiEnvelope, ConnectionResult } from './types';\n\nconst CONNECTION_TYPES = new Set([\n 'oauth2',\n 'api_key',\n 'basic',\n 'rdb',\n 'custom',\n]);\n\nexport function unwrapEnvelope<T>(envelope: ApiEnvelope<T>): T {\n const statusCode = envelope.status_code;\n\n if (typeof statusCode !== 'string') {\n throw new ConnectionsSDKError({\n code: 'INVALID_RESPONSE',\n message: 'Invalid connection response: missing status_code',\n });\n }\n\n if (statusCode !== '0') {\n throw new ConnectionsSDKError({\n code: 'BUSINESS_ERROR',\n message:\n envelope.error_msg || `Connection service returned ${statusCode}`,\n });\n }\n\n if (envelope.data === undefined || envelope.data === null) {\n throw new ConnectionsSDKError({\n code: 'MISSING_DATA',\n message: 'Invalid connection response: missing data',\n });\n }\n\n return envelope.data;\n}\n\nexport function assertConnectionResult(\n value: unknown\n): asserts value is ConnectionResult {\n if (typeof value !== 'object' || value === null) {\n throwInvalidConnectionResult();\n }\n\n const result = value as Partial<ConnectionResult>;\n if (result.state === 'connected') {\n const connected = result as Partial<\n Extract<ConnectionResult, { state: 'connected' }>\n >;\n const connectionValue = connected.value as { type?: unknown } | undefined;\n if (\n typeof connected.issuedAt !== 'string' ||\n typeof connected.issuanceId !== 'string' ||\n typeof connectionValue?.type !== 'string' ||\n !CONNECTION_TYPES.has(connectionValue.type)\n ) {\n throwInvalidConnectionResult();\n }\n return;\n }\n\n if (result.state === 'not_connected') {\n const notConnected = result as Partial<\n Extract<ConnectionResult, { state: 'not_connected' }>\n >;\n if (\n typeof notConnected.reason !== 'string' ||\n typeof notConnected.recoveryHint !== 'string'\n ) {\n throwInvalidConnectionResult();\n }\n return;\n }\n\n throwInvalidConnectionResult();\n}\n\nfunction throwInvalidConnectionResult(): never {\n throw new ConnectionsSDKError({\n code: 'INVALID_RESPONSE',\n message: 'Invalid connection response: unexpected data shape',\n });\n}\n"],"mappings":";;AAGA,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAgB,eAAkB,UAA6B;CAC7D,MAAM,aAAa,SAAS;AAE5B,KAAI,OAAO,eAAe,SACxB,OAAM,IAAI,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC;AAGJ,KAAI,eAAe,IACjB,OAAM,IAAI,oBAAoB;EAC5B,MAAM;EACN,SACE,SAAS,aAAa,+BAA+B;EACxD,CAAC;AAGJ,KAAI,SAAS,SAAS,KAAA,KAAa,SAAS,SAAS,KACnD,OAAM,IAAI,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC;AAGJ,QAAO,SAAS;;AAGlB,SAAgB,uBACd,OACmC;AACnC,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,+BAA8B;CAGhC,MAAM,SAAS;AACf,KAAI,OAAO,UAAU,aAAa;EAChC,MAAM,YAAY;EAGlB,MAAM,kBAAkB,UAAU;AAClC,MACE,OAAO,UAAU,aAAa,YAC9B,OAAO,UAAU,eAAe,YAChC,OAAO,iBAAiB,SAAS,YACjC,CAAC,iBAAiB,IAAI,gBAAgB,KAAK,CAE3C,+BAA8B;AAEhC;;AAGF,KAAI,OAAO,UAAU,iBAAiB;EACpC,MAAM,eAAe;AAGrB,MACE,OAAO,aAAa,WAAW,YAC/B,OAAO,aAAa,iBAAiB,SAErC,+BAA8B;AAEhC;;AAGF,+BAA8B;;AAGhC,SAAS,+BAAsC;AAC7C,OAAM,IAAI,oBAAoB;EAC5B,MAAM;EACN,SAAS;EACV,CAAC"}
|
package/dist/errors.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/errors.ts
|
|
2
|
+
var ConnectionsSDKError = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
statusCode;
|
|
5
|
+
requestId;
|
|
6
|
+
cause;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super(options.message);
|
|
9
|
+
this.name = "ConnectionsSDKError";
|
|
10
|
+
this.code = options.code;
|
|
11
|
+
this.statusCode = options.statusCode;
|
|
12
|
+
this.requestId = options.requestId;
|
|
13
|
+
this.cause = options.cause;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.ConnectionsSDKError = ConnectionsSDKError;
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=errors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["export type ConnectionsSDKErrorCode =\n | 'INVALID_CONNECTION_NAME'\n | 'BUSINESS_ERROR'\n | 'REQUEST_FAILED'\n | 'TIMEOUT'\n | 'MISSING_DATA'\n | 'INVALID_RESPONSE';\n\nexport interface ConnectionsSDKErrorOptions {\n code: ConnectionsSDKErrorCode;\n message: string;\n statusCode?: number;\n requestId?: string;\n cause?: unknown;\n}\n\nexport class ConnectionsSDKError extends Error {\n readonly code: ConnectionsSDKErrorCode;\n readonly statusCode?: number;\n readonly requestId?: string;\n override readonly cause?: unknown;\n\n constructor(options: ConnectionsSDKErrorOptions) {\n super(options.message);\n this.name = 'ConnectionsSDKError';\n this.code = options.code;\n this.statusCode = options.statusCode;\n this.requestId = options.requestId;\n this.cause = options.cause;\n }\n}\n"],"mappings":";AAgBA,IAAa,sBAAb,cAAyC,MAAM;CAC7C;CACA;CACA;CACA;CAEA,YAAY,SAAqC;AAC/C,QAAM,QAAQ,QAAQ;AACtB,OAAK,OAAO;AACZ,OAAK,OAAO,QAAQ;AACpB,OAAK,aAAa,QAAQ;AAC1B,OAAK,YAAY,QAAQ;AACzB,OAAK,QAAQ,QAAQ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/errors.d.ts
|
|
2
|
+
type ConnectionsSDKErrorCode = 'INVALID_CONNECTION_NAME' | 'BUSINESS_ERROR' | 'REQUEST_FAILED' | 'TIMEOUT' | 'MISSING_DATA' | 'INVALID_RESPONSE';
|
|
3
|
+
interface ConnectionsSDKErrorOptions {
|
|
4
|
+
code: ConnectionsSDKErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
statusCode?: number;
|
|
7
|
+
requestId?: string;
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
}
|
|
10
|
+
declare class ConnectionsSDKError extends Error {
|
|
11
|
+
readonly code: ConnectionsSDKErrorCode;
|
|
12
|
+
readonly statusCode?: number;
|
|
13
|
+
readonly requestId?: string;
|
|
14
|
+
readonly cause?: unknown;
|
|
15
|
+
constructor(options: ConnectionsSDKErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ConnectionsSDKError, ConnectionsSDKErrorCode, ConnectionsSDKErrorOptions };
|
|
19
|
+
//# sourceMappingURL=errors.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";KAAY,uBAAA;AAAA,UAQK,0BAAA;EACf,IAAA,EAAM,uBAAA;EACN,OAAA;EACA,UAAA;EACA,SAAA;EACA,KAAA;AAAA;AAAA,cAGW,mBAAA,SAA4B,KAAA;EAAA,SAC9B,IAAA,EAAM,uBAAA;EAAA,SACN,UAAA;EAAA,SACA,SAAA;EAAA,SACS,KAAA;cAEN,OAAA,EAAS,0BAAA;AAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/errors.d.ts
|
|
2
|
+
type ConnectionsSDKErrorCode = 'INVALID_CONNECTION_NAME' | 'BUSINESS_ERROR' | 'REQUEST_FAILED' | 'TIMEOUT' | 'MISSING_DATA' | 'INVALID_RESPONSE';
|
|
3
|
+
interface ConnectionsSDKErrorOptions {
|
|
4
|
+
code: ConnectionsSDKErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
statusCode?: number;
|
|
7
|
+
requestId?: string;
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
}
|
|
10
|
+
declare class ConnectionsSDKError extends Error {
|
|
11
|
+
readonly code: ConnectionsSDKErrorCode;
|
|
12
|
+
readonly statusCode?: number;
|
|
13
|
+
readonly requestId?: string;
|
|
14
|
+
readonly cause?: unknown;
|
|
15
|
+
constructor(options: ConnectionsSDKErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ConnectionsSDKError, ConnectionsSDKErrorCode, ConnectionsSDKErrorOptions };
|
|
19
|
+
//# sourceMappingURL=errors.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";KAAY,uBAAA;AAAA,UAQK,0BAAA;EACf,IAAA,EAAM,uBAAA;EACN,OAAA;EACA,UAAA;EACA,SAAA;EACA,KAAA;AAAA;AAAA,cAGW,mBAAA,SAA4B,KAAA;EAAA,SAC9B,IAAA,EAAM,uBAAA;EAAA,SACN,UAAA;EAAA,SACA,SAAA;EAAA,SACS,KAAA;cAEN,OAAA,EAAS,0BAAA;AAAA"}
|
package/dist/errors.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/errors.ts
|
|
2
|
+
var ConnectionsSDKError = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
statusCode;
|
|
5
|
+
requestId;
|
|
6
|
+
cause;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super(options.message);
|
|
9
|
+
this.name = "ConnectionsSDKError";
|
|
10
|
+
this.code = options.code;
|
|
11
|
+
this.statusCode = options.statusCode;
|
|
12
|
+
this.requestId = options.requestId;
|
|
13
|
+
this.cause = options.cause;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ConnectionsSDKError };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["export type ConnectionsSDKErrorCode =\n | 'INVALID_CONNECTION_NAME'\n | 'BUSINESS_ERROR'\n | 'REQUEST_FAILED'\n | 'TIMEOUT'\n | 'MISSING_DATA'\n | 'INVALID_RESPONSE';\n\nexport interface ConnectionsSDKErrorOptions {\n code: ConnectionsSDKErrorCode;\n message: string;\n statusCode?: number;\n requestId?: string;\n cause?: unknown;\n}\n\nexport class ConnectionsSDKError extends Error {\n readonly code: ConnectionsSDKErrorCode;\n readonly statusCode?: number;\n readonly requestId?: string;\n override readonly cause?: unknown;\n\n constructor(options: ConnectionsSDKErrorOptions) {\n super(options.message);\n this.name = 'ConnectionsSDKError';\n this.code = options.code;\n this.statusCode = options.statusCode;\n this.requestId = options.requestId;\n this.cause = options.cause;\n }\n}\n"],"mappings":";AAgBA,IAAa,sBAAb,cAAyC,MAAM;CAC7C;CACA;CACA;CACA;CAEA,YAAY,SAAqC;AAC/C,QAAM,QAAQ,QAAQ;AACtB,OAAK,OAAO;AACZ,OAAK,OAAO,QAAQ;AACpB,OAAK,aAAa,QAAQ;AAC1B,OAAK,YAAY,QAAQ;AACzB,OAAK,QAAQ,QAAQ"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_errors = require("./errors.cjs");
|
|
3
|
+
const require_create_client = require("./create-client.cjs");
|
|
4
|
+
const require_nestjs = require("./nestjs.cjs");
|
|
5
|
+
exports.ConnectionsSDKError = require_errors.ConnectionsSDKError;
|
|
6
|
+
exports.ConnectionsService = require_nestjs.ConnectionsService;
|
|
7
|
+
Object.defineProperty(exports, "MiaodaConnectionsModule", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function() {
|
|
10
|
+
return require_nestjs.MiaodaConnectionsModule;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.createConnectionsClient = require_create_client.createConnectionsClient;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ApiEnvelope, ApiKeyConnection, BasicConnection, ConnectedConnection, ConnectionResult, ConnectionValue, ConnectionsClient, ConnectionsLogger, ConnectionsRequest, ConnectionsTransport, CreateConnectionsClientOptions, CustomConnection, GetConnectionOptions, NotConnectedConnection, OAuth2Connection, RdbConnection } from "./types.cjs";
|
|
2
|
+
import { createConnectionsClient } from "./create-client.cjs";
|
|
3
|
+
import { ConnectionsSDKError, ConnectionsSDKErrorCode, ConnectionsSDKErrorOptions } from "./errors.cjs";
|
|
4
|
+
import { ConnectionsService, MiaodaConnectionsModule } from "./nestjs.cjs";
|
|
5
|
+
export { type ApiEnvelope, type ApiKeyConnection, type BasicConnection, type ConnectedConnection, type ConnectionResult, type ConnectionValue, type ConnectionsClient, type ConnectionsLogger, type ConnectionsRequest, ConnectionsSDKError, type ConnectionsSDKErrorCode, type ConnectionsSDKErrorOptions, ConnectionsService, type ConnectionsTransport, type CreateConnectionsClientOptions, type CustomConnection, type GetConnectionOptions, MiaodaConnectionsModule, type NotConnectedConnection, type OAuth2Connection, type RdbConnection, createConnectionsClient };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ApiEnvelope, ApiKeyConnection, BasicConnection, ConnectedConnection, ConnectionResult, ConnectionValue, ConnectionsClient, ConnectionsLogger, ConnectionsRequest, ConnectionsTransport, CreateConnectionsClientOptions, CustomConnection, GetConnectionOptions, NotConnectedConnection, OAuth2Connection, RdbConnection } from "./types.mjs";
|
|
2
|
+
import { createConnectionsClient } from "./create-client.mjs";
|
|
3
|
+
import { ConnectionsSDKError, ConnectionsSDKErrorCode, ConnectionsSDKErrorOptions } from "./errors.mjs";
|
|
4
|
+
import { ConnectionsService, MiaodaConnectionsModule } from "./nestjs.mjs";
|
|
5
|
+
export { type ApiEnvelope, type ApiKeyConnection, type BasicConnection, type ConnectedConnection, type ConnectionResult, type ConnectionValue, type ConnectionsClient, type ConnectionsLogger, type ConnectionsRequest, ConnectionsSDKError, type ConnectionsSDKErrorCode, type ConnectionsSDKErrorOptions, ConnectionsService, type ConnectionsTransport, type CreateConnectionsClientOptions, type CustomConnection, type GetConnectionOptions, MiaodaConnectionsModule, type NotConnectedConnection, type OAuth2Connection, type RdbConnection, createConnectionsClient };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ConnectionsSDKError } from "./errors.mjs";
|
|
2
|
+
import { createConnectionsClient } from "./create-client.mjs";
|
|
3
|
+
import { ConnectionsService, MiaodaConnectionsModule } from "./nestjs.mjs";
|
|
4
|
+
export { ConnectionsSDKError, ConnectionsService, MiaodaConnectionsModule, createConnectionsClient };
|
package/dist/nestjs.cjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const require_create_client = require("./create-client.cjs");
|
|
2
|
+
const require_platform_http_client = require("./platform-http-client.cjs");
|
|
3
|
+
const require_decorateMetadata = require("./_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs");
|
|
4
|
+
const require_decorateParam = require("./_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateParam.cjs");
|
|
5
|
+
const require_decorate = require("./_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs");
|
|
6
|
+
let _nestjs_common = require("@nestjs/common");
|
|
7
|
+
let _lark_apaas_nestjs_common = require("@lark-apaas/nestjs-common");
|
|
8
|
+
//#region src/nestjs.ts
|
|
9
|
+
var _PlatformConnectionsService;
|
|
10
|
+
var ConnectionsService = class {};
|
|
11
|
+
let PlatformConnectionsService = _PlatformConnectionsService = class PlatformConnectionsService extends ConnectionsService {
|
|
12
|
+
client;
|
|
13
|
+
logger = new _nestjs_common.Logger(_PlatformConnectionsService.name);
|
|
14
|
+
constructor(platformHttpClient) {
|
|
15
|
+
super();
|
|
16
|
+
this.client = require_create_client.createConnectionsClient({
|
|
17
|
+
logger: this.logger,
|
|
18
|
+
transport: require_platform_http_client.createPlatformHttpClientTransport(platformHttpClient, { logger: this.logger })
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
getConnection(input) {
|
|
22
|
+
if (typeof input === "string") return this.client.getConnection(input);
|
|
23
|
+
return this.client.getConnection(input);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
PlatformConnectionsService = _PlatformConnectionsService = require_decorate.__decorate([
|
|
27
|
+
(0, _nestjs_common.Injectable)(),
|
|
28
|
+
require_decorateParam.__decorateParam(0, (0, _nestjs_common.Inject)(_lark_apaas_nestjs_common.PLATFORM_HTTP_CLIENT)),
|
|
29
|
+
require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object])
|
|
30
|
+
], PlatformConnectionsService);
|
|
31
|
+
let MiaodaConnectionsModule = class MiaodaConnectionsModule {};
|
|
32
|
+
MiaodaConnectionsModule = require_decorate.__decorate([(0, _nestjs_common.Module)({
|
|
33
|
+
providers: [{
|
|
34
|
+
provide: ConnectionsService,
|
|
35
|
+
useClass: PlatformConnectionsService
|
|
36
|
+
}],
|
|
37
|
+
exports: [ConnectionsService]
|
|
38
|
+
})], MiaodaConnectionsModule);
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.ConnectionsService = ConnectionsService;
|
|
41
|
+
Object.defineProperty(exports, "MiaodaConnectionsModule", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function() {
|
|
44
|
+
return MiaodaConnectionsModule;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=nestjs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestjs.cjs","names":["Logger","createConnectionsClient","createPlatformHttpClientTransport","PLATFORM_HTTP_CLIENT"],"sources":["../src/nestjs.ts"],"sourcesContent":["import { Inject, Injectable, Logger, Module } from '@nestjs/common';\nimport {\n PLATFORM_HTTP_CLIENT,\n type PlatformHttpClient,\n} from '@lark-apaas/nestjs-common';\n\nimport { createConnectionsClient } from './create-client';\nimport { createPlatformHttpClientTransport } from './platform-http-client';\nimport type {\n ConnectionResult,\n ConnectionsClient,\n GetConnectionOptions,\n} from './types';\n\nexport abstract class ConnectionsService implements ConnectionsClient {\n abstract getConnection(name: string): Promise<ConnectionResult>;\n abstract getConnection(options: GetConnectionOptions): Promise<ConnectionResult>;\n}\n\n@Injectable()\nclass PlatformConnectionsService extends ConnectionsService {\n private readonly client: ConnectionsClient;\n private readonly logger = new Logger(PlatformConnectionsService.name);\n\n constructor(\n @Inject(PLATFORM_HTTP_CLIENT)\n platformHttpClient: PlatformHttpClient\n ) {\n super();\n this.client = createConnectionsClient({\n logger: this.logger,\n transport: createPlatformHttpClientTransport(platformHttpClient, {\n logger: this.logger,\n }),\n });\n }\n\n getConnection(name: string): Promise<ConnectionResult>;\n getConnection(options: GetConnectionOptions): Promise<ConnectionResult>;\n getConnection(input: string | GetConnectionOptions): Promise<ConnectionResult> {\n if (typeof input === 'string') {\n return this.client.getConnection(input);\n }\n\n return this.client.getConnection(input);\n }\n}\n\n@Module({\n providers: [\n {\n provide: ConnectionsService,\n useClass: PlatformConnectionsService,\n },\n ],\n exports: [ConnectionsService],\n})\nexport class MiaodaConnectionsModule {}\n"],"mappings":";;;;;;;;;AAcA,IAAsB,qBAAtB,MAAsE;AAKtE,IAAA,6BAAA,8BAAA,MACM,mCAAmC,mBAAmB;CAC1D;CACA,SAA0B,IAAIA,eAAAA,OAAAA,4BAAkC,KAAK;CAErE,YACE,oBAEA;AACA,SAAO;AACP,OAAK,SAASC,sBAAAA,wBAAwB;GACpC,QAAQ,KAAK;GACb,WAAWC,6BAAAA,kCAAkC,oBAAoB,EAC/D,QAAQ,KAAK,QACd,CAAC;GACH,CAAC;;CAKJ,cAAc,OAAiE;AAC7E,MAAI,OAAO,UAAU,SACnB,QAAO,KAAK,OAAO,cAAc,MAAM;AAGzC,SAAO,KAAK,OAAO,cAAc,MAAM;;;;iCAzB9B;qEAMDC,0BAAAA,qBAAqB,CAAA;;;AAgC1B,IAAA,0BAAA,MAAM,wBAAwB;kFAT7B;CACN,WAAW,CACT;EACE,SAAS;EACT,UAAU;EACX,CACF;CACD,SAAS,CAAC,mBAAmB;CAC9B,CAAC,CAAA,EAAA,wBAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConnectionResult, ConnectionsClient, GetConnectionOptions } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/nestjs.d.ts
|
|
4
|
+
declare abstract class ConnectionsService implements ConnectionsClient {
|
|
5
|
+
abstract getConnection(name: string): Promise<ConnectionResult>;
|
|
6
|
+
abstract getConnection(options: GetConnectionOptions): Promise<ConnectionResult>;
|
|
7
|
+
}
|
|
8
|
+
declare class MiaodaConnectionsModule {}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ConnectionsService, MiaodaConnectionsModule };
|
|
11
|
+
//# sourceMappingURL=nestjs.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestjs.d.cts","names":[],"sources":["../src/nestjs.ts"],"mappings":";;;uBAcsB,kBAAA,YAA8B,iBAAA;EAAA,SACzC,aAAA,CAAc,IAAA,WAAe,OAAA,CAAQ,gBAAA;EAAA,SACrC,aAAA,CAAc,OAAA,EAAS,oBAAA,GAAuB,OAAA,CAAQ,gBAAA;AAAA;AAAA,cAyCpD,uBAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConnectionResult, ConnectionsClient, GetConnectionOptions } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/nestjs.d.ts
|
|
4
|
+
declare abstract class ConnectionsService implements ConnectionsClient {
|
|
5
|
+
abstract getConnection(name: string): Promise<ConnectionResult>;
|
|
6
|
+
abstract getConnection(options: GetConnectionOptions): Promise<ConnectionResult>;
|
|
7
|
+
}
|
|
8
|
+
declare class MiaodaConnectionsModule {}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ConnectionsService, MiaodaConnectionsModule };
|
|
11
|
+
//# sourceMappingURL=nestjs.d.mts.map
|