mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Bring lint config back to original strictness
This commit is contained in:
parent
7a007dc466
commit
3bb3004abb
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
solidproject/community-server
|
solidproject/community-server
|
||||||
# edge will always be executed (without latest tag), semver only on tag push events (with latest tag)
|
# Edge will always be executed (without latest tag), semver only on tag push events (with latest tag)
|
||||||
tags: |
|
tags: |
|
||||||
type=edge
|
type=edge
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
|
@ -56,7 +56,7 @@ markdown_extensions:
|
|||||||
- pymdownx.smartsymbols
|
- pymdownx.smartsymbols
|
||||||
- pymdownx.superfences:
|
- pymdownx.superfences:
|
||||||
custom_fences:
|
custom_fences:
|
||||||
# need to fork the theme to make changes https://github.com/squidfunk/mkdocs-material/issues/3665#issuecomment-1060019924
|
# Need to fork the theme to make changes https://github.com/squidfunk/mkdocs-material/issues/3665#issuecomment-1060019924
|
||||||
- name: mermaid
|
- name: mermaid
|
||||||
class: mermaid
|
class: mermaid
|
||||||
format: !!python/name:pymdownx.superfences.fence_code_format
|
format: !!python/name:pymdownx.superfences.fence_code_format
|
||||||
|
136
eslint.config.js
136
eslint.config.js
@ -3,7 +3,7 @@ const jest = require('eslint-plugin-jest');
|
|||||||
|
|
||||||
// Copied from https://github.com/antfu/eslint-config/blob/main/src/configs/typescript.ts
|
// Copied from https://github.com/antfu/eslint-config/blob/main/src/configs/typescript.ts
|
||||||
// Doing it like this, so we can make sure these only try to trigger on *.ts files,
|
// Doing it like this, so we can make sure these only try to trigger on *.ts files,
|
||||||
// preventing issues with the *.js files.
|
// Preventing issues with the *.js files.
|
||||||
const typeAwareRules = {
|
const typeAwareRules = {
|
||||||
'dot-notation': 'off',
|
'dot-notation': 'off',
|
||||||
'no-implied-eval': 'off',
|
'no-implied-eval': 'off',
|
||||||
@ -26,8 +26,7 @@ const typeAwareRules = {
|
|||||||
'ts/unbound-method': 'error',
|
'ts/unbound-method': 'error',
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = antfu(
|
const configs = antfu(
|
||||||
{},
|
|
||||||
{
|
{
|
||||||
// Don't want to lint test assets, or TS snippets in markdown files
|
// Don't want to lint test assets, or TS snippets in markdown files
|
||||||
ignores: [ 'test/assets/*', '**/*.md/**/*.ts' ],
|
ignores: [ 'test/assets/*', '**/*.md/**/*.ts' ],
|
||||||
@ -56,6 +55,9 @@ module.exports = antfu(
|
|||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
...typeAwareRules,
|
...typeAwareRules,
|
||||||
|
'ts/consistent-type-assertions': [ 'error', {
|
||||||
|
assertionStyle: 'as',
|
||||||
|
}],
|
||||||
'ts/naming-convention': [
|
'ts/naming-convention': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
@ -84,8 +86,22 @@ module.exports = antfu(
|
|||||||
prefix: [ 'T' ],
|
prefix: [ 'T' ],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'ts/explicit-function-return-type': [ 'error', {
|
||||||
|
allowExpressions: false,
|
||||||
|
allowTypedFunctionExpressions: false,
|
||||||
|
allowHigherOrderFunctions: false,
|
||||||
|
}],
|
||||||
|
'ts/no-base-to-string': 'error',
|
||||||
'ts/no-floating-promises': [ 'error', { ignoreVoid: false }],
|
'ts/no-floating-promises': [ 'error', { ignoreVoid: false }],
|
||||||
'ts/promise-function-async': 'error',
|
'ts/promise-function-async': 'error',
|
||||||
|
'ts/no-unnecessary-boolean-literal-compare': 'error',
|
||||||
|
'ts/no-unnecessary-qualifier': 'error',
|
||||||
|
'ts/prefer-nullish-coalescing': 'error',
|
||||||
|
'ts/prefer-readonly': 'error',
|
||||||
|
'ts/prefer-reduce-type-parameter': 'error',
|
||||||
|
'ts/prefer-regexp-exec': 'error',
|
||||||
|
'ts/prefer-string-starts-ends-with': 'error',
|
||||||
|
'ts/require-array-sort-compare': 'error',
|
||||||
|
|
||||||
// These are not type specific, but we only care for TS files
|
// These are not type specific, but we only care for TS files
|
||||||
'max-len': [ 'error', { code: 120, ignoreUrls: true }],
|
'max-len': [ 'error', { code: 120, ignoreUrls: true }],
|
||||||
@ -104,16 +120,38 @@ module.exports = antfu(
|
|||||||
// Might want to enable this one but has a drastic impact on the already existing code
|
// Might want to enable this one but has a drastic impact on the already existing code
|
||||||
'antfu/consistent-list-newline': 'off',
|
'antfu/consistent-list-newline': 'off',
|
||||||
|
|
||||||
|
'arrow-body-style': [ 'error', 'as-needed', { requireReturnForObjectLiteral: false }],
|
||||||
|
'capitalized-comments': [ 'error', 'always', { ignoreConsecutiveComments: true }],
|
||||||
curly: [ 'error', 'all' ],
|
curly: [ 'error', 'all' ],
|
||||||
|
'default-case': 'error',
|
||||||
|
eqeqeq: [ 'error', 'always' ],
|
||||||
|
'for-direction': 'error',
|
||||||
|
'func-style': [ 'error', 'declaration' ],
|
||||||
|
'function-call-argument-newline': [ 'error', 'consistent' ],
|
||||||
'function-paren-newline': [ 'error', 'consistent' ],
|
'function-paren-newline': [ 'error', 'consistent' ],
|
||||||
'jsdoc/no-multi-asterisks': [ 'error', { allowWhitespace: true }],
|
'getter-return': [ 'error', { allowImplicit: true }],
|
||||||
|
'grouped-accessor-pairs': [ 'error', 'getBeforeSet' ],
|
||||||
|
'guard-for-in': 'error',
|
||||||
|
'line-comment-position': [ 'error', { position: 'above' }],
|
||||||
|
'linebreak-style': [ 'error', 'unix' ],
|
||||||
|
'multiline-comment-style': [ 'error', 'separate-lines' ],
|
||||||
// Need to override `allow` value
|
// Need to override `allow` value
|
||||||
'no-console': [ 'error', { allow: [ '' ]}],
|
'no-console': [ 'error', { allow: [ '' ]}],
|
||||||
'no-constructor-return': 'error',
|
'no-constructor-return': 'error',
|
||||||
|
'no-dupe-else-if': 'error',
|
||||||
|
'no-else-return': [ 'error', { allowElseIf: false }],
|
||||||
|
'no-implicit-coercion': 'error',
|
||||||
|
'no-implicit-globals': 'error',
|
||||||
|
'no-lonely-if': 'error',
|
||||||
|
'no-plusplus': [ 'error', { allowForLoopAfterthoughts: true }],
|
||||||
'no-sync': [ 'error', { allowAtRootLevel: false }],
|
'no-sync': [ 'error', { allowAtRootLevel: false }],
|
||||||
'node/prefer-global/buffer': 'off',
|
'no-useless-concat': 'error',
|
||||||
'node/prefer-global/process': 'off',
|
'no-useless-escape': 'error',
|
||||||
|
'operator-assignment': [ 'error', 'always' ],
|
||||||
|
'prefer-object-spread': 'error',
|
||||||
|
radix: 'error',
|
||||||
'require-unicode-regexp': 'error',
|
'require-unicode-regexp': 'error',
|
||||||
|
'require-yield': 'error',
|
||||||
'sort-imports': [
|
'sort-imports': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
@ -125,6 +163,14 @@ module.exports = antfu(
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'import/extensions': 'error',
|
||||||
|
|
||||||
|
'jsdoc/no-multi-asterisks': [ 'error', { allowWhitespace: true }],
|
||||||
|
|
||||||
|
// Might want to enable these
|
||||||
|
'node/prefer-global/buffer': 'off',
|
||||||
|
'node/prefer-global/process': 'off',
|
||||||
|
|
||||||
'style/array-bracket-spacing': [ 'error', 'always', {
|
'style/array-bracket-spacing': [ 'error', 'always', {
|
||||||
singleValue: true,
|
singleValue: true,
|
||||||
objectsInArrays: false,
|
objectsInArrays: false,
|
||||||
@ -133,24 +179,21 @@ module.exports = antfu(
|
|||||||
// Conflicts with style/object-curly-spacing
|
// Conflicts with style/object-curly-spacing
|
||||||
'style/block-spacing': 'off',
|
'style/block-spacing': 'off',
|
||||||
'style/brace-style': [ 'error', '1tbs', { allowSingleLine: false }],
|
'style/brace-style': [ 'error', '1tbs', { allowSingleLine: false }],
|
||||||
|
'style/generator-star-spacing': [ 'error', { before: false, after: true }],
|
||||||
'style/member-delimiter-style': [ 'error', {
|
'style/member-delimiter-style': [ 'error', {
|
||||||
multiline: { delimiter: 'semi', requireLast: true },
|
multiline: { delimiter: 'semi', requireLast: true },
|
||||||
singleline: { delimiter: 'semi', requireLast: false },
|
singleline: { delimiter: 'semi', requireLast: false },
|
||||||
}],
|
}],
|
||||||
'style/no-extra-parens': [ 'error', 'all', {
|
'style/no-extra-parens': [ 'error', 'functions' ],
|
||||||
conditionalAssign: false,
|
|
||||||
enforceForArrowConditionals: false,
|
|
||||||
ignoreJSX: 'all',
|
|
||||||
nestedBinaryExpressions: false,
|
|
||||||
returnAssign: false,
|
|
||||||
}],
|
|
||||||
'style/object-curly-spacing': [ 'error', 'always', {
|
'style/object-curly-spacing': [ 'error', 'always', {
|
||||||
objectsInObjects: false,
|
objectsInObjects: false,
|
||||||
arraysInObjects: false,
|
arraysInObjects: false,
|
||||||
}],
|
}],
|
||||||
'style/operator-linebreak': [ 'error', 'after' ],
|
'style/operator-linebreak': [ 'error', 'after' ],
|
||||||
'style/semi': [ 'error', 'always' ],
|
'style/semi': [ 'error', 'always' ],
|
||||||
|
'style/semi-style': [ 'error', 'last' ],
|
||||||
'style/space-before-function-paren': [ 'error', 'never' ],
|
'style/space-before-function-paren': [ 'error', 'never' ],
|
||||||
|
'style/switch-colon-spacing': 'error',
|
||||||
'style/quote-props': [ 'error', 'as-needed', {
|
'style/quote-props': [ 'error', 'as-needed', {
|
||||||
keywords: false,
|
keywords: false,
|
||||||
unnecessary: true,
|
unnecessary: true,
|
||||||
@ -158,28 +201,80 @@ module.exports = antfu(
|
|||||||
}],
|
}],
|
||||||
'style/yield-star-spacing': [ 'error', 'after' ],
|
'style/yield-star-spacing': [ 'error', 'after' ],
|
||||||
|
|
||||||
'test/prefer-lowercase-title': 'off',
|
'ts/adjacent-overload-signatures': 'error',
|
||||||
|
'ts/array-type': 'error',
|
||||||
|
'ts/ban-ts-comment': [ 'error', {
|
||||||
|
'ts-expect-error': true,
|
||||||
|
}],
|
||||||
'ts/consistent-indexed-object-style': [ 'error', 'record' ],
|
'ts/consistent-indexed-object-style': [ 'error', 'record' ],
|
||||||
'ts/consistent-type-definitions': 'off',
|
'ts/consistent-type-definitions': 'off',
|
||||||
|
'ts/explicit-member-accessibility': 'error',
|
||||||
'ts/method-signature-style': 'error',
|
'ts/method-signature-style': 'error',
|
||||||
|
'ts/no-confusing-non-null-assertion': 'error',
|
||||||
'ts/no-extraneous-class': [ 'error', {
|
'ts/no-extraneous-class': [ 'error', {
|
||||||
allowConstructorOnly: false,
|
allowConstructorOnly: false,
|
||||||
allowEmpty: false,
|
allowEmpty: false,
|
||||||
allowStaticOnly: false,
|
allowStaticOnly: false,
|
||||||
}],
|
}],
|
||||||
|
'ts/no-inferrable-types': [ 'error', {
|
||||||
|
ignoreParameters: false,
|
||||||
|
ignoreProperties: false,
|
||||||
|
}],
|
||||||
|
'ts/prefer-for-of': 'error',
|
||||||
|
'ts/prefer-function-type': 'error',
|
||||||
|
|
||||||
|
'unicorn/better-regex': 'error',
|
||||||
|
'unicorn/empty-brace-spaces': 'error',
|
||||||
'unicorn/consistent-function-scoping': 'error',
|
'unicorn/consistent-function-scoping': 'error',
|
||||||
'unicorn/expiring-todo-comments': [ 'error', {
|
'unicorn/expiring-todo-comments': [ 'error', {
|
||||||
ignoreDatesOnPullRequests: false,
|
ignoreDatesOnPullRequests: false,
|
||||||
terms: [ 'todo' ],
|
terms: [ 'todo' ],
|
||||||
allowWarningComments: false,
|
allowWarningComments: false,
|
||||||
}],
|
}],
|
||||||
|
'unicorn/explicit-length-check': 'error',
|
||||||
|
'unicorn/new-for-builtins': 'error',
|
||||||
|
'unicorn/no-for-loop': 'error',
|
||||||
|
'unicorn/no-invalid-remove-event-listener': 'error',
|
||||||
|
'unicorn/no-lonely-if': 'error',
|
||||||
|
'unicorn/no-nested-ternary': 'error',
|
||||||
'unicorn/no-process-exit': 'error',
|
'unicorn/no-process-exit': 'error',
|
||||||
|
'unicorn/no-thenable': 'error',
|
||||||
|
'unicorn/no-useless-fallback-in-spread': 'error',
|
||||||
|
'unicorn/no-useless-length-check': 'error',
|
||||||
|
'unicorn/no-useless-promise-resolve-reject': 'error',
|
||||||
|
'unicorn/no-useless-spread': 'error',
|
||||||
'unicorn/no-useless-undefined': 'error',
|
'unicorn/no-useless-undefined': 'error',
|
||||||
|
'unicorn/no-zero-fractions': 'error',
|
||||||
|
'unicorn/prefer-array-find': 'error',
|
||||||
'unicorn/prefer-array-flat-map': 'error',
|
'unicorn/prefer-array-flat-map': 'error',
|
||||||
'unicorn/prefer-node-protocol': 'off',
|
'unicorn/prefer-array-index-of': 'error',
|
||||||
|
'unicorn/prefer-array-some': 'error',
|
||||||
|
'unicorn/prefer-at': 'error',
|
||||||
|
'unicorn/prefer-code-point': 'error',
|
||||||
|
'unicorn/prefer-date-now': 'error',
|
||||||
|
'unicorn/prefer-default-parameters': 'error',
|
||||||
|
'unicorn/prefer-math-trunc': 'error',
|
||||||
|
'unicorn/prefer-native-coercion-functions': 'error',
|
||||||
|
'unicorn/prefer-negative-index': 'error',
|
||||||
|
'unicorn/prefer-object-from-entries': 'error',
|
||||||
|
'unicorn/prefer-optional-catch-binding': 'error',
|
||||||
|
'unicorn/prefer-reflect-apply': 'error',
|
||||||
|
'unicorn/prefer-regexp-test': 'error',
|
||||||
|
'unicorn/prefer-set-has': 'error',
|
||||||
|
'unicorn/prefer-set-size': 'error',
|
||||||
'unicorn/prefer-spread': 'error',
|
'unicorn/prefer-spread': 'error',
|
||||||
|
'unicorn/prefer-string-replace-all': 'error',
|
||||||
|
'unicorn/prefer-string-slice': 'error',
|
||||||
'unicorn/require-array-join-separator': 'error',
|
'unicorn/require-array-join-separator': 'error',
|
||||||
|
'unicorn/require-number-to-fixed-digits-argument': 'error',
|
||||||
|
|
||||||
|
// Might want to enable these
|
||||||
|
'unicorn/no-array-reduce': 'off',
|
||||||
|
'unicorn/no-array-for-each': 'off',
|
||||||
|
'unicorn/no-await-expression-member': 'off',
|
||||||
|
'unicorn/no-negated-condition': 'off',
|
||||||
|
'unicorn/no-object-as-default-parameter': 'off',
|
||||||
|
'unicorn/prefer-node-protocol': 'off',
|
||||||
|
|
||||||
'unused-imports/no-unused-vars': [
|
'unused-imports/no-unused-vars': [
|
||||||
'error',
|
'error',
|
||||||
@ -216,6 +311,8 @@ module.exports = antfu(
|
|||||||
'jest/prefer-strict-equal': 'off',
|
'jest/prefer-strict-equal': 'off',
|
||||||
'jest/require-hook': 'off',
|
'jest/require-hook': 'off',
|
||||||
|
|
||||||
|
'test/prefer-lowercase-title': 'off',
|
||||||
|
|
||||||
'ts/naming-convention': 'off',
|
'ts/naming-convention': 'off',
|
||||||
'ts/no-unsafe-argument': 'off',
|
'ts/no-unsafe-argument': 'off',
|
||||||
'ts/no-unsafe-assignment': 'off',
|
'ts/no-unsafe-assignment': 'off',
|
||||||
@ -247,3 +344,12 @@ module.exports = antfu(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// The default ignore list contains all `output` folders, which conflicts with our src/http/output folder
|
||||||
|
// See https://github.com/antfu/eslint-config/blob/29f29f1e16d0187f5c870102f910d798acd9b874/src/globs.ts#L53
|
||||||
|
if (!configs[1].ignores.includes('**/output')) {
|
||||||
|
throw new Error('Unexpected data in config position. Check if antfu changed how it handles ignores.');
|
||||||
|
}
|
||||||
|
delete configs[1].ignores;
|
||||||
|
|
||||||
|
module.exports = configs;
|
||||||
|
@ -3,7 +3,7 @@ const v8 = require('v8');
|
|||||||
|
|
||||||
// Several parts inspired by https://github.com/renovatebot/renovate/blob/main/package.json
|
// Several parts inspired by https://github.com/renovatebot/renovate/blob/main/package.json
|
||||||
|
|
||||||
const ci = !!process.env.CI;
|
const ci = Boolean(process.env.CI);
|
||||||
|
|
||||||
const cpus = os.cpus();
|
const cpus = os.cpus();
|
||||||
const mem = os.totalmem();
|
const mem = os.totalmem();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env ts-node
|
#!/usr/bin/env ts-node
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable import/extensions, no-console */
|
||||||
import * as readline from 'readline';
|
import * as readline from 'readline';
|
||||||
import simpleGit from 'simple-git';
|
import simpleGit from 'simple-git';
|
||||||
import { version } from '../package.json';
|
import { version } from '../package.json';
|
||||||
|
@ -18,7 +18,7 @@ import { readFile, writeFile } from 'fs-extra';
|
|||||||
* @returns Promise with output string
|
* @returns Promise with output string
|
||||||
*/
|
*/
|
||||||
async function capitalizeListEntries(input: string): Promise<string> {
|
async function capitalizeListEntries(input: string): Promise<string> {
|
||||||
return input.replace(/^(\W*\* [a-z])/gmu, (match): string => match.toUpperCase());
|
return input.replaceAll(/^(\W*\* [a-z])/gmu, (match): string => match.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,7 +85,7 @@ export class AcpReader extends PermissionReader {
|
|||||||
}
|
}
|
||||||
const modes = allowAccessModes(policies, context);
|
const modes = allowAccessModes(policies, context);
|
||||||
|
|
||||||
const permissionSet: PermissionSet = { };
|
const permissionSet: PermissionSet = {};
|
||||||
for (const aclMode of modes) {
|
for (const aclMode of modes) {
|
||||||
if (aclMode in modesMap) {
|
if (aclMode in modesMap) {
|
||||||
for (const mode of modesMap[aclMode]) {
|
for (const mode of modesMap[aclMode]) {
|
||||||
|
@ -4,4 +4,4 @@ import type { RepresentationMetadata } from '../representation/RepresentationMet
|
|||||||
/**
|
/**
|
||||||
* Generic interface for classes that add metadata to a RepresentationMetadata.
|
* Generic interface for classes that add metadata to a RepresentationMetadata.
|
||||||
*/
|
*/
|
||||||
export abstract class MetadataGenerator extends AsyncHandler<RepresentationMetadata> { }
|
export abstract class MetadataGenerator extends AsyncHandler<RepresentationMetadata> {}
|
||||||
|
@ -10,4 +10,4 @@ export type ValidatorInput = {
|
|||||||
/**
|
/**
|
||||||
* Generic interface for classes that validate Representations in some way.
|
* Generic interface for classes that validate Representations in some way.
|
||||||
*/
|
*/
|
||||||
export abstract class Validator extends AsyncHandler<ValidatorInput, Representation> { }
|
export abstract class Validator extends AsyncHandler<ValidatorInput, Representation> {}
|
||||||
|
@ -62,6 +62,7 @@ export class ConvertingErrorHandler extends ErrorHandler {
|
|||||||
private async extractErrorDetails({ error, request }: ErrorHandlerArgs): Promise<PreparedArguments> {
|
private async extractErrorDetails({ error, request }: ErrorHandlerArgs): Promise<PreparedArguments> {
|
||||||
if (!this.showStackTrace) {
|
if (!this.showStackTrace) {
|
||||||
delete error.stack;
|
delete error.stack;
|
||||||
|
// eslint-disable-next-line ts/no-unsafe-member-access
|
||||||
delete (error as any).cause;
|
delete (error as any).cause;
|
||||||
}
|
}
|
||||||
const representation = new BasicRepresentation([ error ], error.metadata, INTERNAL_ERROR, false);
|
const representation = new BasicRepresentation([ error ], error.metadata, INTERNAL_ERROR, false);
|
||||||
|
@ -29,7 +29,7 @@ export class LinkRelMetadataWriter extends MetadataWriter {
|
|||||||
const values = input.metadata.getAll(predicate)
|
const values = input.metadata.getAll(predicate)
|
||||||
.map((term): string => `<${term.value}>; rel="${relValue}"`);
|
.map((term): string => `<${term.value}>; rel="${relValue}"`);
|
||||||
if (values.length > 0) {
|
if (values.length > 0) {
|
||||||
this.logger.debug(`Adding Link header ${values}`);
|
this.logger.debug(`Adding Link header ${values.join(',')}`);
|
||||||
addHeader(input.response, 'Link', values);
|
addHeader(input.response, 'Link', values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ export class WacAllowMetadataWriter extends MetadataWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private aclToPermission(aclTerm: Term): string {
|
private aclToPermission(this: void, aclTerm: Term): string {
|
||||||
return aclTerm.value.slice(ACL.namespace.length).toLowerCase();
|
return aclTerm.value.slice(ACL.namespace.length).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ export class HtmlViewEntry {
|
|||||||
public constructor(
|
public constructor(
|
||||||
public readonly route: InteractionRoute,
|
public readonly route: InteractionRoute,
|
||||||
public readonly filePath: string,
|
public readonly filePath: string,
|
||||||
) { }
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,4 +25,4 @@ export interface InteractionHandlerInput {
|
|||||||
/**
|
/**
|
||||||
* Handler used for IDP interactions.
|
* Handler used for IDP interactions.
|
||||||
*/
|
*/
|
||||||
export abstract class InteractionHandler extends AsyncHandler<InteractionHandlerInput, Representation> { }
|
export abstract class InteractionHandler extends AsyncHandler<InteractionHandlerInput, Representation> {}
|
||||||
|
@ -38,4 +38,4 @@ export interface JsonInteractionHandlerInput {
|
|||||||
* designed to be used for IDP/OIDC interactions.
|
* designed to be used for IDP/OIDC interactions.
|
||||||
*/
|
*/
|
||||||
export abstract class JsonInteractionHandler<TOut extends Dict<Json> = Dict<Json>>
|
export abstract class JsonInteractionHandler<TOut extends Dict<Json> = Dict<Json>>
|
||||||
extends AsyncHandler<JsonInteractionHandlerInput, JsonRepresentation<TOut>> { }
|
extends AsyncHandler<JsonInteractionHandlerInput, JsonRepresentation<TOut>> {}
|
||||||
|
@ -160,7 +160,7 @@ export class BaseResourcesGenerator implements TemplatedResourcesGenerator {
|
|||||||
private async groupLinks(folderPath: string, mapper: FileIdentifierMapper):
|
private async groupLinks(folderPath: string, mapper: FileIdentifierMapper):
|
||||||
Promise<Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }>> {
|
Promise<Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }>> {
|
||||||
const files = await fsPromises.readdir(folderPath);
|
const files = await fsPromises.readdir(folderPath);
|
||||||
const links: Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }> = { };
|
const links: Record<string, { link: TemplateResourceLink; meta?: TemplateResourceLink }> = {};
|
||||||
for (const name of files) {
|
for (const name of files) {
|
||||||
const link = await this.toTemplateLink(joinFilePath(folderPath, name), mapper);
|
const link = await this.toTemplateLink(joinFilePath(folderPath, name), mapper);
|
||||||
const { path } = link.identifier;
|
const { path } = link.identifier;
|
||||||
|
@ -21,7 +21,7 @@ export class StaticAssetEntry {
|
|||||||
public constructor(
|
public constructor(
|
||||||
public readonly relativeUrl: string,
|
public readonly relativeUrl: string,
|
||||||
public readonly filePath: string,
|
public readonly filePath: string,
|
||||||
) { }
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,4 +5,4 @@ import type { NotificationHandlerInput } from '../NotificationHandler';
|
|||||||
/**
|
/**
|
||||||
* Creates a {@link Notification} based on the provided input.
|
* Creates a {@link Notification} based on the provided input.
|
||||||
*/
|
*/
|
||||||
export abstract class NotificationGenerator extends AsyncHandler<NotificationHandlerInput, Notification> { }
|
export abstract class NotificationGenerator extends AsyncHandler<NotificationHandlerInput, Notification> {}
|
||||||
|
@ -14,4 +14,4 @@ export interface NotificationSerializerInput {
|
|||||||
* This is a separate class between a generator and emitter,
|
* This is a separate class between a generator and emitter,
|
||||||
* so that a specific notification channel type can add extra metadata to the Representation if needed.
|
* so that a specific notification channel type can add extra metadata to the Representation if needed.
|
||||||
*/
|
*/
|
||||||
export abstract class NotificationSerializer extends AsyncHandler<NotificationSerializerInput, Representation> { }
|
export abstract class NotificationSerializer extends AsyncHandler<NotificationSerializerInput, Representation> {}
|
||||||
|
@ -30,7 +30,7 @@ export class InMemoryDataAccessor implements DataAccessor, SingleThreaded {
|
|||||||
public constructor(identifierStrategy: IdentifierStrategy) {
|
public constructor(identifierStrategy: IdentifierStrategy) {
|
||||||
this.identifierStrategy = identifierStrategy;
|
this.identifierStrategy = identifierStrategy;
|
||||||
|
|
||||||
this.store = { entries: { }};
|
this.store = { entries: {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async canHandle(): Promise<void> {
|
public async canHandle(): Promise<void> {
|
||||||
|
@ -65,7 +65,7 @@ export class MaxKeyLengthStorage<T> implements KeyValueStorage<string, T> {
|
|||||||
const parts = key.split('/');
|
const parts = key.split('/');
|
||||||
|
|
||||||
// Prevent non-hashed keys with the prefix to prevent false hits
|
// Prevent non-hashed keys with the prefix to prevent false hits
|
||||||
if (parts[parts.length - 1].startsWith(this.hashPrefix)) {
|
if (parts.at(-1)?.startsWith(this.hashPrefix)) {
|
||||||
throw new NotImplementedHttpError(`Unable to store keys starting with ${this.hashPrefix}`);
|
throw new NotImplementedHttpError(`Unable to store keys starting with ${this.hashPrefix}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export function isGuarded<T extends NodeJS.EventEmitter>(stream: T): stream is G
|
|||||||
function guardingErrorListener(this: Guarded, error: Error): void {
|
function guardingErrorListener(this: Guarded, error: Error): void {
|
||||||
// Only fall back to this if no new listeners are attached since guarding started.
|
// Only fall back to this if no new listeners are attached since guarding started.
|
||||||
const errorListeners = this.listeners('error');
|
const errorListeners = this.listeners('error');
|
||||||
if (errorListeners[errorListeners.length - 1] === guardingErrorListener) {
|
if (errorListeners.at(-1) === guardingErrorListener) {
|
||||||
this[guardedErrors].push(error);
|
this[guardedErrors].push(error);
|
||||||
if (!this[guardedTimeout]) {
|
if (!this[guardedTimeout]) {
|
||||||
this[guardedTimeout] = setTimeout((): void => {
|
this[guardedTimeout] = setTimeout((): void => {
|
||||||
|
@ -38,7 +38,7 @@ const logger = getLoggerFor('HeaderUtil');
|
|||||||
export function transformQuotedStrings(input: string): { result: string; replacements: Record<string, string> } {
|
export function transformQuotedStrings(input: string): { result: string; replacements: Record<string, string> } {
|
||||||
let idx = 0;
|
let idx = 0;
|
||||||
const replacements: Record<string, string> = {};
|
const replacements: Record<string, string> = {};
|
||||||
const result = input.replace(/"(?:[^"\\]|\\.)*"/gu, (match): string => {
|
const result = input.replaceAll(/"(?:[^"\\]|\\.)*"/gu, (match): string => {
|
||||||
// Not all characters allowed in quoted strings, see BNF above
|
// Not all characters allowed in quoted strings, see BNF above
|
||||||
if (!QUOTED_STRING.test(match)) {
|
if (!QUOTED_STRING.test(match)) {
|
||||||
logger.warn(`Invalid quoted string in header: ${match}`);
|
logger.warn(`Invalid quoted string in header: ${match}`);
|
||||||
|
@ -173,7 +173,6 @@ async function findNextSorted<T>(iterators: AsyncIterator<T>[], results: (T | un
|
|||||||
export async function* sortedAsyncMerge<T>(iterators: AsyncIterator<T>[], comparator?: (left: T, right: T) => number):
|
export async function* sortedAsyncMerge<T>(iterators: AsyncIterator<T>[], comparator?: (left: T, right: T) => number):
|
||||||
AsyncIterable<T> {
|
AsyncIterable<T> {
|
||||||
if (!comparator) {
|
if (!comparator) {
|
||||||
// eslint-disable-next-line style/no-extra-parens
|
|
||||||
comparator = (left, right): number => left < right ? -1 : (left > right ? 1 : 0);
|
comparator = (left, right): number => left < right ? -1 : (left > right ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import { errorTermsToMetadata } from './errors/HttpErrorUtil';
|
|||||||
* @returns The potentially changed path (POSIX).
|
* @returns The potentially changed path (POSIX).
|
||||||
*/
|
*/
|
||||||
function windowsToPosixPath(path: string): string {
|
function windowsToPosixPath(path: string): string {
|
||||||
return path.replace(/\\+/gu, '/');
|
return path.replaceAll(/\\+/gu, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ export function splitCommaSeparated(input: string): string[] {
|
|||||||
* @returns The sanitized output.
|
* @returns The sanitized output.
|
||||||
*/
|
*/
|
||||||
export function sanitizeUrlPart(urlPart: string): string {
|
export function sanitizeUrlPart(urlPart: string): string {
|
||||||
return urlPart.replace(/\W/gu, '-');
|
return urlPart.replaceAll(/\W/gu, '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +51,7 @@ export type VocabularyTerm<T> = T extends Vocabulary<any, infer TKey> ? T['terms
|
|||||||
*/
|
*/
|
||||||
function createValueVocabulary<TBase extends string, TLocal extends string>(baseUri: TBase, localNames: TLocal[]):
|
function createValueVocabulary<TBase extends string, TLocal extends string>(baseUri: TBase, localNames: TLocal[]):
|
||||||
ValueVocabulary<TBase, TLocal> {
|
ValueVocabulary<TBase, TLocal> {
|
||||||
const expanded: Partial<ExpandedRecord<TBase, TLocal>> = { };
|
const expanded: Partial<ExpandedRecord<TBase, TLocal>> = {};
|
||||||
// Expose the listed local names as properties
|
// Expose the listed local names as properties
|
||||||
for (const localName of localNames) {
|
for (const localName of localNames) {
|
||||||
expanded[localName] = `${baseUri}${localName}`;
|
expanded[localName] = `${baseUri}${localName}`;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @param ids - IDs of the element (empty to retrieve all elements)
|
* @param ids - IDs of the element (empty to retrieve all elements)
|
||||||
*/
|
*/
|
||||||
export function getElements(...ids) {
|
export function getElements(...ids) {
|
||||||
ids = ids.length ? ids : [ ...document.querySelectorAll('[id]') ].map(e => e.id);
|
ids = ids.length > 0 ? ids : [ ...document.querySelectorAll('[id]') ].map(e => e.id);
|
||||||
return Object.fromEntries(ids.map(id => [ id, document.getElementById(id) ]));
|
return Object.fromEntries(ids.map(id => [ id, document.getElementById(id) ]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ describe('A BearerWebIdExtractor', (): void => {
|
|||||||
describe('on a request without Authorization header', (): void => {
|
describe('on a request without Authorization header', (): void => {
|
||||||
const request = {
|
const request = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: { },
|
headers: {},
|
||||||
} as any as HttpRequest;
|
} as any as HttpRequest;
|
||||||
|
|
||||||
it('throws an error.', async(): Promise<void> => {
|
it('throws an error.', async(): Promise<void> => {
|
||||||
|
@ -44,7 +44,7 @@ describe('An AuthAuxiliaryReader', (): void => {
|
|||||||
|
|
||||||
const result = await reader.handle({ requestedModes, credentials });
|
const result = await reader.handle({ requestedModes, credentials });
|
||||||
expect(result.get(acl1)).toEqual({ read: true, append: true, write: true, control: true });
|
expect(result.get(acl1)).toEqual({ read: true, append: true, write: true, control: true });
|
||||||
expect(result.get(acl2)).toEqual({ });
|
expect(result.get(acl2)).toEqual({});
|
||||||
|
|
||||||
const updatedMap = new IdentifierMap();
|
const updatedMap = new IdentifierMap();
|
||||||
updatedMap.set(subject1, new Set([ AclMode.control ]));
|
updatedMap.set(subject1, new Set([ AclMode.control ]));
|
||||||
|
@ -39,7 +39,7 @@ describe('A ParentContainerReader', (): void => {
|
|||||||
|
|
||||||
const result = await reader.handle({ requestedModes, credentials });
|
const result = await reader.handle({ requestedModes, credentials });
|
||||||
expect(result.get(target1)).toEqual({ create: true });
|
expect(result.get(target1)).toEqual({ create: true });
|
||||||
expect(result.get(target2)).toEqual({ });
|
expect(result.get(target2)).toEqual({});
|
||||||
|
|
||||||
const updatedMap = new IdentifierSetMultiMap(requestedModes);
|
const updatedMap = new IdentifierSetMultiMap(requestedModes);
|
||||||
updatedMap.set(parent1, AccessMode.append);
|
updatedMap.set(parent1, AccessMode.append);
|
||||||
@ -61,7 +61,7 @@ describe('A ParentContainerReader', (): void => {
|
|||||||
|
|
||||||
const result = await reader.handle({ requestedModes, credentials });
|
const result = await reader.handle({ requestedModes, credentials });
|
||||||
expect(result.get(target1)).toEqual({ delete: true, write: true });
|
expect(result.get(target1)).toEqual({ delete: true, write: true });
|
||||||
expect(result.get(target2)).toEqual({ });
|
expect(result.get(target2)).toEqual({});
|
||||||
expect(result.get(target3)).toEqual({ write: true });
|
expect(result.get(target3)).toEqual({ write: true });
|
||||||
|
|
||||||
const updatedMap = new IdentifierSetMultiMap(requestedModes);
|
const updatedMap = new IdentifierSetMultiMap(requestedModes);
|
||||||
|
@ -72,7 +72,7 @@ describe('A WebAclReader', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles all input.', async(): Promise<void> => {
|
it('handles all input.', async(): Promise<void> => {
|
||||||
await expect(reader.canHandle({ } as any)).resolves.toBeUndefined();
|
await expect(reader.canHandle({} as any)).resolves.toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns undefined permissions for undefined credentials.', async(): Promise<void> => {
|
it('returns undefined permissions for undefined credentials.', async(): Promise<void> => {
|
||||||
|
@ -8,7 +8,7 @@ interface CreateExtractorArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper function for instantiating an OriginalUrlExtractor
|
// Helper function for instantiating an OriginalUrlExtractor
|
||||||
function createExtractor(args: CreateExtractorArgs = { }): OriginalUrlExtractor {
|
function createExtractor(args: CreateExtractorArgs = {}): OriginalUrlExtractor {
|
||||||
const identifierStrategy = new SingleRootIdentifierStrategy(args.baseUrl ?? 'http://test.com');
|
const identifierStrategy = new SingleRootIdentifierStrategy(args.baseUrl ?? 'http://test.com');
|
||||||
const extractor = new OriginalUrlExtractor({ identifierStrategy, includeQueryString: args.includeQueryString });
|
const extractor = new OriginalUrlExtractor({ identifierStrategy, includeQueryString: args.includeQueryString });
|
||||||
return extractor;
|
return extractor;
|
||||||
|
@ -60,7 +60,7 @@ describe('A BasicResponseWriter', (): void => {
|
|||||||
|
|
||||||
it('serializes metadata if there is metadata.', async(): Promise<void> => {
|
it('serializes metadata if there is metadata.', async(): Promise<void> => {
|
||||||
result = { statusCode: 201, metadata: new RepresentationMetadata() };
|
result = { statusCode: 201, metadata: new RepresentationMetadata() };
|
||||||
metadataWriter.handle = jest.fn();
|
jest.spyOn(metadataWriter, 'handle').mockImplementation();
|
||||||
await writer.handle({ response, result });
|
await writer.handle({ response, result });
|
||||||
expect(metadataWriter.handle).toHaveBeenCalledTimes(1);
|
expect(metadataWriter.handle).toHaveBeenCalledTimes(1);
|
||||||
expect(metadataWriter.handle).toHaveBeenLastCalledWith({ response, metadata: result.metadata });
|
expect(metadataWriter.handle).toHaveBeenLastCalledWith({ response, metadata: result.metadata });
|
||||||
@ -77,6 +77,7 @@ describe('A BasicResponseWriter', (): void => {
|
|||||||
result = { statusCode: 201, data };
|
result = { statusCode: 201, data };
|
||||||
|
|
||||||
response = new PassThrough();
|
response = new PassThrough();
|
||||||
|
// eslint-disable-next-line jest/prefer-spy-on
|
||||||
response.writeHead = jest.fn();
|
response.writeHead = jest.fn();
|
||||||
|
|
||||||
const end = new Promise<void>((resolve): void => {
|
const end = new Promise<void>((resolve): void => {
|
||||||
|
@ -30,13 +30,13 @@ describe('A LinkRelMetadataWriter', (): void => {
|
|||||||
const metadata = new RepresentationMetadata(identifier);
|
const metadata = new RepresentationMetadata(identifier);
|
||||||
|
|
||||||
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
||||||
expect(response.getHeaders()).toEqual({ });
|
expect(response.getHeaders()).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add link headers for blank node identifiers.', async(): Promise<void> => {
|
it('does not add link headers for blank node identifiers.', async(): Promise<void> => {
|
||||||
const response = createResponse() as HttpResponse;
|
const response = createResponse() as HttpResponse;
|
||||||
const metadata = new RepresentationMetadata();
|
const metadata = new RepresentationMetadata();
|
||||||
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
||||||
expect(response.getHeaders()).toEqual({ });
|
expect(response.getHeaders()).toEqual({});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@ describe('A ContentTypeMetadataWriter', (): void => {
|
|||||||
it('adds no header if there is no relevant metadata.', async(): Promise<void> => {
|
it('adds no header if there is no relevant metadata.', async(): Promise<void> => {
|
||||||
const metadata = new RepresentationMetadata();
|
const metadata = new RepresentationMetadata();
|
||||||
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
||||||
expect(response.getHeaders()).toEqual({ });
|
expect(response.getHeaders()).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds a Content-Type header with parameters if present.', async(): Promise<void> => {
|
it('adds a Content-Type header with parameters if present.', async(): Promise<void> => {
|
||||||
|
@ -37,7 +37,7 @@ describe('RangeMetadataWriter', (): void => {
|
|||||||
|
|
||||||
it('does nothing if there is no range metadata.', async(): Promise<void> => {
|
it('does nothing if there is no range metadata.', async(): Promise<void> => {
|
||||||
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
||||||
expect(response.getHeaders()).toEqual({ });
|
expect(response.getHeaders()).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds a content-length header if the size is known.', async(): Promise<void> => {
|
it('adds a content-length header if the size is known.', async(): Promise<void> => {
|
||||||
|
@ -15,7 +15,7 @@ describe('A WacAllowMetadataWriter', (): void => {
|
|||||||
it('adds no header if there is no relevant metadata.', async(): Promise<void> => {
|
it('adds no header if there is no relevant metadata.', async(): Promise<void> => {
|
||||||
const metadata = new RepresentationMetadata();
|
const metadata = new RepresentationMetadata();
|
||||||
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
||||||
expect(response.getHeaders()).toEqual({ });
|
expect(response.getHeaders()).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds a WAC-Allow header if there is relevant metadata.', async(): Promise<void> => {
|
it('adds a WAC-Allow header if there is relevant metadata.', async(): Promise<void> => {
|
||||||
|
@ -16,13 +16,13 @@ describe('A WwwAuthMetadataWriter', (): void => {
|
|||||||
it('adds no header if there is no relevant metadata.', async(): Promise<void> => {
|
it('adds no header if there is no relevant metadata.', async(): Promise<void> => {
|
||||||
const metadata = new RepresentationMetadata();
|
const metadata = new RepresentationMetadata();
|
||||||
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
||||||
expect(response.getHeaders()).toEqual({ });
|
expect(response.getHeaders()).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds no header if the status code is not 401.', async(): Promise<void> => {
|
it('adds no header if the status code is not 401.', async(): Promise<void> => {
|
||||||
const metadata = new RepresentationMetadata({ [HTTP.statusCodeNumber]: '403' });
|
const metadata = new RepresentationMetadata({ [HTTP.statusCodeNumber]: '403' });
|
||||||
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
await expect(writer.handle({ response, metadata })).resolves.toBeUndefined();
|
||||||
expect(response.getHeaders()).toEqual({ });
|
expect(response.getHeaders()).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds a WWW-Authenticate header if the status code is 401.', async(): Promise<void> => {
|
it('adds a WWW-Authenticate header if the status code is 401.', async(): Promise<void> => {
|
||||||
|
@ -12,6 +12,6 @@ describe('An OidcControlHandler', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns an empty object if there is no OIDC interaction.', async(): Promise<void> => {
|
it('returns an empty object if there is no OIDC interaction.', async(): Promise<void> => {
|
||||||
await expect(handler.handle({ } as any)).resolves.toEqual({ json: { }});
|
await expect(handler.handle({} as any)).resolves.toEqual({ json: {}});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -27,7 +27,7 @@ describe('A LogoutHandler', (): void => {
|
|||||||
expect(outputMetadata?.get(SOLID_HTTP.terms.accountCookie)?.value).toBe(cookie);
|
expect(outputMetadata?.get(SOLID_HTTP.terms.accountCookie)?.value).toBe(cookie);
|
||||||
const date = outputMetadata?.get(SOLID_HTTP.terms.accountCookieExpiration);
|
const date = outputMetadata?.get(SOLID_HTTP.terms.accountCookieExpiration);
|
||||||
expect(date).toBeDefined();
|
expect(date).toBeDefined();
|
||||||
expect(new Date(date!.value).getTime()).toBeLessThan(new Date().getTime());
|
expect(new Date(date!.value).getTime()).toBeLessThan(Date.now());
|
||||||
expect(cookieStore.delete).toHaveBeenCalledTimes(1);
|
expect(cookieStore.delete).toHaveBeenCalledTimes(1);
|
||||||
expect(cookieStore.delete).toHaveBeenLastCalledWith(cookie);
|
expect(cookieStore.delete).toHaveBeenLastCalledWith(cookie);
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@ describe('A PromptHandler', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('errors if there is no interaction.', async(): Promise<void> => {
|
it('errors if there is no interaction.', async(): Promise<void> => {
|
||||||
await expect(handler.handle({ } as any)).rejects.toThrow(BadRequestHttpError);
|
await expect(handler.handle({} as any)).rejects.toThrow(BadRequestHttpError);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('errors if the prompt is unsupported.', async(): Promise<void> => {
|
it('errors if the prompt is unsupported.', async(): Promise<void> => {
|
||||||
|
@ -3,7 +3,7 @@ import { BaseLogger, WrappingLogger } from '../../../src/logging/Logger';
|
|||||||
import type { LogMetadata, SimpleLogger } from '../../../src/logging/Logger';
|
import type { LogMetadata, SimpleLogger } from '../../../src/logging/Logger';
|
||||||
|
|
||||||
class DummyLogger extends BaseLogger {
|
class DummyLogger extends BaseLogger {
|
||||||
log(): this {
|
public log(): this {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import { IdentifierMap, IdentifierSetMultiMap } from '../../../src/util/map/Iden
|
|||||||
import { SOLID_META } from '../../../src/util/Vocabularies';
|
import { SOLID_META } from '../../../src/util/Vocabularies';
|
||||||
|
|
||||||
describe('An AuthorizingHttpHandler', (): void => {
|
describe('An AuthorizingHttpHandler', (): void => {
|
||||||
const credentials = { };
|
const credentials = {};
|
||||||
const target = { path: 'http://example.com/foo' };
|
const target = { path: 'http://example.com/foo' };
|
||||||
const requestedModes: AccessMap = new IdentifierSetMultiMap<AccessMode>(
|
const requestedModes: AccessMap = new IdentifierSetMultiMap<AccessMode>(
|
||||||
[[ target, new Set([ AccessMode.read, AccessMode.write ]) ]],
|
[[ target, new Set([ AccessMode.read, AccessMode.write ]) ]],
|
||||||
|
@ -485,7 +485,7 @@ describe('A FileDataAccessor', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can delete the root container.', async(): Promise<void> => {
|
it('can delete the root container.', async(): Promise<void> => {
|
||||||
cache.data = { };
|
cache.data = {};
|
||||||
await expect(accessor.deleteResource({ path: `${base}` })).resolves.toBeUndefined();
|
await expect(accessor.deleteResource({ path: `${base}` })).resolves.toBeUndefined();
|
||||||
expect(cache.data).toBeUndefined();
|
expect(cache.data).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ function simplifyQuery(query: string | string[]): string {
|
|||||||
if (Array.isArray(query)) {
|
if (Array.isArray(query)) {
|
||||||
query = query.join(' ');
|
query = query.join(' ');
|
||||||
}
|
}
|
||||||
return query.replace(/\n/gu, ' ').trim();
|
return query.replaceAll('\n', ' ').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('A SparqlDataAccessor', (): void => {
|
describe('A SparqlDataAccessor', (): void => {
|
||||||
|
@ -29,7 +29,7 @@ describe('A BaseTypedRepresentationConverter', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can not handle input without a Content-Type.', async(): Promise<void> => {
|
it('can not handle input without a Content-Type.', async(): Promise<void> => {
|
||||||
const args: RepresentationConverterArgs = { representation: { metadata: { }}, preferences: {}} as any;
|
const args: RepresentationConverterArgs = { representation: { metadata: {}}, preferences: {}} as any;
|
||||||
const converter = new CustomTypedRepresentationConverter('*/*', 'b/b');
|
const converter = new CustomTypedRepresentationConverter('*/*', 'b/b');
|
||||||
await expect(converter.canHandle(args)).rejects.toThrow(NotImplementedHttpError);
|
await expect(converter.canHandle(args)).rejects.toThrow(NotImplementedHttpError);
|
||||||
});
|
});
|
||||||
|
@ -55,7 +55,7 @@ describe('A ChainedConverter', (): void => {
|
|||||||
|
|
||||||
it('needs at least 1 converter.', async(): Promise<void> => {
|
it('needs at least 1 converter.', async(): Promise<void> => {
|
||||||
expect((): any => new ChainedConverter([])).toThrow('At least 1 converter is required.');
|
expect((): any => new ChainedConverter([])).toThrow('At least 1 converter is required.');
|
||||||
expect(new ChainedConverter([ new DummyConverter({ }, { }) ])).toBeInstanceOf(ChainedConverter);
|
expect(new ChainedConverter([ new DummyConverter({}, {}) ])).toBeInstanceOf(ChainedConverter);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('errors if there are no content-type or preferences.', async(): Promise<void> => {
|
it('errors if there are no content-type or preferences.', async(): Promise<void> => {
|
||||||
@ -106,7 +106,7 @@ describe('A ChainedConverter', (): void => {
|
|||||||
expect(result.metadata.contentType).toBe('b/b');
|
expect(result.metadata.contentType).toBe('b/b');
|
||||||
expect(result.metadata.get(POSIX.terms.size)?.value).toBe('500');
|
expect(result.metadata.get(POSIX.terms.size)?.value).toBe('500');
|
||||||
|
|
||||||
args.preferences.type = { };
|
args.preferences.type = {};
|
||||||
result = await converter.handle(args);
|
result = await converter.handle(args);
|
||||||
expect(result.metadata.contentType).toBe('b/b');
|
expect(result.metadata.contentType).toBe('b/b');
|
||||||
expect(result.metadata.get(POSIX.terms.size)?.value).toBe('500');
|
expect(result.metadata.get(POSIX.terms.size)?.value).toBe('500');
|
||||||
|
@ -43,7 +43,7 @@ describe('A RdfToQuadConverter', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('may not handle application/json to quad conversion.', async(): Promise<void> => {
|
it('may not handle application/json to quad conversion.', async(): Promise<void> => {
|
||||||
await expect(converter.getOutputTypes('application/json')).resolves.toEqual({ });
|
await expect(converter.getOutputTypes('application/json')).resolves.toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can handle turtle to quad conversions.', async(): Promise<void> => {
|
it('can handle turtle to quad conversions.', async(): Promise<void> => {
|
||||||
|
@ -39,7 +39,7 @@ describe('An RdfPatcher,', (): void => {
|
|||||||
};
|
};
|
||||||
patcher.handle.mockImplementation(
|
patcher.handle.mockImplementation(
|
||||||
async(input: RepresentationPatcherInput<RdfDatasetRepresentation>):
|
async(input: RepresentationPatcherInput<RdfDatasetRepresentation>):
|
||||||
Promise<RdfDatasetRepresentation> => Promise.resolve(input.representation!),
|
Promise<RdfDatasetRepresentation> => input.representation!,
|
||||||
);
|
);
|
||||||
|
|
||||||
rdfPatcher = new RdfPatcher(patcher);
|
rdfPatcher = new RdfPatcher(patcher);
|
||||||
|
@ -143,7 +143,7 @@ export function mockFileSystem(rootFilepath?: string, time?: Date): { data: any
|
|||||||
return { folder: cache, name: 'data' };
|
return { folder: cache, name: 'data' };
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = parts.slice(-1)[0];
|
const name = parts.at(-1) as string;
|
||||||
parts = parts.slice(0, -1);
|
parts = parts.slice(0, -1);
|
||||||
let folder = cache.data;
|
let folder = cache.data;
|
||||||
parts.forEach((part): any => {
|
parts.forEach((part): any => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user