@pgpmjs/core 7.18.0 → 7.19.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/apply/materialize.d.ts +26 -0
- package/apply/materialize.js +45 -3
- package/esm/apply/materialize.js +44 -3
- package/package.json +10 -10
package/apply/materialize.d.ts
CHANGED
|
@@ -38,3 +38,29 @@ export declare function materializeApplyModule(options: MaterializeApplyOptions)
|
|
|
38
38
|
export declare function resolveEffectiveModulePath(moduleName: string, modulePath: string, moduleMap: ModuleMap, workspacePath: string): Promise<string>;
|
|
39
39
|
/** Test seam: clear the per-process materialization cache. */
|
|
40
40
|
export declare function clearApplyMaterializationCache(): void;
|
|
41
|
+
export interface MaterializeWorkspaceTargetOptions {
|
|
42
|
+
/** Absolute workspace root path. */
|
|
43
|
+
workspacePath: string;
|
|
44
|
+
/** The workspace module map (proxies already synthesized in). */
|
|
45
|
+
moduleMap: ModuleMap;
|
|
46
|
+
/** Name of the apply-proxy module to materialize. */
|
|
47
|
+
target: string;
|
|
48
|
+
/** Directory to write the plain, deployable module into. */
|
|
49
|
+
outDir: string;
|
|
50
|
+
}
|
|
51
|
+
export interface MaterializeWorkspaceTargetResult {
|
|
52
|
+
/** The deployable module directory the bundle was written to. */
|
|
53
|
+
outDir: string;
|
|
54
|
+
/** The transpiled, content-addressed bundle that was materialized. */
|
|
55
|
+
bundle: MigrationBundle;
|
|
56
|
+
/** The resolved apply spec the materialization was driven by. */
|
|
57
|
+
spec: ResolvedApplySpec;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve an apply-proxy module by name in a workspace and materialize it to a
|
|
61
|
+
* chosen directory as a plain, deployable module (transforms baked in — no
|
|
62
|
+
* `pgpm.apply.json`). Shared by the `pgpm materialize` command and tests; the
|
|
63
|
+
* counterpart to {@link resolveEffectiveModulePath}, but with an explicit,
|
|
64
|
+
* stable `outDir` and no per-process cache.
|
|
65
|
+
*/
|
|
66
|
+
export declare function materializeWorkspaceTarget(options: MaterializeWorkspaceTargetOptions): Promise<MaterializeWorkspaceTargetResult>;
|
package/apply/materialize.js
CHANGED
|
@@ -3,15 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.materializeApplyModule = materializeApplyModule;
|
|
4
4
|
exports.resolveEffectiveModulePath = resolveEffectiveModulePath;
|
|
5
5
|
exports.clearApplyMaterializationCache = clearApplyMaterializationCache;
|
|
6
|
+
exports.materializeWorkspaceTarget = materializeWorkspaceTarget;
|
|
7
|
+
const bundle_1 = require("@pgpmjs/bundle");
|
|
8
|
+
const slice_1 = require("@pgpmjs/slice");
|
|
9
|
+
const transform_1 = require("@pgpmjs/transform");
|
|
6
10
|
const fs_1 = require("fs");
|
|
7
11
|
const os_1 = require("os");
|
|
8
12
|
const path_1 = require("path");
|
|
9
|
-
const bundle_1 = require("@pgpmjs/bundle");
|
|
10
|
-
const transform_1 = require("@pgpmjs/transform");
|
|
11
|
-
const slice_1 = require("@pgpmjs/slice");
|
|
12
13
|
const apply_spec_1 = require("./apply-spec");
|
|
13
14
|
const profile_1 = require("./profile");
|
|
14
15
|
const reuse_1 = require("./reuse");
|
|
16
|
+
const types_1 = require("./types");
|
|
15
17
|
// Functions that take a bare schema name as a string-literal first argument.
|
|
16
18
|
// The AST pass only remaps dotted literals ('schema.object'); these helpers
|
|
17
19
|
// (ubiquitous in verify scripts) name the schema alone, so a string-level
|
|
@@ -200,3 +202,43 @@ async function resolveEffectiveModulePath(moduleName, modulePath, moduleMap, wor
|
|
|
200
202
|
function clearApplyMaterializationCache() {
|
|
201
203
|
materializedCache.clear();
|
|
202
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Resolve an apply-proxy module by name in a workspace and materialize it to a
|
|
207
|
+
* chosen directory as a plain, deployable module (transforms baked in — no
|
|
208
|
+
* `pgpm.apply.json`). Shared by the `pgpm materialize` command and tests; the
|
|
209
|
+
* counterpart to {@link resolveEffectiveModulePath}, but with an explicit,
|
|
210
|
+
* stable `outDir` and no per-process cache.
|
|
211
|
+
*/
|
|
212
|
+
async function materializeWorkspaceTarget(options) {
|
|
213
|
+
const { workspacePath, moduleMap, target, outDir } = options;
|
|
214
|
+
const module = moduleMap[target];
|
|
215
|
+
if (!module) {
|
|
216
|
+
const proxies = Object.keys(moduleMap).sort();
|
|
217
|
+
throw new Error(`Module "${target}" not found in the workspace.` +
|
|
218
|
+
(proxies.length ? ` Available modules: ${proxies.join(', ')}.` : ''));
|
|
219
|
+
}
|
|
220
|
+
const modulePath = (0, path_1.resolve)(workspacePath, module.path);
|
|
221
|
+
if (!(0, apply_spec_1.hasApplySpec)(modulePath)) {
|
|
222
|
+
throw new Error(`Module "${target}" is not an apply proxy (no ${types_1.APPLY_SPEC_FILE} in ${modulePath}). ` +
|
|
223
|
+
`Only apply-proxy modules can be materialized.`);
|
|
224
|
+
}
|
|
225
|
+
const spec = (0, profile_1.resolveEffectiveApplySpec)((0, apply_spec_1.readApplySpec)(modulePath), (0, profile_1.loadWorkspaceRoutingProfile)(workspacePath));
|
|
226
|
+
if ((0, reuse_1.isReuseSpec)(spec)) {
|
|
227
|
+
throw new Error(`Apply proxy "${target}" is a reuse proxy (shared + per-tenant). ` +
|
|
228
|
+
`Reuse proxies are not yet supported by \`pgpm materialize\`.`);
|
|
229
|
+
}
|
|
230
|
+
const sourceModule = moduleMap[spec.source.module];
|
|
231
|
+
if (!sourceModule) {
|
|
232
|
+
throw new Error(`Apply spec in "${target}" references source module "${spec.source.module}", ` +
|
|
233
|
+
`which was not found in the workspace. Run \`pgpm install\` to install it` +
|
|
234
|
+
(spec.source.package ? ` (${spec.source.package})` : '') +
|
|
235
|
+
`.`);
|
|
236
|
+
}
|
|
237
|
+
const sourceDir = (0, path_1.resolve)(workspacePath, sourceModule.path);
|
|
238
|
+
const { outDir: writtenDir, bundle } = await materializeApplyModule({
|
|
239
|
+
sourceDir,
|
|
240
|
+
spec,
|
|
241
|
+
outDir
|
|
242
|
+
});
|
|
243
|
+
return { outDir: writtenDir, bundle, spec };
|
|
244
|
+
}
|
package/esm/apply/materialize.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { bundleFromModule, materializeBundle, transpileBundle, verifyBundle } from '@pgpmjs/bundle';
|
|
2
|
+
import { excludeSubsystemPrograms, stripSubsystemSql } from '@pgpmjs/slice';
|
|
3
|
+
import { buildSchemaRouter, loadModule, makeSchemaTranspiler, parseSqlProgram } from '@pgpmjs/transform';
|
|
1
4
|
import { mkdtempSync } from 'fs';
|
|
2
5
|
import { tmpdir } from 'os';
|
|
3
6
|
import { join, resolve } from 'path';
|
|
4
|
-
import { bundleFromModule, materializeBundle, transpileBundle, verifyBundle } from '@pgpmjs/bundle';
|
|
5
|
-
import { buildSchemaRouter, loadModule, makeSchemaTranspiler, parseSqlProgram } from '@pgpmjs/transform';
|
|
6
|
-
import { excludeSubsystemPrograms, stripSubsystemSql } from '@pgpmjs/slice';
|
|
7
7
|
import { hasApplySpec, readApplySpec } from './apply-spec';
|
|
8
8
|
import { loadWorkspaceRoutingProfile, resolveEffectiveApplySpec } from './profile';
|
|
9
9
|
import { isReuseSpec, materializeReuseModule, resolveSharedModuleName } from './reuse';
|
|
10
|
+
import { APPLY_SPEC_FILE } from './types';
|
|
10
11
|
// Functions that take a bare schema name as a string-literal first argument.
|
|
11
12
|
// The AST pass only remaps dotted literals ('schema.object'); these helpers
|
|
12
13
|
// (ubiquitous in verify scripts) name the schema alone, so a string-level
|
|
@@ -195,3 +196,43 @@ export async function resolveEffectiveModulePath(moduleName, modulePath, moduleM
|
|
|
195
196
|
export function clearApplyMaterializationCache() {
|
|
196
197
|
materializedCache.clear();
|
|
197
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Resolve an apply-proxy module by name in a workspace and materialize it to a
|
|
201
|
+
* chosen directory as a plain, deployable module (transforms baked in — no
|
|
202
|
+
* `pgpm.apply.json`). Shared by the `pgpm materialize` command and tests; the
|
|
203
|
+
* counterpart to {@link resolveEffectiveModulePath}, but with an explicit,
|
|
204
|
+
* stable `outDir` and no per-process cache.
|
|
205
|
+
*/
|
|
206
|
+
export async function materializeWorkspaceTarget(options) {
|
|
207
|
+
const { workspacePath, moduleMap, target, outDir } = options;
|
|
208
|
+
const module = moduleMap[target];
|
|
209
|
+
if (!module) {
|
|
210
|
+
const proxies = Object.keys(moduleMap).sort();
|
|
211
|
+
throw new Error(`Module "${target}" not found in the workspace.` +
|
|
212
|
+
(proxies.length ? ` Available modules: ${proxies.join(', ')}.` : ''));
|
|
213
|
+
}
|
|
214
|
+
const modulePath = resolve(workspacePath, module.path);
|
|
215
|
+
if (!hasApplySpec(modulePath)) {
|
|
216
|
+
throw new Error(`Module "${target}" is not an apply proxy (no ${APPLY_SPEC_FILE} in ${modulePath}). ` +
|
|
217
|
+
`Only apply-proxy modules can be materialized.`);
|
|
218
|
+
}
|
|
219
|
+
const spec = resolveEffectiveApplySpec(readApplySpec(modulePath), loadWorkspaceRoutingProfile(workspacePath));
|
|
220
|
+
if (isReuseSpec(spec)) {
|
|
221
|
+
throw new Error(`Apply proxy "${target}" is a reuse proxy (shared + per-tenant). ` +
|
|
222
|
+
`Reuse proxies are not yet supported by \`pgpm materialize\`.`);
|
|
223
|
+
}
|
|
224
|
+
const sourceModule = moduleMap[spec.source.module];
|
|
225
|
+
if (!sourceModule) {
|
|
226
|
+
throw new Error(`Apply spec in "${target}" references source module "${spec.source.module}", ` +
|
|
227
|
+
`which was not found in the workspace. Run \`pgpm install\` to install it` +
|
|
228
|
+
(spec.source.package ? ` (${spec.source.package})` : '') +
|
|
229
|
+
`.`);
|
|
230
|
+
}
|
|
231
|
+
const sourceDir = resolve(workspacePath, sourceModule.path);
|
|
232
|
+
const { outDir: writtenDir, bundle } = await materializeApplyModule({
|
|
233
|
+
sourceDir,
|
|
234
|
+
spec,
|
|
235
|
+
outDir
|
|
236
|
+
});
|
|
237
|
+
return { outDir: writtenDir, bundle, spec };
|
|
238
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpmjs/core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.19.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PGPM Package and Migration Tools",
|
|
6
6
|
"main": "index.js",
|
|
@@ -48,24 +48,24 @@
|
|
|
48
48
|
"makage": "^0.3.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@pgpmjs/ast": "^0.9.
|
|
52
|
-
"@pgpmjs/bundle": "^0.12.
|
|
53
|
-
"@pgpmjs/env": "^2.39.
|
|
51
|
+
"@pgpmjs/ast": "^0.9.6",
|
|
52
|
+
"@pgpmjs/bundle": "^0.12.5",
|
|
53
|
+
"@pgpmjs/env": "^2.39.3",
|
|
54
54
|
"@pgpmjs/logger": "^2.22.1",
|
|
55
|
-
"@pgpmjs/server-utils": "^3.23.
|
|
56
|
-
"@pgpmjs/slice": "^0.12.
|
|
57
|
-
"@pgpmjs/transform": "^0.13.
|
|
58
|
-
"@pgpmjs/types": "^2.48.
|
|
55
|
+
"@pgpmjs/server-utils": "^3.23.5",
|
|
56
|
+
"@pgpmjs/slice": "^0.12.1",
|
|
57
|
+
"@pgpmjs/transform": "^0.13.1",
|
|
58
|
+
"@pgpmjs/types": "^2.48.2",
|
|
59
59
|
"csv-to-pg": "^4.8.1",
|
|
60
60
|
"genomic": "^5.6.2",
|
|
61
61
|
"glob": "^13.0.6",
|
|
62
62
|
"parse-package-name": "^1.0.0",
|
|
63
63
|
"pg": "^8.21.0",
|
|
64
|
-
"pg-cache": "^3.23.
|
|
64
|
+
"pg-cache": "^3.23.5",
|
|
65
65
|
"pg-env": "^1.26.1",
|
|
66
66
|
"pgsql-deparser": "^18.1.1",
|
|
67
67
|
"pgsql-parser": "^18.1.1",
|
|
68
68
|
"yanse": "^0.2.1"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "947334d361e9f4c48d451f1c7312b2d705ea154e"
|
|
71
71
|
}
|