@pgpmjs/types 2.11.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/LICENSE +23 -0
- package/README.md +89 -0
- package/error-factory.d.ts +59 -0
- package/error-factory.js +37 -0
- package/error.d.ts +7 -0
- package/error.js +22 -0
- package/esm/error-factory.js +33 -0
- package/esm/error.js +18 -0
- package/esm/index.js +5 -0
- package/esm/jobs.js +53 -0
- package/esm/pgpm.js +157 -0
- package/esm/update.js +3 -0
- package/index.d.ts +5 -0
- package/index.js +21 -0
- package/jobs.d.ts +198 -0
- package/jobs.js +56 -0
- package/package.json +49 -0
- package/pgpm.d.ts +233 -0
- package/pgpm.js +161 -0
- package/update.d.ts +10 -0
- package/update.js +6 -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,89 @@
|
|
|
1
|
+
# @launchql/types
|
|
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/types"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=packages%2Ftypes%2Fpackage.json"/></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Education and Tutorials
|
|
18
|
+
|
|
19
|
+
1. 🚀 [Quickstart: Getting Up and Running](https://constructive.io/learn/quickstart)
|
|
20
|
+
Get started with modular databases in minutes. Install prerequisites and deploy your first module.
|
|
21
|
+
|
|
22
|
+
2. 📦 [Modular PostgreSQL Development with Database Packages](https://constructive.io/learn/modular-postgres)
|
|
23
|
+
Learn to organize PostgreSQL projects with pgpm workspaces and reusable database modules.
|
|
24
|
+
|
|
25
|
+
3. ✏️ [Authoring Database Changes](https://constructive.io/learn/authoring-database-changes)
|
|
26
|
+
Master the workflow for adding, organizing, and managing database changes with pgpm.
|
|
27
|
+
|
|
28
|
+
4. 🧪 [End-to-End PostgreSQL Testing with TypeScript](https://constructive.io/learn/e2e-postgres-testing)
|
|
29
|
+
Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.
|
|
30
|
+
|
|
31
|
+
5. ⚡ [Supabase Testing](https://constructive.io/learn/supabase)
|
|
32
|
+
Use TypeScript-first tools to test Supabase projects with realistic RLS, policies, and auth contexts.
|
|
33
|
+
|
|
34
|
+
6. 💧 [Drizzle ORM Testing](https://constructive.io/learn/drizzle-testing)
|
|
35
|
+
Run full-stack tests with Drizzle ORM, including database setup, teardown, and RLS enforcement.
|
|
36
|
+
|
|
37
|
+
7. 🔧 [Troubleshooting](https://constructive.io/learn/troubleshooting)
|
|
38
|
+
Common issues and solutions for pgpm, PostgreSQL, and testing.
|
|
39
|
+
|
|
40
|
+
## Related Constructive Tooling
|
|
41
|
+
|
|
42
|
+
### 🧪 Testing
|
|
43
|
+
|
|
44
|
+
* [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.
|
|
45
|
+
* [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.
|
|
46
|
+
* [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.
|
|
47
|
+
* [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.
|
|
48
|
+
|
|
49
|
+
### 🧠 Parsing & AST
|
|
50
|
+
|
|
51
|
+
* [pgsql-parser](https://www.npmjs.com/package/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
|
|
52
|
+
* [libpg-query-node](https://www.npmjs.com/package/libpg-query): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
|
|
53
|
+
* [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.
|
|
54
|
+
* [@pgsql/enums](https://www.npmjs.com/package/@pgsql/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic.
|
|
55
|
+
* [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
|
|
56
|
+
* [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
|
|
57
|
+
* [pg-ast](https://www.npmjs.com/package/pg-ast): **🔍 Low-level AST tools** and transformations for Postgres query structures.
|
|
58
|
+
|
|
59
|
+
### 🚀 API & Dev Tools
|
|
60
|
+
|
|
61
|
+
* [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.
|
|
62
|
+
* [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.
|
|
63
|
+
|
|
64
|
+
### 🔁 Streaming & Uploads
|
|
65
|
+
|
|
66
|
+
* [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.
|
|
67
|
+
* [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.
|
|
68
|
+
* [launchql/etag-stream](https://github.com/constructive-io/constructive/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
|
|
69
|
+
* [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.
|
|
70
|
+
* [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.
|
|
71
|
+
* [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.
|
|
72
|
+
|
|
73
|
+
### 🧰 CLI & Codegen
|
|
74
|
+
|
|
75
|
+
* [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.
|
|
76
|
+
* [@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.
|
|
77
|
+
* [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.
|
|
78
|
+
* [@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.
|
|
79
|
+
* [@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.
|
|
80
|
+
|
|
81
|
+
## Credits
|
|
82
|
+
|
|
83
|
+
**🛠 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).**
|
|
84
|
+
|
|
85
|
+
## Disclaimer
|
|
86
|
+
|
|
87
|
+
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
|
|
88
|
+
|
|
89
|
+
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,59 @@
|
|
|
1
|
+
import { PgpmError } from './error';
|
|
2
|
+
type ErrorContext = Record<string, string | number | boolean>;
|
|
3
|
+
export declare const makeError: <T extends ErrorContext>(code: string, messageFn: (context: T) => string, httpCode?: number) => (context: T, overrideMessage?: string) => PgpmError;
|
|
4
|
+
export declare const errors: {
|
|
5
|
+
NOT_FOUND: (context: ErrorContext, overrideMessage?: string) => PgpmError;
|
|
6
|
+
MODULE_NOT_FOUND: (context: {
|
|
7
|
+
name: string;
|
|
8
|
+
}, overrideMessage?: string) => PgpmError;
|
|
9
|
+
NO_ACCOUNT_EXISTS: (context: ErrorContext, overrideMessage?: string) => PgpmError;
|
|
10
|
+
INTERNAL_FAILURE: (context: ErrorContext, overrideMessage?: string) => PgpmError;
|
|
11
|
+
CONTEXT_MISSING: (context: ErrorContext, overrideMessage?: string) => PgpmError;
|
|
12
|
+
NOT_IN_WORKSPACE: (context: ErrorContext, overrideMessage?: string) => PgpmError;
|
|
13
|
+
NOT_IN_WORKSPACE_MODULE: (context: ErrorContext, overrideMessage?: string) => PgpmError;
|
|
14
|
+
DEPLOYMENT_FAILED: (context: {
|
|
15
|
+
type: "Deployment" | "Revert" | "Verify";
|
|
16
|
+
module: string;
|
|
17
|
+
}, overrideMessage?: string) => PgpmError;
|
|
18
|
+
UNSUPPORTED_TYPE_HINT: (context: ErrorContext, overrideMessage?: string) => PgpmError;
|
|
19
|
+
BAD_FILE_NAME: (context: ErrorContext, overrideMessage?: string) => PgpmError;
|
|
20
|
+
UNKNOWN_COMMAND: (context: ErrorContext, overrideMessage?: string) => PgpmError;
|
|
21
|
+
CHANGE_NOT_FOUND: (context: {
|
|
22
|
+
change: string;
|
|
23
|
+
plan?: string;
|
|
24
|
+
}, overrideMessage?: string) => PgpmError;
|
|
25
|
+
TAG_NOT_FOUND: (context: {
|
|
26
|
+
tag: string;
|
|
27
|
+
project?: string;
|
|
28
|
+
}, overrideMessage?: string) => PgpmError;
|
|
29
|
+
PATH_NOT_FOUND: (context: {
|
|
30
|
+
path: string;
|
|
31
|
+
type: "module" | "workspace" | "file";
|
|
32
|
+
}, overrideMessage?: string) => PgpmError;
|
|
33
|
+
OPERATION_FAILED: (context: {
|
|
34
|
+
operation: string;
|
|
35
|
+
target?: string;
|
|
36
|
+
reason?: string;
|
|
37
|
+
}, overrideMessage?: string) => PgpmError;
|
|
38
|
+
PLAN_PARSE_ERROR: (context: {
|
|
39
|
+
planPath: string;
|
|
40
|
+
errors: string;
|
|
41
|
+
}, overrideMessage?: string) => PgpmError;
|
|
42
|
+
CIRCULAR_DEPENDENCY: (context: {
|
|
43
|
+
module: string;
|
|
44
|
+
dependency: string;
|
|
45
|
+
}, overrideMessage?: string) => PgpmError;
|
|
46
|
+
INVALID_NAME: (context: {
|
|
47
|
+
name: string;
|
|
48
|
+
type: "tag" | "change" | "module";
|
|
49
|
+
rules?: string;
|
|
50
|
+
}, overrideMessage?: string) => PgpmError;
|
|
51
|
+
WORKSPACE_OPERATION_ERROR: (context: {
|
|
52
|
+
operation: string;
|
|
53
|
+
}, overrideMessage?: string) => PgpmError;
|
|
54
|
+
FILE_NOT_FOUND: (context: {
|
|
55
|
+
filePath: string;
|
|
56
|
+
type?: string;
|
|
57
|
+
}, overrideMessage?: string) => PgpmError;
|
|
58
|
+
};
|
|
59
|
+
export {};
|
package/error-factory.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errors = exports.makeError = void 0;
|
|
4
|
+
const error_1 = require("./error");
|
|
5
|
+
const makeError = (code, messageFn, httpCode) => {
|
|
6
|
+
return (context, overrideMessage) => {
|
|
7
|
+
const message = overrideMessage || messageFn(context);
|
|
8
|
+
return new error_1.PgpmError(code, message, context, httpCode);
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
exports.makeError = makeError;
|
|
12
|
+
exports.errors = {
|
|
13
|
+
NOT_FOUND: (0, exports.makeError)('NOT_FOUND', () => `Not found.`, 404),
|
|
14
|
+
MODULE_NOT_FOUND: (0, exports.makeError)('MODULE_NOT_FOUND', ({ name }) => `Module "${name}" not found in modules list.`, 404),
|
|
15
|
+
NO_ACCOUNT_EXISTS: (0, exports.makeError)('NO_ACCOUNT_EXISTS', ({ userId }) => `No account exists for user: ${userId}`, 404),
|
|
16
|
+
INTERNAL_FAILURE: (0, exports.makeError)('INTERNAL_FAILURE', ({ details }) => `Something went wrong: ${details}`, 500),
|
|
17
|
+
CONTEXT_MISSING: (0, exports.makeError)('CONTEXT_MISSING', () => `Context is not initialized. Did you run setup()?`, 500),
|
|
18
|
+
NOT_IN_WORKSPACE: (0, exports.makeError)('NOT_IN_WORKSPACE', () => `You must be in a PGPM workspace. Initialize with "pgpm init workspace".`, 400),
|
|
19
|
+
NOT_IN_WORKSPACE_MODULE: (0, exports.makeError)('NOT_IN_WORKSPACE_MODULE', () => `Error: You must be inside one of the workspace packages.`, 400),
|
|
20
|
+
DEPLOYMENT_FAILED: (0, exports.makeError)('DEPLOYMENT_FAILED', ({ type, module }) => `${type} failed for module: ${module}`, 500),
|
|
21
|
+
UNSUPPORTED_TYPE_HINT: (0, exports.makeError)('UNSUPPORTED_TYPE_HINT', ({ typeHint }) => `Unsupported type hint: ${typeHint}`, 400),
|
|
22
|
+
BAD_FILE_NAME: (0, exports.makeError)('BAD_FILE_NAME', ({ name }) => `Invalid file name: ${name}`, 400),
|
|
23
|
+
UNKNOWN_COMMAND: (0, exports.makeError)('UNKNOWN_COMMAND', ({ cmd }) => `Unknown command: ${cmd}`, 400),
|
|
24
|
+
CHANGE_NOT_FOUND: (0, exports.makeError)('CHANGE_NOT_FOUND', ({ change, plan }) => `Change '${change}' not found in plan${plan ? ` file: ${plan}` : ''}`, 404),
|
|
25
|
+
TAG_NOT_FOUND: (0, exports.makeError)('TAG_NOT_FOUND', ({ tag, project }) => `Tag '${tag}' not found${project ? ` in project ${project}` : ' in plan'}`, 404),
|
|
26
|
+
PATH_NOT_FOUND: (0, exports.makeError)('PATH_NOT_FOUND', ({ path, type }) => `${type} path not found: ${path}`, 404),
|
|
27
|
+
OPERATION_FAILED: (0, exports.makeError)('OPERATION_FAILED', ({ operation, target, reason }) => `${operation} failed${target ? ` for ${target}` : ''}${reason ? `: ${reason}` : ''}`, 500),
|
|
28
|
+
PLAN_PARSE_ERROR: (0, exports.makeError)('PLAN_PARSE_ERROR', ({ planPath, errors }) => `Failed to parse plan file ${planPath}: ${errors}`, 400),
|
|
29
|
+
CIRCULAR_DEPENDENCY: (0, exports.makeError)('CIRCULAR_DEPENDENCY', ({ module, dependency }) => `Circular reference detected: ${module} → ${dependency}`, 400),
|
|
30
|
+
INVALID_NAME: (0, exports.makeError)('INVALID_NAME', ({ name, type, rules }) => `Invalid ${type} name: ${name}${rules ? `. ${rules}` : ''}`, 400),
|
|
31
|
+
WORKSPACE_OPERATION_ERROR: (0, exports.makeError)('WORKSPACE_OPERATION_ERROR', ({ operation }) => `Cannot perform non-recursive ${operation} on workspace. Use recursive=true or specify a target module.`, 400),
|
|
32
|
+
FILE_NOT_FOUND: (0, exports.makeError)('FILE_NOT_FOUND', ({ filePath, type }) => `${type ? `${type} file` : 'File'} not found: ${filePath}`, 404),
|
|
33
|
+
};
|
|
34
|
+
// throw errors.MODULE_NOT_FOUND({ name: 'auth' });
|
|
35
|
+
// throw errors.INTERNAL_FAILURE({ details: 'Could not connect to DB' });
|
|
36
|
+
// throw errors.UNKNOWN_COMMAND({ cmd: 'foo' }, 'Unsupported command "foo"');
|
|
37
|
+
// throw errors.CONTEXT_MISSING(();
|
package/error.d.ts
ADDED
package/error.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PgpmError = void 0;
|
|
4
|
+
class PgpmError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
context;
|
|
7
|
+
httpCode;
|
|
8
|
+
constructor(code, message, context, httpCode) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'PgpmError';
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.context = context;
|
|
13
|
+
this.httpCode = httpCode;
|
|
14
|
+
if (Error.captureStackTrace) {
|
|
15
|
+
Error.captureStackTrace(this, PgpmError);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
toString() {
|
|
19
|
+
return `[${this.code}] ${this.message}`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.PgpmError = PgpmError;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PgpmError } from './error';
|
|
2
|
+
export const makeError = (code, messageFn, httpCode) => {
|
|
3
|
+
return (context, overrideMessage) => {
|
|
4
|
+
const message = overrideMessage || messageFn(context);
|
|
5
|
+
return new PgpmError(code, message, context, httpCode);
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export const errors = {
|
|
9
|
+
NOT_FOUND: makeError('NOT_FOUND', () => `Not found.`, 404),
|
|
10
|
+
MODULE_NOT_FOUND: makeError('MODULE_NOT_FOUND', ({ name }) => `Module "${name}" not found in modules list.`, 404),
|
|
11
|
+
NO_ACCOUNT_EXISTS: makeError('NO_ACCOUNT_EXISTS', ({ userId }) => `No account exists for user: ${userId}`, 404),
|
|
12
|
+
INTERNAL_FAILURE: makeError('INTERNAL_FAILURE', ({ details }) => `Something went wrong: ${details}`, 500),
|
|
13
|
+
CONTEXT_MISSING: makeError('CONTEXT_MISSING', () => `Context is not initialized. Did you run setup()?`, 500),
|
|
14
|
+
NOT_IN_WORKSPACE: makeError('NOT_IN_WORKSPACE', () => `You must be in a PGPM workspace. Initialize with "pgpm init workspace".`, 400),
|
|
15
|
+
NOT_IN_WORKSPACE_MODULE: makeError('NOT_IN_WORKSPACE_MODULE', () => `Error: You must be inside one of the workspace packages.`, 400),
|
|
16
|
+
DEPLOYMENT_FAILED: makeError('DEPLOYMENT_FAILED', ({ type, module }) => `${type} failed for module: ${module}`, 500),
|
|
17
|
+
UNSUPPORTED_TYPE_HINT: makeError('UNSUPPORTED_TYPE_HINT', ({ typeHint }) => `Unsupported type hint: ${typeHint}`, 400),
|
|
18
|
+
BAD_FILE_NAME: makeError('BAD_FILE_NAME', ({ name }) => `Invalid file name: ${name}`, 400),
|
|
19
|
+
UNKNOWN_COMMAND: makeError('UNKNOWN_COMMAND', ({ cmd }) => `Unknown command: ${cmd}`, 400),
|
|
20
|
+
CHANGE_NOT_FOUND: makeError('CHANGE_NOT_FOUND', ({ change, plan }) => `Change '${change}' not found in plan${plan ? ` file: ${plan}` : ''}`, 404),
|
|
21
|
+
TAG_NOT_FOUND: makeError('TAG_NOT_FOUND', ({ tag, project }) => `Tag '${tag}' not found${project ? ` in project ${project}` : ' in plan'}`, 404),
|
|
22
|
+
PATH_NOT_FOUND: makeError('PATH_NOT_FOUND', ({ path, type }) => `${type} path not found: ${path}`, 404),
|
|
23
|
+
OPERATION_FAILED: makeError('OPERATION_FAILED', ({ operation, target, reason }) => `${operation} failed${target ? ` for ${target}` : ''}${reason ? `: ${reason}` : ''}`, 500),
|
|
24
|
+
PLAN_PARSE_ERROR: makeError('PLAN_PARSE_ERROR', ({ planPath, errors }) => `Failed to parse plan file ${planPath}: ${errors}`, 400),
|
|
25
|
+
CIRCULAR_DEPENDENCY: makeError('CIRCULAR_DEPENDENCY', ({ module, dependency }) => `Circular reference detected: ${module} → ${dependency}`, 400),
|
|
26
|
+
INVALID_NAME: makeError('INVALID_NAME', ({ name, type, rules }) => `Invalid ${type} name: ${name}${rules ? `. ${rules}` : ''}`, 400),
|
|
27
|
+
WORKSPACE_OPERATION_ERROR: makeError('WORKSPACE_OPERATION_ERROR', ({ operation }) => `Cannot perform non-recursive ${operation} on workspace. Use recursive=true or specify a target module.`, 400),
|
|
28
|
+
FILE_NOT_FOUND: makeError('FILE_NOT_FOUND', ({ filePath, type }) => `${type ? `${type} file` : 'File'} not found: ${filePath}`, 404),
|
|
29
|
+
};
|
|
30
|
+
// throw errors.MODULE_NOT_FOUND({ name: 'auth' });
|
|
31
|
+
// throw errors.INTERNAL_FAILURE({ details: 'Could not connect to DB' });
|
|
32
|
+
// throw errors.UNKNOWN_COMMAND({ cmd: 'foo' }, 'Unsupported command "foo"');
|
|
33
|
+
// throw errors.CONTEXT_MISSING(();
|
package/esm/error.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class PgpmError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
context;
|
|
4
|
+
httpCode;
|
|
5
|
+
constructor(code, message, context, httpCode) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'PgpmError';
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.context = context;
|
|
10
|
+
this.httpCode = httpCode;
|
|
11
|
+
if (Error.captureStackTrace) {
|
|
12
|
+
Error.captureStackTrace(this, PgpmError);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
toString() {
|
|
16
|
+
return `[${this.code}] ${this.message}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/esm/index.js
ADDED
package/esm/jobs.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default configuration values for job system
|
|
3
|
+
*/
|
|
4
|
+
export const jobsDefaults = {
|
|
5
|
+
pg: {
|
|
6
|
+
host: 'localhost',
|
|
7
|
+
port: 5432,
|
|
8
|
+
user: 'postgres',
|
|
9
|
+
password: 'password',
|
|
10
|
+
database: 'jobs'
|
|
11
|
+
},
|
|
12
|
+
schema: {
|
|
13
|
+
schema: 'app_jobs'
|
|
14
|
+
},
|
|
15
|
+
worker: {
|
|
16
|
+
host: 'localhost',
|
|
17
|
+
port: 5432,
|
|
18
|
+
user: 'postgres',
|
|
19
|
+
password: 'password',
|
|
20
|
+
database: 'jobs',
|
|
21
|
+
schema: 'app_jobs',
|
|
22
|
+
hostname: 'worker-0',
|
|
23
|
+
supportAny: true,
|
|
24
|
+
supported: [],
|
|
25
|
+
pollInterval: 1000,
|
|
26
|
+
gracefulShutdown: true
|
|
27
|
+
},
|
|
28
|
+
scheduler: {
|
|
29
|
+
host: 'localhost',
|
|
30
|
+
port: 5432,
|
|
31
|
+
user: 'postgres',
|
|
32
|
+
password: 'password',
|
|
33
|
+
database: 'jobs',
|
|
34
|
+
schema: 'app_jobs',
|
|
35
|
+
hostname: 'scheduler-0',
|
|
36
|
+
supportAny: true,
|
|
37
|
+
supported: [],
|
|
38
|
+
pollInterval: 1000,
|
|
39
|
+
gracefulShutdown: true
|
|
40
|
+
},
|
|
41
|
+
openFaas: {
|
|
42
|
+
gateway: {
|
|
43
|
+
gatewayUrl: 'http://gateway:8080',
|
|
44
|
+
callbackUrl: 'http://callback:12345',
|
|
45
|
+
callbackPort: 12345
|
|
46
|
+
},
|
|
47
|
+
server: {
|
|
48
|
+
schema: 'app_jobs',
|
|
49
|
+
port: 3000,
|
|
50
|
+
host: 'localhost'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
package/esm/pgpm.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration values for PGPM framework
|
|
4
|
+
*/
|
|
5
|
+
export const pgpmDefaults = {
|
|
6
|
+
db: {
|
|
7
|
+
rootDb: 'postgres',
|
|
8
|
+
prefix: 'db-',
|
|
9
|
+
extensions: [],
|
|
10
|
+
cwd: process.cwd(),
|
|
11
|
+
connection: {
|
|
12
|
+
user: 'app_user',
|
|
13
|
+
password: 'app_password',
|
|
14
|
+
// TODO: check if this is used vs. roles below...
|
|
15
|
+
role: 'anonymous'
|
|
16
|
+
},
|
|
17
|
+
roles: {
|
|
18
|
+
anonymous: 'anonymous',
|
|
19
|
+
authenticated: 'authenticated',
|
|
20
|
+
administrator: 'administrator',
|
|
21
|
+
default: 'anonymous'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
pg: {
|
|
25
|
+
host: 'localhost',
|
|
26
|
+
port: 5432,
|
|
27
|
+
user: 'postgres',
|
|
28
|
+
password: 'password',
|
|
29
|
+
database: 'postgres',
|
|
30
|
+
},
|
|
31
|
+
graphile: {
|
|
32
|
+
schema: [],
|
|
33
|
+
appendPlugins: [],
|
|
34
|
+
overrideSettings: {},
|
|
35
|
+
graphileBuildOptions: {},
|
|
36
|
+
},
|
|
37
|
+
server: {
|
|
38
|
+
host: 'localhost',
|
|
39
|
+
port: 3000,
|
|
40
|
+
trustProxy: false,
|
|
41
|
+
strictAuth: false,
|
|
42
|
+
},
|
|
43
|
+
features: {
|
|
44
|
+
simpleInflection: true,
|
|
45
|
+
oppositeBaseNames: true,
|
|
46
|
+
postgis: true
|
|
47
|
+
},
|
|
48
|
+
api: {
|
|
49
|
+
enableMetaApi: true,
|
|
50
|
+
exposedSchemas: [],
|
|
51
|
+
anonRole: 'administrator',
|
|
52
|
+
roleName: 'administrator',
|
|
53
|
+
defaultDatabaseId: 'hard-coded',
|
|
54
|
+
isPublic: true,
|
|
55
|
+
metaSchemas: ['collections_public', 'meta_public']
|
|
56
|
+
},
|
|
57
|
+
cdn: {
|
|
58
|
+
bucketName: 'test-bucket',
|
|
59
|
+
awsRegion: 'us-east-1',
|
|
60
|
+
awsAccessKey: 'minioadmin',
|
|
61
|
+
awsSecretKey: 'minioadmin',
|
|
62
|
+
minioEndpoint: 'http://localhost:9000'
|
|
63
|
+
},
|
|
64
|
+
deployment: {
|
|
65
|
+
useTx: true,
|
|
66
|
+
fast: false,
|
|
67
|
+
usePlan: true,
|
|
68
|
+
cache: false,
|
|
69
|
+
logOnly: false,
|
|
70
|
+
hashMethod: 'content'
|
|
71
|
+
},
|
|
72
|
+
migrations: {
|
|
73
|
+
codegen: {
|
|
74
|
+
useTx: false
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
jobs: {
|
|
78
|
+
pg: {
|
|
79
|
+
host: 'localhost',
|
|
80
|
+
port: 5432,
|
|
81
|
+
user: 'postgres',
|
|
82
|
+
password: 'password',
|
|
83
|
+
database: 'jobs'
|
|
84
|
+
},
|
|
85
|
+
schema: {
|
|
86
|
+
schema: 'app_jobs'
|
|
87
|
+
},
|
|
88
|
+
worker: {
|
|
89
|
+
host: 'localhost',
|
|
90
|
+
port: 5432,
|
|
91
|
+
user: 'postgres',
|
|
92
|
+
password: 'password',
|
|
93
|
+
database: 'jobs',
|
|
94
|
+
schema: 'app_jobs',
|
|
95
|
+
hostname: 'worker-0',
|
|
96
|
+
supportAny: true,
|
|
97
|
+
supported: [],
|
|
98
|
+
pollInterval: 1000,
|
|
99
|
+
gracefulShutdown: true
|
|
100
|
+
},
|
|
101
|
+
scheduler: {
|
|
102
|
+
host: 'localhost',
|
|
103
|
+
port: 5432,
|
|
104
|
+
user: 'postgres',
|
|
105
|
+
password: 'password',
|
|
106
|
+
database: 'jobs',
|
|
107
|
+
schema: 'app_jobs',
|
|
108
|
+
hostname: 'scheduler-0',
|
|
109
|
+
supportAny: true,
|
|
110
|
+
supported: [],
|
|
111
|
+
pollInterval: 1000,
|
|
112
|
+
gracefulShutdown: true
|
|
113
|
+
},
|
|
114
|
+
openFaas: {
|
|
115
|
+
gateway: {
|
|
116
|
+
gatewayUrl: 'http://gateway:8080',
|
|
117
|
+
callbackUrl: 'http://callback:12345',
|
|
118
|
+
callbackPort: 12345
|
|
119
|
+
},
|
|
120
|
+
server: {
|
|
121
|
+
schema: 'app_jobs',
|
|
122
|
+
port: 3000,
|
|
123
|
+
host: 'localhost'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
export function getGitConfigInfo() {
|
|
129
|
+
const isTestEnv = process.env.NODE_ENV === 'test' ||
|
|
130
|
+
process.env.NODE_ENV === 'testing' || // fallback
|
|
131
|
+
process.env.GITHUB_ACTIONS === 'true'; // GitHub Actions
|
|
132
|
+
if (isTestEnv) {
|
|
133
|
+
return {
|
|
134
|
+
username: 'CI Test User',
|
|
135
|
+
email: 'ci@example.com'
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
let username = '';
|
|
139
|
+
let email = '';
|
|
140
|
+
try {
|
|
141
|
+
username = execSync('git config --global user.name', {
|
|
142
|
+
encoding: 'utf8'
|
|
143
|
+
}).trim();
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
username = '';
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
email = execSync('git config --global user.email', {
|
|
150
|
+
encoding: 'utf8'
|
|
151
|
+
}).trim();
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
email = '';
|
|
155
|
+
}
|
|
156
|
+
return { username, email };
|
|
157
|
+
}
|
package/esm/update.js
ADDED
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./error"), exports);
|
|
18
|
+
__exportStar(require("./error-factory"), exports);
|
|
19
|
+
__exportStar(require("./pgpm"), exports);
|
|
20
|
+
__exportStar(require("./jobs"), exports);
|
|
21
|
+
__exportStar(require("./update"), exports);
|
package/jobs.d.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { PgConfig } from 'pg-env';
|
|
2
|
+
/**
|
|
3
|
+
* Job system PostgreSQL configuration
|
|
4
|
+
* Extends the base PgConfig with job-specific database settings
|
|
5
|
+
*/
|
|
6
|
+
export interface JobPgConfig extends PgConfig {
|
|
7
|
+
/** Database name for job system (defaults to 'jobs') */
|
|
8
|
+
database: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Job schema configuration
|
|
12
|
+
*/
|
|
13
|
+
export interface JobSchemaConfig {
|
|
14
|
+
/** PostgreSQL schema name for job tables and functions (defaults to 'app_jobs') */
|
|
15
|
+
schema: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Worker/Scheduler hostname configuration
|
|
19
|
+
*/
|
|
20
|
+
export interface JobHostnameConfig {
|
|
21
|
+
/** Unique identifier for the worker or scheduler instance */
|
|
22
|
+
hostname: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Job task support configuration
|
|
26
|
+
*/
|
|
27
|
+
export interface JobTaskSupportConfig {
|
|
28
|
+
/** Whether to support any/all task types (defaults to true) */
|
|
29
|
+
supportAny: boolean;
|
|
30
|
+
/** Array of explicitly supported task names */
|
|
31
|
+
supported: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* OpenFaaS job system gateway configuration
|
|
35
|
+
*/
|
|
36
|
+
export interface JobGatewayConfig {
|
|
37
|
+
/** Internal gateway URL for OpenFaaS function calls */
|
|
38
|
+
gatewayUrl: string;
|
|
39
|
+
/** Callback URL for job completion notifications */
|
|
40
|
+
callbackUrl: string;
|
|
41
|
+
/** Port for internal job callback server (defaults to 12345) */
|
|
42
|
+
callbackPort: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parameters for failing a job
|
|
46
|
+
*/
|
|
47
|
+
export interface FailJobParams {
|
|
48
|
+
/** Worker ID that is failing the job */
|
|
49
|
+
workerId: string;
|
|
50
|
+
/** Job ID to fail */
|
|
51
|
+
jobId: number | string;
|
|
52
|
+
/** Error message or reason for failure */
|
|
53
|
+
message: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parameters for completing a job
|
|
57
|
+
*/
|
|
58
|
+
export interface CompleteJobParams {
|
|
59
|
+
/** Worker ID that completed the job */
|
|
60
|
+
workerId: string;
|
|
61
|
+
/** Job ID to mark as complete */
|
|
62
|
+
jobId: number | string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parameters for getting a job from the queue
|
|
66
|
+
*/
|
|
67
|
+
export interface GetJobParams {
|
|
68
|
+
/** Worker ID requesting a job */
|
|
69
|
+
workerId: string;
|
|
70
|
+
/**
|
|
71
|
+
* Array of task names this worker supports.
|
|
72
|
+
* When `null`, the job system will consider any task as supported.
|
|
73
|
+
*/
|
|
74
|
+
supportedTaskNames: string[] | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Parameters for getting a scheduled job
|
|
78
|
+
*/
|
|
79
|
+
export interface GetScheduledJobParams {
|
|
80
|
+
/** Worker ID requesting a scheduled job */
|
|
81
|
+
workerId: string;
|
|
82
|
+
/**
|
|
83
|
+
* Array of task names this worker supports.
|
|
84
|
+
* When `null`, the scheduler will consider any task as supported.
|
|
85
|
+
*/
|
|
86
|
+
supportedTaskNames: string[] | null;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Parameters for running a scheduled job
|
|
90
|
+
*/
|
|
91
|
+
export interface RunScheduledJobParams {
|
|
92
|
+
/** Job ID to run */
|
|
93
|
+
jobId: number | string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Parameters for releasing scheduled jobs
|
|
97
|
+
*/
|
|
98
|
+
export interface ReleaseScheduledJobsParams {
|
|
99
|
+
/** Worker ID releasing the jobs */
|
|
100
|
+
workerId: string;
|
|
101
|
+
/**
|
|
102
|
+
* Array of job IDs to release.
|
|
103
|
+
* When omitted, all scheduled jobs for the worker may be released.
|
|
104
|
+
*/
|
|
105
|
+
ids?: Array<number | string>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Parameters for releasing all jobs held by a worker
|
|
109
|
+
*/
|
|
110
|
+
export interface ReleaseJobsParams {
|
|
111
|
+
/** Worker ID releasing all its jobs */
|
|
112
|
+
workerId: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Job record structure from database
|
|
116
|
+
*/
|
|
117
|
+
export interface Job {
|
|
118
|
+
/** Unique job identifier */
|
|
119
|
+
id: number | string;
|
|
120
|
+
/** Task name/type for this job */
|
|
121
|
+
task_name: string;
|
|
122
|
+
/** JSON payload data for the job */
|
|
123
|
+
payload?: any;
|
|
124
|
+
/** Worker ID currently assigned to this job */
|
|
125
|
+
worker_id?: string;
|
|
126
|
+
/** Maximum number of retry attempts */
|
|
127
|
+
max_attempts?: number;
|
|
128
|
+
/** Current attempt number */
|
|
129
|
+
attempts?: number;
|
|
130
|
+
/** Priority level for job execution */
|
|
131
|
+
priority?: number;
|
|
132
|
+
/** Timestamp when job was created */
|
|
133
|
+
created_at?: Date | string;
|
|
134
|
+
/** Timestamp when job was last updated */
|
|
135
|
+
updated_at?: Date | string;
|
|
136
|
+
/** Timestamp when job should run (for scheduled jobs) */
|
|
137
|
+
run_at?: Date | string;
|
|
138
|
+
/** Last error message if job failed */
|
|
139
|
+
last_error?: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Worker configuration options
|
|
143
|
+
*/
|
|
144
|
+
export interface JobWorkerConfig extends JobPgConfig, JobSchemaConfig, JobHostnameConfig, JobTaskSupportConfig {
|
|
145
|
+
/** Polling interval in milliseconds */
|
|
146
|
+
pollInterval?: number;
|
|
147
|
+
/** Whether to enable graceful shutdown */
|
|
148
|
+
gracefulShutdown?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Scheduler configuration options
|
|
152
|
+
*/
|
|
153
|
+
export interface JobSchedulerConfig extends JobPgConfig, JobSchemaConfig, JobHostnameConfig, JobTaskSupportConfig {
|
|
154
|
+
/** Polling interval in milliseconds for checking scheduled jobs */
|
|
155
|
+
pollInterval?: number;
|
|
156
|
+
/** Whether to enable graceful shutdown */
|
|
157
|
+
gracefulShutdown?: boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* OpenFaaS worker configuration
|
|
161
|
+
*/
|
|
162
|
+
export interface OpenFaasJobWorkerConfig extends JobWorkerConfig, JobGatewayConfig {
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* OpenFaaS server configuration
|
|
166
|
+
*/
|
|
167
|
+
export interface OpenFaasJobServerConfig extends JobSchemaConfig {
|
|
168
|
+
/** Port for the job server */
|
|
169
|
+
port: number;
|
|
170
|
+
/** Host address for the job server */
|
|
171
|
+
host?: string;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Complete job system configuration
|
|
175
|
+
*/
|
|
176
|
+
export interface JobsConfig {
|
|
177
|
+
/** PostgreSQL database configuration */
|
|
178
|
+
pg?: Partial<JobPgConfig>;
|
|
179
|
+
/** Job schema configuration */
|
|
180
|
+
schema?: Partial<JobSchemaConfig>;
|
|
181
|
+
/** Worker configuration */
|
|
182
|
+
worker?: Partial<JobWorkerConfig>;
|
|
183
|
+
/** Scheduler configuration */
|
|
184
|
+
scheduler?: Partial<JobSchedulerConfig>;
|
|
185
|
+
/** OpenFaaS specific configuration */
|
|
186
|
+
openFaas?: {
|
|
187
|
+
/** OpenFaaS worker config */
|
|
188
|
+
worker?: Partial<OpenFaasJobWorkerConfig>;
|
|
189
|
+
/** OpenFaaS server config */
|
|
190
|
+
server?: Partial<OpenFaasJobServerConfig>;
|
|
191
|
+
/** Gateway config */
|
|
192
|
+
gateway?: Partial<JobGatewayConfig>;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Default configuration values for job system
|
|
197
|
+
*/
|
|
198
|
+
export declare const jobsDefaults: JobsConfig;
|
package/jobs.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jobsDefaults = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default configuration values for job system
|
|
6
|
+
*/
|
|
7
|
+
exports.jobsDefaults = {
|
|
8
|
+
pg: {
|
|
9
|
+
host: 'localhost',
|
|
10
|
+
port: 5432,
|
|
11
|
+
user: 'postgres',
|
|
12
|
+
password: 'password',
|
|
13
|
+
database: 'jobs'
|
|
14
|
+
},
|
|
15
|
+
schema: {
|
|
16
|
+
schema: 'app_jobs'
|
|
17
|
+
},
|
|
18
|
+
worker: {
|
|
19
|
+
host: 'localhost',
|
|
20
|
+
port: 5432,
|
|
21
|
+
user: 'postgres',
|
|
22
|
+
password: 'password',
|
|
23
|
+
database: 'jobs',
|
|
24
|
+
schema: 'app_jobs',
|
|
25
|
+
hostname: 'worker-0',
|
|
26
|
+
supportAny: true,
|
|
27
|
+
supported: [],
|
|
28
|
+
pollInterval: 1000,
|
|
29
|
+
gracefulShutdown: true
|
|
30
|
+
},
|
|
31
|
+
scheduler: {
|
|
32
|
+
host: 'localhost',
|
|
33
|
+
port: 5432,
|
|
34
|
+
user: 'postgres',
|
|
35
|
+
password: 'password',
|
|
36
|
+
database: 'jobs',
|
|
37
|
+
schema: 'app_jobs',
|
|
38
|
+
hostname: 'scheduler-0',
|
|
39
|
+
supportAny: true,
|
|
40
|
+
supported: [],
|
|
41
|
+
pollInterval: 1000,
|
|
42
|
+
gracefulShutdown: true
|
|
43
|
+
},
|
|
44
|
+
openFaas: {
|
|
45
|
+
gateway: {
|
|
46
|
+
gatewayUrl: 'http://gateway:8080',
|
|
47
|
+
callbackUrl: 'http://callback:12345',
|
|
48
|
+
callbackPort: 12345
|
|
49
|
+
},
|
|
50
|
+
server: {
|
|
51
|
+
schema: 'app_jobs',
|
|
52
|
+
port: 3000,
|
|
53
|
+
host: 'localhost'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pgpmjs/types",
|
|
3
|
+
"version": "2.11.0",
|
|
4
|
+
"author": "Constructive <developers@constructive.io>",
|
|
5
|
+
"description": "PGPM types",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"module": "esm/index.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"homepage": "https://github.com/constructive-io/constructive",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"directory": "dist"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/constructive-io/constructive"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/constructive-io/constructive/issues"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"clean": "makage clean",
|
|
24
|
+
"prepack": "npm run build",
|
|
25
|
+
"build": "makage build",
|
|
26
|
+
"build:dev": "makage build --dev",
|
|
27
|
+
"lint": "eslint . --fix",
|
|
28
|
+
"test": "jest",
|
|
29
|
+
"test:watch": "jest --watch"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"deepmerge": "^4.3.1",
|
|
33
|
+
"graphile-build": "^4.14.1",
|
|
34
|
+
"pg-env": "^1.2.1",
|
|
35
|
+
"postgraphile": "^4.14.1"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"graphql",
|
|
39
|
+
"types",
|
|
40
|
+
"typescript",
|
|
41
|
+
"pgpm",
|
|
42
|
+
"pgpmjs",
|
|
43
|
+
"schema"
|
|
44
|
+
],
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"makage": "^0.1.8"
|
|
47
|
+
},
|
|
48
|
+
"gitHead": "e4d5396a5d9154f4886176bb00c2b460b0f320e5"
|
|
49
|
+
}
|
package/pgpm.d.ts
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { Plugin } from 'graphile-build';
|
|
2
|
+
import { PgConfig } from 'pg-env';
|
|
3
|
+
import { PostGraphileOptions } from 'postgraphile';
|
|
4
|
+
import { JobsConfig } from './jobs';
|
|
5
|
+
/**
|
|
6
|
+
* Authentication options for test client sessions
|
|
7
|
+
*/
|
|
8
|
+
export interface AuthOptions {
|
|
9
|
+
/** Role to assume (defaults to 'authenticated' from RoleMapping config) */
|
|
10
|
+
role?: string;
|
|
11
|
+
/** User ID to set in session context */
|
|
12
|
+
userId?: string | number;
|
|
13
|
+
/** Key name for user ID in session context (defaults to 'jwt.claims.user_id') */
|
|
14
|
+
userIdKey?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Configuration options for PostgreSQL test database connections
|
|
18
|
+
*/
|
|
19
|
+
export interface PgTestConnectionOptions {
|
|
20
|
+
/** The root database to connect to for creating test databases */
|
|
21
|
+
rootDb?: string;
|
|
22
|
+
/** Template database to use when creating test databases */
|
|
23
|
+
template?: string;
|
|
24
|
+
/** Prefix to add to test database names */
|
|
25
|
+
prefix?: string;
|
|
26
|
+
/** PostgreSQL extensions to install in test databases */
|
|
27
|
+
extensions?: string[];
|
|
28
|
+
/** Current working directory for database operations */
|
|
29
|
+
cwd?: string;
|
|
30
|
+
/** Database connection credentials */
|
|
31
|
+
connection?: DatabaseConnectionOptions;
|
|
32
|
+
/** Role mapping configuration */
|
|
33
|
+
roles?: RoleMapping;
|
|
34
|
+
/** Default authentication options for db connections */
|
|
35
|
+
auth?: AuthOptions;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* PostgreSQL session context settings for test clients
|
|
39
|
+
* Used to set session variables via set_config() for RLS policies, search_path, etc.
|
|
40
|
+
*/
|
|
41
|
+
export interface PgTestClientContext {
|
|
42
|
+
/** PostgreSQL role to assume */
|
|
43
|
+
role?: string | null;
|
|
44
|
+
/** Additional session context variables (e.g., 'jwt.claims.user_id', 'search_path') */
|
|
45
|
+
[key: string]: string | null | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use PgTestClientContext instead (typo fix)
|
|
49
|
+
*/
|
|
50
|
+
export type PgTextClientContext = PgTestClientContext;
|
|
51
|
+
/**
|
|
52
|
+
* Role mapping configuration for database security
|
|
53
|
+
*/
|
|
54
|
+
export interface RoleMapping {
|
|
55
|
+
/** Anonymous (unauthenticated) role name */
|
|
56
|
+
anonymous?: string;
|
|
57
|
+
/** Authenticated user role name */
|
|
58
|
+
authenticated?: string;
|
|
59
|
+
/** Administrator role name */
|
|
60
|
+
administrator?: string;
|
|
61
|
+
/** Default role for new connections */
|
|
62
|
+
default?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Database connection credentials
|
|
66
|
+
*/
|
|
67
|
+
export interface DatabaseConnectionOptions {
|
|
68
|
+
/** Database user name */
|
|
69
|
+
user?: string;
|
|
70
|
+
/** Database password */
|
|
71
|
+
password?: string;
|
|
72
|
+
/** Database role to assume */
|
|
73
|
+
role?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* HTTP server configuration
|
|
77
|
+
*/
|
|
78
|
+
export interface ServerOptions {
|
|
79
|
+
/** Server host address */
|
|
80
|
+
host?: string;
|
|
81
|
+
/** Server port number */
|
|
82
|
+
port?: number;
|
|
83
|
+
/** Whether to trust proxy headers */
|
|
84
|
+
trustProxy?: boolean;
|
|
85
|
+
/** CORS origin configuration */
|
|
86
|
+
origin?: string;
|
|
87
|
+
/** Whether to enforce strict authentication */
|
|
88
|
+
strictAuth?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Feature flags and toggles
|
|
92
|
+
*/
|
|
93
|
+
export interface FeatureOptions {
|
|
94
|
+
/** Use simple inflection for GraphQL field names */
|
|
95
|
+
simpleInflection?: boolean;
|
|
96
|
+
/** Use opposite base names for relationships */
|
|
97
|
+
oppositeBaseNames?: boolean;
|
|
98
|
+
/** Enable PostGIS spatial database support */
|
|
99
|
+
postgis?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* PostGraphile/Graphile configuration
|
|
103
|
+
*/
|
|
104
|
+
export interface GraphileOptions {
|
|
105
|
+
/** Database schema(s) to expose through GraphQL */
|
|
106
|
+
schema?: string | string[];
|
|
107
|
+
/** Additional Graphile plugins to load */
|
|
108
|
+
appendPlugins?: Plugin[];
|
|
109
|
+
/** Build options for Graphile */
|
|
110
|
+
graphileBuildOptions?: PostGraphileOptions['graphileBuildOptions'];
|
|
111
|
+
/** Override settings for PostGraphile */
|
|
112
|
+
overrideSettings?: Partial<PostGraphileOptions>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* CDN and file storage configuration
|
|
116
|
+
*/
|
|
117
|
+
export interface CDNOptions {
|
|
118
|
+
/** S3 bucket name for file storage */
|
|
119
|
+
bucketName?: string;
|
|
120
|
+
/** AWS region for S3 bucket */
|
|
121
|
+
awsRegion?: string;
|
|
122
|
+
/** AWS access key for S3 */
|
|
123
|
+
awsAccessKey?: string;
|
|
124
|
+
/** AWS secret key for S3 */
|
|
125
|
+
awsSecretKey?: string;
|
|
126
|
+
/** MinIO endpoint URL for local development */
|
|
127
|
+
minioEndpoint?: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Code generation settings
|
|
131
|
+
*/
|
|
132
|
+
export interface CodegenOptions {
|
|
133
|
+
/** Whether to wrap generated SQL code in transactions */
|
|
134
|
+
useTx?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Migration and code generation options
|
|
138
|
+
*/
|
|
139
|
+
export interface MigrationOptions {
|
|
140
|
+
/** Code generation settings */
|
|
141
|
+
codegen?: CodegenOptions;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Configuration options for the LaunchQL API
|
|
145
|
+
*/
|
|
146
|
+
export interface ApiOptions {
|
|
147
|
+
/** Whether to enable the meta API endpoints */
|
|
148
|
+
enableMetaApi?: boolean;
|
|
149
|
+
/** Database schemas to expose through the API */
|
|
150
|
+
exposedSchemas?: string[];
|
|
151
|
+
/** Anonymous role name for unauthenticated requests */
|
|
152
|
+
anonRole?: string;
|
|
153
|
+
/** Default role name for authenticated requests */
|
|
154
|
+
roleName?: string;
|
|
155
|
+
/** Default database identifier to use */
|
|
156
|
+
defaultDatabaseId?: string;
|
|
157
|
+
/** Whether the API is publicly accessible */
|
|
158
|
+
isPublic?: boolean;
|
|
159
|
+
/** Schemas containing metadata tables */
|
|
160
|
+
metaSchemas?: string[];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Configuration for PGPM workspace
|
|
164
|
+
*/
|
|
165
|
+
export interface PgpmWorkspaceConfig {
|
|
166
|
+
/** Glob patterns for package directories */
|
|
167
|
+
packages: string[];
|
|
168
|
+
/** Optional workspace metadata */
|
|
169
|
+
name?: string;
|
|
170
|
+
version?: string;
|
|
171
|
+
/** Additional workspace settings */
|
|
172
|
+
settings?: {
|
|
173
|
+
[key: string]: any;
|
|
174
|
+
};
|
|
175
|
+
/** Deployment configuration for the workspace */
|
|
176
|
+
deployment?: Omit<DeploymentOptions, 'toChange'>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Configuration options for module deployment
|
|
180
|
+
*/
|
|
181
|
+
export interface DeploymentOptions {
|
|
182
|
+
/** Whether to wrap deployments in database transactions */
|
|
183
|
+
useTx?: boolean;
|
|
184
|
+
/** Use fast deployment strategy (skip migration system) */
|
|
185
|
+
fast?: boolean;
|
|
186
|
+
/** Whether to use Sqitch plan files for deployments */
|
|
187
|
+
usePlan?: boolean;
|
|
188
|
+
/** Enable caching of deployment packages */
|
|
189
|
+
cache?: boolean;
|
|
190
|
+
/** Deploy up to a specific change (inclusive) - can be a change name or tag reference (e.g., '@v1.0.0') */
|
|
191
|
+
toChange?: string;
|
|
192
|
+
/** Log-only mode - skip script execution and only record deployment metadata */
|
|
193
|
+
logOnly?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Hash method for SQL files:
|
|
196
|
+
* - 'content': Hash the raw file content (fast, but sensitive to formatting changes)
|
|
197
|
+
* - 'ast': Hash the parsed AST structure (robust, ignores formatting/comments but slower)
|
|
198
|
+
*/
|
|
199
|
+
hashMethod?: 'content' | 'ast';
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Main configuration options for the PGPM framework
|
|
203
|
+
*/
|
|
204
|
+
export interface PgpmOptions {
|
|
205
|
+
/** Test database configuration options */
|
|
206
|
+
db?: Partial<PgTestConnectionOptions>;
|
|
207
|
+
/** PostgreSQL connection configuration */
|
|
208
|
+
pg?: Partial<PgConfig>;
|
|
209
|
+
/** PostGraphile/Graphile configuration */
|
|
210
|
+
graphile?: GraphileOptions;
|
|
211
|
+
/** HTTP server configuration */
|
|
212
|
+
server?: ServerOptions;
|
|
213
|
+
/** Feature flags and toggles */
|
|
214
|
+
features?: FeatureOptions;
|
|
215
|
+
/** API configuration options */
|
|
216
|
+
api?: ApiOptions;
|
|
217
|
+
/** CDN and file storage configuration */
|
|
218
|
+
cdn?: CDNOptions;
|
|
219
|
+
/** Module deployment configuration */
|
|
220
|
+
deployment?: DeploymentOptions;
|
|
221
|
+
/** Migration and code generation options */
|
|
222
|
+
migrations?: MigrationOptions;
|
|
223
|
+
/** Job system configuration */
|
|
224
|
+
jobs?: JobsConfig;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Default configuration values for PGPM framework
|
|
228
|
+
*/
|
|
229
|
+
export declare const pgpmDefaults: PgpmOptions;
|
|
230
|
+
export declare function getGitConfigInfo(): {
|
|
231
|
+
username: string;
|
|
232
|
+
email: string;
|
|
233
|
+
};
|
package/pgpm.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pgpmDefaults = void 0;
|
|
4
|
+
exports.getGitConfigInfo = getGitConfigInfo;
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
/**
|
|
7
|
+
* Default configuration values for PGPM framework
|
|
8
|
+
*/
|
|
9
|
+
exports.pgpmDefaults = {
|
|
10
|
+
db: {
|
|
11
|
+
rootDb: 'postgres',
|
|
12
|
+
prefix: 'db-',
|
|
13
|
+
extensions: [],
|
|
14
|
+
cwd: process.cwd(),
|
|
15
|
+
connection: {
|
|
16
|
+
user: 'app_user',
|
|
17
|
+
password: 'app_password',
|
|
18
|
+
// TODO: check if this is used vs. roles below...
|
|
19
|
+
role: 'anonymous'
|
|
20
|
+
},
|
|
21
|
+
roles: {
|
|
22
|
+
anonymous: 'anonymous',
|
|
23
|
+
authenticated: 'authenticated',
|
|
24
|
+
administrator: 'administrator',
|
|
25
|
+
default: 'anonymous'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
pg: {
|
|
29
|
+
host: 'localhost',
|
|
30
|
+
port: 5432,
|
|
31
|
+
user: 'postgres',
|
|
32
|
+
password: 'password',
|
|
33
|
+
database: 'postgres',
|
|
34
|
+
},
|
|
35
|
+
graphile: {
|
|
36
|
+
schema: [],
|
|
37
|
+
appendPlugins: [],
|
|
38
|
+
overrideSettings: {},
|
|
39
|
+
graphileBuildOptions: {},
|
|
40
|
+
},
|
|
41
|
+
server: {
|
|
42
|
+
host: 'localhost',
|
|
43
|
+
port: 3000,
|
|
44
|
+
trustProxy: false,
|
|
45
|
+
strictAuth: false,
|
|
46
|
+
},
|
|
47
|
+
features: {
|
|
48
|
+
simpleInflection: true,
|
|
49
|
+
oppositeBaseNames: true,
|
|
50
|
+
postgis: true
|
|
51
|
+
},
|
|
52
|
+
api: {
|
|
53
|
+
enableMetaApi: true,
|
|
54
|
+
exposedSchemas: [],
|
|
55
|
+
anonRole: 'administrator',
|
|
56
|
+
roleName: 'administrator',
|
|
57
|
+
defaultDatabaseId: 'hard-coded',
|
|
58
|
+
isPublic: true,
|
|
59
|
+
metaSchemas: ['collections_public', 'meta_public']
|
|
60
|
+
},
|
|
61
|
+
cdn: {
|
|
62
|
+
bucketName: 'test-bucket',
|
|
63
|
+
awsRegion: 'us-east-1',
|
|
64
|
+
awsAccessKey: 'minioadmin',
|
|
65
|
+
awsSecretKey: 'minioadmin',
|
|
66
|
+
minioEndpoint: 'http://localhost:9000'
|
|
67
|
+
},
|
|
68
|
+
deployment: {
|
|
69
|
+
useTx: true,
|
|
70
|
+
fast: false,
|
|
71
|
+
usePlan: true,
|
|
72
|
+
cache: false,
|
|
73
|
+
logOnly: false,
|
|
74
|
+
hashMethod: 'content'
|
|
75
|
+
},
|
|
76
|
+
migrations: {
|
|
77
|
+
codegen: {
|
|
78
|
+
useTx: false
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
jobs: {
|
|
82
|
+
pg: {
|
|
83
|
+
host: 'localhost',
|
|
84
|
+
port: 5432,
|
|
85
|
+
user: 'postgres',
|
|
86
|
+
password: 'password',
|
|
87
|
+
database: 'jobs'
|
|
88
|
+
},
|
|
89
|
+
schema: {
|
|
90
|
+
schema: 'app_jobs'
|
|
91
|
+
},
|
|
92
|
+
worker: {
|
|
93
|
+
host: 'localhost',
|
|
94
|
+
port: 5432,
|
|
95
|
+
user: 'postgres',
|
|
96
|
+
password: 'password',
|
|
97
|
+
database: 'jobs',
|
|
98
|
+
schema: 'app_jobs',
|
|
99
|
+
hostname: 'worker-0',
|
|
100
|
+
supportAny: true,
|
|
101
|
+
supported: [],
|
|
102
|
+
pollInterval: 1000,
|
|
103
|
+
gracefulShutdown: true
|
|
104
|
+
},
|
|
105
|
+
scheduler: {
|
|
106
|
+
host: 'localhost',
|
|
107
|
+
port: 5432,
|
|
108
|
+
user: 'postgres',
|
|
109
|
+
password: 'password',
|
|
110
|
+
database: 'jobs',
|
|
111
|
+
schema: 'app_jobs',
|
|
112
|
+
hostname: 'scheduler-0',
|
|
113
|
+
supportAny: true,
|
|
114
|
+
supported: [],
|
|
115
|
+
pollInterval: 1000,
|
|
116
|
+
gracefulShutdown: true
|
|
117
|
+
},
|
|
118
|
+
openFaas: {
|
|
119
|
+
gateway: {
|
|
120
|
+
gatewayUrl: 'http://gateway:8080',
|
|
121
|
+
callbackUrl: 'http://callback:12345',
|
|
122
|
+
callbackPort: 12345
|
|
123
|
+
},
|
|
124
|
+
server: {
|
|
125
|
+
schema: 'app_jobs',
|
|
126
|
+
port: 3000,
|
|
127
|
+
host: 'localhost'
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
function getGitConfigInfo() {
|
|
133
|
+
const isTestEnv = process.env.NODE_ENV === 'test' ||
|
|
134
|
+
process.env.NODE_ENV === 'testing' || // fallback
|
|
135
|
+
process.env.GITHUB_ACTIONS === 'true'; // GitHub Actions
|
|
136
|
+
if (isTestEnv) {
|
|
137
|
+
return {
|
|
138
|
+
username: 'CI Test User',
|
|
139
|
+
email: 'ci@example.com'
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
let username = '';
|
|
143
|
+
let email = '';
|
|
144
|
+
try {
|
|
145
|
+
username = (0, child_process_1.execSync)('git config --global user.name', {
|
|
146
|
+
encoding: 'utf8'
|
|
147
|
+
}).trim();
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
username = '';
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
email = (0, child_process_1.execSync)('git config --global user.email', {
|
|
154
|
+
encoding: 'utf8'
|
|
155
|
+
}).trim();
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
email = '';
|
|
159
|
+
}
|
|
160
|
+
return { username, email };
|
|
161
|
+
}
|
package/update.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata stored for npm update checks.
|
|
3
|
+
*/
|
|
4
|
+
export interface UpdateCheckConfig {
|
|
5
|
+
lastCheckedAt: number;
|
|
6
|
+
latestKnownVersion: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const UPDATE_CHECK_TTL_MS: number;
|
|
9
|
+
export declare const UPDATE_CHECK_APPSTASH_KEY = "pgpm-update-check";
|
|
10
|
+
export declare const UPDATE_PACKAGE_NAME = "pgpm";
|
package/update.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UPDATE_PACKAGE_NAME = exports.UPDATE_CHECK_APPSTASH_KEY = exports.UPDATE_CHECK_TTL_MS = void 0;
|
|
4
|
+
exports.UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1000;
|
|
5
|
+
exports.UPDATE_CHECK_APPSTASH_KEY = 'pgpm-update-check';
|
|
6
|
+
exports.UPDATE_PACKAGE_NAME = 'pgpm';
|