@ghentcdh/annotation-api 0.0.1-alpha.1 → 0.0.1-alpha.13

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.
@@ -0,0 +1,11 @@
1
+ import { W3CAnnotation } from '@ghentcdh/w3c-utils';
2
+ import { AnnotationContext } from '@ghentcdh/annotation-core';
3
+ import { AnnotationContextService } from '../context/annotation-context.service';
4
+ export declare abstract class AnnotationW3cMapperService<ANNOTATION> {
5
+ private contextService;
6
+ constructor(contextService: AnnotationContextService);
7
+ getW3CAnnotation(type: string, annotation: ANNOTATION): Promise<W3CAnnotation>;
8
+ fromW3CAnnotation(type: string, annotation: W3CAnnotation): Promise<ANNOTATION>;
9
+ abstract mapToW3CAnnotation(context: AnnotationContext | undefined | null, annotation: ANNOTATION): W3CAnnotation;
10
+ abstract mapFromW3CAnnotation(context: AnnotationContext | undefined | null, annotation: W3CAnnotation): ANNOTATION;
11
+ }
@@ -0,0 +1,9 @@
1
+ export declare abstract class AnnotationCrudRepository<ANNOTATION> {
2
+ abstract delete(id: string): Promise<boolean>;
3
+ abstract create(annotation: ANNOTATION): Promise<ANNOTATION>;
4
+ abstract update(id: string, annotation: ANNOTATION): Promise<ANNOTATION>;
5
+ abstract findOne(id: string): Promise<{
6
+ annotation: ANNOTATION;
7
+ type: string;
8
+ }>;
9
+ }
@@ -1,11 +1,12 @@
1
- import { DynamicModule, Type } from '@nestjs/common';
1
+ import { DynamicModule } from '@nestjs/common';
2
2
  import { AnnotationDefConfig } from '@ghentcdh/annotation-core';
3
- import { AnnotationDefinitionService } from './service/annotation-definition.service';
4
- type AnnotationApiConfig = {
5
- annotationDefinitionService: Type<AnnotationDefinitionService>;
3
+ import { AnnotationCrudRepository } from './annotation/annotation.repository';
4
+ import { AnnotationW3cMapperService } from './annotation/annotation.mapper.service';
5
+ type AnnotationRepositoryConfig<ANNOTATION> = {
6
+ repository: new (...args: any[]) => AnnotationCrudRepository<ANNOTATION>;
7
+ mapper: new (...args: any[]) => AnnotationW3cMapperService<ANNOTATION>;
6
8
  };
7
9
  export declare class AnnotationApiModule {
8
- static forService(config: AnnotationApiConfig): DynamicModule;
9
- static forResourceDir(dirPath: string, config: AnnotationDefConfig): Promise<DynamicModule>;
10
+ static forResourceDir<ANNOTATION>(resourcePath: string, datasourcePath: string, config: AnnotationDefConfig, annotation?: AnnotationRepositoryConfig<ANNOTATION>): Promise<DynamicModule>;
10
11
  }
11
12
  export {};
@@ -1,65 +1,17 @@
1
- import { AnnotationDefConfig } from '@ghentcdh/annotation-core';
2
- import { AnnotationDefinitionService } from './service/annotation-definition.service';
1
+ import { AnnotationJsonResource } from '@ghentcdh/annotation-core';
2
+ import { ResourceConfigRegistry } from '@ghentcdh/crouton-api';
3
+ import { AnnotationContextService } from './context/annotation-context.service';
3
4
  export declare class AnnotationNamespaceController {
4
5
  private readonly service;
5
- private readonly annotationDefConfig;
6
- constructor(service: AnnotationDefinitionService, annotationDefConfig: AnnotationDefConfig);
7
- getAll(): Promise<{
8
- id: string;
9
- name: string;
10
- columns: Record<string, never>[];
11
- color: string;
12
- isRoot: boolean;
13
- context: unknown;
14
- json_schema?: any;
15
- json_ld?: any;
16
- ui_schema?: any;
17
- metadata_schema?: any;
18
- type?: string | undefined;
19
- icon?: string | undefined;
20
- allowedChildren?: string[] | undefined;
21
- allowedLinks?: string[] | undefined;
22
- target?: "gutter" | "underline" | "highlight" | undefined;
23
- }[]>;
24
- getJsonLd_(id: string): Promise<any>;
25
- getSchemas(id: string): Promise<{
26
- id: string;
27
- name: string;
28
- json_schema: any;
29
- ui_schema: any;
30
- metadata_schema: any;
31
- columns: Record<string, never>[];
32
- isRoot: boolean;
33
- allowedChildren: string[] | undefined;
34
- allowedLinks: string[] | undefined;
35
- type: string | undefined;
36
- icon: string | undefined;
37
- target: "gutter" | "underline" | "highlight" | undefined;
38
- }>;
39
- getById(id: string): Promise<{
40
- id: string;
41
- name: string;
42
- columns: Record<string, never>[];
43
- color: string;
44
- isRoot: boolean;
45
- context: unknown;
46
- json_schema?: any;
47
- json_ld?: any;
48
- ui_schema?: any;
49
- metadata_schema?: any;
50
- type?: string | undefined;
51
- icon?: string | undefined;
52
- allowedChildren?: string[] | undefined;
53
- allowedLinks?: string[] | undefined;
54
- target?: "gutter" | "underline" | "highlight" | undefined;
55
- }>;
56
- getFullJsonLd(): Promise<{
57
- '@context': Record<string, unknown>;
58
- }[]>;
59
- getJsonLd(type: string): Promise<{
60
- jsonLd: {
61
- '@context': Record<string, unknown>;
62
- };
63
- forms: any;
6
+ private readonly annotationContextService;
7
+ constructor(service: ResourceConfigRegistry<AnnotationJsonResource>, annotationContextService: AnnotationContextService);
8
+ listNames(): Promise<{
9
+ annotations: {
10
+ id: string;
11
+ name: string;
12
+ schemas: string;
13
+ jsonld: string;
14
+ }[];
64
15
  }>;
16
+ getJsonLd_(id: string): Promise<string | undefined>;
65
17
  }
@@ -0,0 +1,12 @@
1
+ import { AnnotationContext, AnnotationDefConfig, AnnotationResource } from '@ghentcdh/annotation-core';
2
+ import { ResourceConfigRegistry } from '@ghentcdh/crouton-api';
3
+ export declare class AnnotationContextService {
4
+ private readonly configRegistry;
5
+ private readonly annotationDefConfig;
6
+ private readonly contextConfigMap;
7
+ private readonly prefixMap;
8
+ constructor(configRegistry: ResourceConfigRegistry<AnnotationResource>, annotationDefConfig: AnnotationDefConfig);
9
+ reloadAll(): Promise<void>;
10
+ findById(annotationId: string): Promise<AnnotationContext | null>;
11
+ getResourceIdFromUri: (uri: string) => string | null;
12
+ }
@@ -0,0 +1 @@
1
+ export * from './annotation-context.service';
@@ -0,0 +1 @@
1
+ export declare const SCHEMA_PREFIX = "annotation-editor";
@@ -0,0 +1 @@
1
+ export declare const createSchemaEnricher: (baseUrl?: string) => (schema: any) => Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghentcdh/annotation-api",
3
- "version": "0.0.1-alpha.1",
3
+ "version": "0.0.1-alpha.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/GhentCDH/annotation-editor"
@@ -9,7 +9,10 @@
9
9
  "main": "./index.js",
10
10
  "types": "./index.d.ts",
11
11
  "peerDependencies": {
12
- "@ghentcdh/w3c-utils": "^1.0.6",
12
+ "@ghentcdh/w3c-utils": "^1.0.11",
13
13
  "@nestjs/common": "^11.1.19"
14
+ },
15
+ "dependencies": {
16
+ "@ghentcdh/crouton-api": "0.0.1-alpha.55"
14
17
  }
15
- }
18
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # annotation-api
2
-
3
- This library was generated with [Nx](https://nx.dev).
@@ -1,10 +0,0 @@
1
- import { AnnotationResourceDefinition } from '@ghentcdh/annotation-core';
2
- export declare class AnnotationResourceDefinitionService {
3
- private readonly byType;
4
- constructor(definitions: AnnotationResourceDefinition[]);
5
- findAll: () => AnnotationResourceDefinition[];
6
- getResourceForType: (type: string) => AnnotationResourceDefinition | null;
7
- getResourceFromUri: (uri: string) => (AnnotationResourceDefinition & {
8
- id: string;
9
- }) | null;
10
- }
@@ -1,2 +0,0 @@
1
- import { AnnotationResourceDefinition, AnnotationDefConfig } from '@ghentcdh/annotation-core';
2
- export declare const loadAnnotationResourcesFromDir: (dirPath: string, config: AnnotationDefConfig) => AnnotationResourceDefinition[];
@@ -1,26 +0,0 @@
1
- import { AnnotationDefinition, AnnotationDefConfig } from '@ghentcdh/annotation-core';
2
- import { AnnotationDefinitionService } from './annotation-definition.service';
3
- type AnnotationDefinitionLoaderFn = () => AnnotationDefinition[];
4
- export declare class AnnotationDefinitionFromFilesService extends AnnotationDefinitionService {
5
- private readonly _initialDefinitions;
6
- private readonly _loaderFn?;
7
- constructor(config: AnnotationDefConfig, _initialDefinitions: AnnotationDefinition[], _loaderFn?: AnnotationDefinitionLoaderFn | undefined);
8
- protected reloadDefinitions: () => Promise<{
9
- id: string;
10
- name: string;
11
- columns: Record<string, never>[];
12
- color: string;
13
- isRoot: boolean;
14
- context: unknown;
15
- json_schema?: any;
16
- json_ld?: any;
17
- ui_schema?: any;
18
- metadata_schema?: any;
19
- type?: string | undefined;
20
- icon?: string | undefined;
21
- allowedChildren?: string[] | undefined;
22
- allowedLinks?: string[] | undefined;
23
- target?: "gutter" | "underline" | "highlight" | undefined;
24
- }[]>;
25
- }
26
- export {};
@@ -1,2 +0,0 @@
1
- import { AnnotationDefinition, AnnotationDefConfig, ContextBuilderFactory } from '@ghentcdh/annotation-core';
2
- export declare const loadAnnotationDefinitionsFromDir: (dirPath: string, annotationDefConfig: AnnotationDefConfig, contextBuilderFactory: ContextBuilderFactory) => AnnotationDefinition[];
@@ -1,16 +0,0 @@
1
- import { ContextBuilder } from '@ghentcdh/w3c-utils';
2
- import { AnnotationDefinition, AnnotationDefConfig } from '@ghentcdh/annotation-core';
3
- export declare abstract class AnnotationDefinitionService {
4
- protected readonly config: AnnotationDefConfig;
5
- private definitions;
6
- private groupedDefinitions;
7
- private cachedAt;
8
- constructor(config: AnnotationDefConfig);
9
- findAllGrouped(): Promise<Record<string, AnnotationDefinition>>;
10
- protected abstract reloadDefinitions(): Promise<AnnotationDefinition[]>;
11
- setDefinitions(force?: boolean): Promise<void>;
12
- findAll(): Promise<AnnotationDefinition[]>;
13
- findById(id: string): Promise<AnnotationDefinition>;
14
- getAllContextBuilders(): Promise<ContextBuilder[]>;
15
- getContextBuilder(type: string): Promise<ContextBuilder>;
16
- }