@simpleapps-com/augur-server 2026.11.5 → 2026.11.7

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.
Files changed (81) hide show
  1. package/EXPORTS.md +26 -1
  2. package/README.md +33 -2
  3. package/dist/actions/action-rules.d.ts +99 -0
  4. package/dist/actions/action-rules.d.ts.map +1 -0
  5. package/dist/actions/agr-site.d.ts +7 -15
  6. package/dist/actions/agr-site.d.ts.map +1 -1
  7. package/dist/actions/commerce.d.ts.map +1 -1
  8. package/dist/actions/customers.d.ts +12 -15
  9. package/dist/actions/customers.d.ts.map +1 -1
  10. package/dist/actions/favorites.d.ts +9 -12
  11. package/dist/actions/favorites.d.ts.map +1 -1
  12. package/dist/actions/gregorovich.d.ts +7 -15
  13. package/dist/actions/gregorovich.d.ts.map +1 -1
  14. package/dist/actions/items.d.ts +8 -20
  15. package/dist/actions/items.d.ts.map +1 -1
  16. package/dist/actions/joomla.d.ts +8 -14
  17. package/dist/actions/joomla.d.ts.map +1 -1
  18. package/dist/actions/legacy.d.ts +10 -20
  19. package/dist/actions/legacy.d.ts.map +1 -1
  20. package/dist/actions/orders.d.ts +7 -14
  21. package/dist/actions/orders.d.ts.map +1 -1
  22. package/dist/actions/read-specs.d.ts +119 -0
  23. package/dist/actions/read-specs.d.ts.map +1 -0
  24. package/dist/actions/site.d.ts.map +1 -1
  25. package/dist/actions/vmi.d.ts +10 -16
  26. package/dist/actions/vmi.d.ts.map +1 -1
  27. package/dist/actions/wishlists.d.ts +11 -13
  28. package/dist/actions/wishlists.d.ts.map +1 -1
  29. package/dist/api-handler.d.ts.map +1 -1
  30. package/dist/api.js +3 -2
  31. package/dist/api.js.map +1 -1
  32. package/dist/auth.js +3 -2
  33. package/dist/cache/redis-client.d.ts.map +1 -1
  34. package/dist/cache/redis-rules.d.ts +21 -0
  35. package/dist/cache/redis-rules.d.ts.map +1 -0
  36. package/dist/cache/spec-read.d.ts +39 -0
  37. package/dist/cache/spec-read.d.ts.map +1 -0
  38. package/dist/cache/with-cache.d.ts +2 -2
  39. package/dist/cache/with-cache.d.ts.map +1 -1
  40. package/dist/{chunk-KSGH4DXD.js → chunk-4JPJQHT6.js} +2 -2
  41. package/dist/{chunk-FIM6LDMD.js → chunk-GJHQPBK7.js} +5 -3
  42. package/dist/chunk-GJHQPBK7.js.map +1 -0
  43. package/dist/chunk-JIYVQWXK.js +10 -0
  44. package/dist/chunk-JIYVQWXK.js.map +1 -0
  45. package/dist/{chunk-U54IM6FL.js → chunk-SFXO74RC.js} +874 -719
  46. package/dist/chunk-SFXO74RC.js.map +1 -0
  47. package/dist/chunk-V76GZZF3.js +66 -0
  48. package/dist/chunk-V76GZZF3.js.map +1 -0
  49. package/dist/{chunk-6GPKXGPG.js → chunk-Z53NEFEQ.js} +8 -16
  50. package/dist/chunk-Z53NEFEQ.js.map +1 -0
  51. package/dist/hooks.d.ts +2 -2
  52. package/dist/hooks.d.ts.map +1 -1
  53. package/dist/hooks.js +5 -3
  54. package/dist/hooks.js.map +1 -1
  55. package/dist/index.js +4 -2
  56. package/dist/index.js.map +1 -1
  57. package/dist/query-action.d.ts +11 -4
  58. package/dist/query-action.d.ts.map +1 -1
  59. package/dist/query-action.js +3 -2
  60. package/dist/read-rules.d.ts +45 -0
  61. package/dist/read-rules.d.ts.map +1 -0
  62. package/dist/server-site-registry.d.ts.map +1 -1
  63. package/dist/server-site.d.ts.map +1 -1
  64. package/dist/site.js +24 -14
  65. package/dist/site.js.map +1 -1
  66. package/dist/sitemap-rules.d.ts +154 -0
  67. package/dist/sitemap-rules.d.ts.map +1 -0
  68. package/dist/sitemap.d.ts +80 -0
  69. package/dist/sitemap.d.ts.map +1 -0
  70. package/dist/sitemap.js +242 -0
  71. package/dist/sitemap.js.map +1 -0
  72. package/dist/testing.js +4 -2
  73. package/dist/testing.js.map +1 -1
  74. package/dist/utils/read-all-pages.d.ts +17 -0
  75. package/dist/utils/read-all-pages.d.ts.map +1 -0
  76. package/llms.txt +44 -1
  77. package/package.json +9 -5
  78. package/dist/chunk-6GPKXGPG.js.map +0 -1
  79. package/dist/chunk-FIM6LDMD.js.map +0 -1
  80. package/dist/chunk-U54IM6FL.js.map +0 -1
  81. /package/dist/{chunk-KSGH4DXD.js.map → chunk-4JPJQHT6.js.map} +0 -0
@@ -0,0 +1,119 @@
1
+ import type { EdgeCacheValue } from "@simpleapps-com/augur-core";
2
+ import type { Seconds } from "../duration";
3
+ /**
4
+ * Which config values a read uses: the short pair (redisTtl, edgeCache), the long pair, the short
5
+ * Redis TTL with the short edge (vmi availability), the short Redis TTL with a fixed 4-hour edge
6
+ * (items invMast and its doc), or the short Redis TTL and no edge value (joomla menu doc,
7
+ * gregorovich documents, whose routes take none).
8
+ */
9
+ export type ReadTier = "short" | "long" | "shortRedis" | "itemEdge" | "shortNoEdge";
10
+ /**
11
+ * What a list read returns: one record, every row (paged until an empty page), the first `top`
12
+ * (an explicit limit), or what the caller's own limit and offset ask for.
13
+ */
14
+ export type ReadPaging = "one" | "all" | "top" | "caller";
15
+ /** One action read. `keySuffix` is "" or a sub-key for a second shape of the same call. */
16
+ export interface ReadSpec {
17
+ sdkPath: string;
18
+ keySuffix: string;
19
+ tier: ReadTier;
20
+ paging: ReadPaging;
21
+ top: number;
22
+ }
23
+ /** A read spec from its parts. */
24
+ export declare function readSpec(sdkPath: string, keySuffix: string, tier: ReadTier, paging: ReadPaging, top: number): ReadSpec;
25
+ /**
26
+ * The method path the cache key is built from: the call's own, or a sub-key under it.
27
+ *
28
+ * @ensures exactly the model's KeyPath
29
+ */
30
+ export declare function keyPath(spec: ReadSpec): string;
31
+ /**
32
+ * The Redis TTL a tier uses from the factory's config.
33
+ *
34
+ * @ensures exactly the model's TierRedis
35
+ */
36
+ export declare function tierRedis(tier: ReadTier, redisTtl: Seconds, longRedisTtl: Seconds, shortRedisTtl: Seconds): Seconds;
37
+ /** Which edge value a tier sends: the config's short or long one, a fixed 4 hours, or none. */
38
+ export type EdgeChoice = "shortEdge" | "longEdge" | "fourHours" | "noEdge";
39
+ /**
40
+ * The edge value a tier sends (before augur-core strips it on a path the server never caches).
41
+ *
42
+ * @ensures exactly the model's TierEdge
43
+ */
44
+ export declare function edgeChoice(tier: ReadTier): EdgeChoice;
45
+ /**
46
+ * The edge value a choice sends, from the factory's short and long values and the fixed four
47
+ * hours (`fourHours`, passed in: lsc keeps `EdgeCacheValue` opaque, so a literal can't be one);
48
+ * undefined for none.
49
+ *
50
+ * @ensures exactly the link's EdgeOf (the model's TierEdge through `edgeChoice`)
51
+ */
52
+ export declare function edgeValueOf(choice: EdgeChoice, edge: EdgeCacheValue, longEdge: EdgeCacheValue, fourHours: EdgeCacheValue): EdgeCacheValue | undefined;
53
+ /** What a read call sends after its positional arguments: nothing, its params, or both + edge. */
54
+ export type SentShape = "argsOnly" | "withParams" | "withParamsAndEdge";
55
+ /**
56
+ * The call's shape: no params object sends the arguments alone (so no edge value), else the
57
+ * params, with the tier's edge value when it has one.
58
+ *
59
+ * @ensures exactly the model's SentShapeOf
60
+ */
61
+ export declare function sentShape(hasParams: boolean, hasEdge: boolean): SentShape;
62
+ /**
63
+ * The limit a read sends: the page size on an every-row read, its `top` on a first-n read, else
64
+ * none of its own (one record, or the caller's own limit and offset).
65
+ *
66
+ * @ensures exactly the model's LimitSent
67
+ */
68
+ export declare function limitSent(paging: ReadPaging, top: number, size: number): number | undefined;
69
+ export declare function categoryLookupRead(): ReadSpec;
70
+ export declare function categoryRead(): ReadSpec;
71
+ export declare function categoryItemsRead(): ReadSpec;
72
+ export declare function categoryAttributesRead(): ReadSpec;
73
+ export declare function invMastRead(): ReadSpec;
74
+ export declare function invMastDocRead(): ReadSpec;
75
+ export declare function stockRead(): ReadSpec;
76
+ /** The company summary of the stock call, cached apart from getStock's whole value (#98). */
77
+ export declare function stockSummaryRead(): ReadSpec;
78
+ export declare function faqsRead(): ReadSpec;
79
+ export declare function substitutesRead(): ReadSpec;
80
+ export declare function accessoriesRead(): ReadSpec;
81
+ /** The similar-items route takes no limit: one call. */
82
+ export declare function similarRead(): ReadSpec;
83
+ export declare function customerLookupRead(): ReadSpec;
84
+ export declare function customerDocRead(): ReadSpec;
85
+ export declare function customerOrdersRead(): ReadSpec;
86
+ export declare function customerOrderRead(): ReadSpec;
87
+ export declare function customerInvoicesRead(): ReadSpec;
88
+ export declare function customerInvoiceRead(): ReadSpec;
89
+ export declare function customerQuotesRead(): ReadSpec;
90
+ export declare function customerQuoteRead(): ReadSpec;
91
+ export declare function shipToRead(): ReadSpec;
92
+ export declare function warehousesRead(): ReadSpec;
93
+ export declare function availabilityRead(): ReadSpec;
94
+ export declare function distributorsRead(): ReadSpec;
95
+ export declare function productsRead(): ReadSpec;
96
+ export declare function inventoryProfilesRead(): ReadSpec;
97
+ export declare function restockHeadersRead(): ReadSpec;
98
+ export declare function sectionsRead(): ReadSpec;
99
+ export declare function wishlistsRead(): ReadSpec;
100
+ export declare function wishlistLinesRead(): ReadSpec;
101
+ export declare function favoritesRead(): ReadSpec;
102
+ export declare function contentRead(): ReadSpec;
103
+ export declare function contentListRead(): ReadSpec;
104
+ /** A menu's items under a parent: the route answers the whole subtree, read to the end. */
105
+ export declare function menuRead(): ReadSpec;
106
+ export declare function menuListRead(): ReadSpec;
107
+ export declare function menuDocRead(): ReadSpec;
108
+ export declare function userProfileRead(): ReadSpec;
109
+ export declare function webDescRead(): ReadSpec;
110
+ /** Its route takes no limit (only statusCd): one call. */
111
+ export declare function legacyAlsoBoughtRead(): ReadSpec;
112
+ export declare function tagsRead(): ReadSpec;
113
+ export declare function statesRead(): ReadSpec;
114
+ export declare function settingsRead(): ReadSpec;
115
+ export declare function robotsRead(): ReadSpec;
116
+ export declare function orderDocRead(): ReadSpec;
117
+ export declare function documentsRead(): ReadSpec;
118
+ export declare function cartAlsoBoughtRead(): ReadSpec;
119
+ //# sourceMappingURL=read-specs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-specs.d.ts","sourceRoot":"","sources":["../../src/actions/read-specs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;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,MAAM,EACnD,GAAG,EAAE,IAAI,EACT,MAAM,GAAE,iBAAsB,GAC7B,WAAW,CA4Pb"}
@@ -1,18 +1,14 @@
1
1
  import type { AugurAPI, VMITypes } from "@simpleapps-com/augur-api";
2
- import type { Seconds } from "../duration";
3
- import type { EdgeCacheValue, ListResult } from "../sdk-call";
2
+ import type { ListResult } from "../sdk-call";
3
+ import { type SpecReadConfig } from "../cache/spec-read";
4
4
  /** Derived from augur-api SDK — keeps types in sync automatically. */
5
5
  export type VmiApiClient = Pick<AugurAPI, "vmi">;
6
- export interface VmiActionsConfig {
7
- /** Cache key prefix (e.g. "example:"). Default: "". */
8
- cachePrefix?: string;
9
- /** CDN edge cache value passed to SDK. Default: 1 (hour). */
10
- edgeCache?: EdgeCacheValue;
11
- /** Redis TTL in seconds. Default: 3600 (1 hour). */
12
- redisTtl?: Seconds;
13
- /** Redis TTL for short-lived data like availability. Default: 300 (5 min). */
14
- shortRedisTtl?: Seconds;
15
- }
6
+ /**
7
+ * Cache values (`shortRedisTtl` was availability's). VMI data is per customer and is a user path
8
+ * (augur-core `USER_PATHS`, atlas#102): the server never caches it, whatever these say; the
9
+ * browser keeps a short cache.
10
+ */
11
+ export type VmiActionsConfig = SpecReadConfig;
16
12
  export interface VmiActions {
17
13
  getWarehouses: (params: VMITypes.WarehouseListParams) => Promise<ListResult>;
18
14
  getWarehouseAvailability: (warehouseUid: number, params: VMITypes.WarehouseAvailabilityListParams) => Promise<ListResult>;
@@ -23,10 +19,8 @@ export interface VmiActions {
23
19
  getSections: (params: VMITypes.SectionsListParams) => Promise<ListResult>;
24
20
  }
25
21
  /**
26
- * Creates server-side VMI (Vendor Managed Inventory) actions with Redis caching.
27
- *
28
- * All VMI read operations are cached. Warehouse availability uses a shorter TTL
29
- * because inventory levels change more frequently than configuration data.
22
+ * Creates server-side VMI (Vendor Managed Inventory) actions. Each read is a spec
23
+ * (`read-specs.ts`) passing the caller's own paging; none is cached on the server.
30
24
  *
31
25
  * @example
32
26
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"vmi.d.ts","sourceRoot":"","sources":["../../src/actions/vmi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9D,sEAAsE;AACtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,mBAAmB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7E,wBAAwB,EAAE,CACxB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,QAAQ,CAAC,+BAA+B,KAC7C,OAAO,CAAC,UAAU,CAAC,CAAC;IACzB,eAAe,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,sBAAsB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAClF,WAAW,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,kBAAkB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1E,oBAAoB,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,uBAAuB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACxF,iBAAiB,EAA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AU,CAAC,CAAC;IACxF,iBAAiB,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,oBAAoB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACnF,WAAW,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,kBAAkB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAC3E;AAED;;;;;;;;;;;;;;;;SAgBS;AACT,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,GAAE,gBAAqB,GAAG,UAAU,CAmD7F"}
@@ -1,29 +1,27 @@
1
1
  import type { AugurAPI } from "@simpleapps-com/augur-api";
2
- import type { Seconds } from "../duration";
3
- import type { EdgeCacheValue, ListResult } from "../sdk-call";
2
+ import { type AllRows, type SpecReadConfig } from "../cache/spec-read";
4
3
  /** Derived from augur-api SDK — keeps types in sync automatically. */
5
4
  export type WishlistsApiClient = Pick<AugurAPI, "items">;
6
- export interface WishlistActionsConfig {
7
- /** Cache key prefix (e.g. "example:"). Default: "". */
8
- cachePrefix?: string;
9
- /** CDN edge cache value passed to SDK. Default: 1 (hour). */
10
- edgeCache?: EdgeCacheValue;
11
- /** Redis TTL in seconds. Default: 3600 (1 hour). */
12
- redisTtl?: Seconds;
13
- }
5
+ /**
6
+ * Cache values. Wishlists are a user path (augur-core `USER_PATHS`, atlas#102): the server never
7
+ * caches them, whatever these say; the browser keeps a short cache its own writes clear.
8
+ */
9
+ export type WishlistActionsConfig = SpecReadConfig;
14
10
  export interface WishlistActions {
15
- getWishlists: (userId: number) => Promise<ListResult>;
11
+ /** Every wishlist of the user (paged to the end), and whether the page cap stopped the read. */
12
+ getWishlists: (userId: number) => Promise<AllRows>;
16
13
  createWishlist: (userId: number, data: {
17
14
  name: string;
18
15
  description?: string;
19
16
  }) => Promise<unknown>;
20
- getWishlistDetail: (userId: number, wishlistId: number) => Promise<unknown>;
17
+ /** Every line of the wishlist (paged to the end). */
18
+ getWishlistDetail: (userId: number, wishlistId: number) => Promise<AllRows>;
21
19
  deleteWishlist: (userId: number, wishlistId: number) => Promise<void>;
22
20
  addWishlistItems: (userId: number, wishlistId: number, items: {
23
21
  invMastUid: number;
24
22
  }[]) => Promise<unknown>;
25
23
  removeWishlistItem: (userId: number, wishlistId: number, lineId: number) => Promise<void>;
26
24
  }
27
- /** Creates server-side wishlist actions with Redis caching and edge cache support. */
25
+ /** Creates server-side wishlist actions: every read pages to the end and is never cached. */
28
26
  export declare function createWishlistActions(api: WishlistsApiClient, config?: WishlistActionsConfig): WishlistActions;
29
27
  //# sourceMappingURL=wishlists.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wishlists.d.ts","sourceRoot":"","sources":["../../src/actions/wishlists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9D,sEAAsE;AACtE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IACpC,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACtD,cAAc,EAAE,CACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,KACzC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,E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AqD;IACrD,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5E,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,gBAAgB,EAAE,CAChB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,KAC5B,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3F;AAED,6FAA6F;AAC7F,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,kBAAkB,EACvB,MAAM,GAAE,qBAA0B,GACjC,eAAe,CAsDjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"api-handler.d.ts","sourceRoot":"","sources":["../src/api-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAyBH;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,KACrB,KAAK,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CA+B/C"}
1
+ {"version":3,"file":"api-handler.d.ts","sourceRoot":"","sources":["../src/api-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA2BH;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,KACrB,KAAK,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAiC/C"}
package/dist/api.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  queryAction,
3
3
  queryActionRaw
4
- } from "./chunk-FIM6LDMD.js";
4
+ } from "./chunk-GJHQPBK7.js";
5
5
  import {
6
6
  answersFullOf,
7
7
  apiMessageOf,
@@ -9,7 +9,8 @@ import {
9
9
  bodyOutcomeOf,
10
10
  isCrossOrigin,
11
11
  runsOf
12
- } from "./chunk-6GPKXGPG.js";
12
+ } from "./chunk-Z53NEFEQ.js";
13
+ import "./chunk-V76GZZF3.js";
13
14
 
14
15
  // src/api-handler.ts
15
16
  function refusal(outcome) {
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api-handler.ts"],"sourcesContent":["/**\n * Generic API route handler for fetch-mode proxy.\n *\n * Exposes the existing queryAction as an HTTP POST endpoint so that\n * `createFetchQueryAction()` from augur-core can route calls through\n * fetch() instead of server actions. This is needed on platforms where\n * server actions cannot access request cookies (e.g., CF Workers via OpenNext).\n *\n * The handler validates same-origin requests via the Sec-Fetch-Site header\n * (set by browsers automatically and cannot be forged by scripts).\n */\n\nimport { queryAction, queryActionRaw } from \"./query-action\";\nimport {\n answersFullOf,\n apiMessageOf,\n apiStatusOf,\n bodyOutcomeOf,\n isCrossOrigin,\n runsOf,\n type ApiOutcome,\n} from \"./rules\";\n\n/** A refused request's response: the outcome's text and status. */\nfunction refusal(outcome: ApiOutcome): Response {\n return new Response(apiMessageOf(outcome), { status: apiStatusOf(outcome) });\n}\n\n/** Request body shape for the API handler; `raw: true` asks for the full response. */\ninterface AugurApiRequestBody {\n methodPath: string;\n args: unknown[];\n raw?: unknown;\n}\n\n/**\n * Creates a Next.js Route Handler that routes method calls through queryAction, or through\n * queryActionRaw when the body has `raw: true` (augur-core's `createFetchQueryActionRaw`).\n *\n * @example\n * ```ts\n * // app/api/augur/route.ts\n * import { createAugurApiHandler } from \"@simpleapps-com/augur-server/api\";\n *\n * const handler = createAugurApiHandler();\n * export const POST = handler;\n * ```\n */\nexport function createAugurApiHandler() {\n return async (req: Request): Promise<Response> => {\n // Same-origin validation: Sec-Fetch-Site is set by browsers and\n // cannot be forged by JavaScript. Reject cross-origin requests.\n if (isCrossOrigin(req.headers.get(\"sec-fetch-site\") ?? \"\")) return refusal(\"forbidden\");\n\n let body: AugurApiRequestBody;\n try {\n body = (await req.json()) as AugurApiRequestBody;\n } catch {\n return refusal(\"bad-json\");\n }\n\n const { methodPath, args, raw } = body;\n const outcome = bodyOutcomeOf(\n true,\n typeof methodPath === \"string\" && methodPath !== \"\",\n Array.isArray(args),\n raw === true,\n );\n if (!runsOf(outcome)) return refusal(outcome);\n\n try {\n const result = answersFullOf(outcome)\n ? await queryActionRaw(methodPath, ...args)\n : await queryAction(methodPath, ...args);\n return Response.json(result);\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Internal server error\";\n return new Response(message, { status: 500 });\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAS,QAAQ,SAA+B;AAC9C,SAAO,IAAI,SAAS,aAAa,OAAO,GAAG,EAAE,QAAQ,YAAY,OAAO,EAAE,CAAC;AAC7E;AAsBO,SAAS,wBAAwB;AACtC,SAAO,OAAO,QAAoC;AAGhD,QAAI,cAAc,IAAI,QAAQ,IAAI,gBAAgB,KAAK,EAAE,EAAG,QAAO,QAAQ,WAAW;AAEtF,QAAI;AACJ,QAAI;AACF,aAAQ,MAAM,IAAI,KAAK;AAAA,IACzB,QAAQ;AACN,aAAO,QAAQ,UAAU;AAAA,IAC3B;AAEA,UAAM,EAAE,YAAY,MAAM,IAAI,IAAI;AAClC,UAAM,UAAU;AAAA,MACd;AAAA,MACA,OAAO,eAAe,YAAY,eAAe;AAAA,MACjD,MAAM,QAAQ,IAAI;AAAA,MAClB,QAAQ;AAAA,IACV;AACA,QAAI,CAAC,OAAO,OAAO,EAAG,QAAO,QAAQ,OAAO;AAE5C,QAAI;AACF,YAAM,SAAS,cAAc,OAAO,IAChC,MAAM,eAAe,YAAY,GAAG,IAAI,IACxC,MAAM,YAAY,YAAY,GAAG,IAAI;AACzC,aAAO,SAAS,KAAK,MAAM;AAAA,IAC7B,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,aAAO,IAAI,SAAS,SAAS,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/api-handler.ts"],"sourcesContent":["/**\n * Generic API route handler for fetch-mode proxy.\n *\n * Exposes the existing queryAction as an HTTP POST endpoint so that\n * `createFetchQueryAction()` from augur-core can route calls through\n * fetch() instead of server actions. This is needed on platforms where\n * server actions cannot access request cookies (e.g., CF Workers via OpenNext).\n *\n * The handler validates same-origin requests via the Sec-Fetch-Site header\n * (set by browsers automatically and cannot be forged by scripts).\n */\n\nimport type { AugurAPI } from \"@simpleapps-com/augur-api\";\nimport type { MethodPath } from \"@simpleapps-com/augur-core\";\nimport { queryAction, queryActionRaw } from \"./query-action\";\nimport {\n answersFullOf,\n apiMessageOf,\n apiStatusOf,\n bodyOutcomeOf,\n isCrossOrigin,\n runsOf,\n type ApiOutcome,\n} from \"./rules\";\n\n/** A refused request's response: the outcome's text and status. */\nfunction refusal(outcome: ApiOutcome): Response {\n return new Response(apiMessageOf(outcome), { status: apiStatusOf(outcome) });\n}\n\n/** Request body shape for the API handler; `raw: true` asks for the full response. */\ninterface AugurApiRequestBody {\n methodPath: string;\n args: unknown[];\n raw?: unknown;\n}\n\n/**\n * Creates a Next.js Route Handler that routes method calls through queryAction, or through\n * queryActionRaw when the body has `raw: true` (augur-core's `createFetchQueryActionRaw`).\n *\n * @example\n * ```ts\n * // app/api/augur/route.ts\n * import { createAugurApiHandler } from \"@simpleapps-com/augur-server/api\";\n *\n * const handler = createAugurApiHandler();\n * export const POST = handler;\n * ```\n */\nexport function createAugurApiHandler() {\n return async (req: Request): Promise<Response> => {\n // Same-origin validation: Sec-Fetch-Site is set by browsers and\n // cannot be forged by JavaScript. Reject cross-origin requests.\n if (isCrossOrigin(req.headers.get(\"sec-fetch-site\") ?? \"\")) return refusal(\"forbidden\");\n\n let body: AugurApiRequestBody;\n try {\n body = (await req.json()) as AugurApiRequestBody;\n } catch {\n return refusal(\"bad-json\");\n }\n\n const { methodPath, args, raw } = body;\n const outcome = bodyOutcomeOf(\n true,\n typeof methodPath === \"string\" && methodPath !== \"\",\n Array.isArray(args),\n raw === true,\n );\n if (!runsOf(outcome)) return refusal(outcome);\n\n try {\n // The path arrives in a request, so it has no literal type: typed as any method path, its\n // arguments are unknown[] (atlas#103), and the allowlist checks it at runtime\n const result = answersFullOf(outcome)\n ? await queryActionRaw(methodPath, ...args)\n : await queryAction(methodPath as MethodPath<AugurAPI>, ...args);\n return Response.json(result);\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Internal server error\";\n return new Response(message, { status: 500 });\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,SAAS,QAAQ,SAA+B;AAC9C,SAAO,IAAI,SAAS,aAAa,OAAO,GAAG,EAAE,QAAQ,YAAY,OAAO,EAAE,CAAC;AAC7E;AAsBO,SAAS,wBAAwB;AACtC,SAAO,OAAO,QAAoC;AAGhD,QAAI,cAAc,IAAI,QAAQ,IAAI,gBAAgB,KAAK,EAAE,EAAG,QAAO,QAAQ,WAAW;AAEtF,QAAI;AACJ,QAAI;AACF,aAAQ,MAAM,IAAI,KAAK;AAAA,IACzB,QAAQ;AACN,aAAO,QAAQ,UAAU;AAAA,IAC3B;AAEA,UAAM,EAAE,YAAY,MAAM,IAAI,IAAI;AAClC,UAAM,UAAU;AAAA,MACd;AAAA,MACA,OAAO,eAAe,YAAY,eAAe;AAAA,MACjD,MAAM,QAAQ,IAAI;AAAA,MAClB,QAAQ;AAAA,IACV;AACA,QAAI,CAAC,OAAO,OAAO,EAAG,QAAO,QAAQ,OAAO;AAE5C,QAAI;AAGF,YAAM,SAAS,cAAc,OAAO,IAChC,MAAM,eAAe,YAAY,GAAG,IAAI,IACxC,MAAM,YAAY,YAAoC,GAAG,IAAI;AACjE,aAAO,SAAS,KAAK,MAAM;AAAA,IAC7B,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,aAAO,IAAI,SAAS,SAAS,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
package/dist/auth.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  createAuthConfig
3
- } from "./chunk-KSGH4DXD.js";
4
- import "./chunk-6GPKXGPG.js";
3
+ } from "./chunk-4JPJQHT6.js";
4
+ import "./chunk-Z53NEFEQ.js";
5
+ import "./chunk-V76GZZF3.js";
5
6
  export {
6
7
  createAuthConfig
7
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"redis-client.d.ts","sourceRoot":"","sources":["../../src/cache/redis-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,aAAa,CAAC;AAgHnD;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcpE;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAYxF;AAED,iDAAiD;AACjD,wBAAgB,eAAe,IAAI,QAAQ,GAAG,MAAM,CAEnD;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C"}
1
+ {"version":3,"file":"redis-client.d.ts","sourceRoot":"","sources":["../../src/cache/redis-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,aAAa,CAAC;AAoHnD;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcpE;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAYxF;AAED,iDAAiD;AACjD,wBAAgB,eAAe,IAAI,QAAQ,GAAG,MAAM,CAEnD;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C"}
@@ -0,0 +1,21 @@
1
+ import type { Millis } from "../duration";
2
+ /**
3
+ * The Redis URL: a container's `REDIS_SERVERS` first (as `redis://<servers>`), else the
4
+ * environment's own variable (dev, staging, else production); none when that one is unset.
5
+ *
6
+ * @ensures exactly the model's RedisUrl
7
+ */
8
+ export declare function redisUrl(servers: string, isDev: boolean, isStaging: boolean, dev: string | undefined, staging: string | undefined, prod: string | undefined): string | undefined;
9
+ /** Debug logging is on in development and staging. */
10
+ export declare function debugEnabled(isDev: boolean, isStaging: boolean): boolean;
11
+ /** The circuit was open when it had an end time (0 is closed). */
12
+ export declare function wasOpen(openUntil: Millis): boolean;
13
+ /** The circuit just closed: it was open and the check found it closed (worth a log line). */
14
+ export declare function justClosed(wasOpenBefore: boolean, open: boolean): boolean;
15
+ /** The circuit's state as `getCircuitState` reports it. */
16
+ export declare function circuitLabel(open: boolean): string;
17
+ /** The client is ready for commands. */
18
+ export declare function isReady(status: string): boolean;
19
+ /** A cache read hit: Redis returned a stored text (`null` is a miss). */
20
+ export declare function isHit(cached: string | null): boolean;
21
+ //# sourceMappingURL=redis-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-rules.d.ts","sourceRoot":"","sources":["../../src/cache/redis-rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAO1C;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,OAAO,EAClB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,MAAM,GAAG,SAAS,CAUpB;AAED,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAIxE;AAED,kEAAkE;AAClE,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAIlD;AAED,6FAA6F;AAC7F,wBAAgB,UAAU,CAAC,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAIzE;AAED,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAKlD;AAED,wCAAwC;AACxC,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAI/C;AAED,yEAAyE;AACzE,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAIpD"}
@@ -0,0 +1,39 @@
1
+ import { type EdgeCacheValue, type ListResult } from "@simpleapps-com/augur-core";
2
+ import type { Seconds } from "../duration";
3
+ import { type ReadSpec } from "../actions/read-specs";
4
+ /**
5
+ * A factory's cache values. Each factory fills it from its own config (site.ts gives the short
6
+ * and long values; vmi adds `shortRedisTtl`).
7
+ */
8
+ export interface SpecReadConfig {
9
+ cachePrefix?: string;
10
+ edgeCache?: EdgeCacheValue;
11
+ longEdgeCache?: EdgeCacheValue;
12
+ redisTtl?: Seconds;
13
+ longRedisTtl?: Seconds;
14
+ shortRedisTtl?: Seconds;
15
+ }
16
+ /** Every row of a list read, its count, and whether the page cap stopped it. */
17
+ export type AllRows<T = unknown> = ListResult<T> & {
18
+ capReached: boolean;
19
+ };
20
+ /** The SDK client a factory holds: read by path, never by a hand-written chain. */
21
+ type SdkClient = object;
22
+ /**
23
+ * One action read (atlas#102): cached under the spec's key path with its tier's Redis TTL, which
24
+ * `withServerCache` turns to none on a path the server never caches (proved `readThroughTtl`).
25
+ * `shape` turns the SDK's answer into the action's value inside the cache.
26
+ *
27
+ * @param args The call's positional arguments, before its params object.
28
+ * @param params The call's params object, or undefined when the route takes none.
29
+ * @param keyArgs What the cache key hashes.
30
+ */
31
+ export declare function specRead<T>(api: SdkClient, spec: ReadSpec, config: SpecReadConfig, args: unknown[], params: Record<string, unknown> | undefined, keyArgs: unknown[], shape: (answer: unknown) => T): Promise<T>;
32
+ /** `shape` for a list read: the SDK's envelope as a ListResult (every row for an "all" read). */
33
+ export declare function asList<T>(answer: unknown): ListResult<T>;
34
+ /** `shape` for an "all" read that keeps the cap flag. */
35
+ export declare function asAllRows<T>(answer: unknown): AllRows<T>;
36
+ /** `shape` for a one-record read: the envelope's `data`. */
37
+ export declare function asData<T>(answer: unknown): T;
38
+ export {};
39
+ //# sourceMappingURL=spec-read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-read.d.ts","sourceRoot":"","sources":["../../src/cache/spec-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,UAAU,EAChB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAOL,KAAK,QAAQ,EACd,MAAM,uBAAuB,CAAC;AAK/B;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,gFAAgF;AAChF,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3E,mFAAmF;AACnF,KAAK,SAAS,GAAG,MAAM,CAAC;AAqExB;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,OAAO,EAAE,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,OAAO,EAAE,OAAO,EAAE,EAClB,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,CAAC,GAC5B,OAAO,CAAC,CAAC,CAAC,CASZ;AAED,iGAAiG;AACjG,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,CAExD;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAExD;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,CAE5C"}
@@ -8,10 +8,10 @@ import type { Seconds } from "../duration";
8
8
  * @param fn The async function to cache.
9
9
  * @param keyArgs Values to hash for the cache key.
10
10
  */
11
- export declare function withServerCache<T>(prefix: string, redisTtl: Seconds | undefined, methodPath: string, fn: () => Promise<T>, ...keyArgs: unknown[]): Promise<T>;
11
+ export declare const withServerCache: <T>(prefix: string, redisTtl: Seconds | undefined, methodPath: string, fn: () => Promise<T>, ...keyArgs: unknown[]) => Promise<T>;
12
12
  /**
13
13
  * Caches a raw SDK result (the envelope as returned), in its own key space: the same
14
14
  * parameters as {@link withServerCache}.
15
15
  */
16
- export declare function withRawSdkCache<T>(prefix: string, redisTtl: Seconds | undefined, methodPath: string, fn: () => Promise<T>, ...keyArgs: unknown[]): Promise<T>;
16
+ export declare const withRawSdkCache: <T>(prefix: string, redisTtl: Seconds | undefined, methodPath: string, fn: () => Promise<T>, ...keyArgs: unknown[]) => Promise<T>;
17
17
  //# sourceMappingURL=with-cache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"with-cache.d.ts","sourceRoot":"","sources":["../../src/cache/with-cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAqD3C;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,GAAG,SAAS,EAC7B,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,GAAG,OAAO,EAAE,OAAO,EAAE,GACpB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,GAAG,SAAS,EAC7B,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,GAAG,OAAO,EAAE,OAAO,EAAE,GACpB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
1
+ {"version":3,"file":"with-cache.d.ts","sourceRoot":"","sources":["../../src/cache/with-cache.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA6E3C;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GApBG,CAAC,UACpB,MAAM,YACJ,OAAO,GAAG,SAAS,cACjB,MAAM,MACd,MAAM,OAAO,CAAC,CAAC,CAAC,cACR,OAAO,EAAE,KACpB,OAAO,CAAC,CAAC,CAc2C,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,eAAe,GA1BG,CAAC,UACpB,MAAM,YACJ,OAAO,GAAG,SAAS,cACjB,MAAM,MACd,MAAM,OAAO,CAAC,CAAC,CAAC,cACR,OAAO,EAAE,KACpB,OAAO,CAAC,CAAC,CAoB8C,CAAC"}
@@ -2,7 +2,7 @@ import {
2
2
  getCrossSite,
3
3
  signInTarget,
4
4
  verifiedFlag
5
- } from "./chunk-6GPKXGPG.js";
5
+ } from "./chunk-Z53NEFEQ.js";
6
6
 
7
7
  // src/auth.ts
8
8
  import Credentials from "next-auth/providers/credentials";
@@ -171,4 +171,4 @@ function createAuthConfig(options) {
171
171
  export {
172
172
  createAuthConfig
173
173
  };
174
- //# sourceMappingURL=chunk-KSGH4DXD.js.map
174
+ //# sourceMappingURL=chunk-4JPJQHT6.js.map
@@ -14,7 +14,7 @@ import {
14
14
  scopedPrefix,
15
15
  sessionCookieName,
16
16
  usesCache
17
- } from "./chunk-6GPKXGPG.js";
17
+ } from "./chunk-Z53NEFEQ.js";
18
18
 
19
19
  // src/query-action.ts
20
20
  import {
@@ -22,7 +22,9 @@ import {
22
22
  stripEdgeCacheForNoCachePaths,
23
23
  unwrapBaseResponse
24
24
  } from "@simpleapps-com/augur-core";
25
- import { isSiteId } from "@simpleapps-com/augur-api";
25
+ import {
26
+ isSiteId
27
+ } from "@simpleapps-com/augur-api";
26
28
  var SECURE_COOKIE = "__Secure-authjs.session-token";
27
29
  var _decode;
28
30
  var _cookies;
@@ -185,4 +187,4 @@ export {
185
187
  queryActionRawWith,
186
188
  resetSessionImports
187
189
  };
188
- //# sourceMappingURL=chunk-FIM6LDMD.js.map
190
+ //# sourceMappingURL=chunk-GJHQPBK7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/query-action.ts"],"sourcesContent":["// \"use server\" banner is injected by tsup at build time.\n// Isolated server action for the proxy pattern.\n// This file MUST NOT import from server-actions.ts, server-site-registry.ts,\n// cache/, or any factory. It imports only from lightweight stores with zero\n// deps, the proved pure `rules` (with @atlas/utils' string scans, bundled), plus augur-core\n// and augur-api's `isSiteId` (both external in tsup — not bundled into chunks; every site\n// already loads the SDK on the server).\n// Dynamic imports of next/headers and next-auth/jwt are used for session\n// credential resolution (both are external in tsup).\n\nimport {\n getSdkClientOrNull,\n getSdkCallWrapper,\n getAuthSecret,\n getCrossSite,\n getOrCreateScopedClient,\n getScopedCacheWrapper,\n parseMethodPath,\n type SessionCredentials,\n type ApprovedMethodPath,\n type SdkCallWrapper,\n type ScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport {\n isReadMethod,\n stripEdgeCacheForNoCachePaths,\n unwrapBaseResponse,\n type MethodArgs,\n type MethodData,\n type MethodPath,\n} from \"@simpleapps-com/augur-core\";\nimport {\n isSiteId,\n type AugurAPI,\n type BaseResponse,\n type CallOptions,\n} from \"@simpleapps-com/augur-api\";\nimport {\n clientFor,\n clientIdSiteIdOf,\n mintedCredentials,\n readsSession,\n resolutionOf,\n scopedPrefix,\n sessionCookieName,\n usesCache,\n} from \"./rules\";\n\n/** Auth.js v5's HTTPS session cookie; sessionCookieName (rules.ts) picks it or the plain one. */\nconst SECURE_COOKIE = \"__Secure-authjs.session-token\";\n\n/** Simplified function types for lazy-loaded external deps. */\ntype DecodeFn = (params: {\n token?: string;\n secret: string | string[];\n salt: string;\n}) => Promise<Record<string, unknown> | null>;\ntype CookiesFn = () => Promise<{ get: (name: string) => { value: string } | undefined }>;\ntype DecodeJwtFn = (token: string) => Record<string, unknown>;\n\n/** Cached dynamic imports for next-auth/jwt decode, next/headers cookies, and jose decodeJwt. */\nlet _decode: DecodeFn | null | undefined;\nlet _cookies: CookiesFn | null | undefined;\nlet _decodeJwt: DecodeJwtFn | null | undefined;\n\n/** Lazy-load decode, cookies, and decodeJwt functions from external deps. Cached after first call. */\nasync function ensureImports(): Promise<boolean> {\n if (_decode === undefined) {\n try {\n const mod = await import(\"next-auth/jwt\");\n _decode = mod.decode as unknown as DecodeFn;\n } catch {\n // next-auth is an optional peer: without it there are no session credentials\n _decode = null;\n }\n }\n if (_cookies === undefined) {\n try {\n const mod = await import(\"next/headers\");\n _cookies = mod.cookies as unknown as CookiesFn;\n } catch {\n // outside Next.js there is no request cookie store\n _cookies = null;\n }\n }\n if (_decodeJwt === undefined) {\n try {\n const mod = await import(\"jose\");\n _decodeJwt = mod.decodeJwt as unknown as DecodeJwtFn;\n } catch {\n // jose is an optional peer: without it the bearer cannot be cross-checked\n _decodeJwt = null;\n }\n }\n return !!_decode && !!_cookies && !!_decodeJwt;\n}\n\n/** Read and decode the Auth.js session JWT from request cookies. */\nasync function decodeSessionJwt(secret: string): Promise<Record<string, unknown> | null> {\n const cookieStore = await _cookies!();\n const secureCookie = cookieStore.get(SECURE_COOKIE);\n // The proved rule (rules.ts, AugurServer.SessionCookieName): the HTTPS cookie when present,\n // else the plain one; its name is the salt\n const name = sessionCookieName(Boolean(secureCookie));\n const cookie = secureCookie ?? cookieStore.get(name);\n if (!cookie?.value) return null;\n\n return _decode!({ token: cookie.value, secret, salt: name });\n}\n\n/**\n * Extract the siteId portion of an Augur bearer token's `client_id` claim.\n * Bearer tokens are JWTs whose payload contains `client_id: \"<numeric>|<siteId>\"`.\n * Returns null on any parse failure or unexpected shape.\n *\n * Uses jose.decodeJwt (no signature verification) — we trust the bearer\n * because the *outer* Auth.js cookie's signature was just verified upstream,\n * so the bearer's contents are trusted as session-issued. This check guards\n * against internal inconsistency between the session's `targetSiteId` and the\n * bearer's scope, not against a forged bearer (the auth provider's signature\n * does that).\n */\nfunction parseBearerClientSiteId(bearer: string): string | null {\n try {\n const payload = _decodeJwt!(bearer);\n const clientId = payload[\"client_id\"];\n if (typeof clientId !== \"string\") return null;\n return clientIdSiteIdOf(clientId);\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve session credentials from the Auth.js JWT cookie.\n *\n * Trust-boundary mint point: this is the only function in the package that\n * produces {@link SessionCredentials} values. Bytes from a cookie become\n * typed, paired credentials here and only here. No other production code\n * constructs the branded pair, so a `SessionCredentials` that came through\n * this mint is JWT-validated and internally consistent. The brand is not\n * enforced by the compiler: an `as SessionCredentials` cast compiles (tests\n * do it), so audit casts (see \"Brand strength\" below).\n *\n * Returns null when:\n * - the site did not opt in to cross-site sessions (`createServerSite`'s\n * `auth: { crossSite: true }`, atlas#105): then nothing is imported and no\n * cookie is read, so pages using queryAction can render statically\n * - no AUTH_SECRET is configured\n * - next-auth/jwt, next/headers, or jose cannot be loaded\n * - no session cookie is present\n * - the JWT decode fails or returns null\n * - the decoded payload is missing `targetSiteId` or `token`, or either is\n * not a non-empty string (refuse to mint partial credentials)\n * - `targetSiteId` fails augur-api's `isSiteId` (`[a-z0-9_-]+`): siteIds are\n * lowercase by convention, and the scoped-client key's injectivity proof\n * (`scoped-client-key.ts`) needs a NUL-free siteId\n * - the bearer token's `client_id` siteId portion does not match\n * `targetSiteId` (defense-in-depth: refuses internally inconsistent sessions\n * before they reach the augur-api authority check)\n *\n * ## Verified preconditions for `result = some c`\n *\n * AUTH_SECRET configured\n * next-auth/jwt, next/headers, jose all loadable\n * session cookie present and decodable with the secret\n * typeof jwt.targetSiteId === \"string\" ∧ isSiteId(jwt.targetSiteId) // implies non-empty\n * typeof jwt.token === \"string\" ∧ jwt.token.length > 0\n * bearerClientSiteId(jwt.token) = some jwt.targetSiteId\n *\n * Lean equivalent: each clause becomes a `requires` on the function;\n * `result = none` is the disjunction of any failing.\n * F* equivalent: refinement on the option payload covering the\n * conjunction of these clauses.\n *\n * The bearer cross-check (`bearerClientSiteId(jwt.token) = some jwt.targetSiteId`)\n * is the substantive runtime invariant: it refuses sessions where the bearer's\n * encoded `client_id` siteId disagrees with the session's targetSiteId,\n * catching internal-inconsistency bugs before the call reaches augur-api.\n *\n * ## By construction (not independently verified)\n *\n * c.siteId === jwt.targetSiteId (assigned, not checked)\n * c.token === jwt.token (assigned, not checked)\n *\n * ## Brand strength\n *\n * `SessionCredentials` is a TS-level brand: there is no runtime tag on the\n * value. `value as SessionCredentials` casts compile, so the brand is a\n * code-review signal (audit `as SessionCredentials` usages — there should be\n * exactly one, in this function), not a hard type-system gate.\n */\nasync function getSessionCredentials(): Promise<SessionCredentials | null> {\n const secret = getAuthSecret();\n // Only an opted-in site with a secret looks for a session (rules.readsSession, atlas#105):\n // every other site returns here, before next/headers is imported or cookies() read, so its\n // pages can render statically.\n if (!readsSession(getCrossSite(), Boolean(secret))) return null;\n if (!(await ensureImports())) return null;\n\n try {\n // readsSession held, so the secret is present (Boolean(secret) above).\n const decoded = await decodeSessionJwt(secret as string);\n if (!decoded) return null;\n\n const targetSiteId = decoded[\"targetSiteId\"];\n const token = decoded[\"token\"];\n\n if (typeof targetSiteId !== \"string\" || typeof token !== \"string\") return null;\n\n // An empty or undecodable token has no client_id siteId (\"\").\n const bearerSiteId = parseBearerClientSiteId(token) ?? \"\";\n const mint = mintedCredentials(isSiteId(targetSiteId), targetSiteId, token, bearerSiteId);\n if (mint.kind === \"refused\") return null;\n\n return { siteId: mint.siteId, token: mint.token } as unknown as SessionCredentials;\n } catch {\n // Not in a request context (build time, tests), or decode failed\n }\n\n return null;\n}\n\n/**\n * Discriminated result of client resolution.\n *\n * Encodes two structural invariants at the type level:\n *\n * 1. session credentials exist iff this is the scoped path\n * (only `kind: \"scoped\"` carries `credentials`)\n * 2. a usable client exists iff this is NOT the uninit path\n * (`kind: \"scoped\" | \"global\"` always carry `client: object`)\n *\n * The `client: object` constraint replaces the previous `client: unknown` +\n * runtime null check. Anything narrowed to `kind: \"scoped\"` or `kind: \"global\"`\n * is guaranteed by the type system to have a non-null, traversable client —\n * downstream code that walks the SDK namespace path cannot accidentally\n * dereference null. The runtime check moves into `resolveClient` itself, where\n * `kind: \"uninit\"` is constructed when neither a scoped nor a global client is\n * available.\n *\n * Downstream code that wants to derive a cache prefix can only do so on the\n * scoped variant, and only from the credentials carried by that variant —\n * there is no way to construct a cache prefix from a different source without\n * crossing into the type.\n */\ntype ClientResolution =\n | { kind: \"scoped\"; client: object; credentials: SessionCredentials }\n | { kind: \"global\"; client: object }\n | { kind: \"uninit\" };\n\n/**\n * Resolve the SDK client for this request.\n *\n * - If the session JWT validates and a scoped client can be minted, returns\n * the scoped variant carrying the {@link SessionCredentials} that produced\n * the client. The cache prefix is derived at the use site from\n * `credentials.siteId`, structurally guaranteeing it matches the credentials\n * under which the SDK call is made.\n * - Otherwise returns the global variant. No credentials, no cache prefix.\n *\n * The previous return shape `{ client, cachePrefix: string | null }` made\n * \"cachePrefix exists iff scoped\" a runtime invariant; the tagged union\n * promotes it to a type-level one.\n */\nasync function resolveClient(): Promise<ClientResolution> {\n const creds = await getSessionCredentials();\n const scoped = creds ? getOrCreateScopedClient(creds) : null;\n const globalClient = getSdkClientOrNull();\n const kind = resolutionOf(creds !== null, isObject(scoped), isObject(globalClient));\n if (kind === \"scoped\") return { kind, client: scoped as object, credentials: creds! };\n if (kind === \"global\") return { kind, client: globalClient as object };\n return { kind };\n}\n\n/** A usable client: a non-null object. */\nfunction isObject(value: unknown): boolean {\n return value !== null && typeof value === \"object\";\n}\n\n/** A client offering call options (`AugurAPI.withRequest`, atlas#106). */\ntype BoundableClient = { withRequest: (options: CallOptions) => object };\n\nfunction canBeBounded(client: object): client is BoundableClient {\n return typeof (client as Partial<BoundableClient>).withRequest === \"function\";\n}\n\n/**\n * The client a call runs on (rules.ts `clientFor`, AugurServer.ClientFor): the resolved client\n * with no options; its `withRequest` view with options; and a refusal when it has no\n * `withRequest`, since a call the caller asked to bound must never run unbounded.\n */\nfunction boundClient(client: object, options: CallOptions | undefined): object {\n const choice = clientFor(options !== undefined, canBeBounded(client));\n if (choice === \"client\") return client;\n if (choice === \"refuse\") {\n throw new Error(\n \"queryActionWith: the SDK client has no withRequest; call options need a \" +\n \"@simpleapps-com/augur-api release that has AugurAPI.withRequest.\",\n );\n }\n return (client as BoundableClient).withRequest(options!);\n}\n\n/**\n * Resolve a dot-separated method path on an object, returning the leaf function.\n *\n * Demands {@link ApprovedMethodPath} so callers must have run the path through\n * `parseMethodPath` first — passing an unvalidated string is a compile error.\n */\nfunction resolveMethod(\n client: unknown,\n methodPath: ApprovedMethodPath,\n): (...a: unknown[]) => Promise<unknown> {\n const segments = methodPath.split(\".\");\n\n let current: unknown = client;\n for (const segment of segments) {\n if (current == null || (typeof current !== \"object\" && typeof current !== \"function\")) {\n throw new Error(\n `Cannot resolve \"${methodPath}\": \"${segment}\" is not accessible on ${typeof current}`,\n );\n }\n current = (current as Record<string, unknown>)[segment];\n }\n\n if (typeof current !== \"function\") {\n throw new Error(`\"${methodPath}\" does not resolve to a function (got ${typeof current})`);\n }\n\n return current as (...a: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Bind a scoped cache wrapper to a fixed prefix, producing an `SdkCallWrapper`\n * with the same signature as the global wrapper.\n *\n * On the scoped queryAction path, the cache prefix is derived structurally\n * from the `SessionCredentials` that minted the client (`${credentials.siteId}:`).\n * Capturing that prefix in a closure here lets queryAction's call site treat\n * scoped and global wrappers uniformly — the only thing that differs between\n * them is which prefix gets baked in, and that decision happens in exactly one\n * place per request.\n *\n * Returns null when no scoped wrapper is registered, so the caller falls\n * through to the unwrapped SDK call. The closure preserves the cross-tenant\n * invariant: prefix is captured at bind time from the same credentials value\n * used to mint the scoped client, and cannot be replaced or re-sourced later.\n *\n * ## Property\n *\n * bindScopedPrefix(null, _) = null\n * bindScopedPrefix(w, p)(methodPath, fn, ...args) = w(p, methodPath, fn, ...args)\n *\n * The bound wrapper forwards faithfully — it adds nothing, drops nothing,\n * and reorders nothing. Every effect (cache read, cache write, SDK call)\n * happens inside the underlying scopedWrapper exactly as if queryAction had\n * called it directly with the prefix as the first argument.\n */\nfunction bindScopedPrefix(\n scopedWrapper: ScopedCacheWrapper | null,\n prefix: string,\n): SdkCallWrapper | null {\n if (!scopedWrapper) return null;\n return (methodPath, sdkCall, ...keyArgs) =>\n scopedWrapper(prefix, methodPath, sdkCall, ...keyArgs);\n}\n\n/**\n * The one SDK call behind the two server actions, `queryAction` (the\n * envelope's data) and `queryActionRaw` (the result as returned): routes\n * any SDK method call through the raw SDK client with optional Redis\n * caching. `queryAction` is used internally by `createServerQueryProxy()`\n * to bridge client-side React Query hooks to server-side API calls.\n *\n * For read methods (get, list, lookup, search, suggest), the call is\n * wrapped in the registered cache wrapper (Redis) if one was registered\n * by createServerSite(). Write methods bypass caching.\n *\n * When the request has an active session with targetSiteId + token\n * (from cross-site auth), the call uses a scoped SDK client with those\n * credentials. Redis caching uses targetSiteId as the cache prefix so\n * users managing the same site share cached data.\n *\n * This is the chokepoint: every B2B site without a client-side SDK\n * routes EVERY data access through this one function. The invariants\n * below are load-bearing across every site, every request, every user.\n *\n * ## Preconditions (enforced at runtime via thrown Error)\n *\n * parseMethodPath(methodPath) ≠ null\n * resolveClient().client ≠ null\n *\n * First clause: methodPath is a non-empty string AND — if an allowlist\n * has been registered via `registerAllowedMethodPaths` — methodPath is\n * in the allowlist. Assumes the site opted into surface restriction\n * when narrower-than-augur-api authority is desired; otherwise any\n * non-empty string passes (transparent forwarder default).\n *\n * Second clause: createServerSite() ran during bootstrap OR\n * AUGUR_SITE_ID + AUGUR_JWT env vars are set so the registry can\n * auto-init. Assumes the caller has bootstrapped one of the two paths.\n *\n * Lean equivalent: `requires path : ApprovedMethodPath ∧ client : SDKClient`.\n *\n * ## Cross-tenant cache-prefix invariant (load-bearing)\n *\n * resolution.kind = \"scoped\" ⟹ cachePrefix = `${resolution.credentials.siteId}:`\n *\n * On the scoped path the cache prefix is derived structurally from the\n * same `SessionCredentials` value that minted the scoped client — they\n * cannot be sourced separately. This makes \"siteId from session A\n * combined with token from session B\" or \"siteId X with cache prefix Y\"\n * unrepresentable here. Assumes `getSessionCredentials` performed the\n * bearer/session siteId cross-check at mint time; see the brand-strength\n * caveat on `SessionCredentials`.\n *\n * A regression here would silently leak cached data across tenants.\n * The structural derivation is the only thing standing between the\n * request and that leak — do not reintroduce a separate `cachePrefix`\n * parameter or compute it from anything other than `resolution.credentials`.\n *\n * ### Sibling assumption — bearer is NOT in the cache key\n *\n * The cross-tenant invariant covers cross-SITE leaks. It does NOT cover\n * intra-site cross-USER leaks: the cache key is `(siteId, methodPath, args)`\n * and the bearer token is intentionally absent. Two users with different\n * bearers on the same site share cached data for cacheable namespaces.\n *\n * This is a deliberate design choice. The assumption is:\n *\n * ∀ namespace ∉ NO_CACHE_PATHS, ∀ siteId, ∀ args.\n * augur-api(bearer_A, siteId, args) = augur-api(bearer_B, siteId, args)\n *\n * i.e. for cacheable namespaces, augur-api's response is bearer-independent\n * within a site. augur-api remains the auth authority; `NO_CACHE_PATHS`\n * (commerce.*, payments.*) is the carve-out for namespaces whose responses\n * ARE bearer-coupled. If a future namespace produces bearer-dependent\n * responses (e.g. user-specific permissions affecting query results), it\n * MUST be added to `NO_CACHE_PATHS` or the bearer MUST become part of the\n * cache key — otherwise this assumption silently produces a permission leak.\n *\n * ## No-edge-cache defense-in-depth (load-bearing)\n *\n * ∀ a ∈ safeArgs. methodPath ∈ NO_CACHE_PATHS ⟹ \"edgeCache\" ∉ keys(a)\n *\n * `stripEdgeCacheForNoCachePaths` removes the `edgeCache` key from every\n * first-level object arg when methodPath belongs to a no-cache namespace\n * (currently `commerce.*`, `payments.*`). The augur-api SDK transforms\n * `edgeCache` into a Cloudflare `cacheSiteId{N}` query param; removing\n * it here guarantees no CDN edge-caching of identity-bound responses\n * even if a caller passed one explicitly or a legacy factory injected\n * one. Assumes `NO_CACHE_PATHS` enumerates every namespace whose\n * responses must not cross identity boundaries.\n *\n * ## Postcondition — the SDK's result as returned\n *\n * result = raw (the SDK's result, from the call or the raw cache)\n *\n * Assumes upstream cache wrappers do NOT themselves unwrap — they\n * return whatever the SDK returned (the raw key space, #98), so\n * `queryAction` unwraps exactly once and `queryActionRaw` never does\n * (model: AugurServer.QueryResult).\n *\n * ## Effects\n *\n * @mutates Redis (write-through on read methods when a wrapper is registered)\n * @io augur-api SDK (network request)\n * @throws Error when the allowlist gate fails or no client is initialised\n */\nasync function callSdk(\n methodPath: string,\n args: unknown[],\n options?: CallOptions,\n): Promise<unknown> {\n const approvedPath = parseMethodPath(methodPath);\n if (approvedPath === null) {\n throw new Error(\n `queryAction: methodPath ${JSON.stringify(methodPath)} is not in the registered allowlist. ` +\n `Register it via registerAllowedMethodPaths() in createServerSite() config.`,\n );\n }\n\n const resolution = await resolveClient();\n if (resolution.kind === \"uninit\") {\n throw new Error(\n \"SDK client not initialized. Call createServerSite() or set AUGUR_SITE_ID + AUGUR_JWT env vars.\",\n );\n }\n\n // The options bound the call through the client's view; they are never SDK arguments and\n // never part of the cache key, which stays `safeArgs` (AugurServer.OptionsNeverInTheKey)\n const resolvedMethod = resolveMethod(boundClient(resolution.client, options), approvedPath);\n const leafName = approvedPath.split(\".\").pop()!;\n // Defense in depth: strip `edgeCache` from no-cache paths before the SDK\n // sees it. The augur-api SDK transforms `edgeCache` into a Cloudflare\n // `cacheSiteId{N}` query param; removing it here guarantees no CDN edge\n // caching of identity-bound responses even if a caller explicitly passed\n // one. Also keeps cache keys consistent with what is actually sent.\n const safeArgs = stripEdgeCacheForNoCachePaths(approvedPath, args);\n\n // Pick the wrapper for this resolution's prefix policy. On the scoped path,\n // the prefix is structurally derived from `credentials.siteId` and bound into\n // a closure here — bindScopedPrefix is the only call site that builds it,\n // and the prefix cannot be re-sourced after binding. On the global path, the\n // prefix is closed over by the SdkCallWrapper that createServerSite registered.\n // Both paths now produce a uniform `SdkCallWrapper | null`, so the caching\n // and uncached branches collapse into a single shape below.\n const wrapper: SdkCallWrapper | null =\n resolution.kind === \"scoped\"\n ? bindScopedPrefix(getScopedCacheWrapper(), scopedPrefix(resolution.credentials.siteId))\n : getSdkCallWrapper();\n\n if (usesCache(wrapper !== null, isReadMethod(leafName))) {\n return wrapper!(approvedPath, () => resolvedMethod(...safeArgs), ...safeArgs);\n }\n return resolvedMethod(...safeArgs);\n}\n\n/**\n * The SDK call `callSdk` makes (everything above), answered as its envelope's data.\n *\n * ## Postcondition — BaseResponse pass-through (exactly-once unwrap)\n *\n * result = unwrapBaseResponse(raw)\n * = raw.data when raw is { data, status, message }\n * = raw otherwise\n *\n * Consumers receive `T` directly when the SDK returns\n * `{ data: T, status, message }`, and the original value otherwise.\n * Double-unwrap (caller + queryAction) would silently strip a layer of\n * legitimate `{data, status, message}` user data when that shape happens\n * to round-trip through the API. The envelope's paging (`total`,\n * `totalResults`, `count`) is not in `data`: read it with `queryActionRaw`.\n *\n * ## Typed by path (atlas#103)\n *\n * The path is one of the SDK's method paths, the arguments that method's own, the result the\n * envelope's data (model AugurQueryTypes: `IsTypedPath`, `TypedArgs`, `TypedResult`), so an\n * unknown path or arguments that no longer match an upgraded SDK fail `tsc` instead of a live\n * request. The runtime is unchanged: the allowlist still checks every path.\n *\n * @param methodPath Dot-separated SDK method path (e.g. \"items.invMast.doc.get\")\n * @param args Arguments to pass to the resolved method\n * @returns The unwrapped result from the SDK method (possibly from Redis cache)\n */\nexport async function queryAction<P extends MethodPath<AugurAPI>>(\n methodPath: P,\n ...args: MethodArgs<AugurAPI, P>\n): Promise<MethodData<AugurAPI, P>> {\n // The value is what unwrapBaseResponse gives; its type is the model's TypedResult\n return unwrapBaseResponse(await callSdk(methodPath, args)) as MethodData<AugurAPI, P>;\n}\n\n/**\n * The same call as `queryAction` (allowlist, client, `edgeCache` strip, Redis), answered as\n * the SDK returned it: augur-api's `BaseResponse<T>` envelope (every SDK method's result) with\n * `data`, `total`, `totalResults` and `count`, so client code can page a list (atlas#107). A\n * method path carries no type, so the caller names `T` (`queryActionRaw<Article[]>(…)`). A\n * `queryAction` and a `queryActionRaw` of one call share one Redis entry.\n *\n * MUST NOT run under a React Query key that also holds `queryAction`'s shape (an options\n * proxy's `queryKey`): give it its own key.\n *\n * @param methodPath Dot-separated SDK method path (e.g. \"joomla.content.list\")\n * @param args Arguments to pass to the resolved method\n * @returns The SDK method's result unchanged (possibly from Redis cache)\n */\nexport async function queryActionRaw<T = unknown>(\n methodPath: string,\n ...args: unknown[]\n): Promise<BaseResponse<T>> {\n return callSdk(methodPath, args) as Promise<BaseResponse<T>>;\n}\n\n/**\n * `queryAction`, bounded (atlas#106): `options.deadline` caps the whole call in milliseconds\n * (every retry and the waits between them), and `options.signal` lets the caller cancel it. At\n * the deadline the call rejects with a `TimeoutError` (the request is cancelled, nothing more is\n * retried, nothing is cached), so a server render can fall back to a client-side fetch.\n *\n * Server code (an SSR render) SHOULD set a deadline: with none, the SDK's retry budget (3 retries\n * at 30 s each, plus backoff) becomes page latency. Called as a server action from the browser,\n * only `deadline` crosses: an `AbortSignal` can't be serialized.\n *\n * The options are not SDK arguments and not part of the cache key, so a bounded call and an\n * unbounded one share one Redis entry. Needs an `@simpleapps-com/augur-api` with\n * `AugurAPI.withRequest`; with an older client the call is refused rather than run unbounded.\n *\n * @example\n * ```ts\n * const items = await queryActionWith({ deadline: 5000 }, \"items.categories.items.list\", uid, params)\n * .catch(() => undefined); // past 5 s: render without them, fetch on the client\n * ```\n */\nexport async function queryActionWith<P extends MethodPath<AugurAPI>>(\n options: CallOptions,\n methodPath: P,\n ...args: MethodArgs<AugurAPI, P>\n): Promise<MethodData<AugurAPI, P>> {\n // Typed as queryAction (atlas#103); the value is what unwrapBaseResponse gives\n return unwrapBaseResponse(await callSdk(methodPath, args, options)) as MethodData<AugurAPI, P>;\n}\n/** `queryActionRaw`, bounded: the same options as {@link queryActionWith}. */\nexport async function queryActionRawWith<T = unknown>(\n options: CallOptions,\n methodPath: string,\n ...args: unknown[]\n): Promise<BaseResponse<T>> {\n return callSdk(methodPath, args, options) as Promise<BaseResponse<T>>;\n}\n\n/** Reset lazy-loaded imports. Used in tests only. @internal */\nexport function resetSessionImports(): void {\n _decode = undefined;\n _cookies = undefined;\n _decodeJwt = undefined;\n}\n\nexport { unwrapBaseResponse, getSessionCredentials, resolveMethod };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,OAIK;AAaP,IAAM,gBAAgB;AAYtB,IAAI;AACJ,IAAI;AACJ,IAAI;AAGJ,eAAe,gBAAkC;AAC/C,MAAI,YAAY,QAAW;AACzB,QAAI;AACF,YAAM,MAAM,MAAM,OAAO,eAAe;AACxC,gBAAU,IAAI;AAAA,IAChB,QAAQ;AAEN,gBAAU;AAAA,IACZ;AAAA,EACF;AACA,MAAI,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,QAAQ,YAAY,MAAM,OAAO,CAAC;AACpE;AAEA,eAAsB,mBACpB,SACA,eACG,MACuB;AAC1B,SAAO,QAAQ,YAAY,MAAM,OAAO;AAC1C;AAGO,SAAS,sBAA4B;AAC1C,YAAU;AACV,aAAW;AACX,eAAa;AACf;","names":[]}
@@ -0,0 +1,10 @@
1
+ // ../foundation/src/decimal.ts
2
+ function decimal(n) {
3
+ const last = "0123456789".slice(n % 10, n % 10 + 1);
4
+ return n < 10 ? last : decimal(Math.floor(n / 10)) + last;
5
+ }
6
+
7
+ export {
8
+ decimal
9
+ };
10
+ //# sourceMappingURL=chunk-JIYVQWXK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../foundation/src/decimal.ts"],"sourcesContent":["//@ backend dafny\n\n/* Verified with LemmaScript → Dafny (`pnpm proofs`; hand lemmas in decimal.dfy; model:\n models/Platform.dfy Decimal; link: models/links/foundation-decimal.dfy): how every app\n writes an id as text. Used by services/agr-int-mcp (customer grant ids `<site>|<usersUid>`) and\n packages/joomla-auth (staff grant ids `staff-<Joomla user id>`), so both are one-to-one\n by the same proof. */\n\n/**\n * The decimal digits of `n`, exactly what `String(n)` gives for a non-negative integer\n * (tests pin the two together). Recursive so specs can use it. Injective: different numbers\n * are written differently (lemma DecimalInjective, decimal.dfy; Platform.DecimalInjective).\n *\n * @ensures |result| ≥ 1 ∧ ∀ k < |result|. result[k] ∈ '0'..'9'\n */\nexport function decimal(n: number): string {\n //@ verify\n //@ type n nat\n //@ requires n >= 0\n //@ decreases n\n //@ ensures \\result.length > 0\n //@ ensures forall(k: nat, k < \\result.length ==> (\\result.charCodeAt(k) >= 48 && \\result.charCodeAt(k) <= 57))\n const last = \"0123456789\".slice(n % 10, (n % 10) + 1);\n return n < 10 ? last : decimal(Math.floor(n / 10)) + last;\n}\n\n/**\n * Any integer as `String(n)` writes it: a minus for a negative, then `decimal`'s digits\n * (tests pin it to `String` for safe integers). An id written this way can't change a path.\n *\n * @ensures result is digits, after a \"-\" exactly when n < 0 — never empty, so an id written\n * this way can't change a path; exactly the model's Platform.IntText in the link (a contract\n * naming `decimal` couldn't be resolved by an importer, models/LSC-GAPS.md, so importers that\n * need the exact text take the link's equality as a premise)\n */\nexport function intText(n: number): string {\n //@ verify\n //@ type n int\n //@ ensures \\result.length > 0\n //@ ensures n >= 0 ==> forall(k: nat, k < \\result.length ==> (\\result.charCodeAt(k) >= 48 && \\result.charCodeAt(k) <= 57))\n //@ ensures n < 0 ==> (\\result.length > 1 && \\result.charCodeAt(0) === 45 && forall(k: nat, (1 <= k && k < \\result.length) ==> (\\result.charCodeAt(k) >= 48 && \\result.charCodeAt(k) <= 57)))\n return n < 0 ? \"-\" + decimal(-n) : decimal(n);\n}\n"],"mappings":";AAeO,SAAS,QAAQ,GAAmB;AAOzC,QAAM,OAAO,aAAa,MAAM,IAAI,IAAK,IAAI,KAAM,CAAC;AACpD,SAAO,IAAI,KAAK,OAAO,QAAQ,KAAK,MAAM,IAAI,EAAE,CAAC,IAAI;AACvD;","names":[]}