@_linked/server 2.0.1 → 2.0.2

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/esm/backend.d.ts +6 -0
  3. package/lib/esm/backend.js +27 -0
  4. package/lib/esm/backend.js.map +1 -0
  5. package/lib/esm/index.d.ts +9 -0
  6. package/lib/esm/index.js +11 -0
  7. package/lib/esm/index.js.map +1 -0
  8. package/lib/esm/ontologies/lincd-server.d.ts +31 -0
  9. package/lib/esm/ontologies/lincd-server.js +42 -0
  10. package/lib/esm/ontologies/lincd-server.js.map +1 -0
  11. package/lib/esm/package.d.ts +4 -0
  12. package/lib/esm/package.js +3 -0
  13. package/lib/esm/package.js.map +1 -0
  14. package/lib/esm/shapes/LincdAPI.d.ts +41 -0
  15. package/lib/esm/shapes/LincdAPI.js +113 -0
  16. package/lib/esm/shapes/LincdAPI.js.map +1 -0
  17. package/lib/esm/shapes/LincdServer.d.ts +79 -0
  18. package/lib/esm/shapes/LincdServer.js +1257 -0
  19. package/lib/esm/shapes/LincdServer.js.map +1 -0
  20. package/lib/esm/shapes/LincdWebApp.d.ts +7 -0
  21. package/lib/esm/shapes/LincdWebApp.js +40 -0
  22. package/lib/esm/shapes/LincdWebApp.js.map +1 -0
  23. package/lib/esm/shapes/filestores/LocalFileStore.d.ts +42 -0
  24. package/lib/esm/shapes/filestores/LocalFileStore.js +93 -0
  25. package/lib/esm/shapes/filestores/LocalFileStore.js.map +1 -0
  26. package/lib/esm/shapes/quadstores/BackendAPIStore.d.ts +33 -0
  27. package/lib/esm/shapes/quadstores/BackendAPIStore.js +65 -0
  28. package/lib/esm/shapes/quadstores/BackendAPIStore.js.map +1 -0
  29. package/lib/esm/shapes/quadstores/BackendAPIStoreProvider.d.ts +13 -0
  30. package/lib/esm/shapes/quadstores/BackendAPIStoreProvider.js +26 -0
  31. package/lib/esm/shapes/quadstores/BackendAPIStoreProvider.js.map +1 -0
  32. package/lib/esm/types/RouteConfig.d.ts +56 -0
  33. package/lib/esm/types/RouteConfig.js +2 -0
  34. package/lib/esm/types/RouteConfig.js.map +1 -0
  35. package/lib/esm/types.d.ts +12 -0
  36. package/lib/esm/types.js +1 -0
  37. package/lib/esm/types.js.map +1 -0
  38. package/lib/esm/utils/Shapes.d.ts +7 -0
  39. package/lib/esm/utils/Shapes.js +59 -0
  40. package/lib/esm/utils/Shapes.js.map +1 -0
  41. package/lib/esm/utils/accessUrl.d.ts +6 -0
  42. package/lib/esm/utils/accessUrl.js +9 -0
  43. package/lib/esm/utils/accessUrl.js.map +1 -0
  44. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @\_linked/server
2
2
 
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#8](https://github.com/linked-cm/server/pull/8) [`17e6771`](https://github.com/linked-cm/server/commit/17e6771ba1c2eae2daf24b97dcb9e934827f4396) Thanks [@flyon](https://github.com/flyon)! - Rebuild against `@_linked/server-utils@1.0.5`. The lockfile previously pinned `1.0.4` whose published tarball was empty, so server's build couldn't resolve `BackendProvider`/`JSONParser`/`JSONWriter`/`RouteConfig`. Lockfile now points at `1.0.5` which ships its `lib/` correctly.
8
+
3
9
  ## 2.0.1
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,6 @@
1
+ import { BackendProvider } from '@_linked/server-utils/utils/BackendProvider';
2
+ export * from './shapes/quadstores/BackendAPIStoreProvider.js';
3
+ export default class LincdServerBackendProvider extends BackendProvider {
4
+ setupBeforeControllers(): Promise<void>;
5
+ getShapes(): Record<string, import("@_linked/server-utils/types/ShapeDetails.js").ShapeDetails>;
6
+ }
@@ -0,0 +1,27 @@
1
+ import { BackendProvider } from '@_linked/server-utils/utils/BackendProvider';
2
+ import { LinkedFileStorage } from '@_linked/core/utils/LinkedFileStorage';
3
+ import { LocalFileStore } from './shapes/filestores/LocalFileStore.js';
4
+ import { getShapeIndex } from './utils/Shapes.js';
5
+ import path from 'path';
6
+ import fs from 'fs/promises';
7
+ export * from './shapes/quadstores/BackendAPIStoreProvider.js';
8
+ export default class LincdServerBackendProvider extends BackendProvider {
9
+ async setupBeforeControllers() {
10
+ if (!LinkedFileStorage.getDefaultDataset()) {
11
+ LinkedFileStorage.setDefaultDataset(new LocalFileStore(process.env.NODE_ENV + '-filestore'));
12
+ }
13
+ let fileSystemUploadPath = path.join('data', 'filestores');
14
+ try {
15
+ await fs.access(fileSystemUploadPath);
16
+ }
17
+ catch (err) {
18
+ await fs.mkdir(path.join(fileSystemUploadPath, 'filestores'), {
19
+ recursive: true,
20
+ });
21
+ }
22
+ }
23
+ getShapes() {
24
+ return getShapeIndex();
25
+ }
26
+ }
27
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,cAAc,gDAAgD,CAAC;AAE/D,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,eAAe;IACrE,KAAK,CAAC,sBAAsB;QAC1B,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,EAAE,CAAC;YAC3C,iBAAiB,CAAC,iBAAiB,CACjC,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC,CACxD,CAAC;QACJ,CAAC;QACD,IAAI,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAC3D,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,YAAY,CAAC,EAAE;gBAC5D,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,SAAS;QACP,OAAO,aAAa,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import './types.js';
2
+ import './ontologies/lincd-server.js';
3
+ import './shapes/LincdServer.js';
4
+ import './shapes/LincdAPI.js';
5
+ import './shapes/quadstores/BackendAPIStore.js';
6
+ import './shapes/filestores/LocalFileStore.js';
7
+ import './shapes/LincdWebApp.js';
8
+ import './utils/accessUrl.js';
9
+ export type { RouteConfig, RoutesConfig, RoutesModule, } from '@_linked/server-utils/types/RouteConfig';
@@ -0,0 +1,11 @@
1
+ import './types.js';
2
+ import './ontologies/lincd-server.js';
3
+ //SHAPES FIRST
4
+ import './shapes/LincdServer.js';
5
+ import './shapes/LincdAPI.js';
6
+ import './shapes/quadstores/BackendAPIStore.js';
7
+ import './shapes/filestores/LocalFileStore.js';
8
+ import './shapes/LincdWebApp.js';
9
+ //THEN COMPONENTS
10
+ import './utils/accessUrl.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,OAAO,8BAA8B,CAAC;AAEtC,cAAc;AACd,OAAO,yBAAyB,CAAC;AACjC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,wCAAwC,CAAC;AAChD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,yBAAyB,CAAC;AAEjC,iBAAiB;AACjB,OAAO,sBAAsB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Load the data of this ontology.
3
+ * In @_linked/core, loadData returns the raw JSON import — no JSONLD.parse() needed.
4
+ */
5
+ export declare var loadData: () => Promise<any>;
6
+ export declare var ns: (term: string) => import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
7
+ export declare var _self: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
8
+ export declare var LincdServer: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
9
+ export declare var BackendFileStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
10
+ export declare var NodeFileStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
11
+ export declare var BackendStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
12
+ export declare var BackendAPIStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
13
+ export declare var LincdWebApp: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
14
+ export declare var ownPackage: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
15
+ export declare var maintainsPackage: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
16
+ export declare var N3FileStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
17
+ export declare var LincdAPI: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
18
+ export declare var hasAPI: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
19
+ export declare const lincdServer: {
20
+ LincdServer: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
21
+ BackendFileStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
22
+ NodeFileStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
23
+ BackendStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
24
+ N3FileStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
25
+ BackendAPIStore: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
26
+ LincdWebApp: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
27
+ ownPackage: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
28
+ maintainsPackage: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
29
+ LincdAPI: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
30
+ hasAPI: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
31
+ };
@@ -0,0 +1,42 @@
1
+ import { createNameSpace } from '@_linked/core/utils/NameSpace';
2
+ import { linkedOntology } from '../package.js';
3
+ import * as _this from './lincd-server.js';
4
+ /**
5
+ * Load the data of this ontology.
6
+ * In @_linked/core, loadData returns the raw JSON import — no JSONLD.parse() needed.
7
+ */
8
+ export var loadData = async () => {
9
+ //@ts-ignore
10
+ const data = await import('../data/lincd-server.json', {
11
+ with: { type: 'json' },
12
+ });
13
+ return data.default || data;
14
+ };
15
+ export var ns = createNameSpace('http://lincd.org/ont/lincd-server/');
16
+ export var _self = ns('');
17
+ export var LincdServer = ns('LincdServer');
18
+ export var BackendFileStore = ns('BackendFileStore');
19
+ export var NodeFileStore = ns('NodeFileStore');
20
+ export var BackendStore = ns('BackendStore');
21
+ export var BackendAPIStore = ns('BackendAPIStore');
22
+ export var LincdWebApp = ns('LincdWebApp');
23
+ export var ownPackage = ns('ownPackage');
24
+ export var maintainsPackage = ns('maintainsPackage');
25
+ export var N3FileStore = ns('N3FileStore');
26
+ export var LincdAPI = ns('LincdAPI');
27
+ export var hasAPI = ns('hasAPI');
28
+ export const lincdServer = {
29
+ LincdServer,
30
+ BackendFileStore,
31
+ NodeFileStore,
32
+ BackendStore,
33
+ N3FileStore,
34
+ BackendAPIStore,
35
+ LincdWebApp,
36
+ ownPackage,
37
+ maintainsPackage,
38
+ LincdAPI,
39
+ hasAPI,
40
+ };
41
+ linkedOntology(_this, ns, 'lincd-server', loadData, '../data/lincd-server.json');
42
+ //# sourceMappingURL=lincd-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lincd-server.js","sourceRoot":"","sources":["../../../src/ontologies/lincd-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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C,IAAI,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;AAEjC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,WAAW;IACX,gBAAgB;IAChB,aAAa;IACb,YAAY;IACZ,WAAW;IACX,eAAe;IACf,WAAW;IACX,UAAU;IACV,gBAAgB;IAChB,QAAQ;IACR,MAAM;CACP,CAAC;AAEF,cAAc,CACZ,KAAK,EACL,EAAE,EACF,cAAc,EACd,QAAQ,EACR,2BAA2B,CAC5B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const linkedShape: {
2
+ <T extends typeof import("@_linked/core/shapes/Shape").Shape>(constructor: T): void;
3
+ <T extends typeof import("@_linked/core/shapes/Shape").Shape>(config?: import("@_linked/core/utils/Package").ShapeConfig): (constructor: T) => void;
4
+ }, linkedUtil: (constructor: any) => any, linkedOntology: (allFileExports: any, nameSpace: (term: string) => import("@_linked/core/utils/NodeReference").NodeReferenceValue, suggestedPrefixAndFileName: string, loadDataFunction?: () => Promise<any>, dataSource?: string | string[]) => void, packageExports: any, packageName: string;
@@ -0,0 +1,3 @@
1
+ import { linkedPackage } from '@_linked/core/utils/Package';
2
+ export const { linkedShape, linkedUtil, linkedOntology, packageExports, packageName, } = linkedPackage('@_linked/server');
3
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,MAAM,CAAC,MAAM,EACX,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,WAAW,GACZ,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { Shape } from '@_linked/core/shapes/Shape';
2
+ import { ShapeDetails } from '../utils/Shapes.js';
3
+ export type ShapeSummary = {
4
+ id: string;
5
+ label: string;
6
+ description: string;
7
+ target: {
8
+ id: string;
9
+ };
10
+ extends?: {
11
+ id: string;
12
+ };
13
+ numInstances: number;
14
+ };
15
+ export declare class LincdAPI extends Shape {
16
+ static targetClass: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
17
+ process(request: any, response: any, httpMethod: 'get' | 'post' | 'put' | 'delete'): Promise<void>;
18
+ get_shape_details({ shapes, }: {
19
+ shapes: string[];
20
+ }): Record<string, ShapeDetails>;
21
+ get_all_shapes(): Promise<{
22
+ shapes: Record<string, ShapeDetails>;
23
+ defaultGraph: string;
24
+ }>;
25
+ post_select({ query }: {
26
+ query: any;
27
+ }): Promise<unknown>;
28
+ post_create({ query }: {
29
+ query: any;
30
+ }): Promise<unknown>;
31
+ post_update({ query }: {
32
+ query: any;
33
+ }): Promise<unknown>;
34
+ post_delete({ query }: {
35
+ query: any;
36
+ }): Promise<import("@_linked/core/queries/DeleteQuery.js").DeleteResponse>;
37
+ post_select_raw({ query }: {
38
+ query: any;
39
+ }): Promise<void | import("@_linked/core/sparql/resultMapping.js").SparqlJsonResults>;
40
+ private checkRawQuerySupport;
41
+ }
@@ -0,0 +1,113 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Shape } from '@_linked/core/shapes/Shape';
8
+ import { linkedShape } from '../package.js';
9
+ import { lincdServer } from '../ontologies/lincd-server.js';
10
+ import { JSONParser } from '@_linked/server-utils/utils/JSONParser';
11
+ import { LinkedStorage } from '@_linked/core/utils/LinkedStorage';
12
+ import { JSONWriter } from '@_linked/server-utils/utils/JSONWriter';
13
+ import { cached } from '@_linked/core/utils/cached';
14
+ import { getShapeIndex } from '../utils/Shapes.js';
15
+ const cacheTime = process.env.NODE_ENV === 'development' ? 0 : Infinity;
16
+ let LincdAPI = class LincdAPI extends Shape {
17
+ async process(request, response, httpMethod) {
18
+ let { method, action } = request.params;
19
+ const body = JSONParser.parseObject(request.body);
20
+ //replace - with _ in action names
21
+ let localMethod = httpMethod + '_' + method.replace(/-/g, '_');
22
+ if (typeof this[localMethod] !== 'function') {
23
+ throw new Error('Unknown method: ' + localMethod);
24
+ }
25
+ //TODO: access rights, check if the current user is allowed to execute this method
26
+ try {
27
+ const result = await this[localMethod](body, request, response);
28
+ if (typeof result !== 'undefined' || !response.headersSent) {
29
+ const jsonObject = JSONWriter.toJsObject(result);
30
+ response.json(jsonObject);
31
+ }
32
+ }
33
+ catch (error) {
34
+ console.error(`Error while processing ${localMethod}:`, error);
35
+ if (!response.headersSent) {
36
+ const message = error instanceof Error ? error.message : 'Unknown server error';
37
+ response.status(500).json({ error: message });
38
+ }
39
+ }
40
+ }
41
+ get_shape_details({ shapes, }) {
42
+ return cached(() => {
43
+ const shapeIndex = getShapeIndex();
44
+ const filteredShapeIndex = {};
45
+ for (const shapeId of shapes) {
46
+ if (shapeIndex[shapeId]) {
47
+ filteredShapeIndex[shapeId] = shapeIndex[shapeId];
48
+ }
49
+ }
50
+ return filteredShapeIndex;
51
+ }, [shapes], cacheTime);
52
+ }
53
+ get_all_shapes() {
54
+ return cached(async () => {
55
+ var _a;
56
+ const shapeIndex = getShapeIndex();
57
+ const typesWithInstances = new Map();
58
+ this.checkRawQuerySupport();
59
+ await LinkedStorage.getDefaultDataset()
60
+ .rawQuery(`SELECT (COUNT(?s) AS ?count) ?type WHERE { ?s a ?type } GROUP BY ?type`)
61
+ .then((results) => {
62
+ if (!results)
63
+ return;
64
+ results.results.bindings.forEach((binding) => {
65
+ if (binding.type && binding.type.value) {
66
+ typesWithInstances.set(binding.type.value, parseInt(binding.count.value));
67
+ }
68
+ });
69
+ })
70
+ .catch(console.error);
71
+ const shapesWithInstances = {};
72
+ for (const shapeId in shapeIndex) {
73
+ const shape = shapeIndex[shapeId];
74
+ shapesWithInstances[shapeId] = {
75
+ ...shape,
76
+ numInstances: typesWithInstances.get((_a = shape.targetClass) === null || _a === void 0 ? void 0 : _a.id) || 0,
77
+ };
78
+ }
79
+ return {
80
+ shapes: shapesWithInstances,
81
+ defaultGraph: process.env.DATA_ROOT,
82
+ };
83
+ }, [], cacheTime);
84
+ }
85
+ post_select({ query }) {
86
+ return LinkedStorage.selectQuery(query);
87
+ }
88
+ post_create({ query }) {
89
+ return LinkedStorage.createQuery(query);
90
+ }
91
+ post_update({ query }) {
92
+ return LinkedStorage.updateQuery(query);
93
+ }
94
+ post_delete({ query }) {
95
+ return LinkedStorage.deleteQuery(query);
96
+ }
97
+ post_select_raw({ query }) {
98
+ this.checkRawQuerySupport();
99
+ return LinkedStorage.getDefaultDataset().rawQuery(query);
100
+ }
101
+ checkRawQuerySupport() {
102
+ if (!LinkedStorage.getDefaultDataset().rawQuery) {
103
+ throw new Error(`Default store (${Object.getPrototypeOf(LinkedStorage.getDefaultDataset()).constructor
104
+ .name}) does not support raw SPARQL queries`);
105
+ }
106
+ }
107
+ };
108
+ LincdAPI.targetClass = lincdServer.LincdAPI;
109
+ LincdAPI = __decorate([
110
+ linkedShape
111
+ ], LincdAPI);
112
+ export { LincdAPI };
113
+ //# sourceMappingURL=LincdAPI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LincdAPI.js","sourceRoot":"","sources":["../../../src/shapes/LincdAPI.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,mC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C,oBAAoB,EAAE,CAAC;QAC5B,OAAQ,aAAa,CAAC,iBAAiB,EAA6B,CAAC,QAAQ,CAC3E,KAAK,CACN,CAAC;IACJ,CAAC;IAEO,oBAAoB;QAC1B,IAAI,CAAE,aAAa,CAAC,iBAAiB,EAA6B,CAAC,QAAQ,EAAE,CAAC;YAC5E,MAAM,IAAI,KAAK,CACb,kBACE,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,iBAAiB,EAAE,CAAC,CAAC,WAAW;iBACjE,IACL,uCAAuC,CACxC,CAAC;QACJ,CAAC;IACH,CAAC;;AAhIM,oBAAW,GAAG,WAAW,CAAC,QAAQ,AAAvB,CAAwB;AAD/B,QAAQ;IADpB,WAAW;GACC,QAAQ,CAkIpB"}
@@ -0,0 +1,79 @@
1
+ import { Express as ExpressServer } from 'express';
2
+ import { Server as HttpServer } from 'http';
3
+ import type { LinkedConfig } from '@_linked/cli/interfaces';
4
+ import { Shape } from '@_linked/core/shapes/Shape';
5
+ export declare class LincdServer extends Shape {
6
+ /**
7
+ * indicates that instances of this shape need to have this rdf.type
8
+ */
9
+ static targetClass: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
10
+ private config;
11
+ private cachedPaths;
12
+ private assets;
13
+ private latestManifest;
14
+ protected server: ExpressServer;
15
+ protected httpServer: HttpServer;
16
+ private package;
17
+ private cacheWebpack;
18
+ private cssMode;
19
+ private analyse;
20
+ private shapeProviders;
21
+ private genericProviders;
22
+ private resizePathsMap;
23
+ private api;
24
+ /**
25
+ * yarn linked start sends the contents of linked.config.js as an object to this constructor
26
+ * @param n
27
+ */
28
+ constructor(config?: LinkedConfig | string | {
29
+ id: string;
30
+ });
31
+ get app(): ExpressServer;
32
+ initPackage(): void;
33
+ initOnly(): Promise<this>;
34
+ start(): Promise<this>;
35
+ initOntologies(): Promise<void>;
36
+ /**
37
+ *
38
+ * @returns
39
+ * @todo Check if default file store is set, if not, set it
40
+ */
41
+ initStores(): Promise<any[]>;
42
+ callGenericBackendProvidersMethod(method: string, ...args: any[]): Promise<void>;
43
+ /**
44
+ * Removes temporary nodes from memory if they've been seen twice
45
+ * Current interval is once per hour.
46
+ * So after 2 hours temporary nodes are removed.
47
+ */
48
+ initGarbageCollection(): void;
49
+ initBackendProviders(): Promise<void>;
50
+ /**
51
+ * Filters local workspace packages to only those reachable from the app's
52
+ * dependency tree. Mirrors the logic used by `buildAll` in lincd-cli.
53
+ */
54
+ private filterPackagesByDependencyTree;
55
+ resizeImage(req: any, res: any): Promise<any>;
56
+ indexLincdPackage(pkg: string, warnIfNotFound?: boolean): Promise<void>;
57
+ indexPackageBackendProviders(pkg: string, warnIfNotFound?: boolean, backendIndexFilePath?: string): Promise<{
58
+ backendProviderExports: any;
59
+ shapeProviders: any[];
60
+ }>;
61
+ processBackendMethodCall(request: any, response: any): Promise<void>;
62
+ noCache(response: any): void;
63
+ processAPICall(request: any, response: any, method: 'get' | 'post' | 'put' | 'delete'): Promise<void>;
64
+ processShapeMethodCall(request: any, response: any): Promise<void>;
65
+ callShapeMethod(pkg: string, method: string, shapeURI: string, instanceNode: {
66
+ id: string;
67
+ } | null, args: any[], request: any, response: any): Promise<any>;
68
+ handleErrors(fn: any): (req: any, res: any, next: any) => Promise<any>;
69
+ handleErrorsJson(fn: any): (req: any, res: any, next: any) => Promise<any>;
70
+ sendError(res: any, statusCode: number, message: any, logMessage?: string): void;
71
+ render(req: any, res: any): Promise<void>;
72
+ sendJson(res: any, obj: any): void;
73
+ initRequest(request: any, response: any): Promise<void>;
74
+ getRequestData(request: any, response: any): Promise<{
75
+ requestLD: string;
76
+ requestObject: string;
77
+ }>;
78
+ callBackendMethod(pkg: string, method: string, args: any[], request: any, response: any): Promise<any>;
79
+ }