@nina-protocol/nina-db 0.0.89 → 0.0.91

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/knexfile.js CHANGED
@@ -14,6 +14,15 @@ export default {
14
14
  migrations: {
15
15
  directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
16
16
  },
17
+ auth: {
18
+ client: 'postgresql',
19
+ connection: {
20
+ host: process.env.AUTH_DB_HOST,
21
+ user: process.env.AUTH_USER,
22
+ password: process.env.AUTH_PASSWORD,
23
+ database: process.env.AUTH_DB_NAME
24
+ }
25
+ }
17
26
  },
18
27
  staging: {
19
28
  client: 'postgresql',
@@ -26,6 +35,15 @@ export default {
26
35
  migrations: {
27
36
  directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
28
37
  },
38
+ auth: {
39
+ client: 'postgresql',
40
+ connection: {
41
+ host: process.env.AUTH_DB_HOST,
42
+ user: process.env.AUTH_USER,
43
+ password: process.env.AUTH_PASSWORD,
44
+ database: process.env.AUTH_DB_NAME
45
+ }
46
+ }
29
47
  },
30
48
  production: {
31
49
  client: 'postgresql',
@@ -38,6 +56,23 @@ export default {
38
56
  migrations: {
39
57
  directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
40
58
  },
41
- debug: true,
59
+ auth: {
60
+ client: 'postgresql',
61
+ connection: {
62
+ host: process.env.AUTH_DB_HOST,
63
+ user: process.env.AUTH_USER,
64
+ password: process.env.AUTH_PASSWORD,
65
+ database: process.env.AUTH_DB_NAME
66
+ }
67
+ }
68
+ },
69
+ knexAuthDB: {
70
+ client: 'postgresql',
71
+ connection: {
72
+ host: process.env.AUTH_DB_HOST,
73
+ user: process.env.AUTH_USER,
74
+ password: process.env.AUTH_PASSWORD,
75
+ database: process.env.AUTH_DB_NAME
76
+ }
42
77
  }
43
78
  };
@@ -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('subscriptions', table => {
7
+ table.string('ref').nullable();
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('subscriptions', table => {
16
+ table.dropColumn('ref');
17
+ });
18
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function (knex) {
6
+ return knex.schema.table('hubs_collaborators', table => {
7
+ table.boolean('can_add_content').defaultTo(true);
8
+ table.boolean('can_add_collaborators').defaultTo(true);
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('hubs_collaborators', table => {
17
+ table.dropColumn('can_add_content');
18
+ table.dropColumn('can_add_collaborators');
19
+ });
20
+ };
@@ -8,8 +8,8 @@ import Hub from './Hub.js';
8
8
  import Post from './Post.js';
9
9
  import Tag from './Tag.js';
10
10
  import axios from 'axios';
11
- import { customAlphabet } from 'nanoid';
12
11
  import promiseRetry from 'promise-retry';
12
+ import { customAlphabet } from 'nanoid';
13
13
  const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
14
14
  const randomStringGenerator = customAlphabet(alphabet, 12);
15
15
  export default class Release extends Model {
@@ -13,7 +13,6 @@ class Subscription extends Model {
13
13
  type: 'object',
14
14
  required: ['datetime'],
15
15
  properties: {
16
- publicKey: { type: 'string' },
17
16
  datetime: { type: 'string' },
18
17
  from: { type: 'string' },
19
18
  to: { type: 'string' },
@@ -24,7 +23,7 @@ class Subscription extends Model {
24
23
  },
25
24
  };
26
25
  }
27
- static async findOrCreate({ publicKey, from, to, datetime, subscriptionType }) {
26
+ static async findOrCreate({ from, to, datetime, subscriptionType }) {
28
27
  let subscription = await Subscription.query().findOne({ from, to });
29
28
  if (subscription) {
30
29
  return subscription;
@@ -32,7 +31,7 @@ class Subscription extends Model {
32
31
  subscription = await Subscription.query().insert({
33
32
  from, to, datetime, subscriptionType
34
33
  });
35
- console.log('Inserted subscription: ', publicKey);
34
+ console.log('Inserted subscription: ', from, to);
36
35
  return subscription;
37
36
  }
38
37
  async format() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.89",
3
+ "version": "0.0.91",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
package/src/knexfile.js CHANGED
@@ -2,8 +2,8 @@
2
2
  * @type { Object.<string, import("knex").Knex.Config> }
3
3
  */
4
4
  import "dotenv/config.js";
5
- export default {
6
5
 
6
+ export default {
7
7
  development: {
8
8
  client: 'postgresql',
9
9
  connection: {
@@ -15,6 +15,15 @@ export default {
15
15
  migrations: {
16
16
  directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
17
17
  },
18
+ auth: {
19
+ client: 'postgresql',
20
+ connection: {
21
+ host: process.env.AUTH_DB_HOST,
22
+ user: process.env.AUTH_USER,
23
+ password: process.env.AUTH_PASSWORD,
24
+ database: process.env.AUTH_DB_NAME
25
+ }
26
+ }
18
27
  },
19
28
  staging: {
20
29
  client: 'postgresql',
@@ -27,6 +36,15 @@ export default {
27
36
  migrations: {
28
37
  directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
29
38
  },
39
+ auth: {
40
+ client: 'postgresql',
41
+ connection: {
42
+ host: process.env.AUTH_DB_HOST,
43
+ user: process.env.AUTH_USER,
44
+ password: process.env.AUTH_PASSWORD,
45
+ database: process.env.AUTH_DB_NAME
46
+ }
47
+ }
30
48
  },
31
49
  production: {
32
50
  client: 'postgresql',
@@ -39,6 +57,23 @@ export default {
39
57
  migrations: {
40
58
  directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
41
59
  },
42
- debug: true,
60
+ auth: {
61
+ client: 'postgresql',
62
+ connection: {
63
+ host: process.env.AUTH_DB_HOST,
64
+ user: process.env.AUTH_USER,
65
+ password: process.env.AUTH_PASSWORD,
66
+ database: process.env.AUTH_DB_NAME
67
+ }
68
+ }
69
+ },
70
+ knexAuthDB: {
71
+ client: 'postgresql',
72
+ connection: {
73
+ host: process.env.AUTH_DB_HOST,
74
+ user: process.env.AUTH_USER,
75
+ password: process.env.AUTH_PASSWORD,
76
+ database: process.env.AUTH_DB_NAME
77
+ }
43
78
  }
44
- };
79
+ };
@@ -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('subscriptions', table => {
7
+ table.string('ref').nullable();
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('subscriptions', table => {
17
+ table.dropColumn('ref');
18
+ });
19
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function(knex) {
6
+ return knex.schema.table('hubs_collaborators', table => {
7
+ table.boolean('can_add_content').defaultTo(true);
8
+ table.boolean('can_add_collaborators').defaultTo(true);
9
+ });
10
+ };
11
+
12
+ /**
13
+ * @param { import("knex").Knex } knex
14
+ * @returns { Promise<void> }
15
+ */
16
+ export const down = function(knex) {
17
+ return knex.schema.table('hubs_collaborators', table => {
18
+ table.dropColumn('can_add_content');
19
+ table.dropColumn('can_add_collaborators');
20
+ });
21
+ };
@@ -8,12 +8,12 @@ import Hub from './Hub.js';
8
8
  import Post from './Post.js';
9
9
  import Tag from './Tag.js';
10
10
  import axios from 'axios';
11
+ import promiseRetry from 'promise-retry';
11
12
  import { customAlphabet } from 'nanoid';
12
13
  import promiseRetry from 'promise-retry';
13
14
 
14
15
  const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
15
16
  const randomStringGenerator = customAlphabet(alphabet, 12);
16
-
17
17
  export default class Release extends Model {
18
18
  static tableName = 'releases';
19
19
 
@@ -49,7 +49,7 @@ export default class Release extends Model {
49
49
  archived: { type: 'boolean' },
50
50
  },
51
51
  }
52
-
52
+
53
53
  static findOrCreate = async (publicKey, hubPublicKey=null) => {
54
54
  try {
55
55
  let release = await Release.query().findOne({ publicKey });
@@ -14,7 +14,6 @@ class Subscription extends Model {
14
14
  type: 'object',
15
15
  required: ['datetime'],
16
16
  properties: {
17
- publicKey: { type: 'string' },
18
17
  datetime: { type: 'string' },
19
18
  from: { type: 'string' },
20
19
  to: { type: 'string' },
@@ -26,7 +25,7 @@ class Subscription extends Model {
26
25
  };
27
26
  }
28
27
 
29
- static async findOrCreate({publicKey, from, to, datetime, subscriptionType}) {
28
+ static async findOrCreate({from, to, datetime, subscriptionType}) {
30
29
  let subscription = await Subscription.query().findOne({ from, to });
31
30
  if (subscription) {
32
31
  return subscription;
@@ -35,7 +34,7 @@ class Subscription extends Model {
35
34
  subscription = await Subscription.query().insert({
36
35
  from, to, datetime, subscriptionType
37
36
  });
38
- console.log('Inserted subscription: ', publicKey)
37
+ console.log('Inserted subscription: ', from, to)
39
38
  return subscription;
40
39
  }
41
40
 
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ exports.up = function(knex) {
6
+
7
+ };
8
+
9
+ /**
10
+ * @param { import("knex").Knex } knex
11
+ * @returns { Promise<void> }
12
+ */
13
+ exports.down = function(knex) {
14
+
15
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ exports.up = function(knex) {
6
+
7
+ };
8
+
9
+ /**
10
+ * @param { import("knex").Knex } knex
11
+ * @returns { Promise<void> }
12
+ */
13
+ exports.down = function(knex) {
14
+
15
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ exports.up = function(knex) {
6
+
7
+ };
8
+
9
+ /**
10
+ * @param { import("knex").Knex } knex
11
+ * @returns { Promise<void> }
12
+ */
13
+ exports.down = function(knex) {
14
+
15
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ exports.up = function(knex) {
6
+
7
+ };
8
+
9
+ /**
10
+ * @param { import("knex").Knex } knex
11
+ * @returns { Promise<void> }
12
+ */
13
+ exports.down = function(knex) {
14
+
15
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ exports.up = function(knex) {
6
+
7
+ };
8
+
9
+ /**
10
+ * @param { import("knex").Knex } knex
11
+ * @returns { Promise<void> }
12
+ */
13
+ exports.down = function(knex) {
14
+
15
+ };