Skip to content

Commit 38871a5

Browse files
author
vikasrohit
authored
Merge pull request #287 from topcoder-platform/feature/project-templates-refactoring-fields
Rename Form.scope and PlanConfig.phases to config
2 parents ca7b895 + e8df7e0 commit 38871a5

33 files changed

+118
-118
lines changed

migrations/20190316_extract_scope_from_project_templates.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CREATE TABLE form (
77
"key" character varying(45) NOT NULL,
88
"version" bigint DEFAULT 1 NOT NULL,
99
"revision" bigint DEFAULT 1 NOT NULL,
10-
"scope" json DEFAULT '{}'::json NOT NULL,
10+
"config" json DEFAULT '{}'::json NOT NULL,
1111
"deletedAt" timestamp with time zone,
1212
"createdAt" timestamp with time zone,
1313
"updatedAt" timestamp with time zone,
@@ -67,7 +67,7 @@ CREATE TABLE plan_config (
6767
"key" character varying(45) NOT NULL,
6868
"version" bigint DEFAULT 1 NOT NULL,
6969
"revision" bigint DEFAULT 1 NOT NULL,
70-
"phases" json DEFAULT '{}'::json NOT NULL,
70+
"config" json DEFAULT '{}'::json NOT NULL,
7171
"deletedAt" timestamp with time zone,
7272
"createdAt" timestamp with time zone,
7373
"updatedAt" timestamp with time zone,

postman.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"info": {
3-
"_postman_id": "b2fedaf2-e077-4351-ac5b-72be7f46e3ed",
3+
"_postman_id": "db83f8a1-5b3f-4276-a371-aa3c3497542d",
44
"name": "tc-project-service",
55
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
66
},
@@ -5306,7 +5306,7 @@
53065306
],
53075307
"body": {
53085308
"mode": "raw",
5309-
"raw": "{\r\n \"param\":{\r\n \t\"scope\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
5309+
"raw": "{\r\n \"param\":{\r\n \t\"config\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
53105310
},
53115311
"url": {
53125312
"raw": "{{api-url}}/v4/projects/metadata/form/dev/versions",
@@ -5349,7 +5349,7 @@
53495349
],
53505350
"body": {
53515351
"mode": "raw",
5352-
"raw": "{\r\n \"param\":{\r\n \t\"scope\": {\r\n \t\t\"hello\": \"test111\"\r\n \t}\r\n }\r\n}"
5352+
"raw": "{\r\n \"param\":{\r\n \t\"config\": {\r\n \t\t\"hello\": \"test111\"\r\n \t}\r\n }\r\n}"
53535353
},
53545354
"url": {
53555355
"raw": "{{api-url}}/v4/projects/metadata/form/dev/versions/1",
@@ -5519,7 +5519,7 @@
55195519
],
55205520
"body": {
55215521
"mode": "raw",
5522-
"raw": "{\r\n \"param\":{\r\n \t\"scope\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
5522+
"raw": "{\r\n \"param\":{\r\n \t\"config\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
55235523
},
55245524
"url": {
55255525
"raw": "{{api-url}}/v4/projects/metadata/form/dev/versions/1/revisions",
@@ -5564,7 +5564,7 @@
55645564
],
55655565
"body": {
55665566
"mode": "raw",
5567-
"raw": "{\r\n \"param\":{\r\n \t\"scope\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
5567+
"raw": "{\r\n \"param\":{\r\n \t\"config\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
55685568
},
55695569
"url": {
55705570
"raw": "{{api-url}}/v4/projects/metadata/form/no-exist-2222key36/versions/1/revisions",
@@ -6252,7 +6252,7 @@
62526252
],
62536253
"body": {
62546254
"mode": "raw",
6255-
"raw": "{\r\n \"param\":{\r\n \t\"phases\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
6255+
"raw": "{\r\n \"param\":{\r\n \t\"config\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
62566256
},
62576257
"url": {
62586258
"raw": "{{api-url}}/v4/projects/metadata/planConfig/dev/versions",
@@ -6295,7 +6295,7 @@
62956295
],
62966296
"body": {
62976297
"mode": "raw",
6298-
"raw": "{\r\n \"param\":{\r\n \t\"phases\": {\r\n \t\t\"hello\": \"test111\"\r\n \t}\r\n }\r\n}"
6298+
"raw": "{\r\n \"param\":{\r\n \t\"config\": {\r\n \t\t\"hello\": \"test111\"\r\n \t}\r\n }\r\n}"
62996299
},
63006300
"url": {
63016301
"raw": "{{api-url}}/v4/projects/metadata/planConfig/dev/versions/1",
@@ -6465,7 +6465,7 @@
64656465
],
64666466
"body": {
64676467
"mode": "raw",
6468-
"raw": "{\r\n \"param\":{\r\n \t\"phases\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
6468+
"raw": "{\r\n \"param\":{\r\n \t\"config\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
64696469
},
64706470
"url": {
64716471
"raw": "{{api-url}}/v4/projects/metadata/planConfig/dev/versions/1/revisions",
@@ -6510,7 +6510,7 @@
65106510
],
65116511
"body": {
65126512
"mode": "raw",
6513-
"raw": "{\r\n \"param\":{\r\n \t\"phases\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
6513+
"raw": "{\r\n \"param\":{\r\n \t\"config\": {\r\n \t\t\"hello\": \"test\"\r\n \t}\r\n }\r\n}"
65146514
},
65156515
"url": {
65166516
"raw": "{{api-url}}/v4/projects/metadata/planConfig/no-exist-key/versions/1/revisions",

src/models/form.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = (sequelize, DataTypes) => {
1212
key: { type: DataTypes.STRING(45), allowNull: false },
1313
version: { type: DataTypes.BIGINT, allowNull: false, defaultValue: 1 },
1414
revision: { type: DataTypes.BIGINT, allowNull: false, defaultValue: 1 },
15-
scope: { type: DataTypes.JSON, allowNull: false },
15+
config: { type: DataTypes.JSON, allowNull: false },
1616

1717
deletedAt: { type: DataTypes.DATE, allowNull: true },
1818
createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW },
@@ -35,7 +35,7 @@ module.exports = (sequelize, DataTypes) => {
3535
],
3636
});
3737

38-
const classMethods = versionModelClassMethods(Form, 'scope');
38+
const classMethods = versionModelClassMethods(Form, 'config');
3939
Form.deleteOldestRevision = classMethods.deleteOldestRevision;
4040
Form.newVersionNumber = classMethods.newVersionNumber;
4141
Form.createNewVersion = classMethods.createNewVersion;

src/models/planConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = (sequelize, DataTypes) => {
1212
key: { type: DataTypes.STRING(45), allowNull: false },
1313
version: { type: DataTypes.BIGINT, allowNull: false, defaultValue: 1 },
1414
revision: { type: DataTypes.BIGINT, allowNull: false, defaultValue: 1 },
15-
phases: { type: DataTypes.JSON, allowNull: false },
15+
config: { type: DataTypes.JSON, allowNull: false },
1616

1717
deletedAt: { type: DataTypes.DATE, allowNull: true },
1818
createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW },
@@ -35,7 +35,7 @@ module.exports = (sequelize, DataTypes) => {
3535
],
3636
});
3737

38-
const classMethods = versionModelClassMethods(PlanConfig, 'phases');
38+
const classMethods = versionModelClassMethods(PlanConfig, 'config');
3939
PlanConfig.deleteOldestRevision = classMethods.deleteOldestRevision;
4040
PlanConfig.newVersionNumber = classMethods.newVersionNumber;
4141
PlanConfig.createNewVersion = classMethods.createNewVersion;

src/routes/form/revision/create.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const schema = {
1717
},
1818
body: {
1919
param: Joi.object().keys({
20-
scope: Joi.object().required(),
20+
config: Joi.object().required(),
2121

2222
createdAt: Joi.any().strip(),
2323
updatedAt: Joi.any().strip(),
@@ -49,7 +49,7 @@ module.exports = [
4949
createdBy: req.authUser.userId,
5050
updatedBy: req.authUser.userId,
5151
key: req.params.key,
52-
scope: req.body.param.scope,
52+
config: req.body.param.config,
5353
});
5454
return models.Form.create(entity);
5555
}

src/routes/form/revision/create.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('CREATE Form Revision', () => {
1515
const forms = [
1616
{
1717
key: 'dev',
18-
scope: {
18+
config: {
1919
test: 'test1',
2020
},
2121
version: 1,
@@ -25,7 +25,7 @@ describe('CREATE Form Revision', () => {
2525
},
2626
{
2727
key: 'dev',
28-
scope: {
28+
config: {
2929
test: 'test2',
3030
},
3131
version: 1,
@@ -45,7 +45,7 @@ describe('CREATE Form Revision', () => {
4545
describe('Post /projects/metadata/form/{key}/versions/{version}/revision', () => {
4646
const body = {
4747
param: {
48-
scope: {
48+
config: {
4949
'test create': 'test create',
5050
},
5151
},
@@ -80,10 +80,10 @@ describe('CREATE Form Revision', () => {
8080
.expect(404, done);
8181
});
8282

83-
it('should return 422 if missing scope', (done) => {
83+
it('should return 422 if missing config', (done) => {
8484
const invalidBody = {
8585
param: _.assign({}, body.param, {
86-
scope: undefined,
86+
config: undefined,
8787
}),
8888
};
8989

@@ -109,7 +109,7 @@ describe('CREATE Form Revision', () => {
109109
.end((err, res) => {
110110
const resJson = res.body.result.content;
111111
should.exist(resJson.id);
112-
resJson.scope.should.be.eql(body.param.scope);
112+
resJson.config.should.be.eql(body.param.config);
113113
resJson.key.should.be.eql('dev');
114114
resJson.revision.should.be.eql(3);
115115
resJson.version.should.be.eql(1);

src/routes/form/revision/delete.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('DELETE form revision', () => {
4040
const forms = [
4141
{
4242
key: 'dev',
43-
scope: {
43+
config: {
4444
test: 'test1',
4545
},
4646
version: 1,
@@ -50,7 +50,7 @@ describe('DELETE form revision', () => {
5050
},
5151
{
5252
key: 'dev',
53-
scope: {
53+
config: {
5454
test: 'test2',
5555
},
5656
version: 1,

src/routes/form/revision/get.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('GET a particular revision of specific version Form', () => {
1414
const forms = [
1515
{
1616
key: 'dev',
17-
scope: {
17+
config: {
1818
test: 'test1',
1919
},
2020
version: 1,
@@ -24,7 +24,7 @@ describe('GET a particular revision of specific version Form', () => {
2424
},
2525
{
2626
key: 'dev',
27-
scope: {
27+
config: {
2828
test: 'test2',
2929
},
3030
version: 1,
@@ -54,7 +54,7 @@ describe('GET a particular revision of specific version Form', () => {
5454
const resJson = res.body.result.content;
5555

5656
resJson.key.should.be.eql(form.key);
57-
resJson.scope.should.be.eql(form.scope);
57+
resJson.config.should.be.eql(form.config);
5858
resJson.version.should.be.eql(form.version);
5959
resJson.revision.should.be.eql(form.revision);
6060
should.exist(resJson.createdAt);

src/routes/form/revision/list.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('LIST form revisions', () => {
1515
const forms = [
1616
{
1717
key: 'dev',
18-
scope: {
18+
config: {
1919
'test': 'test1',
2020
},
2121
version: 1,
@@ -25,7 +25,7 @@ describe('LIST form revisions', () => {
2525
},
2626
{
2727
key: 'dev',
28-
scope: {
28+
config: {
2929
test: 'test2',
3030
},
3131
version: 1,
@@ -56,7 +56,7 @@ describe('LIST form revisions', () => {
5656
resJson.should.have.length(2);
5757

5858
resJson[0].key.should.be.eql(form.key);
59-
resJson[0].scope.should.be.eql(form.scope);
59+
resJson[0].config.should.be.eql(form.config);
6060
resJson[0].version.should.be.eql(form.version);
6161
resJson[0].revision.should.be.eql(form.revision);
6262
should.exist(resJson[0].createdAt);

src/routes/form/version/create.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const schema = {
1616
},
1717
body: {
1818
param: Joi.object().keys({
19-
scope: Joi.object().required(),
19+
config: Joi.object().required(),
2020

2121
createdAt: Joi.any().strip(),
2222
updatedAt: Joi.any().strip(),
@@ -51,7 +51,7 @@ module.exports = [
5151
createdBy: req.authUser.userId,
5252
updatedBy: req.authUser.userId,
5353
key: req.params.key,
54-
scope: req.body.param.scope,
54+
config: req.body.param.config,
5555
});
5656
return models.Form.create(entity);
5757
}).then((createdEntity) => {

0 commit comments

Comments
 (0)