@ghentcdh/annotation-api 0.0.1-alpha.4 → 0.0.1-alpha.5
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/index.cjs +1 -1
- package/index.d.ts +1 -1
- package/index.js +112 -109
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@nestjs/common"),t=require("zod"),n=require("@ghentcdh/w3c-utils")
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@nestjs/common"),t=require("zod"),n=require("@ghentcdh/w3c-utils"),r=require("@ghentcdh/annotated-text"),i=require("node:fs"),a=require("node:path"),o=require("@nestjs/swagger");var s=`AnnotationMetadata`,c=t.z.object({}),l=t.z.object({id:t.z.string(),name:t.z.string(),columns:t.z.array(c),json_schema:t.z.any().optional(),json_ld:t.z.any().optional(),ui_schema:t.z.any().optional(),metadata_schema:t.z.any().optional(),color:t.z.string(),type:t.z.string().optional(),icon:t.z.string().optional(),isRoot:t.z.boolean().default(!0),allowedChildren:t.z.array(t.z.string()).optional(),allowedLinks:t.z.array(t.z.string()).optional(),context:t.z.custom(),target:t.z.enum([`gutter`,`underline`,`highlight`]).optional()}),u={baseUrl:`http://localhost:3000/`,app:`ghentcdh`,prefix:`ghentcdh`,isDev:!1,cacheTTLms:1200*1e3},d=(e={})=>{let t=e.baseUrl??u.baseUrl,n=t.endsWith(`/`)?t:`${t}/`,r=e.isDev??!1,i=r?0:1200*1e3;return{baseUrl:n,contextUrl:`${n}ns/`,app:e.app??u.app,prefix:e.prefix??u.prefix,isDev:r,cacheTTLms:i}},f=(e,t)=>{let{prefix:r,baseUrl:i,contextUrl:a}=d(t),o=s;return(0,n.contextBuilder)(r,i).setType(r,o).addPrefix(e,`${r}:${e}`).setContextUri(`${a}${e}.jsonld`)},p=`annotation.style`,m=t.z.object({id:t.z.string(),name:t.z.string(),target:t.z.enum([`gutter`,`underline`,`highlight`]).optional().default(`underline`),color:t.z.string().optional()}),h=`AnnotationStyle`,g=e=>{let{prefix:t,baseUrl:r,contextUrl:i}=d(e);return(0,n.contextBuilder)(t,r).setType(t,h).setContextUri(`${i}${h}.jsonld`).parseZodSchema(m)},_=(e,t)=>{let n=g(e).toAnnotationBodyUnsafe(t);return n.success||(r.Debugger.debug(p,`AnnotationStyleContextBuilder safe parse failed`),r.Debugger.warn(n.error)),n},v=e=>{let t={};if(e.fieldInput){let{type:n,options:r}=e.fieldInput;t.format=n,n===`autocomplete`&&(t.dataField=`data`,r.uri&&(t.uri=r.uri),r.resource&&(t.resource=r.resource),r.valueKey&&(t.valueKey=r.valueKey),r.labelKey&&(t.labelKey=r.labelKey),r.enableCreate!==void 0&&(t.enableCreate=r.enableCreate))}return{type:`Control`,scope:`#/properties/${e.id}`,options:t}},y=e=>({type:`TextCell`,scope:`#/properties/${e.id}`,options:{format:`keyValue`,key:e.fieldInput?.options?.labelKey??e.displayKey??`label`}}),b=e=>({type:`GridLayout`,elements:e.filter(e=>!e.hiddenInForm).map(v),options:{}}),x=e=>({type:`GridLayout`,elements:e.filter(e=>!e.hiddenInMetadata).map(y),options:{}}),S=e=>{if(e.type===`object`&&e.properties){let n={};for(let[t,r]of Object.entries(e.properties))n[t]=S(r);return t.z.object(n)}return t.z.string()},C=(e,n,r)=>{let i=f(e,r),a=n.columns??[];if(!a.length)return i;let o={};for(let e of a)e.type&&(o[e.id]=S(e.type));return Object.keys(o).length?i.parseZodSchema(t.z.object(o)):i},w=(e,t,n=C)=>{let r=n(e.id,e,t),i=e.columns??[],a=i.length>0,o=e.ui_schema??(a?b(i):void 0),s=e.metadata_schema??(a?x(i):void 0),c={id:e.id,name:e.name,color:e.color,isRoot:e.isRoot??!0,columns:i,context:r,json_ld:r.toJsonLdContext(),json_schema:o?r.toJsonSchema():null};return o&&(c.ui_schema=o),s&&(c.metadata_schema=s),e.type&&(c.type=e.type),e.icon&&(c.icon=e.icon),e.target&&(c.target=e.target),e.allowedChildren&&(c.allowedChildren=e.allowedChildren),e.allowedLinks&&(c.allowedLinks=e.allowedLinks),c},T=(e,t,n)=>e.map(e=>w(e,t,n)),E=Symbol(`ANNOTATION_DEF_CONFIG_TOKEN`);function D(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function O(e,t){return function(n,r){t(n,r,e)}}function k(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var A=class{config;definitions=[];groupedDefinitions={};cachedAt=0;constructor(e){this.config=e}async findAllGrouped(){return await this.setDefinitions(),Promise.resolve(this.groupedDefinitions)}async setDefinitions(e=!1){let t=Date.now();if(!e&&this.definitions.length&&t-this.cachedAt<this.config.cacheTTLms)return;let n=await this.reloadDefinitions()??[];this.definitions=n,this.groupedDefinitions=n.reduce((e,t)=>(e[t.id]=t,e),{}),this.cachedAt=t}async findAll(){return await this.setDefinitions(),Promise.resolve(this.definitions)}async findById(t){await this.setDefinitions();let n=this.groupedDefinitions[t];if(n||await this.setDefinitions(!0),n=this.groupedDefinitions[t],!n)throw new e.NotFoundException;return Promise.resolve(n)}async getAllContextBuilders(){return(await this.findAll()).map(e=>e.context)}async getContextBuilder(t){let n=await this.findById(t);if(!n)throw new e.NotFoundException;return n.context}};A=k([(0,e.Injectable)(),O(0,(0,e.Inject)(E)),D(`design:paramtypes`,[Object])],A);var j=class extends A{_initialDefinitions;_loaderFn;constructor(e,t,n){super(e),this._initialDefinitions=t,this._loaderFn=n}reloadDefinitions=()=>this.config.isDev&&this._loaderFn?Promise.resolve(this._loaderFn()):Promise.resolve(this._initialDefinitions??[])};j=k([(0,e.Injectable)(),O(0,(0,e.Inject)(E)),D(`design:paramtypes`,[Object,Array,Object])],j);var M=(e,t,n)=>{if(!(0,i.existsSync)(e))return[];let r=(0,i.readdirSync)(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name),o=[];for(let s of r){let r=(0,a.join)(e,s,`resource.json`);if(!(0,i.existsSync)(r))continue;let c=JSON.parse((0,i.readFileSync)(r,`utf-8`));o.push(w(c,t,n))}return o},N=class{service;annotationDefConfig;constructor(e,t){this.service=e,this.annotationDefConfig=t}getAll(){return this.service.findAll()}async getJsonLd_(e){return e===`AnnotationStyle`?g(this.annotationDefConfig).toJsonLdContext():(await this.service.findById(e))?.json_ld}async getSchemas(e){let t=await this.service.findById(e);return{id:t.id,name:t.name,json_schema:t.json_schema,ui_schema:t.ui_schema,metadata_schema:t.metadata_schema,columns:t.columns,isRoot:t.isRoot,allowedChildren:t.allowedChildren,allowedLinks:t.allowedLinks,type:t.type,icon:t.icon,target:t.target}}async getById(e){return await this.service.findById(e)}async getFullJsonLd(){return(await this.service.getAllContextBuilders()).map(e=>e.toJsonLdContext())}async getJsonLd(e){let t=await this.service.getContextBuilder(e);return{jsonLd:t.toJsonLdContext(),forms:t.toJsonSchema()}}};k([(0,e.Get)(),D(`design:type`,Function),D(`design:paramtypes`,[]),D(`design:returntype`,void 0)],N.prototype,`getAll`,null),k([(0,e.Get)(`:id.jsonld`),O(0,(0,e.Param)(`id`)),D(`design:type`,Function),D(`design:paramtypes`,[String]),D(`design:returntype`,Promise)],N.prototype,`getJsonLd_`,null),k([(0,e.Get)(`:id/schemas`),O(0,(0,e.Param)(`id`)),D(`design:type`,Function),D(`design:paramtypes`,[String]),D(`design:returntype`,Promise)],N.prototype,`getSchemas`,null),k([(0,e.Get)(`:id`),O(0,(0,e.Param)(`id`)),D(`design:type`,Function),D(`design:paramtypes`,[String]),D(`design:returntype`,Promise)],N.prototype,`getById`,null),k([(0,e.Get)(`anno.jsonld`),D(`design:type`,Function),D(`design:paramtypes`,[]),D(`design:returntype`,Promise)],N.prototype,`getFullJsonLd`,null),k([(0,e.Get)(`:type/anno.jsonld`),O(0,(0,e.Param)(`type`)),D(`design:type`,Function),D(`design:paramtypes`,[String]),D(`design:returntype`,Promise)],N.prototype,`getJsonLd`,null),N=k([(0,e.Controller)(`ns`),(0,o.ApiTags)(`Annotations NS`),O(0,(0,e.Inject)(A)),O(1,(0,e.Inject)(E)),D(`design:paramtypes`,[A===void 0?Object:A,Object])],N);var P=(e,t)=>{let n=(0,a.join)(e,`_resource`);if(!(0,i.existsSync)(n))return[];let r=(0,i.readdirSync)(n).filter(e=>e.endsWith(`.json`)),{prefix:o}=d(t);return r.map(e=>{let t=JSON.parse((0,i.readFileSync)((0,a.join)(n,e),`utf-8`)),r=t.columns.find(e=>e.displayAs===`id`),s=t.columns.find(e=>e.displayAs===`label`);return{type:t.type,table:t.table,database:t.database,field:{id:r?.column??`id`,label:s?.column??`name`},prefix:`${o}:${t.type}/`}})},F=class{byType=new Map;constructor(e){for(let t of e)this.byType.set(t.type,t)}findAll=()=>[...this.byType.values()];getResourceForType=e=>this.byType.get(e)??null;getResourceFromUri=e=>{for(let t of this.byType.values())if(e.startsWith(t.prefix))return{...t,id:e.substring(t.prefix.length)};return null}};F=k([(0,e.Injectable)(),D(`design:paramtypes`,[Array])],F);var I,L=I=class{static forService(e){return{module:I,global:!0,controllers:[N],providers:[{provide:A,useClass:e.annotationDefinitionService}],exports:[A]}}static async forResourceDir(e,t){let n=()=>M(e,t,C),r=new j(t,n(),n),i=new F(P(e,t));return{module:I,global:!0,controllers:[N],providers:[{provide:E,useValue:t},{provide:A,useValue:r},{provide:F,useValue:i}],exports:[A,F]}}};L=I=k([(0,e.Module)({controllers:[],providers:[],exports:[]})],L),exports.ANNOTATION_DEF_CONFIG_TOKEN=E,Object.defineProperty(exports,"AnnotationApiModule",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"AnnotationDefinitionFromFilesService",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"AnnotationDefinitionService",{enumerable:!0,get:function(){return A}}),exports.AnnotationMetadataType=s,Object.defineProperty(exports,"AnnotationResourceDefinitionService",{enumerable:!0,get:function(){return F}}),exports.AnnotationStyleContextBuilder=g,exports.AnnotationStyleType=h,exports.annotationColumnDefinition=c,exports.annotationContextBuilderFactory=C,exports.annotationDefinition=l,exports.baseContextBuilder=f,exports.buildAnnotationDefinition=w,exports.buildAnnotationDefinitions=T,exports.buildMetadataSchema=x,exports.buildUiSchema=b,exports.createAnnotationStyleBodyUnsafe=_,exports.jsonSchemaPropertyToZod=S,exports.loadAnnotationDefinitionsFromDir=M,exports.loadAnnotationResourcesFromDir=P,exports.resolveConfig=d;
|
package/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export * from './lib/service/annotation-definition.loader';
|
|
|
5
5
|
export * from './lib/resource/annotation-resource-definition.service';
|
|
6
6
|
export * from './lib/resource/annotation-resource.loader';
|
|
7
7
|
export * from './lib/utils/annotation.context-builder';
|
|
8
|
-
export
|
|
8
|
+
export * from '@ghentcdh/annotation-core';
|
package/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Controller as e, Get as t, Inject as n, Injectable as r, Module as i, NotFoundException as a, Param as o } from "@nestjs/common";
|
|
2
2
|
import { z as s } from "zod";
|
|
3
3
|
import { contextBuilder as c } from "@ghentcdh/w3c-utils";
|
|
4
|
-
import "@ghentcdh/annotated-text";
|
|
5
|
-
import { existsSync as
|
|
6
|
-
import { join as
|
|
7
|
-
import { ApiTags as
|
|
4
|
+
import { Debugger as l } from "@ghentcdh/annotated-text";
|
|
5
|
+
import { existsSync as u, readFileSync as d, readdirSync as f } from "node:fs";
|
|
6
|
+
import { join as p } from "node:path";
|
|
7
|
+
import { ApiTags as m } from "@nestjs/swagger";
|
|
8
8
|
//#region packages/annotation-core/src/lib/types/annotation.contex.ts
|
|
9
|
-
var
|
|
9
|
+
var h = "AnnotationMetadata", g = s.object({}), _ = s.object({
|
|
10
10
|
id: s.string(),
|
|
11
11
|
name: s.string(),
|
|
12
|
-
columns: s.array(
|
|
12
|
+
columns: s.array(g),
|
|
13
13
|
json_schema: s.any().optional(),
|
|
14
14
|
json_ld: s.any().optional(),
|
|
15
15
|
ui_schema: s.any().optional(),
|
|
@@ -26,26 +26,26 @@ var m = "AnnotationMetadata", h = s.object({}), g = s.object({
|
|
|
26
26
|
"underline",
|
|
27
27
|
"highlight"
|
|
28
28
|
]).optional()
|
|
29
|
-
}),
|
|
29
|
+
}), v = {
|
|
30
30
|
baseUrl: "http://localhost:3000/",
|
|
31
31
|
app: "ghentcdh",
|
|
32
32
|
prefix: "ghentcdh",
|
|
33
33
|
isDev: !1,
|
|
34
34
|
cacheTTLms: 1200 * 1e3
|
|
35
|
-
},
|
|
36
|
-
let t = e.baseUrl ??
|
|
35
|
+
}, y = (e = {}) => {
|
|
36
|
+
let t = e.baseUrl ?? v.baseUrl, n = t.endsWith("/") ? t : `${t}/`, r = e.isDev ?? !1, i = r ? 0 : 1200 * 1e3;
|
|
37
37
|
return {
|
|
38
38
|
baseUrl: n,
|
|
39
39
|
contextUrl: `${n}ns/`,
|
|
40
|
-
app: e.app ??
|
|
41
|
-
prefix: e.prefix ??
|
|
40
|
+
app: e.app ?? v.app,
|
|
41
|
+
prefix: e.prefix ?? v.prefix,
|
|
42
42
|
isDev: r,
|
|
43
43
|
cacheTTLms: i
|
|
44
44
|
};
|
|
45
|
-
},
|
|
46
|
-
let { prefix: n, baseUrl: r, contextUrl: i } =
|
|
45
|
+
}, b = (e, t) => {
|
|
46
|
+
let { prefix: n, baseUrl: r, contextUrl: i } = y(t), a = h;
|
|
47
47
|
return c(n, r).setType(n, a).addPrefix(e, `${n}:${e}`).setContextUri(`${i}${e}.jsonld`);
|
|
48
|
-
},
|
|
48
|
+
}, x = "annotation.style", S = s.object({
|
|
49
49
|
id: s.string(),
|
|
50
50
|
name: s.string(),
|
|
51
51
|
target: s.enum([
|
|
@@ -54,10 +54,13 @@ var m = "AnnotationMetadata", h = s.object({}), g = s.object({
|
|
|
54
54
|
"highlight"
|
|
55
55
|
]).optional().default("underline"),
|
|
56
56
|
color: s.string().optional()
|
|
57
|
-
}),
|
|
58
|
-
let { prefix: t, baseUrl: n, contextUrl: r } =
|
|
59
|
-
return c(t, n).setType(t,
|
|
60
|
-
},
|
|
57
|
+
}), C = "AnnotationStyle", w = (e) => {
|
|
58
|
+
let { prefix: t, baseUrl: n, contextUrl: r } = y(e);
|
|
59
|
+
return c(t, n).setType(t, C).setContextUri(`${r}${C}.jsonld`).parseZodSchema(S);
|
|
60
|
+
}, T = (e, t) => {
|
|
61
|
+
let n = w(e).toAnnotationBodyUnsafe(t);
|
|
62
|
+
return n.success || (l.debug(x, "AnnotationStyleContextBuilder safe parse failed"), l.warn(n.error)), n;
|
|
63
|
+
}, E = (e) => {
|
|
61
64
|
let t = {};
|
|
62
65
|
if (e.fieldInput) {
|
|
63
66
|
let { type: n, options: r } = e.fieldInput;
|
|
@@ -68,36 +71,36 @@ var m = "AnnotationMetadata", h = s.object({}), g = s.object({
|
|
|
68
71
|
scope: `#/properties/${e.id}`,
|
|
69
72
|
options: t
|
|
70
73
|
};
|
|
71
|
-
},
|
|
74
|
+
}, D = (e) => ({
|
|
72
75
|
type: "TextCell",
|
|
73
76
|
scope: `#/properties/${e.id}`,
|
|
74
77
|
options: {
|
|
75
78
|
format: "keyValue",
|
|
76
79
|
key: e.fieldInput?.options?.labelKey ?? e.displayKey ?? "label"
|
|
77
80
|
}
|
|
78
|
-
}),
|
|
81
|
+
}), O = (e) => ({
|
|
79
82
|
type: "GridLayout",
|
|
80
|
-
elements: e.filter((e) => !e.hiddenInForm).map(
|
|
83
|
+
elements: e.filter((e) => !e.hiddenInForm).map(E),
|
|
81
84
|
options: {}
|
|
82
|
-
}),
|
|
85
|
+
}), k = (e) => ({
|
|
83
86
|
type: "GridLayout",
|
|
84
|
-
elements: e.filter((e) => !e.hiddenInMetadata).map(
|
|
87
|
+
elements: e.filter((e) => !e.hiddenInMetadata).map(D),
|
|
85
88
|
options: {}
|
|
86
|
-
}),
|
|
89
|
+
}), A = (e) => {
|
|
87
90
|
if (e.type === "object" && e.properties) {
|
|
88
91
|
let t = {};
|
|
89
|
-
for (let [n, r] of Object.entries(e.properties)) t[n] =
|
|
92
|
+
for (let [n, r] of Object.entries(e.properties)) t[n] = A(r);
|
|
90
93
|
return s.object(t);
|
|
91
94
|
}
|
|
92
95
|
return s.string();
|
|
93
|
-
},
|
|
94
|
-
let r =
|
|
96
|
+
}, j = (e, t, n) => {
|
|
97
|
+
let r = b(e, n), i = t.columns ?? [];
|
|
95
98
|
if (!i.length) return r;
|
|
96
99
|
let a = {};
|
|
97
|
-
for (let e of i) e.type && (a[e.id] =
|
|
100
|
+
for (let e of i) e.type && (a[e.id] = A(e.type));
|
|
98
101
|
return Object.keys(a).length ? r.parseZodSchema(s.object(a)) : r;
|
|
99
|
-
},
|
|
100
|
-
let r = n(e.id, e, t), i = e.columns ?? [], a = i.length > 0, o = e.ui_schema ?? (a ?
|
|
102
|
+
}, M = (e, t, n = j) => {
|
|
103
|
+
let r = n(e.id, e, t), i = e.columns ?? [], a = i.length > 0, o = e.ui_schema ?? (a ? O(i) : void 0), s = e.metadata_schema ?? (a ? k(i) : void 0), c = {
|
|
101
104
|
id: e.id,
|
|
102
105
|
name: e.name,
|
|
103
106
|
color: e.color,
|
|
@@ -108,22 +111,22 @@ var m = "AnnotationMetadata", h = s.object({}), g = s.object({
|
|
|
108
111
|
json_schema: o ? r.toJsonSchema() : null
|
|
109
112
|
};
|
|
110
113
|
return o && (c.ui_schema = o), s && (c.metadata_schema = s), e.type && (c.type = e.type), e.icon && (c.icon = e.icon), e.target && (c.target = e.target), e.allowedChildren && (c.allowedChildren = e.allowedChildren), e.allowedLinks && (c.allowedLinks = e.allowedLinks), c;
|
|
111
|
-
},
|
|
114
|
+
}, N = (e, t, n) => e.map((e) => M(e, t, n)), P = Symbol("ANNOTATION_DEF_CONFIG_TOKEN");
|
|
112
115
|
//#endregion
|
|
113
116
|
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateMetadata.js
|
|
114
|
-
function
|
|
117
|
+
function F(e, t) {
|
|
115
118
|
if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
|
|
116
119
|
}
|
|
117
120
|
//#endregion
|
|
118
121
|
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
119
|
-
function
|
|
122
|
+
function I(e, t) {
|
|
120
123
|
return function(n, r) {
|
|
121
124
|
t(n, r, e);
|
|
122
125
|
};
|
|
123
126
|
}
|
|
124
127
|
//#endregion
|
|
125
128
|
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
126
|
-
function
|
|
129
|
+
function L(e, t, n, r) {
|
|
127
130
|
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
128
131
|
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
129
132
|
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
@@ -131,7 +134,7 @@ function N(e, t, n, r) {
|
|
|
131
134
|
}
|
|
132
135
|
//#endregion
|
|
133
136
|
//#region packages/annotation-api/src/lib/service/annotation-definition.service.ts
|
|
134
|
-
var
|
|
137
|
+
var R = class {
|
|
135
138
|
config;
|
|
136
139
|
definitions = [];
|
|
137
140
|
groupedDefinitions = {};
|
|
@@ -166,14 +169,14 @@ var P = class {
|
|
|
166
169
|
return t.context;
|
|
167
170
|
}
|
|
168
171
|
};
|
|
169
|
-
|
|
172
|
+
R = L([
|
|
170
173
|
r(),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
],
|
|
174
|
+
I(0, n(P)),
|
|
175
|
+
F("design:paramtypes", [Object])
|
|
176
|
+
], R);
|
|
174
177
|
//#endregion
|
|
175
178
|
//#region packages/annotation-api/src/lib/service/annotation-definition-from-files.service.ts
|
|
176
|
-
var
|
|
179
|
+
var z = class extends R {
|
|
177
180
|
_initialDefinitions;
|
|
178
181
|
_loaderFn;
|
|
179
182
|
constructor(e, t, n) {
|
|
@@ -181,28 +184,28 @@ var F = class extends P {
|
|
|
181
184
|
}
|
|
182
185
|
reloadDefinitions = () => this.config.isDev && this._loaderFn ? Promise.resolve(this._loaderFn()) : Promise.resolve(this._initialDefinitions ?? []);
|
|
183
186
|
};
|
|
184
|
-
|
|
187
|
+
z = L([
|
|
185
188
|
r(),
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
I(0, n(P)),
|
|
190
|
+
F("design:paramtypes", [
|
|
188
191
|
Object,
|
|
189
192
|
Array,
|
|
190
193
|
Object
|
|
191
194
|
])
|
|
192
|
-
],
|
|
195
|
+
], z);
|
|
193
196
|
//#endregion
|
|
194
197
|
//#region packages/annotation-api/src/lib/service/annotation-definition.loader.ts
|
|
195
|
-
var
|
|
196
|
-
if (!
|
|
197
|
-
let r =
|
|
198
|
+
var B = (e, t, n) => {
|
|
199
|
+
if (!u(e)) return [];
|
|
200
|
+
let r = f(e, { withFileTypes: !0 }).filter((e) => e.isDirectory()).map((e) => e.name), i = [];
|
|
198
201
|
for (let a of r) {
|
|
199
|
-
let r =
|
|
200
|
-
if (!
|
|
201
|
-
let o = JSON.parse(
|
|
202
|
-
i.push(
|
|
202
|
+
let r = p(e, a, "resource.json");
|
|
203
|
+
if (!u(r)) continue;
|
|
204
|
+
let o = JSON.parse(d(r, "utf-8"));
|
|
205
|
+
i.push(M(o, t, n));
|
|
203
206
|
}
|
|
204
207
|
return i;
|
|
205
|
-
},
|
|
208
|
+
}, V = class {
|
|
206
209
|
service;
|
|
207
210
|
annotationDefConfig;
|
|
208
211
|
constructor(e, t) {
|
|
@@ -212,7 +215,7 @@ var I = (e, t, n) => {
|
|
|
212
215
|
return this.service.findAll();
|
|
213
216
|
}
|
|
214
217
|
async getJsonLd_(e) {
|
|
215
|
-
return e === "AnnotationStyle" ?
|
|
218
|
+
return e === "AnnotationStyle" ? w(this.annotationDefConfig).toJsonLdContext() : (await this.service.findById(e))?.json_ld;
|
|
216
219
|
}
|
|
217
220
|
async getSchemas(e) {
|
|
218
221
|
let t = await this.service.findById(e);
|
|
@@ -245,55 +248,55 @@ var I = (e, t, n) => {
|
|
|
245
248
|
};
|
|
246
249
|
}
|
|
247
250
|
};
|
|
248
|
-
|
|
251
|
+
L([
|
|
249
252
|
t(),
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
],
|
|
253
|
+
F("design:type", Function),
|
|
254
|
+
F("design:paramtypes", []),
|
|
255
|
+
F("design:returntype", void 0)
|
|
256
|
+
], V.prototype, "getAll", null), L([
|
|
254
257
|
t(":id.jsonld"),
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
],
|
|
258
|
+
I(0, o("id")),
|
|
259
|
+
F("design:type", Function),
|
|
260
|
+
F("design:paramtypes", [String]),
|
|
261
|
+
F("design:returntype", Promise)
|
|
262
|
+
], V.prototype, "getJsonLd_", null), L([
|
|
260
263
|
t(":id/schemas"),
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
],
|
|
264
|
+
I(0, o("id")),
|
|
265
|
+
F("design:type", Function),
|
|
266
|
+
F("design:paramtypes", [String]),
|
|
267
|
+
F("design:returntype", Promise)
|
|
268
|
+
], V.prototype, "getSchemas", null), L([
|
|
266
269
|
t(":id"),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
],
|
|
270
|
+
I(0, o("id")),
|
|
271
|
+
F("design:type", Function),
|
|
272
|
+
F("design:paramtypes", [String]),
|
|
273
|
+
F("design:returntype", Promise)
|
|
274
|
+
], V.prototype, "getById", null), L([
|
|
272
275
|
t("anno.jsonld"),
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
],
|
|
276
|
+
F("design:type", Function),
|
|
277
|
+
F("design:paramtypes", []),
|
|
278
|
+
F("design:returntype", Promise)
|
|
279
|
+
], V.prototype, "getFullJsonLd", null), L([
|
|
277
280
|
t(":type/anno.jsonld"),
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
],
|
|
281
|
+
I(0, o("type")),
|
|
282
|
+
F("design:type", Function),
|
|
283
|
+
F("design:paramtypes", [String]),
|
|
284
|
+
F("design:returntype", Promise)
|
|
285
|
+
], V.prototype, "getJsonLd", null), V = L([
|
|
283
286
|
e("ns"),
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
],
|
|
287
|
+
m("Annotations NS"),
|
|
288
|
+
I(0, n(R)),
|
|
289
|
+
I(1, n(P)),
|
|
290
|
+
F("design:paramtypes", [R === void 0 ? Object : R, Object])
|
|
291
|
+
], V);
|
|
289
292
|
//#endregion
|
|
290
293
|
//#region packages/annotation-api/src/lib/resource/annotation-resource.loader.ts
|
|
291
|
-
var
|
|
292
|
-
let n =
|
|
293
|
-
if (!
|
|
294
|
-
let r =
|
|
294
|
+
var H = (e, t) => {
|
|
295
|
+
let n = p(e, "_resource");
|
|
296
|
+
if (!u(n)) return [];
|
|
297
|
+
let r = f(n).filter((e) => e.endsWith(".json")), { prefix: i } = y(t);
|
|
295
298
|
return r.map((e) => {
|
|
296
|
-
let t = JSON.parse(
|
|
299
|
+
let t = JSON.parse(d(p(n, e), "utf-8")), r = t.columns.find((e) => e.displayAs === "id"), a = t.columns.find((e) => e.displayAs === "label");
|
|
297
300
|
return {
|
|
298
301
|
type: t.type,
|
|
299
302
|
table: t.table,
|
|
@@ -305,7 +308,7 @@ var R = (e, t) => {
|
|
|
305
308
|
prefix: `${i}:${t.type}/`
|
|
306
309
|
};
|
|
307
310
|
});
|
|
308
|
-
},
|
|
311
|
+
}, U = class {
|
|
309
312
|
byType = /* @__PURE__ */ new Map();
|
|
310
313
|
constructor(e) {
|
|
311
314
|
for (let t of e) this.byType.set(t.type, t);
|
|
@@ -320,50 +323,50 @@ var R = (e, t) => {
|
|
|
320
323
|
return null;
|
|
321
324
|
};
|
|
322
325
|
};
|
|
323
|
-
|
|
326
|
+
U = L([r(), F("design:paramtypes", [Array])], U);
|
|
324
327
|
//#endregion
|
|
325
328
|
//#region packages/annotation-api/src/lib/annotation-api.module.ts
|
|
326
|
-
var
|
|
329
|
+
var W, G = W = class {
|
|
327
330
|
static forService(e) {
|
|
328
331
|
return {
|
|
329
|
-
module:
|
|
332
|
+
module: W,
|
|
330
333
|
global: !0,
|
|
331
|
-
controllers: [
|
|
334
|
+
controllers: [V],
|
|
332
335
|
providers: [{
|
|
333
|
-
provide:
|
|
336
|
+
provide: R,
|
|
334
337
|
useClass: e.annotationDefinitionService
|
|
335
338
|
}],
|
|
336
|
-
exports: [
|
|
339
|
+
exports: [R]
|
|
337
340
|
};
|
|
338
341
|
}
|
|
339
342
|
static async forResourceDir(e, t) {
|
|
340
|
-
let n = () =>
|
|
343
|
+
let n = () => B(e, t, j), r = new z(t, n(), n), i = new U(H(e, t));
|
|
341
344
|
return {
|
|
342
|
-
module:
|
|
345
|
+
module: W,
|
|
343
346
|
global: !0,
|
|
344
|
-
controllers: [
|
|
347
|
+
controllers: [V],
|
|
345
348
|
providers: [
|
|
346
349
|
{
|
|
347
|
-
provide:
|
|
350
|
+
provide: P,
|
|
348
351
|
useValue: t
|
|
349
352
|
},
|
|
350
353
|
{
|
|
351
|
-
provide:
|
|
354
|
+
provide: R,
|
|
352
355
|
useValue: r
|
|
353
356
|
},
|
|
354
357
|
{
|
|
355
|
-
provide:
|
|
358
|
+
provide: U,
|
|
356
359
|
useValue: i
|
|
357
360
|
}
|
|
358
361
|
],
|
|
359
|
-
exports: [
|
|
362
|
+
exports: [R, U]
|
|
360
363
|
};
|
|
361
364
|
}
|
|
362
365
|
};
|
|
363
|
-
|
|
366
|
+
G = W = L([i({
|
|
364
367
|
controllers: [],
|
|
365
368
|
providers: [],
|
|
366
369
|
exports: []
|
|
367
|
-
})],
|
|
370
|
+
})], G);
|
|
368
371
|
//#endregion
|
|
369
|
-
export {
|
|
372
|
+
export { P as ANNOTATION_DEF_CONFIG_TOKEN, G as AnnotationApiModule, z as AnnotationDefinitionFromFilesService, R as AnnotationDefinitionService, h as AnnotationMetadataType, U as AnnotationResourceDefinitionService, w as AnnotationStyleContextBuilder, C as AnnotationStyleType, g as annotationColumnDefinition, j as annotationContextBuilderFactory, _ as annotationDefinition, b as baseContextBuilder, M as buildAnnotationDefinition, N as buildAnnotationDefinitions, k as buildMetadataSchema, O as buildUiSchema, T as createAnnotationStyleBodyUnsafe, A as jsonSchemaPropertyToZod, B as loadAnnotationDefinitionsFromDir, H as loadAnnotationResourcesFromDir, y as resolveConfig };
|