shelving 1.307.0 → 1.307.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.
@@ -75,5 +75,6 @@ function _isRetryableError(thrown) {
75
75
  /** Convert a strings array into the `TemplateStringsArray` shape `Bun.SQL` expects. */
76
76
  function _getTemplateStrings(strings) {
77
77
  const raw = [...strings];
78
- return Object.assign(raw, { raw });
78
+ // `raw` must not be enumerable: newer Bun versions refuse a template object with an enumerable `raw`.
79
+ return Object.defineProperty(raw, "raw", { value: raw });
79
80
  }
@@ -1,7 +1,7 @@
1
1
  import type { Data } from "../../util/data.js";
2
2
  import type { Identifier, Item, Items, ItemsSequence, OptionalItem, OptionalItemSequence } from "../../util/item.js";
3
3
  import type { Query } from "../../util/query.js";
4
- import type { Updates } from "../../util/update.js";
4
+ import { type Updates } from "../../util/update.js";
5
5
  import type { Collection } from "../collection/Collection.js";
6
6
  import { ThroughDBProvider } from "./ThroughDBProvider.js";
7
7
  /**
@@ -1,6 +1,7 @@
1
1
  import { ValueError } from "../../error/ValueError.js";
2
2
  import { PARTIAL } from "../../schema/DataSchema.js";
3
3
  import { getNamedMessage } from "../../util/error.js";
4
+ import { getUpdates } from "../../util/update.js";
4
5
  import { ThroughDBProvider } from "./ThroughDBProvider.js";
5
6
  /**
6
7
  * Database provider that validates data flowing to and from an asynchronous source provider.
@@ -113,8 +114,19 @@ function* _yieldValidItems(collection, items, caller) {
113
114
  throw new ValueError(`Invalid data for "${collection}"\n${messages.join("\n")}`, { received: items, caller });
114
115
  }
115
116
  function _validateUpdates(collection, updates, caller) {
117
+ // Only a plain top-level key is a prop of the data schema. An encoded key (`+=num`, `+[]tags`, `=a.b`) or a path (`a.b`)
118
+ // is not, so the schema would strip it: keep it as it is. `getUpdates()` throws if a sum is not a number.
119
+ const plain = {};
120
+ const encoded = {};
121
+ for (const [key, value] of Object.entries(updates)) {
122
+ if (_isPlainKey(key))
123
+ plain[key] = value;
124
+ else
125
+ encoded[key] = value;
126
+ }
127
+ getUpdates(encoded);
116
128
  try {
117
- return PARTIAL(collection).validate(updates);
129
+ return { ...PARTIAL(collection).validate(plain), ...encoded };
118
130
  }
119
131
  catch (thrown) {
120
132
  if (typeof thrown !== "string")
@@ -122,3 +134,7 @@ function _validateUpdates(collection, updates, caller) {
122
134
  throw new ValueError(`Invalid updates for "${collection}"\n${thrown}`, { received: updates, caller });
123
135
  }
124
136
  }
137
+ /** Is an `Updates` key a plain top-level prop, with no update prefix and no path? */
138
+ function _isPlainKey(key) {
139
+ return !key.includes(".") && !/^(?:=|\+=|-=|\+\[\]|-\[\])/.test(key);
140
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.307.0",
3
+ "version": "1.307.2",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,8 +48,14 @@
48
48
  }
49
49
  }
50
50
 
51
- /* Title chevron (the summary's flex class sets its size). Points down while closed. */
52
- .summary [data-slot="icon"] {
51
+ /* Title text: takes the spare width, so a title with a bar or a right-aligned value fills the row up to the chevron. */
52
+ .summary > span {
53
+ flex: 1 1 auto;
54
+ min-inline-size: 0;
55
+ }
56
+
57
+ /* Title chevron (the summary's flex class sets its size). Points down while closed. Only the direct child, so icons in the title keep their own colour. */
58
+ .summary > [data-slot="icon"] {
53
59
  color: var(--details-icon-color, var(--tint-50));
54
60
  transform: rotate(180deg);
55
61
  transition: var(--details-transition, all var(--duration-fast));
@@ -81,7 +87,7 @@
81
87
 
82
88
  /* States */
83
89
  &[open] {
84
- .summary [data-slot="icon"] {
90
+ .summary > [data-slot="icon"] {
85
91
  transform: rotate(0deg);
86
92
  }
87
93