@simpleapps-com/augur-server 2.2.0 → 2.2.1

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/hooks.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { OptionsProxyConfig } from '@simpleapps-com/augur-core';
1
+ import { OptionsProxyConfig, DeepQueryOptions } from '@simpleapps-com/augur-core';
2
2
 
3
3
  /**
4
4
  * Creates a client-side proxy that mirrors the SDK namespace and routes
@@ -38,6 +38,6 @@ import { OptionsProxyConfig } from '@simpleapps-com/augur-core';
38
38
  * const addToCart = useMutation(q.commerce.cartLine.add.create());
39
39
  * ```
40
40
  */
41
- declare function createServerQueryProxy(config?: OptionsProxyConfig): unknown;
41
+ declare function createServerQueryProxy<TApi extends object = object>(config?: OptionsProxyConfig): DeepQueryOptions<TApi>;
42
42
 
43
43
  export { createServerQueryProxy };
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks.ts"],"sourcesContent":["// \"use client\" banner is injected by tsup at build time.\n// Client-side proxy that generates React Query options backed by server actions.\n\nimport {\n createDeepProxy,\n isReadMethod,\n getCacheTier,\n buildQueryKey,\n stableArgs,\n} from \"@simpleapps-com/augur-core\";\nimport type {\n OptionsProxyConfig,\n ProxyQueryOptions,\n ProxyMutationOptions,\n} from \"@simpleapps-com/augur-core\";\nimport { queryAction } from \"./server-actions\";\n\n/**\n * Creates a client-side proxy that mirrors the SDK namespace and routes\n * every method call through a generic server action.\n *\n * Read methods (get, list, lookup, search, suggest) return TanStack Query\n * options with queryKey, queryFn, staleTime, gcTime. Write methods return\n * mutation options with mutationKey and mutationFn.\n *\n * queryFn calls the generic `queryAction` server function, which resolves\n * the method through `getSiteActions()` on the server. No SDK instance is\n * needed on the client.\n *\n * QueryKeys are identical to `createOptionsProxy` and `createKeysOnlyProxy`,\n * so SSR hydration via `createAugurOptions()` works automatically.\n *\n * @param config Optional cache configuration overrides\n *\n * @example\n * ```tsx\n * import { createServerQueryProxy } from \"@simpleapps-com/augur-server/hooks\";\n *\n * const q = createServerQueryProxy();\n *\n * // Reads — any SDK method, routed through server actions\n * const { data: item } = useQuery(q.items.invMast.doc.get(42));\n * const { data: price } = useQuery(q.pricing.priceEngine.get({ itemId, customerId }));\n *\n * // Infinite queries — spread and add infinite-specific options\n * const { data, fetchNextPage } = useInfiniteQuery({\n * ...q.items.itemCategory.categoryItems.get(uid, filters),\n * getNextPageParam: (lastPage) => lastPage.nextCursor,\n * initialPageParam: 0,\n * });\n *\n * // Mutations — write methods return mutation options\n * const addToCart = useMutation(q.commerce.cartLine.add.create());\n * ```\n */\nexport function createServerQueryProxy(config?: OptionsProxyConfig): unknown {\n return createDeepProxy(\n (\n path: string[],\n args: unknown[],\n ): ProxyQueryOptions<unknown> | ProxyMutationOptions<unknown, unknown[]> => {\n const methodName = path[path.length - 1]!;\n const methodPath = path.join(\".\");\n const normalizedArgs = stableArgs(args);\n\n if (isReadMethod(methodName)) {\n const tier = getCacheTier(methodPath, config?.cache);\n return {\n queryKey: buildQueryKey(path, normalizedArgs),\n queryFn: () => queryAction(methodPath, ...args),\n staleTime: tier.staleTime,\n gcTime: tier.gcTime,\n };\n }\n\n return {\n mutationKey: path,\n mutationFn: (...mutationArgs: unknown[]) => queryAction(methodPath, ...mutationArgs),\n };\n },\n );\n}\n"],"mappings":";;;;;;;AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA8CA,SAAS,uBAAuB,QAAsC;AAC3E,SAAO;AAAA,IACL,CACE,MACA,SAC0E;AAC1E,YAAM,aAAa,KAAK,KAAK,SAAS,CAAC;AACvC,YAAM,aAAa,KAAK,KAAK,GAAG;AAChC,YAAM,iBAAiB,WAAW,IAAI;AAEtC,UAAI,aAAa,UAAU,GAAG;AAC5B,cAAM,OAAO,aAAa,YAAY,QAAQ,KAAK;AACnD,eAAO;AAAA,UACL,UAAU,cAAc,MAAM,cAAc;AAAA,UAC5C,SAAS,MAAM,YAAY,YAAY,GAAG,IAAI;AAAA,UAC9C,WAAW,KAAK;AAAA,UAChB,QAAQ,KAAK;AAAA,QACf;AAAA,MACF;AAEA,aAAO;AAAA,QACL,aAAa;AAAA,QACb,YAAY,IAAI,iBAA4B,YAAY,YAAY,GAAG,YAAY;AAAA,MACrF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/hooks.ts"],"sourcesContent":["// \"use client\" banner is injected by tsup at build time.\n// Client-side proxy that generates React Query options backed by server actions.\n\nimport {\n createDeepProxy,\n isReadMethod,\n getCacheTier,\n buildQueryKey,\n stableArgs,\n} from \"@simpleapps-com/augur-core\";\nimport type {\n DeepQueryOptions,\n OptionsProxyConfig,\n ProxyQueryOptions,\n ProxyMutationOptions,\n} from \"@simpleapps-com/augur-core\";\nimport { queryAction } from \"./server-actions\";\n\n/**\n * Creates a client-side proxy that mirrors the SDK namespace and routes\n * every method call through a generic server action.\n *\n * Read methods (get, list, lookup, search, suggest) return TanStack Query\n * options with queryKey, queryFn, staleTime, gcTime. Write methods return\n * mutation options with mutationKey and mutationFn.\n *\n * queryFn calls the generic `queryAction` server function, which resolves\n * the method through `getSiteActions()` on the server. No SDK instance is\n * needed on the client.\n *\n * QueryKeys are identical to `createOptionsProxy` and `createKeysOnlyProxy`,\n * so SSR hydration via `createAugurOptions()` works automatically.\n *\n * @param config Optional cache configuration overrides\n *\n * @example\n * ```tsx\n * import { createServerQueryProxy } from \"@simpleapps-com/augur-server/hooks\";\n *\n * const q = createServerQueryProxy();\n *\n * // Reads — any SDK method, routed through server actions\n * const { data: item } = useQuery(q.items.invMast.doc.get(42));\n * const { data: price } = useQuery(q.pricing.priceEngine.get({ itemId, customerId }));\n *\n * // Infinite queries — spread and add infinite-specific options\n * const { data, fetchNextPage } = useInfiniteQuery({\n * ...q.items.itemCategory.categoryItems.get(uid, filters),\n * getNextPageParam: (lastPage) => lastPage.nextCursor,\n * initialPageParam: 0,\n * });\n *\n * // Mutations — write methods return mutation options\n * const addToCart = useMutation(q.commerce.cartLine.add.create());\n * ```\n */\nexport function createServerQueryProxy<TApi extends object = object>(\n config?: OptionsProxyConfig,\n): DeepQueryOptions<TApi> {\n return createDeepProxy(\n (\n path: string[],\n args: unknown[],\n ): ProxyQueryOptions<unknown> | ProxyMutationOptions<unknown, unknown[]> => {\n const methodName = path[path.length - 1]!;\n const methodPath = path.join(\".\");\n const normalizedArgs = stableArgs(args);\n\n if (isReadMethod(methodName)) {\n const tier = getCacheTier(methodPath, config?.cache);\n return {\n queryKey: buildQueryKey(path, normalizedArgs),\n queryFn: () => queryAction(methodPath, ...args),\n staleTime: tier.staleTime,\n gcTime: tier.gcTime,\n };\n }\n\n return {\n mutationKey: path,\n mutationFn: (...mutationArgs: unknown[]) => queryAction(methodPath, ...mutationArgs),\n };\n },\n ) as DeepQueryOptions<TApi>;\n}\n"],"mappings":";;;;;;;AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA+CA,SAAS,uBACd,QACwB;AACxB,SAAO;AAAA,IACL,CACE,MACA,SAC0E;AAC1E,YAAM,aAAa,KAAK,KAAK,SAAS,CAAC;AACvC,YAAM,aAAa,KAAK,KAAK,GAAG;AAChC,YAAM,iBAAiB,WAAW,IAAI;AAEtC,UAAI,aAAa,UAAU,GAAG;AAC5B,cAAM,OAAO,aAAa,YAAY,QAAQ,KAAK;AACnD,eAAO;AAAA,UACL,UAAU,cAAc,MAAM,cAAc;AAAA,UAC5C,SAAS,MAAM,YAAY,YAAY,GAAG,IAAI;AAAA,UAC9C,WAAW,KAAK;AAAA,UAChB,QAAQ,KAAK;AAAA,QACf;AAAA,MACF;AAEA,aAAO;AAAA,QACL,aAAa;AAAA,QACb,YAAY,IAAI,iBAA4B,YAAY,YAAY,GAAG,YAAY;AAAA,MACrF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleapps-com/augur-server",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -50,9 +50,9 @@
50
50
  "llms.txt"
51
51
  ],
52
52
  "dependencies": {
53
- "@simpleapps-com/augur-core": "2.2.0",
54
- "@simpleapps-com/augur-hooks": "2.2.0",
55
- "@simpleapps-com/augur-utils": "2.2.0"
53
+ "@simpleapps-com/augur-core": "2.2.1",
54
+ "@simpleapps-com/augur-hooks": "2.2.1",
55
+ "@simpleapps-com/augur-utils": "2.2.1"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@simpleapps-com/augur-api": "^2026.3.3",
@@ -80,7 +80,7 @@
80
80
  "tsup": "^8.5.0",
81
81
  "vitest": "^3.2.0",
82
82
  "@augur-packages/tsconfig": "0.0.0",
83
- "@simpleapps-com/augur-hooks": "2.2.0"
83
+ "@simpleapps-com/augur-hooks": "2.2.1"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "tsup",