better-supabase 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -16
- package/dist/actor-DaJjqD5R.d.ts +43 -0
- package/dist/channel-FQW-CnGR.d.ts +70 -0
- package/dist/cli/bin.js +1 -1
- package/dist/cli/codemod-DqV7612m.js +388 -0
- package/dist/cli/{config-D9R0o1LH.js → config-CPVpXP5I.js} +78 -8
- package/dist/cli/{config-SSKSTUl2.js → config-dtoekM0v.js} +1 -1
- package/dist/cli/{read-sets-CMa29t9a.js → diff-SjkO5rNr.js} +1 -220
- package/dist/cli/{dist-CFgGknmZ.js → dist-DBPdlPYK.js} +4 -4
- package/dist/cli/{dist-B1MvLv-M.js → dist-DreZ24Sz.js} +1 -1
- package/dist/cli/{dist-Du7VnEUG.js → dist-xn4wlboc.js} +112 -1
- package/dist/cli/{doctor-BOym3mbL.js → doctor-C_A-KEAz.js} +533 -50
- package/dist/cli/{env-BZ0uy8XK.js → env-DmKv_G4A.js} +1 -1
- package/dist/cli/gen-CIdSQZad.js +2 -0
- package/dist/cli/{gen-Ccn_p90L.js → gen-CjElD1Vw.js} +321 -88
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +4 -4
- package/dist/cli/{init-ClnxRYBF.js → init-DMa6M7hV.js} +2 -2
- package/dist/cli/{introspect-DxqfkVIv.js → introspect-BKlaIu_M.js} +2 -2
- package/dist/cli/{openapi-8WHjxiTJ.js → openapi-Cp5Fyta-.js} +1 -1
- package/dist/cli/read-sets-VQcPgxU9.js +436 -0
- package/dist/cli/{run-CP20LKk_.js → run-Bo_NLT5n.js} +16 -12
- package/dist/cli/{seed-5J6eu_Xg.js → seed-CUlqWh-8.js} +1 -1
- package/dist/cli/sql-CVx-1O8G.js +373 -0
- package/dist/cli/{version-5mW_8sY1.js → version-BCtlgDQx.js} +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +3 -10
- package/dist/clone-BfgmLU90.js +21 -0
- package/dist/{compiler-DB3aSFOA.d.ts → compiler-BXH_aZ7N.d.ts} +2 -2
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +4 -4
- package/dist/{config-C1CYcm6o.d.ts → config-Bv7gvfzC.d.ts} +185 -11
- package/dist/{config-CbvFmGD8.js → config-DreERlKo.js} +1 -1
- package/dist/{define-CRS2MRV3.d.ts → define-Bp_BZa5h.d.ts} +11 -7
- package/dist/{define-Bh0AqTik.js → define-cNKzqwL_.js} +202 -16
- package/dist/edge/index.d.ts +16 -5
- package/dist/edge/index.js +10 -7
- package/dist/{entitlements-Dm-FHpNH.d.ts → entitlements-BiJZ4t49.d.ts} +1 -1
- package/dist/env/index.d.ts +2 -2
- package/dist/env/index.js +34 -1
- package/dist/{errors-L0xK41y_.js → errors-DtwXa6b8.js} +1 -0
- package/dist/events/index.d.ts +3 -2
- package/dist/events/index.js +65 -12
- package/dist/events-aIO7vsIk.d.ts +230 -0
- package/dist/{result-CqEsbgYs.d.ts → executor-BunPOO-k.d.ts} +200 -1
- package/dist/{executor-CZ7ImRiD.d.ts → executor-Cghdstwu.d.ts} +1 -2
- package/dist/{executor-CVt6dD0B.js → executor-XycESQPH.js} +3 -3
- package/dist/hono/index.d.ts +17 -6
- package/dist/hono/index.js +40 -5
- package/dist/impersonation-BgSHAYLf.js +133 -0
- package/dist/{resolve-BAqQcwMW.d.ts → impersonation-BmePsuxz.d.ts} +36 -6
- package/dist/{index-BhHEC04r.d.ts → index-C7f8cOBM.d.ts} +2 -2
- package/dist/{index-Dy6kuF0P.d.ts → index-CLg87OBW.d.ts} +6 -1
- package/dist/{index-Cf-D2jk1.d.ts → index-CWMDdEr4.d.ts} +2 -2
- package/dist/{index-D5IfUIDh.d.ts → index-DOESKG27.d.ts} +33 -8
- package/dist/{index-DFmOpBGC.d.ts → index-DgILJRXj.d.ts} +35 -9
- package/dist/{index-RlLXd8dL.d.ts → index-DmXSxbLi.d.ts} +4 -4
- package/dist/{index-BBdvo-5d.d.ts → index-Dp2VDwog.d.ts} +49 -6
- package/dist/{index-528Ugmyp.d.ts → index-SaTsEfGP.d.ts} +76 -8
- package/dist/{index-BAy4tsAP.d.ts → index-fag8VJZ2.d.ts} +3 -4
- package/dist/index.d.ts +30 -13
- package/dist/index.js +10 -9
- package/dist/jobs/index.d.ts +147 -101
- package/dist/jobs/index.js +744 -237
- package/dist/{json-schema-DP6V7cbr.js → json-schema-m1fiwKgN.js} +22 -1
- package/dist/kit-events-CTFDfSwb.js +60 -0
- package/dist/kit-transport-B82k1djG.d.ts +33 -0
- package/dist/kit-transport-DJlHQUBU.js +55 -0
- package/dist/{config-BpxDfnbg.js → kits-CGLLrNPd.js} +37 -9
- package/dist/list/index.d.ts +1 -1
- package/dist/{live-BHakSWWo.d.ts → live-D9W2M5aO.d.ts} +6 -5
- package/dist/mcp/index.d.ts +25 -8
- package/dist/mcp/index.js +23 -14
- package/dist/{mfa-C7MNQ1Ob.d.ts → mfa-Cu96oJdw.d.ts} +2 -16
- package/dist/next/index.d.ts +31 -10
- package/dist/next/index.js +136 -27
- package/dist/notifications/index.d.ts +162 -0
- package/dist/notifications/index.js +264 -0
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +2 -2
- package/dist/orgs/index.d.ts +132 -0
- package/dist/orgs/index.js +245 -0
- package/dist/orpc/index.d.ts +28 -8
- package/dist/orpc/index.js +16 -3
- package/dist/otel/index.d.ts +21 -2
- package/dist/otel/index.js +50 -9
- package/dist/permdock-sql-C2Inc6Xc.d.ts +29 -0
- package/dist/permdock-sql-DgOfeixi.js +51 -0
- package/dist/plugin-DwARMuQp.js +59 -0
- package/dist/{plugin-bNhvJwRh.d.ts → plugin-o144f322.d.ts} +17 -5
- package/dist/plugins/actor/index.d.ts +5 -2
- package/dist/plugins/actor/index.js +22 -8
- package/dist/plugins/rules/index.d.ts +2 -2
- package/dist/plugins/rules/index.js +15 -10
- package/dist/plugins/soft-delete/index.d.ts +3 -3
- package/dist/plugins/soft-delete/index.js +14 -5
- package/dist/plugins/tenant/index.d.ts +2 -2
- package/dist/plugins/tenant/index.js +38 -20
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +4 -3
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/plugins/validation/index.js +26 -6
- package/dist/{pool-DFwEQwmN.d.ts → pool-C9voM4Kw.d.ts} +17 -6
- package/dist/postgres/index.d.ts +5 -5
- package/dist/postgres/index.js +20 -11
- package/dist/{postgrest-Bc-0Xw62.d.ts → postgrest-CruYKAvV.d.ts} +1 -1
- package/dist/{problem-BihjPR0t.js → problem-BW1KhzSG.js} +2 -1
- package/dist/{problem-U8UEKccv.d.ts → problem-Blxe8S31.d.ts} +1 -1
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +3 -3
- package/dist/{query-BMMSWbI7.js → query-CCbo44lG.js} +2 -2
- package/dist/queue-BYUCjr59.d.ts +252 -0
- package/dist/react/index.d.ts +8 -7
- package/dist/react/index.js +4 -3
- package/dist/react/server.d.ts +14 -3
- package/dist/react/server.js +10 -2
- package/dist/react/session.d.ts +7 -1
- package/dist/react/session.js +9 -1
- package/dist/{react-CQHMaESR.js → react-C_s7kiNz.js} +103 -11
- package/dist/{read-set-FWK8qQ58.js → read-set-DQFt1N_Y.js} +22 -1
- package/dist/realtime/index.d.ts +3 -3
- package/dist/realtime/index.js +5 -4
- package/dist/{refresh-BwYkyNOQ.d.ts → refresh-CFPX0Qft.d.ts} +1 -1
- package/dist/{resource-BJcaIfxi.d.ts → resource-DNRFP7KR.d.ts} +5 -5
- package/dist/{resource-My_y-Syh.js → resource-mqfJW4YF.js} +22 -7
- package/dist/respond-BR1fJWOB.d.ts +377 -0
- package/dist/{result-Bj6yt33D.js → result-BKiliPY7.js} +1 -1
- package/dist/server/index.d.ts +15 -12
- package/dist/server/index.js +11 -17
- package/dist/{server-BA75B0mT.js → server-B1mZ7CgQ.js} +259 -37
- package/dist/{shared-DnoCdMDr.js → shared-D1dRUrAg.js} +16 -2
- package/dist/signers-Cc6r98SW.d.ts +162 -0
- package/dist/{simplify-Cqvfr9dj.js → simplify-_0oUKqCd.js} +4 -115
- package/dist/sql/index.d.ts +283 -11
- package/dist/sql/index.js +8705 -775
- package/dist/{sql-B34HU2DI.js → sql-Coh6n4cC.js} +9 -2
- package/dist/ssr/index.d.ts +4 -4
- package/dist/ssr/index.js +1 -2
- package/dist/{standard-BRyBGTtp.js → standard-D7r6dMUu.js} +6 -3
- package/dist/{standard-BsaCYQJc.d.ts → standard-J4YgMOLm.d.ts} +1 -1
- package/dist/{stats-C_YxA2r1.js → stats-Bqob3WqT.js} +4 -4
- package/dist/storage/index.d.ts +4 -4
- package/dist/storage/index.js +155 -26
- package/dist/support-CEPwlw2G.d.ts +89 -0
- package/dist/support-view-B8SlToQX.d.ts +17 -0
- package/dist/support-view-g4YLBeqX.js +18 -0
- package/dist/support-wHnK6zp-.js +293 -0
- package/dist/{permdock-sql-C4KFzLc9.js → template-TxrGI5jR.js} +2 -31
- package/dist/{temporal-BwshQk0W.js → temporal-CVlIV2DZ.js} +17 -4
- package/dist/{temporal-required-CBNHT6ni.js → temporal-required-CAt4Dc9Z.js} +2 -2
- package/dist/testing/index.d.ts +132 -10
- package/dist/testing/index.js +476 -8
- package/dist/{types-DONv9SHN.d.ts → types-Dnf_wRDz.d.ts} +26 -3
- package/dist/user-change-CHFEUro1.js +49 -0
- package/dist/{webhooks-Bh_Jf_-l.js → verify-Ce49ETPz.js} +5 -5
- package/dist/{version-Bmf7_FzM.js → version-DOYTYwHP.js} +1 -1
- package/dist/{mfa-byfjruR9.js → view-Bn6HNKUe.js} +97 -98
- package/dist/{view-B64o81wp.d.ts → view-CbgObAeb.d.ts} +22 -31
- package/dist/webhooks/index.d.ts +135 -4
- package/dist/webhooks/index.js +588 -2
- package/dist/wire-D2dT86vi.js +35 -0
- package/package.json +27 -19
- package/schemas/config-v1.json +131 -1
- package/schemas/doctor-report-v1.json +11 -0
- package/skills/better-supabase/SKILL.md +9 -6
- package/skills/better-supabase/references/plugins.md +6 -3
- package/skills/better-supabase/references/troubleshooting.md +1 -0
- package/skills/better-supabase-api/SKILL.md +9 -2
- package/skills/better-supabase-api/references/adapters.md +11 -8
- package/skills/better-supabase-auth/SKILL.md +18 -7
- package/skills/better-supabase-auth/references/permdock.md +78 -11
- package/dist/cli/gen-D5cLCULx.js +0 -2
- package/dist/cli/sql-D4VbqmXi.js +0 -199
- package/dist/events-B21UOhvP.d.ts +0 -84
- package/dist/executor-B5IoUxLE.d.ts +0 -195
- package/dist/invalidate-CgxmRamI.js +0 -24
- package/dist/permdock-sql-DImJULY-.d.ts +0 -17
- package/dist/plugin-BqR6wKMB.js +0 -23
- package/dist/respond-DgIbdrt8.d.ts +0 -194
- package/dist/view-BrJI2LKp.js +0 -45
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { i as plain } from "./style-C0NFdJRL.js";
|
|
2
|
-
import { i as importModule } from "./config-D9R0o1LH.js";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
|
-
import { readFile } from "node:fs/promises";
|
|
6
|
-
import { compileReadSets } from "better-supabase/sql";
|
|
7
|
-
import { isReadSet } from "better-supabase";
|
|
8
2
|
//#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/base.js
|
|
9
3
|
var Diff = class {
|
|
10
4
|
diff(oldStr, newStr, options = {}) {
|
|
@@ -755,217 +749,4 @@ function fileDiff(path, current, next, paint = plain) {
|
|
|
755
749
|
return [...shown, ...hidden > 0 ? [paint("dim", `... ${hidden} more diff lines`)] : []].join("\n");
|
|
756
750
|
}
|
|
757
751
|
//#endregion
|
|
758
|
-
|
|
759
|
-
const PERMDOCK_CONFIGS = [
|
|
760
|
-
"permdock.config.ts",
|
|
761
|
-
"permdock.config.mts",
|
|
762
|
-
"permdock.config.js",
|
|
763
|
-
"permdock.config.mjs"
|
|
764
|
-
];
|
|
765
|
-
/** The PermDock config file in `root`, if there is one. */
|
|
766
|
-
function permdockConfig(root) {
|
|
767
|
-
return PERMDOCK_CONFIGS.find((file) => existsSync(resolve(root, file)));
|
|
768
|
-
}
|
|
769
|
-
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
770
|
-
const isString = (value) => typeof value === "string";
|
|
771
|
-
const strings = (value) => Array.isArray(value) ? value.filter(isString) : [];
|
|
772
|
-
const column = (value) => isRecord(value) && isString(value["column"]) ? { column: value["column"] } : void 0;
|
|
773
|
-
function manifestValue(value, accept) {
|
|
774
|
-
if (!isRecord(value)) return void 0;
|
|
775
|
-
if (isString(value["column"])) return { column: value["column"] };
|
|
776
|
-
return accept(value["value"]) ? { value: value["value"] } : void 0;
|
|
777
|
-
}
|
|
778
|
-
const roleValue = (value) => isString(value) || Array.isArray(value) && value.every(isString);
|
|
779
|
-
function membership(value) {
|
|
780
|
-
if (!isRecord(value) || !isString(value["table"])) return void 0;
|
|
781
|
-
const user = column(value["user"]);
|
|
782
|
-
const id = column(value["id"]);
|
|
783
|
-
const scope = manifestValue(value["scope"], isString);
|
|
784
|
-
if (!user || !id || !scope) return void 0;
|
|
785
|
-
const role = manifestValue(value["role"], roleValue);
|
|
786
|
-
const expiresAt = column(value["expiresAt"]);
|
|
787
|
-
return {
|
|
788
|
-
table: value["table"],
|
|
789
|
-
user,
|
|
790
|
-
scope,
|
|
791
|
-
id,
|
|
792
|
-
...role ? { role } : {},
|
|
793
|
-
...expiresAt ? { expiresAt } : {},
|
|
794
|
-
columns: strings(value["columns"])
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
/** Reads a parsed manifest; throws with the reason when it isn't version 1. */
|
|
798
|
-
function parseManifest(json) {
|
|
799
|
-
if (!isRecord(json)) throw new TypeError("not a JSON object");
|
|
800
|
-
if (json["version"] !== 1) throw new TypeError(`version ${String(json["version"])} is not supported (this release reads version 1)`);
|
|
801
|
-
const hook = json["hook"];
|
|
802
|
-
const rls = json["rls"];
|
|
803
|
-
const budget = isRecord(json["budget"]) ? json["budget"]["bytes"] : void 0;
|
|
804
|
-
return {
|
|
805
|
-
version: 1,
|
|
806
|
-
...typeof budget === "number" ? { budget } : {},
|
|
807
|
-
...isRecord(hook) && isString(hook["schema"]) && isString(hook["function"]) ? { hook: {
|
|
808
|
-
schema: hook["schema"],
|
|
809
|
-
function: hook["function"]
|
|
810
|
-
} } : {},
|
|
811
|
-
...isString(json["tenantClaim"]) ? { tenantClaim: json["tenantClaim"] } : {},
|
|
812
|
-
claims: (Array.isArray(json["claims"]) ? json["claims"] : []).flatMap((claim) => isRecord(claim) && isString(claim["name"]) && isString(claim["source"]) ? [{
|
|
813
|
-
name: claim["name"],
|
|
814
|
-
source: claim["source"]
|
|
815
|
-
}] : []),
|
|
816
|
-
memberships: (Array.isArray(json["memberships"]) ? json["memberships"] : []).flatMap((entry) => {
|
|
817
|
-
const parsed = membership(entry);
|
|
818
|
-
return parsed ? [parsed] : [];
|
|
819
|
-
}),
|
|
820
|
-
...isRecord(rls) && isString(rls["schema"]) ? { rls: {
|
|
821
|
-
schema: rls["schema"],
|
|
822
|
-
mode: rls["mode"] === "jwt" ? "jwt" : "database",
|
|
823
|
-
scopes: (Array.isArray(rls["scopes"]) ? rls["scopes"] : []).flatMap((scope) => isRecord(scope) && isString(scope["name"]) && isString(scope["type"]) ? [{
|
|
824
|
-
name: scope["name"],
|
|
825
|
-
type: scope["type"]
|
|
826
|
-
}] : []),
|
|
827
|
-
helpers: (Array.isArray(rls["helpers"]) ? rls["helpers"] : []).flatMap((helper) => isRecord(helper) && isString(helper["name"]) && isString(helper["args"]) && isString(helper["returns"]) ? [{
|
|
828
|
-
name: helper["name"],
|
|
829
|
-
args: helper["args"],
|
|
830
|
-
returns: helper["returns"],
|
|
831
|
-
execute: strings(helper["execute"])
|
|
832
|
-
}] : [])
|
|
833
|
-
} } : {},
|
|
834
|
-
decidingColumns: strings(json["decidingColumns"])
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
/** The keys of a parsed `permissions.catalog.json` whose entry has `rowConditions: true`. */
|
|
838
|
-
function rowConditionKeys(json) {
|
|
839
|
-
if (!isRecord(json) || !Array.isArray(json["permissions"])) throw new TypeError("has no permissions array");
|
|
840
|
-
const keys = /* @__PURE__ */ new Set();
|
|
841
|
-
for (const permission of json["permissions"]) if (isRecord(permission) && isString(permission["key"]) && permission["rowConditions"] === true) keys.add(permission["key"]);
|
|
842
|
-
return keys;
|
|
843
|
-
}
|
|
844
|
-
async function readJson(root, path) {
|
|
845
|
-
const absolute = resolve(root, path);
|
|
846
|
-
if (!existsSync(absolute)) return { missing: true };
|
|
847
|
-
try {
|
|
848
|
-
return { json: JSON.parse(await readFile(absolute, "utf8")) };
|
|
849
|
-
} catch (cause) {
|
|
850
|
-
return { problem: `${path}: ${cause instanceof Error ? cause.message : String(cause)}` };
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
/**
|
|
854
|
-
* Reads PermDock's JSON outputs: the manifest `permdock supabase inspect
|
|
855
|
-
* --out` writes and the catalog `permdock catalog` writes. Nothing is
|
|
856
|
-
* imported from PermDock. Returns `undefined` when the project has neither a
|
|
857
|
-
* PermDock config nor a manifest.
|
|
858
|
-
*/
|
|
859
|
-
async function readPermdock(root, paths) {
|
|
860
|
-
const config = permdockConfig(root);
|
|
861
|
-
const problems = [];
|
|
862
|
-
const manifestFile = await readJson(root, paths.manifest);
|
|
863
|
-
let manifest;
|
|
864
|
-
if ("json" in manifestFile) try {
|
|
865
|
-
manifest = parseManifest(manifestFile.json);
|
|
866
|
-
} catch (cause) {
|
|
867
|
-
problems.push(`${paths.manifest}: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
868
|
-
}
|
|
869
|
-
else if ("problem" in manifestFile) problems.push(manifestFile.problem);
|
|
870
|
-
if (!config && !manifest && "missing" in manifestFile) return void 0;
|
|
871
|
-
const catalogFile = await readJson(root, paths.catalog);
|
|
872
|
-
let rowConditions;
|
|
873
|
-
if ("json" in catalogFile) try {
|
|
874
|
-
rowConditions = rowConditionKeys(catalogFile.json);
|
|
875
|
-
} catch (cause) {
|
|
876
|
-
problems.push(`${paths.catalog}: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
877
|
-
}
|
|
878
|
-
else if ("problem" in catalogFile) problems.push(catalogFile.problem);
|
|
879
|
-
return {
|
|
880
|
-
...config ? { config } : {},
|
|
881
|
-
manifestPath: paths.manifest,
|
|
882
|
-
...manifest ? { manifest } : {},
|
|
883
|
-
catalogPath: paths.catalog,
|
|
884
|
-
...rowConditions ? { rowConditions } : {},
|
|
885
|
-
problems
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
/** How findings name the PermDock project: its config file or its manifest. */
|
|
889
|
-
const permdockSource = (project) => project.config ?? project.manifestPath;
|
|
890
|
-
const HOOK_MARKER = /^--\s*permdock:hook\s+v(\d+)([^\n]*)$/m;
|
|
891
|
-
const GRANTS_MARKER = /^--\s*permdock:grants\s+v(\d+)([^\n]*)$/m;
|
|
892
|
-
function markerFields(rest) {
|
|
893
|
-
const fields = /* @__PURE__ */ new Map();
|
|
894
|
-
for (const match of rest.matchAll(/(\w+)=(\S*)/g)) fields.set(match[1], match[2]);
|
|
895
|
-
return fields;
|
|
896
|
-
}
|
|
897
|
-
/** The `-- permdock:hook v1 schema=... tenant=... budget=... claims=...` line PermDock's hook file starts with. */
|
|
898
|
-
function parseHookMarker(sql) {
|
|
899
|
-
const match = HOOK_MARKER.exec(sql);
|
|
900
|
-
if (!match) return void 0;
|
|
901
|
-
const fields = markerFields(match[2]);
|
|
902
|
-
const budget = Number(fields.get("budget"));
|
|
903
|
-
const schema = fields.get("schema");
|
|
904
|
-
const tenantClaim = fields.get("tenant");
|
|
905
|
-
return {
|
|
906
|
-
version: Number(match[1]),
|
|
907
|
-
...schema ? { schema } : {},
|
|
908
|
-
...tenantClaim ? { tenantClaim } : {},
|
|
909
|
-
...Number.isFinite(budget) && fields.has("budget") ? { budget } : {},
|
|
910
|
-
claims: (fields.get("claims") ?? "").split(",").filter(Boolean)
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
/** The `-- permdock:grants v1 schema=...` line of the migration `--grants-out` writes. */
|
|
914
|
-
function parseGrantsMarker(sql) {
|
|
915
|
-
const match = GRANTS_MARKER.exec(sql);
|
|
916
|
-
if (!match) return void 0;
|
|
917
|
-
const schema = markerFields(match[2]).get("schema");
|
|
918
|
-
return {
|
|
919
|
-
version: Number(match[1]),
|
|
920
|
-
...schema ? { schema } : {}
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
/**
|
|
924
|
-
* PermDock mode, when the manifest has an `rls` block and
|
|
925
|
-
* `entitlements.permdock` is not `false`: the scope must be one of the
|
|
926
|
-
* manifest's `rls.scopes`. Without a manifest the module keeps using `tenant`.
|
|
927
|
-
*/
|
|
928
|
-
function entitlementsMode(config, project) {
|
|
929
|
-
const setting = config.entitlements.permdock;
|
|
930
|
-
const rls = project?.manifest?.rls;
|
|
931
|
-
if (setting === false || !project?.manifest || !rls) return { kind: "tenant" };
|
|
932
|
-
if (!rls.scopes.some((scope) => scope.name === setting.scope)) return {
|
|
933
|
-
kind: "invalid",
|
|
934
|
-
problem: `entitlements.permdock.scope is "${setting.scope}", but ${project.manifestPath} has the scopes ${rls.scopes.map((scope) => scope.name).join(", ") || "(none)"}. Set entitlements.permdock: { scope } to one of them.`
|
|
935
|
-
};
|
|
936
|
-
return {
|
|
937
|
-
kind: "permdock",
|
|
938
|
-
permdock: {
|
|
939
|
-
schema: rls.schema,
|
|
940
|
-
scope: setting.scope,
|
|
941
|
-
memberships: project.manifest.memberships.map((source) => ({
|
|
942
|
-
table: source.table,
|
|
943
|
-
userColumn: source.user.column,
|
|
944
|
-
scope: source.scope,
|
|
945
|
-
idColumn: source.id.column
|
|
946
|
-
}))
|
|
947
|
-
}
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
/** The `member_<scope>_ids` helpers PermDock mode calls, as `schema.name`. */
|
|
951
|
-
const entitlementHelpers = (permdock) => [`${permdock.schema}.member_${permdock.scope}_ids`, `${permdock.schema}.member_${permdock.scope}_ids_for`];
|
|
952
|
-
//#endregion
|
|
953
|
-
//#region src/cli/read-sets.ts
|
|
954
|
-
/** Every read set exported by the modules in `config.readSets`. */
|
|
955
|
-
async function loadReadSets(config) {
|
|
956
|
-
const sets = [];
|
|
957
|
-
for (const entry of config.readSets) {
|
|
958
|
-
const loaded = await importModule(resolve(config.root, entry));
|
|
959
|
-
const found = Object.values(loaded).filter(isReadSet);
|
|
960
|
-
if (found.length === 0) throw new Error(`${entry} exports no read set (defineReadSet)`);
|
|
961
|
-
for (const set of found) if (!sets.includes(set)) sets.push(set);
|
|
962
|
-
}
|
|
963
|
-
return sets;
|
|
964
|
-
}
|
|
965
|
-
/** The compiled functions for `config.readSets`; empty when none are configured. */
|
|
966
|
-
async function compiledReadSets(config) {
|
|
967
|
-
if (config.readSets.length === 0) return [];
|
|
968
|
-
return compileReadSets(await loadReadSets(config));
|
|
969
|
-
}
|
|
970
|
-
//#endregion
|
|
971
|
-
export { parseHookMarker as a, readPermdock as c, parseGrantsMarker as i, fileDiff as l, entitlementHelpers as n, permdockConfig as o, entitlementsMode as r, permdockSource as s, compiledReadSets as t };
|
|
752
|
+
export { fileDiff as t };
|
|
@@ -117,7 +117,7 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
117
117
|
const isAbsolute$1 = function(p) {
|
|
118
118
|
return _IS_ABSOLUTE_RE.test(p);
|
|
119
119
|
};
|
|
120
|
-
const extname$
|
|
120
|
+
const extname$2 = function(p) {
|
|
121
121
|
if (p === "..") return "";
|
|
122
122
|
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
123
123
|
return match && match[1] || "";
|
|
@@ -527,7 +527,7 @@ function getDataProtocolModuleFormat(parsed) {
|
|
|
527
527
|
}
|
|
528
528
|
const DOT_CODE = 46;
|
|
529
529
|
const SLASH_CODE = 47;
|
|
530
|
-
function extname(url) {
|
|
530
|
+
function extname$1(url) {
|
|
531
531
|
const pathname = url.pathname;
|
|
532
532
|
for (let i = pathname.length - 1; i > 0; i--) switch (pathname.charCodeAt(i)) {
|
|
533
533
|
case SLASH_CODE: return "";
|
|
@@ -536,7 +536,7 @@ function extname(url) {
|
|
|
536
536
|
return "";
|
|
537
537
|
}
|
|
538
538
|
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
539
|
-
const ext = extname(url);
|
|
539
|
+
const ext = extname$1(url);
|
|
540
540
|
if (ext === ".js") {
|
|
541
541
|
const { type: packageType } = getPackageScopeConfig(url);
|
|
542
542
|
if (packageType !== "none") return packageType;
|
|
@@ -1109,4 +1109,4 @@ function _parseInput(input) {
|
|
|
1109
1109
|
throw new TypeError("id must be a `string` or `URL`");
|
|
1110
1110
|
}
|
|
1111
1111
|
//#endregion
|
|
1112
|
-
export { isAbsolute$1 as a, resolve$1 as c, extname$
|
|
1112
|
+
export { isAbsolute$1 as a, resolve$1 as c, extname$2 as i, basename$1 as n, join$1 as o, dirname$1 as r, normalize$1 as s, resolveModulePath as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isAbsolute, c as resolve, o as join, r as dirname, s as normalize, t as resolveModulePath } from "./dist-
|
|
1
|
+
import { a as isAbsolute, c as resolve, o as join, r as dirname, s as normalize, t as resolveModulePath } from "./dist-DBPdlPYK.js";
|
|
2
2
|
import { n as o, t as i } from "./_format-Cax5EsM9.js";
|
|
3
3
|
import { t as i$1 } from "./jsonc-D5Fu67jw.js";
|
|
4
4
|
import { promises, statSync } from "node:fs";
|
|
@@ -297,6 +297,28 @@ function literal(literal_, message$1) {
|
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
/* @__NO_SIDE_EFFECTS__ */
|
|
300
|
+
function nullable(wrapped, default_) {
|
|
301
|
+
return _standardSchema({
|
|
302
|
+
kind: "schema",
|
|
303
|
+
type: "nullable",
|
|
304
|
+
reference: nullable,
|
|
305
|
+
expects: `(${wrapped.expects} | null)`,
|
|
306
|
+
async: false,
|
|
307
|
+
wrapped,
|
|
308
|
+
default: default_,
|
|
309
|
+
"~run"(dataset, config$1) {
|
|
310
|
+
if (dataset.value === null) {
|
|
311
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
|
|
312
|
+
if (dataset.value === null) {
|
|
313
|
+
dataset.typed = true;
|
|
314
|
+
return dataset;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return this.wrapped["~run"](dataset, config$1);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
300
322
|
function number(message$1) {
|
|
301
323
|
return _standardSchema({
|
|
302
324
|
kind: "schema",
|
|
@@ -313,6 +335,95 @@ function number(message$1) {
|
|
|
313
335
|
});
|
|
314
336
|
}
|
|
315
337
|
/* @__NO_SIDE_EFFECTS__ */
|
|
338
|
+
function objectWithRest(entries$1, rest, message$1) {
|
|
339
|
+
return _standardSchema({
|
|
340
|
+
kind: "schema",
|
|
341
|
+
type: "object_with_rest",
|
|
342
|
+
reference: objectWithRest,
|
|
343
|
+
expects: "Object",
|
|
344
|
+
async: false,
|
|
345
|
+
entries: entries$1,
|
|
346
|
+
rest,
|
|
347
|
+
message: message$1,
|
|
348
|
+
"~run"(dataset, config$1) {
|
|
349
|
+
const input = dataset.value;
|
|
350
|
+
if (input && typeof input === "object") {
|
|
351
|
+
dataset.typed = true;
|
|
352
|
+
dataset.value = {};
|
|
353
|
+
for (const key in this.entries) {
|
|
354
|
+
const valueSchema = this.entries[key];
|
|
355
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
356
|
+
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
357
|
+
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
358
|
+
if (valueDataset.issues) {
|
|
359
|
+
const pathItem = {
|
|
360
|
+
type: "object",
|
|
361
|
+
origin: "value",
|
|
362
|
+
input,
|
|
363
|
+
key,
|
|
364
|
+
value: value$1
|
|
365
|
+
};
|
|
366
|
+
for (const issue of valueDataset.issues) {
|
|
367
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
368
|
+
else issue.path = [pathItem];
|
|
369
|
+
dataset.issues?.push(issue);
|
|
370
|
+
}
|
|
371
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
372
|
+
if (config$1.abortEarly) {
|
|
373
|
+
dataset.typed = false;
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
378
|
+
dataset.value[key] = valueDataset.value;
|
|
379
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
380
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
381
|
+
_addIssue(this, "key", dataset, config$1, {
|
|
382
|
+
input: void 0,
|
|
383
|
+
expected: `"${key}"`,
|
|
384
|
+
path: [{
|
|
385
|
+
type: "object",
|
|
386
|
+
origin: "key",
|
|
387
|
+
input,
|
|
388
|
+
key,
|
|
389
|
+
value: input[key]
|
|
390
|
+
}]
|
|
391
|
+
});
|
|
392
|
+
if (config$1.abortEarly) break;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (!dataset.issues || !config$1.abortEarly) {
|
|
396
|
+
for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) {
|
|
397
|
+
const valueDataset = this.rest["~run"]({ value: input[key] }, config$1);
|
|
398
|
+
if (valueDataset.issues) {
|
|
399
|
+
const pathItem = {
|
|
400
|
+
type: "object",
|
|
401
|
+
origin: "value",
|
|
402
|
+
input,
|
|
403
|
+
key,
|
|
404
|
+
value: input[key]
|
|
405
|
+
};
|
|
406
|
+
for (const issue of valueDataset.issues) {
|
|
407
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
408
|
+
else issue.path = [pathItem];
|
|
409
|
+
dataset.issues?.push(issue);
|
|
410
|
+
}
|
|
411
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
412
|
+
if (config$1.abortEarly) {
|
|
413
|
+
dataset.typed = false;
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
418
|
+
dataset.value[key] = valueDataset.value;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
422
|
+
return dataset;
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
316
427
|
function optional(wrapped, default_) {
|
|
317
428
|
return _standardSchema({
|
|
318
429
|
kind: "schema",
|
|
@@ -618,4 +729,4 @@ function safeParse(schema, input, config$1) {
|
|
|
618
729
|
};
|
|
619
730
|
}
|
|
620
731
|
//#endregion
|
|
621
|
-
export { literal as a,
|
|
732
|
+
export { unknown as _, literal as a, objectWithRest as c, pipe as d, record as f, union as g, string as h, getDotPath as i, optional as l, strictObject as m, boolean as n, nullable as o, safeParse as p, custom as r, number as s, array as t, picklist as u, url as v };
|