@wmfs/tymly-pg-plugin
Advanced tools
Comparing version 1.289.0 to 1.290.0
@@ -7,6 +7,10 @@ { | ||
"namespace": "wmfs", | ||
"id": "tempUprn" | ||
"id": "tempUprn", | ||
"prefix": "FSC" | ||
}, | ||
"ResultSelector": { | ||
"uprn.$": "$.value" | ||
}, | ||
"Next": "Create" | ||
} | ||
} |
module.exports = { | ||
description: 'Gets current value from sequence', | ||
description: 'Gets the current value from the specified sequence, returning it as the value of the value property', | ||
example: require('./example.json') | ||
} |
@@ -6,2 +6,3 @@ const _ = require('lodash') | ||
this.id = `${_.snakeCase(resourceConfig.namespace)}.${_.snakeCase(resourceConfig.id)}` | ||
this.prefix = resourceConfig.prefix || '' | ||
this.client = env.bootedServices.storage.client | ||
@@ -12,3 +13,3 @@ } | ||
const value = await this.client.query(`SELECT last_value FROM ${this.id}`) | ||
context.sendTaskSuccess({ value: value.rows[0].last_value }) | ||
context.sendTaskSuccess({ value: `${this.prefix}${value.rows[0].last_value}` }) | ||
} | ||
@@ -15,0 +16,0 @@ } |
{ | ||
"type": "object", | ||
"properties": {}, | ||
"required": [] | ||
"properties": { | ||
"namespace": { | ||
"type": "string", | ||
"description": "This is the name of the namespace in which the sequence exists." | ||
}, | ||
"id": { | ||
"type": "string", | ||
"description": "This is the id of a sequence from which the current value will be fetched." | ||
}, | ||
"prefix": { | ||
"type": "string", | ||
"description": "This setting allows you to specify a value which will be prepended to the returned value." | ||
} | ||
}, | ||
"required": [ | ||
"namespace", | ||
"id" | ||
] | ||
} | ||
@@ -7,6 +7,10 @@ { | ||
"namespace": "wmfs", | ||
"id": "tempUprn" | ||
"id": "tempUprn", | ||
"prefix": "FSA" | ||
}, | ||
"ResultSelector": { | ||
"uprn.$": "$.value" | ||
}, | ||
"Next": "Create" | ||
} | ||
} |
module.exports = { | ||
description: 'Gets next value from sequence', | ||
description: 'Gets the next value from the specified sequence, returning it as the value of the value property', | ||
example: require('./example.json') | ||
} |
@@ -6,2 +6,3 @@ const _ = require('lodash') | ||
this.id = `${_.snakeCase(resourceConfig.namespace)}.${_.snakeCase(resourceConfig.id)}` | ||
this.prefix = resourceConfig.prefix || '' | ||
this.client = env.bootedServices.storage.client | ||
@@ -12,3 +13,3 @@ } | ||
const value = await this.client.query(`select nextval('${this.id}')`) | ||
context.sendTaskSuccess({ value: value.rows[0].nextval }) | ||
context.sendTaskSuccess({ value: `${this.prefix}${value.rows[0].nextval}` }) | ||
} | ||
@@ -15,0 +16,0 @@ } |
{ | ||
"type": "object", | ||
"properties": {}, | ||
"required": [] | ||
"properties": { | ||
"namespace": { | ||
"type": "string", | ||
"description": "This is the name of the namespace in which the sequence exists." | ||
}, | ||
"id": { | ||
"type": "string", | ||
"description": "This is the id of a sequence from which the next value will be fetched." | ||
}, | ||
"prefix": { | ||
"type": "string", | ||
"description": "This setting allows you to specify a value which will be prepended to the returned value." | ||
} | ||
}, | ||
"required": [ | ||
"namespace", | ||
"id" | ||
] | ||
} | ||
{ | ||
"name": "@wmfs/tymly-pg-plugin", | ||
"version": "1.289.0", | ||
"version": "1.290.0", | ||
"description": "Replace Tymly's out-the-box memory storage with PostgreSQL", | ||
@@ -37,3 +37,3 @@ "author": "West Midlands Fire Service", | ||
"devDependencies": { | ||
"chai": "4.3.8", | ||
"chai": "4.3.10", | ||
"chai-subset": "1.6.0", | ||
@@ -46,3 +46,3 @@ "codecov": "3.8.3", | ||
"nyc": "15.1.0", | ||
"rimraf": "5.0.1", | ||
"rimraf": "5.0.5", | ||
"semantic-release": "21.1.1", | ||
@@ -49,0 +49,0 @@ "standard": "17.1.0", |
{ | ||
"name": "pg", | ||
"version": "1.289.0", | ||
"version": "1.290.0", | ||
"label": "PG", | ||
@@ -5,0 +5,0 @@ "author": "Tim Needham", |
@@ -11,2 +11,5 @@ /* eslint-env mocha */ | ||
const process = require('process') | ||
const chai = require('chai') | ||
const chaiSubset = require('chai-subset') | ||
chai.use(chaiSubset) | ||
const sqlScriptRunner = require('./fixtures/sql-script-runner') | ||
@@ -39,7 +42,6 @@ const OUTPUT_DIR_PATH = path.resolve(__dirname, './output') | ||
], | ||
blueprintPaths: [ | ||
path.resolve(__dirname, './fixtures/blueprints/animal-blueprint') | ||
path.resolve(__dirname, './fixtures/blueprints/animal-blueprint'), | ||
path.resolve(__dirname, './fixtures/blueprints/sequence-blueprint') | ||
], | ||
config: {} | ||
@@ -126,2 +128,72 @@ } | ||
it('find current sequence value of 1', async () => { | ||
const executionDescription = await statebox.startExecution( | ||
{}, | ||
'tymlyTest_findCurrentSequenceValue_1_0', | ||
{ | ||
sendResponse: 'COMPLETE' | ||
} | ||
) | ||
expect(executionDescription.ctx).to.containSubset({ | ||
ticketId: '1' | ||
}) | ||
}) | ||
it('find next sequence value of 1', async () => { | ||
const executionDescription = await statebox.startExecution( | ||
{}, | ||
'tymlyTest_findNextSequenceValue_1_0', | ||
{ | ||
sendResponse: 'COMPLETE' | ||
} | ||
) | ||
expect(executionDescription.ctx).to.containSubset({ | ||
ticketId: '1' | ||
}) | ||
}) | ||
it('find next sequence value of 2', async () => { | ||
const executionDescription = await statebox.startExecution( | ||
{}, | ||
'tymlyTest_findNextSequenceValue_1_0', | ||
{ | ||
sendResponse: 'COMPLETE' | ||
} | ||
) | ||
expect(executionDescription.ctx).to.containSubset({ | ||
ticketId: '2' | ||
}) | ||
}) | ||
it('find (prefixed) current sequence value of ABC2', async () => { | ||
const executionDescription = await statebox.startExecution( | ||
{}, | ||
'tymlyTest_findCurrentSequenceValueWithPrefix_1_0', | ||
{ | ||
sendResponse: 'COMPLETE' | ||
} | ||
) | ||
expect(executionDescription.ctx).to.containSubset({ | ||
ticketId: 'ABC2' | ||
}) | ||
}) | ||
it('find (prefixed) next sequence value of XYZ3', async () => { | ||
const executionDescription = await statebox.startExecution( | ||
{}, | ||
'tymlyTest_findNextSequenceValueWithPrefix_1_0', | ||
{ | ||
sendResponse: 'COMPLETE' | ||
} | ||
) | ||
expect(executionDescription.ctx).to.containSubset({ | ||
ticketId: 'XYZ3' | ||
}) | ||
}) | ||
after('uninstall test schemas', async () => { | ||
@@ -128,0 +200,0 @@ sqlScriptRunner.uninstall(client) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
299123
128
3749