@aurabase/gen 0.6.2 → 0.7.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/dist/cli.cjs +26 -26
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +26 -26
- package/package.json +3 -3
package/dist/cli.cjs
CHANGED
|
@@ -345,7 +345,7 @@ export type Enums<
|
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
// src/cli.ts
|
|
348
|
-
var VERSION = "0.
|
|
348
|
+
var VERSION = "0.7.1";
|
|
349
349
|
function loadEnvFiles() {
|
|
350
350
|
const envCandidates = [".env.local", ".env.development.local", ".env.development", ".env"];
|
|
351
351
|
for (const file of envCandidates) {
|
|
@@ -380,11 +380,11 @@ function loadEnvFiles() {
|
|
|
380
380
|
}
|
|
381
381
|
function diagnostiquerSchema(tables) {
|
|
382
382
|
if (tables.length === 0) {
|
|
383
|
-
return "
|
|
383
|
+
return "Empty schema: no table. The generated types would be unusable.";
|
|
384
384
|
}
|
|
385
385
|
const vides = tables.filter((t) => !t.columns || t.columns.length === 0).map((t) => t.name);
|
|
386
386
|
if (vides.length > 0) {
|
|
387
|
-
return `Tables
|
|
387
|
+
return `Tables without any column: ${vides.join(", ")}. The generated types for them would be "Row: {}", with no guarantee: they accept any field and guarantee none. This is the case of a MongoDB project, whose schema is not declared. Use --allow-empty to generate anyway.`;
|
|
388
388
|
}
|
|
389
389
|
return null;
|
|
390
390
|
}
|
|
@@ -434,30 +434,30 @@ function parseArgs(argv) {
|
|
|
434
434
|
return a;
|
|
435
435
|
}
|
|
436
436
|
var HELP_TEXT = `
|
|
437
|
-
aurabase-gen (v${VERSION}) \u2014
|
|
437
|
+
aurabase-gen (v${VERSION}) \u2014 TypeScript type generator for Aurabase
|
|
438
438
|
|
|
439
|
-
USAGE
|
|
439
|
+
USAGE:
|
|
440
440
|
npx @aurabase/gen [options]
|
|
441
|
-
aurabase-gen --url <projectUrl> --key <apiKey> [--out <
|
|
441
|
+
aurabase-gen --url <projectUrl> --key <apiKey> [--out <file>]
|
|
442
442
|
|
|
443
|
-
OPTIONS
|
|
444
|
-
--url <url>
|
|
445
|
-
[Auto-
|
|
446
|
-
--key <
|
|
447
|
-
[Auto-
|
|
448
|
-
-o, --out <
|
|
449
|
-
|
|
450
|
-
-s, --schema <
|
|
451
|
-
-t, --type-name <t>
|
|
452
|
-
--allow-empty
|
|
453
|
-
-h, --help
|
|
454
|
-
-v, --version
|
|
443
|
+
OPTIONS:
|
|
444
|
+
--url <url> Aurabase project URL (e.g. https://my-project.aurabase.cloud)
|
|
445
|
+
[Auto-detected: NEXT_PUBLIC_AURABASE_URL]
|
|
446
|
+
--key <key> Project API key (anon or service_role)
|
|
447
|
+
[Auto-detected: AURABASE_SERVICE_ROLE_KEY, then NEXT_PUBLIC_AURABASE_ANON_KEY]
|
|
448
|
+
-o, --out <file> Output file (e.g. src/types/database.types.ts)
|
|
449
|
+
If omitted, the result is written to stdout.
|
|
450
|
+
-s, --schema <name> Database schema name (default: 'public')
|
|
451
|
+
-t, --type-name <t> Name of the main generated interface (default: 'Database')
|
|
452
|
+
--allow-empty Generate the types even if some tables have no declared columns
|
|
453
|
+
-h, --help Show this help
|
|
454
|
+
-v, --version Show the version
|
|
455
455
|
|
|
456
|
-
|
|
457
|
-
#
|
|
456
|
+
EXAMPLES:
|
|
457
|
+
# Generation reading the environment variables automatically (.env / .env.local):
|
|
458
458
|
npx @aurabase/gen --out src/types/database.types.ts
|
|
459
459
|
|
|
460
|
-
#
|
|
460
|
+
# Explicit parameters:
|
|
461
461
|
npx @aurabase/gen --url https://xyz.aurabase.cloud --key aura_anon_123 --out db.types.ts
|
|
462
462
|
`;
|
|
463
463
|
async function main() {
|
|
@@ -474,11 +474,11 @@ async function main() {
|
|
|
474
474
|
const url = args.url ?? process.env.NEXT_PUBLIC_AURABASE_URL;
|
|
475
475
|
const key = args.key ?? process.env.AURABASE_SERVICE_ROLE_KEY ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY;
|
|
476
476
|
if (!url || !key) {
|
|
477
|
-
console.error("[aurabase-gen]
|
|
478
|
-
console.error("
|
|
477
|
+
console.error("[aurabase-gen] Error: the project URL and/or API key is missing.\n");
|
|
478
|
+
console.error("Provide them through the CLI arguments (--url and --key) or in your environment variables (.env / .env.local):");
|
|
479
479
|
console.error(" NEXT_PUBLIC_AURABASE_URL=https://<slug>.aurabase.cloud");
|
|
480
480
|
console.error(" NEXT_PUBLIC_AURABASE_ANON_KEY=aura_anon_...\n");
|
|
481
|
-
console.error("
|
|
481
|
+
console.error("Run `npx @aurabase/gen --help` to see all the available options.");
|
|
482
482
|
process.exit(1);
|
|
483
483
|
}
|
|
484
484
|
const schemaName = args.schema ?? process.env.AURABASE_SCHEMA ?? "public";
|
|
@@ -486,7 +486,7 @@ async function main() {
|
|
|
486
486
|
const client = aurabaseJs.createClient(url, key);
|
|
487
487
|
const { data, error } = await client.db.schema();
|
|
488
488
|
if (error) {
|
|
489
|
-
console.error(`[aurabase-gen]
|
|
489
|
+
console.error(`[aurabase-gen] Error fetching the schema: ${error.message}`);
|
|
490
490
|
process.exit(1);
|
|
491
491
|
}
|
|
492
492
|
const tables = data?.tables ?? [];
|
|
@@ -510,7 +510,7 @@ async function main() {
|
|
|
510
510
|
if (outPath) {
|
|
511
511
|
fs.writeFileSync(outPath, output);
|
|
512
512
|
console.error(
|
|
513
|
-
`[aurabase-gen] \u2713 Types
|
|
513
|
+
`[aurabase-gen] \u2713 Types written to ${outPath} (${tables.length} table(s), ${functions.length} function(s), ${enums.length} enum(s), ${views.length} view(s)).`
|
|
514
514
|
);
|
|
515
515
|
} else {
|
|
516
516
|
process.stdout.write(output);
|
package/dist/cli.d.cts
CHANGED
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -343,7 +343,7 @@ export type Enums<
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
// src/cli.ts
|
|
346
|
-
var VERSION = "0.
|
|
346
|
+
var VERSION = "0.7.1";
|
|
347
347
|
function loadEnvFiles() {
|
|
348
348
|
const envCandidates = [".env.local", ".env.development.local", ".env.development", ".env"];
|
|
349
349
|
for (const file of envCandidates) {
|
|
@@ -378,11 +378,11 @@ function loadEnvFiles() {
|
|
|
378
378
|
}
|
|
379
379
|
function diagnostiquerSchema(tables) {
|
|
380
380
|
if (tables.length === 0) {
|
|
381
|
-
return "
|
|
381
|
+
return "Empty schema: no table. The generated types would be unusable.";
|
|
382
382
|
}
|
|
383
383
|
const vides = tables.filter((t) => !t.columns || t.columns.length === 0).map((t) => t.name);
|
|
384
384
|
if (vides.length > 0) {
|
|
385
|
-
return `Tables
|
|
385
|
+
return `Tables without any column: ${vides.join(", ")}. The generated types for them would be "Row: {}", with no guarantee: they accept any field and guarantee none. This is the case of a MongoDB project, whose schema is not declared. Use --allow-empty to generate anyway.`;
|
|
386
386
|
}
|
|
387
387
|
return null;
|
|
388
388
|
}
|
|
@@ -432,30 +432,30 @@ function parseArgs(argv) {
|
|
|
432
432
|
return a;
|
|
433
433
|
}
|
|
434
434
|
var HELP_TEXT = `
|
|
435
|
-
aurabase-gen (v${VERSION}) \u2014
|
|
435
|
+
aurabase-gen (v${VERSION}) \u2014 TypeScript type generator for Aurabase
|
|
436
436
|
|
|
437
|
-
USAGE
|
|
437
|
+
USAGE:
|
|
438
438
|
npx @aurabase/gen [options]
|
|
439
|
-
aurabase-gen --url <projectUrl> --key <apiKey> [--out <
|
|
439
|
+
aurabase-gen --url <projectUrl> --key <apiKey> [--out <file>]
|
|
440
440
|
|
|
441
|
-
OPTIONS
|
|
442
|
-
--url <url>
|
|
443
|
-
[Auto-
|
|
444
|
-
--key <
|
|
445
|
-
[Auto-
|
|
446
|
-
-o, --out <
|
|
447
|
-
|
|
448
|
-
-s, --schema <
|
|
449
|
-
-t, --type-name <t>
|
|
450
|
-
--allow-empty
|
|
451
|
-
-h, --help
|
|
452
|
-
-v, --version
|
|
441
|
+
OPTIONS:
|
|
442
|
+
--url <url> Aurabase project URL (e.g. https://my-project.aurabase.cloud)
|
|
443
|
+
[Auto-detected: NEXT_PUBLIC_AURABASE_URL]
|
|
444
|
+
--key <key> Project API key (anon or service_role)
|
|
445
|
+
[Auto-detected: AURABASE_SERVICE_ROLE_KEY, then NEXT_PUBLIC_AURABASE_ANON_KEY]
|
|
446
|
+
-o, --out <file> Output file (e.g. src/types/database.types.ts)
|
|
447
|
+
If omitted, the result is written to stdout.
|
|
448
|
+
-s, --schema <name> Database schema name (default: 'public')
|
|
449
|
+
-t, --type-name <t> Name of the main generated interface (default: 'Database')
|
|
450
|
+
--allow-empty Generate the types even if some tables have no declared columns
|
|
451
|
+
-h, --help Show this help
|
|
452
|
+
-v, --version Show the version
|
|
453
453
|
|
|
454
|
-
|
|
455
|
-
#
|
|
454
|
+
EXAMPLES:
|
|
455
|
+
# Generation reading the environment variables automatically (.env / .env.local):
|
|
456
456
|
npx @aurabase/gen --out src/types/database.types.ts
|
|
457
457
|
|
|
458
|
-
#
|
|
458
|
+
# Explicit parameters:
|
|
459
459
|
npx @aurabase/gen --url https://xyz.aurabase.cloud --key aura_anon_123 --out db.types.ts
|
|
460
460
|
`;
|
|
461
461
|
async function main() {
|
|
@@ -472,11 +472,11 @@ async function main() {
|
|
|
472
472
|
const url = args.url ?? process.env.NEXT_PUBLIC_AURABASE_URL;
|
|
473
473
|
const key = args.key ?? process.env.AURABASE_SERVICE_ROLE_KEY ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY;
|
|
474
474
|
if (!url || !key) {
|
|
475
|
-
console.error("[aurabase-gen]
|
|
476
|
-
console.error("
|
|
475
|
+
console.error("[aurabase-gen] Error: the project URL and/or API key is missing.\n");
|
|
476
|
+
console.error("Provide them through the CLI arguments (--url and --key) or in your environment variables (.env / .env.local):");
|
|
477
477
|
console.error(" NEXT_PUBLIC_AURABASE_URL=https://<slug>.aurabase.cloud");
|
|
478
478
|
console.error(" NEXT_PUBLIC_AURABASE_ANON_KEY=aura_anon_...\n");
|
|
479
|
-
console.error("
|
|
479
|
+
console.error("Run `npx @aurabase/gen --help` to see all the available options.");
|
|
480
480
|
process.exit(1);
|
|
481
481
|
}
|
|
482
482
|
const schemaName = args.schema ?? process.env.AURABASE_SCHEMA ?? "public";
|
|
@@ -484,7 +484,7 @@ async function main() {
|
|
|
484
484
|
const client = createClient(url, key);
|
|
485
485
|
const { data, error } = await client.db.schema();
|
|
486
486
|
if (error) {
|
|
487
|
-
console.error(`[aurabase-gen]
|
|
487
|
+
console.error(`[aurabase-gen] Error fetching the schema: ${error.message}`);
|
|
488
488
|
process.exit(1);
|
|
489
489
|
}
|
|
490
490
|
const tables = data?.tables ?? [];
|
|
@@ -508,7 +508,7 @@ async function main() {
|
|
|
508
508
|
if (outPath) {
|
|
509
509
|
writeFileSync(outPath, output);
|
|
510
510
|
console.error(
|
|
511
|
-
`[aurabase-gen] \u2713 Types
|
|
511
|
+
`[aurabase-gen] \u2713 Types written to ${outPath} (${tables.length} table(s), ${functions.length} function(s), ${enums.length} enum(s), ${views.length} view(s)).`
|
|
512
512
|
);
|
|
513
513
|
} else {
|
|
514
514
|
process.stdout.write(output);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aurabase/gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Générateur de types TypeScript Database pour le SDK Aurabase (CLI aurabase-gen)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"types"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@aurabase/
|
|
53
|
-
"@aurabase/
|
|
52
|
+
"@aurabase/core": "0.7.1",
|
|
53
|
+
"@aurabase/aurabase-js": "0.7.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"tsup": "^8.0.0",
|