@rr0/cms 0.3.8 → 0.3.10

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.
@@ -7,7 +7,7 @@ export class TimeContextFilter extends ContextFilter {
7
7
  var _a, _b, _c;
8
8
  const sightingTime = c.time;
9
9
  const time = this.context.time;
10
- if (time) {
10
+ if (time && sightingTime) {
11
11
  const day = time.getDayOfMonth();
12
12
  const month = time.getMonth();
13
13
  const year = time.getYear();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { beforeEach, describe, expect, test } from "@javarome/testscript";
2
+ import { TimeContextFilter } from "./TimeContextFilter";
3
+ import { rr0TestUtil } from "../../test";
4
+ describe("TimeContextFilter", () => {
5
+ let context;
6
+ beforeEach(() => {
7
+ context = rr0TestUtil.time.newHtmlContext("1/9/7/0/03/index.html");
8
+ context.time.setYear(1970);
9
+ context.time.setMonth(3);
10
+ });
11
+ test("test", async () => {
12
+ const filter = new TimeContextFilter(context);
13
+ expect(filter.filter({})).toBe(true);
14
+ });
15
+ });
@@ -6,6 +6,7 @@ import { Place } from "@rr0/place";
6
6
  export declare class RR0ContextFilter extends TimeContextFilter<RR0CaseSummary> {
7
7
  }
8
8
  export declare abstract class RR0Datasource extends AbstractDatasource<RR0CaseSummary> {
9
+ static idCount: number;
9
10
  static readonly placeRegex: RegExp;
10
11
  protected constructor();
11
12
  static id(dateTime: EdtfDate, place: Place | undefined): string;
@@ -8,7 +8,8 @@ export class RR0Datasource extends AbstractDatasource {
8
8
  }
9
9
  static id(dateTime, place) {
10
10
  var _a;
11
- return `${dateTime.toString()}$${((_a = place === null || place === void 0 ? void 0 : place.toString()) !== null && _a !== void 0 ? _a : "")}`;
11
+ return `${(dateTime === null || dateTime === void 0 ? void 0 : dateTime.toString()) || ("rr0-" + ++this.idCount)}$${((_a = place === null || place === void 0 ? void 0 : place.toString()) !== null && _a !== void 0 ? _a : "")}`;
12
12
  }
13
13
  }
14
+ RR0Datasource.idCount = 0;
14
15
  RR0Datasource.placeRegex = /^(.+?)(?:\s*\((.+?)(?:\s*,\s*(.+?)(?:\s*,\s*(.+?)))?\))?$/g;
@@ -88,5 +88,6 @@ describe("RR0CaseSource", () => {
88
88
  test("id", async () => {
89
89
  expect(RR0Datasource.id(EdtfDate.fromString("1972-08-12"), new NamedPlace("Chatillon"))).toBe("1972-08-12$Chatillon");
90
90
  expect(RR0Datasource.id(EdtfDate.fromString("1972-08-12"), undefined)).toBe("1972-08-12$");
91
+ expect(RR0Datasource.id(undefined, undefined)).toBe("rr0-1$");
91
92
  });
92
93
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@rr0/cms",
3
3
  "type": "module",
4
4
  "author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
5
- "version": "0.3.8",
5
+ "version": "0.3.10",
6
6
  "description": "RR0 Content Management System (CMS)",
7
7
  "exports": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "build": "rm -Rf dist && tsc --project tsconfig.prod.json",
25
25
  "prepublishOnly": "npm run build",
26
26
  "test": "testscript",
27
- "test-one": "rm -Rf out && tsx src/RR0Build.test.ts",
27
+ "test-one": "rm -Rf out && tsx src/time/datasource/TimeContextFilter.test.ts",
28
28
  "test-ci": "rm -Rf out && testscript"
29
29
  },
30
30
  "dependencies": {