@getstrata/core 3.1.4 → 3.1.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @getstrata/core changelog
2
2
 
3
+ ## 3.1.6
4
+
5
+ fix: drain admitted request bookkeeping during shutdown
6
+
7
+ ## 3.1.5
8
+
9
+ Fix published class-model type exports so inferred fields and strict model/repository contracts remain intact in installed applications.
10
+
3
11
  ## 3.1.4
4
12
 
5
13
  - Synchronize package versions and dependency pins at 3.1.4 for the corrected starter release validation. No additional runtime changes in this package.
@@ -5,5 +5,6 @@ declare function ownExecutionContext(envelope: ExecutionEnvelope, applicationId:
5
5
  context: ExecutionContext;
6
6
  dispose: () => void;
7
7
  check: () => void;
8
+ admit(drainSignal: AbortSignal): void;
8
9
  };
9
10
  export { normalizeExecutionEnvelope, ownExecutionContext };
@@ -178,8 +178,10 @@ function ownExecutionContext(envelope, applicationId, appSignal) {
178
178
  const subscribe = (signal) => {
179
179
  const listener = () => cancel(signal);
180
180
  addListener.call(signal, "abort", listener);
181
- subscriptions.push({ signal, listener });
181
+ const subscription = { signal, listener };
182
+ subscriptions.push(subscription);
182
183
  cancel(signal);
184
+ return subscription;
183
185
  };
184
186
  const dispose = () => {
185
187
  disposed = true;
@@ -191,7 +193,7 @@ function ownExecutionContext(envelope, applicationId, appSignal) {
191
193
  try {
192
194
  if (envelope.signal !== undefined)
193
195
  subscribe(envelope.signal);
194
- subscribe(appSignal);
196
+ const admission = subscribe(appSignal);
195
197
  const deadline = envelope.deadlineAtMs;
196
198
  const refreshDeadline = () => {
197
199
  if (disposed || controller.signal.aborted || deadline === undefined)
@@ -222,7 +224,18 @@ function ownExecutionContext(envelope, applicationId, appSignal) {
222
224
  executionId,
223
225
  signal: controller.signal
224
226
  });
225
- return { context, dispose, check };
227
+ return {
228
+ context,
229
+ dispose,
230
+ check,
231
+ admit(drainSignal) {
232
+ check();
233
+ subscribe(drainSignal);
234
+ check();
235
+ removeListener.call(admission.signal, "abort", admission.listener);
236
+ subscriptions.splice(subscriptions.indexOf(admission), 1);
237
+ }
238
+ };
226
239
  } catch (error) {
227
240
  dispose();
228
241
  throw error;
@@ -187,8 +187,10 @@ function ownExecutionContext(envelope, applicationId, appSignal) {
187
187
  const subscribe = (signal) => {
188
188
  const listener = () => cancel(signal);
189
189
  addListener.call(signal, "abort", listener);
190
- subscriptions.push({ signal, listener });
190
+ const subscription = { signal, listener };
191
+ subscriptions.push(subscription);
191
192
  cancel(signal);
193
+ return subscription;
192
194
  };
193
195
  const dispose = () => {
194
196
  disposed = true;
@@ -200,7 +202,7 @@ function ownExecutionContext(envelope, applicationId, appSignal) {
200
202
  try {
201
203
  if (envelope.signal !== undefined)
202
204
  subscribe(envelope.signal);
203
- subscribe(appSignal);
205
+ const admission = subscribe(appSignal);
204
206
  const deadline = envelope.deadlineAtMs;
205
207
  const refreshDeadline = () => {
206
208
  if (disposed || controller.signal.aborted || deadline === undefined)
@@ -231,7 +233,18 @@ function ownExecutionContext(envelope, applicationId, appSignal) {
231
233
  executionId,
232
234
  signal: controller.signal
233
235
  });
234
- return { context, dispose, check };
236
+ return {
237
+ context,
238
+ dispose,
239
+ check,
240
+ admit(drainSignal) {
241
+ check();
242
+ subscribe(drainSignal);
243
+ check();
244
+ removeListener.call(admission.signal, "abort", admission.listener);
245
+ subscriptions.splice(subscriptions.indexOf(admission), 1);
246
+ }
247
+ };
235
248
  } catch (error) {
236
249
  dispose();
237
250
  throw error;
@@ -1319,7 +1332,11 @@ class OwnedApplication {
1319
1332
  finalize: () => this.taskStorage.run(undefined, () => this.journal.finalizeGroup(group, cleanupContext))
1320
1333
  });
1321
1334
  };
1322
- const callbacks = initialization.ok ? await settleExecutionTasks(work, owner.check, (body, spawn, resources, dispatch) => {
1335
+ const callbacks = initialization.ok ? await settleExecutionTasks((scope) => {
1336
+ if (scope.context.kind === "request")
1337
+ owner.admit(this.cleanupCancellation.signal);
1338
+ return work(scope);
1339
+ }, owner.check, (body, spawn, resources, dispatch) => {
1323
1340
  const lease = { active: true };
1324
1341
  const frame = Object.freeze({
1325
1342
  application: this,
@@ -26,7 +26,6 @@ export type { PersistenceErrorCode, PersistenceErrorOptions, PersistenceResult,
26
26
  export { mapDatabaseError, PersistenceError, RecordNotFoundError, withDatabaseErrorHandling, } from "@getstrata/core/database/errors";
27
27
  export type { FactoryBehavior, FactoryConstruction, FactoryDefinition, FactoryMakeResult, FactoryParent, FactoryPersist, StatelessFactoryConstruction, } from "@getstrata/core/database/factory";
28
28
  export { defineFactory, Factory } from "@getstrata/core/database/factory";
29
- export type { AnyModelClass, AuthoredModelClass, InferModelFields, ModelClassOptions, ModelField, ModelFields, } from "@getstrata/core/database/model";
30
29
  export { DATABASE_SESSION_TOKEN } from "@getstrata/core/database/tokens";
31
30
  export { BadRequestError, ConflictError, ForbiddenError, HttpError, InternalServerError, InvalidCredentialsError, isHttpErrorLike, NotFoundError, PayloadTooLargeError, PreconditionFailedError, toHttpError, UnauthorizedError, UnprocessableEntityError, ValidationError, } from "@getstrata/core/errors/http";
32
31
  export { type ParsedUpload, parseMultipartUpload, parseMultipartUploadStream, sanitizeUploadFileName, UploadedFile, validateUploadFile, } from "@getstrata/core/http/parseMultipartUpload";
@@ -81,6 +80,7 @@ export { freshDatabase, getMigrationStatus, loadMigrationsFromDirectory, migrate
81
80
  export type { Migration, MigrationDatabase, MigrationStatus, } from "../core/database/migrations/types.ts";
82
81
  export type { CastType, ModelAttributes, ModelProjection, } from "../core/database/model.ts";
83
82
  export { applyCasts, dehydrateValue, filterMassAssignable, hydrateValue, } from "../core/database/modelAttributes.ts";
83
+ export type { AnyModelClass, AuthoredModelClass, InferModelFields, ModelClassOptions, ModelField, ModelFields, } from "../core/database/modelAuthoring";
84
84
  export type { MysqlConnection, MysqlExecutable, MysqlPool, } from "../core/database/mysqlConnection.ts";
85
85
  export { createMysqlConnection, createMysqlConnectionFromPool, createMysqlPool, } from "../core/database/mysqlConnection.ts";
86
86
  export { buildAdvancedWhereClause, buildCountQuery, buildDeleteByIdQuery, buildGroupedCountQuery, buildInsertQuery, buildJoinClause, buildOrderByClause, buildProjectionQuery, buildQueryWhereClause, buildRestoreByIdQuery, buildSelectQuery, buildSoftDeleteByIdQuery, buildUpdateQuery, buildWhereClause, parseQualifiedColumn, qualifyColumn, quoteIdentifier, resolveQualifiedColumn, resolveSoftDeleteColumn, } from "../core/database/query.ts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/core",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "description": "Laravel-inspired framework for Bun and TypeScript: models, authentication, queues, mail, and storage.",
5
5
  "type": "module",
6
6
  "license": "MIT",