@pgpmjs/types
Advanced tools
+9
-59
@@ -1,59 +0,9 @@ | ||
| import { PgpmError } from './error'; | ||
| type ErrorContext = Record<string, string | number | boolean>; | ||
| export declare const makeError: <T extends ErrorContext>(code: string, messageFn: (context: T) => string, httpCode?: number) => (context: T, overrideMessage?: string) => PgpmError; | ||
| export declare const errors: { | ||
| NOT_FOUND: (context: ErrorContext, overrideMessage?: string) => PgpmError; | ||
| MODULE_NOT_FOUND: (context: { | ||
| name: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| NO_ACCOUNT_EXISTS: (context: ErrorContext, overrideMessage?: string) => PgpmError; | ||
| INTERNAL_FAILURE: (context: ErrorContext, overrideMessage?: string) => PgpmError; | ||
| CONTEXT_MISSING: (context: ErrorContext, overrideMessage?: string) => PgpmError; | ||
| NOT_IN_WORKSPACE: (context: ErrorContext, overrideMessage?: string) => PgpmError; | ||
| NOT_IN_WORKSPACE_MODULE: (context: ErrorContext, overrideMessage?: string) => PgpmError; | ||
| DEPLOYMENT_FAILED: (context: { | ||
| type: "Deployment" | "Revert" | "Verify"; | ||
| module: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| UNSUPPORTED_TYPE_HINT: (context: ErrorContext, overrideMessage?: string) => PgpmError; | ||
| BAD_FILE_NAME: (context: ErrorContext, overrideMessage?: string) => PgpmError; | ||
| UNKNOWN_COMMAND: (context: ErrorContext, overrideMessage?: string) => PgpmError; | ||
| CHANGE_NOT_FOUND: (context: { | ||
| change: string; | ||
| plan?: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| TAG_NOT_FOUND: (context: { | ||
| tag: string; | ||
| project?: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| PATH_NOT_FOUND: (context: { | ||
| path: string; | ||
| type: "module" | "workspace" | "file"; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| OPERATION_FAILED: (context: { | ||
| operation: string; | ||
| target?: string; | ||
| reason?: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| PLAN_PARSE_ERROR: (context: { | ||
| planPath: string; | ||
| errors: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| CIRCULAR_DEPENDENCY: (context: { | ||
| module: string; | ||
| dependency: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| INVALID_NAME: (context: { | ||
| name: string; | ||
| type: "tag" | "change" | "module"; | ||
| rules?: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| WORKSPACE_OPERATION_ERROR: (context: { | ||
| operation: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| FILE_NOT_FOUND: (context: { | ||
| filePath: string; | ||
| type?: string; | ||
| }, overrideMessage?: string) => PgpmError; | ||
| }; | ||
| export {}; | ||
| /** | ||
| * pgpm error factory. | ||
| * | ||
| * The canonical error system now lives in `@constructive-io/errors` (a | ||
| * standalone, zero-dependency package). pgpm's error codes are registered | ||
| * there; this module re-exports the shared factory so existing call sites | ||
| * (`throw errors.MODULE_NOT_FOUND({ name })`) are unchanged. | ||
| */ | ||
| export { errors, makeError } from '@constructive-io/errors'; |
+12
-35
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.errors = exports.makeError = void 0; | ||
| const error_1 = require("./error"); | ||
| const makeError = (code, messageFn, httpCode) => { | ||
| return (context, overrideMessage) => { | ||
| const message = overrideMessage || messageFn(context); | ||
| return new error_1.PgpmError(code, message, context, httpCode); | ||
| }; | ||
| }; | ||
| exports.makeError = makeError; | ||
| exports.errors = { | ||
| NOT_FOUND: (0, exports.makeError)('NOT_FOUND', () => `Not found.`, 404), | ||
| MODULE_NOT_FOUND: (0, exports.makeError)('MODULE_NOT_FOUND', ({ name }) => `Module "${name}" not found in modules list.`, 404), | ||
| NO_ACCOUNT_EXISTS: (0, exports.makeError)('NO_ACCOUNT_EXISTS', ({ userId }) => `No account exists for user: ${userId}`, 404), | ||
| INTERNAL_FAILURE: (0, exports.makeError)('INTERNAL_FAILURE', ({ details }) => `Something went wrong: ${details}`, 500), | ||
| CONTEXT_MISSING: (0, exports.makeError)('CONTEXT_MISSING', () => `Context is not initialized. Did you run setup()?`, 500), | ||
| NOT_IN_WORKSPACE: (0, exports.makeError)('NOT_IN_WORKSPACE', () => `You must be in a PGPM workspace. Initialize with "pgpm init workspace".`, 400), | ||
| NOT_IN_WORKSPACE_MODULE: (0, exports.makeError)('NOT_IN_WORKSPACE_MODULE', () => `Error: You must be inside one of the workspace packages.`, 400), | ||
| DEPLOYMENT_FAILED: (0, exports.makeError)('DEPLOYMENT_FAILED', ({ type, module }) => `${type} failed for module: ${module}`, 500), | ||
| UNSUPPORTED_TYPE_HINT: (0, exports.makeError)('UNSUPPORTED_TYPE_HINT', ({ typeHint }) => `Unsupported type hint: ${typeHint}`, 400), | ||
| BAD_FILE_NAME: (0, exports.makeError)('BAD_FILE_NAME', ({ name }) => `Invalid file name: ${name}`, 400), | ||
| UNKNOWN_COMMAND: (0, exports.makeError)('UNKNOWN_COMMAND', ({ cmd }) => `Unknown command: ${cmd}`, 400), | ||
| CHANGE_NOT_FOUND: (0, exports.makeError)('CHANGE_NOT_FOUND', ({ change, plan }) => `Change '${change}' not found in plan${plan ? ` file: ${plan}` : ''}`, 404), | ||
| TAG_NOT_FOUND: (0, exports.makeError)('TAG_NOT_FOUND', ({ tag, project }) => `Tag '${tag}' not found${project ? ` in project ${project}` : ' in plan'}`, 404), | ||
| PATH_NOT_FOUND: (0, exports.makeError)('PATH_NOT_FOUND', ({ path, type }) => `${type} path not found: ${path}`, 404), | ||
| OPERATION_FAILED: (0, exports.makeError)('OPERATION_FAILED', ({ operation, target, reason }) => `${operation} failed${target ? ` for ${target}` : ''}${reason ? `: ${reason}` : ''}`, 500), | ||
| PLAN_PARSE_ERROR: (0, exports.makeError)('PLAN_PARSE_ERROR', ({ planPath, errors }) => `Failed to parse plan file ${planPath}: ${errors}`, 400), | ||
| CIRCULAR_DEPENDENCY: (0, exports.makeError)('CIRCULAR_DEPENDENCY', ({ module, dependency }) => `Circular reference detected: ${module} → ${dependency}`, 400), | ||
| INVALID_NAME: (0, exports.makeError)('INVALID_NAME', ({ name, type, rules }) => `Invalid ${type} name: ${name}${rules ? `. ${rules}` : ''}`, 400), | ||
| 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), | ||
| FILE_NOT_FOUND: (0, exports.makeError)('FILE_NOT_FOUND', ({ filePath, type }) => `${type ? `${type} file` : 'File'} not found: ${filePath}`, 404), | ||
| }; | ||
| // throw errors.MODULE_NOT_FOUND({ name: 'auth' }); | ||
| // throw errors.INTERNAL_FAILURE({ details: 'Could not connect to DB' }); | ||
| // throw errors.UNKNOWN_COMMAND({ cmd: 'foo' }, 'Unsupported command "foo"'); | ||
| // throw errors.CONTEXT_MISSING((); | ||
| exports.makeError = exports.errors = void 0; | ||
| /** | ||
| * pgpm error factory. | ||
| * | ||
| * The canonical error system now lives in `@constructive-io/errors` (a | ||
| * standalone, zero-dependency package). pgpm's error codes are registered | ||
| * there; this module re-exports the shared factory so existing call sites | ||
| * (`throw errors.MODULE_NOT_FOUND({ name })`) are unchanged. | ||
| */ | ||
| var errors_1 = require("@constructive-io/errors"); | ||
| Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return errors_1.errors; } }); | ||
| Object.defineProperty(exports, "makeError", { enumerable: true, get: function () { return errors_1.makeError; } }); |
+9
-33
@@ -1,33 +0,9 @@ | ||
| import { PgpmError } from './error'; | ||
| export const makeError = (code, messageFn, httpCode) => { | ||
| return (context, overrideMessage) => { | ||
| const message = overrideMessage || messageFn(context); | ||
| return new PgpmError(code, message, context, httpCode); | ||
| }; | ||
| }; | ||
| export const errors = { | ||
| NOT_FOUND: makeError('NOT_FOUND', () => `Not found.`, 404), | ||
| MODULE_NOT_FOUND: makeError('MODULE_NOT_FOUND', ({ name }) => `Module "${name}" not found in modules list.`, 404), | ||
| NO_ACCOUNT_EXISTS: makeError('NO_ACCOUNT_EXISTS', ({ userId }) => `No account exists for user: ${userId}`, 404), | ||
| INTERNAL_FAILURE: makeError('INTERNAL_FAILURE', ({ details }) => `Something went wrong: ${details}`, 500), | ||
| CONTEXT_MISSING: makeError('CONTEXT_MISSING', () => `Context is not initialized. Did you run setup()?`, 500), | ||
| NOT_IN_WORKSPACE: makeError('NOT_IN_WORKSPACE', () => `You must be in a PGPM workspace. Initialize with "pgpm init workspace".`, 400), | ||
| NOT_IN_WORKSPACE_MODULE: makeError('NOT_IN_WORKSPACE_MODULE', () => `Error: You must be inside one of the workspace packages.`, 400), | ||
| DEPLOYMENT_FAILED: makeError('DEPLOYMENT_FAILED', ({ type, module }) => `${type} failed for module: ${module}`, 500), | ||
| UNSUPPORTED_TYPE_HINT: makeError('UNSUPPORTED_TYPE_HINT', ({ typeHint }) => `Unsupported type hint: ${typeHint}`, 400), | ||
| BAD_FILE_NAME: makeError('BAD_FILE_NAME', ({ name }) => `Invalid file name: ${name}`, 400), | ||
| UNKNOWN_COMMAND: makeError('UNKNOWN_COMMAND', ({ cmd }) => `Unknown command: ${cmd}`, 400), | ||
| CHANGE_NOT_FOUND: makeError('CHANGE_NOT_FOUND', ({ change, plan }) => `Change '${change}' not found in plan${plan ? ` file: ${plan}` : ''}`, 404), | ||
| TAG_NOT_FOUND: makeError('TAG_NOT_FOUND', ({ tag, project }) => `Tag '${tag}' not found${project ? ` in project ${project}` : ' in plan'}`, 404), | ||
| PATH_NOT_FOUND: makeError('PATH_NOT_FOUND', ({ path, type }) => `${type} path not found: ${path}`, 404), | ||
| OPERATION_FAILED: makeError('OPERATION_FAILED', ({ operation, target, reason }) => `${operation} failed${target ? ` for ${target}` : ''}${reason ? `: ${reason}` : ''}`, 500), | ||
| PLAN_PARSE_ERROR: makeError('PLAN_PARSE_ERROR', ({ planPath, errors }) => `Failed to parse plan file ${planPath}: ${errors}`, 400), | ||
| CIRCULAR_DEPENDENCY: makeError('CIRCULAR_DEPENDENCY', ({ module, dependency }) => `Circular reference detected: ${module} → ${dependency}`, 400), | ||
| INVALID_NAME: makeError('INVALID_NAME', ({ name, type, rules }) => `Invalid ${type} name: ${name}${rules ? `. ${rules}` : ''}`, 400), | ||
| WORKSPACE_OPERATION_ERROR: makeError('WORKSPACE_OPERATION_ERROR', ({ operation }) => `Cannot perform non-recursive ${operation} on workspace. Use recursive=true or specify a target module.`, 400), | ||
| FILE_NOT_FOUND: makeError('FILE_NOT_FOUND', ({ filePath, type }) => `${type ? `${type} file` : 'File'} not found: ${filePath}`, 404), | ||
| }; | ||
| // throw errors.MODULE_NOT_FOUND({ name: 'auth' }); | ||
| // throw errors.INTERNAL_FAILURE({ details: 'Could not connect to DB' }); | ||
| // throw errors.UNKNOWN_COMMAND({ cmd: 'foo' }, 'Unsupported command "foo"'); | ||
| // throw errors.CONTEXT_MISSING((); | ||
| /** | ||
| * pgpm error factory. | ||
| * | ||
| * The canonical error system now lives in `@constructive-io/errors` (a | ||
| * standalone, zero-dependency package). pgpm's error codes are registered | ||
| * there; this module re-exports the shared factory so existing call sites | ||
| * (`throw errors.MODULE_NOT_FOUND({ name })`) are unchanged. | ||
| */ | ||
| export { errors, makeError } from '@constructive-io/errors'; |
+4
-3
| { | ||
| "name": "@pgpmjs/types", | ||
| "version": "2.40.0", | ||
| "version": "2.42.0", | ||
| "author": "Constructive <developers@constructive.io>", | ||
@@ -32,3 +32,4 @@ "description": "PGPM types", | ||
| "dependencies": { | ||
| "pg-env": "^1.22.0" | ||
| "@constructive-io/errors": "^0.3.0", | ||
| "pg-env": "^1.23.0" | ||
| }, | ||
@@ -46,3 +47,3 @@ "keywords": [ | ||
| }, | ||
| "gitHead": "73f55ad24d9a92e7ef1e268526b31bfb7bb12b28" | ||
| "gitHead": "bb3269d48cdf2bc8f361bdd79b4833c921c13ec3" | ||
| } |
+1
-0
@@ -49,2 +49,3 @@ # @pgpmjs/types | ||
| * [pgsql-test](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation. | ||
| * [pglite-test](https://github.com/constructive-io/constructive/tree/main/postgres/pglite-test): **🪶 Drop-in pgsql-test replacement backed by PGlite** — in-process Postgres, no server required, instance-per-suite isolation. | ||
| * [pgsql-seed](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-seed): **🌱 PostgreSQL seeding utilities** for CSV, JSON, SQL data loading, and pgpm deployment. | ||
@@ -51,0 +52,0 @@ * [supabase-test](https://github.com/constructive-io/constructive/tree/main/postgres/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready. |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
88
1.15%44432
-14.49%2
100%1058
-8.4%+ Added
Updated