@rebasepro/server 0.29.1 → 0.29.3

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 (110) hide show
  1. package/dist/{GCSStorageController-Crdllv9A.js → GCSStorageController-Bgrcn6Uh.js} +2 -2
  2. package/dist/{GCSStorageController-Crdllv9A.js.map → GCSStorageController-Bgrcn6Uh.js.map} +1 -1
  3. package/dist/{S3StorageController-C7x2Yaiz.js → S3StorageController-B27ibWz8.js} +2 -2
  4. package/dist/{S3StorageController-C7x2Yaiz.js.map → S3StorageController-B27ibWz8.js.map} +1 -1
  5. package/dist/{access-BNZBi9yL.js → access-BihomvkO.js} +5 -5
  6. package/dist/access-BihomvkO.js.map +1 -0
  7. package/dist/api/rest/api-generator.d.ts +9 -0
  8. package/dist/api/rest/auth-collection-writes.d.ts +2 -2
  9. package/dist/api/rest/field-access-query.d.ts +1 -1
  10. package/dist/api/rest/query-parser.d.ts +29 -5
  11. package/dist/api/types.d.ts +9 -0
  12. package/dist/apps/saved-apps.d.ts +69 -0
  13. package/dist/{ast-schema-editor-D56sGr0L.js → ast-schema-editor-C0n8s_Z6.js} +2 -2
  14. package/dist/{ast-schema-editor-D56sGr0L.js.map → ast-schema-editor-C0n8s_Z6.js.map} +1 -1
  15. package/dist/auth/user-profile.d.ts +29 -0
  16. package/dist/{auth-CV82Wvq1.js → auth-C-RJT4VO.js} +7 -7
  17. package/dist/{auth-CV82Wvq1.js.map → auth-C-RJT4VO.js.map} +1 -1
  18. package/dist/auth_adapter-HFv5axIT.js.map +1 -1
  19. package/dist/{backup-BiAhhHKV.js → backup-D-ds7wml.js} +6 -6
  20. package/dist/{backup-BiAhhHKV.js.map → backup-D-ds7wml.js.map} +1 -1
  21. package/dist/boot/env.d.ts +4 -2
  22. package/dist/boot/options.d.ts +4 -2
  23. package/dist/boot/resource-adapters.d.ts +1 -1
  24. package/dist/{branch-routes-DqKPRFtb.js → branch-routes-ClQrYUyP.js} +2 -2
  25. package/dist/{branch-routes-DqKPRFtb.js.map → branch-routes-ClQrYUyP.js.map} +1 -1
  26. package/dist/{contract-routes-AD3hi7ad.js → contract-routes-BGXR9D5C.js} +2 -2
  27. package/dist/contract-routes-BGXR9D5C.js.map +1 -0
  28. package/dist/{cron-loader-D1zNARNU.js → cron-loader-BN24T-O1.js} +2 -2
  29. package/dist/{cron-loader-D1zNARNU.js.map → cron-loader-BN24T-O1.js.map} +1 -1
  30. package/dist/{cron-routes-BtB2VVTk.js → cron-routes-CjCWNcX6.js} +3 -3
  31. package/dist/{cron-routes-BtB2VVTk.js.map → cron-routes-CjCWNcX6.js.map} +1 -1
  32. package/dist/{cron-scheduler-DEKiJh_G.js → cron-scheduler-CM08t50L.js} +2 -2
  33. package/dist/{cron-scheduler-DEKiJh_G.js.map → cron-scheduler-CM08t50L.js.map} +1 -1
  34. package/dist/{cron-store-DcaNQIAr.js → cron-store-iv5yn27j.js} +3 -3
  35. package/dist/{cron-store-DcaNQIAr.js.map → cron-store-iv5yn27j.js.map} +1 -1
  36. package/dist/data_driver-D0mg1Y_x.js.map +1 -1
  37. package/dist/dist-BCMr0NfI.js +19359 -0
  38. package/dist/dist-BCMr0NfI.js.map +1 -0
  39. package/dist/dynamic-import-Bi3XK5y-.js.map +1 -1
  40. package/dist/{field-access-BHi-4uSo.js → field-access-BDyTY2D4.js} +2 -2
  41. package/dist/{field-access-BHi-4uSo.js.map → field-access-BDyTY2D4.js.map} +1 -1
  42. package/dist/{filter-dialect-Cbzt7lO9.js → filter-dialect-CgeSm3Kl.js} +17 -2
  43. package/dist/filter-dialect-CgeSm3Kl.js.map +1 -0
  44. package/dist/{function-routes-CdtIKSV8.js → function-routes-mSmsW34_.js} +23 -2
  45. package/dist/function-routes-mSmsW34_.js.map +1 -0
  46. package/dist/functions/context.d.ts +37 -0
  47. package/dist/functions/index.d.ts +2 -2
  48. package/dist/functions/index.js +22 -1
  49. package/dist/functions/index.js.map +1 -1
  50. package/dist/history/history-routes.d.ts +2 -1
  51. package/dist/{history-recorder-C8FBGUa9.js → history-recorder-BV34l2qf.js} +3 -3
  52. package/dist/{history-recorder-C8FBGUa9.js.map → history-recorder-BV34l2qf.js.map} +1 -1
  53. package/dist/{history-store-DL-ydprp.js → history-store-Dbyvv1KZ.js} +3 -3
  54. package/dist/{history-store-DL-ydprp.js.map → history-store-Dbyvv1KZ.js.map} +1 -1
  55. package/dist/index.d.ts +3 -3
  56. package/dist/index.es.js +745 -141
  57. package/dist/index.es.js.map +1 -1
  58. package/dist/init/health.d.ts +1 -1
  59. package/dist/init/surfaces.d.ts +2 -0
  60. package/dist/{internal-tables-D2IdQlUW.js → internal-tables-BmN-5QQr.js} +3 -1
  61. package/dist/internal-tables-BmN-5QQr.js.map +1 -0
  62. package/dist/jobs/job-store.d.ts +3 -1
  63. package/dist/{jobs-DK9ra01Y.js → jobs-D9RBf3Yb.js} +4 -4
  64. package/dist/jobs-D9RBf3Yb.js.map +1 -0
  65. package/dist/{jwt-iiP_ZZzR.js → jwt-C3dwSo1U.js} +2 -2
  66. package/dist/{jwt-iiP_ZZzR.js.map → jwt-C3dwSo1U.js.map} +1 -1
  67. package/dist/{keys-krxEEEj4.js → keys-DmK8vGhX.js} +2 -2
  68. package/dist/{keys-krxEEEj4.js.map → keys-DmK8vGhX.js.map} +1 -1
  69. package/dist/mcp/admin-apps-mcp.d.ts +28 -0
  70. package/dist/mcp/mcp-routes.d.ts +1 -1
  71. package/dist/mcp/mcp-tools.d.ts +10 -2
  72. package/dist/mcp/mcp-view.d.ts +7 -0
  73. package/dist/mcp/oauth-store.d.ts +3 -1
  74. package/dist/mcp/show-app-guide.d.ts +9 -0
  75. package/dist/{offline-Cy6woFyt-CbjOQGD1.js → offline-B6J1YUWF-CEJLzvJw.js} +71 -11
  76. package/dist/offline-B6J1YUWF-CEJLzvJw.js.map +1 -0
  77. package/dist/{offline-store-C2Sy3Kwl-C8KIwabG.js → offline-store-B7F5mimt-Bh5f-dWu.js} +55 -10
  78. package/dist/offline-store-B7F5mimt-Bh5f-dWu.js.map +1 -0
  79. package/dist/{openapi-generator-Cn-ytCH8.js → openapi-generator-1s5sWUnN.js} +3 -3
  80. package/dist/openapi-generator-1s5sWUnN.js.map +1 -0
  81. package/dist/{query-parser-CTiEg64k.js → query-parser-mFFiGEFV.js} +120 -29
  82. package/dist/query-parser-mFFiGEFV.js.map +1 -0
  83. package/dist/{rls-simulator-routes-5nbuDwWR.js → rls-simulator-routes-C7C3f57E.js} +3 -3
  84. package/dist/{rls-simulator-routes-5nbuDwWR.js.map → rls-simulator-routes-C7C3f57E.js.map} +1 -1
  85. package/dist/{schema-editor-routes-Bi8S1gn7.js → schema-editor-routes-BFRh4mHu.js} +3 -3
  86. package/dist/{schema-editor-routes-Bi8S1gn7.js.map → schema-editor-routes-BFRh4mHu.js.map} +1 -1
  87. package/dist/{sql-export-routes-XkcXbxw5.js → sql-export-routes-9nXTfyP_.js} +2 -2
  88. package/dist/{sql-export-routes-XkcXbxw5.js.map → sql-export-routes-9nXTfyP_.js.map} +1 -1
  89. package/dist/{sql-rows-C6GEc2oE.js → sql-rows-CIThkmuF.js} +2 -2
  90. package/dist/sql-rows-CIThkmuF.js.map +1 -0
  91. package/dist/{src-0nCWajy7.js → src-CE9LRXDq.js} +20 -4
  92. package/dist/src-CE9LRXDq.js.map +1 -0
  93. package/dist/topics/runtime.d.ts +1 -1
  94. package/dist/user-profile-C1UkoaJe.js +46 -0
  95. package/dist/user-profile-C1UkoaJe.js.map +1 -0
  96. package/package.json +5 -5
  97. package/dist/access-BNZBi9yL.js.map +0 -1
  98. package/dist/contract-routes-AD3hi7ad.js.map +0 -1
  99. package/dist/dist-BpP9FwVH.js +0 -19359
  100. package/dist/dist-BpP9FwVH.js.map +0 -1
  101. package/dist/filter-dialect-Cbzt7lO9.js.map +0 -1
  102. package/dist/function-routes-CdtIKSV8.js.map +0 -1
  103. package/dist/internal-tables-D2IdQlUW.js.map +0 -1
  104. package/dist/jobs-DK9ra01Y.js.map +0 -1
  105. package/dist/offline-Cy6woFyt-CbjOQGD1.js.map +0 -1
  106. package/dist/offline-store-C2Sy3Kwl-C8KIwabG.js.map +0 -1
  107. package/dist/openapi-generator-Cn-ytCH8.js.map +0 -1
  108. package/dist/query-parser-CTiEg64k.js.map +0 -1
  109. package/dist/sql-rows-C6GEc2oE.js.map +0 -1
  110. package/dist/src-0nCWajy7.js.map +0 -1
@@ -2,7 +2,7 @@ import { createRequire as __rebaseCreateRequire } from "module";
2
2
  import __rebaseProcess from "process";
3
3
  globalThis.process ??= __rebaseProcess;
4
4
  __rebaseCreateRequire(import.meta.url);
5
- import { A as DEFAULT_STORAGE_SOURCE_KEY } from "./src-0nCWajy7.js";
5
+ import { A as DEFAULT_STORAGE_SOURCE_KEY } from "./src-CE9LRXDq.js";
6
6
  //#region src/storage/keys.ts
7
7
  /**
8
8
  * Canonical storage keys and bucket names.
@@ -228,4 +228,4 @@ var InvalidListOptionsError = class extends Error {
228
228
  //#endregion
229
229
  export { canonicalStorageId as a, listingPrefix as c, canonicalStorageBucket as i, InvalidStorageBucketError as n, canonicalStorageKey as o, InvalidStorageKeyError as r, folderKey as s, InvalidListOptionsError as t };
230
230
 
231
- //# sourceMappingURL=keys-krxEEEj4.js.map
231
+ //# sourceMappingURL=keys-DmK8vGhX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keys-krxEEEj4.js","names":[],"sources":["../src/storage/keys.ts"],"sourcesContent":["/**\n * Canonical storage keys and bucket names.\n *\n * Storage is not under RLS, so a `storageAuthorize` hook is the whole access\n * control model — and a hook can only be correct if the key it is shown is the\n * key that is written. That is the invariant this module exists to hold: one\n * canonical string, computed once per request, handed to the hook, to the\n * controller, and to the download token alike.\n *\n * ## Why rejecting beats stripping\n *\n * The previous `sanitizeStorageKey` *stripped* `../` in a single pass. Two\n * things were wrong with that, and only one of them was the obvious one.\n *\n * The obvious one: a single pass is not a fixed point. `....//` contains `../`\n * at offset 2, so removing it leaves `../` behind — the sanitizer manufactured\n * the traversal it was there to remove. `users/alice/....//bob/x` came out as\n * `users/alice/../bob/x`, which a prefix hook reads as alice's (it starts with\n * `users/alice/`) and the filesystem reads as bob's. The hook approved one\n * object and the controller wrote another.\n *\n * The subtler one, and the reason this is a rewrite rather than a loop: even a\n * correct strip is a silent rewrite. A caller who asks to store at `a/../b` and\n * gets an object at `a/b` was not protected, they were misled — and every later\n * read, ownership row and audit line now refers to a path nobody chose. So a key\n * that means something other than what it says is refused (400), not repaired.\n *\n * Note what is NOT traversal under this rule: `....` is an ordinary directory\n * name, and `users/alice/....//bob/x` canonicalizes to\n * `users/alice/..../bob/x` — still comfortably inside alice's prefix, which is\n * exactly right. Only a real `..` segment is refused.\n */\n\nimport { DEFAULT_STORAGE_SOURCE_KEY } from \"@rebasepro/types\";\n\n/**\n * `path.posix.normalize`, without `node:path`.\n *\n * A storage key is a POSIX-shaped string that never touches a filesystem, so\n * reaching for `node:path` to fold `.` and `//` out of it was always a little\n * wrong on its own terms — on Windows the platform `path` would have applied\n * different rules to the same key. It also put the module that every storage\n * read, ownership row and audit line goes through on the list of things that\n * only run in a Node process.\n *\n * This is the algorithm Node implements, transcribed: segments are folded left\n * to right, `..` pops unless it would climb past the root of a relative path,\n * and both the leading and the trailing separator survive the round trip. The\n * `..` branch is unreachable from {@link canonicalStorageKey}, which refuses\n * those keys outright before it gets here — it exists so that this function is\n * *the* normalizer rather than a subset of one, and\n * `storage-keys.property.test.ts` holds it to that with a property test against\n * `path.posix.normalize` itself. Exported for exactly that — nothing outside\n * this module should be normalizing a key.\n */\nexport function normalizePosix(input: string): string {\n if (input.length === 0) return \".\";\n const isAbsolute = input.startsWith(\"/\");\n const trailingSeparator = input.endsWith(\"/\");\n\n const segments: string[] = [];\n for (const segment of input.split(\"/\")) {\n if (segment === \"\" || segment === \".\") continue;\n if (segment === \"..\") {\n if (segments.length > 0 && segments[segments.length - 1] !== \"..\") segments.pop();\n else if (!isAbsolute) segments.push(\"..\");\n continue;\n }\n segments.push(segment);\n }\n\n const joined = segments.join(\"/\");\n if (joined === \"\") {\n if (isAbsolute) return \"/\";\n return trailingSeparator ? \"./\" : \".\";\n }\n const withTrailing = trailingSeparator ? `${joined}/` : joined;\n return isAbsolute ? `/${withTrailing}` : withTrailing;\n}\n\n/** Longest key accepted, in UTF-16 code units. Matches the previous cap. */\nexport const MAX_STORAGE_KEY_LENGTH = 1024;\n\n/**\n * A key that cannot be canonicalized. Carries no path back to the caller\n * beyond what they sent, so it is safe to surface as a 400 message.\n */\nexport class InvalidStorageKeyError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidStorageKeyError\";\n }\n}\n\n/**\n * Canonicalize a caller-supplied storage key, or throw\n * {@link InvalidStorageKeyError}.\n *\n * Normalizations applied (safe, idempotent, and meaning-preserving):\n * - leading slashes removed — `/a/b` and `a/b` name the same object\n * - `.` segments and repeated slashes collapsed\n *\n * Refusals (the key means something other than what it says):\n * - any `..` segment, on either separator, at any depth\n * - null bytes\n * - keys longer than {@link MAX_STORAGE_KEY_LENGTH}\n *\n * A trailing slash is preserved: it is how the folder route marks a prefix.\n */\nexport function canonicalStorageKey(rawKey: string): string {\n if (rawKey.includes(\"\\0\")) {\n throw new InvalidStorageKeyError(\"Storage key contains a null byte.\");\n }\n if (rawKey.length > MAX_STORAGE_KEY_LENGTH) {\n throw new InvalidStorageKeyError(\n `Storage key exceeds the maximum length of ${MAX_STORAGE_KEY_LENGTH} characters.`\n );\n }\n\n // Split on both separators: `path.join` treats `\\` as a separator on\n // Windows, so `..\\` is traversal there even though POSIX reads it as a\n // filename. Checked against the RAW key, before any normalization — the\n // whole point is that `a/../b` is refused rather than quietly turned into\n // `b`.\n if (rawKey.split(/[\\\\/]/).some((segment) => segment === \"..\")) {\n throw new InvalidStorageKeyError(\n \"Storage key contains a '..' path segment. Keys must name an object directly.\"\n );\n }\n\n const withoutLeadingSlashes = rawKey.replace(/^\\/+/, \"\");\n if (withoutLeadingSlashes === \"\") return \"\";\n\n // Whether the key names a *directory* rather than an object: it ends with a\n // separator, or its last segment is the `.` that means \"this directory\".\n //\n // Recorded before normalizing, because normalization drops the\n // distinction in one of those two spellings and not the other: `public/.`\n // becomes `public` while `public/./` stays `public/`. That asymmetry breaks\n // the rule this module states — a trailing slash is preserved, because it is\n // how the folder route marks a prefix — and it is not cosmetic on `list`,\n // where a prefix of `public` also matches `publicity/` and hands back keys\n // the caller never asked for.\n const denotesDirectory = /(?:^|\\/)\\.?$/.test(withoutLeadingSlashes);\n\n // Safe now: with no `..` segment in the input, `normalize` can only collapse\n // `.` and duplicate slashes — it cannot climb.\n const normalized = normalizePosix(withoutLeadingSlashes);\n\n // `normalize(\".\")`, and `normalize(\"./\")` → `./`; neither names an object.\n if (normalized === \".\" || normalized === \"./\") return \"\";\n\n // Defensive: nothing reaching here still carries a leading `./`, since the\n // leading slashes are already gone and `normalize` only emits `./` for a\n // key that normalizes to nothing — which returned above.\n const key = normalized.replace(/^\\.\\//, \"\").replace(/^\\/+/, \"\");\n if (key === \"\") return \"\";\n return denotesDirectory && !key.endsWith(\"/\") ? `${key}/` : key;\n}\n\n/**\n * Canonicalize, or return `null` when the key is not canonicalizable.\n *\n * For callers that must fail closed without an exception — the download-token\n * middleware compares a request path against a granted path, and a key it\n * cannot canonicalize simply matches nothing.\n */\nexport function tryCanonicalStorageKey(rawKey: string): string | null {\n try {\n return canonicalStorageKey(rawKey);\n } catch {\n return null;\n }\n}\n\n/**\n * Canonicalize the storage *source* a request names (`?storageId=`), so that\n * \"the default source\" has exactly one spelling.\n *\n * The default source can be asked for three ways — the parameter omitted, sent\n * empty, or sent as the literal `(default)` — and all three resolve to the same\n * controller. Without a single spelling, the value derived when a download\n * token is minted and the value derived when it is presented can differ for the\n * same object, which is either a spurious 403 or, if the comparison is dropped\n * to stop those, no scoping at all.\n *\n * Deliberately *not* validated against the registry: this is a naming rule, not\n * an existence check, and it must give the same answer in `auth/` (which has no\n * registry) as in the storage routes. An id that names no source still\n * canonicalizes to itself and simply matches only itself.\n */\nexport function canonicalStorageId(rawStorageId: string | undefined | null): string {\n if (rawStorageId === undefined || rawStorageId === null) return DEFAULT_STORAGE_SOURCE_KEY;\n const trimmed = rawStorageId.trim();\n return trimmed === \"\" ? DEFAULT_STORAGE_SOURCE_KEY : trimmed;\n}\n\n/**\n * Longest bucket name accepted. 63 is the S3/GCS limit, and a local bucket is\n * one directory name, so the tighter of the two bounds everything.\n */\nexport const MAX_STORAGE_BUCKET_LENGTH = 63;\n\n/** A bucket name that does not name a bucket. See {@link canonicalStorageBucket}. */\nexport class InvalidStorageBucketError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidStorageBucketError\";\n }\n}\n\n/**\n * One path segment: letters, digits, `.`, `_`, `-`, first character\n * alphanumeric. Deliberately narrow — it is the intersection of what S3, GCS\n * and a filesystem directory all accept, and it makes `..`, `.tus-uploads`,\n * absolute paths and anything containing a separator unrepresentable.\n */\nconst STORAGE_BUCKET_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\n\n/**\n * Canonicalize a caller-supplied bucket name, or throw\n * {@link InvalidStorageBucketError}.\n *\n * The bucket is the *other* caller-controlled routing value in an upload\n * request, and it was the one nobody validated. `LocalStorageController`\n * builds `join(basePath, bucket)` and then checks containment against that\n * result, so a bucket of `../../etc` moved the boundary rather than crossing\n * it — the guard passed because the guard's reference point was the attacker's.\n * The containment check now resolves against the storage root, and this is the\n * check at the route boundary that stops the value before it gets there.\n *\n * A bucket is configuration, not user data: there is no legitimate caller that\n * needs a separator, a leading dot, or a `..` in one. So this refuses rather\n * than repairs, exactly as {@link canonicalStorageKey} does — a rewritten\n * bucket would silently store the object somewhere the caller did not ask for.\n *\n * Returns `undefined` when the caller named no bucket (absent, or an empty\n * form field), which is how every controller spells \"use my default\". An empty\n * string used to reach `getFullPath` and resolve to the storage *root* rather\n * than the `default` bucket, which is a third place a bare key did not\n * round-trip.\n */\nexport function canonicalStorageBucket(rawBucket: string | undefined | null): string | undefined {\n if (rawBucket === undefined || rawBucket === null || rawBucket === \"\") return undefined;\n if (rawBucket.length > MAX_STORAGE_BUCKET_LENGTH) {\n throw new InvalidStorageBucketError(\n `Storage bucket exceeds the maximum length of ${MAX_STORAGE_BUCKET_LENGTH} characters.`\n );\n }\n if (!STORAGE_BUCKET_PATTERN.test(rawBucket)) {\n throw new InvalidStorageBucketError(\n \"Storage bucket must be a single name of letters, digits, '.', '_' or '-', \" +\n \"starting with a letter or digit.\"\n );\n }\n return rawBucket;\n}\n\n/**\n * The prefix an object store's listing should be given for a caller's key, and\n * the key a listing should hand back for a folder.\n *\n * The three controllers answer the same question in two different ways, and\n * they used to disagree about the answer. `LocalStorageController` resolves a\n * *directory* on disk, so `listObjects(\"products/images\")` and\n * `listObjects(\"products/images/\")` both list what is inside it. An object\n * store under `Delimiter: \"/\"` does not: `Prefix: \"products/images\"` matches\n * `products/images.txt` and `productsomething/`, and returns none of the files\n * inside `products/images/`. So the same call — the SDK's own documented one —\n * answered one thing against local dev and another against the S3 bucket in\n * production, which is the worst place for a divergence to live.\n *\n * `listingPrefix` is what to *send*: a trailing slash, always, because that is\n * the only spelling that means \"inside this folder\" to a delimiter listing.\n * `folderKey` is what to *return* for a common prefix: no trailing slash, the\n * form the local controller has always used, so a `fullPath` from a listing is\n * a key you can pass straight back to any of them.\n */\nexport function listingPrefix(rawPrefix: string): string | undefined {\n const key = rawPrefix.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n return key === \"\" ? undefined : `${key}/`;\n}\n\n/** @see listingPrefix */\nexport function folderKey(rawPrefix: string): string {\n return rawPrefix.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n\n/**\n * A listing asked for paging a controller cannot honour: a page size below one,\n * or a page token it never issued.\n *\n * Refused rather than coerced. A page size of 0 answered an empty page whose\n * next token was the one it had been handed, so `while (pageToken)` never\n * ended; a token of `-1` read before the first entry and crashed. The route\n * turns this into a 400.\n */\nexport class InvalidListOptionsError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidListO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ACb,KAAK,OAAO;CAChB;AACJ"}
1
+ {"version":3,"file":"keys-DmK8vGhX.js","names":[],"sources":["../src/storage/keys.ts"],"sourcesContent":["/**\n * Canonical storage keys and bucket names.\n *\n * Storage is not under RLS, so a `storageAuthorize` hook is the whole access\n * control model — and a hook can only be correct if the key it is shown is the\n * key that is written. That is the invariant this module exists to hold: one\n * canonical string, computed once per request, handed to the hook, to the\n * controller, and to the download token alike.\n *\n * ## Why rejecting beats stripping\n *\n * The previous `sanitizeStorageKey` *stripped* `../` in a single pass. Two\n * things were wrong with that, and only one of them was the obvious one.\n *\n * The obvious one: a single pass is not a fixed point. `....//` contains `../`\n * at offset 2, so removing it leaves `../` behind — the sanitizer manufactured\n * the traversal it was there to remove. `users/alice/....//bob/x` came out as\n * `users/alice/../bob/x`, which a prefix hook reads as alice's (it starts with\n * `users/alice/`) and the filesystem reads as bob's. The hook approved one\n * object and the controller wrote another.\n *\n * The subtler one, and the reason this is a rewrite rather than a loop: even a\n * correct strip is a silent rewrite. A caller who asks to store at `a/../b` and\n * gets an object at `a/b` was not protected, they were misled — and every later\n * read, ownership row and audit line now refers to a path nobody chose. So a key\n * that means something other than what it says is refused (400), not repaired.\n *\n * Note what is NOT traversal under this rule: `....` is an ordinary directory\n * name, and `users/alice/....//bob/x` canonicalizes to\n * `users/alice/..../bob/x` — still comfortably inside alice's prefix, which is\n * exactly right. Only a real `..` segment is refused.\n */\n\nimport { DEFAULT_STORAGE_SOURCE_KEY } from \"@rebasepro/types\";\n\n/**\n * `path.posix.normalize`, without `node:path`.\n *\n * A storage key is a POSIX-shaped string that never touches a filesystem, so\n * reaching for `node:path` to fold `.` and `//` out of it was always a little\n * wrong on its own terms — on Windows the platform `path` would have applied\n * different rules to the same key. It also put the module that every storage\n * read, ownership row and audit line goes through on the list of things that\n * only run in a Node process.\n *\n * This is the algorithm Node implements, transcribed: segments are folded left\n * to right, `..` pops unless it would climb past the root of a relative path,\n * and both the leading and the trailing separator survive the round trip. The\n * `..` branch is unreachable from {@link canonicalStorageKey}, which refuses\n * those keys outright before it gets here — it exists so that this function is\n * *the* normalizer rather than a subset of one, and\n * `storage-keys.property.test.ts` holds it to that with a property test against\n * `path.posix.normalize` itself. Exported for exactly that — nothing outside\n * this module should be normalizing a key.\n */\nexport function normalizePosix(input: string): string {\n if (input.length === 0) return \".\";\n const isAbsolute = input.startsWith(\"/\");\n const trailingSeparator = input.endsWith(\"/\");\n\n const segments: string[] = [];\n for (const segment of input.split(\"/\")) {\n if (segment === \"\" || segment === \".\") continue;\n if (segment === \"..\") {\n if (segments.length > 0 && segments[segments.length - 1] !== \"..\") segments.pop();\n else if (!isAbsolute) segments.push(\"..\");\n continue;\n }\n segments.push(segment);\n }\n\n const joined = segments.join(\"/\");\n if (joined === \"\") {\n if (isAbsolute) return \"/\";\n return trailingSeparator ? \"./\" : \".\";\n }\n const withTrailing = trailingSeparator ? `${joined}/` : joined;\n return isAbsolute ? `/${withTrailing}` : withTrailing;\n}\n\n/** Longest key accepted, in UTF-16 code units. Matches the previous cap. */\nexport const MAX_STORAGE_KEY_LENGTH = 1024;\n\n/**\n * A key that cannot be canonicalized. Carries no path back to the caller\n * beyond what they sent, so it is safe to surface as a 400 message.\n */\nexport class InvalidStorageKeyError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidStorageKeyError\";\n }\n}\n\n/**\n * Canonicalize a caller-supplied storage key, or throw\n * {@link InvalidStorageKeyError}.\n *\n * Normalizations applied (safe, idempotent, and meaning-preserving):\n * - leading slashes removed — `/a/b` and `a/b` name the same object\n * - `.` segments and repeated slashes collapsed\n *\n * Refusals (the key means something other than what it says):\n * - any `..` segment, on either separator, at any depth\n * - null bytes\n * - keys longer than {@link MAX_STORAGE_KEY_LENGTH}\n *\n * A trailing slash is preserved: it is how the folder route marks a prefix.\n */\nexport function canonicalStorageKey(rawKey: string): string {\n if (rawKey.includes(\"\\0\")) {\n throw new InvalidStorageKeyError(\"Storage key contains a null byte.\");\n }\n if (rawKey.length > MAX_STORAGE_KEY_LENGTH) {\n throw new InvalidStorageKeyError(\n `Storage key exceeds the maximum length of ${MAX_STORAGE_KEY_LENGTH} characters.`\n );\n }\n\n // Split on both separators: `path.join` treats `\\` as a separator on\n // Windows, so `..\\` is traversal there even though POSIX reads it as a\n // filename. Checked against the RAW key, before any normalization — the\n // whole point is that `a/../b` is refused rather than quietly turned into\n // `b`.\n if (rawKey.split(/[\\\\/]/).some((segment) => segment === \"..\")) {\n throw new InvalidStorageKeyError(\n \"Storage key contains a '..' path segment. Keys must name an object directly.\"\n );\n }\n\n const withoutLeadingSlashes = rawKey.replace(/^\\/+/, \"\");\n if (withoutLeadingSlashes === \"\") return \"\";\n\n // Whether the key names a *directory* rather than an object: it ends with a\n // separator, or its last segment is the `.` that means \"this directory\".\n //\n // Recorded before normalizing, because normalization drops the\n // distinction in one of those two spellings and not the other: `public/.`\n // becomes `public` while `public/./` stays `public/`. That asymmetry breaks\n // the rule this module states — a trailing slash is preserved, because it is\n // how the folder route marks a prefix — and it is not cosmetic on `list`,\n // where a prefix of `public` also matches `publicity/` and hands back keys\n // the caller never asked for.\n const denotesDirectory = /(?:^|\\/)\\.?$/.test(withoutLeadingSlashes);\n\n // Safe now: with no `..` segment in the input, `normalize` can only collapse\n // `.` and duplicate slashes — it cannot climb.\n const normalized = normalizePosix(withoutLeadingSlashes);\n\n // `normalize(\".\")`, and `normalize(\"./\")` → `./`; neither names an object.\n if (normalized === \".\" || normalized === \"./\") return \"\";\n\n // Defensive: nothing reaching here still carries a leading `./`, since the\n // leading slashes are already gone and `normalize` only emits `./` for a\n // key that normalizes to nothing — which returned above.\n const key = normalized.replace(/^\\.\\//, \"\").replace(/^\\/+/, \"\");\n if (key === \"\") return \"\";\n return denotesDirectory && !key.endsWith(\"/\") ? `${key}/` : key;\n}\n\n/**\n * Canonicalize, or return `null` when the key is not canonicalizable.\n *\n * For callers that must fail closed without an exception — the download-token\n * middleware compares a request path against a granted path, and a key it\n * cannot canonicalize simply matches nothing.\n */\nexport function tryCanonicalStorageKey(rawKey: string): string | null {\n try {\n return canonicalStorageKey(rawKey);\n } catch {\n return null;\n }\n}\n\n/**\n * Canonicalize the storage *source* a request names (`?storageId=`), so that\n * \"the default source\" has exactly one spelling.\n *\n * The default source can be asked for three ways — the parameter omitted, sent\n * empty, or sent as the literal `(default)` — and all three resolve to the same\n * controller. Without a single spelling, the value derived when a download\n * token is minted and the value derived when it is presented can differ for the\n * same object, which is either a spurious 403 or, if the comparison is dropped\n * to stop those, no scoping at all.\n *\n * Deliberately *not* validated against the registry: this is a naming rule, not\n * an existence check, and it must give the same answer in `auth/` (which has no\n * registry) as in the storage routes. An id that names no source still\n * canonicalizes to itself and simply matches only itself.\n */\nexport function canonicalStorageId(rawStorageId: string | undefined | null): string {\n if (rawStorageId === undefined || rawStorageId === null) return DEFAULT_STORAGE_SOURCE_KEY;\n const trimmed = rawStorageId.trim();\n return trimmed === \"\" ? DEFAULT_STORAGE_SOURCE_KEY : trimmed;\n}\n\n/**\n * Longest bucket name accepted. 63 is the S3/GCS limit, and a local bucket is\n * one directory name, so the tighter of the two bounds everything.\n */\nexport const MAX_STORAGE_BUCKET_LENGTH = 63;\n\n/** A bucket name that does not name a bucket. See {@link canonicalStorageBucket}. */\nexport class InvalidStorageBucketError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidStorageBucketError\";\n }\n}\n\n/**\n * One path segment: letters, digits, `.`, `_`, `-`, first character\n * alphanumeric. Deliberately narrow — it is the intersection of what S3, GCS\n * and a filesystem directory all accept, and it makes `..`, `.tus-uploads`,\n * absolute paths and anything containing a separator unrepresentable.\n */\nconst STORAGE_BUCKET_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\n\n/**\n * Canonicalize a caller-supplied bucket name, or throw\n * {@link InvalidStorageBucketError}.\n *\n * The bucket is the *other* caller-controlled routing value in an upload\n * request, and it was the one nobody validated. `LocalStorageController`\n * builds `join(basePath, bucket)` and then checks containment against that\n * result, so a bucket of `../../etc` moved the boundary rather than crossing\n * it — the guard passed because the guard's reference point was the attacker's.\n * The containment check now resolves against the storage root, and this is the\n * check at the route boundary that stops the value before it gets there.\n *\n * A bucket is configuration, not user data: there is no legitimate caller that\n * needs a separator, a leading dot, or a `..` in one. So this refuses rather\n * than repairs, exactly as {@link canonicalStorageKey} does — a rewritten\n * bucket would silently store the object somewhere the caller did not ask for.\n *\n * Returns `undefined` when the caller named no bucket (absent, or an empty\n * form field), which is how every controller spells \"use my default\". An empty\n * string used to reach `getFullPath` and resolve to the storage *root* rather\n * than the `default` bucket, which is a third place a bare key did not\n * round-trip.\n */\nexport function canonicalStorageBucket(rawBucket: string | undefined | null): string | undefined {\n if (rawBucket === undefined || rawBucket === null || rawBucket === \"\") return undefined;\n if (rawBucket.length > MAX_STORAGE_BUCKET_LENGTH) {\n throw new InvalidStorageBucketError(\n `Storage bucket exceeds the maximum length of ${MAX_STORAGE_BUCKET_LENGTH} characters.`\n );\n }\n if (!STORAGE_BUCKET_PATTERN.test(rawBucket)) {\n throw new InvalidStorageBucketError(\n \"Storage bucket must be a single name of letters, digits, '.', '_' or '-', \" +\n \"starting with a letter or digit.\"\n );\n }\n return rawBucket;\n}\n\n/**\n * The prefix an object store's listing should be given for a caller's key, and\n * the key a listing should hand back for a folder.\n *\n * The three controllers answer the same question in two different ways, and\n * they used to disagree about the answer. `LocalStorageController` resolves a\n * *directory* on disk, so `listObjects(\"products/images\")` and\n * `listObjects(\"products/images/\")` both list what is inside it. An object\n * store under `Delimiter: \"/\"` does not: `Prefix: \"products/images\"` matches\n * `products/images.txt` and `productsomething/`, and returns none of the files\n * inside `products/images/`. So the same call — the SDK's own documented one —\n * answered one thing against local dev and another against the S3 bucket in\n * production, which is the worst place for a divergence to live.\n *\n * `listingPrefix` is what to *send*: a trailing slash, always, because that is\n * the only spelling that means \"inside this folder\" to a delimiter listing.\n * `folderKey` is what to *return* for a common prefix: no trailing slash, the\n * form the local controller has always used, so a `fullPath` from a listing is\n * a key you can pass straight back to any of them.\n */\nexport function listingPrefix(rawPrefix: string): string | undefined {\n const key = rawPrefix.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n return key === \"\" ? undefined : `${key}/`;\n}\n\n/** @see listingPrefix */\nexport function folderKey(rawPrefix: string): string {\n return rawPrefix.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n\n/**\n * A listing asked for paging a controller cannot honour: a page size below one,\n * or a page token it never issued.\n *\n * Refused rather than coerced. A page size of 0 answered an empty page whose\n * next token was the one it had been handed, so `while (pageToken)` never\n * ended; a token of `-1` read before the first entry and crashed. The route\n * turns this into a 400.\n */\nexport class InvalidListOptionsError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidListOptionsError\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,SAAgB,eAAe,OAAuB;CAClD,IAAI,MAAM,WAAW,GAAG,OAAO;CAC/B,MAAM,aAAa,MAAM,WAAW,GAAG;CACvC,MAAM,oBAAoB,MAAM,SAAS,GAAG;CAE5C,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,WAAW,MAAM,MAAM,GAAG,GAAG;EACpC,IAAI,YAAY,MAAM,YAAY,KAAK;EACvC,IAAI,YAAY,MAAM;GAClB,IAAI,SAAS,SAAS,KAAK,SAAS,SAAS,SAAS,OAAO,MAAM,SAAS,IAAI;QAC3E,IAAI,CAAC,YAAY,SAAS,KAAK,IAAI;GACxC;EACJ;EACA,SAAS,KAAK,OAAO;CACzB;CAEA,MAAM,SAAS,SAAS,KAAK,GAAG;CAChC,IAAI,WAAW,IAAI;EACf,IAAI,YAAY,OAAO;EACvB,OAAO,oBAAoB,OAAO;CACtC;CACA,MAAM,eAAe,oBAAoB,GAAG,OAAO,KAAK;CACxD,OAAO,aAAa,IAAI,iBAAiB;AAC7C;;AAGA,IAAa,yBAAyB;;;;;AAMtC,IAAa,yBAAb,cAA4C,MAAM;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uBAAuB,KAAK,SAAS,GACtC,MAAM,IAAI,0BACN,4GAEJ;CAEJ,OAAO;AACX;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,cAAc,WAAuC;CACjE,MAAM,MAAM,UAAU,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,QAAQ,EAAE;CAC5D,OAAO,QAAQ,KAAK,KAAA,IAAY,GAAG,IAAI;AAC3C;;AAGA,SAAgB,UAAU,WAA2B;CACjD,OAAO,UAAU,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,QAAQ,EAAE;AAC3D;;;;;;;;;;AAWA,IAAa,0BAAb,cAA6C,MAAM;CAC/C,YAAY,SAAiB;EACzB,MAAM,OAAO;EACb,KAAK,OAAO;CAChB;AACJ"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * EXPERIMENTAL. The admin panel's MCP endpoint: `POST /api/admin/apps/mcp`,
3
+ * for the person signed in to the admin panel.
4
+ *
5
+ * The admin panel opens a saved app (`apps/saved-apps.ts`) the way Claude
6
+ * opens one: the MCP App view in a sandboxed frame, its tool calls relayed
7
+ * here. So an app runs in the admin panel exactly as in the conversation —
8
+ * the same compiled code, the same view, the same data tools as the same
9
+ * person under their RLS — and the frame holds no session: it has no network
10
+ * of its own, and the page relays its calls.
11
+ *
12
+ * What it accepts: the backend's own session, through the auth adapter as
13
+ * every data request is authenticated, with the roles the database holds now.
14
+ * Not an anonymous session. A caller gets the `data:*` scopes, which reach no
15
+ * further than the REST data API does for the same person: every call still
16
+ * runs under their RLS.
17
+ *
18
+ * Independent of `REBASE_MCP_ENABLED`: no credential leaves the backend.
19
+ *
20
+ * @module
21
+ */
22
+ import type { Hono } from "hono";
23
+ import type { HonoEnv } from "../api/types.js";
24
+ import { type McpRoutesConfig } from "./mcp-routes.js";
25
+ /** Where it is mounted, under `basePath`. */
26
+ export declare const ADMIN_APPS_MCP_PATH = "/admin/apps/mcp";
27
+ export type AdminAppsMcpConfig = Omit<McpRoutesConfig, "authenticate" | "resolveApiKey" | "identity" | "jwt" | "vocabulary">;
28
+ export declare function createAdminAppsMcpRoutes(config: AdminAppsMcpConfig): Hono<HonoEnv>;
@@ -71,7 +71,7 @@ export interface McpRoutesConfig {
71
71
  /**
72
72
  * The deployment's auth adapter. A write to the auth collection is user
73
73
  * administration, and the adapter holds it to the rules `/admin/users`
74
- * does. Without one, those rows are written as any table's.
74
+ * does. Without one, those rows are written like any table's.
75
75
  */
76
76
  getAuthAdapter?(): AuthAdapter | undefined;
77
77
  /** The server's own name and version, for `initialize`. */
@@ -23,8 +23,8 @@
23
23
  */
24
24
  import type { AuthAdapter, CallerCredential, CollectionConfig, DataDriver } from "@rebasepro/types";
25
25
  import type { McpConfirmationPlan } from "./confirmation.js";
26
- import { SHOW_APP_CODE_GUIDE, SHOW_APP_ESSENTIALS, SHOW_APP_GUIDE_TOOL } from "./show-app-guide.js";
27
- export { SHOW_APP_CODE_GUIDE, SHOW_APP_ESSENTIALS, SHOW_APP_GUIDE_TOOL };
26
+ import { SHOW_APP_CODE_GUIDE, SHOW_APP_ESSENTIALS, SHOW_APP_GUIDE_TOOL, showAppArtifactGuide } from "./show-app-guide.js";
27
+ export { SHOW_APP_CODE_GUIDE, SHOW_APP_ESSENTIALS, SHOW_APP_GUIDE_TOOL, showAppArtifactGuide };
28
28
  /** The identity a tool call runs as. Comes from the verified access token. */
29
29
  export interface McpCaller {
30
30
  uid: string;
@@ -98,6 +98,14 @@ export interface McpToolDefinition {
98
98
  * so the reply is not twice its size. Defaults to true.
99
99
  */
100
100
  structuredContent?: boolean;
101
+ /**
102
+ * The JSON Schema of the structured result, listed with the tool so a
103
+ * client — or a page calling the tool through one, such as a Claude
104
+ * artifact — reads the shape rather than guesses it. A client may check
105
+ * every result against it, so it describes what every result holds and
106
+ * no more: loose where a result varies.
107
+ */
108
+ outputSchema?: Record<string, unknown>;
101
109
  /**
102
110
  * The MCP App view a host shows this tool's result in (see
103
111
  * `mcp-apps.ts`). A tool with one is offered only where that view is
@@ -80,6 +80,13 @@ export interface McpViewPayload {
80
80
  * them through the host. Absent where a read failed.
81
81
  */
82
82
  seeds?: McpViewSeed[];
83
+ /**
84
+ * When the server began reading the rows the result carries (show_collection's
85
+ * page, show_app's seeds), in epoch milliseconds. The view serves them in
86
+ * place of a read only while that is recent, so a host that draws a stored
87
+ * result again later reads afresh.
88
+ */
89
+ readAt?: number;
83
90
  }
84
91
  /** A page read ahead for a view: the rows, the read's arguments, and the count where the server took it. */
85
92
  export interface McpViewSeed {
@@ -176,7 +176,9 @@ export interface GrantSummary {
176
176
  * server that cannot persist a code is not a degraded authorization server, it
177
177
  * is one that hands out credentials it cannot check.
178
178
  */
179
- export declare function createOAuthStore(driver: DataDriver, options?: {
179
+ export declare function createOAuthStore(
180
+ /** Only its SQL escape hatch is read. */
181
+ driver: Pick<DataDriver, "admin">, options?: {
180
182
  /**
181
183
  * Default `true`. `false` is a backend that changes nothing in its
182
184
  * database: `ensureTables` creates and revokes nothing, and throws
@@ -18,3 +18,12 @@ export declare const SHOW_APP_GUIDE_TOOL = "show_app_guide";
18
18
  */
19
19
  export declare const SHOW_APP_ESSENTIALS = "\nCall show_app_guide before writing the code: it gives every hook, component and prop an app may use, with a worked example. Props guessed from other libraries draw nothing. In short:\n- One TSX module, default-exporting a React component with no props. Its only imports: \"react\"; \"@rebasepro/app\" (useRows, useRow, useRowCount, useAggregate, useRowWrites: the project's rows as the user); \"@rebasepro/cms\" (CollectionPanel, RecordForm, FormField, RecordDetail, FieldValue, useSidePanel: the admin panel's own views and forms); \"@rebasepro/ui\" (the UI kit: SplitView, KpiGrid, KpiTile, ChartCard, BarChart, TimeSeriesChart, Card, Button, Tabs, \u2026).\n- A list and a form: <SplitView master={\u2026} detail={\u2026} selected={\u2026} onClearSelection={\u2026} /> inside a parent with a height (style={{ height: 560 }}), never grid columns side by side.\n- Figures and charts: KpiTile and BarChart, not drawn by hand.\n- Tailwind's standard utilities only: an arbitrary value (h-[560px]) does nothing.";
20
20
  export declare const SHOW_APP_CODE_GUIDE: string;
21
+ /**
22
+ * EXPERIMENTAL. The guide's last part, where the artifact kit is served: how
23
+ * to make the same app a Claude artifact — a page that keeps, that its owner
24
+ * shares inside their organization, and that reads the project as whoever
25
+ * opens it, through their own Rebase connector. Only for a server that knows
26
+ * where the kit is (`kitUrl`, the published `rebase-artifact.js`), so nothing
27
+ * points the model at a script that is not there.
28
+ */
29
+ export declare function showAppArtifactGuide(kitUrl: string): string;
@@ -3,11 +3,11 @@ import __rebaseProcess from "process";
3
3
  globalThis.process ??= __rebaseProcess;
4
4
  __rebaseCreateRequire(import.meta.url);
5
5
  import { a as RebaseClientError, i as RebaseApiError, o as isUnsupported } from "./data_driver-D0mg1Y_x.js";
6
- import { D as Vector, E as GeoPoint, S as hasFieldOperation, T as EntityRelation, _ as normalizeOrderBy, c as collectAllPages, l as paginateFind, u as resolveFindWindow, w as EntityReference } from "./filter-dialect-Cbzt7lO9.js";
7
- import { rt as toCanonicalOp, tt as parseRelationAggregateSort } from "./src-0nCWajy7.js";
6
+ import { D as Vector, E as GeoPoint, S as hasFieldOperation, T as EntityRelation, _ as normalizeOrderBy, c as collectAllPages, l as paginateFind, u as resolveFindWindow, w as EntityReference } from "./filter-dialect-CgeSm3Kl.js";
7
+ import { it as toCanonicalOp, nt as parseRelationAggregateSort, tt as parseCaseFoldedFieldPath } from "./src-CE9LRXDq.js";
8
8
  import { t as splitSearchTerms } from "./strings.es-B7QLnHh2.js";
9
- import { a as byIdRead, f as rebaseReviver, h as unref, i as buildQueryString, m as withETag, n as MemoryOfflineStore, p as etagOf, r as SDKQueryBuilder, s as createMutationId, t as IndexedDBOfflineStore, u as invalidBulkBody } from "./offline-store-C2Sy3Kwl-C8KIwabG.js";
10
- //#region ../client/dist/offline-Cy6woFyt.js
9
+ import { a as byIdRead, f as rebaseReviver, h as unref, i as buildQueryString, m as withETag, n as MemoryOfflineStore, p as etagOf, r as SDKQueryBuilder, s as createMutationId, t as IndexedDBOfflineStore, u as invalidBulkBody } from "./offline-store-B7F5mimt-Bh5f-dWu.js";
10
+ //#region ../client/dist/offline-B6J1YUWF.js
11
11
  /**
12
12
  * Lossless round-tripping of rows through the offline store.
13
13
  *
@@ -540,6 +540,10 @@ function matchesOperator(rowValue, op, filterValue) {
540
540
  }
541
541
  }
542
542
  function isTuple(value) {
543
+ if (Array.isArray(value) && value.length === 1 && typeof value[0] === "string") {
544
+ const op = toCanonicalOp(value[0]);
545
+ return op === "is-null" || op === "is-not-null";
546
+ }
543
547
  return Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && toCanonicalOp(value[0]) !== void 0;
544
548
  }
545
549
  /**
@@ -575,6 +579,19 @@ function conditionTuples(condition) {
575
579
  unreadable: tuples.length !== condition.length || tuples.length === 0
576
580
  };
577
581
  }
582
+ /**
583
+ * The value a filter key reads off a row: the field itself, or — for
584
+ * `lower(field)` / `upper(field)` — the field's text folded to that case.
585
+ * JavaScript's folding is not the database's for every script, so a query that
586
+ * folds is never called exact ({@link isExactlyEvaluable}).
587
+ */
588
+ function filterValueOf(row, field) {
589
+ const folded = parseCaseFoldedFieldPath(field);
590
+ if (!folded) return row[field];
591
+ const value = row[folded.field];
592
+ if (value === null || value === void 0) return value;
593
+ return folded.fn === "lower" ? String(value).toLowerCase() : String(value).toUpperCase();
594
+ }
578
595
  /** Evaluate a `where` clause: every field, and every tuple on a field, AND-ed. */
579
596
  function matchesWhere(row, where) {
580
597
  if (!where) return true;
@@ -582,7 +599,7 @@ function matchesWhere(row, where) {
582
599
  const { tuples } = conditionTuples(condition);
583
600
  for (const [rawOp, value] of tuples) {
584
601
  const op = toCanonicalOp(rawOp) ?? rawOp;
585
- if (!matchesOperator(row[field], op, value)) return false;
602
+ if (!matchesOperator(filterValueOf(row, field), op, value)) return false;
586
603
  }
587
604
  }
588
605
  return true;
@@ -596,7 +613,7 @@ function matchesLogical(row, condition) {
596
613
  return condition.type === "or" ? children.some((c) => matchesLogical(row, c)) : children.every((c) => matchesLogical(row, c));
597
614
  }
598
615
  const op = toCanonicalOp(condition.operator) ?? condition.operator;
599
- return matchesOperator(row[condition.column], op, condition.value);
616
+ return matchesOperator(filterValueOf(row, condition.column), op, condition.value);
600
617
  }
601
618
  /**
602
619
  * Approximate the server's full-text search with a case-insensitive substring
@@ -767,15 +784,18 @@ function isExactlyEvaluable(params) {
767
784
  if (logicalReachesThroughRelation(params.logical)) return false;
768
785
  return true;
769
786
  }
770
- /** Does any filter key reach outside this row — `applications.status`? */
787
+ /**
788
+ * Does any filter key reach outside this row — `applications.status` — or fold
789
+ * a field's case, which the database does by its own rules?
790
+ */
771
791
  function whereReachesThroughRelation(where) {
772
- return where ? Object.keys(where).some((field) => field.includes(".")) : false;
792
+ return where ? Object.keys(where).some((field) => field.includes(".") || parseCaseFoldedFieldPath(field) !== void 0) : false;
773
793
  }
774
794
  /** The same question, through an `and(...)`/`or(...)` tree. */
775
795
  function logicalReachesThroughRelation(condition, depth = 0) {
776
796
  if (!condition || depth > 32) return false;
777
797
  if ("type" in condition) return (condition.conditions ?? []).some((c) => logicalReachesThroughRelation(c, depth + 1));
778
- return typeof condition.column === "string" && condition.column.includes(".");
798
+ return typeof condition.column === "string" && (condition.column.includes(".") || parseCaseFoldedFieldPath(condition.column) !== void 0);
779
799
  }
780
800
  /**
781
801
  * Would sorting `rows` locally reproduce the order the server would have sent?
@@ -1377,6 +1397,16 @@ var OfflineManager = class {
1377
1397
  * user's, unconfirmed: it would go out with no credentials, as nobody. It
1378
1398
  * queues for its author instead, as it does offline.
1379
1399
  */
1400
+ /**
1401
+ * A filtered write runs on the server or not at all: refused while writes
1402
+ * are being queued, and while this collection has queued writes the
1403
+ * server has not seen — the filter would be judged against rows they are
1404
+ * about to change.
1405
+ */
1406
+ assertOnlineForFilteredWrite(slug, method) {
1407
+ if (this.sendsWrites() && !this.hasPendingIn(slug)) return;
1408
+ throw new RebaseClientError(`${method}() on "${slug}" needs the server: which rows a filter matches is the server's answer, so a filtered write is not queued offline, nor sent ahead of writes this collection still has queued.`, { code: "OFFLINE_FILTERED_WRITE_UNSUPPORTED" });
1409
+ }
1380
1410
  sendsWrites() {
1381
1411
  return this.connectivity.shouldAttempt() && !this.unverified;
1382
1412
  }
@@ -1624,7 +1654,7 @@ var OfflineManager = class {
1624
1654
  if (this.sendsWrites()) try {
1625
1655
  const row = await inner.upsert(data, options);
1626
1656
  this.connectivity.markSuccess();
1627
- await this.ingest(slug, [row], ticket);
1657
+ if (row) await this.ingest(slug, [row], ticket);
1628
1658
  this.notifyCollection(slug);
1629
1659
  this.scheduleRefresh(slug);
1630
1660
  return row;
@@ -1633,6 +1663,7 @@ var OfflineManager = class {
1633
1663
  this.connectivity.markFailure();
1634
1664
  }
1635
1665
  const rowId = data.id;
1666
+ if (options?.where || options?.ignoreDuplicates) throw new RebaseClientError(`Cannot upsert into "${slug}" with \`where\` or \`ignoreDuplicates\` while offline: whether the stored row is kept is decided by the server, on the row it holds.`, { code: "OFFLINE_UPSERT_UNSUPPORTED" });
1636
1667
  if (options?.onConflict?.length || rowId === void 0) throw new RebaseClientError(`Cannot upsert into "${slug}" while offline: the row it would replace can only be found by the server. Upserting on the primary key, with the key in the row, is queued; upserting on a natural key is not.`, { code: "OFFLINE_UPSERT_UNSUPPORTED" });
1637
1668
  const row = optimisticRow(data, rowId);
1638
1669
  await this.enqueue({
@@ -1685,6 +1716,31 @@ var OfflineManager = class {
1685
1716
  this.notifyCollection(slug);
1686
1717
  return optimistic;
1687
1718
  },
1719
+ /**
1720
+ * Online only. Which rows a filter matches is the server's answer —
1721
+ * the local store holds a subset of them — so a filtered write is
1722
+ * never applied locally or queued. The rows it updated are folded
1723
+ * into the store; a filtered delete refreshes the collection.
1724
+ */
1725
+ updateWhere: async (query, data, options) => {
1726
+ const ticket = this.ticket() ?? await this.nextTicket();
1727
+ await this.ensureCollection(slug);
1728
+ this.assertOnlineForFilteredWrite(slug, "updateWhere");
1729
+ const rows = await inner.updateWhere(query, data, options);
1730
+ this.connectivity.markSuccess();
1731
+ await this.ingest(slug, rows, ticket);
1732
+ this.notifyCollection(slug);
1733
+ this.scheduleRefresh(slug);
1734
+ return rows;
1735
+ },
1736
+ deleteWhere: async (query, options) => {
1737
+ await this.ensureCollection(slug);
1738
+ this.assertOnlineForFilteredWrite(slug, "deleteWhere");
1739
+ const deleted = await inner.deleteWhere(query, options);
1740
+ this.connectivity.markSuccess();
1741
+ this.scheduleRefresh(slug);
1742
+ return deleted;
1743
+ },
1688
1744
  deleteMany: async (ids, options) => {
1689
1745
  const ticket = this.ticket() ?? await this.nextTicket();
1690
1746
  await this.ensureCollection(slug);
@@ -2731,6 +2787,10 @@ var OfflineManager = class {
2731
2787
  hasPending(slug, id) {
2732
2788
  return this.pendingIds(slug)?.writes.has(String(id)) ?? false;
2733
2789
  }
2790
+ /** Does this collection have any write the server has not seen? */
2791
+ hasPendingIn(slug) {
2792
+ return (this.pendingIds(slug)?.writes.size ?? 0) > 0;
2793
+ }
2734
2794
  /** Is this row one the server has never been told about? */
2735
2795
  isLocallyCreated(slug, idKey) {
2736
2796
  return this.pendingIds(slug)?.creates.has(idKey) ?? false;
@@ -3426,4 +3486,4 @@ var OfflineManager = class {
3426
3486
  //#endregion
3427
3487
  export { OfflineManager };
3428
3488
 
3429
- //# sourceMappingURL=offline-Cy6woFyt-CbjOQGD1.js.map
3489
+ //# sourceMappingURL=offline-B6J1YUWF-CEJLzvJw.js.map