@nina-protocol/nina-db 0.0.45 → 0.0.46
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/dist/migrations/20231112031914_post_version copy.js +15 -0
- package/dist/migrations/20240131143626_release_price.js +16 -0
- package/dist/models/Release.js +12 -2
- package/package.json +1 -1
- package/src/migrations/20240131143626_release_price.js +18 -0
- package/src/models/Release.js +15 -2
- package/src/migrations/20231116215117_add_tags.js +0 -41
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param { import("knex").Knex } knex
|
|
3
|
+
* @returns { Promise<void> }
|
|
4
|
+
*/
|
|
5
|
+
export const up = function (knex) {
|
|
6
|
+
return knex.schema.table('posts', table => {
|
|
7
|
+
table.string('version').notNullable().defaultTo('0.0.0');
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @param { import("knex").Knex } knex
|
|
12
|
+
* @returns { Promise<void> }
|
|
13
|
+
*/
|
|
14
|
+
export const down = function (knex) {
|
|
15
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param { import("knex").Knex } knex
|
|
3
|
+
* @returns { Promise<void> }
|
|
4
|
+
*/
|
|
5
|
+
export const up = function (knex) {
|
|
6
|
+
return knex.schema.table('releases', table => {
|
|
7
|
+
table.number('price').defaultTo(0);
|
|
8
|
+
table.string('paymentMint');
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @param { import("knex").Knex } knex
|
|
13
|
+
* @returns { Promise<void> }
|
|
14
|
+
*/
|
|
15
|
+
export const down = function (knex) {
|
|
16
|
+
};
|
package/dist/models/Release.js
CHANGED
|
@@ -15,7 +15,7 @@ export default class Release extends Model {
|
|
|
15
15
|
static idColumn = 'id';
|
|
16
16
|
static jsonSchema = {
|
|
17
17
|
type: 'object',
|
|
18
|
-
required: ['publicKey', 'mint', 'metadata', 'datetime', 'slug'],
|
|
18
|
+
required: ['publicKey', 'mint', 'metadata', 'datetime', 'slug', 'price'],
|
|
19
19
|
properties: {
|
|
20
20
|
publicKey: { type: 'string' },
|
|
21
21
|
mint: { type: 'string' },
|
|
@@ -40,9 +40,10 @@ export default class Release extends Model {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
+
price: { type: 'number' },
|
|
43
44
|
},
|
|
44
45
|
};
|
|
45
|
-
static findOrCreate = async (publicKey) => {
|
|
46
|
+
static findOrCreate = async (publicKey, hubPublicKey = null) => {
|
|
46
47
|
let release = await Release.query().findOne({ publicKey });
|
|
47
48
|
if (release) {
|
|
48
49
|
return release;
|
|
@@ -71,6 +72,13 @@ export default class Release extends Model {
|
|
|
71
72
|
publisherId: publisher.id,
|
|
72
73
|
releaseAccount
|
|
73
74
|
});
|
|
75
|
+
if (hubPublicKey) {
|
|
76
|
+
const hub = await Hub.query().findOne({ publicKey: hubPublicKey });
|
|
77
|
+
await release.$query().patch({ hubId: hub.id });
|
|
78
|
+
await Hub.relatedQuery('releases').for(hub.id).patch({
|
|
79
|
+
visible: true,
|
|
80
|
+
}).where({ id: release.id });
|
|
81
|
+
}
|
|
74
82
|
return release;
|
|
75
83
|
};
|
|
76
84
|
static createRelease = async ({ publicKey, mint, metadata, datetime, publisherId, releaseAccount }) => {
|
|
@@ -82,6 +90,8 @@ export default class Release extends Model {
|
|
|
82
90
|
slug,
|
|
83
91
|
datetime,
|
|
84
92
|
publisherId,
|
|
93
|
+
price: releaseAccount.price.toNumber(),
|
|
94
|
+
paymentMint: releaseAccount.paymentMint.toBase58(),
|
|
85
95
|
});
|
|
86
96
|
await this.processRevenueShares(releaseAccount, release);
|
|
87
97
|
tweetNewRelease(metadata, publisherId);
|
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param { import("knex").Knex } knex
|
|
3
|
+
* @returns { Promise<void> }
|
|
4
|
+
*/
|
|
5
|
+
export const up = function(knex) {
|
|
6
|
+
return knex.schema.table('releases' , table => {
|
|
7
|
+
table.number('price').defaultTo(0);
|
|
8
|
+
table.string('paymentMint');
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param { import("knex").Knex } knex
|
|
14
|
+
* @returns { Promise<void> }
|
|
15
|
+
*/
|
|
16
|
+
export const down = function(knex) {
|
|
17
|
+
|
|
18
|
+
};
|
package/src/models/Release.js
CHANGED
|
@@ -18,7 +18,7 @@ export default class Release extends Model {
|
|
|
18
18
|
static idColumn = 'id';
|
|
19
19
|
static jsonSchema = {
|
|
20
20
|
type: 'object',
|
|
21
|
-
required: ['publicKey', 'mint', 'metadata', 'datetime', 'slug'],
|
|
21
|
+
required: ['publicKey', 'mint', 'metadata', 'datetime', 'slug', 'price'],
|
|
22
22
|
properties: {
|
|
23
23
|
publicKey: { type: 'string' },
|
|
24
24
|
mint: { type: 'string' },
|
|
@@ -43,10 +43,11 @@ export default class Release extends Model {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
+
price: { type: 'number' },
|
|
46
47
|
},
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
static findOrCreate = async (publicKey) => {
|
|
50
|
+
static findOrCreate = async (publicKey, hubPublicKey=null) => {
|
|
50
51
|
let release = await Release.query().findOne({ publicKey });
|
|
51
52
|
if (release) {
|
|
52
53
|
return release;
|
|
@@ -79,6 +80,16 @@ export default class Release extends Model {
|
|
|
79
80
|
publisherId: publisher.id,
|
|
80
81
|
releaseAccount
|
|
81
82
|
});
|
|
83
|
+
|
|
84
|
+
if (hubPublicKey) {
|
|
85
|
+
|
|
86
|
+
const hub = await Hub.query().findOne({ publicKey: hubPublicKey })
|
|
87
|
+
await release.$query().patch({ hubId: hub.id })
|
|
88
|
+
await Hub.relatedQuery('releases').for(hub.id).patch({
|
|
89
|
+
visible: true,
|
|
90
|
+
}).where( {id: release.id });
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
return release;
|
|
83
94
|
}
|
|
84
95
|
|
|
@@ -92,6 +103,8 @@ export default class Release extends Model {
|
|
|
92
103
|
slug,
|
|
93
104
|
datetime,
|
|
94
105
|
publisherId,
|
|
106
|
+
price: releaseAccount.price.toNumber(),
|
|
107
|
+
paymentMint: releaseAccount.paymentMint.toBase58(),
|
|
95
108
|
})
|
|
96
109
|
await this.processRevenueShares(releaseAccount, release);
|
|
97
110
|
tweetNewRelease(metadata, publisherId);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param { import("knex").Knex } knex
|
|
3
|
-
* @returns { Promise<void> }
|
|
4
|
-
*/
|
|
5
|
-
export const up = function(knex) {
|
|
6
|
-
return Promise.all([
|
|
7
|
-
knex.schema.createTable('tags', table => {
|
|
8
|
-
table.increments('id').primary();
|
|
9
|
-
table.string('value').notNullable();
|
|
10
|
-
}),
|
|
11
|
-
knex.schema.createTable('tags_content', table => {
|
|
12
|
-
table.primary(['tagId', 'releaseId', 'postId']);
|
|
13
|
-
table.integer('releaseId')
|
|
14
|
-
.unsigned()
|
|
15
|
-
.references('id')
|
|
16
|
-
.inTable('releases')
|
|
17
|
-
.onDelete('CASCADE')
|
|
18
|
-
.index();
|
|
19
|
-
table.integer('postId')
|
|
20
|
-
.unsigned()
|
|
21
|
-
.references('id')
|
|
22
|
-
.inTable('accounts')
|
|
23
|
-
.onDelete('CASCADE')
|
|
24
|
-
.index();
|
|
25
|
-
table.integer('tagId')
|
|
26
|
-
.unsigned()
|
|
27
|
-
.references('id')
|
|
28
|
-
.inTable('accounts')
|
|
29
|
-
.onDelete('CASCADE')
|
|
30
|
-
.index();
|
|
31
|
-
}),
|
|
32
|
-
])
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @param { import("knex").Knex } knex
|
|
37
|
-
* @returns { Promise<void> }
|
|
38
|
-
*/
|
|
39
|
-
export const down = function(knex) {
|
|
40
|
-
return knex.schema.dropTableIfExists('tags');
|
|
41
|
-
};
|