better-supabase 0.3.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 +7 -6
- package/bin/better-supabase.js +4 -0
- package/dist/{base64-CQeB1eSf.js → base64-D2gsioCY.js} +2 -2
- package/dist/claims-BAf6c7is.js +48 -0
- package/dist/cli/_format-Cax5EsM9.js +101 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +48 -0
- 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 +493 -0
- package/dist/cli/index.js +184 -0
- 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/cli/version-5mW_8sY1.js +4 -0
- package/dist/cli/yaml-CYCbJ6et.js +2252 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +13 -13
- package/dist/{compiler-2zqGzxVZ.d.ts → compiler-DB3aSFOA.d.ts} +2 -2
- package/dist/config/index.js +4 -4
- package/dist/{config-Be4GwsqI.js → config-BpxDfnbg.js} +1 -1
- package/dist/{config-DOsGYSiT.js → config-CbvFmGD8.js} +1 -1
- package/dist/{define-DF341GDj.js → define-Bh0AqTik.js} +160 -79
- package/dist/{define-DUbydmJa.d.ts → define-CRS2MRV3.d.ts} +32 -28
- package/dist/edge/index.d.ts +8 -12
- package/dist/edge/index.js +50 -24
- package/dist/{entitlements-DvJXoI02.d.ts → entitlements-Dm-FHpNH.d.ts} +2 -2
- package/dist/{errors-Bl3rkOzo.js → errors-L0xK41y_.js} +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -4
- package/dist/{events-Do8jXh4D.d.ts → events-B21UOhvP.d.ts} +4 -4
- package/dist/{executor-DynmIWhq.d.ts → executor-B5IoUxLE.d.ts} +1 -1
- package/dist/{executor-C57jx2pn.js → executor-CVt6dD0B.js} +3 -3
- package/dist/{executor-B26lgbHD.d.ts → executor-CZ7ImRiD.d.ts} +2 -2
- package/dist/hono/index.d.ts +16 -23
- package/dist/hono/index.js +10 -10
- package/dist/{index-CTTMS6_1.d.ts → index-528Ugmyp.d.ts} +12 -3
- package/dist/{index-CADlNHK-.d.ts → index-BAy4tsAP.d.ts} +5 -5
- package/dist/{index-BNsABq7P.d.ts → index-BBdvo-5d.d.ts} +23 -25
- package/dist/{index-qriRM9cZ.d.ts → index-BhHEC04r.d.ts} +3 -3
- package/dist/{index-GV77NpRP.d.ts → index-D5IfUIDh.d.ts} +3 -3
- package/dist/{index-CriFFJ_p.d.ts → index-DFmOpBGC.d.ts} +11 -11
- package/dist/{index-UJ-LUxtI.d.ts → index-RlLXd8dL.d.ts} +12 -12
- package/dist/index.d.ts +15 -15
- package/dist/index.js +13 -13
- package/dist/{invalidate-DbxuL2jL.js → invalidate-CgxmRamI.js} +7 -1
- package/dist/jobs/index.d.ts +10 -4
- package/dist/jobs/index.js +32 -16
- package/dist/{json-schema--aOXAGfU.js → json-schema-DP6V7cbr.js} +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.js +3 -3
- package/dist/{live-QE3UPbGm.d.ts → live-BHakSWWo.d.ts} +12 -12
- package/dist/{live-D8rV1Ldw.js → live-CdJBOc4f.js} +13 -9
- package/dist/lookup-BaP5bI27.js +18 -0
- package/dist/mcp/index.d.ts +18 -18
- package/dist/mcp/index.js +23 -18
- package/dist/{mfa-x3V3vGh-.d.ts → mfa-C7MNQ1Ob.d.ts} +1 -1
- package/dist/{mfa-BxoR1RkN.js → mfa-byfjruR9.js} +118 -29
- package/dist/next/image/index.js +6 -3
- package/dist/next/index.d.ts +38 -35
- package/dist/next/index.js +41 -33
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +6 -6
- package/dist/orpc/index.d.ts +17 -20
- package/dist/orpc/index.js +11 -11
- package/dist/otel/index.d.ts +5 -5
- package/dist/otel/index.js +81 -62
- package/dist/{permdock-sql-Bta_G0v-.js → permdock-sql-C4KFzLc9.js} +1 -1
- package/dist/{plugin-DVRB8qNE.d.ts → plugin-bNhvJwRh.d.ts} +2 -2
- 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 +42 -12
- package/dist/plugins/soft-delete/index.d.ts +2 -2
- package/dist/plugins/soft-delete/index.js +2 -2
- package/dist/plugins/tenant/index.d.ts +2 -2
- package/dist/plugins/tenant/index.js +10 -4
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +1 -1
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/plugins/validation/index.js +3 -3
- package/dist/{pool-B9qsLyFR.d.ts → pool-DFwEQwmN.d.ts} +11 -4
- package/dist/postgres/index.d.ts +5 -5
- package/dist/postgres/index.js +3 -2
- package/dist/{postgrest-DmBlevh-.d.ts → postgrest-Bc-0Xw62.d.ts} +1 -1
- package/dist/{problem-CGt1ADix.js → problem-BihjPR0t.js} +1 -1
- package/dist/{problem-Z2RTQjZD.d.ts → problem-U8UEKccv.d.ts} +1 -1
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +2 -2
- package/dist/{query-BdKLTPlj.js → query-BMMSWbI7.js} +18 -18
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +1 -1
- package/dist/react/server.d.ts +5 -5
- package/dist/react/server.js +3 -3
- package/dist/react/session.d.ts +4 -4
- package/dist/react/session.js +2 -2
- package/dist/{react-DNBYNazu.js → react-CQHMaESR.js} +39 -39
- package/dist/{read-set-D0qBcboM.js → read-set-FWK8qQ58.js} +50 -15
- package/dist/realtime/index.d.ts +1 -1
- package/dist/realtime/index.js +13 -12
- package/dist/{index-kpgopLNv.d.ts → refresh-BwYkyNOQ.d.ts} +6 -3
- package/dist/{resolve-BRciX2jK.d.ts → resolve-BAqQcwMW.d.ts} +15 -10
- package/dist/{resource-CwVgiI5q.d.ts → resource-BJcaIfxi.d.ts} +5 -5
- package/dist/{resource-D30rp0GN.js → resource-My_y-Syh.js} +6 -6
- package/dist/{respond-DAkPIdTH.d.ts → respond-DgIbdrt8.d.ts} +31 -12
- package/dist/{result-DWXatkd6.js → result-Bj6yt33D.js} +2 -2
- package/dist/{result-c2OYgCV2.d.ts → result-CqEsbgYs.d.ts} +3 -3
- package/dist/server/index.d.ts +14 -14
- package/dist/server/index.js +12 -12
- package/dist/{respond-C44EZAJo.js → server-BA75B0mT.js} +139 -100
- package/dist/{shared-_6-uPL7E.js → shared-DnoCdMDr.js} +4 -3
- package/dist/{simplify-LakqK1vH.js → simplify-Cqvfr9dj.js} +67 -24
- package/dist/sql/index.d.ts +1 -1
- package/dist/sql/index.js +7 -7
- package/dist/{sql-BIgk12ew.js → sql-B34HU2DI.js} +3 -2
- 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-eudBiRk1.d.ts → standard-BsaCYQJc.d.ts} +1 -1
- package/dist/{stats-D78UQ8Yu.js → stats-C_YxA2r1.js} +33 -8
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +26 -8
- package/dist/{tables-Dhha3BXM.js → tables-Cb-3_VWc.js} +14 -0
- package/dist/{temporal-required-CMxeSVPo.js → temporal-required-CBNHT6ni.js} +1 -1
- package/dist/testing/index.d.ts +20 -21
- package/dist/testing/index.js +45 -45
- package/dist/{version-BfpG2gks.js → version-Bmf7_FzM.js} +1 -1
- package/dist/{view-3Po_PVlr.d.ts → view-B64o81wp.d.ts} +5 -5
- package/dist/{view-wZ-9qIUz.js → view-BrJI2LKp.js} +1 -1
- package/dist/webhooks/index.d.ts +3 -3
- package/dist/webhooks/index.js +1 -1
- package/dist/{webhooks-CAIFQSTM.js → webhooks-Bh_Jf_-l.js} +37 -18
- package/package.json +36 -4
- package/skills/better-supabase/SKILL.md +57 -10
- package/skills/better-supabase/references/plugins.md +7 -11
- package/skills/better-supabase/references/troubleshooting.md +24 -4
- package/skills/better-supabase-api/SKILL.md +66 -18
- package/skills/better-supabase-api/references/adapters.md +44 -26
- 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 +58 -4
- package/dist/claims-CoTobNC-.js +0 -25
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { r as defineCliCommand } from "./command-CK14fP91.js";
|
|
2
|
+
import { r as writeIfChanged, t as display } from "./io-k41_z-jT.js";
|
|
3
|
+
import { i as plain, r as painter } from "./style-C0NFdJRL.js";
|
|
4
|
+
import { d as readSupabaseToml, f as schemaPaths, l as migrationCommand } from "./config-D9R0o1LH.js";
|
|
5
|
+
import { c as readPermdock, l as fileDiff, o as permdockConfig, r as entitlementsMode, t as compiledReadSets } from "./read-sets-CMa29t9a.js";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
|
+
import { SQL_MODULES, kitLayout, renderKit, resolveModules, sameKitFile } from "better-supabase/sql";
|
|
10
|
+
//#region src/cli/commands/sql.ts
|
|
11
|
+
const SQL_ARGS = {
|
|
12
|
+
action: {
|
|
13
|
+
type: "positional",
|
|
14
|
+
required: false,
|
|
15
|
+
description: "list (modules and whether they are installed), add <module...>, sync or print <module>"
|
|
16
|
+
},
|
|
17
|
+
check: {
|
|
18
|
+
type: "boolean",
|
|
19
|
+
description: "With sync: fail when a file is stale"
|
|
20
|
+
},
|
|
21
|
+
"tests-dir": {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Where the pgtap module goes. Defaults to sql.testsDir",
|
|
24
|
+
valueHint: "dir"
|
|
25
|
+
},
|
|
26
|
+
"dry-run": {
|
|
27
|
+
type: "boolean",
|
|
28
|
+
description: "Show what would be written"
|
|
29
|
+
},
|
|
30
|
+
force: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
description: "Write tenant even though a permdock.config.ts is present"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const USAGE = "Run `better-supabase sql --help` for the actions.";
|
|
36
|
+
/** Modules that fill a claim PermDock's hook also writes (`memberships`). */
|
|
37
|
+
const PERMDOCK_OWNED = /* @__PURE__ */ new Set(["tenant"]);
|
|
38
|
+
/** PermDock's helpers for the `entitlements` module; throws for a scope the manifest lacks. */
|
|
39
|
+
async function permdockFor(config) {
|
|
40
|
+
const mode = entitlementsMode(config, await readPermdock(config.root, config.permdock));
|
|
41
|
+
switch (mode.kind) {
|
|
42
|
+
case "tenant": return;
|
|
43
|
+
case "permdock": return mode.permdock;
|
|
44
|
+
case "invalid": throw new TypeError(mode.problem);
|
|
45
|
+
default: return mode;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function layout(config, args) {
|
|
49
|
+
return kitLayout(config, args["tests-dir"], [], await permdockFor(config));
|
|
50
|
+
}
|
|
51
|
+
/** The layout, with `config.readSets` compiled when `names` includes `read-sets`. */
|
|
52
|
+
async function layoutFor(config, args, names) {
|
|
53
|
+
const permdock = await permdockFor(config);
|
|
54
|
+
const needsReadSets = resolveModules(names, { ...permdock ? { permdock } : {} }).some((module) => module.name === "read-sets");
|
|
55
|
+
return kitLayout(config, args["tests-dir"], needsReadSets ? await compiledReadSets(config) : [], permdock);
|
|
56
|
+
}
|
|
57
|
+
async function write(config, args, names, kit) {
|
|
58
|
+
const lines = [];
|
|
59
|
+
const dryRun = args["dry-run"] === true;
|
|
60
|
+
for (const file of renderKit(names, kit)) {
|
|
61
|
+
const path = resolve(config.root, file.path);
|
|
62
|
+
const shown = display(config.root, file.path);
|
|
63
|
+
if (dryRun) {
|
|
64
|
+
lines.push(`Would write ${shown} (${file.module})`);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const wrote = await writeIfChanged(path, file.contents);
|
|
68
|
+
lines.push(`${wrote ? "Wrote" : "Unchanged"} ${shown} (${file.module})`);
|
|
69
|
+
}
|
|
70
|
+
return lines;
|
|
71
|
+
}
|
|
72
|
+
/** A note when migra's `schema_paths` is set and misses kit files, which `supabase db diff` would then skip. */
|
|
73
|
+
async function unlistedKitFiles(config, names, kit) {
|
|
74
|
+
const order = await schemaPaths(config.root, await readSupabaseToml(config.root));
|
|
75
|
+
if (!order.configured) return [];
|
|
76
|
+
const unlisted = new Set(order.unlisted);
|
|
77
|
+
const listed = new Set(order.files.filter((path) => !unlisted.has(path)));
|
|
78
|
+
const dir = `${config.sql.dir.replace(/\/$/, "")}/`;
|
|
79
|
+
const missing = renderKit(names, kit).map((file) => file.path).filter((path) => path.startsWith(dir) && !listed.has(path));
|
|
80
|
+
if (missing.length === 0) return [];
|
|
81
|
+
return [
|
|
82
|
+
"",
|
|
83
|
+
"supabase/config.toml sets [db.migrations] schema_paths, and no entry matches these files, so `supabase db diff` skips them.",
|
|
84
|
+
"Add them before the schemas that call their functions:",
|
|
85
|
+
...missing.map((path) => ` "./${path.startsWith("supabase/") ? path.slice(9) : path}",`)
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
async function runSql(config, args, paint = plain) {
|
|
89
|
+
const [action, ...names] = args._;
|
|
90
|
+
switch (action) {
|
|
91
|
+
case "list": {
|
|
92
|
+
const kit = await layout(config, args);
|
|
93
|
+
const files = new Map(renderKit(Object.keys(SQL_MODULES), kit).map((file) => [file.module, file.path]));
|
|
94
|
+
return {
|
|
95
|
+
code: 0,
|
|
96
|
+
output: `${Object.values(SQL_MODULES).map((module) => {
|
|
97
|
+
const path = files.get(module.name);
|
|
98
|
+
const installed = existsSync(resolve(config.root, path));
|
|
99
|
+
const tracked = config.sql.kit.includes(module.name);
|
|
100
|
+
const mark = installed ? tracked ? "●" : "○" : " ";
|
|
101
|
+
const requires = kit.permdock && module.permdockRequires ? module.permdockRequires : module.requires;
|
|
102
|
+
const needs = requires.length > 0 ? ` (needs ${requires.join(", ")})` : "";
|
|
103
|
+
return `${mark} ${module.name.padEnd(15)} ${module.description}${needs}`;
|
|
104
|
+
}).join("\n")}\n\n● installed and in sql.kit ○ installed, not in sql.kit`
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
case "add": {
|
|
108
|
+
if (names.length === 0) return {
|
|
109
|
+
code: 2,
|
|
110
|
+
error: `Name at least one module.\n${USAGE}`
|
|
111
|
+
};
|
|
112
|
+
const unknown = names.filter((name) => !(name in SQL_MODULES));
|
|
113
|
+
if (unknown.length > 0) return {
|
|
114
|
+
code: 2,
|
|
115
|
+
error: `Unknown module ${unknown.join(", ")}. Available: ${Object.keys(SQL_MODULES).join(", ")}`
|
|
116
|
+
};
|
|
117
|
+
const permdock = permdockConfig(config.root);
|
|
118
|
+
const hookModules = names.filter((name) => PERMDOCK_OWNED.has(name));
|
|
119
|
+
if (permdock && hookModules.length > 0 && args.force !== true) return {
|
|
120
|
+
code: 1,
|
|
121
|
+
error: [
|
|
122
|
+
`${permdock} is present, so PermDock owns the access token hook and the memberships claim.`,
|
|
123
|
+
`${hookModules.join(" and ")} would add a second source for them. Use \`permdock supabase hook generate\` instead,`,
|
|
124
|
+
"or pass --force to write the modules anyway."
|
|
125
|
+
].join("\n")
|
|
126
|
+
};
|
|
127
|
+
const kit = await layoutFor(config, args, names);
|
|
128
|
+
const lines = await write(config, args, names, kit);
|
|
129
|
+
const pulledIn = resolveModules(names, kit).map((module) => module.name).filter((name) => PERMDOCK_OWNED.has(name) && !names.includes(name));
|
|
130
|
+
if (permdock && pulledIn.length > 0) lines.push("", `${pulledIn.join(" and ")} came along as a dependency: its memberships table backs has_org_role() and has_entitlement().`, `PermDock's hook still owns the memberships claim, so don't call better_supabase.membership_claims from a hook.`, "List better_supabase.memberships as a PermDock membership source if both should agree.");
|
|
131
|
+
const untracked = resolveModules(names, kit).map((module) => module.name).filter((name) => !config.sql.kit.includes(name));
|
|
132
|
+
if (untracked.length > 0) lines.push("", `Add them to your config so \`sql sync --check\` keeps them current:`, ` sql: { kit: [${[...config.sql.kit, ...untracked].map((name) => `'${name}'`).join(", ")}] }`);
|
|
133
|
+
if (args["dry-run"] !== true) lines.push(...await unlistedKitFiles(config, names, kit));
|
|
134
|
+
lines.push("", `Then create a migration: ${migrationCommand(await readSupabaseToml(config.root), "better_supabase_kit")}`);
|
|
135
|
+
return {
|
|
136
|
+
code: 0,
|
|
137
|
+
output: lines.join("\n")
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
case "sync": {
|
|
141
|
+
if (config.sql.kit.length === 0) return {
|
|
142
|
+
code: 0,
|
|
143
|
+
output: "sql.kit is empty; nothing to sync."
|
|
144
|
+
};
|
|
145
|
+
if (args.check !== true) return {
|
|
146
|
+
code: 0,
|
|
147
|
+
output: (await write(config, args, config.sql.kit, await layoutFor(config, args, config.sql.kit))).join("\n")
|
|
148
|
+
};
|
|
149
|
+
const stale = [];
|
|
150
|
+
const diffs = [];
|
|
151
|
+
for (const file of renderKit(config.sql.kit, await layoutFor(config, args, config.sql.kit))) {
|
|
152
|
+
const current = await readFile(resolve(config.root, file.path), "utf8").catch(() => void 0);
|
|
153
|
+
if (!sameKitFile(current, file.contents)) {
|
|
154
|
+
const shown = display(config.root, file.path);
|
|
155
|
+
stale.push(shown);
|
|
156
|
+
diffs.push(fileDiff(shown, current, file.contents, paint));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return stale.length === 0 ? {
|
|
160
|
+
code: 0,
|
|
161
|
+
output: "SQL kit files are up to date."
|
|
162
|
+
} : {
|
|
163
|
+
code: 1,
|
|
164
|
+
output: diffs.join("\n\n"),
|
|
165
|
+
error: `Out of date: ${stale.join(", ")}. Run \`better-supabase sql sync\`.`
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
case "print": {
|
|
169
|
+
const [name] = names;
|
|
170
|
+
const module = name ? SQL_MODULES[name] : void 0;
|
|
171
|
+
if (!module) return {
|
|
172
|
+
code: 2,
|
|
173
|
+
error: `Name one module: ${Object.keys(SQL_MODULES).join(", ")}`
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
code: 0,
|
|
177
|
+
output: module.render ? module.render(config.claims, await layout(config, args)) : module.sql
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
case void 0: return {
|
|
181
|
+
code: 2,
|
|
182
|
+
error: `Name an action.\n${USAGE}`
|
|
183
|
+
};
|
|
184
|
+
default: return {
|
|
185
|
+
code: 2,
|
|
186
|
+
error: `Unknown sql action "${action}".\n${USAGE}`
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const sqlCommand = defineCliCommand({
|
|
191
|
+
meta: {
|
|
192
|
+
name: "sql",
|
|
193
|
+
description: "Lists, adds, syncs and prints SQL kit modules"
|
|
194
|
+
},
|
|
195
|
+
args: SQL_ARGS,
|
|
196
|
+
run: (args, { config, io }) => runSql(config, args, painter(io.color))
|
|
197
|
+
});
|
|
198
|
+
//#endregion
|
|
199
|
+
export { sqlCommand };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
//#region src/cli/style.ts
|
|
3
|
+
const plain = (_format, text) => text;
|
|
4
|
+
const colored = (format, text) => styleText(format, text, { validateStream: false });
|
|
5
|
+
function painter(color) {
|
|
6
|
+
return color === true ? colored : plain;
|
|
7
|
+
}
|
|
8
|
+
/** Whether stdout takes colors: a TTY, and neither `NO_COLOR` nor `NODE_DISABLE_COLORS` set (`FORCE_COLOR` overrides). */
|
|
9
|
+
function colorEnabled() {
|
|
10
|
+
return styleText("red", "x", { stream: process.stdout }) !== "x";
|
|
11
|
+
}
|
|
12
|
+
const VERBS = [
|
|
13
|
+
[/^(?:Wrote|Updated)\b/, "green"],
|
|
14
|
+
[/^Would write\b/, "yellow"],
|
|
15
|
+
[/^(?:Unchanged|Kept|Same)\b/, "dim"]
|
|
16
|
+
];
|
|
17
|
+
/** Colors the verb that starts each `Wrote`, `Kept`, `Unchanged` or `Would write` line. */
|
|
18
|
+
function highlight(text, paint) {
|
|
19
|
+
if (paint === plain) return text;
|
|
20
|
+
return text.split("\n").map((line) => {
|
|
21
|
+
for (const [pattern, format] of VERBS) {
|
|
22
|
+
const verb = pattern.exec(line)?.[0];
|
|
23
|
+
if (verb) return `${paint(format, verb)}${line.slice(verb.length)}`;
|
|
24
|
+
}
|
|
25
|
+
return line;
|
|
26
|
+
}).join("\n");
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { plain as i, highlight as n, painter as r, colorEnabled as t };
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { n as o$1, t as i$1 } from "./_format-Cax5EsM9.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs
|
|
3
|
+
let e = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
4
|
+
var t = class t extends Date {
|
|
5
|
+
#e = !1;
|
|
6
|
+
#t = !1;
|
|
7
|
+
#n = null;
|
|
8
|
+
constructor(t) {
|
|
9
|
+
let n = !0, r = !0, i = `Z`;
|
|
10
|
+
if (typeof t == `string`) {
|
|
11
|
+
let a = t.match(e);
|
|
12
|
+
a ? (a[1] || (n = !1, t = `0000-01-01T${t}`), r = !!a[2], r && t[10] === ` ` && (t = t.replace(` `, `T`)), a[2] && +a[2] > 23 ? t = `` : (i = a[3] || null, t = t.toUpperCase(), !i && r && (t += `Z`))) : t = ``;
|
|
13
|
+
}
|
|
14
|
+
super(t), isNaN(this.getTime()) || (this.#e = n, this.#t = r, this.#n = i);
|
|
15
|
+
}
|
|
16
|
+
isDateTime() {
|
|
17
|
+
return this.#e && this.#t;
|
|
18
|
+
}
|
|
19
|
+
isLocal() {
|
|
20
|
+
return !this.#e || !this.#t || !this.#n;
|
|
21
|
+
}
|
|
22
|
+
isDate() {
|
|
23
|
+
return this.#e && !this.#t;
|
|
24
|
+
}
|
|
25
|
+
isTime() {
|
|
26
|
+
return this.#t && !this.#e;
|
|
27
|
+
}
|
|
28
|
+
isValid() {
|
|
29
|
+
return this.#e || this.#t;
|
|
30
|
+
}
|
|
31
|
+
toISOString() {
|
|
32
|
+
let e = super.toISOString();
|
|
33
|
+
if (this.isDate()) return e.slice(0, 10);
|
|
34
|
+
if (this.isTime()) return e.slice(11, 23);
|
|
35
|
+
if (this.#n === null) return e.slice(0, -1);
|
|
36
|
+
if (this.#n === `Z`) return e;
|
|
37
|
+
let t = this.#n.slice(1, 3) * 60 + +this.#n.slice(4, 6);
|
|
38
|
+
return t = this.#n[0] === `-` ? t : -t, (/* @__PURE__ */ new Date(this.getTime() - t * 6e4)).toISOString().slice(0, -1) + this.#n;
|
|
39
|
+
}
|
|
40
|
+
static wrapAsOffsetDateTime(e, n = `Z`) {
|
|
41
|
+
let r = new t(e);
|
|
42
|
+
return r.#n = n, r;
|
|
43
|
+
}
|
|
44
|
+
static wrapAsLocalDateTime(e) {
|
|
45
|
+
let n = new t(e);
|
|
46
|
+
return n.#n = null, n;
|
|
47
|
+
}
|
|
48
|
+
static wrapAsLocalDate(e) {
|
|
49
|
+
let n = new t(e);
|
|
50
|
+
return n.#t = !1, n.#n = null, n;
|
|
51
|
+
}
|
|
52
|
+
static wrapAsLocalTime(e) {
|
|
53
|
+
let n = new t(e);
|
|
54
|
+
return n.#e = !1, n.#n = null, n;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
function n(e, t) {
|
|
58
|
+
let n = e.slice(0, t).split(/\r\n|\n|\r/g);
|
|
59
|
+
return [n.length, n.pop().length + 1];
|
|
60
|
+
}
|
|
61
|
+
function r(e, t, n) {
|
|
62
|
+
let r = e.split(/\r\n|\n|\r/g), i = ``, a = (Math.log10(t + 1) | 0) + 1;
|
|
63
|
+
for (let e = t - 1; e <= t + 1; e++) {
|
|
64
|
+
let o = r[e - 1];
|
|
65
|
+
o && (i += e.toString().padEnd(a, ` `), i += `: `, i += o, i += `
|
|
66
|
+
`, e === t && (i += ` `.repeat(a + n + 2), i += `^
|
|
67
|
+
`));
|
|
68
|
+
}
|
|
69
|
+
return i;
|
|
70
|
+
}
|
|
71
|
+
var i = class extends Error {
|
|
72
|
+
line;
|
|
73
|
+
column;
|
|
74
|
+
codeblock;
|
|
75
|
+
constructor(e, t) {
|
|
76
|
+
let [i, a] = n(t.toml, t.ptr), o = r(t.toml, i, a);
|
|
77
|
+
super(`Invalid TOML document: ${e}\n\n${o}`, t), this.line = i, this.column = a, this.codeblock = o;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
function a$1(e, t = 0) {
|
|
81
|
+
let n = e.indexOf(`
|
|
82
|
+
`, t);
|
|
83
|
+
return e.charCodeAt(n - 1) === 13 && n--, n;
|
|
84
|
+
}
|
|
85
|
+
function o(e) {
|
|
86
|
+
for (; e.p < e.s.length; e.p++) {
|
|
87
|
+
let t = e.s.charCodeAt(e.p);
|
|
88
|
+
if (t === 10) break;
|
|
89
|
+
if (t === 13 && e.s.charCodeAt(e.p + 1) === 10) {
|
|
90
|
+
e.p++;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (t < 32 && t !== 9 || t === 127) throw new i(`control characters are not allowed in comments`, {
|
|
94
|
+
toml: e.s,
|
|
95
|
+
ptr: e.p
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function s(e, t, n) {
|
|
100
|
+
let r;
|
|
101
|
+
for (;;) {
|
|
102
|
+
for (; (r = e.s.charCodeAt(e.p)) === 32 || r === 9 || !t && (r === 10 || r === 13 && e.s.charCodeAt(e.p + 1) === 10);) e.p++;
|
|
103
|
+
if (n || r !== 35) break;
|
|
104
|
+
o(e);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function c(e, t, n) {
|
|
108
|
+
let r = e.p;
|
|
109
|
+
if (!n) {
|
|
110
|
+
r = a$1(e.s, r), e.p = r < 0 ? e.s.length : r;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
for (; e.p < e.s.length; e.p++) {
|
|
114
|
+
let r = e.s.charCodeAt(e.p);
|
|
115
|
+
if (r === 35) o(e);
|
|
116
|
+
else if (r === n || r === t) return;
|
|
117
|
+
}
|
|
118
|
+
throw new i(`cannot find end of structure`, {
|
|
119
|
+
toml: e.s,
|
|
120
|
+
ptr: r
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
let l = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
124
|
+
let u = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
125
|
+
let d = /^[+-]?0[0-9_]/;
|
|
126
|
+
function f(e) {
|
|
127
|
+
let t = e.p, n = e.s.charCodeAt(e.p++), r = n, a = n === 39, o = n === e.s.charCodeAt(e.p) && n === e.s.charCodeAt(e.p + 1);
|
|
128
|
+
o && ((n = e.s.charCodeAt(e.p += 2)) === 10 ? e.p++ : n === 13 && e.s.charCodeAt(e.p + 1) === 10 && (e.p += 2));
|
|
129
|
+
let s = ``, c = e.p, l = 0;
|
|
130
|
+
for (; e.p < e.s.length; e.p++) if (n = e.s.charCodeAt(e.p), o && (n === 10 || n === 13 && e.s.charCodeAt(e.p + 1) === 10)) l &&= 3;
|
|
131
|
+
else if (n < 32 && n !== 9 || n === 127) throw new i(`control characters are not allowed in strings`, {
|
|
132
|
+
toml: e.s,
|
|
133
|
+
ptr: e.p
|
|
134
|
+
});
|
|
135
|
+
else if ((!l || l === 3) && n === r && (!o || e.s.charCodeAt(e.p + 1) === r && e.s.charCodeAt(e.p + 2) === r)) return o && (e.s.charCodeAt(e.p + 3) === r && e.p++, e.s.charCodeAt(e.p + 3) === r && e.p++), l || (s += e.s.slice(c, e.p)), e.p += o ? 3 : 1, s;
|
|
136
|
+
else if (!l) !a && n === 92 && (s += e.s.slice(c, c = e.p), l = 1);
|
|
137
|
+
else if (l === 1) {
|
|
138
|
+
if (n === 120 || n === 117 || n === 85) {
|
|
139
|
+
let t = 0, r = n === 120 ? 2 : n === 117 ? 4 : 8;
|
|
140
|
+
for (let n = 0; n < r; n++, e.p++) {
|
|
141
|
+
let n = e.s.charCodeAt(e.p + 1), r = n >= 48 && n <= 57 ? n - 48 : n >= 65 && n <= 70 ? n - 65 + 10 : n >= 97 && n <= 102 ? n - 97 + 10 : -1;
|
|
142
|
+
if (r < 0) throw new i(`invalid non-hex character in unicode escape`, {
|
|
143
|
+
toml: e.s,
|
|
144
|
+
ptr: e.p + 1
|
|
145
|
+
});
|
|
146
|
+
t = t << 4 | r;
|
|
147
|
+
}
|
|
148
|
+
if (t < 0 || t > 1114111 || t >= 55296 && t <= 57343) throw new i(`invalid unicode escape`, {
|
|
149
|
+
toml: e.s,
|
|
150
|
+
ptr: e.p
|
|
151
|
+
});
|
|
152
|
+
s += String.fromCodePoint(t), c = e.p + 1, l = 0;
|
|
153
|
+
} else if (n === 32 || n === 9) l = 2;
|
|
154
|
+
else {
|
|
155
|
+
if (n === 98) s += `\b`;
|
|
156
|
+
else if (n === 116) s += ` `;
|
|
157
|
+
else if (n === 110) s += `
|
|
158
|
+
`;
|
|
159
|
+
else if (n === 102) s += `\f`;
|
|
160
|
+
else if (n === 114) s += `\r`;
|
|
161
|
+
else if (n === 101) s += `\x1B`;
|
|
162
|
+
else if (n === 34) s += `"`;
|
|
163
|
+
else if (n === 92) s += `\\`;
|
|
164
|
+
else throw new i(`unrecognized escape sequence`, {
|
|
165
|
+
toml: e.s,
|
|
166
|
+
ptr: e.p
|
|
167
|
+
});
|
|
168
|
+
c = e.p + 1, l = 0;
|
|
169
|
+
}
|
|
170
|
+
} else if (n !== 32 && n !== 9) {
|
|
171
|
+
if (l === 2) throw new i(`invalid escape: only line-ending whitespace may be escaped`, {
|
|
172
|
+
toml: e.s,
|
|
173
|
+
ptr: c
|
|
174
|
+
});
|
|
175
|
+
l = +(!a && n === 92), c = e.p;
|
|
176
|
+
}
|
|
177
|
+
throw new i(`unfinished string`, {
|
|
178
|
+
toml: e.s,
|
|
179
|
+
ptr: t
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function p(e, t, n) {
|
|
183
|
+
let r = e.s.slice(t, n), i = r.indexOf(`#`);
|
|
184
|
+
return i > 0 && (o({
|
|
185
|
+
s: r,
|
|
186
|
+
p: i,
|
|
187
|
+
d: 0
|
|
188
|
+
}), r = r.slice(0, i)), r.trimEnd();
|
|
189
|
+
}
|
|
190
|
+
function m(e, n, r) {
|
|
191
|
+
let a = e.p, o = {
|
|
192
|
+
toml: e.s,
|
|
193
|
+
ptr: a
|
|
194
|
+
};
|
|
195
|
+
c(e, 44, r);
|
|
196
|
+
let s = p(e, a, e.p);
|
|
197
|
+
if (!s) throw new i(`incomplete declaration: value expected`, o);
|
|
198
|
+
if (s === `-inf`) return -1 / 0;
|
|
199
|
+
if (s === `inf` || s === `+inf`) return 1 / 0;
|
|
200
|
+
if (s === `nan` || s === `+nan` || s === `-nan`) return NaN;
|
|
201
|
+
if (s === `-0`) return n ? 0n : 0;
|
|
202
|
+
let f = l.test(s);
|
|
203
|
+
if (f || u.test(s)) {
|
|
204
|
+
if (d.test(s)) throw new i(`leading zeroes are not allowed`, o);
|
|
205
|
+
s = s.replace(/_/g, ``);
|
|
206
|
+
let e = +s;
|
|
207
|
+
if (isNaN(e)) throw new i(`invalid number`, o);
|
|
208
|
+
if (f) {
|
|
209
|
+
if ((f = !Number.isSafeInteger(e)) && !n) throw new i(`integer value cannot be represented losslessly`, o);
|
|
210
|
+
(f || n === !0) && (e = BigInt(s));
|
|
211
|
+
}
|
|
212
|
+
return e;
|
|
213
|
+
}
|
|
214
|
+
let m = new t(s);
|
|
215
|
+
if (!m.isValid()) throw new i(`invalid value`, o);
|
|
216
|
+
return m;
|
|
217
|
+
}
|
|
218
|
+
function h(e, t, n) {
|
|
219
|
+
let r = e.p, a = e.s.charCodeAt(r);
|
|
220
|
+
if (a === 91 || a === 123) {
|
|
221
|
+
if (!e.d--) throw new i(`document contains excessively nested structures. aborting.`, {
|
|
222
|
+
toml: e.s,
|
|
223
|
+
ptr: r
|
|
224
|
+
});
|
|
225
|
+
let t = a === 91 ? y(e, n) : v(e, n);
|
|
226
|
+
return e.d++, t;
|
|
227
|
+
}
|
|
228
|
+
if (a === 34 || a === 39) return f(e);
|
|
229
|
+
if (a === 116) {
|
|
230
|
+
if (e.s.charCodeAt(++e.p) !== 114 || e.s.charCodeAt(++e.p) !== 117 || e.s.charCodeAt(++e.p) !== 101) throw new i(`invalid value`, {
|
|
231
|
+
toml: e.s,
|
|
232
|
+
ptr: r
|
|
233
|
+
});
|
|
234
|
+
return e.p++, !0;
|
|
235
|
+
}
|
|
236
|
+
if (a === 102) {
|
|
237
|
+
if (e.s.charCodeAt(++e.p) !== 97 || e.s.charCodeAt(++e.p) !== 108 || e.s.charCodeAt(++e.p) !== 115 || e.s.charCodeAt(++e.p) !== 101) throw new i(`invalid value`, {
|
|
238
|
+
toml: e.s,
|
|
239
|
+
ptr: r
|
|
240
|
+
});
|
|
241
|
+
return e.p++, !1;
|
|
242
|
+
}
|
|
243
|
+
return m(e, n, t);
|
|
244
|
+
}
|
|
245
|
+
let g = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
246
|
+
function _(e, t = `=`) {
|
|
247
|
+
let n = e.p, r = n - 1, o = [], c = e.s.indexOf(t, n);
|
|
248
|
+
if (c < 0) throw new i(`incomplete key-value: cannot find end of key`, {
|
|
249
|
+
toml: e.s,
|
|
250
|
+
ptr: n
|
|
251
|
+
});
|
|
252
|
+
do {
|
|
253
|
+
let s = e.s.charCodeAt(e.p = ++r);
|
|
254
|
+
if (s !== 32 && s !== 9) {
|
|
255
|
+
if (s === 34 || s === 39) {
|
|
256
|
+
if (s === e.s.charCodeAt(e.p + 1) && s === e.s.charCodeAt(e.p + 2)) throw new i(`multiline strings are not allowed in keys`, {
|
|
257
|
+
toml: e.s,
|
|
258
|
+
ptr: e.p
|
|
259
|
+
});
|
|
260
|
+
let l = f(e);
|
|
261
|
+
r = e.s.indexOf(`.`, e.p);
|
|
262
|
+
let u = e.s.slice(e.p, r < 0 || r > c ? c : r), d = a$1(u);
|
|
263
|
+
if (d > -1) throw new i(`newlines are not allowed in keys`, {
|
|
264
|
+
toml: e.s,
|
|
265
|
+
ptr: d
|
|
266
|
+
});
|
|
267
|
+
if (u.trimStart()) throw new i(`found extra tokens after the string part`, {
|
|
268
|
+
toml: e.s,
|
|
269
|
+
ptr: e.p
|
|
270
|
+
});
|
|
271
|
+
if (c < e.p && (c = e.s.indexOf(t, e.p), c < 0)) throw new i(`incomplete key-value: cannot find end of key`, {
|
|
272
|
+
toml: e.s,
|
|
273
|
+
ptr: n
|
|
274
|
+
});
|
|
275
|
+
o.push(l);
|
|
276
|
+
} else {
|
|
277
|
+
r = e.s.indexOf(`.`, e.p);
|
|
278
|
+
let t = e.s.slice(e.p, r < 0 || r > c ? c : r);
|
|
279
|
+
if (!g.test(t)) throw new i(`only letter, numbers, dashes and underscores are allowed in keys`, {
|
|
280
|
+
toml: e.s,
|
|
281
|
+
ptr: e.p
|
|
282
|
+
});
|
|
283
|
+
o.push(t.trimEnd());
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
} while (r + 1 && r < c);
|
|
287
|
+
return e.p = c + 1, s(e, !0, !0), o;
|
|
288
|
+
}
|
|
289
|
+
function v(e, t) {
|
|
290
|
+
let n = {}, r = /* @__PURE__ */ new Set(), a;
|
|
291
|
+
for (e.p++; e.p < e.s.length;) {
|
|
292
|
+
if (s(e), (a = e.s.charCodeAt(e.p)) === 125) return e.p++, n;
|
|
293
|
+
let o, c = n, l = !1, u = e.p, d = _(e);
|
|
294
|
+
for (let t = 0; t < d.length; t++) {
|
|
295
|
+
if (t && (c = l ? c[o] : c[o] = {}), o = d[t], (l = Object.hasOwn(c, o)) && (typeof c[o] != `object` || r.has(c[o]))) throw new i(`trying to redefine an already defined value`, {
|
|
296
|
+
toml: e.s,
|
|
297
|
+
ptr: u
|
|
298
|
+
});
|
|
299
|
+
!l && o === `__proto__` && Object.defineProperty(c, o, {
|
|
300
|
+
enumerable: !0,
|
|
301
|
+
configurable: !0,
|
|
302
|
+
writable: !0
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
if (l) throw new i(`trying to redefine an already defined value`, {
|
|
306
|
+
toml: e.s,
|
|
307
|
+
ptr: e.p
|
|
308
|
+
});
|
|
309
|
+
let f = h(e, 125, t);
|
|
310
|
+
if (r.add(c[o] = f), s(e), (a = e.s.charCodeAt(e.p++)) === 125) return n;
|
|
311
|
+
if (a !== 44) throw new i(`expected comma or end of structure`, {
|
|
312
|
+
toml: e.s,
|
|
313
|
+
ptr: e.p - 1
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
throw new i(`unfinished table encountered`, {
|
|
317
|
+
toml: e.s,
|
|
318
|
+
ptr: e.p
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function y(e, t) {
|
|
322
|
+
let n = [], r;
|
|
323
|
+
for (e.p++; e.p < e.s.length;) {
|
|
324
|
+
if (s(e), (r = e.s.charCodeAt(e.p)) === 93) return e.p++, n;
|
|
325
|
+
if (n.push(h(e, 93, t)), s(e), (r = e.s.charCodeAt(e.p++)) === 93) return n;
|
|
326
|
+
if (r !== 44) throw new i(`expected comma or end of structure`, {
|
|
327
|
+
toml: e.s,
|
|
328
|
+
ptr: e.p - 1
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
throw new i(`unfinished array encountered`, {
|
|
332
|
+
toml: e.s,
|
|
333
|
+
ptr: e.p
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function b(e, t, n, r) {
|
|
337
|
+
let i = t, a = n, o, s = !1, c;
|
|
338
|
+
for (let t = 0; t < e.length; t++) {
|
|
339
|
+
if (t) {
|
|
340
|
+
if (i = s ? i[o] : i[o] = {}, a = (c = a[o]).c, r === 0 && (c.t === 1 || c.t === 2)) return null;
|
|
341
|
+
if (c.t === 2) {
|
|
342
|
+
let e = i.length - 1;
|
|
343
|
+
i = i[e], a = a[e].c;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (o = e[t], (s = Object.hasOwn(i, o)) && a[o]?.t === 0 && a[o]?.d) return null;
|
|
347
|
+
s || (o === `__proto__` && (Object.defineProperty(i, o, {
|
|
348
|
+
enumerable: !0,
|
|
349
|
+
configurable: !0,
|
|
350
|
+
writable: !0
|
|
351
|
+
}), Object.defineProperty(a, o, {
|
|
352
|
+
enumerable: !0,
|
|
353
|
+
configurable: !0,
|
|
354
|
+
writable: !0
|
|
355
|
+
})), a[o] = {
|
|
356
|
+
t: t < e.length - 1 && r === 2 ? 3 : r,
|
|
357
|
+
d: !1,
|
|
358
|
+
i: 0,
|
|
359
|
+
c: {}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
if (c = a[o], c.t !== r && (r !== 1 || c.t !== 3) || (r === 2 && (c.d || (c.d = !0, i[o] = []), i[o].push(i = {}), c.c[c.i++] = c = {
|
|
363
|
+
t: 1,
|
|
364
|
+
d: !1,
|
|
365
|
+
i: 0,
|
|
366
|
+
c: {}
|
|
367
|
+
}), c.d)) return null;
|
|
368
|
+
if (c.d = !0, r === 1) i = s ? i[o] : i[o] = {};
|
|
369
|
+
else if (r === 0 && s) return null;
|
|
370
|
+
return [
|
|
371
|
+
o,
|
|
372
|
+
i,
|
|
373
|
+
c.c
|
|
374
|
+
];
|
|
375
|
+
}
|
|
376
|
+
function x(e, { maxDepth: t = 1e3, integersAsBigInt: n } = {}) {
|
|
377
|
+
let r = {
|
|
378
|
+
s: e,
|
|
379
|
+
p: 0,
|
|
380
|
+
d: t
|
|
381
|
+
}, a = {}, o = {}, c, l = a, u = o;
|
|
382
|
+
for (s(r); r.p < e.length;) {
|
|
383
|
+
if (e.charCodeAt(r.p) === 91) {
|
|
384
|
+
let t = e.charCodeAt(++r.p) === 91;
|
|
385
|
+
c = r.p += +t;
|
|
386
|
+
let n = _(r, `]`);
|
|
387
|
+
if (t) {
|
|
388
|
+
if (e.charCodeAt(r.p - 1) !== 93) throw new i(`expected end of table declaration`, {
|
|
389
|
+
toml: e,
|
|
390
|
+
ptr: r.p - 1
|
|
391
|
+
});
|
|
392
|
+
r.p++;
|
|
393
|
+
}
|
|
394
|
+
let s = b(n, a, o, t ? 2 : 1);
|
|
395
|
+
if (!s) throw new i(`trying to redefine an already defined table or value`, {
|
|
396
|
+
toml: e,
|
|
397
|
+
ptr: c
|
|
398
|
+
});
|
|
399
|
+
u = s[2], l = s[1];
|
|
400
|
+
} else {
|
|
401
|
+
c = r.p;
|
|
402
|
+
let t = b(_(r), l, u, 0);
|
|
403
|
+
if (!t) throw new i(`trying to redefine an already defined table or value`, {
|
|
404
|
+
toml: e,
|
|
405
|
+
ptr: c
|
|
406
|
+
});
|
|
407
|
+
t[1][t[0]] = h(r, void 0, n);
|
|
408
|
+
}
|
|
409
|
+
if (s(r, !0), r.p < e.length && (c = e.charCodeAt(r.p)) !== 10 && c !== 13) throw new i(`each key-value declaration must be followed by an end-of-line`, {
|
|
410
|
+
toml: e,
|
|
411
|
+
ptr: r.p
|
|
412
|
+
});
|
|
413
|
+
s(r);
|
|
414
|
+
}
|
|
415
|
+
return a;
|
|
416
|
+
}
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/toml.mjs
|
|
419
|
+
function a(e) {
|
|
420
|
+
let i = x(i$1(e));
|
|
421
|
+
return o$1(e, i, { preserveIndentation: !1 }), i;
|
|
422
|
+
}
|
|
423
|
+
//#endregion
|
|
424
|
+
export { a as parseTOML };
|