@pgpmjs/transform 0.11.1 → 0.12.2

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.
@@ -26,8 +26,18 @@ export interface SchemaObjectRoute {
26
26
  kind: 'table' | 'view' | 'function' | 'procedure' | 'type';
27
27
  /** Unqualified object name (e.g. `accounts`). */
28
28
  name: string;
29
- /** Target schema this object is routed to (e.g. `reporting`). */
30
- toSchema: string;
29
+ /**
30
+ * Target schema this object is routed to (e.g. `reporting`). `null` strips
31
+ * qualification (resolve via `search_path`); omitted with `toName` leaves
32
+ * the schema to the whole-schema default.
33
+ */
34
+ toSchema?: string | null;
35
+ /**
36
+ * Target object name — rebinds references to a *different* object (e.g.
37
+ * point `identity.current_actor()` at `current_user_id()`). At least one of
38
+ * `toSchema`/`toName` must be given.
39
+ */
40
+ toName?: string;
31
41
  }
32
42
  /**
33
43
  * Extension routing for a transpile: where to install extensions and where the
package/bundle-driver.js CHANGED
@@ -62,9 +62,18 @@ function buildSchemaRouter(options) {
62
62
  ensure(from).schema = to;
63
63
  }
64
64
  for (const route of options.routes ?? []) {
65
+ if (route.toSchema === undefined && route.toName === undefined) {
66
+ throw new Error(`Object route for ${route.fromSchema}.${route.name} needs "toSchema" and/or "toName"`);
67
+ }
65
68
  const bucketKey = ROUTE_KIND_BUCKET[route.kind];
66
69
  const target = ensure(route.fromSchema);
67
- (target[bucketKey] ??= {})[route.name] = route.toSchema;
70
+ (target[bucketKey] ??= {})[route.name] =
71
+ route.toName === undefined && typeof route.toSchema === 'string'
72
+ ? route.toSchema
73
+ : {
74
+ ...(route.toSchema !== undefined ? { schema: route.toSchema } : {}),
75
+ ...(route.toName !== undefined ? { name: route.toName } : {})
76
+ };
68
77
  }
69
78
  return new transform_2.SchemaRouter(spec);
70
79
  }
@@ -56,9 +56,18 @@ export function buildSchemaRouter(options) {
56
56
  ensure(from).schema = to;
57
57
  }
58
58
  for (const route of options.routes ?? []) {
59
+ if (route.toSchema === undefined && route.toName === undefined) {
60
+ throw new Error(`Object route for ${route.fromSchema}.${route.name} needs "toSchema" and/or "toName"`);
61
+ }
59
62
  const bucketKey = ROUTE_KIND_BUCKET[route.kind];
60
63
  const target = ensure(route.fromSchema);
61
- (target[bucketKey] ??= {})[route.name] = route.toSchema;
64
+ (target[bucketKey] ??= {})[route.name] =
65
+ route.toName === undefined && typeof route.toSchema === 'string'
66
+ ? route.toSchema
67
+ : {
68
+ ...(route.toSchema !== undefined ? { schema: route.toSchema } : {}),
69
+ ...(route.toName !== undefined ? { name: route.toName } : {})
70
+ };
62
71
  }
63
72
  return new SchemaRouter(spec);
64
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpmjs/transform",
3
- "version": "0.11.1",
3
+ "version": "0.12.2",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Change-aware SQL transformation for PGPM — superset of @pgsql/transform plus change categorization, fixture closure, and bundle transpile/apply drivers",
6
6
  "main": "index.js",
@@ -39,12 +39,12 @@
39
39
  "plpgsql"
40
40
  ],
41
41
  "devDependencies": {
42
- "@pgpmjs/bundle": "^0.12.1",
42
+ "@pgpmjs/bundle": "^0.12.4",
43
43
  "makage": "^0.3.0"
44
44
  },
45
45
  "dependencies": {
46
- "@pgsql/transform": "^18.6.0",
46
+ "@pgsql/transform": "^18.7.0",
47
47
  "plpgsql-parser": "^18.2.1"
48
48
  },
49
- "gitHead": "0286d994d98717cb9b28842233d2db6d1e37c48e"
49
+ "gitHead": "a430897efa1488ec24fc636f0d5023207bba7ba7"
50
50
  }