@mocktomata/io-remote 7.0.0-beta.12 → 7.0.0-beta.13
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/cjs/buildUrl.d.ts +2 -0
- package/cjs/buildUrl.d.ts.map +1 -0
- package/cjs/buildUrl.js +8 -0
- package/cjs/buildUrl.js.map +1 -0
- package/cjs/createIO.d.ts +4 -0
- package/cjs/createIO.d.ts.map +1 -0
- package/cjs/createIO.internal.d.ts +5 -0
- package/cjs/createIO.internal.d.ts.map +1 -0
- package/cjs/createIO.internal.js +38 -0
- package/cjs/createIO.internal.js.map +1 -0
- package/cjs/createIO.js +15 -0
- package/cjs/createIO.js.map +1 -0
- package/cjs/errors.d.ts +11 -0
- package/cjs/errors.d.ts.map +1 -0
- package/cjs/errors.js +20 -0
- package/cjs/errors.js.map +1 -0
- package/cjs/getServerInfo.d.ts +16 -0
- package/cjs/getServerInfo.d.ts.map +1 -0
- package/cjs/getServerInfo.js +41 -0
- package/cjs/getServerInfo.js.map +1 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +20 -0
- package/cjs/index.js.map +1 -0
- package/cjs/package.json +1 -0
- package/cjs/platform.d.ts +2 -0
- package/cjs/platform.d.ts.map +1 -0
- package/cjs/platform.js +31 -0
- package/cjs/platform.js.map +1 -0
- package/cjs/types.d.ts +8 -0
- package/cjs/types.d.ts.map +1 -0
- package/cjs/types.internal.d.ts +9 -0
- package/cjs/types.internal.d.ts.map +1 -0
- package/cjs/types.internal.js +3 -0
- package/cjs/types.internal.js.map +1 -0
- package/cjs/types.js +3 -0
- package/cjs/types.js.map +1 -0
- package/package.json +14 -5
- package/esm/createIO.spec.d.ts +0 -2
- package/esm/createIO.spec.d.ts.map +0 -1
- package/esm/createIO.spec.js +0 -54
- package/esm/createIO.spec.js.map +0 -1
- package/esm/getServerInfo.spec.d.ts +0 -2
- package/esm/getServerInfo.spec.d.ts.map +0 -1
- package/esm/getServerInfo.spec.js +0 -69
- package/esm/getServerInfo.spec.js.map +0 -1
- package/esm/index.spec.d.ts +0 -2
- package/esm/index.spec.d.ts.map +0 -1
- package/esm/index.spec.js +0 -5
- package/esm/index.spec.js.map +0 -1
- package/esm/test-util/createFakeServerFetch.d.ts +0 -5
- package/esm/test-util/createFakeServerFetch.d.ts.map +0 -1
- package/esm/test-util/createFakeServerFetch.js +0 -53
- package/esm/test-util/createFakeServerFetch.js.map +0 -1
- package/esm/test-util/index.d.ts +0 -2
- package/esm/test-util/index.d.ts.map +0 -1
- package/esm/test-util/index.js +0 -2
- package/esm/test-util/index.js.map +0 -1
- package/ts/createIO.spec.ts +0 -70
- package/ts/getServerInfo.spec.ts +0 -73
- package/ts/index.spec.ts +0 -5
- package/ts/test-util/createFakeServerFetch.ts +0 -58
- package/ts/test-util/index.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUrl.d.ts","sourceRoot":"","sources":["../ts/buildUrl.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAErD"}
|
package/cjs/buildUrl.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUrl.js","sourceRoot":"","sources":["../ts/buildUrl.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAC,OAAe,EAAE,IAAY;IACpD,OAAO,GAAG,OAAO,eAAe,IAAI,EAAE,CAAA;AACxC,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIO.d.ts","sourceRoot":"","sources":["../ts/createIO.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAIvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,wBAAsB,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAGhF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Mocktomata } from '@mocktomata/framework';
|
|
2
|
+
import type { Context } from './types.internal.js';
|
|
3
|
+
import type { CreateIOOptions } from './types.js';
|
|
4
|
+
export declare function createIOInternal(ctx: Context, options?: CreateIOOptions): Promise<Mocktomata.IO>;
|
|
5
|
+
//# sourceMappingURL=createIO.internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIO.internal.d.ts","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwC,MAAM,uBAAuB,CAAA;AAGxF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CA6BtG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIOInternal = void 0;
|
|
4
|
+
const framework_1 = require("@mocktomata/framework");
|
|
5
|
+
const buildUrl_js_1 = require("./buildUrl.js");
|
|
6
|
+
const getServerInfo_js_1 = require("./getServerInfo.js");
|
|
7
|
+
async function createIOInternal(ctx, options) {
|
|
8
|
+
const info = await (0, getServerInfo_js_1.getServerInfo)(ctx, options);
|
|
9
|
+
return {
|
|
10
|
+
async loadConfig() {
|
|
11
|
+
// @TODO add browser config?
|
|
12
|
+
const url = (0, buildUrl_js_1.buildUrl)(info.url, `config`);
|
|
13
|
+
const response = await ctx.fetch(url);
|
|
14
|
+
return response.json();
|
|
15
|
+
},
|
|
16
|
+
async loadPlugin(name) {
|
|
17
|
+
return ctx.importModule(name);
|
|
18
|
+
},
|
|
19
|
+
async readSpec(specName, specRelativePath) {
|
|
20
|
+
const id = btoa(JSON.stringify({ specName, specRelativePath }));
|
|
21
|
+
const response = await ctx.fetch((0, buildUrl_js_1.buildUrl)(info.url, `specs/${id}`));
|
|
22
|
+
if (response.status === 404) {
|
|
23
|
+
throw new framework_1.SpecNotFound(id, specRelativePath);
|
|
24
|
+
}
|
|
25
|
+
return response.json();
|
|
26
|
+
},
|
|
27
|
+
async writeSpec(specName, specRelativePath, record) {
|
|
28
|
+
const id = btoa(JSON.stringify({ specName, specRelativePath }));
|
|
29
|
+
const response = await ctx.fetch((0, buildUrl_js_1.buildUrl)(info.url, `specs/${id}`), { method: 'POST', body: JSON.stringify(record) });
|
|
30
|
+
// istanbul ignore next
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error(`failed to write spec: ${response.statusText}`);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.createIOInternal = createIOInternal;
|
|
38
|
+
//# sourceMappingURL=createIO.internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIO.internal.js","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":";;;AAAA,qDAAwF;AACxF,+CAAwC;AACxC,yDAAkD;AAI3C,KAAK,UAAU,gBAAgB,CAAC,GAAY,EAAE,OAAyB;IAC5E,MAAM,IAAI,GAAG,MAAM,IAAA,gCAAa,EAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAC9C,OAAO;QACL,KAAK,CAAC,UAAU;YACd,4BAA4B;YAC5B,MAAM,GAAG,GAAG,IAAA,sBAAQ,EAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;YACxC,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACrC,OAAO,QAAQ,CAAC,IAAI,EAAE,CA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@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createIO = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const createIO_internal_js_1 = require("./createIO.internal.js");
|
|
9
|
+
const platform_js_1 = require("./platform.js");
|
|
10
|
+
async function createIO(options) {
|
|
11
|
+
// istanbul ignore next
|
|
12
|
+
return (0, createIO_internal_js_1.createIOInternal)({ fetch: cross_fetch_1.default, location, importModule: platform_js_1.importModule }, options);
|
|
13
|
+
}
|
|
14
|
+
exports.createIO = createIO;
|
|
15
|
+
//# sourceMappingURL=createIO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIO.js","sourceRoot":"","sources":["../ts/createIO.ts"],"names":[],"mappings":";;;;;;AACA,8DAA+B;AAC/B,iEAAyD;AACzD,+CAA4C;AAGrC,KAAK,UAAU,QAAQ,CAAC,OAAyB;IACtD,uBAAuB;IACvB,OAAO,IAAA,uCAAgB,EAAC,EAAE,KAAK,EAAL,qBAAK,EAAE,QAAQ,EAAE,YAAY,EAAZ,0BAAY,EAAE,EAAE,OAAO,CAAC,CAAA;AACrE,CAAC;AAHD,4BAGC"}
|
package/cjs/errors.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MocktomataError } from '@mocktomata/framework';
|
|
2
|
+
import { ModuleError } from 'iso-error';
|
|
3
|
+
export declare class ServerNotAvailable extends MocktomataError {
|
|
4
|
+
url: string;
|
|
5
|
+
constructor(url: string, options?: ModuleError.Options);
|
|
6
|
+
}
|
|
7
|
+
export declare class ServerNotAvailableAtPortRange extends MocktomataError {
|
|
8
|
+
url: string;
|
|
9
|
+
constructor(url: string, start: number, end: number, options?: ModuleError.Options);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,qBAAa,kBAAmB,SAAQ,eAAe;IAClC,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO;CAG9D;AAGD,qBAAa,6BAA8B,SAAQ,eAAe;IAC7C,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO;CAG1F"}
|
package/cjs/errors.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServerNotAvailableAtPortRange = exports.ServerNotAvailable = void 0;
|
|
4
|
+
const framework_1 = require("@mocktomata/framework");
|
|
5
|
+
class ServerNotAvailable extends framework_1.MocktomataError {
|
|
6
|
+
constructor(url, options) {
|
|
7
|
+
super(`Unable to connect to server at ${url}`, options);
|
|
8
|
+
this.url = url;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ServerNotAvailable = ServerNotAvailable;
|
|
12
|
+
// istanbul ignore next
|
|
13
|
+
class ServerNotAvailableAtPortRange extends framework_1.MocktomataError {
|
|
14
|
+
constructor(url, start, end, options) {
|
|
15
|
+
super(`Unable to find mocktomata server at ${url} between port ${start} and ${end}`, options);
|
|
16
|
+
this.url = url;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ServerNotAvailableAtPortRange = ServerNotAvailableAtPortRange;
|
|
20
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;AAAA,qDAAuD;AAEvD,MAAa,kBAAmB,SAAQ,2BAAe;IACrD,YAAmB,GAAW,EAAE,OAA6B;QAC3D,KAAK,CAAC,kCAAkC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAA;QADtC,QAAG,GAAH,GAAG,CAAQ;IAE9B,CAAC;CACF;AAJD,gDAIC;AAED,uBAAuB;AACvB,MAAa,6BAA8B,SAAQ,2BAAe;IAChE,YAAmB,GAAW,EAAE,KAAa,EAAE,GAAW,EAAE,OAA6B;QACvF,KAAK,CAAC,uCAAuC,GAAG,iBAAiB,KAAK,QAAQ,GAAG,EAAE,EAAE,OAAO,CAAC,CAAA;QAD5E,QAAG,GAAH,GAAG,CAAQ;IAE9B,CAAC;CACF;AAJD,sEAIC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CreateIOOptions } from './types.js';
|
|
2
|
+
export declare type ServerInfo = {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
url: string;
|
|
6
|
+
plugins?: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare type Context = {
|
|
9
|
+
fetch: (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
10
|
+
location: {
|
|
11
|
+
protocol: string;
|
|
12
|
+
hostname: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare function getServerInfo(context: Context, options?: CreateIOOptions): Promise<ServerInfo>;
|
|
16
|
+
//# sourceMappingURL=getServerInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getServerInfo.d.ts","sourceRoot":"","sources":["../ts/getServerInfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IAEZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAA;AAED,oBAAY,OAAO,GAAG;IACpB,KAAK,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnE,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;CACF,CAAA;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAEpG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getServerInfo = void 0;
|
|
4
|
+
const buildUrl_js_1 = require("./buildUrl.js");
|
|
5
|
+
const errors_js_1 = require("./errors.js");
|
|
6
|
+
async function getServerInfo(context, options) {
|
|
7
|
+
return options ? tryGetServerInfo(context, options.url) : lookupServerInfo(context);
|
|
8
|
+
}
|
|
9
|
+
exports.getServerInfo = getServerInfo;
|
|
10
|
+
async function lookupServerInfo(context) {
|
|
11
|
+
const { location } = context;
|
|
12
|
+
const url = `${location.protocol}//${location.hostname}`;
|
|
13
|
+
if (location.hostname === 'localhost') {
|
|
14
|
+
return tryGetServerInfoAtPort(context, url, 3698, 3698, 3708);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return tryGetServerInfo(context, url);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function tryGetServerInfoAtPort(context, urlBase, port, start, end) {
|
|
21
|
+
if (port >= end) {
|
|
22
|
+
throw new errors_js_1.ServerNotAvailableAtPortRange(urlBase, start, end);
|
|
23
|
+
}
|
|
24
|
+
const url = `${urlBase}:${port}`;
|
|
25
|
+
try {
|
|
26
|
+
return await tryGetServerInfo(context, url);
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
return tryGetServerInfoAtPort(context, urlBase, port + 1, start, end);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function tryGetServerInfo({ fetch }, url) {
|
|
33
|
+
try {
|
|
34
|
+
const response = await fetch((0, buildUrl_js_1.buildUrl)(url, 'info'));
|
|
35
|
+
return response.json();
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
throw e.code === 'ECONNREFUSED' ? new errors_js_1.ServerNotAvailable(url) : e;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=getServerInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getServerInfo.js","sourceRoot":"","sources":["../ts/getServerInfo.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,2CAA+E;AAmBxE,KAAK,UAAU,aAAa,CAAC,OAAgB,EAAE,OAAyB;IAC7E,OAAO,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;AACrF,CAAC;AAFD,sCAEC;AAED,KAAK,UAAU,gBAAgB,CAAC,OAAgB;IAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAC5B,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,EAAE,CAAA;IACxD,IAAI,QAAQ,CAAC,QAAQ,KAAK,WAAW,EAAE;QACrC,OAAO,sBAAsB,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;KAC9D;SACI;QACH,OAAO,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;KACtC;AACH,CAAC;AAED,KAAK,UAAU,sBAAsB,CAAC,OAAgB,EAAE,OAAe,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IAC/G,IAAI,IAAI,IAAI,GAAG,EAAE;QACf,MAAM,IAAI,yCAA6B,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;KAC7D;IAED,MAAM,GAAG,GAAG,GAAG,OAAO,IAAI,IAAI,EAAE,CAAA;IAEhC,IAAI;QACF,OAAO,MAAM,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;KAC5C;IACD,OAAO,CAAM,EAAE;QACb,OAAO,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;KACtE;AACH,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,EAAE,KAAK,EAAW,EAAE,GAAW;IAC7D,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAA,sBAAQ,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;QACnD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;KACvB;IACD,OAAO,CAAM,EAAE;QACb,MAAM,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,8BAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAClE;AACH,CAAC"}
|
package/cjs/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./createIO.js"), exports);
|
|
18
|
+
__exportStar(require("./errors.js"), exports);
|
|
19
|
+
__exportStar(require("./types.js"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,8CAA2B;AAC3B,6CAA0B"}
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,eAAe,EAAE,MAAM,gBAEnD"}
|
package/cjs/platform.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.importModule = void 0;
|
|
27
|
+
function importModule(moduleSpecifier) {
|
|
28
|
+
return Promise.resolve().then(() => __importStar(require(moduleSpecifier)));
|
|
29
|
+
}
|
|
30
|
+
exports.importModule = importModule;
|
|
31
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,YAAY,CAAC,eAAuB;IAClD,yDAAc,eAAe,IAAC;AAChC,CAAC;AAFD,oCAEC"}
|
package/cjs/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare type Context = {
|
|
2
|
+
fetch: (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
location: {
|
|
4
|
+
protocol: string;
|
|
5
|
+
hostname: string;
|
|
6
|
+
};
|
|
7
|
+
importModule(moduleSpecifier: string): Promise<any>;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=types.internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.internal.d.ts","sourceRoot":"","sources":["../ts/types.internal.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO,GAAG;IACpB,KAAK,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnE,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAC;IACF,YAAY,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;CACpD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.internal.js","sourceRoot":"","sources":["../ts/types.internal.ts"],"names":[],"mappings":""}
|
package/cjs/types.js
ADDED
package/cjs/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mocktomata/io-remote",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.13",
|
|
4
4
|
"description": "mocktomata remote IO",
|
|
5
5
|
"homepage": "https://github.com/mocktomata/mocktomata/tree/main/packages/io-remote",
|
|
6
6
|
"bugs": {
|
|
@@ -15,17 +15,22 @@
|
|
|
15
15
|
"name": "Homa Wong",
|
|
16
16
|
"email": "homawong@gmail.com"
|
|
17
17
|
},
|
|
18
|
+
"sideEffects": false,
|
|
18
19
|
"type": "module",
|
|
19
20
|
"exports": {
|
|
20
|
-
"import": "./esm/index.js"
|
|
21
|
+
"import": "./esm/index.js",
|
|
22
|
+
"require": "./cjs/index.js"
|
|
21
23
|
},
|
|
22
24
|
"types": "./esm/index.d.ts",
|
|
23
25
|
"files": [
|
|
26
|
+
"cjs",
|
|
24
27
|
"esm",
|
|
25
|
-
"ts"
|
|
28
|
+
"ts",
|
|
29
|
+
"!**/*.spec.*",
|
|
30
|
+
"!**/test-util"
|
|
26
31
|
],
|
|
27
32
|
"dependencies": {
|
|
28
|
-
"@mocktomata/framework": "^7.0.0-beta.
|
|
33
|
+
"@mocktomata/framework": "^7.0.0-beta.13",
|
|
29
34
|
"cross-fetch": "^3.1.4",
|
|
30
35
|
"iso-error": "^4.4.0"
|
|
31
36
|
},
|
|
@@ -33,12 +38,14 @@
|
|
|
33
38
|
"@kayahr/jest-electron-runner": "^29.0.0",
|
|
34
39
|
"@mocktomata/plugin-fixture-dummy": "^1.1.10",
|
|
35
40
|
"assertron": "^10.0.0",
|
|
41
|
+
"cross-env": "^7.0.3",
|
|
36
42
|
"depcheck": "^1.4.3",
|
|
37
43
|
"jest": "^29.2.1",
|
|
38
44
|
"jest-validate": "29.2.1",
|
|
39
45
|
"jest-watch-suspend": "^1.1.2",
|
|
40
46
|
"jest-watch-toggle-config": "^2.0.1",
|
|
41
47
|
"jest-watch-typeahead": "^2.2.0",
|
|
48
|
+
"ncp": "^2.0.0",
|
|
42
49
|
"npm-run-all": "^4.1.5",
|
|
43
50
|
"rimraf": "^3.0.2",
|
|
44
51
|
"ts-jest": "^29.0.3",
|
|
@@ -48,7 +55,9 @@
|
|
|
48
55
|
"node": ">= 14.16"
|
|
49
56
|
},
|
|
50
57
|
"scripts": {
|
|
51
|
-
"build": "
|
|
58
|
+
"build": "run-p build:cjs build:esm",
|
|
59
|
+
"build:cjs": "tsc -p ./tsconfig.cjs.json && ncp package.cjs.json cjs/package.json",
|
|
60
|
+
"build:esm": "tsc",
|
|
52
61
|
"clean": "rimraf coverage esm lib libm tslib *.tsbuildinfo",
|
|
53
62
|
"coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest -c jest.electron.cjs --coverage --reporters=default",
|
|
54
63
|
"depcheck": "depcheck",
|
package/esm/createIO.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createIO.spec.d.ts","sourceRoot":"","sources":["../ts/createIO.spec.ts"],"names":[],"mappings":""}
|
package/esm/createIO.spec.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { SpecNotFound } from '@mocktomata/framework';
|
|
2
|
-
import { a } from 'assertron';
|
|
3
|
-
import { createIOInternal } from './createIO.internal.js';
|
|
4
|
-
import { createFakeServerFetch } from './test-util/index.js';
|
|
5
|
-
const location = {
|
|
6
|
-
hostname: 'localhost',
|
|
7
|
-
protocol: 'http:'
|
|
8
|
-
};
|
|
9
|
-
test('read not exist spec throws SpecNotFound', async () => {
|
|
10
|
-
const fetch = createFakeServerFetch();
|
|
11
|
-
const io = await createIOInternal({ fetch, location, importModule: () => Promise.resolve({}) });
|
|
12
|
-
await a.throws(io.readSpec('not exist', 'some-path/file'), SpecNotFound);
|
|
13
|
-
});
|
|
14
|
-
test('read existing spec', async () => {
|
|
15
|
-
const fetch = createFakeServerFetch();
|
|
16
|
-
const io = await createIOInternal({ fetch, location, importModule: () => Promise.resolve({}) });
|
|
17
|
-
const actual = await io.readSpec('exist', 'some-path/file');
|
|
18
|
-
expect(actual).toEqual({ actions: [] });
|
|
19
|
-
});
|
|
20
|
-
test('write spec', async () => {
|
|
21
|
-
const fetch = createFakeServerFetch();
|
|
22
|
-
const io = await createIOInternal({ fetch, location, importModule: () => Promise.resolve({}) });
|
|
23
|
-
const record = { refs: [], actions: [{ type: 'invoke', refId: '1', performer: 'user', thisArg: '0', payload: [], tick: 0 }] };
|
|
24
|
-
await io.writeSpec('new spec', 'some-path/file', record);
|
|
25
|
-
const spec = fetch.specs['new spec'];
|
|
26
|
-
expect(spec).toEqual(record);
|
|
27
|
-
});
|
|
28
|
-
describe('loadConfig()', () => {
|
|
29
|
-
test('returns installed plugin', async () => {
|
|
30
|
-
const fetch = createFakeServerFetch();
|
|
31
|
-
const io = await createIOInternal({ fetch, location, importModule: () => Promise.resolve({}) });
|
|
32
|
-
const list = await (await io.loadConfig()).plugins;
|
|
33
|
-
expect(list).toEqual(['@mocktomata/plugin-fixture-dummy']);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe('loadPlugin()', () => {
|
|
37
|
-
test('load existing plugin', async () => {
|
|
38
|
-
const fetch = createFakeServerFetch();
|
|
39
|
-
const dummy = { activate() { } };
|
|
40
|
-
const io = await createIOInternal({
|
|
41
|
-
fetch, location, importModule: (moduleSpecifier) => Promise.resolve(moduleSpecifier
|
|
42
|
-
? dummy : undefined)
|
|
43
|
-
});
|
|
44
|
-
const p = await io.loadPlugin(`@mocktomata/plugin-fixture-dummy`);
|
|
45
|
-
expect(p).toBe(dummy);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
// describe('loadConfig()', () => {
|
|
49
|
-
// test('load...', async () => {
|
|
50
|
-
// const io = await createClientIO()
|
|
51
|
-
// await io.loadConfig()
|
|
52
|
-
// })
|
|
53
|
-
// })
|
|
54
|
-
//# sourceMappingURL=createIO.spec.js.map
|
package/esm/createIO.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createIO.spec.js","sourceRoot":"","sources":["../ts/createIO.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAc,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,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AAM,EAAE,GAAG,MAAM,gBAAgB,CAAC;YAChC,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,CAC7B,eAAe,EACf,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe;gBAClC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;SACvB,CAAC,CAAA;QAEF,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAA;QAEjE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,mCAAmC;AACnC,kCAAkC;AAClC,wCAAwC;AACxC,4BAA4B;AAC5B,OAAO;AACP,KAAK"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getServerInfo.spec.d.ts","sourceRoot":"","sources":["../ts/getServerInfo.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { a } from 'assertron';
|
|
2
|
-
import { ServerNotAvailable, ServerNotAvailableAtPortRange } from './errors.js';
|
|
3
|
-
import { getServerInfo } from './getServerInfo.js';
|
|
4
|
-
test('will try to search for server', async () => {
|
|
5
|
-
const fetch = (() => {
|
|
6
|
-
let count = 0;
|
|
7
|
-
return () => {
|
|
8
|
-
if (count < 3) {
|
|
9
|
-
count++;
|
|
10
|
-
return Promise.reject({ code: 'some error' });
|
|
11
|
-
}
|
|
12
|
-
return Promise.resolve({
|
|
13
|
-
json() {
|
|
14
|
-
return Promise.resolve({
|
|
15
|
-
name: 'mocktomata',
|
|
16
|
-
url: 'http://localhost:3712',
|
|
17
|
-
plugins: ['@mocktomata/plugin-fixture-dummy']
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
})();
|
|
23
|
-
const info = await getServerInfo({
|
|
24
|
-
fetch, location: {
|
|
25
|
-
hostname: 'localhost',
|
|
26
|
-
protocol: 'http:'
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
a.satisfies(info, {
|
|
30
|
-
name: 'mocktomata',
|
|
31
|
-
url: 'http://localhost:3712',
|
|
32
|
-
plugins: ['@mocktomata/plugin-fixture-dummy']
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
test('throws when specific server is not available', async () => {
|
|
36
|
-
const fetch = () => Promise.reject({ code: 'ECONNREFUSED' });
|
|
37
|
-
await a.throws(getServerInfo({ fetch, location }, { url: 'http://localhost:4321' }), ServerNotAvailable);
|
|
38
|
-
});
|
|
39
|
-
test('throws when server is not up', async () => {
|
|
40
|
-
const fetch = () => Promise.reject({});
|
|
41
|
-
await a.throws(getServerInfo({
|
|
42
|
-
fetch, location: {
|
|
43
|
-
hostname: 'localhost',
|
|
44
|
-
protocol: 'http:'
|
|
45
|
-
}
|
|
46
|
-
}), ServerNotAvailableAtPortRange);
|
|
47
|
-
});
|
|
48
|
-
test('remote', async () => {
|
|
49
|
-
let actual;
|
|
50
|
-
const fetch = (url) => {
|
|
51
|
-
actual = url;
|
|
52
|
-
return Promise.resolve({
|
|
53
|
-
json() {
|
|
54
|
-
return Promise.resolve({
|
|
55
|
-
name: 'mocktomata',
|
|
56
|
-
url: 'http://mocktomata.com',
|
|
57
|
-
plugins: ['@mocktomata/plugin-fixture-dummy']
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
const location = {
|
|
63
|
-
protocol: 'https:',
|
|
64
|
-
hostname: 'mocktomata.com'
|
|
65
|
-
};
|
|
66
|
-
await getServerInfo({ fetch, location });
|
|
67
|
-
expect(actual).toBe('https://mocktomata.com/mocktomata/info');
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=getServerInfo.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getServerInfo.spec.js","sourceRoot":"","sources":["../ts/getServerInfo.spec.ts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@
|
|
|
1
|
-
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../ts/index.spec.ts"],"names":[],"mappings":""}
|
package/esm/index.spec.js
DELETED
package/esm/index.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../ts/index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAC9B,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;AAChC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFakeServerFetch.d.ts","sourceRoot":"","sources":["../../ts/test-util/createFakeServerFetch.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,WAUrB,WAAW,SAAS,WAAW;;;EAsC9C"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as f from 'cross-fetch';
|
|
2
|
-
export function createFakeServerFetch() {
|
|
3
|
-
const specs = {
|
|
4
|
-
'exist': { 'actions': [] }
|
|
5
|
-
};
|
|
6
|
-
const scenarios = {
|
|
7
|
-
'exist': { 'scenario': 'exist' }
|
|
8
|
-
};
|
|
9
|
-
return Object.assign(async (url, init) => {
|
|
10
|
-
const uri = extractUri(url);
|
|
11
|
-
if (uri === 'mocktomata/info') {
|
|
12
|
-
return new f.Response(JSON.stringify({
|
|
13
|
-
url: 'http://localhost:3999',
|
|
14
|
-
version: '1.0',
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
else if (uri === 'mocktomata/config') {
|
|
18
|
-
return new f.Response(JSON.stringify({
|
|
19
|
-
plugins: ['@mocktomata/plugin-fixture-dummy']
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
// istanbul ignore next
|
|
23
|
-
else if (uri.startsWith('mocktomata/specs/')) {
|
|
24
|
-
const id = /mocktomata\/specs\/(.*)/.exec(uri)[1];
|
|
25
|
-
const { specName } = JSON.parse(atob(id));
|
|
26
|
-
if (init && init.method === 'POST') {
|
|
27
|
-
specs[specName] = JSON.parse(init.body);
|
|
28
|
-
return new f.Response(undefined);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
if (specs[specName])
|
|
32
|
-
return new f.Response(JSON.stringify(specs[specName]));
|
|
33
|
-
else
|
|
34
|
-
return new f.Response(undefined, { status: 404 });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// istanbul ignore next
|
|
38
|
-
console.error(url);
|
|
39
|
-
// istanbul ignore next
|
|
40
|
-
return new f.Response(undefined, { status: 404 });
|
|
41
|
-
}, {
|
|
42
|
-
specs,
|
|
43
|
-
scenarios
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function extractUri(url) {
|
|
47
|
-
const match = /https?:\/\/\w*:\d+\/(.*)/.exec(url);
|
|
48
|
-
// istanbul ignore next
|
|
49
|
-
if (!match)
|
|
50
|
-
throw match;
|
|
51
|
-
return match[1];
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=createFakeServerFetch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFakeServerFetch.js","sourceRoot":"","sources":["../../ts/test-util/createFakeServerFetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,aAAa,CAAA;AAEhC,MAAM,UAAU,qBAAqB;IACnC,MAAM,KAAK,GAAwB;QACjC,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;KAC3B,CAAA;IAED,MAAM,SAAS,GAAwB;QACrC,OAAO,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE;KACjC,CAAA;IAED,OAAO,MAAM,CAAC,MAAM,CAClB,KAAK,EAAE,GAAgB,EAAE,IAAkB,EAAE,EAAE;QAC7C,MAAM,GAAG,GAAG,UAAU,CAAC,GAAa,CAAC,CAAA;QACrC,IAAI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AE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IACnD,CAAC,EACD;QACE,KAAK;QACL,SAAS;KACV,CACF,CAAA;AACH,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAClD,uBAAuB;IACvB,IAAI,CAAC,KAAK;QAAE,MAAM,KAAK,CAAA;IACvB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC"}
|
package/esm/test-util/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/test-util/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
package/esm/test-util/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/test-util/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
package/ts/createIO.spec.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { SpecNotFound, SpecRecord } from '@mocktomata/framework'
|
|
2
|
-
import { a } from 'assertron'
|
|
3
|
-
import { createIOInternal } from './createIO.internal.js'
|
|
4
|
-
import { createFakeServerFetch } from './test-util/index.js'
|
|
5
|
-
|
|
6
|
-
const location = {
|
|
7
|
-
hostname: 'localhost',
|
|
8
|
-
protocol: 'http:'
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
test('read not exist spec throws SpecNotFound', async () => {
|
|
12
|
-
const fetch = createFakeServerFetch()
|
|
13
|
-
const io = await createIOInternal({ fetch, location, importModule: () => Promise.resolve({}) })
|
|
14
|
-
|
|
15
|
-
await a.throws(io.readSpec('not exist', 'some-path/file'), SpecNotFound)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('read existing spec', async () => {
|
|
19
|
-
const fetch = createFakeServerFetch()
|
|
20
|
-
const io = await createIOInternal({ fetch, location, importModule: () => Promise.resolve({}) })
|
|
21
|
-
|
|
22
|
-
const actual = await io.readSpec('exist', 'some-path/file')
|
|
23
|
-
|
|
24
|
-
expect(actual).toEqual({ actions: [] })
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test('write spec', async () => {
|
|
28
|
-
const fetch = createFakeServerFetch()
|
|
29
|
-
const io = await createIOInternal({ fetch, location, importModule: () => Promise.resolve({}) })
|
|
30
|
-
|
|
31
|
-
const record: SpecRecord = { refs: [], actions: [{ type: 'invoke', refId: '1', performer: 'user', thisArg: '0', payload: [], tick: 0 }] }
|
|
32
|
-
await io.writeSpec('new spec', 'some-path/file', record)
|
|
33
|
-
|
|
34
|
-
const spec = fetch.specs['new spec']
|
|
35
|
-
expect(spec).toEqual(record)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
describe('loadConfig()', () => {
|
|
39
|
-
test('returns installed plugin', async () => {
|
|
40
|
-
const fetch = createFakeServerFetch()
|
|
41
|
-
const io = await createIOInternal({ fetch, location, importModule: () => Promise.resolve({}) })
|
|
42
|
-
|
|
43
|
-
const list = await (await io.loadConfig()).plugins
|
|
44
|
-
expect(list).toEqual(['@mocktomata/plugin-fixture-dummy'])
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
describe('loadPlugin()', () => {
|
|
49
|
-
test('load existing plugin', async () => {
|
|
50
|
-
const fetch = createFakeServerFetch()
|
|
51
|
-
const dummy = { activate() { } }
|
|
52
|
-
const io = await createIOInternal({
|
|
53
|
-
fetch, location, importModule: (
|
|
54
|
-
moduleSpecifier
|
|
55
|
-
) => Promise.resolve(moduleSpecifier
|
|
56
|
-
? dummy : undefined)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
const p = await io.loadPlugin(`@mocktomata/plugin-fixture-dummy`)
|
|
60
|
-
|
|
61
|
-
expect(p).toBe(dummy)
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
// describe('loadConfig()', () => {
|
|
66
|
-
// test('load...', async () => {
|
|
67
|
-
// const io = await createClientIO()
|
|
68
|
-
// await io.loadConfig()
|
|
69
|
-
// })
|
|
70
|
-
// })
|
package/ts/getServerInfo.spec.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { a } from 'assertron'
|
|
2
|
-
import { ServerNotAvailable, ServerNotAvailableAtPortRange } from './errors.js'
|
|
3
|
-
import { getServerInfo } from './getServerInfo.js'
|
|
4
|
-
|
|
5
|
-
test('will try to search for server', async () => {
|
|
6
|
-
const fetch = (() => {
|
|
7
|
-
let count = 0
|
|
8
|
-
return () => {
|
|
9
|
-
if (count < 3) {
|
|
10
|
-
count++
|
|
11
|
-
return Promise.reject({ code: 'some error' })
|
|
12
|
-
}
|
|
13
|
-
return Promise.resolve({
|
|
14
|
-
json() {
|
|
15
|
-
return Promise.resolve({
|
|
16
|
-
name: 'mocktomata',
|
|
17
|
-
url: 'http://localhost:3712',
|
|
18
|
-
plugins: ['@mocktomata/plugin-fixture-dummy']
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
} as any)
|
|
22
|
-
}
|
|
23
|
-
})()
|
|
24
|
-
const info = await getServerInfo({
|
|
25
|
-
fetch, location: {
|
|
26
|
-
hostname: 'localhost',
|
|
27
|
-
protocol: 'http:'
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
a.satisfies(info, {
|
|
31
|
-
name: 'mocktomata',
|
|
32
|
-
url: 'http://localhost:3712',
|
|
33
|
-
plugins: ['@mocktomata/plugin-fixture-dummy']
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
test('throws when specific server is not available', async () => {
|
|
38
|
-
const fetch = () => Promise.reject({ code: 'ECONNREFUSED' })
|
|
39
|
-
|
|
40
|
-
await a.throws(getServerInfo({ fetch, location }, { url: 'http://localhost:4321' }), ServerNotAvailable)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('throws when server is not up', async () => {
|
|
44
|
-
const fetch = () => Promise.reject({})
|
|
45
|
-
await a.throws(getServerInfo({
|
|
46
|
-
fetch, location: {
|
|
47
|
-
hostname: 'localhost',
|
|
48
|
-
protocol: 'http:'
|
|
49
|
-
}
|
|
50
|
-
}), ServerNotAvailableAtPortRange)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('remote', async () => {
|
|
54
|
-
let actual: RequestInfo
|
|
55
|
-
const fetch = (url: RequestInfo) => {
|
|
56
|
-
actual = url
|
|
57
|
-
return Promise.resolve({
|
|
58
|
-
json() {
|
|
59
|
-
return Promise.resolve({
|
|
60
|
-
name: 'mocktomata',
|
|
61
|
-
url: 'http://mocktomata.com',
|
|
62
|
-
plugins: ['@mocktomata/plugin-fixture-dummy']
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
} as any)
|
|
66
|
-
}
|
|
67
|
-
const location = {
|
|
68
|
-
protocol: 'https:',
|
|
69
|
-
hostname: 'mocktomata.com'
|
|
70
|
-
}
|
|
71
|
-
await getServerInfo({ fetch, location })
|
|
72
|
-
expect(actual!).toBe('https://mocktomata.com/mocktomata/info')
|
|
73
|
-
})
|
package/ts/index.spec.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as f from 'cross-fetch'
|
|
2
|
-
|
|
3
|
-
export function createFakeServerFetch() {
|
|
4
|
-
const specs: Record<string, any> = {
|
|
5
|
-
'exist': { 'actions': [] }
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const scenarios: Record<string, any> = {
|
|
9
|
-
'exist': { 'scenario': 'exist' }
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return Object.assign(
|
|
13
|
-
async (url: RequestInfo, init?: RequestInit) => {
|
|
14
|
-
const uri = extractUri(url as string)
|
|
15
|
-
if (uri === 'mocktomata/info') {
|
|
16
|
-
return new f.Response(JSON.stringify({
|
|
17
|
-
url: 'http://localhost:3999',
|
|
18
|
-
version: '1.0',
|
|
19
|
-
}))
|
|
20
|
-
}
|
|
21
|
-
else if (uri === 'mocktomata/config') {
|
|
22
|
-
return new f.Response(JSON.stringify({
|
|
23
|
-
plugins: ['@mocktomata/plugin-fixture-dummy']
|
|
24
|
-
}))
|
|
25
|
-
}
|
|
26
|
-
// istanbul ignore next
|
|
27
|
-
else if (uri.startsWith('mocktomata/specs/')) {
|
|
28
|
-
const id = /mocktomata\/specs\/(.*)/.exec(uri)![1]
|
|
29
|
-
const { specName } = JSON.parse(atob(id))
|
|
30
|
-
if (init && init.method === 'POST') {
|
|
31
|
-
specs[specName] = JSON.parse(init.body as string)
|
|
32
|
-
return new f.Response(undefined)
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
if (specs[specName])
|
|
36
|
-
return new f.Response(JSON.stringify(specs[specName]))
|
|
37
|
-
else
|
|
38
|
-
return new f.Response(undefined, { status: 404 })
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// istanbul ignore next
|
|
42
|
-
console.error(url)
|
|
43
|
-
// istanbul ignore next
|
|
44
|
-
return new f.Response(undefined, { status: 404 })
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
specs,
|
|
48
|
-
scenarios
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function extractUri(url: string) {
|
|
54
|
-
const match = /https?:\/\/\w*:\d+\/(.*)/.exec(url)
|
|
55
|
-
// istanbul ignore next
|
|
56
|
-
if (!match) throw match
|
|
57
|
-
return match[1]
|
|
58
|
-
}
|
package/ts/test-util/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './createFakeServerFetch.js'
|