@emeryld/rrroutes-client 2.3.3 → 2.3.5

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
@@ -99,17 +99,7 @@ var defaultFetcher = async (req) => {
99
99
  var import_rrroutes_contract = require("@emeryld/rrroutes-contract");
100
100
  var import_react_query = require("@tanstack/react-query");
101
101
  var import_react = require("react");
102
- var import_zod = require("zod");
103
102
  var toUpper = (m) => m.toUpperCase();
104
- var paginationQueryShape = {
105
- pagination_cursor: import_zod.z.string().optional(),
106
- pagination_limit: import_zod.z.coerce.number().min(1).max(100).default(20)
107
- };
108
- var defaultFeedQuerySchema = import_zod.z.object(paginationQueryShape);
109
- var defaultFeedOutputSchema = import_zod.z.object({
110
- items: import_zod.z.array(import_zod.z.unknown()),
111
- nextCursor: import_zod.z.string().optional()
112
- });
113
103
  function toSearchString(query) {
114
104
  if (!query) return "";
115
105
  const params = new URLSearchParams();
@@ -140,7 +130,20 @@ function stripKey(obj, key) {
140
130
  const { [key]: _omit, ...rest } = obj;
141
131
  return rest;
142
132
  }
143
- var defaultGetNextCursor = (p) => p && typeof p === "object" && "nextCursor" in p ? p.nextCursor : void 0;
133
+ var defaultGetNextCursor = (p) => {
134
+ if (!p || typeof p !== "object") return void 0;
135
+ const record = p;
136
+ if ("nextCursor" in record) {
137
+ return record.nextCursor;
138
+ }
139
+ if ("meta" in record) {
140
+ const meta = record.meta;
141
+ if (meta && typeof meta === "object" && "nextCursor" in meta) {
142
+ return meta.nextCursor;
143
+ }
144
+ }
145
+ return void 0;
146
+ };
144
147
  var defaultDebugLogger = (event) => {
145
148
  if (typeof console === "undefined") return;
146
149
  const fn = console.debug ?? console.log;
@@ -208,46 +211,6 @@ function extractArgs(args) {
208
211
  function toArgsTuple(args) {
209
212
  return typeof args === "undefined" ? [] : [args];
210
213
  }
211
- function getZodShape(schema) {
212
- const shapeOrGetter = schema.shape ? schema.shape : schema._def?.shape?.();
213
- if (!shapeOrGetter) return {};
214
- return typeof shapeOrGetter === "function" ? shapeOrGetter.call(schema) : shapeOrGetter;
215
- }
216
- function augmentFeedQuerySchema(schema) {
217
- if (!schema) return defaultFeedQuerySchema;
218
- if (!(schema instanceof import_zod.z.ZodObject)) {
219
- console.warn(
220
- "Feed queries must be a ZodObject; default pagination applied."
221
- );
222
- return defaultFeedQuerySchema;
223
- }
224
- return schema.extend(paginationQueryShape);
225
- }
226
- function augmentFeedOutputSchema(schema) {
227
- if (!schema) return defaultFeedOutputSchema;
228
- if (schema instanceof import_zod.z.ZodArray) {
229
- return import_zod.z.object({
230
- items: schema,
231
- nextCursor: import_zod.z.string().optional()
232
- });
233
- }
234
- if (schema instanceof import_zod.z.ZodObject) {
235
- const shape = getZodShape(schema);
236
- if (shape?.items) {
237
- return schema.extend({
238
- nextCursor: import_zod.z.string().optional()
239
- });
240
- }
241
- return import_zod.z.object({
242
- items: import_zod.z.array(schema),
243
- nextCursor: import_zod.z.string().optional()
244
- });
245
- }
246
- return import_zod.z.object({
247
- items: import_zod.z.array(schema),
248
- nextCursor: import_zod.z.string().optional()
249
- });
250
- }
251
214
  function buildUrl(leaf, baseUrl, params, query) {
252
215
  const normalizedParams = leaf.cfg.paramsSchema ? (0, import_rrroutes_contract.lowProfileParse)(leaf.cfg.paramsSchema, params) : {};
253
216
  const normalizedQuery = leaf.cfg.querySchema ? (0, import_rrroutes_contract.lowProfileParse)(leaf.cfg.querySchema, query) : {};
@@ -282,16 +245,7 @@ function createRouteClient(opts) {
282
245
  function buildInternal(leaf, rqOpts, meta) {
283
246
  const isGet = leaf.method === "get";
284
247
  const isFeed = !!leaf.cfg.feed;
285
- const rawLeafCfg = leaf.cfg;
286
- const leafCfg = isFeed ? {
287
- ...rawLeafCfg,
288
- querySchema: augmentFeedQuerySchema(
289
- rawLeafCfg.querySchema ? (0, import_rrroutes_contract.routeSchemaParse)(rawLeafCfg.querySchema) : void 0
290
- ),
291
- outputSchema: augmentFeedOutputSchema(
292
- rawLeafCfg.outputSchema ? (0, import_rrroutes_contract.routeSchemaParse)(rawLeafCfg.outputSchema) : void 0
293
- )
294
- } : rawLeafCfg;
248
+ const leafCfg = leaf.cfg;
295
249
  const method = toUpper(leaf.method);
296
250
  const expectsArgs = Boolean(leafCfg.paramsSchema || leafCfg.querySchema);
297
251
  const leafLabel = `${leaf.method.toUpperCase()} ${String(leaf.path)}`;
@@ -746,9 +700,9 @@ function compileRawPath(path, params) {
746
700
  }
747
701
 
748
702
  // src/sockets/socket.client.sys.ts
749
- var import_zod2 = require("zod");
750
- var roomValueSchema = import_zod2.z.union([import_zod2.z.array(import_zod2.z.string()), import_zod2.z.string()]);
751
- var buildRoomPayloadSchema = (metaSchema) => import_zod2.z.object({
703
+ var import_zod = require("zod");
704
+ var roomValueSchema = import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.string()]);
705
+ var buildRoomPayloadSchema = (metaSchema) => import_zod.z.object({
752
706
  rooms: roomValueSchema,
753
707
  meta: metaSchema
754
708
  });