@yopdev/dev-server 1.4.0 → 1.4.4
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/src/assert.js +1 -2
- package/dist/src/cloudformation-event-proxy.d.ts +13 -0
- package/dist/src/cloudformation-event-proxy.js +24 -0
- package/dist/src/cloudformation-lambda-http-proxy.d.ts +12 -0
- package/dist/src/cloudformation-lambda-http-proxy.js +42 -0
- package/dist/src/cloudformation.d.ts +28 -0
- package/dist/src/cloudformation.js +47 -0
- package/dist/src/container.js +23 -70
- package/dist/src/deferred.js +28 -89
- package/dist/src/dev-server.js +47 -51
- package/dist/src/dynamodb.js +25 -74
- package/dist/src/event-proxy.js +51 -108
- package/dist/src/factories.js +11 -64
- package/dist/src/http-server.js +23 -25
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +7 -46
- package/dist/src/internal-queue.js +42 -100
- package/dist/src/lambda-http-proxy.d.ts +1 -2
- package/dist/src/lambda-http-proxy.js +28 -93
- package/dist/src/localstack.js +37 -79
- package/dist/src/mappers.js +6 -6
- package/dist/src/pre-traffic-hooks.js +11 -55
- package/dist/src/responses.js +2 -2
- package/dist/src/s3.js +15 -69
- package/dist/src/scheduled-tasks.js +11 -56
- package/dist/src/services.d.ts +4 -2
- package/dist/src/services.js +13 -53
- package/dist/src/sns-http-proxy.js +41 -59
- package/dist/src/sns.js +29 -79
- package/dist/src/sqs.js +27 -74
- package/dist/src/stoppable.js +11 -50
- package/dist/src/tunnel.js +20 -70
- package/package.json +4 -1
package/dist/src/stoppable.js
CHANGED
|
@@ -1,54 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.stopConsumer = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return [2 /*return*/];
|
|
52
|
-
});
|
|
53
|
-
}); };
|
|
4
|
+
const stopConsumer = async (queueWaitTimeSecs, target) => {
|
|
5
|
+
if (target) {
|
|
6
|
+
target.stop();
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
setTimeout(resolve, queueWaitTimeSecs * 1000 + 1);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return Promise.resolve();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
54
15
|
exports.stopConsumer = stopConsumer;
|
package/dist/src/tunnel.js
CHANGED
|
@@ -1,79 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.newTunnel = exports.terminate = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return [2 /*return*/, ngrok.kill()];
|
|
46
|
-
}); }); };
|
|
4
|
+
const services_1 = require("./services");
|
|
5
|
+
const logging_1 = require("@yopdev/logging");
|
|
6
|
+
const ngrok = require("@ngrok/ngrok");
|
|
7
|
+
const assert_1 = require("./assert");
|
|
8
|
+
const terminate = async () => ngrok.kill();
|
|
47
9
|
exports.terminate = terminate;
|
|
48
|
-
|
|
49
|
-
return new services_1.Service(new Tunnel(config.name, config.port, config.fixed));
|
|
50
|
-
};
|
|
10
|
+
const newTunnel = (config) => new services_1.Service(new Tunnel(config.name, config.port, config.fixed));
|
|
51
11
|
exports.newTunnel = newTunnel;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var _this = this;
|
|
12
|
+
class Tunnel {
|
|
13
|
+
constructor(name, port, domain) {
|
|
55
14
|
this.name = name;
|
|
56
15
|
this.port = port;
|
|
57
16
|
this.domain = domain;
|
|
58
|
-
this.start =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.then(function (listener) { return (0, assert_1.assertNotUndefined)(listener.url()); })
|
|
70
|
-
.tap(function (url) { return _this.logger.debug(url); })];
|
|
71
|
-
});
|
|
72
|
-
}); };
|
|
73
|
-
this.stop = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
74
|
-
return [2 /*return*/, ngrok.disconnect()];
|
|
75
|
-
}); }); };
|
|
76
|
-
this.logger = logging_1.LoggerFactory.create("TUNNEL[".concat(name, "]"));
|
|
17
|
+
this.start = async () => ngrok
|
|
18
|
+
.forward({
|
|
19
|
+
proto: 'http',
|
|
20
|
+
domain: this.domain?.name,
|
|
21
|
+
addr: this.port,
|
|
22
|
+
authtoken: this.domain?.token,
|
|
23
|
+
})
|
|
24
|
+
.then((listener) => (0, assert_1.assertNotUndefined)(listener.url()))
|
|
25
|
+
.tap((url) => this.logger.debug(url));
|
|
26
|
+
this.stop = async () => ngrok.disconnect();
|
|
27
|
+
this.logger = logging_1.LoggerFactory.create(`TUNNEL[${name}]`);
|
|
77
28
|
}
|
|
78
|
-
|
|
79
|
-
}());
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yopdev/dev-server",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"compile": "tsc",
|
|
6
6
|
"pretest": "npm run compile",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@types/aws-lambda": "8.10.114",
|
|
14
|
+
"@types/js-yaml": "^4.0.9",
|
|
14
15
|
"@types/node": "^20.9.0",
|
|
15
16
|
"axios": "^1.6.2",
|
|
16
17
|
"ts-jest": "^29.1.1",
|
|
@@ -23,6 +24,8 @@
|
|
|
23
24
|
"@aws-sdk/client-sqs": "^3.451.0",
|
|
24
25
|
"@ngrok/ngrok": "^0.9.1",
|
|
25
26
|
"@yopdev/logging": "^0.0.2",
|
|
27
|
+
"js-yaml": "^4.1.0",
|
|
28
|
+
"js-yaml-cloudformation-schema": "^1.0.0",
|
|
26
29
|
"sqs-consumer": "^7.4.0",
|
|
27
30
|
"testcontainers": "^10.2.2"
|
|
28
31
|
},
|