better-supabase 0.2.0 → 0.4.0
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 +37 -33
- package/dist/base64-D2gsioCY.js +42 -0
- package/dist/claims-BAf6c7is.js +48 -0
- package/dist/cli/_format-Cax5EsM9.js +101 -0
- package/dist/cli/bin.js +39 -6
- package/dist/cli/command-CK14fP91.js +502 -0
- package/dist/cli/compare-BmIWVEui.js +9 -0
- package/dist/cli/config-D9R0o1LH.js +1895 -0
- package/dist/cli/config-SSKSTUl2.js +2 -0
- package/dist/cli/db-DOBPt660.js +52 -0
- package/dist/cli/dist-B1MvLv-M.js +129 -0
- package/dist/cli/dist-CFgGknmZ.js +1112 -0
- package/dist/cli/dist-Du7VnEUG.js +621 -0
- package/dist/cli/doctor-BOym3mbL.js +2382 -0
- package/dist/cli/env-BZ0uy8XK.js +108 -0
- package/dist/cli/env-jIFUADLY.js +511 -0
- package/dist/cli/errors-4v4DTtda.js +56 -0
- package/dist/cli/fastest-levenshtein-CFN-lNDv.js +120 -0
- package/dist/cli/gen-Ccn_p90L.js +2008 -0
- package/dist/cli/gen-D5cLCULx.js +2 -0
- package/dist/cli/index.d.ts +295 -28
- package/dist/cli/index.js +184 -3
- package/dist/cli/init-ClnxRYBF.js +550 -0
- package/dist/cli/introspect-DxqfkVIv.js +81 -0
- package/dist/cli/io-k41_z-jT.js +24 -0
- package/dist/cli/json5-ChRycquj.js +787 -0
- package/dist/cli/jsonc-BUniUpOk.js +2 -0
- package/dist/cli/jsonc-D5Fu67jw.js +45 -0
- package/dist/cli/keys-ByKHnvP9.js +83 -0
- package/dist/cli/ohash-D7bG_EOb.js +277 -0
- package/dist/cli/openapi-8WHjxiTJ.js +66 -0
- package/dist/cli/project-B_GeXyHh.js +70 -0
- package/dist/cli/prompts-BNcNfAve.js +1142 -0
- package/dist/cli/prompts-BTYQGunc.js +2 -0
- package/dist/cli/read-sets-CMa29t9a.js +971 -0
- package/dist/cli/rolldown-runtime-BPOCksWG.js +24 -0
- package/dist/cli/run-CP20LKk_.js +347 -0
- package/dist/cli/seed-5J6eu_Xg.js +98 -0
- package/dist/cli/skills-LJJIhLFR.js +137 -0
- package/dist/cli/sql-D4VbqmXi.js +199 -0
- package/dist/cli/style-C0NFdJRL.js +29 -0
- package/dist/cli/toml-DB-MNnFs.js +424 -0
- package/dist/{version-Cqq1m3UY.js → cli/version-5mW_8sY1.js} +1 -1
- package/dist/cli/yaml-CYCbJ6et.js +2252 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +15 -25
- package/dist/{compiler-CZ9nIuqy.d.ts → compiler-DB3aSFOA.d.ts} +2 -2
- package/dist/config/index.d.ts +4 -3
- package/dist/config/index.js +5 -3
- package/dist/config-BpxDfnbg.js +129 -0
- package/dist/{index-DOsjFvMf.d.ts → config-C1CYcm6o.d.ts} +49 -49
- package/dist/{config-ClDXmVtY.js → config-CbvFmGD8.js} +14 -137
- package/dist/{define-BXMYD9AY.js → define-Bh0AqTik.js} +221 -120
- package/dist/{define-e3zI4_4g.d.ts → define-CRS2MRV3.d.ts} +36 -31
- package/dist/edge/index.d.ts +9 -13
- package/dist/edge/index.js +51 -25
- package/dist/{entitlements-Dng-ctuT.d.ts → entitlements-Dm-FHpNH.d.ts} +2 -2
- package/dist/env/index.js +203 -1
- package/dist/{errors-Bl3rkOzo.js → errors-L0xK41y_.js} +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +139 -1
- package/dist/{events-DOt3nSO-.d.ts → events-B21UOhvP.d.ts} +4 -4
- package/dist/{executor-CGdNQ27g.d.ts → executor-B5IoUxLE.d.ts} +2 -2
- package/dist/{executor-DeppvirK.js → executor-CVt6dD0B.js} +9 -4
- package/dist/{executor-BYXQ9AGn.d.ts → executor-CZ7ImRiD.d.ts} +2 -2
- package/dist/hono/index.d.ts +17 -24
- package/dist/hono/index.js +11 -11
- package/dist/{index-DuP14VHo.d.ts → index-528Ugmyp.d.ts} +30 -10
- package/dist/{index-Bw1bwtC0.d.ts → index-BAy4tsAP.d.ts} +28 -15
- package/dist/{index-CBDufH1M.d.ts → index-BBdvo-5d.d.ts} +24 -26
- package/dist/{index-DbxFr7XG.d.ts → index-BhHEC04r.d.ts} +9 -4
- package/dist/index-Cf-D2jk1.d.ts +50 -0
- package/dist/{index-Ciu5Xlml.d.ts → index-D5IfUIDh.d.ts} +6 -5
- package/dist/{index-K-3WM2Hp.d.ts → index-DFmOpBGC.d.ts} +13 -13
- package/dist/{index-D4v7sncu.d.ts → index-RlLXd8dL.d.ts} +13 -13
- package/dist/index.d.ts +17 -17
- package/dist/index.js +23 -14
- package/dist/{invalidate-DbxuL2jL.js → invalidate-CgxmRamI.js} +7 -1
- package/dist/jobs/index.d.ts +33 -26
- package/dist/jobs/index.js +44 -22
- package/dist/{json-schema-BpYqkCKf.js → json-schema-DP6V7cbr.js} +8 -3
- package/dist/lint/index.js +1 -1
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.js +131 -96
- package/dist/{live-DJyZMD6w.d.ts → live-BHakSWWo.d.ts} +26 -16
- package/dist/{live-D8rV1Ldw.js → live-CdJBOc4f.js} +13 -9
- package/dist/lookup-BaP5bI27.js +18 -0
- package/dist/mcp/index.d.ts +34 -27
- package/dist/mcp/index.js +59 -25
- package/dist/{mfa-TVia554c.d.ts → mfa-C7MNQ1Ob.d.ts} +1 -1
- package/dist/{mfa-CpLfJSde.js → mfa-byfjruR9.js} +190 -46
- package/dist/next/image/index.js +6 -3
- package/dist/next/index.d.ts +64 -48
- package/dist/next/index.js +63 -50
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +61 -38
- package/dist/orpc/index.d.ts +18 -21
- package/dist/orpc/index.js +12 -12
- package/dist/otel/index.d.ts +5 -5
- package/dist/otel/index.js +84 -63
- package/dist/{permdock-sql-CghlHPuH.js → permdock-sql-C4KFzLc9.js} +12 -7
- package/dist/permdock-sql-DImJULY-.d.ts +17 -0
- package/dist/{plugin-C4TR9J0Z.d.ts → plugin-bNhvJwRh.d.ts} +5 -4
- package/dist/plugins/actor/index.d.ts +1 -1
- package/dist/plugins/actor/index.js +1 -1
- package/dist/plugins/rules/index.d.ts +2 -2
- package/dist/plugins/rules/index.js +46 -16
- package/dist/plugins/soft-delete/index.d.ts +3 -3
- package/dist/plugins/soft-delete/index.js +4 -4
- package/dist/plugins/tenant/index.d.ts +3 -3
- package/dist/plugins/tenant/index.js +10 -4
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +2 -2
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/plugins/validation/index.js +3 -3
- package/dist/pool-DFwEQwmN.d.ts +78 -0
- package/dist/postgres/index.d.ts +10 -5
- package/dist/postgres/index.js +37 -16
- package/dist/{postgrest-cAEQ_IQN.d.ts → postgrest-Bc-0Xw62.d.ts} +1 -1
- package/dist/{problem-BTkTtRV9.js → problem-BihjPR0t.js} +11 -5
- package/dist/{problem-DlgB0lYl.d.ts → problem-U8UEKccv.d.ts} +6 -4
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +2 -2
- package/dist/{query-ChvDbsDE.js → query-BMMSWbI7.js} +19 -19
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +2 -2
- package/dist/react/server.d.ts +6 -6
- package/dist/react/server.js +3 -3
- package/dist/react/session.d.ts +21 -2
- package/dist/react/session.js +19 -1
- package/dist/{react-C83BdBGt.js → react-CQHMaESR.js} +59 -55
- package/dist/{read-set-4lI3W_gZ.js → read-set-FWK8qQ58.js} +51 -16
- package/dist/realtime/index.d.ts +4 -3
- package/dist/realtime/index.js +19 -17
- package/dist/{index-CG69s15v.d.ts → refresh-BwYkyNOQ.d.ts} +7 -3
- package/dist/{resolve-CjHILk2w.d.ts → resolve-BAqQcwMW.d.ts} +17 -11
- package/dist/{resource-CgZa3YG_.d.ts → resource-BJcaIfxi.d.ts} +17 -8
- package/dist/{resource-BHEWmQJK.js → resource-My_y-Syh.js} +43 -21
- package/dist/{respond-Dne1ARSa.d.ts → respond-DgIbdrt8.d.ts} +39 -14
- package/dist/{result-DWXatkd6.js → result-Bj6yt33D.js} +2 -2
- package/dist/{result-CTkCZ6JA.d.ts → result-CqEsbgYs.d.ts} +16 -11
- package/dist/server/index.d.ts +38 -13
- package/dist/server/index.js +43 -14
- package/dist/{respond-DMcbQwfN.js → server-BA75B0mT.js} +151 -96
- package/dist/{shared-_6-uPL7E.js → shared-DnoCdMDr.js} +4 -3
- package/dist/{simplify-bwJpLnaS.js → simplify-Cqvfr9dj.js} +76 -39
- package/dist/sql/index.d.ts +139 -0
- package/dist/sql/index.js +1983 -0
- package/dist/{sql-DTjA1LPj.js → sql-B34HU2DI.js} +74 -17
- package/dist/ssr/index.d.ts +4 -4
- package/dist/ssr/index.js +2 -2
- package/dist/{standard-FUi3Z3-7.js → standard-BRyBGTtp.js} +2 -2
- package/dist/{standard-CyhRzctb.d.ts → standard-BsaCYQJc.d.ts} +1 -1
- package/dist/{stats-C5W-rBfR.js → stats-C_YxA2r1.js} +40 -14
- package/dist/storage/index.d.ts +4 -3
- package/dist/storage/index.js +548 -1
- package/dist/{tables-rZxRxNPW.js → tables-Cb-3_VWc.js} +19 -5
- package/dist/temporal-BwshQk0W.js +27 -0
- package/dist/temporal-required-CBNHT6ni.js +19 -0
- package/dist/testing/index.d.ts +25 -24
- package/dist/testing/index.js +165 -66
- package/dist/{types-C83v5SQz.d.ts → types-DONv9SHN.d.ts} +14 -11
- package/dist/version-Bmf7_FzM.js +4 -0
- package/dist/{view-D1s0wa0T.d.ts → view-B64o81wp.d.ts} +36 -6
- package/dist/{view-aOYizTeE.js → view-BrJI2LKp.js} +11 -2
- package/dist/webhooks/index.d.ts +19 -17
- package/dist/webhooks/index.js +1 -1
- package/dist/{webhooks-DMipjhSP.js → webhooks-Bh_Jf_-l.js} +45 -24
- package/package.json +50 -22
- package/schemas/config-v1.json +31 -1
- package/schemas/doctor-report-v1.json +17 -1
- package/schemas/snapshot-v2.json +35 -0
- package/skills/better-supabase/SKILL.md +77 -18
- package/skills/better-supabase/references/plugins.md +21 -22
- package/skills/better-supabase/references/troubleshooting.md +38 -18
- package/skills/better-supabase-api/SKILL.md +66 -18
- package/skills/better-supabase-api/references/adapters.md +64 -41
- package/skills/better-supabase-auth/SKILL.md +146 -0
- package/skills/better-supabase-auth/references/permdock.md +55 -0
- package/skills/better-supabase-testing/SKILL.md +68 -11
- package/dist/casing-da0uRTqt.js +0 -14
- package/dist/claims-CoTobNC-.js +0 -25
- package/dist/cli-DrSgDOQC.js +0 -6646
- package/dist/env-BEToab0I.js +0 -204
- package/dist/events-BuzTgn2D.js +0 -135
- package/dist/pool-R2m_DkXi.d.ts +0 -37
- package/dist/seed-CzecODcJ.js +0 -101
- package/dist/session-C3LxnQ0e.d.ts +0 -22
- package/dist/session-CqEwzVup.js +0 -20
- package/dist/storage-DuGn38fr.js +0 -527
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/better-supabase)
|
|
6
6
|
[](https://github.com/ScaleDockHQ/better-supabase/blob/main/LICENSE)
|
|
7
|
-

|
|
8
8
|
|
|
9
9
|
`better-supabase gen` extends `supabase gen types` with relation cardinality, unique keys, CHECK unions and typed jsonb. The generated `schema` gives every table a typed repository that compiles to one PostgREST request, returns a `Result` instead of throwing, and runs as the caller so RLS always applies.
|
|
10
10
|
|
|
@@ -15,31 +15,33 @@ pnpm add better-supabase @supabase/supabase-js
|
|
|
15
15
|
pnpm add -D pg
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
ESM only. Node 24 or later
|
|
18
|
+
ESM only. The package includes the `better-supabase` CLI, which needs Node 24 or later; the runtime entries run on every WinterTC runtime (Node, Deno, Bun, Workers, Supabase Edge Functions). TypeScript 6 and 7 are tested.
|
|
19
19
|
|
|
20
20
|
## Quick start
|
|
21
21
|
|
|
22
|
+
Or start with `npx better-supabase init`, which detects your frameworks and prints the install command.
|
|
23
|
+
|
|
22
24
|
```bash
|
|
23
25
|
supabase start
|
|
24
|
-
pnpm better-supabase init # config, src/lib/supabase.ts and framework glue
|
|
26
|
+
pnpm better-supabase init # config, src/lib/supabase/index.ts and framework glue
|
|
25
27
|
pnpm better-supabase gen # database.types.ts and generated.ts
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
```ts
|
|
29
|
-
import { createClient } from
|
|
30
|
-
import { defineSupabase } from
|
|
31
|
+
import { createClient } from "@supabase/supabase-js";
|
|
32
|
+
import { defineSupabase } from "better-supabase";
|
|
31
33
|
|
|
32
|
-
import { schema } from
|
|
34
|
+
import { schema } from "./lib/supabase/generated.ts";
|
|
33
35
|
|
|
34
|
-
export const
|
|
36
|
+
export const betterSupabase = defineSupabase(schema);
|
|
35
37
|
|
|
36
|
-
const db =
|
|
38
|
+
const db = betterSupabase.connect(createClient(url, publishableKey));
|
|
37
39
|
|
|
38
40
|
const result = await db.customers.findMany({
|
|
39
|
-
select: [
|
|
40
|
-
where: { status:
|
|
41
|
-
include: { organization: { select: [
|
|
42
|
-
orderBy: { name:
|
|
41
|
+
select: ["id", "name"],
|
|
42
|
+
where: { status: "active", notes: { some: { kind: "call" } } },
|
|
43
|
+
include: { organization: { select: ["name"] } },
|
|
44
|
+
orderBy: { name: "asc" },
|
|
43
45
|
limit: 20,
|
|
44
46
|
});
|
|
45
47
|
if (!result.ok) return result; // DbError: kind, message, status, code
|
|
@@ -47,27 +49,29 @@ if (!result.ok) return result; // DbError: kind, message, status, code
|
|
|
47
49
|
|
|
48
50
|
## Subpaths
|
|
49
51
|
|
|
50
|
-
| Import
|
|
51
|
-
|
|
|
52
|
-
| `better-supabase`
|
|
53
|
-
| `better-supabase/config`
|
|
54
|
-
| `better-supabase/
|
|
55
|
-
| `better-supabase/
|
|
56
|
-
| `better-supabase/
|
|
57
|
-
| `better-supabase/
|
|
58
|
-
| `better-supabase/
|
|
59
|
-
| `better-supabase/
|
|
60
|
-
| `better-supabase/
|
|
61
|
-
| `better-supabase/
|
|
62
|
-
| `better-supabase/
|
|
63
|
-
| `better-supabase/
|
|
64
|
-
| `better-supabase/
|
|
65
|
-
| `better-supabase/
|
|
66
|
-
| `better-supabase/
|
|
67
|
-
| `better-supabase/
|
|
68
|
-
| `better-supabase/
|
|
69
|
-
| `better-supabase/
|
|
70
|
-
| `better-supabase/
|
|
52
|
+
| Import | What it gives you |
|
|
53
|
+
| ---------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
54
|
+
| `better-supabase` | `defineSupabase`, repositories, `Result`, `DbError`, `SPEC_PINS` |
|
|
55
|
+
| `better-supabase/config` | `defineConfig` and generators for `better-supabase.config.ts` |
|
|
56
|
+
| `better-supabase/cli` | `run`, `registerCommand` and codegen for scripts that drive the CLI |
|
|
57
|
+
| `better-supabase/client` | Browser repositories that follow the session |
|
|
58
|
+
| `better-supabase/react` | Provider, typed hooks and the server session |
|
|
59
|
+
| `better-supabase/query` | TanStack Query options with table-based invalidation |
|
|
60
|
+
| `better-supabase/server` | Repositories bound to the caller, admin and acting-as identities |
|
|
61
|
+
| `better-supabase/postgres` | The same repositories over direct Postgres |
|
|
62
|
+
| `better-supabase/ssr` | The `@supabase/ssr` cookie format for any framework |
|
|
63
|
+
| `better-supabase/next`, `/next/image` | Proxy, Server Components, route handlers, server actions, Storage images |
|
|
64
|
+
| `better-supabase/hono`, `/orpc`, `/edge` | Framework adapters |
|
|
65
|
+
| `better-supabase/mcp` | MCP servers whose tools run as the signed-in user |
|
|
66
|
+
| `better-supabase/jobs` | Supabase Queues jobs, idempotency keys and a webhook inbox |
|
|
67
|
+
| `better-supabase/list` | Search, facets, sorting and pagination from one definition |
|
|
68
|
+
| `better-supabase/storage`, `/realtime` | Typed bucket paths and broadcast topics |
|
|
69
|
+
| `better-supabase/env` | Validated Supabase settings |
|
|
70
|
+
| `better-supabase/events`, `/webhooks`, `/openapi`, `/otel` | CloudEvents, Standard Webhooks, OpenAPI 3.1 and OpenTelemetry |
|
|
71
|
+
| `better-supabase/plugins/*` | Timestamps, soft delete, tenant, actor, validation and runtime rules |
|
|
72
|
+
| `better-supabase/sql` | The SQL kit modules and read-set compiler behind `better-supabase sql` |
|
|
73
|
+
| `better-supabase/lint` | Editor rules for unbounded reads and unscoped deletes |
|
|
74
|
+
| `better-supabase/testing` | `asUser`, `localAuth`, typed seeds and conformance kits |
|
|
71
75
|
|
|
72
76
|
## For AI agents
|
|
73
77
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/core/base64.ts
|
|
2
|
+
const encoder = /* @__PURE__ */ new TextEncoder();
|
|
3
|
+
const decoder = /* @__PURE__ */ new TextDecoder();
|
|
4
|
+
/** Standard base64 (RFC 4648 section 4) of `input`, with padding. */
|
|
5
|
+
function toBase64(input) {
|
|
6
|
+
const bytes = typeof input === "string" ? encoder.encode(input) : input;
|
|
7
|
+
let binary = "";
|
|
8
|
+
for (const byte of bytes) binary += String.fromCodePoint(byte);
|
|
9
|
+
return btoa(binary);
|
|
10
|
+
}
|
|
11
|
+
/** Bytes of standard or URL-safe base64, padded or not. Throws on invalid input. */
|
|
12
|
+
function fromBase64(text) {
|
|
13
|
+
const base64 = text.replaceAll("-", "+").replaceAll("_", "/");
|
|
14
|
+
const binary = atob(base64 + "=".repeat((4 - base64.length % 4) % 4));
|
|
15
|
+
const bytes = new Uint8Array(binary.length);
|
|
16
|
+
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.codePointAt(index) ?? 0;
|
|
17
|
+
return bytes;
|
|
18
|
+
}
|
|
19
|
+
/** URL-safe base64 (RFC 4648 section 5) of `input`, without padding. */
|
|
20
|
+
function toBase64Url(input) {
|
|
21
|
+
return toBase64(input).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
22
|
+
}
|
|
23
|
+
/** UTF-8 text of base64 or base64url. Throws on invalid input. */
|
|
24
|
+
function base64ToText(text) {
|
|
25
|
+
return decoder.decode(fromBase64(text));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The payload of a JWT, decoded without verifying the signature. Only for
|
|
29
|
+
* reading claims such as `exp` from a token that is verified elsewhere.
|
|
30
|
+
*/
|
|
31
|
+
function decodeJwtPayload(token) {
|
|
32
|
+
const part = token.split(".")[1];
|
|
33
|
+
if (!part) return void 0;
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(base64ToText(part));
|
|
36
|
+
return typeof parsed === "object" && parsed !== null ? parsed : void 0;
|
|
37
|
+
} catch {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { toBase64Url as a, toBase64 as i, decodeJwtPayload as n, fromBase64 as r, base64ToText as t };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/core/claims.ts
|
|
2
|
+
const DEFAULT_CLAIMS = {
|
|
3
|
+
tenant: "tenant_id",
|
|
4
|
+
scope: "tenant",
|
|
5
|
+
features: "features"
|
|
6
|
+
};
|
|
7
|
+
/** The configured claim names, with defaults for the ones codegen left out. */
|
|
8
|
+
function claimsOf(meta) {
|
|
9
|
+
if (!meta?.claims) return DEFAULT_CLAIMS;
|
|
10
|
+
let claims = claimsByMeta.get(meta);
|
|
11
|
+
if (!claims) {
|
|
12
|
+
claims = {
|
|
13
|
+
...DEFAULT_CLAIMS,
|
|
14
|
+
...meta.claims
|
|
15
|
+
};
|
|
16
|
+
claimsByMeta.set(meta, claims);
|
|
17
|
+
}
|
|
18
|
+
return claims;
|
|
19
|
+
}
|
|
20
|
+
const claimsByMeta = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
/** Where the active tenant is read from: the top-level claim, then `app_metadata`. */
|
|
22
|
+
function tenantClaimPaths(tenant = DEFAULT_CLAIMS.tenant) {
|
|
23
|
+
let paths = tenantPaths.get(tenant);
|
|
24
|
+
if (!paths) {
|
|
25
|
+
paths = [tenant, `app_metadata.${tenant}`];
|
|
26
|
+
tenantPaths.set(tenant, paths);
|
|
27
|
+
}
|
|
28
|
+
return paths;
|
|
29
|
+
}
|
|
30
|
+
const tenantPaths = /* @__PURE__ */ new Map();
|
|
31
|
+
/** Claim paths come from configuration, so this stays small. */
|
|
32
|
+
const segmentsByPath = /* @__PURE__ */ new Map();
|
|
33
|
+
function segmentsOf(path) {
|
|
34
|
+
let segments = segmentsByPath.get(path);
|
|
35
|
+
if (!segments) {
|
|
36
|
+
segments = path.split(".");
|
|
37
|
+
if (segmentsByPath.size < 256) segmentsByPath.set(path, segments);
|
|
38
|
+
}
|
|
39
|
+
return segments;
|
|
40
|
+
}
|
|
41
|
+
/** The string at a dotted claim path, if any. */
|
|
42
|
+
function claimAt(claims, path) {
|
|
43
|
+
let value = claims;
|
|
44
|
+
for (const segment of segmentsOf(path)) value = typeof value === "object" && value !== null ? value[segment] : void 0;
|
|
45
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { tenantClaimPaths as i, claimAt as n, claimsOf as r, DEFAULT_CLAIMS as t };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/_chunks/libs/detect-indent.mjs
|
|
2
|
+
const e = /^(?:( )+|\t+)/;
|
|
3
|
+
const t$1 = `space`;
|
|
4
|
+
function n$1(e, n, r) {
|
|
5
|
+
return e && n === t$1 && r === 1;
|
|
6
|
+
}
|
|
7
|
+
function r$1(r, a) {
|
|
8
|
+
let o = /* @__PURE__ */ new Map(), s = 0, c, l;
|
|
9
|
+
for (let u of r.split(/\n/g)) {
|
|
10
|
+
if (!u) continue;
|
|
11
|
+
let r = u.match(e);
|
|
12
|
+
if (r === null) s = 0, c = ``;
|
|
13
|
+
else {
|
|
14
|
+
let e = r[0].length, u = r[1] ? t$1 : `tab`;
|
|
15
|
+
if (n$1(a, u, e)) continue;
|
|
16
|
+
u !== c && (s = 0), c = u;
|
|
17
|
+
let d = 1, f = 0, p = e - s;
|
|
18
|
+
if (s = e, p === 0) d = 0, f = 1;
|
|
19
|
+
else {
|
|
20
|
+
let e = Math.abs(p);
|
|
21
|
+
if (n$1(a, u, e)) continue;
|
|
22
|
+
l = i$1(u, e);
|
|
23
|
+
}
|
|
24
|
+
let m = o.get(l);
|
|
25
|
+
o.set(l, m === void 0 ? [1, 0] : [m[0] + d, m[1] + f]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return o;
|
|
29
|
+
}
|
|
30
|
+
function i$1(e, n) {
|
|
31
|
+
return (e === t$1 ? `s` : `t`) + String(n);
|
|
32
|
+
}
|
|
33
|
+
function a$1(e) {
|
|
34
|
+
return {
|
|
35
|
+
type: e[0] === `s` ? t$1 : `tab`,
|
|
36
|
+
amount: Number(e.slice(1))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function o$1(e) {
|
|
40
|
+
let t, n = 0, r = 0;
|
|
41
|
+
for (let [i, [a, o]] of e) (a > n || a === n && o > r) && (n = a, r = o, t = i);
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
function s$1(e, n) {
|
|
45
|
+
return (e === t$1 ? ` ` : ` `).repeat(n);
|
|
46
|
+
}
|
|
47
|
+
function c(e) {
|
|
48
|
+
if (typeof e != `string`) throw TypeError(`Expected a string`);
|
|
49
|
+
let t = r$1(e, !0);
|
|
50
|
+
t.size === 0 && (t = r$1(e, !1));
|
|
51
|
+
let n = o$1(t), i, c = 0, l = ``;
|
|
52
|
+
return n !== void 0 && ({type: i, amount: c} = a$1(n), l = s$1(i, c)), {
|
|
53
|
+
amount: c,
|
|
54
|
+
type: i,
|
|
55
|
+
indent: l
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/_chunks/_format.mjs
|
|
60
|
+
const t = Symbol.for(`__confbox_fmt__`);
|
|
61
|
+
const n = /^(\s+)/;
|
|
62
|
+
const r = /(\s+)$/;
|
|
63
|
+
function i(e) {
|
|
64
|
+
return e.charCodeAt(0) === 65279 ? e.slice(1) : e;
|
|
65
|
+
}
|
|
66
|
+
function a(e, t = {}) {
|
|
67
|
+
return {
|
|
68
|
+
sample: t.indent === void 0 && t.preserveIndentation !== !1 && i(e).slice(0, t?.sampleSize || 1024),
|
|
69
|
+
whiteSpace: t.preserveWhitespace === !1 ? void 0 : {
|
|
70
|
+
start: n.exec(e)?.[0] || ``,
|
|
71
|
+
end: r.exec(e)?.[0] || ``
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function o(e, n, r) {
|
|
76
|
+
!n || typeof n != `object` || Object.defineProperty(n, t, {
|
|
77
|
+
enumerable: !1,
|
|
78
|
+
configurable: !0,
|
|
79
|
+
writable: !0,
|
|
80
|
+
value: a(e, r)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function s(n, r) {
|
|
84
|
+
if (!n || typeof n != `object` || !(t in n)) return {
|
|
85
|
+
indent: r?.indent ?? 2,
|
|
86
|
+
whitespace: {
|
|
87
|
+
start: ``,
|
|
88
|
+
end: ``
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
let i = n[t];
|
|
92
|
+
return {
|
|
93
|
+
indent: r?.indent || c(i.sample || ``).indent,
|
|
94
|
+
whitespace: i.whiteSpace || {
|
|
95
|
+
start: ``,
|
|
96
|
+
end: ``
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { o as n, s as r, i as t };
|
package/dist/cli/bin.js
CHANGED
|
@@ -1,15 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as run } from "
|
|
2
|
+
import { i as run } from "./run-CP20LKk_.js";
|
|
3
|
+
import { t as colorEnabled } from "./style-C0NFdJRL.js";
|
|
4
|
+
import { text } from "node:stream/consumers";
|
|
3
5
|
//#region src/cli/bin.ts
|
|
6
|
+
const clack = () => import("./prompts-BTYQGunc.js").then((module) => module.clackPrompter);
|
|
7
|
+
const prompts = {
|
|
8
|
+
select: async (message, choices, initial) => (await clack()).select(message, choices, initial),
|
|
9
|
+
multiselect: async (message, choices, initial) => (await clack()).multiselect(message, choices, initial),
|
|
10
|
+
confirm: async (message) => (await clack()).confirm(message),
|
|
11
|
+
spinner: (message) => {
|
|
12
|
+
let stop;
|
|
13
|
+
let stopped = false;
|
|
14
|
+
clack().then((prompter) => {
|
|
15
|
+
if (!stopped) stop = prompter.spinner(message);
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
stopped = true;
|
|
19
|
+
stop?.();
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
4
23
|
const controller = new AbortController();
|
|
5
|
-
process.once("SIGINT", () =>
|
|
6
|
-
|
|
24
|
+
process.once("SIGINT", () => {
|
|
25
|
+
controller.abort();
|
|
26
|
+
});
|
|
27
|
+
process.once("SIGTERM", () => {
|
|
28
|
+
controller.abort();
|
|
29
|
+
});
|
|
7
30
|
const result = await run(process.argv.slice(2), {
|
|
31
|
+
cwd: process.cwd(),
|
|
32
|
+
env: process.env,
|
|
8
33
|
signal: controller.signal,
|
|
9
34
|
io: {
|
|
10
|
-
stdout: (
|
|
11
|
-
|
|
35
|
+
stdout: (chunk) => {
|
|
36
|
+
process.stdout.write(chunk);
|
|
37
|
+
},
|
|
38
|
+
stderr: (chunk) => {
|
|
39
|
+
process.stderr.write(chunk);
|
|
40
|
+
},
|
|
41
|
+
stdin: () => text(process.stdin),
|
|
42
|
+
color: colorEnabled(),
|
|
43
|
+
...process.stdin.isTTY && process.stdout.isTTY ? { prompts } : {}
|
|
12
44
|
}
|
|
13
45
|
});
|
|
14
|
-
process.exitCode = result.code;
|
|
46
|
+
process.exitCode = controller.signal.aborted ? 130 : result.code;
|
|
15
47
|
//#endregion
|
|
48
|
+
export {};
|