@_linked/server 3.10.0 → 3.12.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @\_linked/server
2
2
 
3
+ ## 3.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#212](https://github.com/linked-fw/server/pull/212) [`2ac07c4`](https://github.com/linked-fw/server/commit/2ac07c49918f31d94bcec03821a0ab29b1811f85) Thanks [@flyon](https://github.com/flyon)! - The graph targets are one global setting (`@_linked/core` 2.42). At boot the server reads `LINKED_ONTOLOGY_GRAPH` / `LINKED_SHAPE_GRAPH` (an invalid value is still a fatal boot error) and calls core's `setGraphTargets` once, before the boot initialises the stores and before the syncs; it no longer sets targets on each store. `GET /admin/routes` reports the setting as `graphTargets` (`{ontologyGraph, shapeGraph}`) next to `graphTargetEnv`; the per-dataset `ontologyGraph` / `shapeGraph` fields are gone. New boot warning: when routing pins `NodeShape` / `PropertyShape` or the ontology term shapes (`rdfs:Class`, `owl:Class`, `rdf:Property`, `owl:ObjectProperty`, `owl:DatatypeProperty`, `owl:AnnotationProperty`) to a dataset other than the default one, the server names them and the dataset and says the syncs write into the default dataset only. `applyGraphTargetsFromEnv(env)` takes no stores any more. Requires `@_linked/core` 2.42.0.
8
+
9
+ ## 3.11.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#210](https://github.com/linked-fw/server/pull/210) [`f494caa`](https://github.com/linked-fw/server/commit/f494caadb531d8acdbd3729a31df7ffe3dfbd525) Thanks [@flyon](https://github.com/flyon)! - `LINKED_ONTOLOGY_GRAPH` and `LINKED_SHAPE_GRAPH` set where the stores keep the packages' ontology data and shapes (core 2.41's graph targets): `package` (default), `default`, or the absolute IRI of one shared graph. The server checks them at boot (an invalid value stops the boot, naming the variable) and fills them into every store that takes graph targets, where the store's own options leave them unset; a store that takes none (`RemoteDataset`) runs `package`, with a warning when the variables ask for another mode. `GET /admin/routes` reports each store's `ontologyGraph` / `shapeGraph` and the variables (`graphTargetEnv`). The boot log names a shared graph or the default graph when the syncs wrote there, and `shapeGraphs` reports `target`. The ontology phase's `graphs` / `droppedGraphs` no longer list the inference probe's temporary graphs. Needs `@_linked/core` ^2.41.0.
14
+
3
15
  ## 3.10.0
4
16
 
5
17
  ### Minor Changes
@@ -133,6 +133,12 @@ export declare class LinkedServer extends Shape {
133
133
  private syncRegisteredShapes;
134
134
  /** The root directory of a package with shapes: the app, a discovered linked package, or one the app resolves. */
135
135
  private shapePackageDir;
136
+ /**
137
+ * Boot: one warning when routing pins the shape shapes or the ontology term shapes to a dataset
138
+ * other than the default one, since the syncs write into the default dataset only (see
139
+ * {@link syncPinWarning}).
140
+ */
141
+ private warnOfSyncPins;
136
142
  /**
137
143
  * Boot: sync the registered ontologies into their graphs in app data and run the shape
138
144
  * check, before the shape sync (see utils/ontologySync). The sync follows the shape sync's
@@ -39,7 +39,7 @@ import { LinkedStorage } from '@_linked/core/utils/LinkedStorage';
39
39
  import { getAllShapeClasses, getShapeClass, getSuperShapesClasses, } from '@_linked/core/utils/ShapeClass';
40
40
  import path from 'path';
41
41
  import { pathToFileURL } from 'node:url';
42
- import { isFatalError } from '../utils/fatalError.js';
42
+ import { FatalStartupError, isFatalError } from '../utils/fatalError.js';
43
43
  import { discoverLinkedDependencies, hasModuleEntry, isBundledBySsr, NODE_IMPORT_CONDITIONS, readDependencyLists, readInstalledPackage, resolveBackendEntry, resolveDevBackendEntry, ssrNoExternalOf, } from '../utils/linkedDependencies.js';
44
44
  /**
45
45
  * `instanceof ShapeProvider`, tolerating a second copy of server-utils.
@@ -139,6 +139,7 @@ import { resolveRouteAssets } from '../utils/routeAssets.js';
139
139
  import { resolveRouteComponent, ssrCssInlineUrls, ssrCssScope, } from '../utils/ssrCss.js';
140
140
  import { appShapesGraph, bootOrphanScope, loadShapeGraphCore, syncShapeGraphsInto, viteShapesTurtleGenerator, } from '../utils/syncShapes.js';
141
141
  import { bootSyncsOntologies, loadOntologyCore, runOntologyPhase, ontologyPackageDirs, sourceModuleImporter, shapeSyncOn, syncOntologiesThenShapes, } from '../utils/ontologySync.js';
142
+ import { applyGraphTargetsFromEnv, syncPinWarning } from '../utils/graphTargets.js';
142
143
  import { AdminRequestError, assertReloadablePackages, registerAdminRoutes, resolveAdminSecret, } from '../utils/adminChannel.js';
143
144
  import { envMs, withTimeout } from '../utils/withTimeout.js';
144
145
  import { invalidateSourceUnder } from '../utils/reloadSource.js';
@@ -363,6 +364,7 @@ let LinkedServer = class LinkedServer extends Shape {
363
364
  this.initPackage();
364
365
  this.server = express();
365
366
  await this.initBackendProviders();
367
+ this.warnOfSyncPins();
366
368
  await this.syncOntologiesOnBoot();
367
369
  await this.materializeShapesIntoStore();
368
370
  return this;
@@ -436,6 +438,16 @@ let LinkedServer = class LinkedServer extends Shape {
436
438
  const installed = readInstalledPackage(name, process.cwd());
437
439
  return installed === null || installed === void 0 ? void 0 : installed.root;
438
440
  }
441
+ /**
442
+ * Boot: one warning when routing pins the shape shapes or the ontology term shapes to a dataset
443
+ * other than the default one, since the syncs write into the default dataset only (see
444
+ * {@link syncPinWarning}).
445
+ */
446
+ warnOfSyncPins() {
447
+ const warning = syncPinWarning();
448
+ if (warning)
449
+ console.warn(warning);
450
+ }
439
451
  /**
440
452
  * Boot: sync the registered ontologies into their graphs in app data and run the shape
441
453
  * check, before the shape sync (see utils/ontologySync). The sync follows the shape sync's
@@ -683,6 +695,7 @@ let LinkedServer = class LinkedServer extends Shape {
683
695
  // });
684
696
  // before controllers
685
697
  await this.initBackendProviders();
698
+ this.warnOfSyncPins();
686
699
  await this.syncOntologiesOnBoot();
687
700
  await this.materializeShapesIntoStore();
688
701
  //START OF EXPRESS ROUTES AND MIDDLEWARE
@@ -806,6 +819,16 @@ let LinkedServer = class LinkedServer extends Shape {
806
819
  * @todo Check if default file store is set, if not, set it
807
820
  */
808
821
  async initStores() {
822
+ var _a;
823
+ // LINKED_ONTOLOGY_GRAPH / LINKED_SHAPE_GRAPH: checked (an invalid value stops the boot) and set
824
+ // once as core's global graph targets, before any store is initialised and before the syncs.
825
+ // A rejected boot does not end the process by itself, so the error is fatal.
826
+ try {
827
+ applyGraphTargetsFromEnv(process.env);
828
+ }
829
+ catch (err) {
830
+ throw new FatalStartupError(`[LinkedServer] ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : err}`, { cause: err });
831
+ }
809
832
  return Promise.all(LinkedStorage.getDatasets().map((store) => {
810
833
  return store.init ? store.init() : Promise.resolve();
811
834
  }));