@vertz/fetch 0.2.47 → 0.2.52

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 ADDED
@@ -0,0 +1,357 @@
1
+ # @vertz/fetch
2
+
3
+ ## 0.2.52
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @vertz/errors@0.2.52
9
+
10
+ ## 0.2.51
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies []:
15
+ - @vertz/errors@0.2.51
16
+
17
+ ## 0.2.50
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies []:
22
+ - @vertz/errors@0.2.50
23
+
24
+ ## 0.2.49
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies []:
29
+ - @vertz/errors@0.2.49
30
+
31
+ ## 0.2.48
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies []:
36
+ - @vertz/errors@0.2.48
37
+
38
+ ## 0.2.47
39
+
40
+ ### Patch Changes
41
+
42
+ - [#2243](https://github.com/vertz-dev/vertz/pull/2243) [`ca0007f`](https://github.com/vertz-dev/vertz/commit/ca0007f83b5be683fa1dfe4532a4d9ee846630d5) Thanks [@viniciusdacal](https://github.com/viniciusdacal)! - Widen query param type from `Record<string, unknown>` to `QueryParams` (`object`) so typed interfaces from codegen are assignable without explicit index signatures.
43
+
44
+ - Updated dependencies []:
45
+ - @vertz/errors@0.2.47
46
+
47
+ ## 0.2.46
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies []:
52
+ - @vertz/errors@0.2.46
53
+
54
+ ## 0.2.45
55
+
56
+ ### Patch Changes
57
+
58
+ - Updated dependencies []:
59
+ - @vertz/errors@0.2.45
60
+
61
+ ## 0.2.44
62
+
63
+ ### Patch Changes
64
+
65
+ - [#2197](https://github.com/vertz-dev/vertz/pull/2197) [`8cdfc4c`](https://github.com/vertz-dev/vertz/commit/8cdfc4c136b2e570e68d5e5af99bcf0ec3420c35) Thanks [@viniciusdacal](https://github.com/viniciusdacal)! - Force publish to sync README with npm registry
66
+
67
+ - Updated dependencies []:
68
+ - @vertz/errors@0.2.44
69
+
70
+ ## 0.2.43
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies []:
75
+ - @vertz/errors@0.2.43
76
+
77
+ ## 0.2.42
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies []:
82
+ - @vertz/errors@0.2.42
83
+
84
+ ## 0.2.41
85
+
86
+ ### Patch Changes
87
+
88
+ - Updated dependencies []:
89
+ - @vertz/errors@0.2.41
90
+
91
+ ## 0.2.40
92
+
93
+ ### Patch Changes
94
+
95
+ - Updated dependencies []:
96
+ - @vertz/errors@0.2.40
97
+
98
+ ## 0.2.39
99
+
100
+ ### Patch Changes
101
+
102
+ - Updated dependencies []:
103
+ - @vertz/errors@0.2.39
104
+
105
+ ## 0.2.38
106
+
107
+ ### Patch Changes
108
+
109
+ - Updated dependencies []:
110
+ - @vertz/errors@0.2.38
111
+
112
+ ## 0.2.37
113
+
114
+ ### Patch Changes
115
+
116
+ - Updated dependencies []:
117
+ - @vertz/errors@0.2.37
118
+
119
+ ## 0.2.36
120
+
121
+ ### Patch Changes
122
+
123
+ - Updated dependencies []:
124
+ - @vertz/errors@0.2.36
125
+
126
+ ## 0.2.35
127
+
128
+ ### Patch Changes
129
+
130
+ - Updated dependencies []:
131
+ - @vertz/errors@0.2.35
132
+
133
+ ## 0.2.34
134
+
135
+ ### Patch Changes
136
+
137
+ - Updated dependencies []:
138
+ - @vertz/errors@0.2.34
139
+
140
+ ## 0.2.33
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies []:
145
+ - @vertz/errors@0.2.33
146
+
147
+ ## 0.2.32
148
+
149
+ ### Patch Changes
150
+
151
+ - Updated dependencies []:
152
+ - @vertz/errors@0.2.32
153
+
154
+ ## 0.2.31
155
+
156
+ ### Patch Changes
157
+
158
+ - Updated dependencies []:
159
+ - @vertz/errors@0.2.31
160
+
161
+ ## 0.2.30
162
+
163
+ ### Patch Changes
164
+
165
+ - Updated dependencies []:
166
+ - @vertz/errors@0.2.30
167
+
168
+ ## 0.2.29
169
+
170
+ ### Patch Changes
171
+
172
+ - Updated dependencies []:
173
+ - @vertz/errors@0.2.29
174
+
175
+ ## 0.2.28
176
+
177
+ ### Patch Changes
178
+
179
+ - Updated dependencies []:
180
+ - @vertz/errors@0.2.28
181
+
182
+ ## 0.2.27
183
+
184
+ ### Patch Changes
185
+
186
+ - Updated dependencies []:
187
+ - @vertz/errors@0.2.27
188
+
189
+ ## 0.2.26
190
+
191
+ ### Patch Changes
192
+
193
+ - Updated dependencies []:
194
+ - @vertz/errors@0.2.26
195
+
196
+ ## 0.2.25
197
+
198
+ ### Patch Changes
199
+
200
+ - Updated dependencies []:
201
+ - @vertz/errors@0.2.25
202
+
203
+ ## 0.2.24
204
+
205
+ ### Patch Changes
206
+
207
+ - [#1707](https://github.com/vertz-dev/vertz/pull/1707) [`adea2f1`](https://github.com/vertz-dev/vertz/commit/adea2f15f306d09ecebc56fc1f3841ff4b14b2ba) Thanks [@viniciusdacal](https://github.com/viniciusdacal)! - Auto-invalidate tenant-scoped queries on tenant switch. When `switchTenant()` succeeds, all active queries with `tenantScoped: true` metadata are automatically cleared and refetched, preventing stale cross-tenant data from being visible.
208
+
209
+ **What changed:**
210
+
211
+ - `EntityQueryMeta` now includes an optional `tenantScoped` boolean field
212
+ - `registerActiveQuery()` accepts an optional `clearData` callback for data clearing before refetch
213
+ - `invalidateTenantQueries()` exported from `@vertz/ui` — clears data + refetches all tenant-scoped queries
214
+ - `TenantProvider.switchTenant()` calls `invalidateTenantQueries()` automatically on success
215
+ - Codegen emits `tenantScoped: true/false` in entity SDK descriptors based on entity configuration
216
+ - `QueryEnvelopeStore` gains a `delete(queryKey)` method for per-key cleanup
217
+
218
+ - [#1692](https://github.com/vertz-dev/vertz/pull/1692) [`99c90d9`](https://github.com/vertz-dev/vertz/commit/99c90d9d9176722d60d998a5a8d1eeaf4146c8de) Thanks [@viniciusdacal](https://github.com/viniciusdacal)! - Fix resolveVertzQL to keep where/orderBy/limit as flat query params instead of encoding them in the base64 q= parameter. Only select and include are encoded in q= (structural, not human-readable). Where is flattened to bracket notation (where[field]=value), orderBy to colon format (orderBy=field:dir), and limit stays as a raw number. Server parser updated to support comma-separated multi-field orderBy.
219
+
220
+ - Updated dependencies []:
221
+ - @vertz/errors@0.2.24
222
+
223
+ ## 0.2.23
224
+
225
+ ### Patch Changes
226
+
227
+ - Updated dependencies []:
228
+ - @vertz/errors@0.2.23
229
+
230
+ ## 0.2.22
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies []:
235
+ - @vertz/errors@0.2.22
236
+
237
+ ## 0.2.21
238
+
239
+ ### Patch Changes
240
+
241
+ - Updated dependencies []:
242
+ - @vertz/errors@0.2.21
243
+
244
+ ## 0.2.20
245
+
246
+ ### Patch Changes
247
+
248
+ - Updated dependencies []:
249
+ - @vertz/errors@0.2.20
250
+
251
+ ## 0.2.19
252
+
253
+ ### Patch Changes
254
+
255
+ - Updated dependencies []:
256
+ - @vertz/errors@0.2.19
257
+
258
+ ## 0.2.18
259
+
260
+ ### Patch Changes
261
+
262
+ - Updated dependencies []:
263
+ - @vertz/errors@0.2.18
264
+
265
+ ## 0.2.17
266
+
267
+ ### Patch Changes
268
+
269
+ - Updated dependencies []:
270
+ - @vertz/errors@0.2.17
271
+
272
+ ## 0.2.16
273
+
274
+ ### Patch Changes
275
+
276
+ - [#1132](https://github.com/vertz-dev/vertz/pull/1132) [`541305e`](https://github.com/vertz-dev/vertz/commit/541305e8f98f2cdcc3bbebd992418680402677fb) Thanks [@viniciusdacal](https://github.com/viniciusdacal)! - feat: VertzQL relation queries with where/orderBy/limit support
277
+
278
+ Breaking change to EntityRelationsConfig: flat field maps replaced with structured
279
+ RelationConfigObject containing `select`, `allowWhere`, `allowOrderBy`, `maxLimit`.
280
+
281
+ - Extended VertzQL include entries to support `where`, `orderBy`, `limit`, nested `include`
282
+ - Recursive include validation with path-prefixed errors and maxLimit clamping
283
+ - Include pass-through from route handler → CRUD pipeline → DB adapter
284
+ - GetOptions added to EntityDbAdapter.get() for include on single-entity fetch
285
+ - Codegen IR and entity schema manifest include allowWhere/allowOrderBy/maxLimit
286
+
287
+ - Updated dependencies []:
288
+ - @vertz/errors@0.2.16
289
+
290
+ ## 0.2.15
291
+
292
+ ### Patch Changes
293
+
294
+ - Updated dependencies []:
295
+ - @vertz/errors@0.2.15
296
+
297
+ ## 0.2.14
298
+
299
+ ### Patch Changes
300
+
301
+ - Updated dependencies []:
302
+ - @vertz/errors@0.2.14
303
+
304
+ ## 0.2.13
305
+
306
+ ### Patch Changes
307
+
308
+ - [#950](https://github.com/vertz-dev/vertz/pull/950) [`a5ceec8`](https://github.com/vertz-dev/vertz/commit/a5ceec812613d92f7261407e86b1a39993687a7a) Thanks [@viniciusdacal](https://github.com/viniciusdacal)! - Automatic optimistic updates for entity mutations.
309
+
310
+ EntityStore gains an optimistic layer stack (applyLayer/commitLayer/rollbackLayer) that overlays in-flight mutation patches on top of server-truth base data. MutationDescriptor in @vertz/fetch orchestrates the apply→fetch→commit/rollback lifecycle. The query() source switcher reads entity-backed data from EntityStore, so optimistic patches propagate reactively to all consuming queries. Generated createClient auto-wires the handler — zero boilerplate for `await api.todos.update(id, { completed: true })` to optimistically update all queries immediately.
311
+
312
+ - [#1003](https://github.com/vertz-dev/vertz/pull/1003) [`de34f8d`](https://github.com/vertz-dev/vertz/commit/de34f8dc9d3e69b507874f33d80bf7dc4420001d) Thanks [@viniciusdacal](https://github.com/viniciusdacal)! - Add same-type query revalidation via MutationEventBus. Entity-backed queries now automatically revalidate when a mutation commits for the same entity type. Opt out per-mutation via `skipInvalidation: true` on MutationMeta.
313
+
314
+ - Updated dependencies [[`efda760`](https://github.com/vertz-dev/vertz/commit/efda76032901138dca7a22acd60ad947a4bdf02a), [`3d2799a`](https://github.com/vertz-dev/vertz/commit/3d2799ac4c3e0d8f65d864b4471e205a64db886a), [`7b125db`](https://github.com/vertz-dev/vertz/commit/7b125db968ba9157ce97932b392cb3be7fcc0344)]:
315
+ - @vertz/errors@0.2.13
316
+
317
+ ## 0.2.12
318
+
319
+ ### Patch Changes
320
+
321
+ - Updated dependencies []:
322
+ - @vertz/errors@0.2.12
323
+
324
+ ## 0.2.11
325
+
326
+ ### Patch Changes
327
+
328
+ - Updated dependencies []:
329
+ - @vertz/errors@0.2.11
330
+
331
+ ## 0.2.8
332
+
333
+ ### Patch Changes
334
+
335
+ - Updated dependencies []:
336
+ - @vertz/errors@0.2.8
337
+
338
+ ## 0.2.7
339
+
340
+ ### Patch Changes
341
+
342
+ - Updated dependencies []:
343
+ - @vertz/errors@0.2.7
344
+
345
+ ## 0.2.6
346
+
347
+ ### Patch Changes
348
+
349
+ - Updated dependencies []:
350
+ - @vertz/errors@0.2.6
351
+
352
+ ## 0.2.5
353
+
354
+ ### Patch Changes
355
+
356
+ - Updated dependencies []:
357
+ - @vertz/errors@0.2.5
package/dist/index.d.ts CHANGED
@@ -203,6 +203,37 @@ declare class ServiceUnavailableError extends FetchError2 {
203
203
  constructor(message: string, body?: unknown);
204
204
  }
205
205
  declare function createErrorFromStatus(status: number, message: string, body?: unknown): FetchError2;
206
+ interface QueryKeyInput {
207
+ path: string;
208
+ params?: Record<string, unknown>;
209
+ query?: Record<string, unknown>;
210
+ }
211
+ /**
212
+ * Build a cache key array from a path template, params, and optional query.
213
+ *
214
+ * Designed for use with TanStack Query, SWR, or any cache library that uses
215
+ * array-based hierarchical keys. For Vertz's internal cache, use
216
+ * `QueryDescriptor._key` instead.
217
+ *
218
+ * The path template is split on `{param}` placeholders. Static segments and
219
+ * resolved param values alternate in the output. When a param value is
220
+ * `undefined` or `null`, the key is truncated at that point — the static
221
+ * segment preceding the param is kept, but the nullish value and everything
222
+ * after it are omitted.
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * queryKey({ path: '/tasks/{taskId}', params: { taskId: 'abc' } })
227
+ * // => ['/tasks', 'abc']
228
+ *
229
+ * queryKey({ path: '/tasks', query: { status: 'active' } })
230
+ * // => ['/tasks', { status: 'active' }]
231
+ *
232
+ * queryKey({ path: '/tasks/{taskId}', params: { taskId: undefined } })
233
+ * // => ['/tasks']
234
+ * ```
235
+ */
236
+ declare function queryKey(input: QueryKeyInput): readonly unknown[];
206
237
  /** Shape of a single include entry for VertzQL client params. */
207
238
  interface VertzQLIncludeEntry {
208
239
  select?: Record<string, true>;
@@ -239,4 +270,4 @@ declare function encodeVertzQL(params: VertzQLParams): string;
239
270
  * Returns the query unchanged if no VertzQL keys are present.
240
271
  */
241
272
  declare function resolveVertzQL(query?: Record<string, unknown>): Record<string, unknown> | undefined;
242
- export { unwrapOr, unwrap, resolveVertzQL, ok, matchError, isQueryDescriptor, isOk, isMutationDescriptor, isErr, err, encodeVertzQL, createMutationDescriptor, createErrorFromStatus, createDescriptor, VertzQLParams, UnprocessableEntityError, UnauthorizedError, StreamingRequestOptions, StreamingFormat, ServiceUnavailableError, RetryConfig, Result3 as Result, RequestOptions, RateLimitError, QueryParams, QueryDescriptor, OptimisticHandler, NotFoundError, MutationMeta, MutationDescriptor, ListResponse, InternalServerError, HooksConfig, GoneError, ForbiddenError, FetchResponse, FetchErrorType, FetchError2 as FetchError, FetchClientConfig, FetchClient, EntityQueryMeta, EntityErrorType, ConflictError, BadRequestError, AuthStrategy };
273
+ export { unwrapOr, unwrap, resolveVertzQL, queryKey, ok, matchError, isQueryDescriptor, isOk, isMutationDescriptor, isErr, err, encodeVertzQL, createMutationDescriptor, createErrorFromStatus, createDescriptor, VertzQLParams, UnprocessableEntityError, UnauthorizedError, StreamingRequestOptions, StreamingFormat, ServiceUnavailableError, RetryConfig, Result3 as Result, RequestOptions, RateLimitError, QueryParams, QueryKeyInput, QueryDescriptor, OptimisticHandler, NotFoundError, MutationMeta, MutationDescriptor, ListResponse, InternalServerError, HooksConfig, GoneError, ForbiddenError, FetchResponse, FetchErrorType, FetchError2 as FetchError, FetchClientConfig, FetchClient, EntityQueryMeta, EntityErrorType, ConflictError, BadRequestError, AuthStrategy };
package/dist/index.js CHANGED
@@ -519,6 +519,34 @@ function createErrorFromStatus(status, message, body) {
519
519
  }
520
520
  return new FetchError(message, status, body);
521
521
  }
522
+ // src/query-key.ts
523
+ function queryKey(input) {
524
+ const { path, params, query } = input;
525
+ if (!path)
526
+ return [];
527
+ const segments = path.split(/\{([^}]+)\}/);
528
+ const parts = [];
529
+ let stopped = false;
530
+ for (let i = 0;i < segments.length; i++) {
531
+ if (i % 2 === 0) {
532
+ const segment = segments[i].replace(/\/$/, "");
533
+ if (segment) {
534
+ parts.push(segment);
535
+ }
536
+ } else {
537
+ const value = params?.[segments[i]];
538
+ if (value === undefined || value === null) {
539
+ stopped = true;
540
+ break;
541
+ }
542
+ parts.push(value);
543
+ }
544
+ }
545
+ if (!stopped && query !== undefined && query !== null && parts.length > 0) {
546
+ parts.push(query);
547
+ }
548
+ return Object.freeze(parts);
549
+ }
522
550
  // src/vertzql.ts
523
551
  function encodeVertzQL(params) {
524
552
  const json = JSON.stringify(params);
@@ -583,6 +611,7 @@ export {
583
611
  unwrapOr,
584
612
  unwrap,
585
613
  resolveVertzQL,
614
+ queryKey,
586
615
  ok3 as ok,
587
616
  matchError,
588
617
  isQueryDescriptor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertz/fetch",
3
- "version": "0.2.47",
3
+ "version": "0.2.52",
4
4
  "description": "Type-safe HTTP client for Vertz",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,12 +26,12 @@
26
26
  "provenance": true
27
27
  },
28
28
  "scripts": {
29
- "build": "bunup",
29
+ "build": "vtzx bunup",
30
30
  "test": "bun test",
31
31
  "typecheck": "tsc --noEmit -p tsconfig.typecheck.json"
32
32
  },
33
33
  "dependencies": {
34
- "@vertz/errors": "^0.2.46"
34
+ "@vertz/errors": "workspace:^"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^25.3.1",