@snowtop/ent 0.1.0-alpha135 → 0.1.0-alpha137

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.
@@ -277,9 +277,7 @@ async function executeOperations(executor, context, trackOps) {
277
277
  if (executor.postFetch) {
278
278
  await executor.postFetch(client, context);
279
279
  }
280
- if (executor.executeObservers) {
281
- await executor.executeObservers();
282
- }
280
+ client.release();
283
281
  }
284
282
  catch (e) {
285
283
  if (!isSyncClient(client)) {
@@ -287,11 +285,15 @@ async function executeOperations(executor, context, trackOps) {
287
285
  (0, ent_1.logQuery)("ROLLBACK", []);
288
286
  await client.query("ROLLBACK");
289
287
  }
288
+ client.release(e);
290
289
  (0, logger_1.log)("error", e);
291
290
  throw e;
292
291
  }
293
- finally {
294
- client.release();
292
+ if (executor.executeObservers) {
293
+ try {
294
+ await executor.executeObservers();
295
+ }
296
+ catch (e) { }
295
297
  }
296
298
  return operations;
297
299
  }
package/core/db.d.ts CHANGED
@@ -22,6 +22,7 @@ interface clientConfigArgs {
22
22
  connectionString?: string;
23
23
  dbFile?: string;
24
24
  db?: Database | DBDict;
25
+ cfg?: PoolConfig;
25
26
  }
26
27
  export default class DB {
27
28
  db: DatabaseInfo;
package/core/db.js CHANGED
@@ -46,9 +46,7 @@ function parseConnectionString(str, args) {
46
46
  dialect: Dialect.SQLite,
47
47
  config: {
48
48
  connectionString: str,
49
- // TODO would like to do this for other args e.g. max being set but would have to update tests
50
- // e.g. src/core/config.test.ts which tests this
51
- // ...args?.db,
49
+ ...args?.cfg,
52
50
  },
53
51
  filePath,
54
52
  };
@@ -56,10 +54,8 @@ function parseConnectionString(str, args) {
56
54
  return {
57
55
  dialect: Dialect.Postgres,
58
56
  config: {
57
+ ...args?.cfg,
59
58
  connectionString: str,
60
- // TODO would like to do this for other args e.g. max being set but would have to update tests
61
- // e.g. src/core/config.test.ts which tests this
62
- // ...args?.db,
63
59
  },
64
60
  };
65
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.1.0-alpha135",
3
+ "version": "0.1.0-alpha137",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -149,17 +149,24 @@ async function captureDynamic(filePath, gqlCapture) {
149
149
  return;
150
150
  }
151
151
  return await new Promise((resolve, reject) => {
152
- // we seem to get tsconfig-paths by default because child process but not 100% sure...
153
- const args = ["--transpileOnly"];
152
+ let cmd = "";
153
+ const args = [];
154
154
  const env = {
155
155
  ...process.env,
156
156
  };
157
- if (!process.env.DISABLE_SWC) {
157
+ // really only exists if there's a bug with swc or something. we should almost always be using swc
158
+ if (process.env.DISABLE_SWC) {
159
+ cmd = "ts-node";
160
+ args.push("--transpileOnly");
161
+ }
162
+ else {
163
+ cmd = "node";
164
+ // we seem to get tsconfig-paths by default because child process but not 100% sure...
158
165
  args.push("-r", "@swc-node/register");
159
166
  env.SWCRC = "true";
160
167
  }
161
168
  args.push(filePath);
162
- const r = (0, child_process_1.spawn)("ts-node", args, {
169
+ const r = (0, child_process_1.spawn)(cmd, args, {
163
170
  env,
164
171
  });
165
172
  const datas = [];
@@ -173,11 +173,14 @@ exports.ChangelogSchema = (0, builder_1.getBuilderSchemaFromFields)({
173
173
  }, Changelog);
174
174
  exports.MessageSchema = (0, builder_1.getBuilderSchemaFromFields)({
175
175
  // TODO both id fields
176
- sender: (0, field_1.StringType)(),
176
+ sender: (0, field_1.StringType)({
177
+ index: true,
178
+ }),
177
179
  recipient: (0, field_1.StringType)(),
178
180
  message: (0, field_1.StringType)(),
179
181
  transient: (0, field_1.BooleanType)({ nullable: true }),
180
182
  expiresAt: (0, field_1.TimestampType)({ nullable: true }),
183
+ delivered: (0, field_1.BooleanType)({ defaultValueOnCreate: () => false }),
181
184
  }, builder_1.Message);
182
185
  jest.spyOn(action, "saveBuilder").mockImplementation(saveBuilder);
183
186
  jest.spyOn(action, "saveBuilderX").mockImplementation(saveBuilderX);
@@ -233,8 +236,12 @@ class MessageAction extends builder_1.SimpleAction {
233
236
  changeset: (builder, _input) => {
234
237
  let sender = builder.fields.get("sender");
235
238
  let recipient = builder.fields.get("recipient");
236
- builder.orchestrator.addInboundEdge(sender, "senderToMessage", "user");
237
- builder.orchestrator.addInboundEdge(recipient, "recipientToMessage", "user");
239
+ if (sender) {
240
+ builder.orchestrator.addInboundEdge(sender, "senderToMessage", "user");
241
+ }
242
+ if (recipient) {
243
+ builder.orchestrator.addInboundEdge(recipient, "recipientToMessage", "user");
244
+ }
238
245
  },
239
246
  },
240
247
  ];
@@ -401,6 +401,10 @@ class TempDB {
401
401
  }
402
402
  db_1.default.initDB({
403
403
  connectionString: connStr,
404
+ cfg: {
405
+ max: 100,
406
+ idleTimeoutMillis: 100,
407
+ },
404
408
  });
405
409
  }
406
410
  else {