@basemaps/shared 6.10.0 → 6.17.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
@@ -3,6 +3,44 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.17.0](https://github.com/linz/basemaps/compare/v6.16.1...v6.17.0) (2021-12-05)
7
+
8
+ **Note:** Version bump only for package @basemaps/shared
9
+
10
+
11
+
12
+
13
+
14
+ ## [6.16.1](https://github.com/linz/basemaps/compare/v6.16.0...v6.16.1) (2021-11-30)
15
+
16
+ **Note:** Version bump only for package @basemaps/shared
17
+
18
+
19
+
20
+
21
+
22
+ # [6.12.0](https://github.com/linz/basemaps/compare/v6.11.0...v6.12.0) (2021-10-05)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **server:** use default of local file system for unknown paths ([#1895](https://github.com/linz/basemaps/issues/1895)) ([1d89456](https://github.com/linz/basemaps/commit/1d894561965a6afd1144dd4580e9ec4cf914ce2c))
28
+
29
+
30
+
31
+
32
+
33
+ # [6.11.0](https://github.com/linz/basemaps/compare/v6.10.1...v6.11.0) (2021-10-03)
34
+
35
+
36
+ ### Features
37
+
38
+ * **server:** use the lambda handler directly ([#1870](https://github.com/linz/basemaps/issues/1870)) ([408ff56](https://github.com/linz/basemaps/commit/408ff5654cc04aae35d05eb5bbc47a51f99ec5b2))
39
+
40
+
41
+
42
+
43
+
6
44
  # [6.10.0](https://github.com/linz/basemaps/compare/v6.9.1...v6.10.0) (2021-09-22)
7
45
 
8
46
 
@@ -1,27 +1,27 @@
1
- import { statSync, unlinkSync } from 'fs';
1
+ import { promises as fs } from 'fs';
2
2
  import o from 'ospec';
3
3
  import path from 'path';
4
4
  import url from 'url';
5
5
  import { fsa } from '../index.js';
6
6
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
7
- function rmF(path) {
7
+ async function rmF(path) {
8
8
  try {
9
- unlinkSync(path);
9
+ await fs.unlink(path);
10
10
  }
11
11
  catch (_err) { }
12
12
  }
13
13
  o.spec('file.local', () => {
14
14
  const jsonFilePath = __dirname + '/testing.json';
15
15
  const jsonFilePathGz = jsonFilePath + '.gz';
16
- o.afterEach(() => {
17
- rmF(jsonFilePathGz);
18
- rmF(jsonFilePath);
16
+ o.afterEach(async () => {
17
+ await Promise.all([rmF(jsonFilePathGz), rmF(jsonFilePath)]);
19
18
  });
20
19
  o('readJson writeJson gzip', async () => {
21
20
  try {
22
21
  await fsa.writeJson(jsonFilePathGz, { json: '1'.repeat(1000) });
23
22
  const ans = await fsa.readJson(jsonFilePathGz);
24
- o(statSync(jsonFilePathGz).size).equals(44);
23
+ const stat = await fs.stat(jsonFilePathGz);
24
+ o(stat.size).equals(44);
25
25
  o(ans).deepEquals({ json: '1'.repeat(1000) });
26
26
  }
27
27
  catch (e) {
@@ -31,7 +31,18 @@ o.spec('file.local', () => {
31
31
  o('readJson writeJson', async () => {
32
32
  await fsa.writeJson(jsonFilePath, { json: '1'.repeat(1000) });
33
33
  const ans = await fsa.readJson(jsonFilePath);
34
- o(statSync(jsonFilePath).size).equals(1016);
34
+ const stat = await fs.stat(jsonFilePath);
35
+ o(stat.size).equals(1016);
35
36
  o(ans).deepEquals({ json: '1'.repeat(1000) });
36
37
  });
38
+ o('should support reading relative paths', async () => {
39
+ try {
40
+ await fs.writeFile('foo.tmp', Buffer.from('hello world'));
41
+ const res = await fsa.read('foo.tmp');
42
+ o(res.toString()).equals('hello world');
43
+ }
44
+ finally {
45
+ await fs.unlink('foo.tmp');
46
+ }
47
+ });
37
48
  });
@@ -34,3 +34,8 @@ fsa.configure = function configure(cfg) {
34
34
  const bucketUri = `s3://${bucket}/`;
35
35
  this.register(bucketUri, FsAwsS3.fromRoleArn(cfg.roleArn, cfg.externalId));
36
36
  };
37
+ /**
38
+ * Default to using the file handler useful for folders like
39
+ * "C:\" or "directory_name/sub_directory"
40
+ */
41
+ fsa.register('', fsa.get('file://'));
package/build/log.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Writable } from 'stream';
2
1
  export interface LogFunc {
3
2
  (msg: string): void;
4
3
  (obj: Record<string, unknown>, msg: string): void;
@@ -23,8 +22,6 @@ export declare const LogConfig: {
23
22
  /** Get the currently configured logger */
24
23
  get(): LogType;
25
24
  set(log: LogType): void;
26
- /** Overwrite the logger with a new logger that outputs to the provided stream*/
27
- setOutputStream(stream: Writable): void;
28
25
  /** Disable the logger */
29
26
  disable(): void;
30
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,MAAM,WAAW,OAAO;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACnD;AAID;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;CAClD;AACD;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB,0CAA0C;WACnC,OAAO;aAOL,OAAO,GAAG,IAAI;IAIvB,gFAAgF;4BACxD,QAAQ,GAAG,IAAI;IAQvC,yBAAyB;eACd,IAAI;CAGhB,CAAC"}
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,OAAO;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACnD;AAID;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;CAClD;AAGD;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB,0CAA0C;WACnC,OAAO;aAOL,OAAO,GAAG,IAAI;IAIvB,yBAAyB;eACd,IAAI;CAGhB,CAAC"}
package/build/log.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import pino from 'pino';
2
+ import { PrettyTransform } from 'pretty-json-log';
2
3
  let currentLog;
4
+ const defaultOpts = { level: 'debug' };
3
5
  /**
4
6
  * Encapsulate the logger so that it can be swapped out
5
7
  */
@@ -7,21 +9,13 @@ export const LogConfig = {
7
9
  /** Get the currently configured logger */
8
10
  get() {
9
11
  if (currentLog == null) {
10
- currentLog = pino({ level: 'debug' });
12
+ currentLog = process.stdout.isTTY ? pino(defaultOpts, PrettyTransform.stream()) : pino(defaultOpts);
11
13
  }
12
14
  return currentLog;
13
15
  },
14
16
  set(log) {
15
17
  currentLog = log;
16
18
  },
17
- /** Overwrite the logger with a new logger that outputs to the provided stream*/
18
- setOutputStream(stream) {
19
- let level = 'debug';
20
- if (currentLog) {
21
- level = currentLog.level;
22
- }
23
- currentLog = pino({ level }, stream);
24
- },
25
19
  /** Disable the logger */
26
20
  disable() {
27
21
  LogConfig.get().level = 'silent';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemaps/shared",
3
- "version": "6.10.0",
3
+ "version": "6.17.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,15 +23,15 @@
23
23
  "test": "ospec --globs 'build/**/*.test.js'"
24
24
  },
25
25
  "dependencies": {
26
- "@basemaps/config": "^6.10.0",
26
+ "@basemaps/config": "^6.17.0",
27
27
  "@basemaps/geo": "^6.10.0",
28
- "@basemaps/tiler": "^6.10.0",
28
+ "@basemaps/tiler": "^6.11.0",
29
29
  "@linzjs/geojson": "^6.10.0",
30
- "@linzjs/metrics": "^6.10.0",
30
+ "@linzjs/metrics": "^6.11.0",
31
31
  "@linzjs/s3fs": "^6.9.1",
32
32
  "aws-sdk": "^2.890.0",
33
33
  "base-x": "^3.0.7",
34
- "pino": "^6.2.1",
34
+ "pino": "^7.5.0",
35
35
  "proj4": "^2.6.2",
36
36
  "sax": "^1.2.4",
37
37
  "source-map-support": "^0.5.19",
@@ -40,7 +40,6 @@
40
40
  "devDependencies": {
41
41
  "@types/aws-lambda": "^8.10.75",
42
42
  "@types/geojson": "^7946.0.7",
43
- "@types/pino": "^6.0.0",
44
43
  "@types/proj4": "^2.5.0",
45
44
  "@types/sax": "^1.2.1"
46
45
  },
@@ -50,5 +49,5 @@
50
49
  "files": [
51
50
  "build/"
52
51
  ],
53
- "gitHead": "c88706ff58f4dfe83bf2b757d1483194accdb4c9"
52
+ "gitHead": "16850d66b32943f40900900c07b0cbc778e8c332"
54
53
  }