@ldo/test-solid-server 1.0.0-alpha.28 → 1.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/authFetch.cjs +80 -0
- package/dist/authFetch.js +80 -0
- package/dist/authFetch.js.map +1 -0
- package/dist/createServer.cjs +32 -0
- package/dist/createServer.d.cts +9 -0
- package/dist/createServer.d.cts.map +1 -0
- package/dist/createServer.d.ts +9 -0
- package/dist/createServer.d.ts.map +1 -0
- package/dist/createServer.js +32 -0
- package/dist/createServer.js.map +1 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/resourceUtils.cjs +29 -0
- package/dist/resourceUtils.d.cts +20 -0
- package/dist/resourceUtils.d.cts.map +1 -0
- package/dist/resourceUtils.d.ts +20 -0
- package/dist/resourceUtils.d.ts.map +1 -0
- package/dist/resourceUtils.js +28 -0
- package/dist/resourceUtils.js.map +1 -0
- package/dist/setupTestServer.cjs +56 -0
- package/dist/setupTestServer.d.cts +16 -0
- package/dist/setupTestServer.d.cts.map +1 -0
- package/dist/setupTestServer.d.ts +16 -0
- package/dist/setupTestServer.d.ts.map +1 -0
- package/dist/setupTestServer.js +56 -0
- package/dist/setupTestServer.js.map +1 -0
- package/package.json +14 -11
- package/src/index.ts +3 -3
- package/src/setupTestServer.ts +4 -4
- package/dist/cjs/authFetch.cjs +0 -106
- package/dist/cjs/authFetch.js.map +0 -1
- package/dist/cjs/configs/server-config-without-websocket.json +0 -44
- package/dist/cjs/configs/server-config.json +0 -43
- package/dist/cjs/configs/solid-css-seed.json +0 -9
- package/dist/cjs/createServer.cjs +0 -68
- package/dist/cjs/createServer.js.map +0 -1
- package/dist/cjs/index.cjs +0 -20
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/resourceUtils.cjs +0 -41
- package/dist/cjs/resourceUtils.js.map +0 -1
- package/dist/cjs/setupTestServer.cjs +0 -66
- package/dist/cjs/setupTestServer.js.map +0 -1
- package/dist/esm/authFetch.js +0 -100
- package/dist/esm/authFetch.js.map +0 -1
- package/dist/esm/configs/server-config-without-websocket.json +0 -44
- package/dist/esm/configs/server-config.json +0 -43
- package/dist/esm/configs/solid-css-seed.json +0 -9
- package/dist/esm/createServer.js +0 -32
- package/dist/esm/createServer.js.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/resourceUtils.js +0 -37
- package/dist/esm/resourceUtils.js.map +0 -1
- package/dist/esm/setupTestServer.js +0 -60
- package/dist/esm/setupTestServer.js.map +0 -1
- package/dist/types/authFetch.d.ts +0 -2
- package/dist/types/authFetch.d.ts.map +0 -1
- package/dist/types/createServer.d.ts +0 -3
- package/dist/types/createServer.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/resourceUtils.d.ts +0 -18
- package/dist/types/resourceUtils.d.ts.map +0 -1
- package/dist/types/setupTestServer.d.ts +0 -10
- package/dist/types/setupTestServer.d.ts.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__toESM', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __toESM;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const __inrupt_solid_client_authn_core = require_rolldown_runtime.__toESM(require("@inrupt/solid-client-authn-core"));
|
|
3
|
+
const cross_fetch = require_rolldown_runtime.__toESM(require("cross-fetch"));
|
|
4
|
+
|
|
5
|
+
//#region src/authFetch.ts
|
|
6
|
+
const config = {
|
|
7
|
+
podName: "example",
|
|
8
|
+
email: "hello@example.com",
|
|
9
|
+
password: "abc123"
|
|
10
|
+
};
|
|
11
|
+
async function reportError(response) {
|
|
12
|
+
if (response.status >= 400) console.error(await response.text());
|
|
13
|
+
}
|
|
14
|
+
async function getAuthorization(port) {
|
|
15
|
+
const indexResponse = await (0, cross_fetch.default)(`http://localhost:${port}/.account/`);
|
|
16
|
+
const { controls } = await indexResponse.json();
|
|
17
|
+
const response = await (0, cross_fetch.default)(controls.password.login, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: { "content-type": "application/json" },
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
email: config.email,
|
|
22
|
+
password: config.password
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
await reportError(response);
|
|
26
|
+
const result = await response.json();
|
|
27
|
+
return result.authorization;
|
|
28
|
+
}
|
|
29
|
+
async function getSecret(port, authorization) {
|
|
30
|
+
const indexResponse = await (0, cross_fetch.default)(`http://localhost:${port}/.account/`, { headers: { authorization: `CSS-Account-Token ${authorization}` } });
|
|
31
|
+
const { controls } = await indexResponse.json();
|
|
32
|
+
const response = await (0, cross_fetch.default)(controls.account.clientCredentials, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: {
|
|
35
|
+
authorization: `CSS-Account-Token ${authorization}`,
|
|
36
|
+
"content-type": "application/json"
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
name: "my-token",
|
|
40
|
+
webId: `http://localhost:${port}/${config.podName}/profile/card#me`
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
await reportError(response);
|
|
44
|
+
const response2 = await response.json();
|
|
45
|
+
return response2;
|
|
46
|
+
}
|
|
47
|
+
async function getAccessToken(port, id, secret) {
|
|
48
|
+
try {
|
|
49
|
+
const dpopKey = await (0, __inrupt_solid_client_authn_core.generateDpopKeyPair)();
|
|
50
|
+
const authString = `${encodeURIComponent(id)}:${encodeURIComponent(secret)}`;
|
|
51
|
+
const tokenUrl = `http://localhost:${port}/.oidc/token`;
|
|
52
|
+
const response = await (0, cross_fetch.default)(tokenUrl, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
headers: {
|
|
55
|
+
authorization: `Basic ${Buffer.from(authString).toString("base64")}`,
|
|
56
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
57
|
+
dpop: await (0, __inrupt_solid_client_authn_core.createDpopHeader)(tokenUrl, "POST", dpopKey)
|
|
58
|
+
},
|
|
59
|
+
body: "grant_type=client_credentials&scope=webid"
|
|
60
|
+
});
|
|
61
|
+
await reportError(response);
|
|
62
|
+
const response2 = await response.json();
|
|
63
|
+
return {
|
|
64
|
+
accessToken: response2.access_token,
|
|
65
|
+
dpopKey
|
|
66
|
+
};
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.error(err);
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function generateAuthFetch(port) {
|
|
73
|
+
const authorization = await getAuthorization(port);
|
|
74
|
+
const { id, secret } = await getSecret(port, authorization);
|
|
75
|
+
const { accessToken, dpopKey } = await getAccessToken(port, id, secret);
|
|
76
|
+
return await (0, __inrupt_solid_client_authn_core.buildAuthenticatedFetch)(accessToken, { dpopKey });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
exports.generateAuthFetch = generateAuthFetch;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { buildAuthenticatedFetch, createDpopHeader, generateDpopKeyPair } from "@inrupt/solid-client-authn-core";
|
|
2
|
+
import fetch from "cross-fetch";
|
|
3
|
+
|
|
4
|
+
//#region src/authFetch.ts
|
|
5
|
+
const config = {
|
|
6
|
+
podName: "example",
|
|
7
|
+
email: "hello@example.com",
|
|
8
|
+
password: "abc123"
|
|
9
|
+
};
|
|
10
|
+
async function reportError(response) {
|
|
11
|
+
if (response.status >= 400) console.error(await response.text());
|
|
12
|
+
}
|
|
13
|
+
async function getAuthorization(port) {
|
|
14
|
+
const indexResponse = await fetch(`http://localhost:${port}/.account/`);
|
|
15
|
+
const { controls } = await indexResponse.json();
|
|
16
|
+
const response = await fetch(controls.password.login, {
|
|
17
|
+
method: "POST",
|
|
18
|
+
headers: { "content-type": "application/json" },
|
|
19
|
+
body: JSON.stringify({
|
|
20
|
+
email: config.email,
|
|
21
|
+
password: config.password
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
await reportError(response);
|
|
25
|
+
const result = await response.json();
|
|
26
|
+
return result.authorization;
|
|
27
|
+
}
|
|
28
|
+
async function getSecret(port, authorization) {
|
|
29
|
+
const indexResponse = await fetch(`http://localhost:${port}/.account/`, { headers: { authorization: `CSS-Account-Token ${authorization}` } });
|
|
30
|
+
const { controls } = await indexResponse.json();
|
|
31
|
+
const response = await fetch(controls.account.clientCredentials, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
authorization: `CSS-Account-Token ${authorization}`,
|
|
35
|
+
"content-type": "application/json"
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
name: "my-token",
|
|
39
|
+
webId: `http://localhost:${port}/${config.podName}/profile/card#me`
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
await reportError(response);
|
|
43
|
+
const response2 = await response.json();
|
|
44
|
+
return response2;
|
|
45
|
+
}
|
|
46
|
+
async function getAccessToken(port, id, secret) {
|
|
47
|
+
try {
|
|
48
|
+
const dpopKey = await generateDpopKeyPair();
|
|
49
|
+
const authString = `${encodeURIComponent(id)}:${encodeURIComponent(secret)}`;
|
|
50
|
+
const tokenUrl = `http://localhost:${port}/.oidc/token`;
|
|
51
|
+
const response = await fetch(tokenUrl, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
headers: {
|
|
54
|
+
authorization: `Basic ${Buffer.from(authString).toString("base64")}`,
|
|
55
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
56
|
+
dpop: await createDpopHeader(tokenUrl, "POST", dpopKey)
|
|
57
|
+
},
|
|
58
|
+
body: "grant_type=client_credentials&scope=webid"
|
|
59
|
+
});
|
|
60
|
+
await reportError(response);
|
|
61
|
+
const response2 = await response.json();
|
|
62
|
+
return {
|
|
63
|
+
accessToken: response2.access_token,
|
|
64
|
+
dpopKey
|
|
65
|
+
};
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.error(err);
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function generateAuthFetch(port) {
|
|
72
|
+
const authorization = await getAuthorization(port);
|
|
73
|
+
const { id, secret } = await getSecret(port, authorization);
|
|
74
|
+
const { accessToken, dpopKey } = await getAccessToken(port, id, secret);
|
|
75
|
+
return await buildAuthenticatedFetch(accessToken, { dpopKey });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
export { generateAuthFetch };
|
|
80
|
+
//# sourceMappingURL=authFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authFetch.js","names":["response: Response","port: number","authorization: string","id: string","secret: string"],"sources":["../src/authFetch.ts"],"sourcesContent":["import type { KeyPair } from \"@inrupt/solid-client-authn-core\";\nimport {\n buildAuthenticatedFetch,\n createDpopHeader,\n generateDpopKeyPair,\n} from \"@inrupt/solid-client-authn-core\";\nimport fetch from \"cross-fetch\";\n\nconst config = {\n podName: \"example\",\n email: \"hello@example.com\",\n password: \"abc123\",\n};\n\nasync function reportError(response: Response) {\n if (response.status >= 400) {\n console.error(await response.text());\n }\n}\n\nasync function getAuthorization(port: number): Promise<string> {\n // First we request the account API controls to find out where we can log in\n const indexResponse = await fetch(`http://localhost:${port}/.account/`);\n const { controls } = await indexResponse.json();\n\n // And then we log in to the account API\n const response = await fetch(controls.password.login, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n email: config.email,\n password: config.password,\n }),\n });\n // This authorization value will be used to authenticate in the next step\n await reportError(response);\n const result = await response.json();\n return result.authorization;\n}\n\nasync function getSecret(\n port: number,\n authorization: string,\n): Promise<{ id: string; secret: string; resource: string }> {\n // Now that we are logged in, we need to request the updated controls from the server.\n // These will now have more values than in the previous example.\n const indexResponse = await fetch(`http://localhost:${port}/.account/`, {\n headers: { authorization: `CSS-Account-Token ${authorization}` },\n });\n const { controls } = await indexResponse.json();\n\n // Here we request the server to generate a token on our account\n const response = await fetch(controls.account.clientCredentials, {\n method: \"POST\",\n headers: {\n authorization: `CSS-Account-Token ${authorization}`,\n \"content-type\": \"application/json\",\n },\n // The name field will be used when generating the ID of your token.\n // The WebID field determines which WebID you will identify as when using the token.\n // Only WebIDs linked to your account can be used.\n body: JSON.stringify({\n name: \"my-token\",\n webId: `http://localhost:${port}/${config.podName}/profile/card#me`,\n }),\n });\n await reportError(response);\n // These are the identifier and secret of your token.\n // Store the secret somewhere safe as there is no way to request it again from the server!\n // The `resource` value can be used to delete the token at a later point in time.\n const response2 = await response.json();\n return response2;\n}\n\nasync function getAccessToken(\n port: number,\n id: string,\n secret: string,\n): Promise<{ accessToken: string; dpopKey: KeyPair }> {\n try {\n // A key pair is needed for encryption.\n // This function from `solid-client-authn` generates such a pair for you.\n const dpopKey = await generateDpopKeyPair();\n\n // These are the ID and secret generated in the previous step.\n // Both the ID and the secret need to be form-encoded.\n const authString = `${encodeURIComponent(id)}:${encodeURIComponent(\n secret,\n )}`;\n // This URL can be found by looking at the \"token_endpoint\" field at\n // http://localhost:PORT/.well-known/openid-configuration\n // if your server is hosted at http://localhost:3000/.\n const tokenUrl = `http://localhost:${port}/.oidc/token`;\n const response = await fetch(tokenUrl, {\n method: \"POST\",\n headers: {\n // The header needs to be in base64 encoding.\n authorization: `Basic ${Buffer.from(authString).toString(\"base64\")}`,\n \"content-type\": \"application/x-www-form-urlencoded\",\n dpop: await createDpopHeader(tokenUrl, \"POST\", dpopKey),\n },\n body: \"grant_type=client_credentials&scope=webid\",\n });\n await reportError(response);\n // This is the Access token that will be used to do an authenticated request to the server.\n // The JSON also contains an \"expires_in\" field in seconds,\n // which you can use to know when you need request a new Access token.\n const response2 = await response.json();\n return { accessToken: response2.access_token, dpopKey };\n } catch (err) {\n console.error(err);\n throw err;\n }\n}\n\nexport async function generateAuthFetch(port: number) {\n const authorization = await getAuthorization(port);\n const { id, secret } = await getSecret(port, authorization);\n const { accessToken, dpopKey } = await getAccessToken(port, id, secret);\n return await buildAuthenticatedFetch(accessToken, { dpopKey });\n}\n"],"mappings":";;;;AAQA,MAAM,SAAS;CACb,SAAS;CACT,OAAO;CACP,UAAU;AACX;AAED,eAAe,YAAYA,UAAoB;AAC7C,KAAI,SAAS,UAAU,IACrB,SAAQ,MAAM,MAAM,SAAS,MAAM,CAAC;AAEvC;AAED,eAAe,iBAAiBC,MAA+B;CAE7D,MAAM,gBAAgB,MAAM,OAAO,mBAAmB,KAAK,YAAY;CACvE,MAAM,EAAE,UAAU,GAAG,MAAM,cAAc,MAAM;CAG/C,MAAM,WAAW,MAAM,MAAM,SAAS,SAAS,OAAO;EACpD,QAAQ;EACR,SAAS,EAAE,gBAAgB,mBAAoB;EAC/C,MAAM,KAAK,UAAU;GACnB,OAAO,OAAO;GACd,UAAU,OAAO;EAClB,EAAC;CACH,EAAC;AAEF,OAAM,YAAY,SAAS;CAC3B,MAAM,SAAS,MAAM,SAAS,MAAM;AACpC,QAAO,OAAO;AACf;AAED,eAAe,UACbA,MACAC,eAC2D;CAG3D,MAAM,gBAAgB,MAAM,OAAO,mBAAmB,KAAK,aAAa,EACtE,SAAS,EAAE,gBAAgB,oBAAoB,cAAc,EAAG,EACjE,EAAC;CACF,MAAM,EAAE,UAAU,GAAG,MAAM,cAAc,MAAM;CAG/C,MAAM,WAAW,MAAM,MAAM,SAAS,QAAQ,mBAAmB;EAC/D,QAAQ;EACR,SAAS;GACP,gBAAgB,oBAAoB,cAAc;GAClD,gBAAgB;EACjB;EAID,MAAM,KAAK,UAAU;GACnB,MAAM;GACN,QAAQ,mBAAmB,KAAK,GAAG,OAAO,QAAQ;EACnD,EAAC;CACH,EAAC;AACF,OAAM,YAAY,SAAS;CAI3B,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,QAAO;AACR;AAED,eAAe,eACbD,MACAE,IACAC,QACoD;AACpD,KAAI;EAGF,MAAM,UAAU,MAAM,qBAAqB;EAI3C,MAAM,cAAc,EAAE,mBAAmB,GAAG,CAAC,GAAG,mBAC9C,OACD,CAAC;EAIF,MAAM,YAAY,mBAAmB,KAAK;EAC1C,MAAM,WAAW,MAAM,MAAM,UAAU;GACrC,QAAQ;GACR,SAAS;IAEP,gBAAgB,QAAQ,OAAO,KAAK,WAAW,CAAC,SAAS,SAAS,CAAC;IACnE,gBAAgB;IAChB,MAAM,MAAM,iBAAiB,UAAU,QAAQ,QAAQ;GACxD;GACD,MAAM;EACP,EAAC;AACF,QAAM,YAAY,SAAS;EAI3B,MAAM,YAAY,MAAM,SAAS,MAAM;AACvC,SAAO;GAAE,aAAa,UAAU;GAAc;EAAS;CACxD,SAAQ,KAAK;AACZ,UAAQ,MAAM,IAAI;AAClB,QAAM;CACP;AACF;AAED,eAAsB,kBAAkBH,MAAc;CACpD,MAAM,gBAAgB,MAAM,iBAAiB,KAAK;CAClD,MAAM,EAAE,IAAI,QAAQ,GAAG,MAAM,UAAU,MAAM,cAAc;CAC3D,MAAM,EAAE,aAAa,SAAS,GAAG,MAAM,eAAe,MAAM,IAAI,OAAO;AACvE,QAAO,MAAM,wBAAwB,aAAa,EAAE,QAAS,EAAC;AAC/D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const path = require_rolldown_runtime.__toESM(require("path"));
|
|
3
|
+
const __solid_community_server = require_rolldown_runtime.__toESM(require("@solid/community-server"));
|
|
4
|
+
const node_path = require_rolldown_runtime.__toESM(require("node:path"));
|
|
5
|
+
const node_url = require_rolldown_runtime.__toESM(require("node:url"));
|
|
6
|
+
|
|
7
|
+
//#region src/createServer.ts
|
|
8
|
+
const __dirname$1 = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
9
|
+
async function createApp(port, customConfigPath) {
|
|
10
|
+
if (process.env.SERVER) return {
|
|
11
|
+
start: () => {},
|
|
12
|
+
stop: () => {}
|
|
13
|
+
};
|
|
14
|
+
const appRunner = new __solid_community_server.AppRunner();
|
|
15
|
+
return appRunner.create({
|
|
16
|
+
loaderProperties: {
|
|
17
|
+
mainModulePath: (0, __solid_community_server.resolveModulePath)(""),
|
|
18
|
+
typeChecking: false
|
|
19
|
+
},
|
|
20
|
+
config: customConfigPath ?? (0, __solid_community_server.resolveModulePath)("config/file-root.json"),
|
|
21
|
+
variableBindings: {},
|
|
22
|
+
shorthand: {
|
|
23
|
+
port,
|
|
24
|
+
loggingLevel: "off",
|
|
25
|
+
seedConfig: path.join(__dirname$1, "configs", "solid-css-seed.json"),
|
|
26
|
+
rootFilePath: path.join(__dirname$1, `./data${port}`)
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.createApp = createApp;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { App } from "@solid/community-server";
|
|
2
|
+
|
|
3
|
+
//#region src/createServer.d.ts
|
|
4
|
+
declare function createApp(port: number, customConfigPath?: string): Promise<App>;
|
|
5
|
+
//# sourceMappingURL=createServer.d.ts.map
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { createApp };
|
|
9
|
+
//# sourceMappingURL=createServer.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createServer.d.cts","names":[],"sources":["../../src/createServer.ts"],"sourcesContent":[],"mappings":";;;iBAYsB,SAAA,2CAGnB,QAAQ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { App } from "@solid/community-server";
|
|
2
|
+
|
|
3
|
+
//#region src/createServer.d.ts
|
|
4
|
+
declare function createApp(port: number, customConfigPath?: string): Promise<App>;
|
|
5
|
+
//# sourceMappingURL=createServer.d.ts.map
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { createApp as createApp$1 };
|
|
9
|
+
//# sourceMappingURL=createServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createServer.d.ts","names":[],"sources":["../../src/createServer.ts"],"sourcesContent":[],"mappings":";;;iBAYsB,SAAA,2CAGnB,QAAQ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as path$1 from "path";
|
|
2
|
+
import { AppRunner, resolveModulePath } from "@solid/community-server";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
//#region src/createServer.ts
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
async function createApp(port, customConfigPath) {
|
|
9
|
+
if (process.env.SERVER) return {
|
|
10
|
+
start: () => {},
|
|
11
|
+
stop: () => {}
|
|
12
|
+
};
|
|
13
|
+
const appRunner = new AppRunner();
|
|
14
|
+
return appRunner.create({
|
|
15
|
+
loaderProperties: {
|
|
16
|
+
mainModulePath: resolveModulePath(""),
|
|
17
|
+
typeChecking: false
|
|
18
|
+
},
|
|
19
|
+
config: customConfigPath ?? resolveModulePath("config/file-root.json"),
|
|
20
|
+
variableBindings: {},
|
|
21
|
+
shorthand: {
|
|
22
|
+
port,
|
|
23
|
+
loggingLevel: "off",
|
|
24
|
+
seedConfig: path$1.join(__dirname, "configs", "solid-css-seed.json"),
|
|
25
|
+
rootFilePath: path$1.join(__dirname, `./data${port}`)
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { createApp };
|
|
32
|
+
//# sourceMappingURL=createServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createServer.js","names":["port: number","customConfigPath?: string"],"sources":["../src/createServer.ts"],"sourcesContent":["// Taken from https://github.com/comunica/comunica/blob/b237be4265c353a62a876187d9e21e3bc05123a3/engines/query-sparql/test/QuerySparql-solid-test.ts#L9\n\nimport * as path from \"path\";\nimport type { App } from \"@solid/community-server\";\nimport { AppRunner, resolveModulePath } from \"@solid/community-server\";\nimport { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport async function createApp(\n port: number,\n customConfigPath?: string,\n): Promise<App> {\n if (process.env.SERVER) {\n return {\n start: () => {},\n stop: () => {},\n } as App;\n }\n const appRunner = new AppRunner();\n\n return appRunner.create({\n loaderProperties: {\n mainModulePath: resolveModulePath(\"\"),\n typeChecking: false,\n },\n config: customConfigPath ?? resolveModulePath(\"config/file-root.json\"),\n variableBindings: {},\n shorthand: {\n port: port,\n loggingLevel: \"off\",\n seedConfig: path.join(__dirname, \"configs\", \"solid-css-seed.json\"),\n rootFilePath: path.join(__dirname, `./data${port}`),\n },\n });\n}\n"],"mappings":";;;;;;AAUA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,eAAsB,UACpBA,MACAC,kBACc;AACd,KAAI,QAAQ,IAAI,OACd,QAAO;EACL,OAAO,MAAM,CAAE;EACf,MAAM,MAAM,CAAE;CACf;CAEH,MAAM,YAAY,IAAI;AAEtB,QAAO,UAAU,OAAO;EACtB,kBAAkB;GAChB,gBAAgB,kBAAkB,GAAG;GACrC,cAAc;EACf;EACD,QAAQ,oBAAoB,kBAAkB,wBAAwB;EACtE,kBAAkB,CAAE;EACpB,WAAW;GACH;GACN,cAAc;GACd,YAAY,OAAK,KAAK,WAAW,WAAW,sBAAsB;GAClE,cAAc,OAAK,KAAK,YAAY,QAAQ,KAAK,EAAE;EACpD;CACF,EAAC;AACH"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_createServer = require('./createServer.cjs');
|
|
2
|
+
const require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_resourceUtils = require('./resourceUtils.cjs');
|
|
3
|
+
const require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_setupTestServer = require('./setupTestServer.cjs');
|
|
4
|
+
|
|
5
|
+
exports.cleanResources = require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_resourceUtils.cleanResources;
|
|
6
|
+
exports.createApp = require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_createServer.createApp;
|
|
7
|
+
exports.initResources = require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_resourceUtils.initResources;
|
|
8
|
+
exports.setupServer = require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_setupTestServer.setupServer;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createApp$1 as createApp } from "./createServer.js";
|
|
2
|
+
import { ResourceInfo, cleanResources$1 as cleanResources, initResources$1 as initResources } from "./resourceUtils.js";
|
|
3
|
+
import { setupServer$1 as setupServer } from "./setupTestServer.js";
|
|
4
|
+
export { ResourceInfo, cleanResources, createApp, initResources, setupServer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/resourceUtils.ts
|
|
3
|
+
async function initResources(rootUri, resourceInfo, authFetch) {
|
|
4
|
+
if (resourceInfo?.shouldNotInit) return;
|
|
5
|
+
if (resourceInfo.isContainer) {
|
|
6
|
+
await authFetch(rootUri, {
|
|
7
|
+
method: "POST",
|
|
8
|
+
headers: {
|
|
9
|
+
link: "<http://www.w3.org/ns/ldp#Container>; rel=\"type\"",
|
|
10
|
+
slug: resourceInfo.slug
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
await Promise.all(resourceInfo.contains.map((subResourceInfo) => initResources(`${rootUri}${resourceInfo.slug}`, subResourceInfo, authFetch)));
|
|
14
|
+
} else await authFetch(`${rootUri}${resourceInfo.slug}`, {
|
|
15
|
+
method: "PUT",
|
|
16
|
+
headers: { "content-type": resourceInfo.mimeType },
|
|
17
|
+
body: resourceInfo.data
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async function cleanResources(rootUri, resourceInfo, authFetch) {
|
|
21
|
+
if (resourceInfo.isContainer) {
|
|
22
|
+
await Promise.all(resourceInfo.contains.map((subResourceInfo) => cleanResources(`${rootUri}${resourceInfo.slug}`, subResourceInfo, authFetch)));
|
|
23
|
+
await authFetch(`${rootUri}${resourceInfo.slug}`, { method: "DELETE" });
|
|
24
|
+
} else await authFetch(`${rootUri}${resourceInfo.slug}`, { method: "DELETE" });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.cleanResources = cleanResources;
|
|
29
|
+
exports.initResources = initResources;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/resourceUtils.d.ts
|
|
2
|
+
type ResourceInfo = ContainerInfo | LeafInfo;
|
|
3
|
+
interface ContainerInfo {
|
|
4
|
+
slug: string;
|
|
5
|
+
isContainer: true;
|
|
6
|
+
shouldNotInit?: boolean;
|
|
7
|
+
contains: (ContainerInfo | LeafInfo)[];
|
|
8
|
+
}
|
|
9
|
+
interface LeafInfo {
|
|
10
|
+
slug: string;
|
|
11
|
+
isContainer: false;
|
|
12
|
+
data: string;
|
|
13
|
+
shouldNotInit?: boolean;
|
|
14
|
+
mimeType: string;
|
|
15
|
+
}
|
|
16
|
+
declare function initResources(rootUri: string, resourceInfo: ResourceInfo, authFetch: typeof fetch): Promise<void>;
|
|
17
|
+
declare function cleanResources(rootUri: string, resourceInfo: ResourceInfo, authFetch: typeof fetch): Promise<void>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ResourceInfo, cleanResources, initResources };
|
|
20
|
+
//# sourceMappingURL=resourceUtils.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceUtils.d.cts","names":[],"sources":["../../src/resourceUtils.ts"],"sourcesContent":[],"mappings":";KAAY,YAAA,GAAe,gBAAgB;AAA3C,UAEU,aAAA,CAFc;EAAA,IAAA,EAAA,MAAA;EAAA,WAAG,EAAA,IAAA;EAAa,aAAG,CAAA,EAAA,OAAA;EAAQ,QAAA,EAAA,CAMtC,aANsC,GAMtB,QANsB,CAAA,EAAA;AAAC;UAS1C,QAAA,CAPa;EAAA,IAIV,EAAA,MAAA;EAAa,WAAG,EAAA,KAAA;EAAQ,IAAA,EAAA,MAAA;EAG3B,aAAQ,CAAA,EAAA,OAAA;EAQI,QAAA,EAAA,MAAa;;AAEnB,iBAFM,aAAA,CAEN,OAAA,EAAA,MAAA,EAAA,YAAA,EAAA,YAAA,EAAA,SAAA,EAAA,OACI,KADJ,CAAA,EAEb,OAFa,CAAA,IAAA,CAAA;AACI,iBA+BE,cAAA,CA/BF,OAAA,EAAA,MAAA,EAAA,YAAA,EAiCJ,YAjCI,EAAA,SAAA,EAAA,OAkCA,KAlCA,CAAA,EAmCjB,OAnCiB,CAAA,IAAA,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/resourceUtils.d.ts
|
|
2
|
+
type ResourceInfo = ContainerInfo | LeafInfo;
|
|
3
|
+
interface ContainerInfo {
|
|
4
|
+
slug: string;
|
|
5
|
+
isContainer: true;
|
|
6
|
+
shouldNotInit?: boolean;
|
|
7
|
+
contains: (ContainerInfo | LeafInfo)[];
|
|
8
|
+
}
|
|
9
|
+
interface LeafInfo {
|
|
10
|
+
slug: string;
|
|
11
|
+
isContainer: false;
|
|
12
|
+
data: string;
|
|
13
|
+
shouldNotInit?: boolean;
|
|
14
|
+
mimeType: string;
|
|
15
|
+
}
|
|
16
|
+
declare function initResources(rootUri: string, resourceInfo: ResourceInfo, authFetch: typeof fetch): Promise<void>;
|
|
17
|
+
declare function cleanResources(rootUri: string, resourceInfo: ResourceInfo, authFetch: typeof fetch): Promise<void>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ResourceInfo, cleanResources as cleanResources$1, initResources as initResources$1 };
|
|
20
|
+
//# sourceMappingURL=resourceUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceUtils.d.ts","names":[],"sources":["../../src/resourceUtils.ts"],"sourcesContent":[],"mappings":";KAAY,YAAA,GAAe,gBAAgB;AAA3C,UAEU,aAAA,CAFc;EAAA,IAAA,EAAA,MAAA;EAAA,WAAG,EAAA,IAAA;EAAa,aAAG,CAAA,EAAA,OAAA;EAAQ,QAAA,EAAA,CAMtC,aANsC,GAMtB,QANsB,CAAA,EAAA;AAAC;UAS1C,QAAA,CAPa;EAAA,IAIV,EAAA,MAAA;EAAa,WAAG,EAAA,KAAA;EAAQ,IAAA,EAAA,MAAA;EAG3B,aAAQ,CAAA,EAAA,OAAA;EAQI,QAAA,EAAA,MAAa;;AAEnB,iBAFM,aAAA,CAEN,OAAA,EAAA,MAAA,EAAA,YAAA,EAAA,YAAA,EAAA,SAAA,EAAA,OACI,KADJ,CAAA,EAEb,OAFa,CAAA,IAAA,CAAA;AACI,iBA+BE,cAAA,CA/BF,OAAA,EAAA,MAAA,EAAA,YAAA,EAiCJ,YAjCI,EAAA,SAAA,EAAA,OAkCA,KAlCA,CAAA,EAmCjB,OAnCiB,CAAA,IAAA,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/resourceUtils.ts
|
|
2
|
+
async function initResources(rootUri, resourceInfo, authFetch) {
|
|
3
|
+
if (resourceInfo?.shouldNotInit) return;
|
|
4
|
+
if (resourceInfo.isContainer) {
|
|
5
|
+
await authFetch(rootUri, {
|
|
6
|
+
method: "POST",
|
|
7
|
+
headers: {
|
|
8
|
+
link: "<http://www.w3.org/ns/ldp#Container>; rel=\"type\"",
|
|
9
|
+
slug: resourceInfo.slug
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
await Promise.all(resourceInfo.contains.map((subResourceInfo) => initResources(`${rootUri}${resourceInfo.slug}`, subResourceInfo, authFetch)));
|
|
13
|
+
} else await authFetch(`${rootUri}${resourceInfo.slug}`, {
|
|
14
|
+
method: "PUT",
|
|
15
|
+
headers: { "content-type": resourceInfo.mimeType },
|
|
16
|
+
body: resourceInfo.data
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async function cleanResources(rootUri, resourceInfo, authFetch) {
|
|
20
|
+
if (resourceInfo.isContainer) {
|
|
21
|
+
await Promise.all(resourceInfo.contains.map((subResourceInfo) => cleanResources(`${rootUri}${resourceInfo.slug}`, subResourceInfo, authFetch)));
|
|
22
|
+
await authFetch(`${rootUri}${resourceInfo.slug}`, { method: "DELETE" });
|
|
23
|
+
} else await authFetch(`${rootUri}${resourceInfo.slug}`, { method: "DELETE" });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { cleanResources, initResources };
|
|
28
|
+
//# sourceMappingURL=resourceUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceUtils.js","names":["rootUri: string","resourceInfo: ResourceInfo","authFetch: typeof fetch"],"sources":["../src/resourceUtils.ts"],"sourcesContent":["export type ResourceInfo = ContainerInfo | LeafInfo;\n\ninterface ContainerInfo {\n slug: string;\n isContainer: true;\n shouldNotInit?: boolean;\n contains: (ContainerInfo | LeafInfo)[];\n}\n\ninterface LeafInfo {\n slug: string;\n isContainer: false;\n data: string;\n shouldNotInit?: boolean;\n mimeType: string;\n}\n\nexport async function initResources(\n rootUri: string,\n resourceInfo: ResourceInfo,\n authFetch: typeof fetch,\n): Promise<void> {\n if (resourceInfo?.shouldNotInit) return;\n if (resourceInfo.isContainer) {\n await authFetch(rootUri, {\n method: \"POST\",\n headers: {\n link: '<http://www.w3.org/ns/ldp#Container>; rel=\"type\"',\n slug: resourceInfo.slug,\n },\n });\n await Promise.all(\n resourceInfo.contains.map((subResourceInfo) =>\n initResources(\n `${rootUri}${resourceInfo.slug}`,\n subResourceInfo,\n authFetch,\n ),\n ),\n );\n } else {\n await authFetch(`${rootUri}${resourceInfo.slug}`, {\n method: \"PUT\",\n headers: {\n \"content-type\": resourceInfo.mimeType,\n },\n body: resourceInfo.data,\n });\n }\n}\n\nexport async function cleanResources(\n rootUri: string,\n resourceInfo: ResourceInfo,\n authFetch: typeof fetch,\n): Promise<void> {\n if (resourceInfo.isContainer) {\n await Promise.all(\n resourceInfo.contains.map((subResourceInfo) =>\n cleanResources(\n `${rootUri}${resourceInfo.slug}`,\n subResourceInfo,\n authFetch,\n ),\n ),\n );\n await authFetch(`${rootUri}${resourceInfo.slug}`, {\n method: \"DELETE\",\n });\n } else {\n await authFetch(`${rootUri}${resourceInfo.slug}`, {\n method: \"DELETE\",\n });\n }\n}\n"],"mappings":";AAiBA,eAAsB,cACpBA,SACAC,cACAC,WACe;AACf,KAAI,cAAc,cAAe;AACjC,KAAI,aAAa,aAAa;AAC5B,QAAM,UAAU,SAAS;GACvB,QAAQ;GACR,SAAS;IACP,MAAM;IACN,MAAM,aAAa;GACpB;EACF,EAAC;AACF,QAAM,QAAQ,IACZ,aAAa,SAAS,IAAI,CAAC,oBACzB,eACG,EAAE,QAAQ,EAAE,aAAa,KAAK,GAC/B,iBACA,UACD,CACF,CACF;CACF,MACC,OAAM,WAAW,EAAE,QAAQ,EAAE,aAAa,KAAK,GAAG;EAChD,QAAQ;EACR,SAAS,EACP,gBAAgB,aAAa,SAC9B;EACD,MAAM,aAAa;CACpB,EAAC;AAEL;AAED,eAAsB,eACpBF,SACAC,cACAC,WACe;AACf,KAAI,aAAa,aAAa;AAC5B,QAAM,QAAQ,IACZ,aAAa,SAAS,IAAI,CAAC,oBACzB,gBACG,EAAE,QAAQ,EAAE,aAAa,KAAK,GAC/B,iBACA,UACD,CACF,CACF;AACD,QAAM,WAAW,EAAE,QAAQ,EAAE,aAAa,KAAK,GAAG,EAChD,QAAQ,SACT,EAAC;CACH,MACC,OAAM,WAAW,EAAE,QAAQ,EAAE,aAAa,KAAK,GAAG,EAChD,QAAQ,SACT,EAAC;AAEL"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_createServer = require('./createServer.cjs');
|
|
3
|
+
const require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_resourceUtils = require('./resourceUtils.cjs');
|
|
4
|
+
const require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_authFetch = require('./authFetch.cjs');
|
|
5
|
+
const path = require_rolldown_runtime.__toESM(require("path"));
|
|
6
|
+
const node_path = require_rolldown_runtime.__toESM(require("node:path"));
|
|
7
|
+
const node_url = require_rolldown_runtime.__toESM(require("node:url"));
|
|
8
|
+
const fs_promises = require_rolldown_runtime.__toESM(require("fs/promises"));
|
|
9
|
+
const vitest = require_rolldown_runtime.__toESM(require("vitest"));
|
|
10
|
+
|
|
11
|
+
//#region src/setupTestServer.ts
|
|
12
|
+
const __dirname$1 = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
13
|
+
vitest.vi.setConfig({
|
|
14
|
+
testTimeout: 4e4,
|
|
15
|
+
hookTimeout: 4e4
|
|
16
|
+
});
|
|
17
|
+
function setupServer(port, resourceInfo, customConfigPath, skipAuthentication) {
|
|
18
|
+
const data = { rootUri: `http://localhost:${port}/` };
|
|
19
|
+
let previousJestId;
|
|
20
|
+
let previousNodeEnv;
|
|
21
|
+
(0, vitest.beforeAll)(async () => {
|
|
22
|
+
process.env.NODE_ENV = "other_test";
|
|
23
|
+
data.app = await require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_createServer.createApp(port, customConfigPath);
|
|
24
|
+
await data.app.start();
|
|
25
|
+
data.authFetch = skipAuthentication ? fetch : await require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_authFetch.generateAuthFetch(port);
|
|
26
|
+
});
|
|
27
|
+
(0, vitest.afterAll)(async () => {
|
|
28
|
+
try {
|
|
29
|
+
await Promise.race([data.app.stop?.(), new Promise((_, reject) => setTimeout(() => reject(new Error("Shutdown timeout")), 1e4))]);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
console.warn("⚠️ Ignoring shutdown error in CI:", err.message);
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const testDataPath = path.default.join(__dirname$1, `./data${port}`);
|
|
35
|
+
await fs_promises.default.rm(testDataPath, {
|
|
36
|
+
recursive: true,
|
|
37
|
+
force: true
|
|
38
|
+
});
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.warn("⚠️ Ignoring data cleanup error in CI:", err.message);
|
|
41
|
+
}
|
|
42
|
+
process.env.JEST_WORKER_ID = previousJestId;
|
|
43
|
+
process.env.NODE_ENV = previousNodeEnv;
|
|
44
|
+
});
|
|
45
|
+
(0, vitest.beforeEach)(async () => {
|
|
46
|
+
data.fetchMock = vitest.vi.fn(data.authFetch);
|
|
47
|
+
await require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_resourceUtils.initResources(data.rootUri, resourceInfo, data.authFetch);
|
|
48
|
+
});
|
|
49
|
+
(0, vitest.afterEach)(async () => {
|
|
50
|
+
await require__Users_jacksonmorgan_O_ldo_packages_test_solid_server_src_resourceUtils.cleanResources(data.rootUri, resourceInfo, data.authFetch);
|
|
51
|
+
});
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
exports.setupServer = setupServer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ResourceInfo } from "./resourceUtils.cjs";
|
|
2
|
+
import { App } from "@solid/community-server";
|
|
3
|
+
import { MockedFunction } from "vitest";
|
|
4
|
+
|
|
5
|
+
//#region src/setupTestServer.d.ts
|
|
6
|
+
declare function setupServer(port: number, resourceInfo: ResourceInfo, customConfigPath?: string, skipAuthentication?: boolean): {
|
|
7
|
+
app: App;
|
|
8
|
+
fetchMock: MockedFunction<(input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>>;
|
|
9
|
+
authFetch: typeof fetch;
|
|
10
|
+
rootUri: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=setupTestServer.d.ts.map
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { setupServer };
|
|
16
|
+
//# sourceMappingURL=setupTestServer.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTestServer.d.cts","names":[],"sources":["../../src/setupTestServer.ts"],"sourcesContent":[],"mappings":";;;;;iBA0BgB,WAAA,6BAEA;OAKP;EAPO,SAAA,EAQD,cARY,CAAA,CAAA,KAAA,EAUZ,WAVY,GAUE,GAVF,EAAA,IAAA,CAAA,EAWZ,WAXY,GAAA,SAAA,EAAA,GAYhB,OAZgB,CAYR,QAZQ,CAAA,CAAA;EAAA,SAAA,EAAA,OAcL,KAdK;EAAA,OAEX,EAAA,MAAA;CAAY"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ResourceInfo } from "./resourceUtils.js";
|
|
2
|
+
import { App } from "@solid/community-server";
|
|
3
|
+
import { MockedFunction } from "vitest";
|
|
4
|
+
|
|
5
|
+
//#region src/setupTestServer.d.ts
|
|
6
|
+
declare function setupServer(port: number, resourceInfo: ResourceInfo, customConfigPath?: string, skipAuthentication?: boolean): {
|
|
7
|
+
app: App;
|
|
8
|
+
fetchMock: MockedFunction<(input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>>;
|
|
9
|
+
authFetch: typeof fetch;
|
|
10
|
+
rootUri: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=setupTestServer.d.ts.map
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { setupServer as setupServer$1 };
|
|
16
|
+
//# sourceMappingURL=setupTestServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTestServer.d.ts","names":[],"sources":["../../src/setupTestServer.ts"],"sourcesContent":[],"mappings":";;;;;iBA0BgB,WAAA,6BAEA;OAKP;EAPO,SAAA,EAQD,cARY,CAAA,CAAA,KAAA,EAUZ,WAVY,GAUE,GAVF,EAAA,IAAA,CAAA,EAWZ,WAXY,GAAA,SAAA,EAAA,GAYhB,OAZgB,CAYR,QAZQ,CAAA,CAAA;EAAA,SAAA,EAAA,OAcL,KAdK;EAAA,OAEX,EAAA,MAAA;CAAY"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createApp } from "./createServer.js";
|
|
2
|
+
import { cleanResources, initResources } from "./resourceUtils.js";
|
|
3
|
+
import { generateAuthFetch } from "./authFetch.js";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { dirname } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import fs from "fs/promises";
|
|
8
|
+
import { afterAll, afterEach, beforeAll, beforeEach, vi } from "vitest";
|
|
9
|
+
|
|
10
|
+
//#region src/setupTestServer.ts
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
vi.setConfig({
|
|
13
|
+
testTimeout: 4e4,
|
|
14
|
+
hookTimeout: 4e4
|
|
15
|
+
});
|
|
16
|
+
function setupServer(port, resourceInfo, customConfigPath, skipAuthentication) {
|
|
17
|
+
const data = { rootUri: `http://localhost:${port}/` };
|
|
18
|
+
let previousJestId;
|
|
19
|
+
let previousNodeEnv;
|
|
20
|
+
beforeAll(async () => {
|
|
21
|
+
process.env.NODE_ENV = "other_test";
|
|
22
|
+
data.app = await createApp(port, customConfigPath);
|
|
23
|
+
await data.app.start();
|
|
24
|
+
data.authFetch = skipAuthentication ? fetch : await generateAuthFetch(port);
|
|
25
|
+
});
|
|
26
|
+
afterAll(async () => {
|
|
27
|
+
try {
|
|
28
|
+
await Promise.race([data.app.stop?.(), new Promise((_, reject) => setTimeout(() => reject(new Error("Shutdown timeout")), 1e4))]);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.warn("⚠️ Ignoring shutdown error in CI:", err.message);
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const testDataPath = path.join(__dirname, `./data${port}`);
|
|
34
|
+
await fs.rm(testDataPath, {
|
|
35
|
+
recursive: true,
|
|
36
|
+
force: true
|
|
37
|
+
});
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.warn("⚠️ Ignoring data cleanup error in CI:", err.message);
|
|
40
|
+
}
|
|
41
|
+
process.env.JEST_WORKER_ID = previousJestId;
|
|
42
|
+
process.env.NODE_ENV = previousNodeEnv;
|
|
43
|
+
});
|
|
44
|
+
beforeEach(async () => {
|
|
45
|
+
data.fetchMock = vi.fn(data.authFetch);
|
|
46
|
+
await initResources(data.rootUri, resourceInfo, data.authFetch);
|
|
47
|
+
});
|
|
48
|
+
afterEach(async () => {
|
|
49
|
+
await cleanResources(data.rootUri, resourceInfo, data.authFetch);
|
|
50
|
+
});
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { setupServer };
|
|
56
|
+
//# sourceMappingURL=setupTestServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTestServer.js","names":["port: number","resourceInfo: ResourceInfo","customConfigPath?: string","skipAuthentication?: boolean","data: {\n app: App;\n fetchMock: MockedFunction<\n (\n input: RequestInfo | URL,\n init?: RequestInit | undefined,\n ) => Promise<Response>\n >;\n authFetch: typeof fetch;\n rootUri: string;\n }","previousJestId: string | undefined","previousNodeEnv: string | undefined"],"sources":["../src/setupTestServer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { App } from \"@solid/community-server\";\nimport { createApp } from \"./createServer\";\nimport path from \"path\";\nimport type { ResourceInfo } from \"./resourceUtils\";\nimport { cleanResources, initResources } from \"./resourceUtils\";\nimport { generateAuthFetch } from \"./authFetch\";\nimport fs from \"fs/promises\";\nimport {\n beforeAll,\n afterAll,\n beforeEach,\n afterEach,\n vi,\n type MockedFunction,\n} from \"vitest\";\nimport { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n// Use an increased timeout, since the CSS server takes too much setup time.\nvi.setConfig({ testTimeout: 40_000, hookTimeout: 40_000 });\n\nexport function setupServer(\n port: number,\n resourceInfo: ResourceInfo,\n customConfigPath?: string,\n skipAuthentication?: boolean,\n) {\n const data: {\n app: App;\n fetchMock: MockedFunction<\n (\n input: RequestInfo | URL,\n init?: RequestInit | undefined,\n ) => Promise<Response>\n >;\n authFetch: typeof fetch;\n rootUri: string;\n } = {\n rootUri: `http://localhost:${port}/`,\n } as any;\n\n let previousJestId: string | undefined;\n let previousNodeEnv: string | undefined;\n beforeAll(async () => {\n // Remove Jest ID so that community solid server doesn't use the Jest Import\n process.env.NODE_ENV = \"other_test\";\n // Start up the server\n data.app = await createApp(port, customConfigPath);\n await data.app.start();\n data.authFetch = skipAuthentication ? fetch : await generateAuthFetch(port);\n });\n\n afterAll(async () => {\n // We're potentially ignoring data clean up and server shutdown because\n // sometimes this doesn't work in CI.\n try {\n await Promise.race([\n data.app.stop?.(),\n new Promise((_, reject) =>\n setTimeout(() => reject(new Error(\"Shutdown timeout\")), 10000),\n ),\n ]);\n } catch (err) {\n console.warn(\"⚠️ Ignoring shutdown error in CI:\", (err as Error).message);\n }\n\n try {\n const testDataPath = path.join(__dirname, `./data${port}`);\n await fs.rm(testDataPath, { recursive: true, force: true });\n } catch (err) {\n console.warn(\n \"⚠️ Ignoring data cleanup error in CI:\",\n (err as Error).message,\n );\n }\n\n process.env.JEST_WORKER_ID = previousJestId;\n process.env.NODE_ENV = previousNodeEnv;\n });\n\n beforeEach(async () => {\n data.fetchMock = vi.fn(data.authFetch);\n // Create a new document called sample.ttl\n await initResources(data.rootUri, resourceInfo, data.authFetch);\n });\n\n afterEach(async () => {\n await cleanResources(data.rootUri, resourceInfo, data.authFetch);\n });\n\n return data;\n}\n"],"mappings":";;;;;;;;;;AAqBA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAGzD,GAAG,UAAU;CAAE,aAAa;CAAQ,aAAa;AAAQ,EAAC;AAE1D,SAAgB,YACdA,MACAC,cACAC,kBACAC,oBACA;CACA,MAAMC,OAUF,EACF,UAAU,mBAAmB,KAAK,GACnC;CAED,IAAIC;CACJ,IAAIC;AACJ,WAAU,YAAY;AAEpB,UAAQ,IAAI,WAAW;AAEvB,OAAK,MAAM,MAAM,UAAU,MAAM,iBAAiB;AAClD,QAAM,KAAK,IAAI,OAAO;AACtB,OAAK,YAAY,qBAAqB,QAAQ,MAAM,kBAAkB,KAAK;CAC5E,EAAC;AAEF,UAAS,YAAY;AAGnB,MAAI;AACF,SAAM,QAAQ,KAAK,CACjB,KAAK,IAAI,QAAQ,EACjB,IAAI,QAAQ,CAAC,GAAG,WACd,WAAW,MAAM,OAAO,IAAI,MAAM,oBAAoB,EAAE,IAAM,CAEjE,EAAC;EACH,SAAQ,KAAK;AACZ,WAAQ,KAAK,qCAAsC,IAAc,QAAQ;EAC1E;AAED,MAAI;GACF,MAAM,eAAe,KAAK,KAAK,YAAY,QAAQ,KAAK,EAAE;AAC1D,SAAM,GAAG,GAAG,cAAc;IAAE,WAAW;IAAM,OAAO;GAAM,EAAC;EAC5D,SAAQ,KAAK;AACZ,WAAQ,KACN,yCACC,IAAc,QAChB;EACF;AAED,UAAQ,IAAI,iBAAiB;AAC7B,UAAQ,IAAI,WAAW;CACxB,EAAC;AAEF,YAAW,YAAY;AACrB,OAAK,YAAY,GAAG,GAAG,KAAK,UAAU;AAEtC,QAAM,cAAc,KAAK,SAAS,cAAc,KAAK,UAAU;CAChE,EAAC;AAEF,WAAU,YAAY;AACpB,QAAM,eAAe,KAAK,SAAS,cAAc,KAAK,UAAU;CACjE,EAAC;AAEF,QAAO;AACR"}
|