wrangler 2.7.1 → 2.8.1
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/package.json +1 -1
- package/src/__tests__/d1/d1.test.ts +12 -8
- package/src/__tests__/deployments.test.ts +4 -4
- package/src/__tests__/helpers/mock-dialogs.ts +2 -0
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
- package/src/__tests__/helpers/mock-known-routes.ts +7 -2
- package/src/__tests__/helpers/mock-kv.ts +29 -16
- package/src/__tests__/helpers/mock-oauth-flow.ts +90 -98
- package/src/__tests__/helpers/msw/handlers/deployments.ts +20 -10
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
- package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
- package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
- package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
- package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
- package/src/__tests__/helpers/msw/index.ts +30 -1
- package/src/__tests__/init.test.ts +3 -14
- package/src/__tests__/jest.setup.ts +0 -23
- package/src/__tests__/pages-deployment-tail.test.ts +72 -1
- package/src/__tests__/pages.test.ts +52 -53
- package/src/__tests__/publish.test.ts +870 -522
- package/src/__tests__/r2.test.ts +11 -35
- package/src/__tests__/secret.test.ts +1 -9
- package/src/__tests__/tail.test.ts +72 -19
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/user.test.ts +5 -16
- package/src/__tests__/whoami.test.tsx +6 -17
- package/src/__tests__/worker-namespace.test.ts +56 -48
- package/src/api/index.ts +1 -0
- package/src/api/pages/index.ts +5 -0
- package/src/api/pages/publish.tsx +321 -0
- package/src/bundle.ts +62 -10
- package/src/cfetch/internal.ts +0 -3
- package/src/cli.ts +2 -2
- package/src/config/environment.ts +12 -10
- package/src/d1/backups.tsx +1 -5
- package/src/d1/utils.ts +1 -1
- package/src/deployments.ts +16 -6
- package/src/dev/local.tsx +1 -10
- package/src/dev/remote.tsx +2 -0
- package/src/dev/start-server.ts +5 -10
- package/src/dev/use-esbuild.ts +1 -0
- package/src/docs/index.ts +2 -1
- package/src/entry.ts +1 -2
- package/src/index.ts +1 -1
- package/src/init.ts +1 -1
- package/src/metrics/send-event.ts +2 -1
- package/src/pages/build.ts +4 -124
- package/src/pages/buildFunctions.ts +129 -0
- package/src/pages/dev.ts +68 -63
- package/src/pages/functions/buildPlugin.ts +3 -20
- package/src/pages/functions/buildWorker.ts +143 -21
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/publish.tsx +21 -220
- package/src/publish/publish.ts +30 -4
- package/src/tail/createTail.ts +28 -1
- package/src/tail/printing.ts +15 -0
- package/templates/checked-fetch.js +1 -3
- package/templates/d1-beta-facade.js +1 -1
- package/templates/middleware/loader-modules.ts +2 -0
- package/templates/tsconfig.tsbuildinfo +1 -1
- package/wrangler-dist/cli.d.ts +132 -10
- package/wrangler-dist/cli.js +3532 -3330
- package/src/__tests__/helpers/mock-cfetch.ts +0 -278
package/package.json
CHANGED
|
@@ -37,10 +37,12 @@ describe("d1", () => {
|
|
|
37
37
|
-h, --help Show help [boolean]
|
|
38
38
|
-v, --version Show version number [boolean]
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
To
|
|
40
|
+
--------------------
|
|
41
|
+
🚧 D1 is currently in open alpha and is not recommended for production data and traffic
|
|
42
|
+
🚧 Please report any bugs to https://github.com/cloudflare/wrangler2/issues/new/choose
|
|
43
|
+
🚧 To request features, visit https://community.cloudflare.com/c/developers/d1
|
|
44
|
+
🚧 To give feedback, visit https://discord.gg/cloudflaredev
|
|
45
|
+
--------------------"
|
|
44
46
|
`);
|
|
45
47
|
});
|
|
46
48
|
|
|
@@ -74,10 +76,12 @@ describe("d1", () => {
|
|
|
74
76
|
-h, --help Show help [boolean]
|
|
75
77
|
-v, --version Show version number [boolean]
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
To
|
|
79
|
+
--------------------
|
|
80
|
+
🚧 D1 is currently in open alpha and is not recommended for production data and traffic
|
|
81
|
+
🚧 Please report any bugs to https://github.com/cloudflare/wrangler2/issues/new/choose
|
|
82
|
+
🚧 To request features, visit https://community.cloudflare.com/c/developers/d1
|
|
83
|
+
🚧 To give feedback, visit https://discord.gg/cloudflaredev
|
|
84
|
+
--------------------"
|
|
81
85
|
`);
|
|
82
86
|
});
|
|
83
87
|
|
|
@@ -68,12 +68,12 @@ describe("deployments", () => {
|
|
|
68
68
|
Deployment ID: Galaxy-Class
|
|
69
69
|
Created on: 2021-01-01T00:00:00.000000Z
|
|
70
70
|
Author: Jean-Luc-Picard@federation.org
|
|
71
|
-
Source: Wrangler
|
|
71
|
+
Source: 🤠 Wrangler
|
|
72
72
|
|
|
73
73
|
Deployment ID: Intrepid-Class
|
|
74
74
|
Created on: 2021-02-02T00:00:00.000000Z
|
|
75
75
|
Author: Kathryn-Janeway@federation.org
|
|
76
|
-
Source: Wrangler
|
|
76
|
+
Source: 🤠 Wrangler
|
|
77
77
|
🟩 Active"
|
|
78
78
|
`);
|
|
79
79
|
});
|
|
@@ -87,12 +87,12 @@ describe("deployments", () => {
|
|
|
87
87
|
Deployment ID: Galaxy-Class
|
|
88
88
|
Created on: 2021-01-01T00:00:00.000000Z
|
|
89
89
|
Author: Jean-Luc-Picard@federation.org
|
|
90
|
-
Source: Wrangler
|
|
90
|
+
Source: 🤠 Wrangler
|
|
91
91
|
|
|
92
92
|
Deployment ID: Intrepid-Class
|
|
93
93
|
Created on: 2021-02-02T00:00:00.000000Z
|
|
94
94
|
Author: Kathryn-Janeway@federation.org
|
|
95
|
-
Source: Wrangler
|
|
95
|
+
Source: 🤠 Wrangler
|
|
96
96
|
🟩 Active"
|
|
97
97
|
`);
|
|
98
98
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import prompts from "prompts";
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* The expected values for a confirmation request.
|
|
4
5
|
*/
|
|
@@ -30,6 +31,7 @@ export function mockConfirm(...expectations: ConfirmExpectation[]) {
|
|
|
30
31
|
if (expectation.options) {
|
|
31
32
|
expect(initial).toStrictEqual(expectation.options?.defaultValue);
|
|
32
33
|
}
|
|
34
|
+
|
|
33
35
|
return Promise.resolve({ value: expectation.result });
|
|
34
36
|
}
|
|
35
37
|
);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rest } from "msw";
|
|
2
|
+
import { msw, createFetchResult } from "./msw";
|
|
2
3
|
|
|
3
4
|
export function mockGetZoneFromHostRequest(host: string, zone?: string) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
msw.use(
|
|
6
|
+
rest.get("*/zones", (req, res, ctx) => {
|
|
7
|
+
expect(req.url.searchParams.get("name")).toEqual(host);
|
|
8
|
+
return res(ctx.json(createFetchResult(zone ? [{ id: zone }] : [])));
|
|
9
|
+
})
|
|
10
|
+
);
|
|
8
11
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rest } from "msw";
|
|
2
|
+
import { createFetchResult, msw } from "./msw";
|
|
2
3
|
|
|
3
4
|
export function mockCollectKnownRoutesRequest(
|
|
4
5
|
routes: { pattern: string; script: string }[]
|
|
5
6
|
) {
|
|
6
|
-
|
|
7
|
+
msw.use(
|
|
8
|
+
rest.get(`*/zones/:zoneId/workers/routes`, (_, res, ctx) =>
|
|
9
|
+
res.once(ctx.json(createFetchResult(routes)))
|
|
10
|
+
)
|
|
11
|
+
);
|
|
7
12
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rest } from "msw";
|
|
2
|
+
import { createFetchResult, msw } from "./msw";
|
|
2
3
|
import type { NamespaceKeyInfo } from "../../kv/helpers";
|
|
3
4
|
|
|
4
5
|
export function mockKeyListRequest(
|
|
@@ -9,25 +10,37 @@ export function mockKeyListRequest(
|
|
|
9
10
|
) {
|
|
10
11
|
const requests = { count: 0 };
|
|
11
12
|
// See https://api.cloudflare.com/#workers-kv-namespace-list-a-namespace-s-keys
|
|
13
|
+
msw.use(
|
|
14
|
+
rest.get(
|
|
15
|
+
"*/accounts/:accountId/storage/kv/namespaces/:namespaceId/keys",
|
|
16
|
+
(req, res, ctx) => {
|
|
17
|
+
requests.count++;
|
|
18
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
19
|
+
expect(req.params.namespaceId).toEqual(expectedNamespaceId);
|
|
20
|
+
let response: undefined | NamespaceKeyInfo[];
|
|
21
|
+
if (expectedKeys.length <= keysPerRequest) {
|
|
22
|
+
response = expectedKeys;
|
|
23
|
+
}
|
|
12
24
|
|
|
13
|
-
|
|
14
|
-
"/accounts/:accountId/storage/kv/namespaces/:namespaceId/keys",
|
|
15
|
-
"GET",
|
|
16
|
-
([_url, accountId, namespaceId], _init, query) => {
|
|
17
|
-
requests.count++;
|
|
18
|
-
expect(accountId).toEqual("some-account-id");
|
|
19
|
-
expect(namespaceId).toEqual(expectedNamespaceId);
|
|
20
|
-
if (expectedKeys.length <= keysPerRequest) {
|
|
21
|
-
return createFetchResult(expectedKeys);
|
|
22
|
-
} else {
|
|
23
|
-
const start = parseInt(query.get("cursor") ?? "0") || 0;
|
|
25
|
+
const start = parseInt(req.url.searchParams.get("cursor") ?? "0") || 0;
|
|
24
26
|
const end = start + keysPerRequest;
|
|
25
27
|
const cursor = end < expectedKeys.length ? end : blankCursorValue;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
return res(
|
|
30
|
+
ctx.json(
|
|
31
|
+
createFetchResult(
|
|
32
|
+
response ? response : expectedKeys.slice(start, end),
|
|
33
|
+
true,
|
|
34
|
+
[],
|
|
35
|
+
[],
|
|
36
|
+
{
|
|
37
|
+
cursor,
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
);
|
|
29
42
|
}
|
|
30
|
-
|
|
43
|
+
)
|
|
31
44
|
);
|
|
32
45
|
return requests;
|
|
33
46
|
}
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { rest } from "msw";
|
|
2
2
|
import { Request } from "undici";
|
|
3
3
|
import openInBrowser from "../../open-in-browser";
|
|
4
|
-
import { setMockResponse } from "./mock-cfetch";
|
|
5
4
|
import { mockHttpServer } from "./mock-http-server";
|
|
5
|
+
import { createFetchResult, msw } from "./msw";
|
|
6
6
|
|
|
7
7
|
export function mockGetMemberships(
|
|
8
8
|
accounts: { id: string; account: { id: string; name: string } }[]
|
|
9
9
|
) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
msw.use(
|
|
11
|
+
rest.get("*/memberships", (_, res, ctx) => {
|
|
12
|
+
return res.once(ctx.json(createFetchResult(accounts)));
|
|
13
|
+
})
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
export function mockGetMembershipsFail() {
|
|
17
|
+
msw.use(
|
|
18
|
+
rest.get("*/memberships", (_, res, ctx) => {
|
|
19
|
+
return res.once(ctx.json(createFetchResult([], false)));
|
|
20
|
+
})
|
|
21
|
+
);
|
|
13
22
|
}
|
|
14
|
-
|
|
15
|
-
// the response to send when wrangler wants an oauth grant
|
|
16
|
-
let oauthGrantResponse: GrantResponseOptions | "timeout" = {};
|
|
17
23
|
|
|
18
24
|
/**
|
|
19
25
|
* Functions to help with mocking various parts of the OAuth Flow
|
|
20
26
|
*/
|
|
21
27
|
export const mockOAuthFlow = () => {
|
|
28
|
+
// the response to send when wrangler wants an oauth grant
|
|
29
|
+
let oauthGrantResponse: GrantResponseOptions | "timeout" = {};
|
|
22
30
|
const fetchHttp = mockHttpServer();
|
|
23
31
|
|
|
24
|
-
afterEach(() => {
|
|
25
|
-
fetchMock.resetMocks();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
32
|
/**
|
|
29
33
|
* Mock out the callback from a browser to our HttpServer.
|
|
30
34
|
*
|
|
@@ -61,7 +65,7 @@ export const mockOAuthFlow = () => {
|
|
|
61
65
|
});
|
|
62
66
|
};
|
|
63
67
|
|
|
64
|
-
//
|
|
68
|
+
// Handled in `mockOAuthServerCallback`
|
|
65
69
|
const mockGrantAuthorization = ({
|
|
66
70
|
respondWith,
|
|
67
71
|
}: {
|
|
@@ -82,25 +86,6 @@ export const mockOAuthFlow = () => {
|
|
|
82
86
|
}
|
|
83
87
|
};
|
|
84
88
|
|
|
85
|
-
const mockRevokeAuthorization = ({
|
|
86
|
-
domain = "dash.cloudflare.com",
|
|
87
|
-
}: { domain?: string } = {}) => {
|
|
88
|
-
const outcome = {
|
|
89
|
-
actual: new Request("https://example.org"),
|
|
90
|
-
expected: new Request(`https://${domain}/oauth2/revoke`, {
|
|
91
|
-
method: "POST",
|
|
92
|
-
}),
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
fetchMock.mockIf(outcome.expected.url, async (req) => {
|
|
96
|
-
// TODO: update Miniflare typings to match full undici Request
|
|
97
|
-
outcome.actual = req as unknown as Request;
|
|
98
|
-
return "";
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
return outcome;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
89
|
const mockGrantAccessToken = ({
|
|
105
90
|
respondWith,
|
|
106
91
|
domain = "dash.cloudflare.com",
|
|
@@ -109,94 +94,101 @@ export const mockOAuthFlow = () => {
|
|
|
109
94
|
domain?: string;
|
|
110
95
|
}) => {
|
|
111
96
|
const outcome = {
|
|
112
|
-
actual:
|
|
113
|
-
expected:
|
|
114
|
-
method: "POST",
|
|
115
|
-
}),
|
|
97
|
+
actual: "https://example.org",
|
|
98
|
+
expected: `https://${domain}/oauth2/token`,
|
|
116
99
|
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
100
|
+
msw.use(
|
|
101
|
+
rest.post(outcome.expected, async (req, res, ctx) => {
|
|
102
|
+
// TODO: update Miniflare typings to match full undici Request
|
|
103
|
+
outcome.actual = req.url.toString();
|
|
104
|
+
return res.once(ctx.json(makeTokenResponse(respondWith)));
|
|
105
|
+
})
|
|
106
|
+
);
|
|
123
107
|
|
|
124
108
|
return outcome;
|
|
125
109
|
};
|
|
126
110
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
domain = "dash.
|
|
111
|
+
function mockDomainUsesAccess({
|
|
112
|
+
usesAccess,
|
|
113
|
+
domain = "dash.cloudflare.com",
|
|
130
114
|
}: {
|
|
131
|
-
|
|
115
|
+
usesAccess: boolean;
|
|
132
116
|
domain?: string;
|
|
133
|
-
})
|
|
134
|
-
|
|
117
|
+
}) {
|
|
118
|
+
// If the domain relies upon Cloudflare Access, then a request to the domain
|
|
119
|
+
// will result in a redirect to the `cloudflareaccess.com` domain.
|
|
120
|
+
msw.use(
|
|
121
|
+
rest.get(`https://${domain}/`, (_, res, ctx) => {
|
|
122
|
+
let status = 200;
|
|
123
|
+
let headers: Record<string, string> = {
|
|
124
|
+
"Content-Type": "application/json",
|
|
125
|
+
};
|
|
126
|
+
if (usesAccess) {
|
|
127
|
+
status = 302;
|
|
128
|
+
headers = { location: "cloudflareaccess.com" };
|
|
129
|
+
}
|
|
130
|
+
return res.once(ctx.status(status), ctx.set(headers));
|
|
131
|
+
})
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
mockHttpServer,
|
|
137
|
+
mockDomainUsesAccess,
|
|
138
|
+
mockGrantAccessToken,
|
|
139
|
+
mockOAuthServerCallback,
|
|
140
|
+
mockExchangeRefreshTokenForAccessToken,
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export function mockExchangeRefreshTokenForAccessToken({
|
|
145
|
+
respondWith,
|
|
146
|
+
domain = "dash.cloudflare.com",
|
|
147
|
+
}: {
|
|
148
|
+
respondWith: "refreshSuccess" | "refreshError" | "badResponse";
|
|
149
|
+
domain?: string;
|
|
150
|
+
}) {
|
|
151
|
+
msw.use(
|
|
152
|
+
rest.post(`https://${domain}/oauth2/token`, async (_, res, ctx) => {
|
|
135
153
|
switch (respondWith) {
|
|
136
154
|
case "refreshSuccess":
|
|
137
|
-
return
|
|
138
|
-
status
|
|
139
|
-
|
|
155
|
+
return res.once(
|
|
156
|
+
ctx.status(200),
|
|
157
|
+
ctx.json({
|
|
140
158
|
access_token: "access_token_success_mock",
|
|
141
159
|
expires_in: 1701,
|
|
142
160
|
refresh_token: "refresh_token_success_mock",
|
|
143
161
|
scope: "scope_success_mock",
|
|
144
162
|
token_type: "bearer",
|
|
145
|
-
})
|
|
146
|
-
|
|
163
|
+
})
|
|
164
|
+
);
|
|
147
165
|
case "refreshError":
|
|
148
|
-
return
|
|
149
|
-
status
|
|
150
|
-
|
|
166
|
+
return res.once(
|
|
167
|
+
ctx.status(400),
|
|
168
|
+
ctx.json({
|
|
151
169
|
error: "invalid_request",
|
|
152
170
|
error_description: "error_description_mock",
|
|
153
171
|
error_hint: "error_hint_mock",
|
|
154
172
|
error_verbose: "error_verbose_mock",
|
|
155
173
|
status_code: 400,
|
|
156
|
-
})
|
|
157
|
-
|
|
174
|
+
})
|
|
175
|
+
);
|
|
158
176
|
case "badResponse":
|
|
159
|
-
return
|
|
160
|
-
status
|
|
161
|
-
|
|
162
|
-
|
|
177
|
+
return res.once(
|
|
178
|
+
ctx.status(400),
|
|
179
|
+
ctx.text(
|
|
180
|
+
`<html> <body> This shouldn't be sent, but should be handled </body> </html>`
|
|
181
|
+
)
|
|
182
|
+
);
|
|
163
183
|
|
|
164
184
|
default:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const mockDomainUsesAccess = ({
|
|
171
|
-
usesAccess,
|
|
172
|
-
domain = "dash.cloudflare.com",
|
|
173
|
-
}: {
|
|
174
|
-
usesAccess: boolean;
|
|
175
|
-
domain?: string;
|
|
176
|
-
}) => {
|
|
177
|
-
// If the domain relies upon Cloudflare Access, then a request to the domain
|
|
178
|
-
// will result in a redirect to the `cloudflareaccess.com` domain.
|
|
179
|
-
fetchMock.mockOnceIf(`https://${domain}/`, async () => {
|
|
180
|
-
if (usesAccess) {
|
|
181
|
-
return {
|
|
182
|
-
status: 302,
|
|
183
|
-
headers: { location: "cloudflareaccess.com" },
|
|
184
|
-
};
|
|
185
|
-
} else {
|
|
186
|
-
return { status: 200 };
|
|
185
|
+
throw new Error(
|
|
186
|
+
"Not a respondWith option for `mockExchangeRefreshTokenForAccessToken`"
|
|
187
|
+
);
|
|
187
188
|
}
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return {
|
|
192
|
-
mockDomainUsesAccess,
|
|
193
|
-
mockGrantAccessToken,
|
|
194
|
-
mockGrantAuthorization,
|
|
195
|
-
mockOAuthServerCallback,
|
|
196
|
-
mockRevokeAuthorization,
|
|
197
|
-
mockExchangeRefreshTokenForAccessToken,
|
|
198
|
-
};
|
|
199
|
-
};
|
|
189
|
+
})
|
|
190
|
+
);
|
|
191
|
+
}
|
|
200
192
|
|
|
201
193
|
type GrantResponseOptions = {
|
|
202
194
|
code?: string;
|
|
@@ -249,7 +241,7 @@ type MockTokenResponse =
|
|
|
249
241
|
error: ErrorType;
|
|
250
242
|
};
|
|
251
243
|
|
|
252
|
-
const makeTokenResponse = (partialResponse: MockTokenResponse)
|
|
244
|
+
const makeTokenResponse = (partialResponse: MockTokenResponse) => {
|
|
253
245
|
let fullResponse: MockTokenResponse;
|
|
254
246
|
|
|
255
247
|
if (partialResponse === "ok") {
|
|
@@ -267,5 +259,5 @@ const makeTokenResponse = (partialResponse: MockTokenResponse): string => {
|
|
|
267
259
|
fullResponse = partialResponse;
|
|
268
260
|
}
|
|
269
261
|
|
|
270
|
-
return
|
|
262
|
+
return fullResponse;
|
|
271
263
|
};
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { rest } from "msw";
|
|
2
|
-
|
|
3
|
-
import type { DeploymentListRes } from "../../../../deployments";
|
|
2
|
+
import { createFetchResult } from "../index";
|
|
4
3
|
|
|
5
4
|
export const mswSuccessDeployments = [
|
|
6
5
|
rest.get(
|
|
7
6
|
"*/accounts/:accountId/workers/deployments/by-script/:scriptTag",
|
|
8
7
|
(_, response, context) =>
|
|
9
8
|
response.once(
|
|
10
|
-
context.
|
|
11
|
-
|
|
12
|
-
success: true,
|
|
13
|
-
errors: [],
|
|
14
|
-
messages: [],
|
|
15
|
-
result: {
|
|
9
|
+
context.json(
|
|
10
|
+
createFetchResult({
|
|
16
11
|
latest: {
|
|
17
12
|
id: "Galaxy-Class",
|
|
18
13
|
number: "1701-E",
|
|
@@ -52,8 +47,23 @@ export const mswSuccessDeployments = [
|
|
|
52
47
|
},
|
|
53
48
|
},
|
|
54
49
|
],
|
|
55
|
-
}
|
|
56
|
-
|
|
50
|
+
})
|
|
51
|
+
)
|
|
57
52
|
)
|
|
58
53
|
),
|
|
59
54
|
];
|
|
55
|
+
|
|
56
|
+
export const mswSuccessLastDeployment = [
|
|
57
|
+
rest.get(
|
|
58
|
+
"*/accounts/:accountId/workers/services/:scriptName",
|
|
59
|
+
(_, res, ctx) => {
|
|
60
|
+
return res.once(
|
|
61
|
+
ctx.json(
|
|
62
|
+
createFetchResult({
|
|
63
|
+
default_environment: { script: { last_deployed_from: "wrangler" } },
|
|
64
|
+
})
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
];
|
|
@@ -1,59 +1,44 @@
|
|
|
1
1
|
import { rest } from "msw";
|
|
2
|
+
import { createFetchResult } from "../index";
|
|
2
3
|
|
|
3
4
|
export const mswSuccessNamespacesHandlers = [
|
|
4
5
|
rest.post(
|
|
5
6
|
"*/accounts/:accountId/workers/dispatch/namespaces",
|
|
6
7
|
(_, response, context) => {
|
|
7
8
|
return response.once(
|
|
8
|
-
context.
|
|
9
|
-
|
|
10
|
-
success: true,
|
|
11
|
-
errors: [],
|
|
12
|
-
messages: [],
|
|
13
|
-
result: {
|
|
9
|
+
context.json(
|
|
10
|
+
createFetchResult({
|
|
14
11
|
namespace_id: "some-namespace-id",
|
|
15
12
|
namespace_name: "namespace-name",
|
|
16
13
|
created_on: "2022-06-29T14:30:08.16152Z",
|
|
17
14
|
created_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
18
15
|
modified_on: "2022-06-29T14:30:08.16152Z",
|
|
19
16
|
modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
20
|
-
}
|
|
21
|
-
|
|
17
|
+
})
|
|
18
|
+
)
|
|
22
19
|
);
|
|
23
20
|
}
|
|
24
21
|
),
|
|
25
22
|
rest.delete(
|
|
26
23
|
"*/accounts/:accountId/workers/dispatch/namespaces/:namespaceName",
|
|
27
24
|
(_, response, context) => {
|
|
28
|
-
return response.once(
|
|
29
|
-
context.status(200),
|
|
30
|
-
context.json({
|
|
31
|
-
success: true,
|
|
32
|
-
errors: [],
|
|
33
|
-
messages: [],
|
|
34
|
-
result: null,
|
|
35
|
-
})
|
|
36
|
-
);
|
|
25
|
+
return response.once(context.json(createFetchResult(null)));
|
|
37
26
|
}
|
|
38
27
|
),
|
|
39
28
|
rest.put(
|
|
40
29
|
"*/accounts/:accountId/workers/dispatch/namespaces/:namespaceName",
|
|
41
30
|
(_, response, context) => {
|
|
42
31
|
return response.once(
|
|
43
|
-
context.
|
|
44
|
-
|
|
45
|
-
success: true,
|
|
46
|
-
errors: [],
|
|
47
|
-
messages: [],
|
|
48
|
-
result: {
|
|
32
|
+
context.json(
|
|
33
|
+
createFetchResult({
|
|
49
34
|
namespace_id: "some-namespace-id",
|
|
50
35
|
namespace_name: "namespace-name",
|
|
51
36
|
created_on: "2022-06-29T14:30:08.16152Z",
|
|
52
37
|
created_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
53
38
|
modified_on: "2022-06-29T14:30:08.16152Z",
|
|
54
39
|
modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
55
|
-
}
|
|
56
|
-
|
|
40
|
+
})
|
|
41
|
+
)
|
|
57
42
|
);
|
|
58
43
|
}
|
|
59
44
|
),
|
|
@@ -61,20 +46,16 @@ export const mswSuccessNamespacesHandlers = [
|
|
|
61
46
|
"*/accounts/:accountId/workers/dispatch/namespaces/:namespaceName",
|
|
62
47
|
(_, response, context) => {
|
|
63
48
|
return response.once(
|
|
64
|
-
context.
|
|
65
|
-
|
|
66
|
-
success: true,
|
|
67
|
-
errors: [],
|
|
68
|
-
messages: [],
|
|
69
|
-
result: {
|
|
49
|
+
context.json(
|
|
50
|
+
createFetchResult({
|
|
70
51
|
namespace_id: "some-namespace-id",
|
|
71
52
|
namespace_name: "namespace-name",
|
|
72
53
|
created_on: "2022-06-29T14:30:08.16152Z",
|
|
73
54
|
created_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
74
55
|
modified_on: "2022-06-29T14:30:08.16152Z",
|
|
75
56
|
modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
76
|
-
}
|
|
77
|
-
|
|
57
|
+
})
|
|
58
|
+
)
|
|
78
59
|
);
|
|
79
60
|
}
|
|
80
61
|
),
|
|
@@ -82,12 +63,8 @@ export const mswSuccessNamespacesHandlers = [
|
|
|
82
63
|
"*/accounts/:accountId/workers/dispatch/namespaces",
|
|
83
64
|
(_, response, context) => {
|
|
84
65
|
return response.once(
|
|
85
|
-
context.
|
|
86
|
-
|
|
87
|
-
success: true,
|
|
88
|
-
errors: [],
|
|
89
|
-
messages: [],
|
|
90
|
-
result: [
|
|
66
|
+
context.json(
|
|
67
|
+
createFetchResult([
|
|
91
68
|
{
|
|
92
69
|
namespace_id: "some-namespace-id",
|
|
93
70
|
namespace_name: "namespace-name",
|
|
@@ -96,8 +73,8 @@ export const mswSuccessNamespacesHandlers = [
|
|
|
96
73
|
modified_on: "2022-06-29T14:30:08.16152Z",
|
|
97
74
|
modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
98
75
|
},
|
|
99
|
-
]
|
|
100
|
-
|
|
76
|
+
])
|
|
77
|
+
)
|
|
101
78
|
);
|
|
102
79
|
}
|
|
103
80
|
),
|