@jarenjs/linq 0.72.0 → 0.72.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.
package/docs/DB-CLIENT.md CHANGED
@@ -826,10 +826,10 @@ never builds one; the migration between two of them is
826
826
 
827
827
  ## 7. Cost
828
828
 
829
- `@jarenjs/linq/db` builds to **<!--fact:bundle.db-->625,827<!--/fact--> bytes** as a minified,
829
+ `@jarenjs/linq/db` builds to **<!--fact:bundle.db-->627,770<!--/fact--> bytes** as a minified,
830
830
  tree-shaken ESM bundle — the figure `scripts/check-tree-shaking.js`
831
831
  measures and `npm run test:tree-shaking` reports, published rounded
832
- (<!--fact:bundle.db.kb-->626<!--/fact--> kB) beside the other nine subpath prices in
832
+ (<!--fact:bundle.db.kb-->628<!--/fact--> kB) beside the other nine subpath prices in
833
833
  [docs/CONSUMING.md](../../../docs/CONSUMING.md).
834
834
 
835
835
  It is by far the largest of the ten, and the reason is §1.1's edge rather
@@ -37,7 +37,7 @@ is the index of those guides, and it is how a reader reaches any of them.
37
37
  | Document | Lines | What it writes, and when to open it |
38
38
  |---|---:|---|
39
39
  | [LINQ-FORMAT.md](LINQ-FORMAT.md) | 948 | this file, the binder and the family's **normative reference**: what a pen is, the rules all of them keep, the shared `JL01xx` table, and the cross-pen views derived from the guides it indexes. **Read it when** you want a rule that is true of every pen, an index of the documents, or one place to look up a method without knowing which pen owns it |
40
- | [QUERY-PEN.md](QUERY-PEN.md) | 1,724 | the chain, `.` — query documents (`jaren-query`) and the provider seam. **Read it when** you are querying data, or implementing a provider that answers a query document |
40
+ | [QUERY-PEN.md](QUERY-PEN.md) | 1,725 | the chain, `.` — query documents (`jaren-query`) and the provider seam. **Read it when** you are querying data, or implementing a provider that answers a query document |
41
41
  | [SCHEMA-PEN.md](SCHEMA-PEN.md) | 1,205 | `./schema` — JSON Schema 2020-12: the structural keywords, the constraints and the annotations, each with a method of its own, plus `$query`, `$defs`/`$ref` recursion and the normalizer's per-field predicates. **Read it when** you are describing the shape of data — for validation, for a form, or as the base of an entity |
42
42
  | [MODEL-PEN.md](MODEL-PEN.md) | 1,092 | `./model` — the `x-entity` vocabulary on JSON Schema, and the `$model` 0.1 document `openStore` accepts unchanged. **Read it when** you are declaring a store's entities, their keys and their relations |
43
43
  | [JSLT-PEN.md](JSLT-PEN.md) | 955 | `./jslt` — `$jslt` 0.1 stylesheets: the envelope and its rules, whose bodies are captured over the matched value. **Read it when** you are transforming one document into another |
@@ -205,7 +205,7 @@ and the bundle is the byte count the tree-shaking probe builds.
205
205
  | Document | Subpath | Lines | Mapping rows | Worked examples | Refusals | Bundle |
206
206
  |---|---|---:|---:|---:|---:|---:|
207
207
  | [LINQ-FORMAT.md](LINQ-FORMAT.md) | — | 948 | — | — | — | — |
208
- | [QUERY-PEN.md](QUERY-PEN.md) | `.` | 1,724 | 34 | 8 | 15 | 174,188 B |
208
+ | [QUERY-PEN.md](QUERY-PEN.md) | `.` | 1,725 | 34 | 8 | 15 | 174,188 B |
209
209
  | [SCHEMA-PEN.md](SCHEMA-PEN.md) | `./schema` | 1,205 | 82 | 10 | 4 | 36,717 B |
210
210
  | [MODEL-PEN.md](MODEL-PEN.md) | `./model` | 1,092 | 28 | 6 | 3 | 45,143 B |
211
211
  | [JSLT-PEN.md](JSLT-PEN.md) | `./jslt` | 955 | 17 | 8 | 3 | 19,856 B |
@@ -219,8 +219,8 @@ and the bundle is the byte count the tree-shaking probe builds.
219
219
  | [JTLT-PEN.md](JTLT-PEN.md) | `./jtlt` | 83 | 13 | 1 | 2 | 16,725 B |
220
220
  | [PROJECT-PEN.md](PROJECT-PEN.md) | `./project` | 75 | 9 | 1 | 1 | 15,132 B |
221
221
  | [CHARTS-PEN.md](CHARTS-PEN.md) | `./charts` | 94 | 21 | 1 | 1 | 17,014 B |
222
- | [DB-CLIENT.md](DB-CLIENT.md) | `./db` | 893 | 41 | 4 | 2 | 625,827 B |
223
- | **16 documents** | | **12,390** | **371** | **73** | | |
222
+ | [DB-CLIENT.md](DB-CLIENT.md) | `./db` | 893 | 41 | 4 | 2 | 627,770 B |
223
+ | **16 documents** | | **12,391** | **371** | **73** | | |
224
224
  <!--/fact-->
225
225
 
226
226
  A pen whose mapping rows are far below its worked examples is a pen
@@ -276,7 +276,7 @@ it and each document publishes it. The rounded column is what
276
276
  | `@jarenjs/linq/jtlt` | [JTLT-PEN.md](JTLT-PEN.md) | 16,725 B | 17 kB |
277
277
  | `@jarenjs/linq/project` | [PROJECT-PEN.md](PROJECT-PEN.md) | 15,132 B | 15 kB |
278
278
  | `@jarenjs/linq/charts` | [CHARTS-PEN.md](CHARTS-PEN.md) | 17,014 B | 17 kB |
279
- | `@jarenjs/linq/db` | [DB-CLIENT.md](DB-CLIENT.md) | 625,827 B | 626 kB |
279
+ | `@jarenjs/linq/db` | [DB-CLIENT.md](DB-CLIENT.md) | 627,770 B | 628 kB |
280
280
  <!--/fact-->
281
281
 
282
282
  Read these as prices, not as scores. `./db` is the largest by an order of
package/docs/QUERY-PEN.md CHANGED
@@ -728,7 +728,8 @@ const rows = await fromAsync(fed.source('orders'))
728
728
  ```
729
729
 
730
730
  `fed.source(name)` is an ordinary provider source (§8) with the root
731
- `$.<name>[*]`, and all of a federation's sources share one scope which
731
+ `$.<name>[*]` (a quoted member selector for names containing punctuation,
732
+ spaces or other characters), and all of a federation's sources share one scope — which
732
733
  is exactly what admits the join. The federation is what executes it:
733
734
 
734
735
  1. each side's own document — the filters and the projection the chain
@@ -1705,7 +1706,7 @@ making:
1705
1706
  `docs/CONSUMING.md` states the rounded price of all ten subpaths in one
1706
1707
  table, each figure held equal to the same measurements. Two of its rows
1707
1708
  are the ones to read together: the chain at <!--fact:bundle.chain.kb-->174<!--/fact--> kB and
1708
- `./db` at <!--fact:bundle.db.kb-->626<!--/fact--> kB.
1709
+ `./db` at <!--fact:bundle.db.kb-->628<!--/fact--> kB.
1709
1710
  The client costs what the store costs, by construction, and the chain
1710
1711
  costs what running a query costs.
1711
1712
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jarenjs/linq",
3
3
  "private": false,
4
- "version": "0.72.0",
4
+ "version": "0.72.2",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "types": "./types/index.d.ts",
@@ -104,13 +104,13 @@
104
104
  "prepack": "npm run build:types"
105
105
  },
106
106
  "dependencies": {
107
- "@jarenjs/core": "^0.72.0",
108
- "@jarenjs/json": "^0.72.0"
107
+ "@jarenjs/core": "^0.72.2",
108
+ "@jarenjs/json": "^0.72.2"
109
109
  },
110
110
  "peerDependencies": {
111
- "@jarenjs/db": "^0.72.0",
112
- "@jarenjs/formats": "^0.72.0",
113
- "@jarenjs/validate": "^0.72.0"
111
+ "@jarenjs/db": "^0.72.2",
112
+ "@jarenjs/formats": "^0.72.2",
113
+ "@jarenjs/validate": "^0.72.2"
114
114
  },
115
115
  "peerDependenciesMeta": {
116
116
  "@jarenjs/db": {
package/src/expression.js CHANGED
@@ -98,7 +98,7 @@ function bracketName(name) {
98
98
  * @param {string} name
99
99
  * @returns {string}
100
100
  */
101
- function memberSegment(name) {
101
+ export function memberSegment(name) {
102
102
  return SHORTHAND_RE.test(name) ? `.${name}` : bracketName(name);
103
103
  }
104
104
 
package/src/federate.js CHANGED
@@ -45,6 +45,7 @@
45
45
 
46
46
  import { LinqBuildError, LinqRuntimeError } from './errors.js';
47
47
  import { compileDocument, isProviderSource, providerRoot } from './provider.js';
48
+ import { memberSegment } from './expression.js';
48
49
 
49
50
  /** The strategies this boundary knows. One, for now, and it says so. */
50
51
  const STRATEGIES = new Set(['hash']);
@@ -123,18 +124,6 @@ function byteSize(row) {
123
124
  return encoder.encode(text).length;
124
125
  }
125
126
 
126
- /**
127
- * The root NAME a root expression carries: `'$.Post[*]'` → `'Post'`.
128
- * A federated source's root is always this shape, because the
129
- * federation names it.
130
- * @param {string} root
131
- * @returns {string}
132
- */
133
- function rootName(root) {
134
- const match = /^\$\.([^.[\]]+)\[\*\]$/.exec(root);
135
- return match === null ? '' : match[1];
136
- }
137
-
138
127
  /**
139
128
  * The FLWOR a terminal wrapped, and how to put a rewritten one back.
140
129
  *
@@ -412,7 +401,7 @@ export function federate(spec) {
412
401
  // the federated root, which is what the chain binds and what the
413
402
  // resident document ranges over; the source's OWN root is what its
414
403
  // child document uses, and `childDocument` rewrites between them
415
- const root = `$.${name}[*]`;
404
+ const root = `$${memberSegment(name)}[*]`;
416
405
  members.set(root, { name, root, provider, estimatedRows });
417
406
  }
418
407
 
@@ -448,8 +437,8 @@ export function federate(spec) {
448
437
  }, open);
449
438
 
450
439
  const input = {
451
- [rootName(plan.build.root)]: built.rows,
452
- [rootName(plan.probe.root)]: probed.rows,
440
+ [plan.build.member.name]: built.rows,
441
+ [plan.probe.member.name]: probed.rows,
453
442
  };
454
443
  const compiled = compileDocument(plan.resident,
455
444
  { ...options, externals: options?.externalNames ?? [] });
@@ -462,7 +451,7 @@ export function federate(spec) {
462
451
  catch (error) {
463
452
  // the call's own failure is the one the caller gets: a cursor
464
453
  // that also fails to close must not replace the budget's refusal
465
- await closeAll(open);
454
+ await closeAll(open).catch(() => {});
466
455
  throw error;
467
456
  }
468
457
  };
@@ -513,7 +502,7 @@ export function federate(spec) {
513
502
  const handleFor = (name) => {
514
503
  let handle = handles.get(name);
515
504
  if (handle === undefined) {
516
- const root = `$.${name}[*]`;
505
+ const root = `$${memberSegment(name)}[*]`;
517
506
  if (!members.has(root)) {
518
507
  throw new LinqBuildError('JL0005',
519
508
  `'${name}' is not one of this federation's sources (${names.join(', ')})`);
package/types/charts.d.ts CHANGED
@@ -75,7 +75,7 @@ export interface ValueSeries {
75
75
  /**
76
76
  * one boxplot category: raw samples in `values`, or a precomputed five-number summary
77
77
  */
78
- export type Box = unknown & { label: string; values?: Array<number | null>; min?: number; q1?: number; med?: number; q3?: number; max?: number; outliers?: Array<number>; [key: string]: unknown; };
78
+ export type Box = ({ values: unknown; [key: string]: unknown; } | Array<unknown> | string | number | boolean | null | { min: unknown; q1: unknown; med: unknown; q3: unknown; max: unknown; [key: string]: unknown; }) & { label: string; values?: Array<number | null>; min?: number; q1?: number; med?: number; q3?: number; max?: number; outliers?: Array<number>; [key: string]: unknown; };
79
79
 
80
80
  export interface TreemapItem {
81
81
  label: string;
@@ -120,6 +120,16 @@ export interface SankeyLink {
120
120
  }
121
121
 
122
122
 
123
+ /**
124
+ * Schema constraints this type cannot express: minimum=-180, maximum=180
125
+ */
126
+ export type MapPointAtItem1 = number;
127
+
128
+ /**
129
+ * Schema constraints this type cannot express: minimum=-90, maximum=90
130
+ */
131
+ export type MapPointAtItem2 = number;
132
+
123
133
  /**
124
134
  * a place marker: the convenience path for a caller holding positions rather than GeoJSON
125
135
  */
@@ -128,17 +138,37 @@ export interface MapPoint {
128
138
  * a GeoJSON position: [longitude, latitude]
129
139
  * Schema constraints this type cannot express: minItems=2, maxItems=3
130
140
  */
131
- at: [number, number, ...Array<number>];
141
+ at: [MapPointAtItem1, MapPointAtItem2, ...Array<number>];
132
142
  label?: string;
133
143
  value?: number;
134
144
  [key: string]: unknown;
135
145
  }
136
146
 
137
147
 
148
+ export interface SamplingPolicyAnyOf3 {
149
+ method?: "lttb" | "minmax";
150
+ /**
151
+ * the most points one series may draw; an explicit target makes the rendered line independent of any layout
152
+ * Schema constraints this type cannot express: type="integer", minimum=2
153
+ */
154
+ target?: number;
155
+ /**
156
+ * the width the derived target assumes, in CSS pixels (default 560)
157
+ * Schema constraints this type cannot express: exclusiveMinimum=0
158
+ */
159
+ width?: number;
160
+ /**
161
+ * Schema constraints this type cannot express: exclusiveMinimum=0
162
+ */
163
+ pixelRatio?: number;
164
+ [key: string]: unknown;
165
+ }
166
+
167
+
138
168
  /**
139
169
  * how many of a line's points are drawn: false never samples, a method name or object samples whatever the count, and an omitted member samples a TIME line above 2000 points through @jarenjs/core/series. Distinct from stream.maxPoints, which decides what exists rather than what is drawn.
140
170
  */
141
- export type SamplingPolicy = false | "lttb" | "minmax" | { method?: "lttb" | "minmax"; target?: number; width?: number; pixelRatio?: number; [key: string]: unknown; };
171
+ export type SamplingPolicy = false | "lttb" | "minmax" | SamplingPolicyAnyOf3;
142
172
 
143
173
  /**
144
174
  * the month, weekday and meridiem names a time-axis pattern with a name token reads (compileDateLocale(pack).names from @jarenjs/locales); a name token with no record is a compile error, never an English fallback
@@ -181,11 +211,24 @@ export interface TimeFormats {
181
211
  }
182
212
 
183
213
 
214
+ export interface DomainPolicyX {
215
+ /**
216
+ * Schema constraints this type cannot express: exclusiveMinimum=0
217
+ */
218
+ window: number;
219
+ /**
220
+ * Schema constraints this type cannot express: exclusiveMinimum=0
221
+ */
222
+ slide?: number;
223
+ [key: string]: unknown;
224
+ }
225
+
226
+
184
227
  /**
185
228
  * domain-stability policy: a quantized sliding x window and/or pinned or step-quantized y bounds, so most streaming ticks keep the scales still
186
229
  */
187
230
  export interface DomainPolicy {
188
- x?: { window: number; slide?: number; [key: string]: unknown; };
231
+ x?: DomainPolicyX;
189
232
  y?: "step" | { min?: number; max?: number; [key: string]: unknown; };
190
233
  [key: string]: unknown;
191
234
  }