@pgpmjs/core 3.0.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.
Files changed (140) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +99 -0
  3. package/core/boilerplate-scanner.d.ts +41 -0
  4. package/core/boilerplate-scanner.js +106 -0
  5. package/core/boilerplate-types.d.ts +52 -0
  6. package/core/boilerplate-types.js +6 -0
  7. package/core/class/pgpm.d.ts +150 -0
  8. package/core/class/pgpm.js +1470 -0
  9. package/core/template-scaffold.d.ts +29 -0
  10. package/core/template-scaffold.js +168 -0
  11. package/esm/core/boilerplate-scanner.js +96 -0
  12. package/esm/core/boilerplate-types.js +5 -0
  13. package/esm/core/class/pgpm.js +1430 -0
  14. package/esm/core/template-scaffold.js +161 -0
  15. package/esm/export/export-meta.js +240 -0
  16. package/esm/export/export-migrations.js +180 -0
  17. package/esm/extensions/extensions.js +31 -0
  18. package/esm/files/extension/index.js +3 -0
  19. package/esm/files/extension/reader.js +79 -0
  20. package/esm/files/extension/writer.js +63 -0
  21. package/esm/files/index.js +6 -0
  22. package/esm/files/plan/generator.js +49 -0
  23. package/esm/files/plan/index.js +5 -0
  24. package/esm/files/plan/parser.js +296 -0
  25. package/esm/files/plan/validators.js +181 -0
  26. package/esm/files/plan/writer.js +114 -0
  27. package/esm/files/sql/index.js +1 -0
  28. package/esm/files/sql/writer.js +107 -0
  29. package/esm/files/sql-scripts/index.js +2 -0
  30. package/esm/files/sql-scripts/reader.js +19 -0
  31. package/esm/files/types/index.js +1 -0
  32. package/esm/files/types/package.js +1 -0
  33. package/esm/index.js +21 -0
  34. package/esm/init/client.js +144 -0
  35. package/esm/init/sql/bootstrap-roles.sql +55 -0
  36. package/esm/init/sql/bootstrap-test-roles.sql +72 -0
  37. package/esm/migrate/clean.js +23 -0
  38. package/esm/migrate/client.js +551 -0
  39. package/esm/migrate/index.js +5 -0
  40. package/esm/migrate/sql/procedures.sql +258 -0
  41. package/esm/migrate/sql/schema.sql +37 -0
  42. package/esm/migrate/types.js +1 -0
  43. package/esm/migrate/utils/event-logger.js +28 -0
  44. package/esm/migrate/utils/hash.js +27 -0
  45. package/esm/migrate/utils/transaction.js +125 -0
  46. package/esm/modules/modules.js +49 -0
  47. package/esm/packaging/package.js +96 -0
  48. package/esm/packaging/transform.js +70 -0
  49. package/esm/projects/deploy.js +123 -0
  50. package/esm/projects/revert.js +75 -0
  51. package/esm/projects/verify.js +61 -0
  52. package/esm/resolution/deps.js +526 -0
  53. package/esm/resolution/resolve.js +101 -0
  54. package/esm/utils/debug.js +147 -0
  55. package/esm/utils/target-utils.js +37 -0
  56. package/esm/workspace/paths.js +43 -0
  57. package/esm/workspace/utils.js +31 -0
  58. package/export/export-meta.d.ts +8 -0
  59. package/export/export-meta.js +244 -0
  60. package/export/export-migrations.d.ts +17 -0
  61. package/export/export-migrations.js +187 -0
  62. package/extensions/extensions.d.ts +5 -0
  63. package/extensions/extensions.js +35 -0
  64. package/files/extension/index.d.ts +2 -0
  65. package/files/extension/index.js +19 -0
  66. package/files/extension/reader.d.ts +24 -0
  67. package/files/extension/reader.js +86 -0
  68. package/files/extension/writer.d.ts +39 -0
  69. package/files/extension/writer.js +70 -0
  70. package/files/index.d.ts +5 -0
  71. package/files/index.js +22 -0
  72. package/files/plan/generator.d.ts +22 -0
  73. package/files/plan/generator.js +57 -0
  74. package/files/plan/index.d.ts +4 -0
  75. package/files/plan/index.js +21 -0
  76. package/files/plan/parser.d.ts +27 -0
  77. package/files/plan/parser.js +303 -0
  78. package/files/plan/validators.d.ts +52 -0
  79. package/files/plan/validators.js +187 -0
  80. package/files/plan/writer.d.ts +27 -0
  81. package/files/plan/writer.js +124 -0
  82. package/files/sql/index.d.ts +1 -0
  83. package/files/sql/index.js +17 -0
  84. package/files/sql/writer.d.ts +12 -0
  85. package/files/sql/writer.js +114 -0
  86. package/files/sql-scripts/index.d.ts +1 -0
  87. package/files/sql-scripts/index.js +18 -0
  88. package/files/sql-scripts/reader.d.ts +8 -0
  89. package/files/sql-scripts/reader.js +23 -0
  90. package/files/types/index.d.ts +46 -0
  91. package/files/types/index.js +17 -0
  92. package/files/types/package.d.ts +20 -0
  93. package/files/types/package.js +2 -0
  94. package/index.d.ts +21 -0
  95. package/index.js +45 -0
  96. package/init/client.d.ts +26 -0
  97. package/init/client.js +148 -0
  98. package/init/sql/bootstrap-roles.sql +55 -0
  99. package/init/sql/bootstrap-test-roles.sql +72 -0
  100. package/migrate/clean.d.ts +1 -0
  101. package/migrate/clean.js +27 -0
  102. package/migrate/client.d.ts +80 -0
  103. package/migrate/client.js +555 -0
  104. package/migrate/index.d.ts +5 -0
  105. package/migrate/index.js +21 -0
  106. package/migrate/sql/procedures.sql +258 -0
  107. package/migrate/sql/schema.sql +37 -0
  108. package/migrate/types.d.ts +67 -0
  109. package/migrate/types.js +2 -0
  110. package/migrate/utils/event-logger.d.ts +13 -0
  111. package/migrate/utils/event-logger.js +32 -0
  112. package/migrate/utils/hash.d.ts +12 -0
  113. package/migrate/utils/hash.js +32 -0
  114. package/migrate/utils/transaction.d.ts +27 -0
  115. package/migrate/utils/transaction.js +129 -0
  116. package/modules/modules.d.ts +31 -0
  117. package/modules/modules.js +56 -0
  118. package/package.json +70 -0
  119. package/packaging/package.d.ts +19 -0
  120. package/packaging/package.js +102 -0
  121. package/packaging/transform.d.ts +22 -0
  122. package/packaging/transform.js +75 -0
  123. package/projects/deploy.d.ts +8 -0
  124. package/projects/deploy.js +160 -0
  125. package/projects/revert.d.ts +15 -0
  126. package/projects/revert.js +112 -0
  127. package/projects/verify.d.ts +8 -0
  128. package/projects/verify.js +98 -0
  129. package/resolution/deps.d.ts +57 -0
  130. package/resolution/deps.js +531 -0
  131. package/resolution/resolve.d.ts +37 -0
  132. package/resolution/resolve.js +107 -0
  133. package/utils/debug.d.ts +21 -0
  134. package/utils/debug.js +153 -0
  135. package/utils/target-utils.d.ts +5 -0
  136. package/utils/target-utils.js +40 -0
  137. package/workspace/paths.d.ts +14 -0
  138. package/workspace/paths.js +50 -0
  139. package/workspace/utils.d.ts +8 -0
  140. package/workspace/utils.js +36 -0
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
4
+ Copyright (c) 2025 Constructive <developers@constructive.io>
5
+ Copyright (c) 2020-present, Interweb, Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # @launchql/core
2
+
3
+ <p align="center" width="100%">
4
+ <img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
5
+ </p>
6
+
7
+ <p align="center" width="100%">
8
+ <a href="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml">
9
+ <img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
10
+ </a>
11
+ <a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
12
+ <a href="https://www.npmjs.com/package/@launchql/core"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=packages%2Fcore%2Fpackage.json"/></a>
13
+ </p>
14
+
15
+ ## Overview
16
+
17
+ LaunchQL Core is the main package for LaunchQL, providing tools for database migrations, package management, and package scaffolding. It includes functionality for:
18
+
19
+ - Managing PostgreSQL extensions and modules
20
+ - Deploying, reverting, and verifying migrations
21
+ - Parsing and generating migration plans
22
+ - Reading and writing SQL scripts
23
+ - Resolving dependencies between migrations
24
+
25
+ ---
26
+
27
+ ## Education and Tutorials
28
+
29
+ 1. 🚀 [Quickstart: Getting Up and Running](https://constructive.io/learn/quickstart)
30
+ Get started with modular databases in minutes. Install prerequisites and deploy your first module.
31
+
32
+ 2. 📦 [Modular PostgreSQL Development with Database Packages](https://constructive.io/learn/modular-postgres)
33
+ Learn to organize PostgreSQL projects with pgpm workspaces and reusable database modules.
34
+
35
+ 3. ✏️ [Authoring Database Changes](https://constructive.io/learn/authoring-database-changes)
36
+ Master the workflow for adding, organizing, and managing database changes with pgpm.
37
+
38
+ 4. 🧪 [End-to-End PostgreSQL Testing with TypeScript](https://constructive.io/learn/e2e-postgres-testing)
39
+ Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.
40
+
41
+ 5. ⚡ [Supabase Testing](https://constructive.io/learn/supabase)
42
+ Use TypeScript-first tools to test Supabase projects with realistic RLS, policies, and auth contexts.
43
+
44
+ 6. 💧 [Drizzle ORM Testing](https://constructive.io/learn/drizzle-testing)
45
+ Run full-stack tests with Drizzle ORM, including database setup, teardown, and RLS enforcement.
46
+
47
+ 7. 🔧 [Troubleshooting](https://constructive.io/learn/troubleshooting)
48
+ Common issues and solutions for pgpm, PostgreSQL, and testing.
49
+
50
+ ## Related Constructive Tooling
51
+
52
+ ### 🧪 Testing
53
+
54
+ * [pgsql-test](https://github.com/constructive-io/constructive/tree/main/packages/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
55
+ * [supabase-test](https://github.com/constructive-io/constructive/tree/main/packages/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
56
+ * [graphile-test](https://github.com/constructive-io/constructive/tree/main/packages/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
57
+ * [pg-query-context](https://github.com/constructive-io/constructive/tree/main/packages/pg-query-context): **🔒 Session context injection** to add session-local context (e.g., `SET LOCAL`) into queries—ideal for setting `role`, `jwt.claims`, and other session settings.
58
+
59
+ ### 🧠 Parsing & AST
60
+
61
+ * [pgsql-parser](https://www.npmjs.com/package/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
62
+ * [libpg-query-node](https://www.npmjs.com/package/libpg-query): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
63
+ * [pg-proto-parser](https://www.npmjs.com/package/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
64
+ * [@pgsql/enums](https://www.npmjs.com/package/@pgsql/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic.
65
+ * [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
66
+ * [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
67
+ * [pg-ast](https://www.npmjs.com/package/pg-ast): **🔍 Low-level AST tools** and transformations for Postgres query structures.
68
+
69
+ ### 🚀 API & Dev Tools
70
+
71
+ * [launchql/server](https://github.com/constructive-io/constructive/tree/main/packages/server): **⚡ Express-based API server** powered by PostGraphile to expose a secure, scalable GraphQL API over your Postgres database.
72
+ * [launchql/explorer](https://github.com/constructive-io/constructive/tree/main/packages/explorer): **🔎 Visual API explorer** with GraphiQL for browsing across all databases and schemas—useful for debugging, documentation, and API prototyping.
73
+
74
+ ### 🔁 Streaming & Uploads
75
+
76
+ * [launchql/s3-streamer](https://github.com/constructive-io/constructive/tree/main/packages/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation.
77
+ * [launchql/etag-hash](https://github.com/constructive-io/constructive/tree/main/packages/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
78
+ * [launchql/etag-stream](https://github.com/constructive-io/constructive/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
79
+ * [launchql/uuid-hash](https://github.com/constructive-io/constructive/tree/main/packages/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
80
+ * [launchql/uuid-stream](https://github.com/constructive-io/constructive/tree/main/packages/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
81
+ * [launchql/upload-names](https://github.com/constructive-io/constructive/tree/main/packages/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads.
82
+
83
+ ### 🧰 CLI & Codegen
84
+
85
+ * [pgpm](https://github.com/constructive-io/constructive/tree/main/packages/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
86
+ * [@launchql/cli](https://github.com/constructive-io/constructive/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing LaunchQL projects—supports database scaffolding, migrations, seeding, code generation, and automation.
87
+ * [constructive-io/constructive-gen](https://github.com/constructive-io/constructive/tree/main/packages/launchql-gen): **✨ Auto-generated GraphQL** mutations and queries dynamically built from introspected schema data.
88
+ * [@launchql/query-builder](https://github.com/constructive-io/constructive/tree/main/packages/query-builder): **🏗️ SQL constructor** providing a robust TypeScript-based query builder for dynamic generation of `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and stored procedure calls—supports advanced SQL features like `JOIN`, `GROUP BY`, and schema-qualified queries.
89
+ * [@launchql/query](https://github.com/constructive-io/constructive/tree/main/packages/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries.
90
+
91
+ ## Credits
92
+
93
+ **🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**
94
+
95
+ ## Disclaimer
96
+
97
+ AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
98
+
99
+ No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
@@ -0,0 +1,41 @@
1
+ import { BoilerplateConfig, BoilerplatesRootConfig, ScannedBoilerplate } from './boilerplate-types';
2
+ /**
3
+ * Read the root `.boilerplates.json` configuration from a template repository.
4
+ * This file specifies the default directory containing boilerplate templates.
5
+ *
6
+ * @param templateDir - The root directory of the template repository
7
+ * @returns The root config or null if not found
8
+ */
9
+ export declare function readBoilerplatesConfig(templateDir: string): BoilerplatesRootConfig | null;
10
+ /**
11
+ * Read the `.boilerplate.json` configuration from a boilerplate directory.
12
+ * This file specifies the boilerplate type and questions.
13
+ *
14
+ * @param boilerplatePath - The path to the boilerplate directory
15
+ * @returns The boilerplate config or null if not found
16
+ */
17
+ export declare function readBoilerplateConfig(boilerplatePath: string): BoilerplateConfig | null;
18
+ /**
19
+ * Scan a base directory for boilerplate templates.
20
+ * Each subdirectory with a `.boilerplate.json` file is considered a boilerplate.
21
+ *
22
+ * @param baseDir - The directory to scan (e.g., "default/")
23
+ * @returns Array of scanned boilerplates with their configurations
24
+ */
25
+ export declare function scanBoilerplates(baseDir: string): ScannedBoilerplate[];
26
+ /**
27
+ * Find a boilerplate by type within a scanned list.
28
+ *
29
+ * @param boilerplates - Array of scanned boilerplates
30
+ * @param type - The type to find ('workspace' or 'module')
31
+ * @returns The matching boilerplate or undefined
32
+ */
33
+ export declare function findBoilerplateByType(boilerplates: ScannedBoilerplate[], type: 'workspace' | 'module'): ScannedBoilerplate | undefined;
34
+ /**
35
+ * Resolve the base directory for boilerplates in a template repository.
36
+ * Uses `.boilerplates.json` if present, otherwise returns empty string.
37
+ *
38
+ * @param templateDir - The root directory of the template repository
39
+ * @returns The resolved base directory path
40
+ */
41
+ export declare function resolveBoilerplateBaseDir(templateDir: string): string;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.readBoilerplatesConfig = readBoilerplatesConfig;
7
+ exports.readBoilerplateConfig = readBoilerplateConfig;
8
+ exports.scanBoilerplates = scanBoilerplates;
9
+ exports.findBoilerplateByType = findBoilerplateByType;
10
+ exports.resolveBoilerplateBaseDir = resolveBoilerplateBaseDir;
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const path_1 = __importDefault(require("path"));
13
+ /**
14
+ * Read the root `.boilerplates.json` configuration from a template repository.
15
+ * This file specifies the default directory containing boilerplate templates.
16
+ *
17
+ * @param templateDir - The root directory of the template repository
18
+ * @returns The root config or null if not found
19
+ */
20
+ function readBoilerplatesConfig(templateDir) {
21
+ const configPath = path_1.default.join(templateDir, '.boilerplates.json');
22
+ if (fs_1.default.existsSync(configPath)) {
23
+ try {
24
+ const content = fs_1.default.readFileSync(configPath, 'utf-8');
25
+ return JSON.parse(content);
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ return null;
32
+ }
33
+ /**
34
+ * Read the `.boilerplate.json` configuration from a boilerplate directory.
35
+ * This file specifies the boilerplate type and questions.
36
+ *
37
+ * @param boilerplatePath - The path to the boilerplate directory
38
+ * @returns The boilerplate config or null if not found
39
+ */
40
+ function readBoilerplateConfig(boilerplatePath) {
41
+ const jsonPath = path_1.default.join(boilerplatePath, '.boilerplate.json');
42
+ if (fs_1.default.existsSync(jsonPath)) {
43
+ try {
44
+ const content = fs_1.default.readFileSync(jsonPath, 'utf-8');
45
+ return JSON.parse(content);
46
+ }
47
+ catch {
48
+ return null;
49
+ }
50
+ }
51
+ return null;
52
+ }
53
+ /**
54
+ * Scan a base directory for boilerplate templates.
55
+ * Each subdirectory with a `.boilerplate.json` file is considered a boilerplate.
56
+ *
57
+ * @param baseDir - The directory to scan (e.g., "default/")
58
+ * @returns Array of scanned boilerplates with their configurations
59
+ */
60
+ function scanBoilerplates(baseDir) {
61
+ const boilerplates = [];
62
+ if (!fs_1.default.existsSync(baseDir)) {
63
+ return boilerplates;
64
+ }
65
+ const entries = fs_1.default.readdirSync(baseDir, { withFileTypes: true });
66
+ for (const entry of entries) {
67
+ if (!entry.isDirectory()) {
68
+ continue;
69
+ }
70
+ const boilerplatePath = path_1.default.join(baseDir, entry.name);
71
+ const config = readBoilerplateConfig(boilerplatePath);
72
+ if (config) {
73
+ boilerplates.push({
74
+ name: entry.name,
75
+ path: boilerplatePath,
76
+ type: config.type ?? 'module',
77
+ questions: config.questions
78
+ });
79
+ }
80
+ }
81
+ return boilerplates;
82
+ }
83
+ /**
84
+ * Find a boilerplate by type within a scanned list.
85
+ *
86
+ * @param boilerplates - Array of scanned boilerplates
87
+ * @param type - The type to find ('workspace' or 'module')
88
+ * @returns The matching boilerplate or undefined
89
+ */
90
+ function findBoilerplateByType(boilerplates, type) {
91
+ return boilerplates.find((bp) => bp.type === type);
92
+ }
93
+ /**
94
+ * Resolve the base directory for boilerplates in a template repository.
95
+ * Uses `.boilerplates.json` if present, otherwise returns empty string.
96
+ *
97
+ * @param templateDir - The root directory of the template repository
98
+ * @returns The resolved base directory path
99
+ */
100
+ function resolveBoilerplateBaseDir(templateDir) {
101
+ const rootConfig = readBoilerplatesConfig(templateDir);
102
+ if (rootConfig?.dir) {
103
+ return path_1.default.join(templateDir, rootConfig.dir);
104
+ }
105
+ return templateDir;
106
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Boilerplate metadata types for the new metadata-driven resolution system.
3
+ * These types support the `.boilerplate.json` and `.boilerplates.json` configuration files.
4
+ */
5
+ /**
6
+ * A question to prompt the user during template scaffolding.
7
+ */
8
+ export interface BoilerplateQuestion {
9
+ /** The placeholder name in templates (e.g., "____fullName____") */
10
+ name: string;
11
+ /** The prompt message shown to the user */
12
+ message: string;
13
+ /** Whether the question is required */
14
+ required?: boolean;
15
+ /** The type of input: text, list (single select), or checkbox (multi select) */
16
+ type?: 'text' | 'list' | 'checkbox';
17
+ /** Options for list or checkbox types */
18
+ options?: string[];
19
+ /** Source to derive default value from (e.g., "git.user.name", "npm.whoami") */
20
+ defaultFrom?: string;
21
+ }
22
+ /**
23
+ * Configuration for a single boilerplate template.
24
+ * Stored in `.boilerplate.json` within each template directory.
25
+ */
26
+ export interface BoilerplateConfig {
27
+ /** The type of boilerplate: workspace or module */
28
+ type: 'workspace' | 'module';
29
+ /** Questions to prompt the user during scaffolding */
30
+ questions?: BoilerplateQuestion[];
31
+ }
32
+ /**
33
+ * Root configuration for a boilerplates repository.
34
+ * Stored in `.boilerplates.json` at the repository root.
35
+ */
36
+ export interface BoilerplatesRootConfig {
37
+ /** The default directory containing boilerplate templates (e.g., "default") */
38
+ dir: string;
39
+ }
40
+ /**
41
+ * A scanned boilerplate with its resolved path and configuration.
42
+ */
43
+ export interface ScannedBoilerplate {
44
+ /** The boilerplate folder name (e.g., "module", "workspace") */
45
+ name: string;
46
+ /** The full path to the boilerplate directory */
47
+ path: string;
48
+ /** The type of boilerplate */
49
+ type: 'workspace' | 'module';
50
+ /** Questions from the boilerplate config */
51
+ questions?: BoilerplateQuestion[];
52
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Boilerplate metadata types for the new metadata-driven resolution system.
4
+ * These types support the `.boilerplate.json` and `.boilerplates.json` configuration files.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,150 @@
1
+ import { PgpmOptions, PgpmWorkspaceConfig } from '@pgpmjs/types';
2
+ import { PgConfig } from 'pg-env';
3
+ import { ExtensionInfo } from '../../files';
4
+ import { ModuleMap } from '../../modules/modules';
5
+ import { PackageAnalysisResult, RenameOptions } from '../../files/types';
6
+ export declare enum PackageContext {
7
+ Outside = "outside",
8
+ Workspace = "workspace-root",
9
+ Module = "module",
10
+ ModuleInsideWorkspace = "module-in-workspace"
11
+ }
12
+ export interface InitModuleOptions {
13
+ name: string;
14
+ description: string;
15
+ author: string;
16
+ extensions: string[];
17
+ branch?: string;
18
+ templateRepo?: string;
19
+ templatePath?: string;
20
+ cacheTtlMs?: number;
21
+ noTty?: boolean;
22
+ toolName?: string;
23
+ answers?: Record<string, any>;
24
+ }
25
+ export declare class PgpmPackage {
26
+ cwd: string;
27
+ workspacePath?: string;
28
+ modulePath?: string;
29
+ config?: PgpmWorkspaceConfig;
30
+ allowedDirs: string[];
31
+ allowedParentDirs: string[];
32
+ private _moduleMap?;
33
+ private _moduleInfo?;
34
+ constructor(cwd?: string);
35
+ resetCwd(cwd: string): void;
36
+ private resolveSqitchPath;
37
+ private loadConfigSync;
38
+ private loadAllowedDirs;
39
+ private loadAllowedParentDirs;
40
+ isInsideAllowedDirs(cwd: string): boolean;
41
+ isParentOfAllowedDirs(cwd: string): boolean;
42
+ private createModuleDirectory;
43
+ ensureModule(): void;
44
+ ensureWorkspace(): void;
45
+ getContext(): PackageContext;
46
+ isInWorkspace(): boolean;
47
+ isInModule(): boolean;
48
+ getWorkspacePath(): string | undefined;
49
+ getModulePath(): string | undefined;
50
+ clearCache(): void;
51
+ getModules(): Promise<PgpmPackage[]>;
52
+ /**
53
+ * List all modules by parsing .control files in the workspace directory.
54
+ * Handles naming collisions by preferring the shortest path.
55
+ */
56
+ listModules(): ModuleMap;
57
+ getModuleMap(): ModuleMap;
58
+ getAvailableModules(): string[];
59
+ getModuleProject(name: string): PgpmPackage;
60
+ getModuleInfo(): ExtensionInfo;
61
+ getModuleName(): string;
62
+ getRequiredModules(): string[];
63
+ setModuleDependencies(modules: string[]): void;
64
+ private validateModuleDependencies;
65
+ private initModuleSqitch;
66
+ initModule(options: InitModuleOptions): Promise<void>;
67
+ getLatestChange(moduleName: string): string;
68
+ getLatestChangeAndVersion(moduleName: string): {
69
+ change: string;
70
+ version: string;
71
+ };
72
+ getModuleExtensions(): {
73
+ resolved: string[];
74
+ external: string[];
75
+ };
76
+ getModuleDependencies(moduleName: string): {
77
+ native: string[];
78
+ modules: string[];
79
+ };
80
+ getModuleDependencyChanges(moduleName: string): {
81
+ native: string[];
82
+ modules: {
83
+ name: string;
84
+ latest: string;
85
+ version: string;
86
+ }[];
87
+ };
88
+ getModulePlan(): string;
89
+ getModuleControlFile(): string;
90
+ getModuleMakefile(): string;
91
+ getModuleSQL(): string;
92
+ generateModulePlan(options: {
93
+ uri?: string;
94
+ includePackages?: boolean;
95
+ includeTags?: boolean;
96
+ }): string;
97
+ writeModulePlan(options: {
98
+ uri?: string;
99
+ includePackages?: boolean;
100
+ includeTags?: boolean;
101
+ }): void;
102
+ /**
103
+ * Add a tag to the current module's plan file
104
+ */
105
+ addTag(tagName: string, changeName?: string, comment?: string): void;
106
+ /**
107
+ * Add a change to the current module's plan file and create SQL files
108
+ */
109
+ addChange(changeName: string, dependencies?: string[], comment?: string): void;
110
+ /**
111
+ * Add change to the current module (internal helper)
112
+ */
113
+ private addChangeToModule;
114
+ /**
115
+ * Create deploy/revert/verify SQL files for a change
116
+ */
117
+ private createSqlFiles;
118
+ publishToDist(distFolder?: string): void;
119
+ /**
120
+ * Installs an extension npm package into the local skitch extensions directory,
121
+ * and automatically adds it to the current module’s package.json dependencies.
122
+ */
123
+ installModules(...pkgstrs: string[]): Promise<void>;
124
+ /**
125
+ * Get the set of modules that have been deployed to the database
126
+ */
127
+ private getDeployedModules;
128
+ resolveWorkspaceExtensionDependencies(opts?: {
129
+ filterDeployed?: boolean;
130
+ pgConfig?: PgConfig;
131
+ }): Promise<{
132
+ resolved: string[];
133
+ external: string[];
134
+ }>;
135
+ private parsePackageTarget;
136
+ deploy(opts: PgpmOptions, target?: string, recursive?: boolean): Promise<void>;
137
+ /**
138
+ * Reverts database changes for modules. Unlike verify operations, revert operations
139
+ * modify database state and must ensure dependent modules are reverted before their
140
+ * dependencies to prevent database constraint violations.
141
+ */
142
+ revert(opts: PgpmOptions, target?: string, recursive?: boolean): Promise<void>;
143
+ verify(opts: PgpmOptions, target?: string, recursive?: boolean): Promise<void>;
144
+ removeFromPlan(toChange: string): Promise<void>;
145
+ analyzeModule(): PackageAnalysisResult;
146
+ renameModule(newName: string, opts?: RenameOptions): {
147
+ changed: string[];
148
+ warnings: string[];
149
+ };
150
+ }