@wmfs/pg-delta-file 1.69.0 β†’ 1.73.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.
@@ -10,9 +10,10 @@ jobs:
10
10
  TZ: "Europe/London"
11
11
  PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:5432/circle_test
12
12
  TIMEOUT: 15000
13
- - image: circleci/postgres:9.6-alpine-postgis-ram
13
+ - image: cimg/postgres:13.4-postgis
14
14
  environment:
15
15
  POSTGRES_USER: postgres
16
+ POSTGRES_HOST_AUTH_METHOD: trust
16
17
  POSTGRES_DB: circle_test
17
18
  TZ: "Europe/London"
18
19
  working_directory: ~/repo
package/CHANGELOG.md CHANGED
@@ -1,3 +1,86 @@
1
+ # [1.73.0](https://github.com/wmfs/pg-delta-file/compare/v1.72.0...v1.73.0) (2022-01-25)
2
+
3
+
4
+ ### πŸ›  Builds
5
+
6
+ * **deps:** update dependency luxon to v2 ([4cfdea8](https://github.com/wmfs/pg-delta-file/commit/4cfdea8bea8c4d4a75af19329b435e71fb9f69f6))
7
+
8
+ # [1.72.0](https://github.com/wmfs/pg-delta-file/compare/v1.71.0...v1.72.0) (2022-01-25)
9
+
10
+
11
+ ### πŸ›  Builds
12
+
13
+ * **deps-dev:** Bump [@wmfs](https://github.com/wmfs)/hl-pg-client from 1.27.0 to 1.28.0 ([3ed1bc9](https://github.com/wmfs/pg-delta-file/commit/3ed1bc9008af08a84ace32b80e1ad0ae8cd31ad4))
14
+ * **deps-dev:** Bump codecov from 3.8.2 to 3.8.3 ([0cfeecb](https://github.com/wmfs/pg-delta-file/commit/0cfeecbd164f12626a439b5c734b31f48ff5c9b9))
15
+ * **deps-dev:** Bump mocha from 8.4.0 to 9.0.0 ([2415420](https://github.com/wmfs/pg-delta-file/commit/2415420bfcde85ac620c248d2adc9ce2714befc8))
16
+ * **deps-dev:** Bump mocha from 9.0.0 to 9.0.1 ([0af15f7](https://github.com/wmfs/pg-delta-file/commit/0af15f7172c48ff12b3cad1a11042626364fc566))
17
+ * **deps-dev:** Bump mocha from 9.0.1 to 9.0.2 ([d675f32](https://github.com/wmfs/pg-delta-file/commit/d675f325161711d7da5a57dc9633c30e8449ee0a))
18
+ * **deps-dev:** Bump mocha from 9.0.2 to 9.0.3 ([0df6f3c](https://github.com/wmfs/pg-delta-file/commit/0df6f3c31528b46b302dd1f2ac783728ca74ba29))
19
+ * **deps-dev:** Bump semantic-release from 17.4.3 to 17.4.4 ([ad32508](https://github.com/wmfs/pg-delta-file/commit/ad32508be8374f9ac78ef6116e95ce1fa2490b09))
20
+ * **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/changelog to v6 ([b9ad2c6](https://github.com/wmfs/pg-delta-file/commit/b9ad2c6690c602bea6211772b7614a3220ea896d))
21
+ * **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/git to v10 ([12e5b80](https://github.com/wmfs/pg-delta-file/commit/12e5b80f17e2fb93fede1db7d050def6f335cc83))
22
+ * **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/git to v9.0.1 ([5055fff](https://github.com/wmfs/pg-delta-file/commit/5055fffb9eef7a70d3e8c2b9ad76ffc995379ef9))
23
+ * **deps-dev:** update dependency mocha to v9.1.0 ([db5ee87](https://github.com/wmfs/pg-delta-file/commit/db5ee87472f5ccb2d7b535e8636887cdcc79b7cb))
24
+ * **deps-dev:** update dependency mocha to v9.1.1 ([2bcceb7](https://github.com/wmfs/pg-delta-file/commit/2bcceb75124e012cbf5e867078d161509ee4fa92))
25
+ * **deps-dev:** update dependency mocha to v9.1.2 ([9dc47b0](https://github.com/wmfs/pg-delta-file/commit/9dc47b02a3f726a6d4c17d285434c9ff88fe93a2))
26
+ * **deps-dev:** update dependency mocha to v9.1.3 ([b2bbe70](https://github.com/wmfs/pg-delta-file/commit/b2bbe7045435c8770340cb4f2a5024a913c6e349))
27
+ * **deps-dev:** update dependency mocha to v9.1.4 ([561e50a](https://github.com/wmfs/pg-delta-file/commit/561e50abb55bd0d035014001b44fc46e414e8b09))
28
+ * **deps-dev:** update dependency mocha to v9.2.0 ([502bb69](https://github.com/wmfs/pg-delta-file/commit/502bb69c987286039c6ae1efb4857de0dd71e540))
29
+ * **deps-dev:** update dependency semantic-release to v17.4.5 ([fc7da16](https://github.com/wmfs/pg-delta-file/commit/fc7da1662a66b9be0fbcca303966c4dc0a7d9c40))
30
+ * **deps-dev:** update dependency semantic-release to v17.4.6 ([1a663d9](https://github.com/wmfs/pg-delta-file/commit/1a663d9473ebb1ff1fa0228c68d059edd16e178e))
31
+ * **deps-dev:** update dependency semantic-release to v17.4.7 ([7d1abda](https://github.com/wmfs/pg-delta-file/commit/7d1abda27ee60a87f45016a73fe85fd217116135))
32
+ * **deps-dev:** update dependency semantic-release to v18 ([e1c04f3](https://github.com/wmfs/pg-delta-file/commit/e1c04f3ac238ee177a1fb84a84072c6a455ef7e7))
33
+ * **deps-dev:** update dependency semantic-release to v18.0.1 ([32c5a14](https://github.com/wmfs/pg-delta-file/commit/32c5a148dabf97df2e785802211f264fe2d849aa))
34
+ * **deps-dev:** update dependency semantic-release to v19 ([754d79a](https://github.com/wmfs/pg-delta-file/commit/754d79aa13e12e23a2ac02dabd7469cce7a4a10a))
35
+ * **deps-dev:** update dependency standard to v16.0.4 ([817fbcf](https://github.com/wmfs/pg-delta-file/commit/817fbcf362fcd5295e78dc2bcaf374a2438826f5))
36
+ * **deps-dev:** update semantic-release monorepo ([b07495e](https://github.com/wmfs/pg-delta-file/commit/b07495e1dfbed391e2444e98fd344a26371146f0))
37
+ * **deps:** update dependency luxon to v1.28.0 ([0fedca1](https://github.com/wmfs/pg-delta-file/commit/0fedca13c1681881cb6d52d455feaa3f34114f45))
38
+
39
+
40
+ ### βš™οΈ Continuous Integrations
41
+
42
+ * **circle:** CircleCI update next gen PostgreSQL image [sc-11442] ([4e377f0](https://github.com/wmfs/pg-delta-file/commit/4e377f0048a1c546893f9b81c253b3385ce71e58))
43
+
44
+
45
+ ### ♻️ Chores
46
+
47
+ * add renovate config [ch6600] ([5aefeae](https://github.com/wmfs/pg-delta-file/commit/5aefeae5b0c91a3d96b8435321536523b76e7eb4))
48
+
49
+ # [1.71.0](https://github.com/wmfs/pg-delta-file/compare/v1.70.0...v1.71.0) (2021-05-26)
50
+
51
+
52
+ ### πŸ›  Builds
53
+
54
+ * **deps:** Bump luxon from 1.26.0 to 1.27.0 ([5c8cdc2](https://github.com/wmfs/pg-delta-file/commit/5c8cdc26799ab8700c0881b4db18e86ff3f14b06))
55
+ * **deps-dev:** Bump codecov from 3.8.1 to 3.8.2 ([5d82a11](https://github.com/wmfs/pg-delta-file/commit/5d82a11c62497a666acfb0babad1a9760f247e83))
56
+ * **deps-dev:** Bump mocha from 8.3.2 to 8.4.0 ([663bcda](https://github.com/wmfs/pg-delta-file/commit/663bcda96317aed2886c59345438022e1170f5a6))
57
+ * **deps-dev:** Bump semantic-release from 17.4.2 to 17.4.3 ([c05f321](https://github.com/wmfs/pg-delta-file/commit/c05f321793f24c8cec861da30978d3be2c272df3))
58
+
59
+ # [1.70.0](https://github.com/wmfs/pg-delta-file/compare/v1.69.0...v1.70.0) (2021-03-31)
60
+
61
+
62
+ ### ✨ Features
63
+
64
+ * 🎸 New option - deletesFunction(namespace,model,sinceDate,oStream) ([0b942bf](https://github.com/wmfs/pg-delta-file/commit/0b942bf89516e5b4bed44b7ec380d112528f32fb))
65
+
66
+
67
+ ### πŸ›  Builds
68
+
69
+ * **deps-dev:** Bump chai from 4.3.0 to 4.3.1 ([5677d33](https://github.com/wmfs/pg-delta-file/commit/5677d33161632a35cff62c914e48221fa5f91efc))
70
+ * **deps-dev:** Bump chai from 4.3.1 to 4.3.2 ([83260cb](https://github.com/wmfs/pg-delta-file/commit/83260cbac7f007ee59d9134bb1fac3f92dbcea4d))
71
+ * **deps-dev:** Bump chai from 4.3.2 to 4.3.3 ([48e129c](https://github.com/wmfs/pg-delta-file/commit/48e129cdd67a67047e97cf57e13a9807c31f4e8a))
72
+ * **deps-dev:** Bump chai from 4.3.3 to 4.3.4 ([e6726a6](https://github.com/wmfs/pg-delta-file/commit/e6726a631bf43614c746629b544c2338db917bce))
73
+ * **deps-dev:** Bump mocha from 8.3.0 to 8.3.1 ([bda1d78](https://github.com/wmfs/pg-delta-file/commit/bda1d78598bf242b2370b24240555cabc6fc1d4e))
74
+ * **deps-dev:** Bump mocha from 8.3.1 to 8.3.2 ([a97b476](https://github.com/wmfs/pg-delta-file/commit/a97b476d940af866d6b1d5f02228a911540a70a2))
75
+ * **deps-dev:** Bump semantic-release from 17.3.9 to 17.4.0 ([e64ffa0](https://github.com/wmfs/pg-delta-file/commit/e64ffa0fd5e072decd147a8d5dbbd2af172f82c6))
76
+ * **deps-dev:** Bump semantic-release from 17.4.0 to 17.4.1 ([d0f84b5](https://github.com/wmfs/pg-delta-file/commit/d0f84b554bcf23cf633ac15d6a70895312f193e9))
77
+ * **deps-dev:** Bump semantic-release from 17.4.1 to 17.4.2 ([0e602be](https://github.com/wmfs/pg-delta-file/commit/0e602be52f4f4737b4770a78f7879f1d90e4a893))
78
+
79
+
80
+ ### βš™οΈ Continuous Integrations
81
+
82
+ * **circle:** update postgres config to 13.2 ([fef7a09](https://github.com/wmfs/pg-delta-file/commit/fef7a09df279122f45786c66aed0fe2296ac735c))
83
+
1
84
  # [1.69.0](https://github.com/wmfs/pg-delta-file/compare/v1.68.0...v1.69.0) (2021-02-24)
2
85
 
3
86
 
@@ -3,10 +3,10 @@ const csvEncoder = require('./simple-csv-encoder')
3
3
  const DateTime = require('luxon').DateTime
4
4
 
5
5
  class Transformer extends Transform {
6
- constructor (info, model, options) {
6
+ constructor (info, model, options, processingDeletes) {
7
7
  super({ objectMode: true })
8
8
  this.info = info
9
- this.modelInfo = { totalCount: 0 }
9
+ this.modelInfo = this.info[model] || { totalCount: 0 }
10
10
  this.info[model] = this.modelInfo
11
11
 
12
12
  const transformers = options.transformFunction ? options.transformFunction : identityTransform
@@ -29,6 +29,8 @@ class Transformer extends Transform {
29
29
 
30
30
  this.progressCallback = options.progressCallback
31
31
 
32
+ const actionTransformer = !processingDeletes ? insertOrUpdateAction(options) : deleteAction(options)
33
+
32
34
  this.transformers = options.csvExtracts[model].map(csvColumnSource => {
33
35
  switch (csvColumnSource[0]) {
34
36
  case '$': {
@@ -37,21 +39,7 @@ class Transformer extends Transform {
37
39
  case 'ROW_NUM':
38
40
  return (row, info) => info.totalCount
39
41
  case 'ACTION':
40
- return row => {
41
- // TODO: handle deleted action
42
- const createdCol = options.createdColumnName || '_created'
43
- const modifiedCol = options.modifiedColumnName || '_modified'
44
- const created = new Date(row[createdCol])
45
- const modified = new Date(row[modifiedCol])
46
- const since = new Date(options.since)
47
-
48
- if (modified >= since && created >= since) {
49
- return options.actionAliases.insert
50
- }
51
- if (modified >= since && created <= since) {
52
- return options.actionAliases.update
53
- }
54
- }
42
+ return actionTransformer
55
43
  case 'TIMESTAMP':
56
44
  return () => DateTime.local().toLocaleString(DateTime.TIME_24_WITH_SECONDS)
57
45
  case 'DATESTAMP':
@@ -122,4 +110,25 @@ function identityTransform (row, callback) {
122
110
  callback(null, row)
123
111
  }
124
112
 
113
+ function insertOrUpdateAction (options) {
114
+ return row => {
115
+ const createdCol = options.createdColumnName || '_created'
116
+ const modifiedCol = options.modifiedColumnName || '_modified'
117
+ const created = new Date(row[createdCol])
118
+ const modified = new Date(row[modifiedCol])
119
+ const since = new Date(options.since)
120
+
121
+ if (modified >= since && created >= since) {
122
+ return options.actionAliases.insert
123
+ }
124
+ if (modified >= since && created <= since) {
125
+ return options.actionAliases.update
126
+ }
127
+ }
128
+ }
129
+
130
+ function deleteAction (options) {
131
+ return () => options.actionAliases.delete
132
+ }
133
+
125
134
  module.exports = Transformer
@@ -20,6 +20,8 @@ module.exports = async function generateDelta (options) {
20
20
  }
21
21
 
22
22
  await extractModel(info, model, options, deltaFileWriteStream)
23
+
24
+ await processDeletes(info, model, options, deltaFileWriteStream)
23
25
  }
24
26
  } finally {
25
27
  progressCallback(info, true)
@@ -73,3 +75,12 @@ function tableName (namespace, model) {
73
75
 
74
76
  return (separator === -1) ? `${snakeCase(namespace)}.${model}` : model
75
77
  } // tableName
78
+
79
+ function processDeletes (info, model, options, outStream) {
80
+ if (!options.deletesFunction) { return }
81
+ const csvTransformer = new Transformer(info, model, options, true)
82
+ csvTransformer.pipe(outStream, { end: false })
83
+
84
+ const since = new Date(options.since)
85
+ return options.deletesFunction(options.namespace, model, since, csvTransformer)
86
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wmfs/pg-delta-file",
3
- "version": "1.69.0",
3
+ "version": "1.73.0",
4
4
  "description": "Outputs change-only-update CSV files (or β€œdelta” files) that contain all the necessary actions required to re-synchronize rows in a cloned table.",
5
5
  "author": "West Midlands Fire Service",
6
6
  "homepage": "https://github.com/wmfs/pg-delta-file#readme",
@@ -22,24 +22,24 @@
22
22
  "main": "./lib/index.js",
23
23
  "dependencies": {
24
24
  "lodash": "4.17.21",
25
- "luxon": "1.26.0",
25
+ "luxon": "2.3.0",
26
26
  "make-dir": "3.1.0",
27
27
  "pg": "8.5.1",
28
28
  "pg-query-stream": "4.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "chai": "4.3.0",
32
- "codecov": "3.8.1",
31
+ "chai": "4.3.4",
32
+ "codecov": "3.8.3",
33
33
  "conventional-changelog-metahub": "4.0.1",
34
34
  "cz-conventional-changelog": "3.3.0",
35
35
  "dirty-chai": "2.0.1",
36
- "mocha": "8.3.0",
36
+ "mocha": "9.2.0",
37
37
  "nyc": "15.1.0",
38
- "semantic-release": "17.3.9",
39
- "standard": "16.0.3",
40
- "@semantic-release/changelog": "5.0.1",
41
- "@semantic-release/git": "9.0.0",
42
- "@wmfs/hl-pg-client": "1.27.0"
38
+ "semantic-release": "19.0.2",
39
+ "standard": "16.0.4",
40
+ "@semantic-release/changelog": "6.0.1",
41
+ "@semantic-release/git": "10.0.1",
42
+ "@wmfs/hl-pg-client": "1.28.0"
43
43
  },
44
44
  "scripts": {
45
45
  "lint": "standard",
package/renovate.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ],
5
+ "dependencyDashboard": true,
6
+ "enabledManagers": ["npm"],
7
+ "packageRules": [
8
+ {
9
+ "matchDepTypes": ["devDependencies"],
10
+ "automerge": true,
11
+ "semanticCommitType": "build",
12
+ "semanticCommitScope": "deps-dev",
13
+ "labels": ["devDependencies"]
14
+ },
15
+ {
16
+ "matchDepTypes": ["dependencies"],
17
+ "semanticCommitType": "build",
18
+ "semanticCommitScope": "deps",
19
+ "labels": ["dependencies"],
20
+ "reviewers": ["team:tymly-reviewers"]
21
+ }
22
+ ],
23
+ "vulnerabilityAlerts": {
24
+ "labels": ["security"]
25
+ }
26
+ }
@@ -0,0 +1,6 @@
1
+ 73,"i",1,1,"Homer","Simpson",39
2
+ 73,"u",2,2,"Marge","Simpson",36
3
+ 73,"i",3,5,"Montgomery","Burns",123
4
+ 73,"i",4,6,"Ned","Flanders",60
5
+ 73,"i",5,8,"Bart","Simpson",10
6
+ 73,"d",6,99,"Marvin","Monroe",45
package/test/tests.js CHANGED
@@ -264,6 +264,45 @@ describe('Run the basic usage example', function () {
264
264
  ]
265
265
  }
266
266
  }
267
+ },
268
+ {
269
+ name: 'delta with delete',
270
+ file: 'with-deletes.csv',
271
+ count: 6,
272
+ info: {
273
+ totalCount: 6,
274
+ people: {
275
+ totalCount: 6
276
+ }
277
+ },
278
+ delta: {
279
+ namespace: 'springfield',
280
+ since: '2016-06-03 15:02:38.000000 GMT',
281
+ actionAliases: {
282
+ insert: 'i',
283
+ update: 'u',
284
+ delete: 'd'
285
+ },
286
+ deletesFunction: function (namespace, tableName, sinceDate, outputStream) {
287
+ outputStream.write({
288
+ social_security_id: 99,
289
+ first_name: 'Marvin',
290
+ last_name: 'Monroe',
291
+ age: 45
292
+ })
293
+ },
294
+ csvExtracts: {
295
+ people: [
296
+ 73,
297
+ '$ACTION',
298
+ '$ROW_NUM',
299
+ '@social_security_id',
300
+ '@first_name',
301
+ '@last_name',
302
+ '@age'
303
+ ]
304
+ }
305
+ }
267
306
  }
268
307
  ]
269
308