mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: add template based data generator
This commit is contained in:
@@ -19,7 +19,7 @@ import { parseQuads, pushQuad, serializeQuads } from '../../util/QuadUtil';
|
||||
import { generateContainmentQuads, generateResourceQuads } from '../../util/ResourceUtil';
|
||||
import { CONTENT_TYPE, DCTERMS, POSIX, RDF, XSD } from '../../util/UriConstants';
|
||||
import { toNamedNode, toTypedLiteral } from '../../util/UriUtil';
|
||||
import type { FileIdentifierMapper, ResourceLink } from '../FileIdentifierMapper';
|
||||
import type { FileIdentifierMapper, ResourceLink } from '../mapping/FileIdentifierMapper';
|
||||
import type { DataAccessor } from './DataAccessor';
|
||||
|
||||
const { join: joinPath } = posix;
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
isContainerIdentifier,
|
||||
trimTrailingSlashes,
|
||||
} from '../../util/PathUtil';
|
||||
import type { FileIdentifierMapper, ResourceLink } from '../FileIdentifierMapper';
|
||||
import type { FileIdentifierMapper, FileIdentifierMapperFactory, ResourceLink } from './FileIdentifierMapper';
|
||||
import { getAbsolutePath, getRelativePath, validateRelativePath } from './MapperUtil';
|
||||
|
||||
const { join: joinPath, normalize: normalizePath } = posix;
|
||||
@@ -197,3 +197,10 @@ export class ExtensionBasedMapper implements FileIdentifierMapper {
|
||||
return extension && extension[1];
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtensionBasedMapperFactory implements FileIdentifierMapperFactory<ExtensionBasedMapper> {
|
||||
public async create(base: string, rootFilePath: string): Promise<ExtensionBasedMapper> {
|
||||
return new ExtensionBasedMapper(base, rootFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ResourceIdentifier } from '../ldp/representation/ResourceIdentifier';
|
||||
import type { ResourceIdentifier } from '../../ldp/representation/ResourceIdentifier';
|
||||
|
||||
export interface ResourceLink {
|
||||
/**
|
||||
@@ -38,3 +38,11 @@ export interface FileIdentifierMapper {
|
||||
*/
|
||||
mapUrlToFilePath: (identifier: ResourceIdentifier, contentType?: string) => Promise<ResourceLink>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory that can create FileIdentifierMappers so the base and rootFilePath can be set dynamically.
|
||||
* Specifically used when identifiers need to be generated for a new pod (since pod identifiers are generated).
|
||||
*/
|
||||
export interface FileIdentifierMapperFactory<T extends FileIdentifierMapper = FileIdentifierMapper> {
|
||||
create: (base: string, rootFilePath: string) => Promise<T>;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
ensureTrailingSlash, isContainerIdentifier,
|
||||
trimTrailingSlashes,
|
||||
} from '../../util/PathUtil';
|
||||
import type { FileIdentifierMapper, ResourceLink } from '../FileIdentifierMapper';
|
||||
import type { FileIdentifierMapper, ResourceLink } from './FileIdentifierMapper';
|
||||
import { getAbsolutePath, getRelativePath, validateRelativePath } from './MapperUtil';
|
||||
|
||||
const { normalize: normalizePath } = posix;
|
||||
|
||||
Reference in New Issue
Block a user