@trayio/tray-api 0.5.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/dist/base/Api.d.ts +4 -0
- package/dist/base/Api.d.ts.map +1 -0
- package/dist/base/Api.js +2 -0
- package/dist/connector/deployment/ConnectorDeploymentApi.abstract.test.d.ts +3 -0
- package/dist/connector/deployment/ConnectorDeploymentApi.abstract.test.d.ts.map +1 -0
- package/dist/connector/deployment/ConnectorDeploymentApi.abstract.test.js +71 -0
- package/dist/connector/deployment/ConnectorDeploymentApi.d.ts +28 -0
- package/dist/connector/deployment/ConnectorDeploymentApi.d.ts.map +1 -0
- package/dist/connector/deployment/ConnectorDeploymentApi.js +9 -0
- package/dist/connector/deployment/cdk-project.test.zip +0 -0
- package/package.json +27 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../src/base/Api.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC"}
|
package/dist/base/Api.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectorDeploymentApi.abstract.test.d.ts","sourceRoot":"","sources":["../../../src/connector/deployment/ConnectorDeploymentApi.abstract.test.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,sBAAsB,EAEtB,MAAM,0BAA0B,CAAC;AAOlC,eAAO,MAAM,0BAA0B,qBACpB,sBAAsB,SAqCxC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.connectorDeploymentApiTest = void 0;
|
|
36
|
+
const fs = __importStar(require("fs"));
|
|
37
|
+
const Result_1 = require("@trayio/tray-commons/result/Result");
|
|
38
|
+
const path_1 = require("path");
|
|
39
|
+
const ConnectorDeploymentApi_1 = require("./ConnectorDeploymentApi");
|
|
40
|
+
const API_TOKEN = process.env.API_TOKEN;
|
|
41
|
+
const connectorName = 'cdk-project';
|
|
42
|
+
const connectorVersion = '1.0';
|
|
43
|
+
const connectorDeploymentApiTest = (deploymentClient) => {
|
|
44
|
+
let sourceCode;
|
|
45
|
+
beforeAll(() => {
|
|
46
|
+
const zipFile = fs.readFileSync((0, path_1.join)(__dirname, `${connectorName}.test.zip`));
|
|
47
|
+
sourceCode = Buffer.from(zipFile).toString('base64');
|
|
48
|
+
});
|
|
49
|
+
describe('ConnectorDeploymentApi', () => {
|
|
50
|
+
it('should be defined', () => {
|
|
51
|
+
expect(deploymentClient).toBeDefined();
|
|
52
|
+
});
|
|
53
|
+
it('deploys a connector from source code', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
const input = {
|
|
55
|
+
connectorName,
|
|
56
|
+
connectorVersion,
|
|
57
|
+
connectorSourceCode: sourceCode,
|
|
58
|
+
token: API_TOKEN,
|
|
59
|
+
};
|
|
60
|
+
const response = yield deploymentClient.deployFromSourceCode(input);
|
|
61
|
+
expect(response).toEqual(Result_1.Result.success({
|
|
62
|
+
id: expect.any(String),
|
|
63
|
+
connectorName,
|
|
64
|
+
connectorVersion,
|
|
65
|
+
deploymentStatus: ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deploying,
|
|
66
|
+
}));
|
|
67
|
+
// Extended timeout to 1 minute for connector code build & compile
|
|
68
|
+
}), 60000);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
exports.connectorDeploymentApiTest = connectorDeploymentApiTest;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Result } from '@trayio/tray-commons/result/Result';
|
|
2
|
+
import { RequestWithToken } from '../../base/Api';
|
|
3
|
+
export interface ConnectorDeploymentApi {
|
|
4
|
+
deployFromSourceCode: ({ connectorName, connectorVersion, connectorSourceCode, token, }: DeployConnectorFromSourceCode) => Promise<Result<Error, ConnectorDeployment>>;
|
|
5
|
+
get: ({ id, connectorName, connectorVersion, token, }: GetConnectorDeployment) => Promise<Result<Error, ConnectorDeployment>>;
|
|
6
|
+
}
|
|
7
|
+
export type DeployConnectorFromSourceCode = RequestWithToken & {
|
|
8
|
+
connectorName: string;
|
|
9
|
+
connectorVersion: string;
|
|
10
|
+
connectorSourceCode: string;
|
|
11
|
+
};
|
|
12
|
+
export type GetConnectorDeployment = RequestWithToken & {
|
|
13
|
+
id: string;
|
|
14
|
+
connectorName: string;
|
|
15
|
+
connectorVersion: string;
|
|
16
|
+
};
|
|
17
|
+
export declare enum ConnectorDeploymentStatus {
|
|
18
|
+
Deployed = "Deployed",
|
|
19
|
+
Failed = "Failed",
|
|
20
|
+
Deploying = "Deploying"
|
|
21
|
+
}
|
|
22
|
+
export type ConnectorDeployment = {
|
|
23
|
+
id: string;
|
|
24
|
+
connectorName: string;
|
|
25
|
+
connectorVersion: string;
|
|
26
|
+
deploymentStatus: ConnectorDeploymentStatus;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=ConnectorDeploymentApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectorDeploymentApi.d.ts","sourceRoot":"","sources":["../../../src/connector/deployment/ConnectorDeploymentApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,sBAAsB;IACtC,oBAAoB,EAAE,CAAC,EACtB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,GACL,EAAE,6BAA6B,KAAK,OAAO,CAC3C,MAAM,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAClC,CAAC;IAEF,GAAG,EAAE,CAAC,EACL,EAAE,EACF,aAAa,EACb,gBAAgB,EAChB,KAAK,GACL,EAAE,sBAAsB,KAAK,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC;CAC1E;AAED,MAAM,MAAM,6BAA6B,GAAG,gBAAgB,GAAG;IAC9D,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,oBAAY,yBAAyB;IACpC,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,SAAS,cAAc;CACvB;AAED,MAAM,MAAM,mBAAmB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,yBAAyB,CAAC;CAC5C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectorDeploymentStatus = void 0;
|
|
4
|
+
var ConnectorDeploymentStatus;
|
|
5
|
+
(function (ConnectorDeploymentStatus) {
|
|
6
|
+
ConnectorDeploymentStatus["Deployed"] = "Deployed";
|
|
7
|
+
ConnectorDeploymentStatus["Failed"] = "Failed";
|
|
8
|
+
ConnectorDeploymentStatus["Deploying"] = "Deploying";
|
|
9
|
+
})(ConnectorDeploymentStatus || (exports.ConnectorDeploymentStatus = ConnectorDeploymentStatus = {}));
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@trayio/tray-api",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "A library for interacting with the Tray.io API",
|
|
5
|
+
"exports": {
|
|
6
|
+
"./*": "./dist/*.js"
|
|
7
|
+
},
|
|
8
|
+
"author": "Tray.io",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18.x"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"typesVersions": {
|
|
17
|
+
"*": {
|
|
18
|
+
"*": [
|
|
19
|
+
"*",
|
|
20
|
+
"dist/*"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"/dist"
|
|
26
|
+
]
|
|
27
|
+
}
|