@dosgato/api 0.0.17 → 0.0.18

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.
@@ -1,9 +1,12 @@
1
+ import db from 'mysql2-async/db';
2
+ import { stringify } from 'txstate-utils';
3
+ // TODO: do not log mutations that failed validation
1
4
  export async function logMutation(queryTime, operationName, query, auth, variables) {
2
- if (query.includes('mutation')) {
3
- // TODO: we have the login and userId is the internal ID for the user. How can we get that internal ID here,
4
- // or does it need to be in the auth object?
5
- // await db.insert('INSERT INTO mutationlog (userId, mutation, query, variables) VALUES (?,?,?,?)',
6
- // [auth.login, query, operationName, JSON.stringify(variables)])
5
+ if (!variables.validateOnly && query.trimStart().startsWith('mutation')) {
6
+ await db.insert(`
7
+ INSERT INTO mutationlog (userId, query, mutation, variables)
8
+ SELECT id, ?, ?, ? FROM users WHERE login=?
9
+ `, [query, operationName, stringify({ ...variables, data: undefined }), auth.sub]);
7
10
  }
8
11
  }
9
12
  //# sourceMappingURL=mutationlogger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutationlogger.js","sourceRoot":"","sources":["../../src/util/mutationlogger.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,WAAW,CAAE,SAAiB,EAAE,aAAqB,EAAE,KAAa,EAAE,IAAS,EAAE,SAAc;IACnH,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QAC9B,4GAA4G;QAC5G,4CAA4C;QAC5C,mGAAmG;QACnG,mEAAmE;KACpE;AACH,CAAC"}
1
+ {"version":3,"file":"mutationlogger.js","sourceRoot":"","sources":["../../src/util/mutationlogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAE,SAAiB,EAAE,aAAqB,EAAE,KAAa,EAAE,IAAS,EAAE,SAAc;IACnH,IAAI,CAAC,SAAS,CAAC,YAAY,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QACvE,MAAM,EAAE,CAAC,MAAM,CAAC;;;KAGf,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;KACnF;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/api",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "A CMS designed for large institutions with thousands of editors and hundreds of subsites.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -12,6 +12,7 @@
12
12
  "@fastify/multipart": "^7.2.0",
13
13
  "@types/sharp": "^0.30.5",
14
14
  "@txstate-mws/graphql-server": "2.0.1",
15
+ "cron": "^2.1.0",
15
16
  "dataloader-factory": "^4.4.3",
16
17
  "fast-json-patch": "^3.1.0",
17
18
  "file-type": "^18.0.0",
@@ -25,6 +26,7 @@
25
26
  "type-graphql": "^1.1.1"
26
27
  },
27
28
  "devDependencies": {
29
+ "@types/cron": "^2.0.0",
28
30
  "@types/luxon": "^3.0.1",
29
31
  "@types/mime-types": "^2.1.1",
30
32
  "@types/node": "^18.7.14",