@nina-protocol/nina-db 0.0.96 → 0.0.99
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/20250616215722_program_id.js +18 -0
- package/dist/models/Hub.js +1 -1
- package/dist/models/Release.js +11 -4
- package/package.json +1 -1
- package/src/migrations/20250616215722_program_id.js +19 -0
- package/src/models/Hub.js +1 -1
- package/src/models/Release.js +12 -4
- package/yarn-error.log +0 -6817
|
@@ -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.string('programId').notNullable().defaultTo(process.env.NINA_PROGRAM_ID);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @param { import("knex").Knex } knex
|
|
12
|
+
* @returns { Promise<void> }
|
|
13
|
+
*/
|
|
14
|
+
export const down = function (knex) {
|
|
15
|
+
return knex.schema.table('releases', table => {
|
|
16
|
+
table.dropColumn('programId');
|
|
17
|
+
});
|
|
18
|
+
};
|
package/dist/models/Hub.js
CHANGED
|
@@ -51,7 +51,7 @@ export default class Hub extends Model {
|
|
|
51
51
|
through: {
|
|
52
52
|
from: 'hubs_collaborators.hubId',
|
|
53
53
|
to: 'hubs_collaborators.accountId',
|
|
54
|
-
extra: ['hubCollaboratorPublicKey'],
|
|
54
|
+
extra: ['hubCollaboratorPublicKey', 'canAddContent', 'canAddCollaborator', 'added_by'],
|
|
55
55
|
},
|
|
56
56
|
to: 'accounts.id',
|
|
57
57
|
},
|
package/dist/models/Release.js
CHANGED
|
@@ -10,6 +10,12 @@ import Tag from './Tag.js';
|
|
|
10
10
|
import axios from 'axios';
|
|
11
11
|
import promiseRetry from 'promise-retry';
|
|
12
12
|
import { customAlphabet } from 'nanoid';
|
|
13
|
+
const ensureHttps = (uri) => {
|
|
14
|
+
if (!uri.startsWith('http://') && !uri.startsWith('https://')) {
|
|
15
|
+
return `https://${uri}`;
|
|
16
|
+
}
|
|
17
|
+
return uri;
|
|
18
|
+
};
|
|
13
19
|
const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
14
20
|
const randomStringGenerator = customAlphabet(alphabet, 12);
|
|
15
21
|
export default class Release extends Model {
|
|
@@ -46,7 +52,7 @@ export default class Release extends Model {
|
|
|
46
52
|
archived: { type: 'boolean' },
|
|
47
53
|
},
|
|
48
54
|
};
|
|
49
|
-
static findOrCreate = async (publicKey, hubPublicKey = null) => {
|
|
55
|
+
static findOrCreate = async (publicKey, hubPublicKey = null, programId = process.env.NINA_PROGRAM_V2_ID) => {
|
|
50
56
|
try {
|
|
51
57
|
let release = await Release.query().findOne({ publicKey });
|
|
52
58
|
if (release) {
|
|
@@ -78,10 +84,10 @@ export default class Release extends Model {
|
|
|
78
84
|
}
|
|
79
85
|
let json;
|
|
80
86
|
try {
|
|
81
|
-
json = (await axios.get(metadataAccount.uri.replace('www.', '').replace('arweave.net', 'gateway.irys.xyz'))).data;
|
|
87
|
+
json = (await axios.get(ensureHttps(metadataAccount.uri.replace('www.', '').replace('arweave.net', 'gateway.irys.xyz')))).data;
|
|
82
88
|
}
|
|
83
89
|
catch (error) {
|
|
84
|
-
json = (await axios.get(metadataAccount.uri.replace('gateway.irys.xyz', 'arweave.net'))).data;
|
|
90
|
+
json = (await axios.get(ensureHttps(metadataAccount.uri.replace('gateway.irys.xyz', 'arweave.net')))).data;
|
|
85
91
|
}
|
|
86
92
|
const slug = await this.generateSlug(json);
|
|
87
93
|
let publisher = await Account.findOrCreate(releaseAccount.authority.toBase58());
|
|
@@ -92,7 +98,8 @@ export default class Release extends Model {
|
|
|
92
98
|
datetime: new Date(releaseAccount.releaseDatetime.toNumber() * 1000).toISOString(),
|
|
93
99
|
slug,
|
|
94
100
|
publisherId: publisher.id,
|
|
95
|
-
releaseAccount
|
|
101
|
+
releaseAccount,
|
|
102
|
+
programId,
|
|
96
103
|
});
|
|
97
104
|
if (hubPublicKey) {
|
|
98
105
|
const hub = await Hub.query().findOne({ publicKey: hubPublicKey });
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
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.string('programId').notNullable().defaultTo(process.env.NINA_PROGRAM_ID);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param { import("knex").Knex } knex
|
|
13
|
+
* @returns { Promise<void> }
|
|
14
|
+
*/
|
|
15
|
+
export const down = function(knex) {
|
|
16
|
+
return knex.schema.table('releases', table => {
|
|
17
|
+
table.dropColumn('programId');
|
|
18
|
+
});
|
|
19
|
+
};
|
package/src/models/Hub.js
CHANGED
|
@@ -56,7 +56,7 @@ export default class Hub extends Model {
|
|
|
56
56
|
through: {
|
|
57
57
|
from: 'hubs_collaborators.hubId',
|
|
58
58
|
to: 'hubs_collaborators.accountId',
|
|
59
|
-
extra: ['hubCollaboratorPublicKey'],
|
|
59
|
+
extra: ['hubCollaboratorPublicKey', 'canAddContent', 'canAddCollaborator', 'added_by'],
|
|
60
60
|
},
|
|
61
61
|
to: 'accounts.id',
|
|
62
62
|
},
|
package/src/models/Release.js
CHANGED
|
@@ -12,6 +12,13 @@ import promiseRetry from 'promise-retry';
|
|
|
12
12
|
import { customAlphabet } from 'nanoid';
|
|
13
13
|
import promiseRetry from 'promise-retry';
|
|
14
14
|
|
|
15
|
+
const ensureHttps = (uri) => {
|
|
16
|
+
if (!uri.startsWith('http://') && !uri.startsWith('https://')) {
|
|
17
|
+
return `https://${uri}`;
|
|
18
|
+
}
|
|
19
|
+
return uri;
|
|
20
|
+
};
|
|
21
|
+
|
|
15
22
|
const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
16
23
|
const randomStringGenerator = customAlphabet(alphabet, 12);
|
|
17
24
|
export default class Release extends Model {
|
|
@@ -50,7 +57,7 @@ export default class Release extends Model {
|
|
|
50
57
|
},
|
|
51
58
|
}
|
|
52
59
|
|
|
53
|
-
static findOrCreate = async (publicKey, hubPublicKey=null) => {
|
|
60
|
+
static findOrCreate = async (publicKey, hubPublicKey=null, programId=process.env.NINA_PROGRAM_V2_ID) => {
|
|
54
61
|
try {
|
|
55
62
|
let release = await Release.query().findOne({ publicKey });
|
|
56
63
|
if (release) {
|
|
@@ -89,9 +96,9 @@ export default class Release extends Model {
|
|
|
89
96
|
}
|
|
90
97
|
let json
|
|
91
98
|
try {
|
|
92
|
-
json = (await axios.get(metadataAccount.uri.replace('www.','').replace('arweave.net', 'gateway.irys.xyz'))).data
|
|
99
|
+
json = (await axios.get(ensureHttps(metadataAccount.uri.replace('www.','').replace('arweave.net', 'gateway.irys.xyz')))).data
|
|
93
100
|
} catch (error) {
|
|
94
|
-
json = (await axios.get(metadataAccount.uri.replace('gateway.irys.xyz', 'arweave.net'))).data
|
|
101
|
+
json = (await axios.get(ensureHttps(metadataAccount.uri.replace('gateway.irys.xyz', 'arweave.net')))).data
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
const slug = await this.generateSlug(json);
|
|
@@ -103,7 +110,8 @@ export default class Release extends Model {
|
|
|
103
110
|
datetime: new Date(releaseAccount.releaseDatetime.toNumber() * 1000).toISOString(),
|
|
104
111
|
slug,
|
|
105
112
|
publisherId: publisher.id,
|
|
106
|
-
releaseAccount
|
|
113
|
+
releaseAccount,
|
|
114
|
+
programId,
|
|
107
115
|
});
|
|
108
116
|
|
|
109
117
|
if (hubPublicKey) {
|