Before attempted vitest conversion

main
Jackson Morgan 4 months ago
parent 6830180b7c
commit 3ecbbe072a
  1. 31
      jest.esm.config.js
  2. 3
      packages/connected-solid/babel.config.cjs
  3. 1
      packages/connected-solid/babel.config.js
  4. 9
      packages/connected-solid/jest.config.cjs
  5. 10
      packages/connected-solid/jest.config.js
  6. 18
      packages/connected-solid/package.json
  7. 6
      packages/connected-solid/src/requester/requests/createDataResource.ts
  8. 5
      packages/connected-solid/src/requester/requests/readResource.ts
  9. 6
      packages/connected-solid/src/requester/requests/uploadResource.ts
  10. 7
      packages/connected-solid/test/Integration.test.ts
  11. 2
      packages/connected-solid/test/RequestBatcher.test.ts
  12. 2
      packages/connected-solid/test/uriTypes.test.ts
  13. 7
      packages/connected-solid/tsconfig.build.json
  14. 10
      packages/connected-solid/tsconfig.cjs.json
  15. 14
      packages/connected-solid/tsconfig.esm.json
  16. 19
      packages/connected-solid/tsconfig.test.json
  17. 14
      packages/connected/jest.config.cjs
  18. 10
      packages/connected/jest.config.js
  19. 7
      packages/connected/package.json
  20. 4
      packages/connected/src/Resource.ts
  21. 4
      packages/connected/src/types/ILinkQuery.ts
  22. 2
      packages/connected/test/.ldo/solidProfile.shapeTypes.ts
  23. 6
      packages/connected/test/LinkTraversalIntegration.test.ts
  24. 9
      packages/connected/test/mocks/MockResource.ts
  25. 5
      packages/connected/tsconfig.cjs.json
  26. 6
      packages/connected/tsconfig.esm.json
  27. 11
      packages/test-solid-server/src/authFetch.ts

@ -0,0 +1,31 @@
/* eslint-disable @typescript-eslint/no-var-requires */
// jest.esm.config.js
const path = require("path");
const monorepoRoot = path.resolve(__dirname);
module.exports = {
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
extensionsToTreatAsEsm: [".ts"],
transform: {
"^.+\\.ts$": [
"ts-jest",
{
useESM: true,
tsconfig: "<rootDir>/tsconfig.esm.json",
},
],
},
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transformIgnorePatterns: ["/node_modules/", "/dist/"],
modulePathIgnorePatterns: ["/dist/"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
coveragePathIgnorePatterns: [
"/node_modules/",
"/dist/",
"/coverage/",
"/test/",
],
};

@ -0,0 +1,3 @@
module.exports = {
presets: [["@babel/preset-env", { targets: { node: "current" } }]],
};

@ -1 +0,0 @@
module.exports = { presets: ["@babel/preset-env"] };

@ -0,0 +1,9 @@
/* eslint-disable @typescript-eslint/no-var-requires */
// packages/connected-solid/jest.config.cjs
const sharedConfig = require("../../jest.esm.config.js");
module.exports = {
...sharedConfig,
rootDir: "./",
collectCoverageFrom: ["src/**/*.ts", "!src/**/*.d.ts"],
};

@ -1,10 +0,0 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const sharedConfig = require("../../jest.config.js");
module.exports = {
...sharedConfig,
rootDir: "./",
transform: {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest",
},
};

@ -2,10 +2,22 @@
"name": "@ldo/connected-solid",
"version": "1.0.0-alpha.9",
"description": "A plugin for @ldo/connected to work with the Solid ecosystem.",
"main": "dist/index.js",
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"build": "tsc --project tsconfig.build.json",
"watch": "tsc --project tsconfig.build.json --watch",
"build": "rimraf dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"test:watch": "jest --watch",
"prepublishOnly": "npm run test && npm run build",

@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { guaranteeFetch } from "../../util/guaranteeFetch.js";
import { guaranteeFetch } from "../../util/guaranteeFetch.js";
import type { AbsentReadSuccess, Resource } from "@ldo/connected";
import { UnexpectedResourceError } from "@ldo/connected";
import type { HttpErrorResultType } from "../results/error/HttpErrorResult.js";
@ -17,6 +16,11 @@ import { readResource } from "./readResource.js";
import type { DatasetRequestOptions } from "./requestOptions.js";
import type { SolidLeaf } from "../../resources/SolidLeaf.js";
import type { SolidContainer } from "../../resources/SolidContainer.js";
import {
addResourceRdfToContainer,
getParentUri,
getSlug,
} from "../../util/rdfUtils.js";
/**
* All possible return values when creating and overwriting a container

@ -3,7 +3,6 @@ import {
HttpErrorResult,
type HttpErrorResultType,
} from "../results/error/HttpErrorResult.js";
$1$2.js$3
import type { DatasetRequestOptions } from "./requestOptions.js";
import {
BinaryReadSuccess,
@ -18,6 +17,10 @@ import { checkHeadersForRootContainer } from "./checkRootContainer.js";
import { namedNode } from "@rdfjs/data-model";
import type { SolidLeaf } from "../../resources/SolidLeaf.js";
import type { SolidContainer } from "../../resources/SolidContainer.js";
import {
addRawTurtleToDataset,
addResourceRdfToContainer,
} from "../../util/rdfUtils.js";
/**
* All possible return values for reading a leaf

@ -1,5 +1,4 @@
import { guaranteeFetch } from "../../util/guaranteeFetch.js";
import { guaranteeFetch } from "../../util/guaranteeFetch.js";
import { UnexpectedResourceError } from "@ldo/connected";
import { HttpErrorResult } from "../results/error/HttpErrorResult.js";
import type {
@ -11,6 +10,11 @@ import { readResource } from "./readResource.js";
import type { DatasetRequestOptions } from "./requestOptions.js";
import type { SolidLeaf } from "../../resources/SolidLeaf.js";
import { CreateSuccess } from "../results/success/CreateSuccess.js";
import {
addResourceRdfToContainer,
getParentUri,
getSlug,
} from "../../util/rdfUtils.js";
/**
* @internal

@ -16,7 +16,11 @@ import type { NoncompliantPodError } from "../src/requester/results/error/Noncom
import type { GetStorageContainerFromWebIdSuccess } from "../src/requester/results/success/CheckRootContainerSuccess.js";
import { wait } from "./utils.helper.js";
import path from "path";
import type { GetWacRuleSuccess, UpdateResultError, WacRule } from "../src/index.js";
import type {
GetWacRuleSuccess,
UpdateResultError,
WacRule,
} from "../src/index.js";
import {
createSolidLdoDataset,
type SolidConnectedPlugin,
@ -43,6 +47,7 @@ import {
import { getStorageFromWebId } from "../src/getStorageFromWebId.js";
import type { ResourceInfo } from "@ldo/test-solid-server";
import { createApp, setupServer } from "@ldo/test-solid-server";
import { jest } from "@jest/globals";
const ROOT_CONTAINER = "http://localhost:3001/";
const WEB_ID = "http://localhost:3001/example/profile/card#me";

@ -1,6 +1,8 @@
import type { WaitingProcess } from "../src/util/RequestBatcher.js";
import { RequestBatcher } from "../src/util/RequestBatcher.js";
import { jest } from "@jest/globals";
describe("RequestBatcher", () => {
type ReadWaitingProcess = WaitingProcess<[string], string>;

@ -1,4 +1,4 @@
import { isSolidLeafUri } from "../src/index.js";
import { isSolidLeafUri } from "../src/util/isSolidUri";
describe("isLeafUri", () => {
it("returns true if the given value is a leaf URI", () => {

@ -1,7 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
},
"include": ["./src"]
}

@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.cjs.json",
"compilerOptions": {
"outDir": "./dist/cjs",
"rootDir": "./src"
},
"include": [
"src"
]
}

@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"outDir": "./dist/esm",
"rootDir": "./src",
"declarationDir": "./dist/types",
"types": [
"jest"
]
},
"include": [
"src"
]
}

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"moduleDetection": "force",
"esModuleInterop": true,
"strict": true,
"resolveJsonModule": true,
"allowJs": false,
"isolatedModules": true,
"sourceMap": true,
"outDir": "./dist"
},
"include": [
"src",
"test"
]
}

@ -0,0 +1,14 @@
/* eslint-disable @typescript-eslint/no-var-requires */
// packages/dataset/jest.config.cjs
const sharedConfig = require("../../jest.config.js");
module.exports = {
...sharedConfig,
rootDir: "./", // Sets context for this package
collectCoverageFrom: [
"src/**/*.ts",
"!src/**/*.d.ts",
// "!src/index.ts", // Optional, if index.ts only re-exports
],
modulePathIgnorePatterns: ["<rootDir>/dist/"],
};

@ -1,10 +0,0 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const sharedConfig = require("../../jest.config.js");
module.exports = {
...sharedConfig,
rootDir: "./",
transform: {
"^.+\\.(ts|tsx)?$": "ts-jest",
},
coveragePathIgnorePatterns: ["/node_modules/", "/dist/"],
};

@ -15,9 +15,10 @@
"./package.json": "./package.json"
},
"scripts": {
"build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"test:watch": "jest --watch",
"build": "rimraf dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"test": "jest --coverage",
"prepublishOnly": "npm run test && npm run build",
"lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
"docs": "typedoc --plugin typedoc-plugin-markdown",

@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type TypedEmitter from "typed-emitter";
import type { ConnectedResult } from "./results/ConnectedResult.js";
import type { DatasetChanges } from "@ldo/rdf-utils";
import type {
@ -9,7 +8,8 @@ import type {
import type { ResourceError } from "./results/error/ErrorResult.js";
import type { ReadSuccess } from "./results/success/ReadSuccess.js";
export type ResourceEventEmitter = TypedEmitter<{
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
export type ResourceEventEmitter = import("typed-emitter").default<{
update: () => void;
notification: () => void;
}>;

@ -110,7 +110,7 @@ export interface ILinkQuery<Type extends LdoBase, Input extends LQInput<Type>> {
// };
// };
// type testReturn = LQReturn<SolidProfileShape, TestLQInput>;
// type testReturn = ExpandDeep<LQReturn<SolidProfileShape, TestLQInput>>;
// type test2 = LQReturnSubSet<string | undefined, true>;
@ -118,6 +118,8 @@ export interface ILinkQuery<Type extends LdoBase, Input extends LQInput<Type>> {
// type meh = TestLQInput extends true ? true : false;
// const thingInput: TestLQInput =
// const thing = test(SolidProfileShapeShapeType, {
// name: true,
// knows: {

@ -1,7 +1,7 @@
import { ShapeType } from "@ldo/ldo";
import { solidProfileSchema } from "./solidProfile.schema.js";
import { solidProfileContext } from "./solidProfile.context.js";
import { solidProfileSchema } from "./solidProfile.schema.js";
import { AddressShape, EmailShape, PhoneNumberShape, RSAPublicKeyShape, SolidProfileShape, TrustedAppShape } from "./solidProfile.typings.js";
/**
* =============================================================================

@ -1,5 +1,9 @@
import type { ConnectedLdoDataset } from "../src/ConnectedLdoDataset.js";
import { changeData, commitData, createConnectedLdoDataset } from "../src/index.js";
import {
changeData,
commitData,
createConnectedLdoDataset,
} from "../src/index.js";
import {
solidConnectedPlugin,
type SolidConnectedPlugin,

@ -1,7 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import EventEmitter from "events";
import type { ResourceError } from "../../src/index.js";
import type { ResourceError } from "../../src/index.js";
import {
Unfetched,
type ConnectedResult,
type Resource,
type ResourceError,
type ResourceEventEmitter,
} from "../../src/index.js";
import type { DatasetChanges } from "@ldo/rdf-utils";
import type { ReadSuccess } from "../../src/results/success/ReadSuccess.js";
import type { UpdateSuccess } from "../../src/results/success/UpdateSuccess.js";

@ -1,9 +1,10 @@
{
"extends": "../../tsconfig.cjs.json",
"compilerOptions": {
"outDir": "./dist/cjs"
"outDir": "./dist/cjs",
"rootDir": "./src"
},
"include": [
"./src"
"src"
]
}

@ -1,9 +1,11 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"outDir": "./dist/esm"
"outDir": "./dist/esm",
"rootDir": "./src",
"declarationDir": "./dist/types"
},
"include": [
"./src"
"src"
]
}

@ -12,6 +12,12 @@ const config = {
password: "abc123",
};
async function reportError(response: Response) {
if (response.status >= 400) {
console.error(await response.text());
}
}
async function getAuthorization(port: number): Promise<string> {
// First we request the account API controls to find out where we can log in
const indexResponse = await fetch(`http://localhost:${port}/.account/`);
@ -27,6 +33,7 @@ async function getAuthorization(port: number): Promise<string> {
}),
});
// This authorization value will be used to authenticate in the next step
await reportError(response);
const result = await response.json();
return result.authorization;
}
@ -57,7 +64,7 @@ async function getSecret(
webId: `http://localhost:${port}/${config.podName}/profile/card#me`,
}),
});
await reportError(response);
// These are the identifier and secret of your token.
// Store the secret somewhere safe as there is no way to request it again from the server!
// The `resource` value can be used to delete the token at a later point in time.
@ -94,7 +101,7 @@ async function getAccessToken(
},
body: "grant_type=client_credentials&scope=webid",
});
await reportError(response);
// This is the Access token that will be used to do an authenticated request to the server.
// The JSON also contains an "expires_in" field in seconds,
// which you can use to know when you need request a new Access token.

Loading…
Cancel
Save