@simpleapps-com/augur-server 2026.11.4 → 2026.11.6

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 (80) hide show
  1. package/EXPORTS.md +28 -1
  2. package/README.md +42 -14
  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.js +3 -2
  30. package/dist/api.js.map +1 -1
  31. package/dist/auth.js +3 -2
  32. package/dist/cache/redis-client.d.ts.map +1 -1
  33. package/dist/cache/redis-rules.d.ts +21 -0
  34. package/dist/cache/redis-rules.d.ts.map +1 -0
  35. package/dist/cache/spec-read.d.ts +39 -0
  36. package/dist/cache/spec-read.d.ts.map +1 -0
  37. package/dist/cache/with-cache.d.ts +2 -2
  38. package/dist/cache/with-cache.d.ts.map +1 -1
  39. package/dist/{chunk-WR7WT2FI.js → chunk-2RAKVFB5.js} +30 -9
  40. package/dist/chunk-2RAKVFB5.js.map +1 -0
  41. package/dist/{chunk-F7QWHMHH.js → chunk-4JPJQHT6.js} +2 -2
  42. package/dist/chunk-JIYVQWXK.js +10 -0
  43. package/dist/chunk-JIYVQWXK.js.map +1 -0
  44. package/dist/{chunk-34NCJS52.js → chunk-SFXO74RC.js} +874 -719
  45. package/dist/chunk-SFXO74RC.js.map +1 -0
  46. package/dist/chunk-V76GZZF3.js +66 -0
  47. package/dist/chunk-V76GZZF3.js.map +1 -0
  48. package/dist/{chunk-B4MGIUCU.js → chunk-Z53NEFEQ.js} +17 -16
  49. package/dist/chunk-Z53NEFEQ.js.map +1 -0
  50. package/dist/hooks.js +3 -2
  51. package/dist/hooks.js.map +1 -1
  52. package/dist/index.js +4 -2
  53. package/dist/index.js.map +1 -1
  54. package/dist/query-action.d.ts +24 -1
  55. package/dist/query-action.d.ts.map +1 -1
  56. package/dist/query-action.js +7 -2
  57. package/dist/read-rules.d.ts +45 -0
  58. package/dist/read-rules.d.ts.map +1 -0
  59. package/dist/rules.d.ts +16 -0
  60. package/dist/rules.d.ts.map +1 -1
  61. package/dist/server-site-registry.d.ts.map +1 -1
  62. package/dist/server-site.d.ts.map +1 -1
  63. package/dist/site.js +24 -14
  64. package/dist/site.js.map +1 -1
  65. package/dist/sitemap-rules.d.ts +154 -0
  66. package/dist/sitemap-rules.d.ts.map +1 -0
  67. package/dist/sitemap.d.ts +80 -0
  68. package/dist/sitemap.d.ts.map +1 -0
  69. package/dist/sitemap.js +242 -0
  70. package/dist/sitemap.js.map +1 -0
  71. package/dist/testing.js +4 -2
  72. package/dist/testing.js.map +1 -1
  73. package/dist/utils/read-all-pages.d.ts +17 -0
  74. package/dist/utils/read-all-pages.d.ts.map +1 -0
  75. package/llms.txt +54 -1
  76. package/package.json +9 -5
  77. package/dist/chunk-34NCJS52.js.map +0 -1
  78. package/dist/chunk-B4MGIUCU.js.map +0 -1
  79. package/dist/chunk-WR7WT2FI.js.map +0 -1
  80. /package/dist/{chunk-F7QWHMHH.js.map → chunk-4JPJQHT6.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAMlD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAShE;AAED,kEAAkE;AAClE,MAAM,MAAM,IAAI,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAE3F;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,GACnB,IAAI,CAQN;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,GAChB,OAAO,CAMT;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM/E;AAED,kCAAkC;AAClC,MAAM,MAAM,GAAG,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,KAAK,CACnB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAC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;AAgCD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAU5C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
1
+ {"version":3,"file":"server-site-registry.d.ts","sourceRoot":"","sources":["../src/server-site-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAelD;;;;;;;;;;;;;;;;GAgBG;AAEH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAE9D;AAuCD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAU5C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"server-site.d.ts","sourceRoot":"","sources":["../src/server-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,QAAQ,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAchD,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,IAAI,CAAC,EAAE,oBAAoB,CAAC;CAC7B;AAED,uDAAuD;AACvD,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,MAAM;IAC7C,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;CAClC;AAcD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,MAAM,EAAE,IAAI,EACZ,MAAM,GAAE,gBAAqB,GAC5B,UAAU,CAAC,IAAI,CAAC,CAmDlB"}
1
+ {"version":3,"file":"server-site.d.ts","sourceRoot":"","sources":["../src/server-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,QAAQ,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAehD,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,IAAI,CAAC,EAAE,oBAAoB,CAAC;CAC7B;AAED,uDAAuD;AACvD,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,MAAM;IAC7C,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;CAClC;AAcD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,MAAM,EAAE,IAAI,EACZ,MAAM,GAAE,gBAAqB,GAC5B,UAAU,CAAC,IAAI,CAAC,CAiElB"}
package/dist/site.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  createAuthConfig
3
- } from "./chunk-F7QWHMHH.js";
3
+ } from "./chunk-4JPJQHT6.js";
4
4
  import {
5
5
  createSiteActions,
6
6
  registerSiteActions,
7
+ serverTtlOf,
7
8
  withRawSdkCache
8
- } from "./chunk-34NCJS52.js";
9
+ } from "./chunk-SFXO74RC.js";
10
+ import "./chunk-JIYVQWXK.js";
9
11
  import {
10
12
  crossSiteOf,
11
13
  registerAuthSecret,
@@ -13,13 +15,13 @@ import {
13
15
  registerCrossSite,
14
16
  registerScopedCacheWrapper,
15
17
  registerSdkCallWrapper,
16
- registerSdkClient,
17
- ttlFor
18
- } from "./chunk-B4MGIUCU.js";
18
+ registerSdkClient
19
+ } from "./chunk-Z53NEFEQ.js";
20
+ import "./chunk-V76GZZF3.js";
19
21
 
20
22
  // src/server-site.ts
21
23
  import { hours } from "@simpleapps-com/augur-utils";
22
- import { getCacheTier } from "@simpleapps-com/augur-core";
24
+ import { getCacheTier, isP21Path } from "@simpleapps-com/augur-core";
23
25
  function registerSessionAuth(auth) {
24
26
  const authSecret = auth?.secret ?? process.env["AUTH_SECRET"];
25
27
  if (authSecret) {
@@ -32,16 +34,24 @@ function createServerSite(client, config = {}) {
32
34
  registerSiteActions(actions);
33
35
  registerSdkClient(client);
34
36
  const { cachePrefix = "", redisTtl = hours(1), longRedisTtl = hours(8) } = config;
35
- registerSdkCallWrapper((methodPath, sdkCall, ...keyArgs) => {
36
- const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);
37
- if (ttl === null) return sdkCall();
38
- return withRawSdkCache(cachePrefix, ttl, methodPath, sdkCall, ...keyArgs);
39
- });
40
- registerScopedCacheWrapper((prefix, methodPath, sdkCall, ...keyArgs) => {
41
- const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);
37
+ const cachedRaw = (prefix, methodPath, sdkCall, keyArgs) => {
38
+ const tier = getCacheTier(methodPath);
39
+ const ttl = serverTtlOf(
40
+ tier.redisTtl !== void 0,
41
+ isP21Path(methodPath),
42
+ tier.staleTime,
43
+ redisTtl,
44
+ longRedisTtl
45
+ );
42
46
  if (ttl === null) return sdkCall();
43
47
  return withRawSdkCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);
44
- });
48
+ };
49
+ registerSdkCallWrapper(
50
+ (methodPath, sdkCall, ...keyArgs) => cachedRaw(cachePrefix, methodPath, sdkCall, keyArgs)
51
+ );
52
+ registerScopedCacheWrapper(
53
+ (prefix, methodPath, sdkCall, ...keyArgs) => cachedRaw(prefix, methodPath, sdkCall, keyArgs)
54
+ );
45
55
  const baseConfig = client["config"];
46
56
  if (baseConfig) {
47
57
  const Ctor = client.constructor;
package/dist/site.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server-site.ts"],"sourcesContent":["import { hours } from \"@simpleapps-com/augur-utils\";\nimport { createSiteActions } from \"./actions/site\";\nimport type { SiteActionsConfig, SiteActions } from \"./actions/site\";\nimport { createAuthConfig } from \"./auth\";\nimport type { AugurAuthCallbacks, AugurAuthClient } from \"./auth\";\nimport type { NextAuthConfig } from \"next-auth\";\nimport { registerSiteActions } from \"./server-site-registry\";\nimport {\n registerSdkClient,\n registerSdkCallWrapper,\n registerAuthSecret,\n registerClientFactory,\n registerCrossSite,\n registerScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport { withRawSdkCache } from \"./cache/with-cache\";\nimport { crossSiteOf, ttlFor } from \"./rules\";\nimport { getCacheTier } from \"@simpleapps-com/augur-core\";\n\n/** Auth options forwarded to NextAuth when creating a server site. */\nexport interface ServerSiteAuthConfig {\n secret?: string;\n maxAge?: number;\n callbacks?: Partial<AugurAuthCallbacks>;\n debug?: boolean;\n /**\n * Cross-site sessions (the augur-support pattern: an augur_info client, and the target\n * `siteId` passed to `signIn`). Only when true does sign-in keep the target siteId and does\n * `queryAction` read the session cookie to use a client scoped to that site. Default off: a\n * site that does not set it never reads cookies in `queryAction`, so its pages can render\n * statically (atlas#105). A multi-tenant site MUST set it.\n */\n crossSite?: boolean;\n}\n\n/** Configuration for {@link createServerSite}, combining action config and auth. */\nexport interface ServerSiteConfig extends SiteActionsConfig {\n auth?: ServerSiteAuthConfig;\n}\n\n/** The object returned by {@link createServerSite}. */\nexport interface ServerSite<TApi extends object> {\n client: TApi;\n actions: SiteActions;\n auth: NextAuthConfig | undefined;\n}\n\n/**\n * Register what queryAction and sign-in need from `auth`: the secret (`auth.secret`, else\n * `AUTH_SECRET`) and the cross-site opt-in, the one source both read (atlas#105).\n */\nfunction registerSessionAuth(auth: ServerSiteAuthConfig | undefined): void {\n const authSecret = auth?.secret ?? process.env[\"AUTH_SECRET\"];\n if (authSecret) {\n registerAuthSecret(authSecret);\n }\n registerCrossSite(crossSiteOf(auth?.crossSite));\n}\n\n/**\n * Create a server-side site instance that bundles the SDK client, server\n * actions, and (optional) NextAuth configuration.\n *\n * @example\n * ```ts\n * import { AugurAPI } from \"@simpleapps-com/augur-api\";\n * import { createServerSite } from \"@simpleapps-com/augur-server/site\";\n *\n * const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });\n * export const site = createServerSite(api, {\n * defaultCustomerId: \"12345\",\n * auth: { secret: process.env.AUTH_SECRET },\n * });\n * ```\n */\nexport function createServerSite<TApi extends object>(\n client: TApi,\n config: ServerSiteConfig = {},\n): ServerSite<TApi> {\n const actions = createSiteActions(client, config);\n registerSiteActions(actions);\n registerSdkClient(client);\n\n // Register a cache wrapper that captures the site's Redis config.\n // queryAction uses this to wrap read methods in Redis caching without\n // importing the cache directly (which would pull ioredis into the client\n // bundle via tsup code splitting). The SDK's raw result is cached, in its\n // own key space (withRawSdkCache, #98); queryAction unwraps after the read.\n const { cachePrefix = \"\", redisTtl = hours(1), longRedisTtl = hours(8) } = config;\n registerSdkCallWrapper((methodPath, sdkCall, ...keyArgs) => {\n // An hour of staleTime or more: the long TTL; any other: the standard; 0: no caching.\n const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);\n if (ttl === null) return sdkCall();\n return withRawSdkCache(cachePrefix, ttl, methodPath, sdkCall, ...keyArgs);\n });\n\n // Register scoped cache wrapper for per-request session credentials.\n // queryAction uses this to wrap scoped client calls with Redis caching\n // using the targetSiteId as the cache prefix.\n registerScopedCacheWrapper((prefix, methodPath, sdkCall, ...keyArgs) => {\n const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);\n if (ttl === null) return sdkCall();\n return withRawSdkCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);\n });\n\n // Register client factory for creating scoped SDK clients with\n // per-request credentials. Uses the same constructor + base config\n // (baseUrl, timeout, retries) but different siteId/bearerToken.\n const baseConfig = (client as Record<string, unknown>)[\"config\"] as\n Record<string, unknown> | undefined;\n if (baseConfig) {\n const Ctor = client.constructor as new (cfg: Record<string, unknown>) => object;\n registerClientFactory((siteId: string, bearerToken: string) => {\n return new Ctor({ ...baseConfig, siteId, bearerToken });\n });\n }\n\n registerSessionAuth(config.auth);\n\n const auth = config.auth\n ? createAuthConfig({\n augurClient: client as unknown as AugurAuthClient,\n defaultCustomerId: config.defaultCustomerId,\n defaultContactId: config.defaultContactId,\n ...config.auth,\n })\n : undefined;\n\n return { client, actions, auth };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AAiBtB,SAAS,oBAAoB;AAkC7B,SAAS,oBAAoB,MAA8C;AACzE,QAAM,aAAa,MAAM,UAAU,QAAQ,IAAI,aAAa;AAC5D,MAAI,YAAY;AACd,uBAAmB,UAAU;AAAA,EAC/B;AACA,oBAAkB,YAAY,MAAM,SAAS,CAAC;AAChD;AAkBO,SAAS,iBACd,QACA,SAA2B,CAAC,GACV;AAClB,QAAM,UAAU,kBAAkB,QAAQ,MAAM;AAChD,sBAAoB,OAAO;AAC3B,oBAAkB,MAAM;AAOxB,QAAM,EAAE,cAAc,IAAI,WAAW,MAAM,CAAC,GAAG,eAAe,MAAM,CAAC,EAAE,IAAI;AAC3E,yBAAuB,CAAC,YAAY,YAAY,YAAY;AAE1D,UAAM,MAAM,OAAO,aAAa,UAAU,EAAE,WAAW,UAAU,YAAY;AAC7E,QAAI,QAAQ,KAAM,QAAO,QAAQ;AACjC,WAAO,gBAAgB,aAAa,KAAK,YAAY,SAAS,GAAG,OAAO;AAAA,EAC1E,CAAC;AAKD,6BAA2B,CAAC,QAAQ,YAAY,YAAY,YAAY;AACtE,UAAM,MAAM,OAAO,aAAa,UAAU,EAAE,WAAW,UAAU,YAAY;AAC7E,QAAI,QAAQ,KAAM,QAAO,QAAQ;AACjC,WAAO,gBAAgB,QAAQ,KAAK,YAAY,SAAS,GAAG,OAAO;AAAA,EACrE,CAAC;AAKD,QAAM,aAAc,OAAmC,QAAQ;AAE/D,MAAI,YAAY;AACd,UAAM,OAAO,OAAO;AACpB,0BAAsB,CAAC,QAAgB,gBAAwB;AAC7D,aAAO,IAAI,KAAK,EAAE,GAAG,YAAY,QAAQ,YAAY,CAAC;AAAA,IACxD,CAAC;AAAA,EACH;AAEA,sBAAoB,OAAO,IAAI;AAE/B,QAAM,OAAO,OAAO,OAChB,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,mBAAmB,OAAO;AAAA,IAC1B,kBAAkB,OAAO;AAAA,IACzB,GAAG,OAAO;AAAA,EACZ,CAAC,IACD;AAEJ,SAAO,EAAE,QAAQ,SAAS,KAAK;AACjC;","names":[]}
1
+ {"version":3,"sources":["../src/server-site.ts"],"sourcesContent":["import { hours } from \"@simpleapps-com/augur-utils\";\nimport { createSiteActions } from \"./actions/site\";\nimport type { SiteActionsConfig, SiteActions } from \"./actions/site\";\nimport { createAuthConfig } from \"./auth\";\nimport type { AugurAuthCallbacks, AugurAuthClient } from \"./auth\";\nimport type { NextAuthConfig } from \"next-auth\";\nimport { registerSiteActions } from \"./server-site-registry\";\nimport {\n registerSdkClient,\n registerSdkCallWrapper,\n registerAuthSecret,\n registerClientFactory,\n registerCrossSite,\n registerScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport { withRawSdkCache } from \"./cache/with-cache\";\nimport { crossSiteOf } from \"./rules\";\nimport { serverTtlOf } from \"./read-rules\";\nimport { getCacheTier, isP21Path } from \"@simpleapps-com/augur-core\";\n\n/** Auth options forwarded to NextAuth when creating a server site. */\nexport interface ServerSiteAuthConfig {\n secret?: string;\n maxAge?: number;\n callbacks?: Partial<AugurAuthCallbacks>;\n debug?: boolean;\n /**\n * Cross-site sessions (the augur-support pattern: an augur_info client, and the target\n * `siteId` passed to `signIn`). Only when true does sign-in keep the target siteId and does\n * `queryAction` read the session cookie to use a client scoped to that site. Default off: a\n * site that does not set it never reads cookies in `queryAction`, so its pages can render\n * statically (atlas#105). A multi-tenant site MUST set it.\n */\n crossSite?: boolean;\n}\n\n/** Configuration for {@link createServerSite}, combining action config and auth. */\nexport interface ServerSiteConfig extends SiteActionsConfig {\n auth?: ServerSiteAuthConfig;\n}\n\n/** The object returned by {@link createServerSite}. */\nexport interface ServerSite<TApi extends object> {\n client: TApi;\n actions: SiteActions;\n auth: NextAuthConfig | undefined;\n}\n\n/**\n * Register what queryAction and sign-in need from `auth`: the secret (`auth.secret`, else\n * `AUTH_SECRET`) and the cross-site opt-in, the one source both read (atlas#105).\n */\nfunction registerSessionAuth(auth: ServerSiteAuthConfig | undefined): void {\n const authSecret = auth?.secret ?? process.env[\"AUTH_SECRET\"];\n if (authSecret) {\n registerAuthSecret(authSecret);\n }\n registerCrossSite(crossSiteOf(auth?.crossSite));\n}\n\n/**\n * Create a server-side site instance that bundles the SDK client, server\n * actions, and (optional) NextAuth configuration.\n *\n * @example\n * ```ts\n * import { AugurAPI } from \"@simpleapps-com/augur-api\";\n * import { createServerSite } from \"@simpleapps-com/augur-server/site\";\n *\n * const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });\n * export const site = createServerSite(api, {\n * defaultCustomerId: \"12345\",\n * auth: { secret: process.env.AUTH_SECRET },\n * });\n * ```\n */\nexport function createServerSite<TApi extends object>(\n client: TApi,\n config: ServerSiteConfig = {},\n): ServerSite<TApi> {\n const actions = createSiteActions(client, config);\n registerSiteActions(actions);\n registerSdkClient(client);\n\n // Register a cache wrapper that captures the site's Redis config.\n // queryAction uses this to wrap read methods in Redis caching without\n // importing the cache directly (which would pull ioredis into the client\n // bundle via tsup code splitting). The SDK's raw result is cached, in its\n // own key space (withRawSdkCache, #98); queryAction unwraps after the read.\n const { cachePrefix = \"\", redisTtl = hours(1), longRedisTtl = hours(8) } = config;\n // No Redis TTL on the tier (no-cache, user): no caching; else an hour of staleTime or more,\n // the long TTL; any other, the standard (proved serverTtlOf, atlas#102).\n const cachedRaw = <T>(\n prefix: string,\n methodPath: string,\n sdkCall: () => Promise<T>,\n keyArgs: unknown[],\n ): Promise<T> => {\n const tier = getCacheTier(methodPath);\n const ttl = serverTtlOf(\n tier.redisTtl !== undefined,\n isP21Path(methodPath),\n tier.staleTime,\n redisTtl,\n longRedisTtl,\n );\n if (ttl === null) return sdkCall();\n return withRawSdkCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);\n };\n registerSdkCallWrapper((methodPath, sdkCall, ...keyArgs) =>\n cachedRaw(cachePrefix, methodPath, sdkCall, keyArgs),\n );\n\n // Register scoped cache wrapper for per-request session credentials.\n // queryAction uses this to wrap scoped client calls with Redis caching\n // using the targetSiteId as the cache prefix.\n registerScopedCacheWrapper((prefix, methodPath, sdkCall, ...keyArgs) =>\n cachedRaw(prefix, methodPath, sdkCall, keyArgs),\n );\n\n // Register client factory for creating scoped SDK clients with\n // per-request credentials. Uses the same constructor + base config\n // (baseUrl, timeout, retries) but different siteId/bearerToken.\n const baseConfig = (client as Record<string, unknown>)[\"config\"] as\n Record<string, unknown> | undefined;\n if (baseConfig) {\n const Ctor = client.constructor as new (cfg: Record<string, unknown>) => object;\n registerClientFactory((siteId: string, bearerToken: string) => {\n return new Ctor({ ...baseConfig, siteId, bearerToken });\n });\n }\n\n registerSessionAuth(config.auth);\n\n const auth = config.auth\n ? createAuthConfig({\n augurClient: client as unknown as AugurAuthClient,\n defaultCustomerId: config.defaultCustomerId,\n defaultContactId: config.defaultContactId,\n ...config.auth,\n })\n : undefined;\n\n return { client, actions, auth };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AAkBtB,SAAS,cAAc,iBAAiB;AAkCxC,SAAS,oBAAoB,MAA8C;AACzE,QAAM,aAAa,MAAM,UAAU,QAAQ,IAAI,aAAa;AAC5D,MAAI,YAAY;AACd,uBAAmB,UAAU;AAAA,EAC/B;AACA,oBAAkB,YAAY,MAAM,SAAS,CAAC;AAChD;AAkBO,SAAS,iBACd,QACA,SAA2B,CAAC,GACV;AAClB,QAAM,UAAU,kBAAkB,QAAQ,MAAM;AAChD,sBAAoB,OAAO;AAC3B,oBAAkB,MAAM;AAOxB,QAAM,EAAE,cAAc,IAAI,WAAW,MAAM,CAAC,GAAG,eAAe,MAAM,CAAC,EAAE,IAAI;AAG3E,QAAM,YAAY,CAChB,QACA,YACA,SACA,YACe;AACf,UAAM,OAAO,aAAa,UAAU;AACpC,UAAM,MAAM;AAAA,MACV,KAAK,aAAa;AAAA,MAClB,UAAU,UAAU;AAAA,MACpB,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACF;AACA,QAAI,QAAQ,KAAM,QAAO,QAAQ;AACjC,WAAO,gBAAgB,QAAQ,KAAK,YAAY,SAAS,GAAG,OAAO;AAAA,EACrE;AACA;AAAA,IAAuB,CAAC,YAAY,YAAY,YAC9C,UAAU,aAAa,YAAY,SAAS,OAAO;AAAA,EACrD;AAKA;AAAA,IAA2B,CAAC,QAAQ,YAAY,YAAY,YAC1D,UAAU,QAAQ,YAAY,SAAS,OAAO;AAAA,EAChD;AAKA,QAAM,aAAc,OAAmC,QAAQ;AAE/D,MAAI,YAAY;AACd,UAAM,OAAO,OAAO;AACpB,0BAAsB,CAAC,QAAgB,gBAAwB;AAC7D,aAAO,IAAI,KAAK,EAAE,GAAG,YAAY,QAAQ,YAAY,CAAC;AAAA,IACxD,CAAC;AAAA,EACH;AAEA,sBAAoB,OAAO,IAAI;AAE/B,QAAM,OAAO,OAAO,OAChB,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,mBAAmB,OAAO;AAAA,IAC1B,kBAAkB,OAAO;AAAA,IACzB,GAAG,OAAO;AAAA,EACZ,CAAC,IACD;AAEJ,SAAO,EAAE,QAAQ,SAAS,KAAK;AACjC;","names":[]}
@@ -0,0 +1,154 @@
1
+ /** One item for a `<urlset>`: its page URL and, when known, its last change ("" leaves it out). */
2
+ export interface SitemapRow {
3
+ loc: string;
4
+ lastmod: string;
5
+ }
6
+ /** What a sitemap request comes to: served, not a sitemap (404), or Augur failed (503). */
7
+ export type SitemapOutcome = "ok" | "not-found" | "unavailable";
8
+ /**
9
+ * The SDK's `total` as a count: itself when a whole number ≥ 0, else 0 (no item sitemaps rather
10
+ * than a guess).
11
+ *
12
+ * @ensures exactly the model's UsableTotal
13
+ */
14
+ export declare function usableTotal(isWhole: boolean, n: number): number;
15
+ /**
16
+ * How many 5,000-item sitemaps cover `total` items (the endpoint fixes a page at 5,000).
17
+ *
18
+ * @requires total ≥ 0
19
+ * @ensures result = ⌈total / 5000⌉ — exactly the model's ItemSitemapCount
20
+ */
21
+ export declare function itemSitemapCount(total: number): number;
22
+ /**
23
+ * The page a request names (the rewrite's bare `:page`): its value when it is a canonical
24
+ * natural number, else 0, "not a page" (`0`, `01`, `1e3`, ` 1`, `-1` and text never name one).
25
+ *
26
+ * @ensures result = canonicalNatValue(page) for canonical text, else 0 — exactly the model's
27
+ * ItemSitemapPage (the test is spelled out: canonicalNatValue's contract names
28
+ * isCanonicalNat, which this file must call to resolve, models/LSC-GAPS.md)
29
+ */
30
+ export declare function parseItemSitemapPage(page: string): number;
31
+ /**
32
+ * An item page's outcome: not a page, or an empty page past the first, is "not-found"; a failed
33
+ * fetch is "unavailable"; anything else is served. `rows` counts what the endpoint returned,
34
+ * before the scope filter.
35
+ *
36
+ * @ensures exactly the model's ItemOutcome
37
+ */
38
+ export declare function itemSitemapOutcome(page: number, fetched: boolean, rows: number): SitemapOutcome;
39
+ /**
40
+ * The item index's outcome: served when the count was read, else "unavailable" (a 200 with no
41
+ * sitemaps would tell a crawler the site has none).
42
+ *
43
+ * @ensures exactly the model's IndexOutcome
44
+ */
45
+ export declare function sitemapIndexOutcome(fetched: boolean): SitemapOutcome;
46
+ /**
47
+ * The HTTP status of an outcome.
48
+ *
49
+ * @ensures exactly the model's StatusOf
50
+ */
51
+ export declare function sitemapStatus(o: SitemapOutcome): number;
52
+ /**
53
+ * An outcome's `Cache-Control`: a served sitemap for a day at the CDN and an hour in browsers
54
+ * (rebuilt at most daily); a 404 or a 503 never.
55
+ *
56
+ * @ensures exactly the model's CacheControlOf
57
+ */
58
+ export declare function sitemapCacheControl(o: SitemapOutcome): string;
59
+ /**
60
+ * An outcome's `Retry-After` in seconds: an hour for a 503, else "" (no header).
61
+ *
62
+ * @ensures exactly the model's RetryAfterOf
63
+ */
64
+ export declare function sitemapRetryAfter(o: SitemapOutcome): string;
65
+ /**
66
+ * Whether a request's page is worth asking Augur for: only a page (≥ 1); "not a page" is
67
+ * answered without a call.
68
+ *
69
+ * @ensures exactly the model's FetchesPage
70
+ */
71
+ export declare function fetchesPage(page: number): boolean;
72
+ /**
73
+ * A response's body: the XML when served, else a short plain-text reason.
74
+ *
75
+ * @ensures exactly the model's BodyOf
76
+ */
77
+ export declare function sitemapBody(o: SitemapOutcome, xml: string): string;
78
+ /** One response header. */
79
+ export interface SitemapHeader {
80
+ name: string;
81
+ value: string;
82
+ }
83
+ /**
84
+ * A response's headers: its type, its cache rule, and `Retry-After` on a 503 only.
85
+ *
86
+ * @ensures exactly the model's HeadersOf
87
+ */
88
+ export declare function sitemapHeaders(o: SitemapOutcome): SitemapHeader[];
89
+ /**
90
+ * The items' folder as a path, with one leading and one trailing "/" ("items" → "/items/").
91
+ *
92
+ * @ensures exactly the model's SitemapBase
93
+ */
94
+ export declare function sitemapBase(base: string): string;
95
+ /**
96
+ * The folder every item sitemap, and every item it lists, sits in: the site's origin with no
97
+ * trailing "/", then the base.
98
+ *
99
+ * @ensures result = rStripCode(siteUrl, "/") + sitemapBase(base) — exactly the model's ItemsPrefix
100
+ */
101
+ export declare function itemsPrefix(siteUrl: string, base: string): string;
102
+ /**
103
+ * Item sitemap n's URL: `{siteUrl}{base}sitemap-{n}.xml`.
104
+ *
105
+ * @ensures exactly the model's ItemSitemapUrl
106
+ */
107
+ export declare function itemSitemapUrl(siteUrl: string, base: string, n: number): string;
108
+ /**
109
+ * Whether a link is under the items' folder (the location rule); an empty link never is.
110
+ *
111
+ * @ensures exactly the model's InScope
112
+ */
113
+ export declare function inScope(prefix: string, loc: string): boolean;
114
+ /**
115
+ * The item index: a `<sitemapindex>` of `{base}sitemap-1.xml` … `{base}sitemap-{count}.xml`.
116
+ *
117
+ * @ensures exactly the model's ItemIndex
118
+ */
119
+ export declare function buildSitemapIndexXml(siteUrl: string, base: string, count: number): string;
120
+ /**
121
+ * An item page: a `<urlset>` of the rows under the items' folder, in order.
122
+ *
123
+ * @ensures exactly the model's ItemUrlset
124
+ */
125
+ export declare function buildUrlsetXml(rows: SitemapRow[], siteUrl: string, base: string): string;
126
+ /**
127
+ * The Next.js rewrite `source` for the page files, `{base}sitemap-:page.xml`, with every
128
+ * character Next reads as pattern syntax (`( ) { } [ ] | \ ^ . : * + - ? $`) escaped by a "\".
129
+ *
130
+ * @ensures exactly the model's RewriteSource
131
+ */
132
+ export declare function rewriteSource(base: string): string;
133
+ /**
134
+ * The rewrite's destination, the page handler's route `{base}sitemap.xml/:page`
135
+ * (`app/<base>/sitemap.xml/[page]/route.ts`).
136
+ *
137
+ * @ensures exactly the model's RewriteDestination
138
+ */
139
+ export declare function rewriteDestination(base: string): string;
140
+ /**
141
+ * Whether a path is one of the item sitemaps (the index or a page file), which a site's proxy
142
+ * MUST pass through before any item-URL redirect (the proxy runs before rewrites).
143
+ *
144
+ * @ensures exactly the model's IsSitemapPath
145
+ */
146
+ export declare function isSitemapPath(pathname: string, base: string): boolean;
147
+ /**
148
+ * robots.txt's sitemaps: the site's own root `/sitemap.xml` and the item index. Two lines, since
149
+ * the specs name no index inside an index.
150
+ *
151
+ * @ensures exactly the model's RobotsSitemaps
152
+ */
153
+ export declare function robotsSitemaps(siteUrl: string, base: string): string[];
154
+ //# sourceMappingURL=sitemap-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sitemap-rules.d.ts","sourceRoot":"","sources":["../src/sitemap-rules.ts"],"names":[],"mappings":"AA2BA,mGAAmG;AACnG,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,2FAA2F;AAC3F,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,WAAW,GAAG,aAAa,CAAC;AAIhE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAI/D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIzD;AAID;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAU/F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CAIpE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAKvD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAI7D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,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;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAIrE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAMtE"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Item sitemaps for a Next.js site, built at request time from the Augur SDK's
3
+ * `googMc.sitemaps.items.list` (atlas#101), so the number of files follows the catalog without a
4
+ * deploy, whatever its size.
5
+ *
6
+ * Layout: the item index at `{base}sitemap.xml` and page n (5,000 items) at
7
+ * `{base}sitemap-{n}.xml`, in the items' own folder (`base`, default "/items/"), so by the
8
+ * sitemap protocol's location rule they may list the item pages there. The site's root
9
+ * `/sitemap.xml` stays its own; robots.txt names both (`robotsSitemaps`).
10
+ *
11
+ * Every decision is a proved rule in `sitemap-rules.ts`; this file only awaits the SDK and maps
12
+ * the rules' answers to a Response.
13
+ */
14
+ import type { AugurAPI } from "@simpleapps-com/augur-api";
15
+ export { buildSitemapIndexXml, buildUrlsetXml, inScope, isSitemapPath, itemSitemapCount, itemSitemapUrl, parseItemSitemapPage, robotsSitemaps, sitemapBase, type SitemapOutcome, type SitemapRow, } from "./sitemap-rules";
16
+ /** The items' folder when a site names none. */
17
+ export declare const DEFAULT_SITEMAP_BASE = "/items/";
18
+ /**
19
+ * How long one Augur call may take, in milliseconds: crawlers wait longer than page visitors, and
20
+ * a call past it is a 503 the crawler retries.
21
+ */
22
+ export declare const DEFAULT_SITEMAP_DEADLINE = 10000;
23
+ /** What the handlers need of a server site: its SDK client (`createServerSite`'s result fits). */
24
+ export interface SitemapSite {
25
+ client: Pick<AugurAPI, "withRequest" | "googMc">;
26
+ }
27
+ /** Where the site lives and where its item sitemaps sit. */
28
+ export interface SitemapOptions {
29
+ /** The site's origin, e.g. "https://www.example.com" (a trailing "/" is dropped). */
30
+ siteUrl: string;
31
+ /** The items' folder, matching the item links Augur returns; default "/items/". */
32
+ base?: string;
33
+ /** Milliseconds one Augur call may take; default 10,000. */
34
+ deadline?: number;
35
+ }
36
+ /** A Next.js rewrite, as `next.config` `rewrites()` takes it. */
37
+ export interface SitemapRewrite {
38
+ source: string;
39
+ destination: string;
40
+ }
41
+ /**
42
+ * The item index's Route Handler, for `app/items/sitemap.xml/route.ts` (or the folder `base`
43
+ * names): a `<sitemapindex>` of every item page file, or a 503 when Augur can't be read.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * export const dynamic = "force-dynamic";
48
+ * export const GET = createSitemapIndexHandler(site, { siteUrl: "https://www.example.com" });
49
+ * ```
50
+ */
51
+ export declare function createSitemapIndexHandler(site: SitemapSite, options: SitemapOptions): () => Promise<Response>;
52
+ /**
53
+ * An item page's Route Handler, for `app/items/sitemap.xml/[page]/route.ts`, which
54
+ * `sitemapRewrite` maps `{base}sitemap-{n}.xml` onto: a `<urlset>` of page n's items under
55
+ * `base`, a 404 for no such page, or a 503 when Augur can't be read.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * export const dynamic = "force-dynamic";
60
+ * export const GET = createItemSitemapHandler(site, { siteUrl: "https://www.example.com" });
61
+ * ```
62
+ */
63
+ export declare function createItemSitemapHandler(site: SitemapSite, options: SitemapOptions): (_request: Request, context: {
64
+ params: Promise<{
65
+ page: string;
66
+ }>;
67
+ }) => Promise<Response>;
68
+ /**
69
+ * The Next.js rewrite from `{base}sitemap-{n}.xml` to the item page handler's route; spread it
70
+ * into `next.config`'s `rewrites()`.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * async rewrites() {
75
+ * return [sitemapRewrite()];
76
+ * }
77
+ * ```
78
+ */
79
+ export declare function sitemapRewrite(base?: string): SitemapRewrite;
80
+ //# sourceMappingURL=sitemap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../src/sitemap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OA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+1,242 @@
1
+ import {
2
+ decimal
3
+ } from "./chunk-JIYVQWXK.js";
4
+ import {
5
+ canonicalNatValue,
6
+ endsWith,
7
+ isCanonicalNat,
8
+ lineFeed,
9
+ rStripCode,
10
+ startsWithAt
11
+ } from "./chunk-V76GZZF3.js";
12
+
13
+ // ../utils/src/replace.ts
14
+ function codeIndex(codes, c, i) {
15
+ if (i === codes.length) return -1;
16
+ return codes[i] === c ? i : codeIndex(codes, c, i + 1);
17
+ }
18
+ function substitutedText(s, codes, texts) {
19
+ if (s.length === 0) return "";
20
+ const k = codeIndex(codes, s.charCodeAt(0), 0);
21
+ const head = k >= 0 && k < texts.length ? texts[k] : s.slice(0, 1);
22
+ return head + substitutedText(s.slice(1), codes, texts);
23
+ }
24
+
25
+ // ../utils/src/xml.ts
26
+ function xmlEntity(c) {
27
+ if (c === 38) return "&amp;";
28
+ if (c === 60) return "&lt;";
29
+ if (c === 62) return "&gt;";
30
+ if (c === 34) return "&quot;";
31
+ if (c === 39) return "&apos;";
32
+ return "";
33
+ }
34
+ function xmlEscaped(s) {
35
+ if (s.length === 0) return "";
36
+ const entity = xmlEntity(s.charCodeAt(0));
37
+ return (entity === "" ? s.slice(0, 1) : entity) + xmlEscaped(s.slice(1));
38
+ }
39
+
40
+ // ../utils/src/sitemap.ts
41
+ function urlsetHead() {
42
+ return '<?xml version="1.0" encoding="UTF-8"?>' + lineFeed() + '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' + lineFeed();
43
+ }
44
+ function urlsetTail() {
45
+ return "</urlset>" + lineFeed();
46
+ }
47
+ function sitemapIndexHead() {
48
+ return '<?xml version="1.0" encoding="UTF-8"?>' + lineFeed() + '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' + lineFeed();
49
+ }
50
+ function sitemapIndexTail() {
51
+ return "</sitemapindex>" + lineFeed();
52
+ }
53
+ function urlBlock(loc, lastmod) {
54
+ const date = lastmod === "" ? "" : " <lastmod>" + xmlEscaped(lastmod) + "</lastmod>" + lineFeed();
55
+ return " <url>" + lineFeed() + " <loc>" + xmlEscaped(loc) + "</loc>" + lineFeed() + date + " </url>" + lineFeed();
56
+ }
57
+ function sitemapBlock(loc) {
58
+ return " <sitemap>" + lineFeed() + " <loc>" + xmlEscaped(loc) + "</loc>" + lineFeed() + " </sitemap>" + lineFeed();
59
+ }
60
+
61
+ // src/sitemap-rules.ts
62
+ function usableTotal(isWhole, n) {
63
+ return isWhole && n >= 0 ? n : 0;
64
+ }
65
+ function itemSitemapCount(total) {
66
+ return Math.floor((total + 4999) / 5e3);
67
+ }
68
+ function parseItemSitemapPage(page) {
69
+ return isCanonicalNat(page) ? canonicalNatValue(page) : 0;
70
+ }
71
+ function itemSitemapOutcome(page, fetched, rows) {
72
+ if (page === 0) return "not-found";
73
+ if (!fetched) return "unavailable";
74
+ if (rows === 0 && page > 1) return "not-found";
75
+ return "ok";
76
+ }
77
+ function sitemapIndexOutcome(fetched) {
78
+ return fetched ? "ok" : "unavailable";
79
+ }
80
+ function sitemapStatus(o) {
81
+ if (o === "ok") return 200;
82
+ return o === "not-found" ? 404 : 503;
83
+ }
84
+ function sitemapCacheControl(o) {
85
+ return o === "ok" ? "public, max-age=3600, s-maxage=86400" : "no-store";
86
+ }
87
+ function sitemapRetryAfter(o) {
88
+ return o === "unavailable" ? "3600" : "";
89
+ }
90
+ function fetchesPage(page) {
91
+ return page >= 1;
92
+ }
93
+ function sitemapBody(o, xml) {
94
+ if (o === "ok") return xml;
95
+ return o === "not-found" ? "Not Found" : "Sitemap temporarily unavailable";
96
+ }
97
+ function sitemapHeaders(o) {
98
+ const type = {
99
+ name: "Content-Type",
100
+ value: o === "ok" ? "application/xml; charset=utf-8" : "text/plain; charset=utf-8"
101
+ };
102
+ const cache = { name: "Cache-Control", value: sitemapCacheControl(o) };
103
+ const retry = { name: "Retry-After", value: sitemapRetryAfter(o) };
104
+ return o === "unavailable" ? [type, cache, retry] : [type, cache];
105
+ }
106
+ function sitemapBase(base) {
107
+ const lead = base.length > 0 && base.charCodeAt(0) === 47 ? base : "/" + base;
108
+ return lead.charCodeAt(lead.length - 1) === 47 ? lead : lead + "/";
109
+ }
110
+ function itemsPrefix(siteUrl, base) {
111
+ return rStripCode(siteUrl, 47) + sitemapBase(base);
112
+ }
113
+ function itemSitemapUrl(siteUrl, base, n) {
114
+ return itemsPrefix(siteUrl, base) + "sitemap-" + decimal(n) + ".xml";
115
+ }
116
+ function inScope(prefix, loc) {
117
+ return startsWithAt(loc, prefix, 0);
118
+ }
119
+ function indexBlocksRange(siteUrl, base, lo, hi) {
120
+ if (hi - lo === 0) return "";
121
+ if (hi - lo === 1) return sitemapBlock(itemSitemapUrl(siteUrl, base, lo + 1));
122
+ const mid = lo + Math.floor((hi - lo) / 2);
123
+ return indexBlocksRange(siteUrl, base, lo, mid) + indexBlocksRange(siteUrl, base, mid, hi);
124
+ }
125
+ function buildSitemapIndexXml(siteUrl, base, count) {
126
+ return sitemapIndexHead() + indexBlocksRange(siteUrl, base, 0, count) + sitemapIndexTail();
127
+ }
128
+ function urlBlocksRange(rows, prefix, lo, hi) {
129
+ if (hi - lo === 0) return "";
130
+ if (hi - lo === 1) {
131
+ const row = rows[lo];
132
+ return inScope(prefix, row.loc) ? urlBlock(row.loc, row.lastmod) : "";
133
+ }
134
+ const mid = lo + Math.floor((hi - lo) / 2);
135
+ return urlBlocksRange(rows, prefix, lo, mid) + urlBlocksRange(rows, prefix, mid, hi);
136
+ }
137
+ function buildUrlsetXml(rows, siteUrl, base) {
138
+ return urlsetHead() + urlBlocksRange(rows, itemsPrefix(siteUrl, base), 0, rows.length) + urlsetTail();
139
+ }
140
+ function rewriteSource(base) {
141
+ return substitutedText(
142
+ sitemapBase(base),
143
+ [40, 41, 123, 125, 91, 93, 124, 92, 94, 46, 58, 42, 43, 45, 63, 36],
144
+ [
145
+ "\\(",
146
+ "\\)",
147
+ "\\{",
148
+ "\\}",
149
+ "\\[",
150
+ "\\]",
151
+ "\\|",
152
+ "\\\\",
153
+ "\\^",
154
+ "\\.",
155
+ "\\:",
156
+ "\\*",
157
+ "\\+",
158
+ "\\-",
159
+ "\\?",
160
+ "\\$"
161
+ ]
162
+ ) + "sitemap\\-:page\\.xml";
163
+ }
164
+ function rewriteDestination(base) {
165
+ return sitemapBase(base) + "sitemap.xml/:page";
166
+ }
167
+ function isSitemapPath(pathname, base) {
168
+ return startsWithAt(pathname, sitemapBase(base) + "sitemap", 0) && endsWith(pathname, ".xml");
169
+ }
170
+ function robotsSitemaps(siteUrl, base) {
171
+ return [rStripCode(siteUrl, 47) + "/sitemap.xml", itemsPrefix(siteUrl, base) + "sitemap.xml"];
172
+ }
173
+
174
+ // src/sitemap.ts
175
+ var DEFAULT_SITEMAP_BASE = "/items/";
176
+ var DEFAULT_SITEMAP_DEADLINE = 1e4;
177
+ var EDGE_CACHE_HOURS = 1;
178
+ function respond(outcome, xml) {
179
+ const headers = new Headers(
180
+ sitemapHeaders(outcome).map((h) => [h.name, h.value])
181
+ );
182
+ return new Response(sitemapBody(outcome, xml), { status: sitemapStatus(outcome), headers });
183
+ }
184
+ async function readTotal(site, deadline) {
185
+ try {
186
+ const response = await site.client.withRequest({ deadline }).googMc.sitemaps.items.list({ limit: 1, edgeCache: EDGE_CACHE_HOURS });
187
+ return usableTotal(Number.isInteger(response.total), response.total);
188
+ } catch {
189
+ return void 0;
190
+ }
191
+ }
192
+ async function readPage(site, page, deadline) {
193
+ try {
194
+ const response = await site.client.withRequest({ deadline }).googMc.sitemaps.items.list({ page, edgeCache: EDGE_CACHE_HOURS });
195
+ return (response.data ?? []).map((row) => ({
196
+ loc: row.link ?? "",
197
+ lastmod: row.lastModified ?? ""
198
+ }));
199
+ } catch {
200
+ return void 0;
201
+ }
202
+ }
203
+ function createSitemapIndexHandler(site, options) {
204
+ const { siteUrl, base = DEFAULT_SITEMAP_BASE, deadline = DEFAULT_SITEMAP_DEADLINE } = options;
205
+ return async () => {
206
+ const total = await readTotal(site, deadline);
207
+ const count = itemSitemapCount(total ?? 0);
208
+ return respond(
209
+ sitemapIndexOutcome(total !== void 0),
210
+ buildSitemapIndexXml(siteUrl, base, count)
211
+ );
212
+ };
213
+ }
214
+ function createItemSitemapHandler(site, options) {
215
+ const { siteUrl, base = DEFAULT_SITEMAP_BASE, deadline = DEFAULT_SITEMAP_DEADLINE } = options;
216
+ return async (_request, context) => {
217
+ const page = parseItemSitemapPage((await context.params).page);
218
+ const rows = fetchesPage(page) ? await readPage(site, page, deadline) : [];
219
+ const outcome = itemSitemapOutcome(page, rows !== void 0, rows?.length ?? 0);
220
+ return respond(outcome, buildUrlsetXml(rows ?? [], siteUrl, base));
221
+ };
222
+ }
223
+ function sitemapRewrite(base = DEFAULT_SITEMAP_BASE) {
224
+ return { source: rewriteSource(base), destination: rewriteDestination(base) };
225
+ }
226
+ export {
227
+ DEFAULT_SITEMAP_BASE,
228
+ DEFAULT_SITEMAP_DEADLINE,
229
+ buildSitemapIndexXml,
230
+ buildUrlsetXml,
231
+ createItemSitemapHandler,
232
+ createSitemapIndexHandler,
233
+ inScope,
234
+ isSitemapPath,
235
+ itemSitemapCount,
236
+ itemSitemapUrl,
237
+ parseItemSitemapPage,
238
+ robotsSitemaps,
239
+ sitemapBase,
240
+ sitemapRewrite
241
+ };
242
+ //# sourceMappingURL=sitemap.js.map