barnard59-base 1.2.1 → 2.0.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,23 @@
1
1
  # v1.0.0
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 6be7cd8: Literals loaded as step arguments will be converted to matching JS type (closes #116)
8
+ - 72648c5: Change the operation URLs to be HTTPS (re zazuko/barnard59-website#4).
9
+ This will only be a breaking change to those using the [shorthand step syntax](https://data-centric.zazuko.com/docs/workflows/explanations/simplified-syntax).
10
+
11
+ ### Minor Changes
12
+
13
+ - 64b50ac: glob: added a warning message when nothing was matched
14
+
15
+ ## 1.2.2
16
+
17
+ ### Patch Changes
18
+
19
+ - f0814d5: Operations in manifest had wrong types
20
+
3
21
  ## 1.2.1
4
22
 
5
23
  ### Patch Changes
package/glob.js CHANGED
@@ -6,6 +6,7 @@ import { Readable } from 'readable-stream'
6
6
  import tracer from './lib/tracer.js'
7
7
 
8
8
  function glob({ pattern, ...options }) {
9
+ const { logger } = this
9
10
  let filenames = null
10
11
 
11
12
  const span = tracer.startSpan('glob')
@@ -13,15 +14,19 @@ function glob({ pattern, ...options }) {
13
14
  const init = onetime(async () => {
14
15
  span.addEvent('init')
15
16
  filenames = await promisify(globFn)(pattern, options)
17
+ return filenames.length === 0
16
18
  })
17
19
 
18
20
  const stream = new Readable({
19
21
  objectMode: true,
20
22
  read: async () => {
21
23
  try {
22
- await init()
24
+ const noneMatched = await init()
23
25
 
24
26
  if (filenames.length === 0) {
27
+ if (noneMatched) {
28
+ logger.warn(`No files matched by glob '${pattern}'`)
29
+ }
25
30
  return stream.push(null)
26
31
  }
27
32
 
package/manifest.ttl CHANGED
@@ -1,4 +1,4 @@
1
- @base <http://barnard59.zazuko.com/operations/base/> .
1
+ @base <https://barnard59.zazuko.com/operations/base/> .
2
2
  @prefix code: <https://code.described.at/> .
3
3
  @prefix p: <https://pipeline.described.at/> .
4
4
  @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@@ -6,104 +6,104 @@
6
6
  <combine> a p:Operation, p:Writable, p:Readable;
7
7
  rdfs:label "Combine";
8
8
  rdfs:comment "Combines multiple streams to a single stream connecting them in the given order.";
9
- code:implementedBy [ a code:EcmaScript;
9
+ code:implementedBy [ a code:EcmaScriptModule;
10
10
  code:link <node:barnard59-base/combine.js#default>
11
11
  ].
12
12
 
13
13
  <concat> a p:Operation, p:Readable;
14
14
  rdfs:label "Concat";
15
15
  rdfs:comment "Concatenates the content of the given streams to a single stream.";
16
- code:implementedBy [ a code:EcmaScript;
16
+ code:implementedBy [ a code:EcmaScriptModule;
17
17
  code:link <node:barnard59-base/concat.js#default>
18
18
  ].
19
19
 
20
20
  <concat/object> a p:Operation, p:ReadableObjectMode;
21
21
  rdfs:label "Concat (Object)";
22
22
  rdfs:comment "Concatenates the content of the given streams to a single stream.";
23
- code:implementedBy [ a code:EcmaScript;
23
+ code:implementedBy [ a code:EcmaScriptModule;
24
24
  code:link <node:barnard59-base/concat.js#object>
25
25
  ].
26
26
 
27
27
  <filter> a p:Operation, p:WritableObjectMode, p:ReadableObjectMode;
28
28
  rdfs:label "Filter";
29
29
  rdfs:comment "Forwards incoming chunks if they pass the filter function.";
30
- code:implementedBy [ a code:EcmaScript;
30
+ code:implementedBy [ a code:EcmaScriptModule;
31
31
  code:link <node:barnard59-base/filter.js#default>
32
32
  ].
33
33
 
34
34
  <flatten> a p:Operation, p:WritableObjectMode, p:ReadableObjectMode;
35
35
  rdfs:label "Flatten";
36
36
  rdfs:comment "Separates incoming arrays into their elements and emits each element as a single chunk.";
37
- code:implementedBy [ a code:EcmaScript;
37
+ code:implementedBy [ a code:EcmaScriptModule;
38
38
  code:link <node:barnard59-base/flatten.js#default>
39
39
  ].
40
40
 
41
41
  <forEach> a p:Operation, p:WritableObjectMode, p:ReadableObjectMode;
42
42
  rdfs:label "For Each";
43
43
  rdfs:comment "Calls a sub pipeline for each incoming chunk.";
44
- code:implementedBy [ a code:EcmaScript;
44
+ code:implementedBy [ a code:EcmaScriptModule;
45
45
  code:link <node:barnard59-base/forEach.js#default>
46
46
  ].
47
47
 
48
48
  <glob> a p:Operation, p:ReadableObjectMode;
49
49
  rdfs:label "Glob";
50
50
  rdfs:comment "Match files using the given pattern and emits each filename as a single chunk.";
51
- code:implementedBy [ a code:EcmaScript;
51
+ code:implementedBy [ a code:EcmaScriptModule;
52
52
  code:link <node:barnard59-base/glob.js#default>
53
53
  ].
54
54
 
55
55
  <json/parse> a p:Operation, p:Writable, p:ReadableObjectMode;
56
56
  rdfs:label "Parse JSON";
57
57
  rdfs:comment "Converts each chunk to an object by calling JSON.parse().";
58
- code:implementedBy [ a code:EcmaScript;
58
+ code:implementedBy [ a code:EcmaScriptModule;
59
59
  code:link <node:barnard59-base/json.js#parse>
60
60
  ].
61
61
 
62
62
  <json/stringify> a p:Operation, p:WritableObjectMode, p:Readable;
63
63
  rdfs:label "Serialize JSON";
64
64
  rdfs:comment "Converts each chunk to a JSON string by calling JSON.stringify().";
65
- code:implementedBy [ a code:EcmaScript;
65
+ code:implementedBy [ a code:EcmaScriptModule;
66
66
  code:link <node:barnard59-base/json.js#stringify>
67
67
  ].
68
68
 
69
69
  <limit> a p:Operation, p:WritableObjectMode, p:ReadableObjectMode;
70
70
  rdfs:label "Limit";
71
71
  rdfs:comment "Limits the amount of forwarded chunks and discards any chunks after reaching the limit.";
72
- code:implementedBy [ a code:EcmaScript;
72
+ code:implementedBy [ a code:EcmaScriptModule;
73
73
  code:link <node:barnard59-base/limit.js#default>
74
74
  ].
75
75
 
76
76
  <map> a p:Operation, p:WritableObjectMode, p:ReadableObjectMode;
77
77
  rdfs:label "Map";
78
78
  rdfs:comment "Converts each chunk using the given function.";
79
- code:implementedBy [ a code:EcmaScript;
79
+ code:implementedBy [ a code:EcmaScriptModule;
80
80
  code:link <node:barnard59-base/map.js#default>
81
81
  ].
82
82
 
83
83
  <nul> a p:Operation, p:WritableObjectMode;
84
84
  rdfs:label "/dev/null";
85
85
  rdfs:comment "Dummy output stream, just like /dev/null.";
86
- code:implementedBy [ a code:EcmaScript;
86
+ code:implementedBy [ a code:EcmaScriptModule;
87
87
  code:link <node:barnard59-base/nul.js#default>
88
88
  ].
89
89
 
90
90
  <offset> a p:Operation, p:WritableObjectMode, p:ReadableObjectMode;
91
91
  rdfs:label "Offset";
92
92
  rdfs:comment "Discards all chunks before the given offset.";
93
- code:implementedBy [ a code:EcmaScript;
93
+ code:implementedBy [ a code:EcmaScriptModule;
94
94
  code:link <node:barnard59-base/offset.js#default>
95
95
  ].
96
96
 
97
97
  <stdout> a p:Operation, p:Writable, p:Readable;
98
98
  rdfs:label "stdout";
99
99
  rdfs:comment "Writes the incoming data to stdout and also forwards the data to the stream output.";
100
- code:implementedBy [ a code:EcmaScript;
100
+ code:implementedBy [ a code:EcmaScriptModule;
101
101
  code:link <node:barnard59-base/stdout.js#default>
102
102
  ].
103
103
 
104
104
  <toString> a p:Operation, p:WritableObjectMode, p:Readable;
105
105
  rdfs:label "To String";
106
106
  rdfs:comment "Converts each chunk to a string by calling .toString().";
107
- code:implementedBy [ a code:EcmaScript;
107
+ code:implementedBy [ a code:EcmaScriptModule;
108
108
  code:link <node:barnard59-base/toString.js#default>
109
109
  ].
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barnard59-base",
3
- "version": "1.2.1",
3
+ "version": "2.0.0",
4
4
  "description": "Linked Data pipelines",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -30,13 +30,19 @@
30
30
  "through2": "^4.0.2"
31
31
  },
32
32
  "devDependencies": {
33
+ "barnard59-core": "^4.0.0",
34
+ "chai": "^4.3.10",
33
35
  "get-stream": "^6.0.1",
34
36
  "into-stream": "^7.0.0",
35
37
  "isstream": "^0.1.2",
36
38
  "mocha": "^9.0.1",
37
- "rdf-utils-fs": "^2.1.0"
39
+ "rdf-utils-fs": "^2.1.0",
40
+ "sinon": "^17.0.0"
38
41
  },
39
42
  "engines": {
40
43
  "node": ">= 14.0.0"
44
+ },
45
+ "mocha": {
46
+ "require": "../../test/mocha-setup.cjs"
41
47
  }
42
48
  }
package/test/glob.test.js CHANGED
@@ -1,22 +1,37 @@
1
1
  import { deepStrictEqual, strictEqual } from 'assert'
2
2
  import { array } from 'get-stream'
3
3
  import { isReadable, isWritable } from 'isstream'
4
+ import sinon from 'sinon'
5
+ import { expect } from 'chai'
4
6
  import glob from '../glob.js'
5
7
 
6
8
  describe('glob', () => {
9
+ let logger
10
+
11
+ beforeEach(() => {
12
+ logger = {
13
+ debug: sinon.spy(),
14
+ info: sinon.spy(),
15
+ error: sinon.spy(),
16
+ trace: sinon.spy(),
17
+ warn: sinon.spy(),
18
+ verbose: sinon.spy(),
19
+ }
20
+ })
21
+
7
22
  it('should be a function', () => {
8
23
  strictEqual(typeof glob, 'function')
9
24
  })
10
25
 
11
26
  it('should return a Readable stream', () => {
12
- const s = glob({ pattern: 'test/support/*' })
27
+ const s = glob.call({ logger }, { pattern: 'test/support/*' })
13
28
 
14
29
  strictEqual(isReadable(s), true)
15
30
  strictEqual(isWritable(s), false)
16
31
  })
17
32
 
18
33
  it('should emit each file name as a chunk', async () => {
19
- const s = glob({ pattern: '../../test/e2e/definitions/foreach/*' })
34
+ const s = glob.call({ logger }, { pattern: '../../test/e2e/definitions/foreach/*' })
20
35
 
21
36
  const filenames = await array(s)
22
37
 
@@ -28,7 +43,7 @@ describe('glob', () => {
28
43
  })
29
44
 
30
45
  it('should forward additional options', async () => {
31
- const s = glob({
46
+ const s = glob.call({ logger }, {
32
47
  cwd: '../../test/e2e/definitions/foreach',
33
48
  pattern: '*',
34
49
  })
@@ -41,4 +56,26 @@ describe('glob', () => {
41
56
  'with-variable.ttl',
42
57
  ])
43
58
  })
59
+
60
+ it('should warn when no files are matched', async () => {
61
+ const s = glob.call({ logger }, {
62
+ cwd: '../../test/e2e/definitions/foreach',
63
+ pattern: 'foobar',
64
+ })
65
+
66
+ await array(s)
67
+
68
+ expect(logger.warn).to.have.been.called
69
+ })
70
+
71
+ it('should not warn files have been matched', async () => {
72
+ const s = glob.call({ logger }, {
73
+ cwd: '../../test/e2e/definitions/foreach',
74
+ pattern: '*',
75
+ })
76
+
77
+ await array(s)
78
+
79
+ expect(logger.warn).not.to.have.been.called
80
+ })
44
81
  })