gitsheets 0.21.3 → 0.21.6

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/commands/query.js CHANGED
@@ -28,15 +28,23 @@ exports.builder = {
28
28
  describe: 'Truncate results to given count',
29
29
  type: 'number'
30
30
  },
31
- 'filter.<field>': {
31
+ 'filter': {
32
+ group: 'Filtering',
32
33
  describe: 'Filter results by one or more field values',
34
+ type: 'array'
35
+ },
36
+ 'filter.<field>[=<value>]': {
37
+ group: 'Filtering',
38
+ describe: 'Field to filter by'
33
39
  },
34
40
  fields: {
41
+ group: 'Field selection',
35
42
  describe: 'List of fields to order/limit output columns with',
36
43
  type: 'array'
37
44
  },
38
- 'fields.<from>': {
39
- describe: 'Fields to remap',
45
+ 'fields.<from>=<to>': {
46
+ group: 'Field selection',
47
+ describe: 'Field to remap',
40
48
  type: 'array'
41
49
  }
42
50
  };
@@ -125,11 +133,25 @@ async function* limitResult(result, limit) {
125
133
  }
126
134
 
127
135
  async function* mapResult(result, fields) {
136
+ if (!Array.isArray(fields)) {
137
+ const fieldsObject = fields;
138
+ fields = [];
139
+ for (const fromKey in fieldsObject) {
140
+ const fieldMap = {};
141
+ fieldMap[fromKey] = fieldsObject[fromKey];
142
+ fields.push(fieldMap);
143
+ }
144
+ }
145
+
128
146
  for await (const record of result) {
129
147
  const output = {};
130
148
 
131
149
  for (const field of fields) {
132
- if (typeof field == 'object') {
150
+ if (Array.isArray(field)) {
151
+ for (const fieldValue of field) {
152
+ output[fieldValue] = record[fieldValue];
153
+ }
154
+ } else if (typeof field == 'object') {
133
155
  for (const from in field) {
134
156
  output[field[from]] = record[from];
135
157
  }
@@ -101,11 +101,20 @@ exports.handler = async function singerTarget({
101
101
  const clearedSheets = new Set();
102
102
  const writtenStreams = new Set();
103
103
  for await (const { type, stream, ...message} of readMessages({ jsonlFile })) {
104
- const sheet = sheets[stream];
105
-
106
104
  console.log(`${type}\t${stream}`, message);
107
105
 
108
106
 
107
+ // ignore unhandled message types for now
108
+ if (type == 'STATE' || type == 'ACTIVATE_VERSION') {
109
+ console.warn(`ignoring ${type} message`);
110
+ continue;
111
+ }
112
+
113
+
114
+ // get sheet
115
+ const sheet = sheets[stream];
116
+
117
+
109
118
  // create schema if needed
110
119
  if (!sheet) {
111
120
  if (type == 'SCHEMA') {
@@ -129,13 +138,6 @@ exports.handler = async function singerTarget({
129
138
  }
130
139
 
131
140
 
132
- // ignore state for now
133
- if (type == 'STATE') {
134
- console.warn('ignoring STATE message');
135
- continue;
136
- }
137
-
138
-
139
141
  // handle record message
140
142
  if (type == 'RECORD') {
141
143
  if (deleteMissing && !clearedSheets.has(sheet)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitsheets",
3
- "version": "0.21.3",
3
+ "version": "0.21.6",
4
4
  "description": "A toolkit for using a git repository to store low-volume, high-touch, human-scale data",
5
5
  "main": "lib/GitSheets.js",
6
6
  "scripts": {
@@ -26,7 +26,7 @@
26
26
  "fast-csv": "^4.3.6",
27
27
  "fast-json-patch": "^2.2.1",
28
28
  "get-stream": "^5.2.0",
29
- "hologit": "^0.40.5",
29
+ "hologit": "^0.41.3",
30
30
  "http-assert": "^1.4.1",
31
31
  "koa": "^2.13.1",
32
32
  "koa-bodyparser": "^4.3.0",
@@ -39,7 +39,7 @@
39
39
  "tmp": "^0.2.1",
40
40
  "to-readable-stream": "^2.1.0",
41
41
  "winston": "^3.3.3",
42
- "yargs": "^13.3.2"
42
+ "yargs": "^17.5.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "common-tags": "^1.8.0",