@digitraffic/common 2026.1.26-1 → 2026.2.4-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.
@@ -7,10 +7,6 @@ test("database import ok?", () => {
7
7
  const database = import("../database/database.js");
8
8
  return expect(database).resolves.toBeDefined();
9
9
  });
10
- test("cached import ok?", () => {
11
- const cached = import("../database/cached.js");
12
- return expect(cached).resolves.toBeDefined();
13
- });
14
10
  test("models import ok?", () => {
15
11
  const models = import("../database/models.js");
16
12
  return expect(models).resolves.toBeDefined();
@@ -4,7 +4,7 @@ import { CanaryAlarm } from "./canary-alarm.js";
4
4
  export class DigitrafficCanary extends Canary {
5
5
  constructor(scope, canaryName, role, params, environmentVariables) {
6
6
  super(scope, canaryName, {
7
- runtime: params.runtime ?? Runtime.SYNTHETICS_NODEJS_PUPPETEER_9_0,
7
+ runtime: params.runtime ?? Runtime.SYNTHETICS_NODEJS_PUPPETEER_13_0,
8
8
  role,
9
9
  test: Test.custom({
10
10
  code: new AssetCode("dist", {
@@ -14,6 +14,9 @@ const baseHeaders = {
14
14
  "Accept-Encoding": "gzip",
15
15
  Accept: "*/*",
16
16
  };
17
+ function sanitizeStepName(url) {
18
+ return url.replace(/\//g, " ").replace(/auth=.*/, "");
19
+ }
17
20
  export class UrlChecker {
18
21
  requestOptions;
19
22
  constructor(hostname, apiKey) {
@@ -50,7 +53,8 @@ export class UrlChecker {
50
53
  path: url,
51
54
  },
52
55
  };
53
- await synthetics.executeHttpStep(`Verify ${statusCode} for ${url.replace(/auth=.*/, "")}`, requestOptions, callback);
56
+ // The step name can only contain letters, numbers, hyphens, underscores, periods, and spaces
57
+ await synthetics.executeHttpStep(`Verify ${statusCode} for ${sanitizeStepName(url)}`, requestOptions, callback);
54
58
  }
55
59
  expect200(url, ...callbacks) {
56
60
  const callback = async (json, body, res) => {
@@ -65,7 +69,7 @@ export class UrlChecker {
65
69
  path: url,
66
70
  },
67
71
  };
68
- return synthetics.executeHttpStep(`Verify 404 for ${url}`, requestOptions, validateStatusCodeAndContentType(404, MediaType.TEXT_PLAIN));
72
+ return synthetics.executeHttpStep(`Verify 404 for ${sanitizeStepName(url)}`, requestOptions, validateStatusCodeAndContentType(404, MediaType.TEXT_PLAIN));
69
73
  }
70
74
  expect400(url) {
71
75
  const requestOptions = {
@@ -74,7 +78,7 @@ export class UrlChecker {
74
78
  path: url,
75
79
  },
76
80
  };
77
- return synthetics.executeHttpStep(`Verify 400 for ${url}`, requestOptions, validateStatusCodeAndContentType(400, MediaType.TEXT_PLAIN));
81
+ return synthetics.executeHttpStep(`Verify 400 for ${sanitizeStepName(url)}`, requestOptions, validateStatusCodeAndContentType(400, MediaType.TEXT_PLAIN));
78
82
  }
79
83
  expect403WithoutApiKey(url, mediaType) {
80
84
  if (!this.requestOptions.headers ||
@@ -92,7 +96,7 @@ export class UrlChecker {
92
96
  headers: baseHeaders,
93
97
  },
94
98
  };
95
- return synthetics.executeHttpStep(`Verify 403 for ${url}`, requestOptions, validateStatusCodeAndContentType(403, mediaType ?? MediaType.APPLICATION_JSON));
99
+ return synthetics.executeHttpStep(`Verify 403 for ${sanitizeStepName(url)}`, requestOptions, validateStatusCodeAndContentType(403, mediaType ?? MediaType.APPLICATION_JSON));
96
100
  }
97
101
  done() {
98
102
  return "Canary successful";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2026.1.26-1",
3
+ "version": "2026.2.4-2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "repository": {
@@ -12,7 +12,6 @@
12
12
  "exports": {
13
13
  ".": "./dist/index.js",
14
14
  "./dist/database/database": "./dist/database/database.js",
15
- "./dist/database/cached": "./dist/database/cached.js",
16
15
  "./dist/database/models": "./dist/database/models.js",
17
16
  "./dist/database/last-updated": "./dist/database/last-updated.js",
18
17
  "./dist/types/geojson": "./dist/types/geojson.js",
@@ -1,19 +0,0 @@
1
- import type { DTDatabase, DTTransaction } from "./database.js";
2
- export interface CachedValue<T> {
3
- content: T;
4
- last_updated: Date;
5
- modified: Date;
6
- }
7
- export declare enum JSON_CACHE_KEY {
8
- NAUTICAL_WARNINGS_ACTIVE = "nautical-warnings-active",
9
- NAUTICAL_WARNINGS_ARCHIVED = "nautical-warnings-archived"
10
- }
11
- /**
12
- * @param db
13
- * @param cacheKey
14
- * @param value
15
- * @param lastUpdated time when data was created or updated
16
- */
17
- export declare function updateCachedJson<T>(db: DTDatabase | DTTransaction, cacheKey: JSON_CACHE_KEY, value: T, lastUpdated: Date): Promise<void>;
18
- export declare function getJsonFromCache<T>(db: DTDatabase | DTTransaction, cacheKey: JSON_CACHE_KEY): Promise<T | undefined>;
19
- export declare function getFromCache<T>(db: DTDatabase | DTTransaction, cacheKey: JSON_CACHE_KEY): Promise<CachedValue<T> | undefined>;
@@ -1,40 +0,0 @@
1
- import pg from "pg-promise";
2
- const { PreparedStatement } = pg;
3
- const PS_UPDATE_CACHE_VALUE = new PreparedStatement({
4
- name: "update-cache-value",
5
- text: `insert into cached_json(cache_id, content, last_updated)
6
- values ($1, $2, $3)
7
- on conflict(cache_id) do
8
- update set content = $2, last_updated = $3`,
9
- });
10
- const PS_GET_CACHE_VALUE = new PreparedStatement({
11
- name: "get-cache-value",
12
- text: "select content, last_updated, modified from cached_json where cache_id = $1",
13
- });
14
- export var JSON_CACHE_KEY;
15
- (function (JSON_CACHE_KEY) {
16
- JSON_CACHE_KEY["NAUTICAL_WARNINGS_ACTIVE"] = "nautical-warnings-active";
17
- JSON_CACHE_KEY["NAUTICAL_WARNINGS_ARCHIVED"] = "nautical-warnings-archived";
18
- })(JSON_CACHE_KEY || (JSON_CACHE_KEY = {}));
19
- /**
20
- * @param db
21
- * @param cacheKey
22
- * @param value
23
- * @param lastUpdated time when data was created or updated
24
- */
25
- export async function updateCachedJson(db, cacheKey, value, lastUpdated) {
26
- await db.none(PS_UPDATE_CACHE_VALUE, [cacheKey, value, lastUpdated]);
27
- }
28
- export function getJsonFromCache(db, cacheKey) {
29
- return db
30
- .oneOrNone(PS_GET_CACHE_VALUE, [cacheKey])
31
- .then((value) => value?.content ?? undefined);
32
- }
33
- export async function getFromCache(db, cacheKey) {
34
- return db
35
- .oneOrNone(PS_GET_CACHE_VALUE, [cacheKey])
36
- .then((result) => {
37
- return result ?? undefined;
38
- });
39
- }
40
- //# sourceMappingURL=cached.js.map