@warp-drive/holodeck 0.0.0-alpha.9 → 0.0.0-beta.3

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.
@@ -0,0 +1,12 @@
1
+ import type { Handler, NextFn, RequestContext, StructuredDataDocument } from '@ember-data/request';
2
+ import type { ScaffoldGenerator } from './mock';
3
+ export declare function setTestId(context: object, str: string | null): void;
4
+ export declare function setIsRecording(value: boolean): void;
5
+ export declare function getIsRecording(): boolean;
6
+ export declare class MockServerHandler implements Handler {
7
+ owner: object;
8
+ constructor(owner: object);
9
+ request<T>(context: RequestContext, next: NextFn<T>): Promise<StructuredDataDocument<T>>;
10
+ }
11
+ export declare function mock(owner: object, generate: ScaffoldGenerator, isRecording?: boolean): Promise<void>;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAe,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEhH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAIhD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,QAS5D;AAGD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,QAE5C;AACD,wBAAgB,cAAc,YAE7B;AAED,qBAAa,iBAAkB,YAAW,OAAO;IACvC,KAAK,EAAE,MAAM,CAAC;gBACV,KAAK,EAAE,MAAM;IAGnB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;CA6B/F;AAED,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,WAAW,CAAC,EAAE,OAAO,iBAgB3F"}
package/dist/mock.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ export interface Scaffold {
2
+ status: number;
3
+ statusText?: string;
4
+ headers: Record<string, string>;
5
+ body: Record<string, string> | string | null;
6
+ method: string;
7
+ url: string;
8
+ response: Record<string, unknown>;
9
+ }
10
+ export type ScaffoldGenerator = () => Scaffold;
11
+ export type ResponseGenerator = () => Record<string, unknown>;
12
+ /**
13
+ * Sets up Mocking for a GET request on the mock server
14
+ * for the supplied url.
15
+ *
16
+ * The response body is generated by the supplied response function.
17
+ *
18
+ * Available options:
19
+ * - status: the status code to return (default: 200)
20
+ * - headers: the headers to return (default: {})
21
+ * - body: the body to match against for the request (default: null)
22
+ * - RECORD: whether to record the request (default: false)
23
+ *
24
+ * @param url the url to mock, relative to the mock server host (e.g. `users/1`)
25
+ * @param response a function which generates the response to return
26
+ * @param options status, headers for the response, body to match against for the request, and whether to record the request
27
+ * @return
28
+ */
29
+ export declare function GET(owner: object, url: string, response: ResponseGenerator, options?: Partial<Omit<Scaffold, 'response' | 'url' | 'method'>> & {
30
+ RECORD?: boolean;
31
+ }): Promise<void>;
32
+ export declare function POST(): void;
33
+ export declare function PUT(): void;
34
+ export declare function PATCH(): void;
35
+ export declare function DELETE(): void;
36
+ export declare function QUERY(): void;
37
+ //# sourceMappingURL=mock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../client/mock.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,QAAQ,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE9D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,GAAG,CACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACtF,OAAO,CAAC,IAAI,CAAC,CAcf;AACD,wBAAgB,IAAI,SAAK;AACzB,wBAAgB,GAAG,SAAK;AACxB,wBAAgB,KAAK,SAAK;AAC1B,wBAAgB,MAAM,SAAK;AAC3B,wBAAgB,KAAK,SAAK"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warp-drive/holodeck",
3
3
  "description": "⚡️ Simple, Fast HTTP Mocking for Tests",
4
- "version": "0.0.0-alpha.9",
4
+ "version": "0.0.0-beta.3",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -12,7 +12,7 @@
12
12
  "homepage": "https://github.com/emberjs/data",
13
13
  "bugs": "https://github.com/emberjs/data/issues",
14
14
  "engines": {
15
- "node": ">= 20.11.0"
15
+ "node": ">= 18.19.1"
16
16
  },
17
17
  "keywords": [
18
18
  "http-mock"
@@ -40,22 +40,21 @@
40
40
  "holodeck": "./bin/holodeck.js"
41
41
  },
42
42
  "peerDependencies": {
43
- "@ember-data/request": "5.4.0-alpha.23",
44
- "@warp-drive/core-types": "0.0.0-alpha.9"
43
+ "@ember-data/request": "5.4.0-beta.3"
45
44
  },
46
45
  "devDependencies": {
47
- "@babel/cli": "^7.23.4",
48
- "@babel/core": "^7.23.7",
46
+ "@babel/cli": "^7.23.9",
47
+ "@babel/core": "^7.23.9",
49
48
  "@babel/plugin-transform-typescript": "^7.23.6",
50
- "@babel/preset-env": "^7.23.8",
49
+ "@babel/preset-env": "^7.23.9",
51
50
  "@babel/preset-typescript": "^7.23.3",
52
- "@babel/runtime": "^7.23.8",
53
- "@ember-data/request": "5.4.0-alpha.23",
51
+ "@babel/runtime": "^7.23.9",
52
+ "@ember-data/request": "5.4.0-beta.3",
54
53
  "@embroider/addon-dev": "^4.1.2",
55
54
  "@rollup/plugin-babel": "^6.0.4",
56
55
  "@rollup/plugin-node-resolve": "^15.2.3",
57
- "@warp-drive/core-types": "0.0.0-alpha.9",
58
- "@warp-drive/internal-config": "5.4.0-alpha.23",
56
+ "@warp-drive/core-types": "0.0.0-beta.3",
57
+ "@warp-drive/internal-config": "5.4.0-beta.3",
59
58
  "rollup": "^4.9.6",
60
59
  "typescript": "^5.3.3",
61
60
  "walk-sync": "^3.0.0"