@emeryld/rrroutes-client 2.3.3 → 2.3.4

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.mjs CHANGED
@@ -55,8 +55,7 @@ var defaultFetcher = async (req) => {
55
55
  import {
56
56
  buildCacheKey,
57
57
  compilePath,
58
- lowProfileParse,
59
- routeSchemaParse
58
+ lowProfileParse
60
59
  } from "@emeryld/rrroutes-contract";
61
60
  import {
62
61
  keepPreviousData,
@@ -65,17 +64,7 @@ import {
65
64
  useQuery
66
65
  } from "@tanstack/react-query";
67
66
  import { useCallback, useRef } from "react";
68
- import { z } from "zod";
69
67
  var toUpper = (m) => m.toUpperCase();
70
- var paginationQueryShape = {
71
- pagination_cursor: z.string().optional(),
72
- pagination_limit: z.coerce.number().min(1).max(100).default(20)
73
- };
74
- var defaultFeedQuerySchema = z.object(paginationQueryShape);
75
- var defaultFeedOutputSchema = z.object({
76
- items: z.array(z.unknown()),
77
- nextCursor: z.string().optional()
78
- });
79
68
  function toSearchString(query) {
80
69
  if (!query) return "";
81
70
  const params = new URLSearchParams();
@@ -106,7 +95,20 @@ function stripKey(obj, key) {
106
95
  const { [key]: _omit, ...rest } = obj;
107
96
  return rest;
108
97
  }
109
- var defaultGetNextCursor = (p) => p && typeof p === "object" && "nextCursor" in p ? p.nextCursor : void 0;
98
+ var defaultGetNextCursor = (p) => {
99
+ if (!p || typeof p !== "object") return void 0;
100
+ const record = p;
101
+ if ("nextCursor" in record) {
102
+ return record.nextCursor;
103
+ }
104
+ if ("meta" in record) {
105
+ const meta = record.meta;
106
+ if (meta && typeof meta === "object" && "nextCursor" in meta) {
107
+ return meta.nextCursor;
108
+ }
109
+ }
110
+ return void 0;
111
+ };
110
112
  var defaultDebugLogger = (event) => {
111
113
  if (typeof console === "undefined") return;
112
114
  const fn = console.debug ?? console.log;
@@ -174,46 +176,6 @@ function extractArgs(args) {
174
176
  function toArgsTuple(args) {
175
177
  return typeof args === "undefined" ? [] : [args];
176
178
  }
177
- function getZodShape(schema) {
178
- const shapeOrGetter = schema.shape ? schema.shape : schema._def?.shape?.();
179
- if (!shapeOrGetter) return {};
180
- return typeof shapeOrGetter === "function" ? shapeOrGetter.call(schema) : shapeOrGetter;
181
- }
182
- function augmentFeedQuerySchema(schema) {
183
- if (!schema) return defaultFeedQuerySchema;
184
- if (!(schema instanceof z.ZodObject)) {
185
- console.warn(
186
- "Feed queries must be a ZodObject; default pagination applied."
187
- );
188
- return defaultFeedQuerySchema;
189
- }
190
- return schema.extend(paginationQueryShape);
191
- }
192
- function augmentFeedOutputSchema(schema) {
193
- if (!schema) return defaultFeedOutputSchema;
194
- if (schema instanceof z.ZodArray) {
195
- return z.object({
196
- items: schema,
197
- nextCursor: z.string().optional()
198
- });
199
- }
200
- if (schema instanceof z.ZodObject) {
201
- const shape = getZodShape(schema);
202
- if (shape?.items) {
203
- return schema.extend({
204
- nextCursor: z.string().optional()
205
- });
206
- }
207
- return z.object({
208
- items: z.array(schema),
209
- nextCursor: z.string().optional()
210
- });
211
- }
212
- return z.object({
213
- items: z.array(schema),
214
- nextCursor: z.string().optional()
215
- });
216
- }
217
179
  function buildUrl(leaf, baseUrl, params, query) {
218
180
  const normalizedParams = leaf.cfg.paramsSchema ? lowProfileParse(leaf.cfg.paramsSchema, params) : {};
219
181
  const normalizedQuery = leaf.cfg.querySchema ? lowProfileParse(leaf.cfg.querySchema, query) : {};
@@ -248,16 +210,7 @@ function createRouteClient(opts) {
248
210
  function buildInternal(leaf, rqOpts, meta) {
249
211
  const isGet = leaf.method === "get";
250
212
  const isFeed = !!leaf.cfg.feed;
251
- const rawLeafCfg = leaf.cfg;
252
- const leafCfg = isFeed ? {
253
- ...rawLeafCfg,
254
- querySchema: augmentFeedQuerySchema(
255
- rawLeafCfg.querySchema ? routeSchemaParse(rawLeafCfg.querySchema) : void 0
256
- ),
257
- outputSchema: augmentFeedOutputSchema(
258
- rawLeafCfg.outputSchema ? routeSchemaParse(rawLeafCfg.outputSchema) : void 0
259
- )
260
- } : rawLeafCfg;
213
+ const leafCfg = leaf.cfg;
261
214
  const method = toUpper(leaf.method);
262
215
  const expectsArgs = Boolean(leafCfg.paramsSchema || leafCfg.querySchema);
263
216
  const leafLabel = `${leaf.method.toUpperCase()} ${String(leaf.path)}`;
@@ -712,9 +665,9 @@ function compileRawPath(path, params) {
712
665
  }
713
666
 
714
667
  // src/sockets/socket.client.sys.ts
715
- import { z as z2 } from "zod";
716
- var roomValueSchema = z2.union([z2.array(z2.string()), z2.string()]);
717
- var buildRoomPayloadSchema = (metaSchema) => z2.object({
668
+ import { z } from "zod";
669
+ var roomValueSchema = z.union([z.array(z.string()), z.string()]);
670
+ var buildRoomPayloadSchema = (metaSchema) => z.object({
718
671
  rooms: roomValueSchema,
719
672
  meta: metaSchema
720
673
  });