@atscript/moost-db 0.1.143 → 0.1.144

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/index.cjs CHANGED
@@ -4107,21 +4107,29 @@ function seedActionFields(ctx, table) {
4107
4107
  * `dbActionOverlaySlot`, since 0.1.143): an out-of-scope id loads nothing —
4108
4108
  * exactly like a missing one (the same 404 on `'row'` actions, so the two
4109
4109
  * can't be told apart).
4110
+ *
4111
+ * The overlay resolves BEFORE the ids — i.e. before the request body is
4112
+ * read. Moost's HTTP adapter releases the event's DI scope when the request
4113
+ * stream ends, so a `transformFilter` / `transformOne` that instantiates a
4114
+ * `FOR_EVENT` dependency (an ARBAC user provider) fails with "scope isn't
4115
+ * registered" once the body has been consumed.
4110
4116
  */
4111
4117
  async function loadRow(ctx) {
4118
+ const overlay = await ctx.get(dbActionOverlaySlot);
4112
4119
  const id = await ctx.get(dbActionIdSlot);
4113
4120
  const table = asFetchTable(getActionTable(ctx));
4114
4121
  if (!table) throw noTableError(ctx);
4115
4122
  const fields = seedActionFields(ctx, table);
4116
4123
  for (const k of Object.keys(id)) fields.add(k);
4117
4124
  const row = await table.findOne({
4118
- filter: withOverlay(id, await ctx.get(dbActionOverlaySlot)),
4125
+ filter: withOverlay(id, overlay),
4119
4126
  controls: { $select: [...fields] }
4120
4127
  });
4121
4128
  if (row == null) throw new _moostjs_event_http.HttpError(404, "Row not found for action identifier");
4122
4129
  return row;
4123
4130
  }
4124
4131
  async function loadRows(ctx) {
4132
+ const overlay = await ctx.get(dbActionOverlaySlot);
4125
4133
  const ids = await ctx.get(dbActionIdsSlot);
4126
4134
  const table = asFetchTable(getActionTable(ctx));
4127
4135
  if (!table) throw noTableError(ctx);
@@ -4147,7 +4155,7 @@ async function loadRows(ctx) {
4147
4155
  }
4148
4156
  }
4149
4157
  const rows = await table.findMany({
4150
- filter: withOverlay({ $or: dedupedIds }, await ctx.get(dbActionOverlaySlot)),
4158
+ filter: withOverlay({ $or: dedupedIds }, overlay),
4151
4159
  controls: { $select: [...fields] }
4152
4160
  });
4153
4161
  const rowByKey = /* @__PURE__ */ new Map();
@@ -4184,6 +4192,7 @@ function buildGateInterceptor(opts) {
4184
4192
  const ctx = (0, _wooksjs_event_core.current)();
4185
4193
  await awaitActionPrepared(ctx);
4186
4194
  injectBoundTable(table);
4195
+ await ctx.get(dbActionOverlaySlot);
4187
4196
  if (level === "row") {
4188
4197
  const verdicts = disabled([await ctx.get(dbActionRowSlot)]);
4189
4198
  assertVerdictLength(action, verdicts, 1);
package/dist/index.mjs CHANGED
@@ -4106,21 +4106,29 @@ function seedActionFields(ctx, table) {
4106
4106
  * `dbActionOverlaySlot`, since 0.1.143): an out-of-scope id loads nothing —
4107
4107
  * exactly like a missing one (the same 404 on `'row'` actions, so the two
4108
4108
  * can't be told apart).
4109
+ *
4110
+ * The overlay resolves BEFORE the ids — i.e. before the request body is
4111
+ * read. Moost's HTTP adapter releases the event's DI scope when the request
4112
+ * stream ends, so a `transformFilter` / `transformOne` that instantiates a
4113
+ * `FOR_EVENT` dependency (an ARBAC user provider) fails with "scope isn't
4114
+ * registered" once the body has been consumed.
4109
4115
  */
4110
4116
  async function loadRow(ctx) {
4117
+ const overlay = await ctx.get(dbActionOverlaySlot);
4111
4118
  const id = await ctx.get(dbActionIdSlot);
4112
4119
  const table = asFetchTable(getActionTable(ctx));
4113
4120
  if (!table) throw noTableError(ctx);
4114
4121
  const fields = seedActionFields(ctx, table);
4115
4122
  for (const k of Object.keys(id)) fields.add(k);
4116
4123
  const row = await table.findOne({
4117
- filter: withOverlay(id, await ctx.get(dbActionOverlaySlot)),
4124
+ filter: withOverlay(id, overlay),
4118
4125
  controls: { $select: [...fields] }
4119
4126
  });
4120
4127
  if (row == null) throw new HttpError(404, "Row not found for action identifier");
4121
4128
  return row;
4122
4129
  }
4123
4130
  async function loadRows(ctx) {
4131
+ const overlay = await ctx.get(dbActionOverlaySlot);
4124
4132
  const ids = await ctx.get(dbActionIdsSlot);
4125
4133
  const table = asFetchTable(getActionTable(ctx));
4126
4134
  if (!table) throw noTableError(ctx);
@@ -4146,7 +4154,7 @@ async function loadRows(ctx) {
4146
4154
  }
4147
4155
  }
4148
4156
  const rows = await table.findMany({
4149
- filter: withOverlay({ $or: dedupedIds }, await ctx.get(dbActionOverlaySlot)),
4157
+ filter: withOverlay({ $or: dedupedIds }, overlay),
4150
4158
  controls: { $select: [...fields] }
4151
4159
  });
4152
4160
  const rowByKey = /* @__PURE__ */ new Map();
@@ -4183,6 +4191,7 @@ function buildGateInterceptor(opts) {
4183
4191
  const ctx = current();
4184
4192
  await awaitActionPrepared(ctx);
4185
4193
  injectBoundTable(table);
4194
+ await ctx.get(dbActionOverlaySlot);
4186
4195
  if (level === "row") {
4187
4196
  const verdicts = disabled([await ctx.get(dbActionRowSlot)]);
4188
4197
  assertVerdictLength(action, verdicts, 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/moost-db",
3
- "version": "0.1.143",
3
+ "version": "0.1.144",
4
4
  "description": "Generic database controller for Moost with Atscript.",
5
5
  "keywords": [
6
6
  "annotations",
@@ -44,27 +44,27 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@uniqu/url": "^0.1.11",
47
- "@atscript/db-memory": "^0.1.143"
47
+ "@atscript/db-memory": "^0.1.144"
48
48
  },
49
49
  "devDependencies": {
50
- "@atscript/core": "^0.1.95",
51
- "@atscript/typescript": "^0.1.95",
52
- "@moostjs/event-http": "^0.6.37",
50
+ "@atscript/core": "^0.1.96",
51
+ "@atscript/typescript": "^0.1.96",
52
+ "@moostjs/event-http": "^0.6.40",
53
53
  "@uniqu/core": "^0.1.11",
54
- "@wooksjs/event-core": "^0.7.23",
55
- "@wooksjs/event-http": "^0.7.23",
56
- "@wooksjs/http-body": "^0.7.23",
57
- "moost": "^0.6.37",
58
- "unplugin-atscript": "^0.1.95"
54
+ "@wooksjs/event-core": "^0.7.24",
55
+ "@wooksjs/event-http": "^0.7.24",
56
+ "@wooksjs/http-body": "^0.7.24",
57
+ "moost": "^0.6.40",
58
+ "unplugin-atscript": "^0.1.96"
59
59
  },
60
60
  "peerDependencies": {
61
- "@atscript/typescript": "^0.1.95",
62
- "@moostjs/event-http": "^0.6.37",
61
+ "@atscript/typescript": "^0.1.96",
62
+ "@moostjs/event-http": "^0.6.40",
63
63
  "@uniqu/core": "^0.1.11",
64
- "@wooksjs/event-core": "^0.7.23",
65
- "@wooksjs/http-body": "^0.7.23",
66
- "moost": "^0.6.37",
67
- "@atscript/db": "^0.1.143"
64
+ "@wooksjs/event-core": "^0.7.24",
65
+ "@wooksjs/http-body": "^0.7.24",
66
+ "moost": "^0.6.40",
67
+ "@atscript/db": "^0.1.144"
68
68
  },
69
69
  "scripts": {
70
70
  "postinstall": "asc -f dts",