@subsquid/openreader 0.1.0 → 0.3.2

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/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@subsquid/openreader",
3
- "version": "0.1.0",
4
- "description": "GraphQL server for Hydra",
3
+ "version": "0.3.2",
4
+ "description": "GraphQL server for squid framework",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "opencrud"
8
8
  ],
9
- "license": "MIT",
10
- "repository": "git@github.com:subsquid/openreader.git",
9
+ "license": "GPL-3.0-or-later",
10
+ "repository": "git@github.com:subsquid/squid.git",
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
14
  "bin": {
15
- "openreader": "./dist/main.js"
15
+ "openreader": "./bin/main.js"
16
16
  },
17
17
  "files": [
18
18
  "dist",
@@ -22,23 +22,28 @@
22
22
  "@graphql-tools/merge": "^8",
23
23
  "@graphql-tools/utils": "^8",
24
24
  "@subsquid/graphiql-console": "^0.2.0",
25
- "apollo-server-core": "^3.3.0",
26
- "apollo-server-express": "^3.3.0",
27
- "express": "^4.17.1",
28
- "graphql": "^15.5.2",
25
+ "@subsquid/util": "^0.0.2",
26
+ "apollo-server-core": "^3.5.0",
27
+ "apollo-server-express": "^3.5.0",
28
+ "express": "^4.17.2",
29
+ "graphql": "^15.8.0",
29
30
  "graphql-parse-resolve-info": "^4.12.0",
30
- "inflected": "^2.1.0",
31
31
  "pg": "^8.7.1"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/inflected": "^1.1.29",
34
+ "@types/express": "^4.17.13",
35
35
  "@types/mocha": "^9.0.0",
36
- "@types/node-fetch": "^2.5.12",
37
- "@types/pg": "^8.6.1",
36
+ "@types/node": "^16.11.17",
37
+ "@types/pg": "^8.6.3",
38
38
  "dotenv": "^10.0.0",
39
- "expect": "^27.2.1",
40
- "mocha": "^9.1.1",
41
- "node-fetch": "^2.6.3",
42
- "typescript": "^4.4.2"
43
- }
44
- }
39
+ "expect": "^27.4.6",
40
+ "gql-test-client": "^0.0.0",
41
+ "mocha": "^9.1.3",
42
+ "typescript": "~4.5.4"
43
+ },
44
+ "scripts": {
45
+ "build": "rm -rf dist && tsc",
46
+ "test": "make up && sleep 1 && make test && make down || (make down && exit 1)"
47
+ },
48
+ "readme": "# OpenReader\n\nGraphQL server for squid framework. Given [data schema](https://docs.subsquid.io/schema-spec) \nand compatible Postgres database it serves \"read part\" of [OpenCRUD spec](https://www.opencrud.org).\n\n## Usage\n\n```bash\nopenreader schema.graphql\n```\n\nDatabase connection and server port are configured via environment variables:\n\n```\nDB_NAME\nDB_USER\nDB_PASS\nDB_HOST\nDB_PORT\nGRAPHQL_SERVER_PORT\n```\n"
49
+ }
@@ -1,10 +0,0 @@
1
- import type { Pool, ClientBase } from "pg";
2
- export declare class Transaction {
3
- private pool;
4
- private client;
5
- private closed;
6
- constructor(pool: Pool);
7
- get(): Promise<ClientBase>;
8
- private startTransaction;
9
- close(): Promise<void>;
10
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Transaction = void 0;
4
- class Transaction {
5
- constructor(pool) {
6
- this.pool = pool;
7
- this.closed = false;
8
- }
9
- get() {
10
- if (this.closed) {
11
- throw new Error('Too late to request transaction');
12
- }
13
- if (this.client) {
14
- return this.client;
15
- }
16
- else {
17
- return this.client = this.startTransaction();
18
- }
19
- }
20
- async startTransaction() {
21
- let client = await this.pool.connect();
22
- try {
23
- await client.query('START TRANSACTION ISOLATION LEVEL SERIALIZABLE READ ONLY');
24
- return client;
25
- }
26
- catch (e) {
27
- client.release();
28
- throw e;
29
- }
30
- }
31
- close() {
32
- this.closed = true;
33
- return this.client?.then(async (client) => {
34
- try {
35
- await client.query('COMMIT');
36
- }
37
- catch (e) {
38
- // ignore
39
- }
40
- finally {
41
- client.release();
42
- }
43
- }) || Promise.resolve();
44
- }
45
- }
46
- exports.Transaction = Transaction;
47
- //# sourceMappingURL=transaction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":";;;AAGA,MAAa,WAAW;IAIpB,YAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;QAFtB,WAAM,GAAG,KAAK,CAAA;IAEW,CAAC;IAElC,GAAG;QACC,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;SACrD;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,OAAO,IAAI,CAAC,MAAM,CAAA;SACrB;aAAM;YACH,OAAO,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAA;SAC/C;IACL,CAAC;IAEO,KAAK,CAAC,gBAAgB;QAC1B,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;QACtC,IAAI;YACA,MAAM,MAAM,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAA;YAC9E,OAAO,MAAM,CAAA;SAChB;QAAC,OAAM,CAAM,EAAE;YACZ,MAAM,CAAC,OAAO,EAAE,CAAA;YAChB,MAAM,CAAC,CAAA;SACV;IACL,CAAC;IAED,KAAK;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;YACpC,IAAI;gBACA,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;aAC/B;YAAC,OAAM,CAAM,EAAE;gBACZ,SAAS;aACZ;oBAAS;gBACN,MAAM,CAAC,OAAO,EAAE,CAAA;aACnB;QACL,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAA;IAC3B,CAAC;CACJ;AAxCD,kCAwCC"}