@pgpmjs/core 5.0.1 → 5.1.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/esm/export/export-meta.js +22 -11
- package/esm/export/export-migrations.js +1 -1
- package/esm/index.js +1 -0
- package/esm/slice/index.js +3 -0
- package/esm/slice/output.js +117 -0
- package/esm/slice/slice.js +520 -0
- package/esm/slice/types.js +1 -0
- package/export/export-meta.js +22 -11
- package/export/export-migrations.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +3 -2
- package/slice/index.d.ts +3 -0
- package/slice/index.js +19 -0
- package/slice/output.d.ts +22 -0
- package/slice/output.js +124 -0
- package/slice/slice.d.ts +59 -0
- package/slice/slice.js +536 -0
- package/slice/types.d.ts +133 -0
- package/slice/types.js +2 -0
|
@@ -443,7 +443,8 @@ const config = {
|
|
|
443
443
|
api_id: 'uuid',
|
|
444
444
|
schema_id: 'uuid',
|
|
445
445
|
private_schema_id: 'uuid',
|
|
446
|
-
|
|
446
|
+
session_credentials_table_id: 'uuid',
|
|
447
|
+
sessions_table_id: 'uuid',
|
|
447
448
|
users_table_id: 'uuid',
|
|
448
449
|
authenticate: 'text',
|
|
449
450
|
authenticate_strict: 'text',
|
|
@@ -462,7 +463,10 @@ const config = {
|
|
|
462
463
|
users_table_id: 'uuid',
|
|
463
464
|
secrets_table_id: 'uuid',
|
|
464
465
|
encrypted_table_id: 'uuid',
|
|
465
|
-
|
|
466
|
+
sessions_table_id: 'uuid',
|
|
467
|
+
session_credentials_table_id: 'uuid',
|
|
468
|
+
audits_table_id: 'uuid',
|
|
469
|
+
audits_table_name: 'text',
|
|
466
470
|
sign_in_function: 'text',
|
|
467
471
|
sign_up_function: 'text',
|
|
468
472
|
sign_out_function: 'text',
|
|
@@ -475,7 +479,9 @@ const config = {
|
|
|
475
479
|
reset_password_function: 'text',
|
|
476
480
|
forgot_password_function: 'text',
|
|
477
481
|
send_verification_email_function: 'text',
|
|
478
|
-
verify_email_function: 'text'
|
|
482
|
+
verify_email_function: 'text',
|
|
483
|
+
verify_password_function: 'text',
|
|
484
|
+
check_password_function: 'text'
|
|
479
485
|
}
|
|
480
486
|
},
|
|
481
487
|
memberships_module: {
|
|
@@ -677,17 +683,21 @@ const config = {
|
|
|
677
683
|
table_name: 'text'
|
|
678
684
|
}
|
|
679
685
|
},
|
|
680
|
-
|
|
686
|
+
sessions_module: {
|
|
681
687
|
schema: 'metaschema_modules_public',
|
|
682
|
-
table: '
|
|
688
|
+
table: 'sessions_module',
|
|
683
689
|
fields: {
|
|
684
690
|
id: 'uuid',
|
|
685
691
|
database_id: 'uuid',
|
|
686
692
|
schema_id: 'uuid',
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
693
|
+
sessions_table_id: 'uuid',
|
|
694
|
+
session_credentials_table_id: 'uuid',
|
|
695
|
+
auth_settings_table_id: 'uuid',
|
|
696
|
+
users_table_id: 'uuid',
|
|
697
|
+
sessions_default_expiration: 'interval',
|
|
698
|
+
sessions_table: 'text',
|
|
699
|
+
session_credentials_table: 'text',
|
|
700
|
+
auth_settings_table: 'text'
|
|
691
701
|
}
|
|
692
702
|
},
|
|
693
703
|
secrets_module: {
|
|
@@ -785,7 +795,8 @@ const config = {
|
|
|
785
795
|
database_id: 'uuid',
|
|
786
796
|
schema_id: 'uuid',
|
|
787
797
|
users_table_id: 'uuid',
|
|
788
|
-
|
|
798
|
+
sessions_table_id: 'uuid',
|
|
799
|
+
session_credentials_table_id: 'uuid',
|
|
789
800
|
secrets_table_id: 'uuid',
|
|
790
801
|
addresses_table_id: 'uuid',
|
|
791
802
|
user_field: 'text',
|
|
@@ -980,7 +991,7 @@ export const exportMeta = async ({ opts, dbname, database_id }) => {
|
|
|
980
991
|
await queryAndParse('membership_types_module', `SELECT * FROM metaschema_modules_public.membership_types_module WHERE database_id = $1`);
|
|
981
992
|
await queryAndParse('invites_module', `SELECT * FROM metaschema_modules_public.invites_module WHERE database_id = $1`);
|
|
982
993
|
await queryAndParse('emails_module', `SELECT * FROM metaschema_modules_public.emails_module WHERE database_id = $1`);
|
|
983
|
-
await queryAndParse('
|
|
994
|
+
await queryAndParse('sessions_module', `SELECT * FROM metaschema_modules_public.sessions_module WHERE database_id = $1`);
|
|
984
995
|
await queryAndParse('secrets_module', `SELECT * FROM metaschema_modules_public.secrets_module WHERE database_id = $1`);
|
|
985
996
|
await queryAndParse('profiles_module', `SELECT * FROM metaschema_modules_public.profiles_module WHERE database_id = $1`);
|
|
986
997
|
await queryAndParse('encrypted_secrets_module', `SELECT * FROM metaschema_modules_public.encrypted_secrets_module WHERE database_id = $1`);
|
package/esm/index.js
CHANGED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Write sliced packages to disk
|
|
5
|
+
*/
|
|
6
|
+
export function writeSliceResult(result, options) {
|
|
7
|
+
const { outputDir, overwrite = false, copySourceFiles = false, sourceDir } = options;
|
|
8
|
+
// Create output directory
|
|
9
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
10
|
+
// Write each package
|
|
11
|
+
for (const pkg of result.packages) {
|
|
12
|
+
writePackage(pkg, outputDir, overwrite, copySourceFiles, sourceDir);
|
|
13
|
+
}
|
|
14
|
+
// Write workspace manifest
|
|
15
|
+
const manifestPath = path.join(outputDir, 'pgpm-workspace.json');
|
|
16
|
+
const manifestContent = JSON.stringify({
|
|
17
|
+
packages: result.workspace.packages.map(p => `packages/${p}`),
|
|
18
|
+
slicing: {
|
|
19
|
+
deployOrder: result.workspace.deployOrder,
|
|
20
|
+
dependencies: result.workspace.dependencies
|
|
21
|
+
},
|
|
22
|
+
stats: result.stats
|
|
23
|
+
}, null, 2);
|
|
24
|
+
fs.writeFileSync(manifestPath, manifestContent);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Write a single package to disk
|
|
28
|
+
*/
|
|
29
|
+
function writePackage(pkg, outputDir, overwrite, copySourceFiles, sourceDir) {
|
|
30
|
+
const pkgDir = path.join(outputDir, 'packages', pkg.name);
|
|
31
|
+
// Check if package already exists
|
|
32
|
+
if (fs.existsSync(pkgDir) && !overwrite) {
|
|
33
|
+
throw new Error(`Package directory already exists: ${pkgDir}. Use --overwrite to replace.`);
|
|
34
|
+
}
|
|
35
|
+
// Create package directory structure
|
|
36
|
+
fs.mkdirSync(pkgDir, { recursive: true });
|
|
37
|
+
fs.mkdirSync(path.join(pkgDir, 'deploy'), { recursive: true });
|
|
38
|
+
fs.mkdirSync(path.join(pkgDir, 'revert'), { recursive: true });
|
|
39
|
+
fs.mkdirSync(path.join(pkgDir, 'verify'), { recursive: true });
|
|
40
|
+
// Write plan file
|
|
41
|
+
fs.writeFileSync(path.join(pkgDir, 'pgpm.plan'), pkg.planContent);
|
|
42
|
+
// Write control file
|
|
43
|
+
fs.writeFileSync(path.join(pkgDir, `${pkg.name}.control`), pkg.controlContent);
|
|
44
|
+
// Copy SQL files if requested
|
|
45
|
+
if (copySourceFiles && sourceDir) {
|
|
46
|
+
for (const change of pkg.changes) {
|
|
47
|
+
copyChangeFiles(change.name, sourceDir, pkgDir);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Copy deploy/revert/verify SQL files for a change
|
|
53
|
+
*/
|
|
54
|
+
function copyChangeFiles(changeName, sourceDir, targetDir) {
|
|
55
|
+
const types = ['deploy', 'revert', 'verify'];
|
|
56
|
+
for (const type of types) {
|
|
57
|
+
const sourceFile = path.join(sourceDir, type, `${changeName}.sql`);
|
|
58
|
+
const targetFile = path.join(targetDir, type, `${changeName}.sql`);
|
|
59
|
+
if (fs.existsSync(sourceFile)) {
|
|
60
|
+
// Create target directory if needed
|
|
61
|
+
const targetSubDir = path.dirname(targetFile);
|
|
62
|
+
fs.mkdirSync(targetSubDir, { recursive: true });
|
|
63
|
+
// Copy file
|
|
64
|
+
fs.copyFileSync(sourceFile, targetFile);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Generate a dry-run report of what would be created
|
|
70
|
+
*/
|
|
71
|
+
export function generateDryRunReport(result) {
|
|
72
|
+
const lines = [];
|
|
73
|
+
lines.push('=== PGPM Slice Dry Run Report ===\n');
|
|
74
|
+
// Statistics
|
|
75
|
+
lines.push('Statistics:');
|
|
76
|
+
lines.push(` Total changes: ${result.stats.totalChanges}`);
|
|
77
|
+
lines.push(` Packages to create: ${result.stats.packagesCreated}`);
|
|
78
|
+
lines.push(` Internal edges: ${result.stats.internalEdges}`);
|
|
79
|
+
lines.push(` Cross-package edges: ${result.stats.crossPackageEdges}`);
|
|
80
|
+
lines.push(` Cross-package ratio: ${(result.stats.crossPackageRatio * 100).toFixed(1)}%`);
|
|
81
|
+
lines.push('');
|
|
82
|
+
// Warnings
|
|
83
|
+
if (result.warnings.length > 0) {
|
|
84
|
+
lines.push('Warnings:');
|
|
85
|
+
for (const warning of result.warnings) {
|
|
86
|
+
lines.push(` [${warning.type}] ${warning.message}`);
|
|
87
|
+
if (warning.suggestedAction) {
|
|
88
|
+
lines.push(` Suggestion: ${warning.suggestedAction}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
lines.push('');
|
|
92
|
+
}
|
|
93
|
+
// Deploy order
|
|
94
|
+
lines.push('Deploy Order:');
|
|
95
|
+
for (let i = 0; i < result.workspace.deployOrder.length; i++) {
|
|
96
|
+
const pkg = result.workspace.deployOrder[i];
|
|
97
|
+
const deps = result.workspace.dependencies[pkg] || [];
|
|
98
|
+
const depStr = deps.length > 0 ? ` (depends on: ${deps.join(', ')})` : '';
|
|
99
|
+
lines.push(` ${i + 1}. ${pkg}${depStr}`);
|
|
100
|
+
}
|
|
101
|
+
lines.push('');
|
|
102
|
+
// Package details
|
|
103
|
+
lines.push('Packages:');
|
|
104
|
+
for (const pkg of result.packages) {
|
|
105
|
+
lines.push(`\n ${pkg.name}/`);
|
|
106
|
+
lines.push(` Changes: ${pkg.changes.length}`);
|
|
107
|
+
lines.push(` Dependencies: ${pkg.packageDependencies.join(', ') || 'none'}`);
|
|
108
|
+
lines.push(' Contents:');
|
|
109
|
+
for (const change of pkg.changes.slice(0, 5)) {
|
|
110
|
+
lines.push(` - ${change.name}`);
|
|
111
|
+
}
|
|
112
|
+
if (pkg.changes.length > 5) {
|
|
113
|
+
lines.push(` ... and ${pkg.changes.length - 5} more`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return lines.join('\n');
|
|
117
|
+
}
|