@mocktomata/io-remote 7.1.1 → 8.0.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/cjs/buildUrl.js.map +1 -1
- package/cjs/createIO.internal.d.ts +1 -1
- package/cjs/createIO.internal.d.ts.map +1 -1
- package/cjs/createIO.internal.js +7 -4
- package/cjs/createIO.internal.js.map +1 -1
- package/cjs/createIO.js.map +1 -1
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js.map +1 -1
- package/cjs/getServerInfo.d.ts +2 -2
- package/cjs/getServerInfo.d.ts.map +1 -1
- package/cjs/getServerInfo.js.map +1 -1
- package/cjs/platform.js.map +1 -1
- package/cjs/types.d.ts +5 -4
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.internal.d.ts.map +1 -1
- package/esm/buildUrl.js.map +1 -1
- package/esm/createIO.internal.d.ts +1 -1
- package/esm/createIO.internal.d.ts.map +1 -1
- package/esm/createIO.internal.js +8 -5
- package/esm/createIO.internal.js.map +1 -1
- package/esm/createIO.js.map +1 -1
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js.map +1 -1
- package/esm/getServerInfo.d.ts +2 -2
- package/esm/getServerInfo.d.ts.map +1 -1
- package/esm/getServerInfo.js.map +1 -1
- package/esm/platform.js.map +1 -1
- package/esm/types.d.ts +5 -4
- package/esm/types.d.ts.map +1 -1
- package/esm/types.internal.d.ts.map +1 -1
- package/package.json +13 -11
- package/ts/buildUrl.ts +1 -1
- package/ts/createIO.internal.ts +32 -29
- package/ts/createIO.ts +2 -2
- package/ts/errors.ts +6 -6
- package/ts/getServerInfo.ts +44 -41
- package/ts/platform.ts +1 -1
- package/ts/types.internal.ts +6 -7
- package/ts/types.ts +9 -6
package/cjs/buildUrl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUrl.js","sourceRoot":"","sources":["../ts/buildUrl.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAC,OAAe,EAAE,IAAY;
|
|
1
|
+
{"version":3,"file":"buildUrl.js","sourceRoot":"","sources":["../ts/buildUrl.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAC,OAAe,EAAE,IAAY;IACrD,OAAO,GAAG,OAAO,eAAe,IAAI,EAAE,CAAA;AACvC,CAAC;AAFD,4BAEC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mocktomata } from '@mocktomata/framework';
|
|
1
|
+
import { type Mocktomata } from '@mocktomata/framework';
|
|
2
2
|
import type { Context } from './types.internal.js';
|
|
3
3
|
import type { CreateIOOptions } from './types.js';
|
|
4
4
|
export declare function createIOInternal(ctx: Context, options?: CreateIOOptions): Promise<Mocktomata.IO>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createIO.internal.d.ts","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createIO.internal.d.ts","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,UAAU,EAAoC,MAAM,uBAAuB,CAAA;AAG7G,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,CAgCtG"}
|
package/cjs/createIO.internal.js
CHANGED
|
@@ -17,7 +17,7 @@ async function createIOInternal(ctx, options) {
|
|
|
17
17
|
return ctx.importModule(name);
|
|
18
18
|
},
|
|
19
19
|
async readSpec(specName, specRelativePath) {
|
|
20
|
-
const id = btoa(
|
|
20
|
+
const id = btoa(framework_1.json.stringify({ specName, specRelativePath }));
|
|
21
21
|
const response = await ctx.fetch((0, buildUrl_js_1.buildUrl)(info.url, `specs/${id}`));
|
|
22
22
|
if (response.status === 404) {
|
|
23
23
|
throw new framework_1.SpecNotFound(id, specRelativePath);
|
|
@@ -25,13 +25,16 @@ async function createIOInternal(ctx, options) {
|
|
|
25
25
|
return response.json();
|
|
26
26
|
},
|
|
27
27
|
async writeSpec(specName, specRelativePath, record) {
|
|
28
|
-
const id = btoa(
|
|
29
|
-
const response = await ctx.fetch((0, buildUrl_js_1.buildUrl)(info.url, `specs/${id}`), {
|
|
28
|
+
const id = btoa(framework_1.json.stringify({ specName, specRelativePath }));
|
|
29
|
+
const response = await ctx.fetch((0, buildUrl_js_1.buildUrl)(info.url, `specs/${id}`), {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: framework_1.json.stringify(record)
|
|
32
|
+
});
|
|
30
33
|
// istanbul ignore next
|
|
31
34
|
if (!response.ok) {
|
|
32
35
|
throw new Error(`failed to write spec: ${response.statusText}`);
|
|
33
36
|
}
|
|
34
|
-
}
|
|
37
|
+
}
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
exports.createIOInternal = createIOInternal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createIO.internal.js","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"createIO.internal.js","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":";;;AAAA,qDAA6G;AAC7G,+CAAwC;AACxC,yDAAkD;AAI3C,KAAK,UAAU,gBAAgB,CAAC,GAAY,EAAE,OAAyB;IAC7E,MAAM,IAAI,GAAG,MAAM,IAAA,gCAAa,EAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAC9C,OAAO;QACN,KAAK,CAAC,UAAU;YACf,4BAA4B;YAC5B,MAAM,GAAG,GAAG,IAAA,sBAAQ,EAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;YACxC,MAAM,QAAQ,GAAG,MAAM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,CAAC;KACD,CAAA;AACF,CAAC;AAhCD,4CAgCC"}
|
package/cjs/createIO.js.map
CHANGED
|
@@ -1 +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;
|
|
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;IACvD,uBAAuB;IACvB,OAAO,IAAA,uCAAgB,EAAC,EAAE,KAAK,EAAL,qBAAK,EAAE,QAAQ,EAAE,YAAY,EAAZ,0BAAY,EAAE,EAAE,OAAO,CAAC,CAAA;AACpE,CAAC;AAHD,4BAGC"}
|
package/cjs/errors.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;IACnC,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO;CAG7D;AAGD,qBAAa,6BAA8B,SAAQ,eAAe;IAC9C,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO;CAGzF"}
|
package/cjs/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;AAAA,qDAAuD;AAEvD,MAAa,kBAAmB,SAAQ,2BAAe;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;AAAA,qDAAuD;AAEvD,MAAa,kBAAmB,SAAQ,2BAAe;IACtD,YAAmB,GAAW,EAAE,OAA6B;QAC5D,KAAK,CAAC,kCAAkC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAA;QADrC,QAAG,GAAH,GAAG,CAAQ;IAE9B,CAAC;CACD;AAJD,gDAIC;AAED,uBAAuB;AACvB,MAAa,6BAA8B,SAAQ,2BAAe;IACjE,YAAmB,GAAW,EAAE,KAAa,EAAE,GAAW,EAAE,OAA6B;QACxF,KAAK,CAAC,uCAAuC,GAAG,iBAAiB,KAAK,QAAQ,GAAG,EAAE,EAAE,OAAO,CAAC,CAAA;QAD3E,QAAG,GAAH,GAAG,CAAQ;IAE9B,CAAC;CACD;AAJD,sEAIC"}
|
package/cjs/getServerInfo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceOptions } from './types.js';
|
|
2
2
|
export type ServerInfo = {
|
|
3
3
|
name: string;
|
|
4
4
|
version: string;
|
|
@@ -12,5 +12,5 @@ export type Context = {
|
|
|
12
12
|
hostname: string;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export declare function getServerInfo(context: Context, options?:
|
|
15
|
+
export declare function getServerInfo(context: Context, options?: ServiceOptions): Promise<ServerInfo>;
|
|
16
16
|
//# sourceMappingURL=getServerInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerInfo.d.ts","sourceRoot":"","sources":["../ts/getServerInfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"getServerInfo.d.ts","sourceRoot":"","sources":["../ts/getServerInfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,MAAM,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IAEX,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAClE,QAAQ,EAAE;QACT,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;KAChB,CAAA;CACD,CAAA;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAEnG"}
|
package/cjs/getServerInfo.js.map
CHANGED
|
@@ -1 +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,
|
|
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,OAAwB;IAC7E,OAAO,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,C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AE;QAChB,MAAM,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,8BAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KACjE;AACF,CAAC"}
|
package/cjs/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,YAAY,CAAC,eAAuB;
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,YAAY,CAAC,eAAuB;IACnD,YAAc,eAAe,0DAAC;AAC/B,CAAC;AAFD,oCAEC"}
|
package/cjs/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Log } from '@mocktomata/framework';
|
|
2
|
+
export type ServiceOptions = {
|
|
2
3
|
/**
|
|
3
|
-
* URL to the
|
|
4
|
-
* This is used by browser tests to connect to the komondor server.
|
|
4
|
+
* URL to the mocktomata service.
|
|
5
5
|
*/
|
|
6
6
|
url: string;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export type CreateIOOptions = ServiceOptions & Log.Context;
|
|
8
9
|
//# sourceMappingURL=types.d.ts.map
|
package/cjs/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAEhD,MAAM,MAAM,cAAc,GAAG;IAC5B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACX,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,GAAG,CAAC,OAAO,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.internal.d.ts","sourceRoot":"","sources":["../ts/types.internal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;
|
|
1
|
+
{"version":3,"file":"types.internal.d.ts","sourceRoot":"","sources":["../ts/types.internal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAClE,QAAQ,EAAE;QACT,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,YAAY,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;CACnD,CAAA"}
|
package/esm/buildUrl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUrl.js","sourceRoot":"","sources":["../ts/buildUrl.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAY;
|
|
1
|
+
{"version":3,"file":"buildUrl.js","sourceRoot":"","sources":["../ts/buildUrl.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAY;IACrD,OAAO,GAAG,OAAO,eAAe,IAAI,EAAE,CAAA;AACvC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mocktomata } from '@mocktomata/framework';
|
|
1
|
+
import { type Mocktomata } from '@mocktomata/framework';
|
|
2
2
|
import type { Context } from './types.internal.js';
|
|
3
3
|
import type { CreateIOOptions } from './types.js';
|
|
4
4
|
export declare function createIOInternal(ctx: Context, options?: CreateIOOptions): Promise<Mocktomata.IO>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createIO.internal.d.ts","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createIO.internal.d.ts","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,UAAU,EAAoC,MAAM,uBAAuB,CAAA;AAG7G,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,CAgCtG"}
|
package/esm/createIO.internal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SpecNotFound } from '@mocktomata/framework';
|
|
1
|
+
import { json, SpecNotFound } from '@mocktomata/framework';
|
|
2
2
|
import { buildUrl } from './buildUrl.js';
|
|
3
3
|
import { getServerInfo } from './getServerInfo.js';
|
|
4
4
|
export async function createIOInternal(ctx, options) {
|
|
@@ -14,7 +14,7 @@ export async function createIOInternal(ctx, options) {
|
|
|
14
14
|
return ctx.importModule(name);
|
|
15
15
|
},
|
|
16
16
|
async readSpec(specName, specRelativePath) {
|
|
17
|
-
const id = btoa(
|
|
17
|
+
const id = btoa(json.stringify({ specName, specRelativePath }));
|
|
18
18
|
const response = await ctx.fetch(buildUrl(info.url, `specs/${id}`));
|
|
19
19
|
if (response.status === 404) {
|
|
20
20
|
throw new SpecNotFound(id, specRelativePath);
|
|
@@ -22,13 +22,16 @@ export async function createIOInternal(ctx, options) {
|
|
|
22
22
|
return response.json();
|
|
23
23
|
},
|
|
24
24
|
async writeSpec(specName, specRelativePath, record) {
|
|
25
|
-
const id = btoa(
|
|
26
|
-
const response = await ctx.fetch(buildUrl(info.url, `specs/${id}`), {
|
|
25
|
+
const id = btoa(json.stringify({ specName, specRelativePath }));
|
|
26
|
+
const response = await ctx.fetch(buildUrl(info.url, `specs/${id}`), {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body: json.stringify(record)
|
|
29
|
+
});
|
|
27
30
|
// istanbul ignore next
|
|
28
31
|
if (!response.ok) {
|
|
29
32
|
throw new Error(`failed to write spec: ${response.statusText}`);
|
|
30
33
|
}
|
|
31
|
-
}
|
|
34
|
+
}
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
37
|
//# sourceMappingURL=createIO.internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createIO.internal.js","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createIO.internal.js","sourceRoot":"","sources":["../ts/createIO.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAC7G,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIlD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAAY,EAAE,OAAyB;IAC7E,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAC9C,OAAO;QACN,KAAK,CAAC,UAAU;YACf,4BAA4B;YAC5B,MAAM,GAAG,GAAG,QAAQ,CAAC,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,CAAA;QACvB,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,IAAY;YAC5B,OAAO,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,Q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AAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAG5C,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAyB;
|
|
1
|
+
{"version":3,"file":"createIO.js","sourceRoot":"","sources":["../ts/createIO.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,aAAa,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAG5C,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAyB;IACvD,uBAAuB;IACvB,OAAO,gBAAgB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC,CAAA;AACpE,CAAC"}
|
package/esm/errors.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;IACnC,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO;CAG7D;AAGD,qBAAa,6BAA8B,SAAQ,eAAe;IAC9C,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO;CAGzF"}
|
package/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,OAAO,kBAAmB,SAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACtD,YAAmB,GAAW,EAAE,OAA6B;QAC5D,KAAK,CAAC,kCAAkC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAA;QADrC,QAAG,GAAH,GAAG,CAAQ;IAE9B,CAAC;CACD;AAED,uBAAuB;AACvB,MAAM,OAAO,6BAA8B,SAAQ,eAAe;IACjE,YAAmB,GAAW,EAAE,KAAa,EAAE,GAAW,EAAE,OAA6B;QACxF,KAAK,CAAC,uCAAuC,GAAG,iBAAiB,KAAK,QAAQ,GAAG,EAAE,EAAE,OAAO,CAAC,CAAA;QAD3E,QAAG,GAAH,GAAG,CAAQ;IAE9B,CAAC;CACD"}
|
package/esm/getServerInfo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceOptions } from './types.js';
|
|
2
2
|
export type ServerInfo = {
|
|
3
3
|
name: string;
|
|
4
4
|
version: string;
|
|
@@ -12,5 +12,5 @@ export type Context = {
|
|
|
12
12
|
hostname: string;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export declare function getServerInfo(context: Context, options?:
|
|
15
|
+
export declare function getServerInfo(context: Context, options?: ServiceOptions): Promise<ServerInfo>;
|
|
16
16
|
//# sourceMappingURL=getServerInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerInfo.d.ts","sourceRoot":"","sources":["../ts/getServerInfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"getServerInfo.d.ts","sourceRoot":"","sources":["../ts/getServerInfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,MAAM,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IAEX,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAClE,QAAQ,EAAE;QACT,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;KAChB,CAAA;CACD,CAAA;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAEnG"}
|
package/esm/getServerInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerInfo.js","sourceRoot":"","sources":["../ts/getServerInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAmB/E,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"getServerInfo.js","sourceRoot":"","sources":["../ts/getServerInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAmB/E,MAA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AG,EAAE,MAAM,CAAC,CAAC,CAAA;QACnD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;KACtB;IAAC,OAAO,CAAM,EAAE;QAChB,MAAM,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KACjE;AACF,CAAC"}
|
package/esm/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,eAAuB;
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,eAAuB;IACnD,OAAO,MAAM,CAAC,eAAe,CAAC,CAAA;AAC/B,CAAC"}
|
package/esm/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Log } from '@mocktomata/framework';
|
|
2
|
+
export type ServiceOptions = {
|
|
2
3
|
/**
|
|
3
|
-
* URL to the
|
|
4
|
-
* This is used by browser tests to connect to the komondor server.
|
|
4
|
+
* URL to the mocktomata service.
|
|
5
5
|
*/
|
|
6
6
|
url: string;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export type CreateIOOptions = ServiceOptions & Log.Context;
|
|
8
9
|
//# sourceMappingURL=types.d.ts.map
|
package/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAEhD,MAAM,MAAM,cAAc,GAAG;IAC5B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACX,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,GAAG,CAAC,OAAO,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.internal.d.ts","sourceRoot":"","sources":["../ts/types.internal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;
|
|
1
|
+
{"version":3,"file":"types.internal.d.ts","sourceRoot":"","sources":["../ts/types.internal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAClE,QAAQ,EAAE;QACT,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,YAAY,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;CACnD,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mocktomata/io-remote",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "mocktomata remote IO",
|
|
5
5
|
"homepage": "https://github.com/mocktomata/mocktomata/tree/main/packages/io-remote",
|
|
6
6
|
"bugs": {
|
|
@@ -19,32 +19,34 @@
|
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"type": "module",
|
|
21
21
|
"exports": {
|
|
22
|
+
"types": "./esm/index.d.ts",
|
|
22
23
|
"import": "./esm/index.js",
|
|
23
|
-
"
|
|
24
|
+
"default": "./cjs/index.js"
|
|
24
25
|
},
|
|
26
|
+
"main": "./cjs/index.js",
|
|
25
27
|
"types": "./esm/index.d.ts",
|
|
26
28
|
"files": [
|
|
27
29
|
"cjs",
|
|
28
30
|
"esm",
|
|
29
31
|
"ts",
|
|
30
|
-
"!**/*.spec.*",
|
|
32
|
+
"!**/*.{spec,test,unit,accept,integrate,system}.*",
|
|
31
33
|
"!**/test-util"
|
|
32
34
|
],
|
|
33
35
|
"dependencies": {
|
|
34
36
|
"cross-fetch": "^3.1.4",
|
|
35
|
-
"iso-error": "^
|
|
36
|
-
"@mocktomata/framework": "^
|
|
37
|
+
"iso-error": "^6.0.0",
|
|
38
|
+
"@mocktomata/framework": "^8.0.0"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@kayahr/jest-electron-runner": "^29.0.0",
|
|
40
42
|
"assertron": "^11.0.0",
|
|
41
43
|
"cross-env": "^7.0.3",
|
|
42
44
|
"depcheck": "^1.4.3",
|
|
43
|
-
"jest": "^29.2
|
|
44
|
-
"jest-validate": "29.
|
|
45
|
+
"jest": "^29.4.2",
|
|
46
|
+
"jest-validate": "29.4.2",
|
|
45
47
|
"jest-watch-suspend": "^1.1.2",
|
|
46
48
|
"jest-watch-toggle-config-2": "^2.1.0",
|
|
47
|
-
"jest-watch-typeahead": "^2.2.
|
|
49
|
+
"jest-watch-typeahead": "^2.2.2",
|
|
48
50
|
"ncp": "^2.0.0",
|
|
49
51
|
"npm-run-all": "^4.1.5",
|
|
50
52
|
"rimraf": "^3.0.2",
|
|
@@ -60,12 +62,12 @@
|
|
|
60
62
|
"build:cjs": "tsc -p ./tsconfig.cjs.json && ncp package.cjs.json cjs/package.json",
|
|
61
63
|
"build:esm": "tsc",
|
|
62
64
|
"clean": "rimraf coverage esm lib libm tslib *.tsbuildinfo",
|
|
63
|
-
"coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest -c jest.electron.
|
|
65
|
+
"coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest -c jest.electron.mjs --coverage --reporters=default",
|
|
64
66
|
"depcheck": "depcheck",
|
|
65
67
|
"lint": "cross-env TIMING=1 eslint --ext=ts,js,cjs,mjs .",
|
|
66
68
|
"nuke": "pnpm run clean && rimraf node_modules",
|
|
67
|
-
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest -c jest.electron.
|
|
68
|
-
"test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest -c jest.electron.
|
|
69
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest -c jest.electron.mjs --reporters=default",
|
|
70
|
+
"test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest -c jest.electron.mjs --watch",
|
|
69
71
|
"verify": "npm-run-all -p lint build coverage -p depcheck",
|
|
70
72
|
"watch": "pnpm run test:watch"
|
|
71
73
|
}
|
package/ts/buildUrl.ts
CHANGED
package/ts/createIO.internal.ts
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { json, SpecNotFound, type Mocktomata, type SpecPlugin, type SpecRecord } from '@mocktomata/framework'
|
|
2
2
|
import { buildUrl } from './buildUrl.js'
|
|
3
3
|
import { getServerInfo } from './getServerInfo.js'
|
|
4
4
|
import type { Context } from './types.internal.js'
|
|
5
5
|
import type { CreateIOOptions } from './types.js'
|
|
6
6
|
|
|
7
7
|
export async function createIOInternal(ctx: Context, options?: CreateIOOptions): Promise<Mocktomata.IO> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
8
|
+
const info = await getServerInfo(ctx, options)
|
|
9
|
+
return {
|
|
10
|
+
async loadConfig() {
|
|
11
|
+
// @TODO add browser config?
|
|
12
|
+
const url = buildUrl(info.url, `config`)
|
|
13
|
+
const response = await ctx.fetch(url)
|
|
14
|
+
return response.json()
|
|
15
|
+
},
|
|
16
|
+
async loadPlugin(name: string): Promise<SpecPlugin.Module> {
|
|
17
|
+
return ctx.importModule(name)
|
|
18
|
+
},
|
|
19
|
+
async readSpec(specName: string, specRelativePath: string): Promise<SpecRecord> {
|
|
20
|
+
const id = btoa(json.stringify({ specName, specRelativePath }))
|
|
21
|
+
const response = await ctx.fetch(buildUrl(info.url, `specs/${id}`))
|
|
22
|
+
if (response.status === 404) {
|
|
23
|
+
throw new 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(buildUrl(info.url, `specs/${id}`), {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: json.stringify(record)
|
|
32
|
+
})
|
|
33
|
+
// istanbul ignore next
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error(`failed to write spec: ${response.statusText}`)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
36
39
|
}
|
package/ts/createIO.ts
CHANGED
|
@@ -5,6 +5,6 @@ import { importModule } from './platform.js'
|
|
|
5
5
|
import type { CreateIOOptions } from './types.js'
|
|
6
6
|
|
|
7
7
|
export async function createIO(options?: CreateIOOptions): Promise<Mocktomata.IO> {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// istanbul ignore next
|
|
9
|
+
return createIOInternal({ fetch, location, importModule }, options)
|
|
10
10
|
}
|
package/ts/errors.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { MocktomataError } from '@mocktomata/framework'
|
|
2
2
|
import { ModuleError } from 'iso-error'
|
|
3
3
|
export class ServerNotAvailable extends MocktomataError {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
constructor(public url: string, options?: ModuleError.Options) {
|
|
5
|
+
super(`Unable to connect to server at ${url}`, options)
|
|
6
|
+
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
// istanbul ignore next
|
|
10
10
|
export class ServerNotAvailableAtPortRange extends MocktomataError {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
constructor(public url: string, start: number, end: number, options?: ModuleError.Options) {
|
|
12
|
+
super(`Unable to find mocktomata server at ${url} between port ${start} and ${end}`, options)
|
|
13
|
+
}
|
|
14
14
|
}
|
package/ts/getServerInfo.ts
CHANGED
|
@@ -1,59 +1,62 @@
|
|
|
1
1
|
import { buildUrl } from './buildUrl.js'
|
|
2
2
|
import { ServerNotAvailable, ServerNotAvailableAtPortRange } from './errors.js'
|
|
3
|
-
import type {
|
|
3
|
+
import type { ServiceOptions } from './types.js'
|
|
4
4
|
|
|
5
5
|
export type ServerInfo = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
name: string
|
|
7
|
+
version: string
|
|
8
|
+
url: string
|
|
9
|
+
// TODO: server not returning plugins
|
|
10
|
+
plugins?: string[]
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export type Context = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
fetch: (url: RequestInfo, init?: RequestInit) => Promise<Response>
|
|
15
|
+
location: {
|
|
16
|
+
protocol: string
|
|
17
|
+
hostname: string
|
|
18
|
+
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export async function getServerInfo(context: Context, options?:
|
|
22
|
-
|
|
21
|
+
export async function getServerInfo(context: Context, options?: ServiceOptions): Promise<ServerInfo> {
|
|
22
|
+
return options ? tryGetServerInfo(context, options.url) : lookupServerInfo(context)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async function lookupServerInfo(context: Context) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
26
|
+
const { location } = context
|
|
27
|
+
const url = `${location.protocol}//${location.hostname}`
|
|
28
|
+
if (location.hostname === 'localhost') {
|
|
29
|
+
return tryGetServerInfoAtPort(context, url, 3698, 3698, 3708)
|
|
30
|
+
} else {
|
|
31
|
+
return tryGetServerInfo(context, url)
|
|
32
|
+
}
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
async function tryGetServerInfoAtPort(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
async function tryGetServerInfoAtPort(
|
|
36
|
+
context: Context,
|
|
37
|
+
urlBase: string,
|
|
38
|
+
port: number,
|
|
39
|
+
start: number,
|
|
40
|
+
end: number
|
|
41
|
+
): Promise<ServerInfo> {
|
|
42
|
+
if (port >= end) {
|
|
43
|
+
throw new ServerNotAvailableAtPortRange(urlBase, start, end)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const url = `${urlBase}:${port}`
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
return await tryGetServerInfo(context, url)
|
|
50
|
+
} catch (e: any) {
|
|
51
|
+
return tryGetServerInfoAtPort(context, urlBase, port + 1, start, end)
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
async function tryGetServerInfo({ fetch }: Context, url: string): Promise<ServerInfo> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
56
|
+
try {
|
|
57
|
+
const response = await fetch(buildUrl(url, 'info'))
|
|
58
|
+
return response.json()
|
|
59
|
+
} catch (e: any) {
|
|
60
|
+
throw e.code === 'ECONNREFUSED' ? new ServerNotAvailable(url) : e
|
|
61
|
+
}
|
|
59
62
|
}
|
package/ts/platform.ts
CHANGED
package/ts/types.internal.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export type Context = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
fetch: (url: RequestInfo, init?: RequestInit) => Promise<Response>
|
|
3
|
+
location: {
|
|
4
|
+
protocol: string
|
|
5
|
+
hostname: string
|
|
6
|
+
}
|
|
7
|
+
importModule(moduleSpecifier: string): Promise<any>
|
|
8
8
|
}
|
|
9
|
-
|
package/ts/types.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { Log } from '@mocktomata/framework'
|
|
2
|
+
|
|
3
|
+
export type ServiceOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* URL to the mocktomata service.
|
|
6
|
+
*/
|
|
7
|
+
url: string
|
|
7
8
|
}
|
|
9
|
+
|
|
10
|
+
export type CreateIOOptions = ServiceOptions & Log.Context
|