@supabase/pg-delta 1.0.0-alpha.22 → 1.0.0-alpha.24
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/dist/core/catalog.model.js +1 -0
- package/dist/core/integrations/filter/flatten.js +13 -0
- package/dist/core/objects/aggregate/aggregate.diff.js +16 -0
- package/dist/core/objects/aggregate/aggregate.model.d.ts +10 -0
- package/dist/core/objects/aggregate/aggregate.model.js +19 -1
- package/dist/core/objects/aggregate/changes/aggregate.base.d.ts +1 -1
- package/dist/core/objects/aggregate/changes/aggregate.security-label.d.ts +28 -0
- package/dist/core/objects/aggregate/changes/aggregate.security-label.js +64 -0
- package/dist/core/objects/aggregate/changes/aggregate.types.d.ts +2 -1
- package/dist/core/objects/base.model.d.ts +8 -0
- package/dist/core/objects/base.model.js +2 -0
- package/dist/core/objects/domain/changes/domain.base.d.ts +1 -1
- package/dist/core/objects/domain/changes/domain.security-label.d.ts +28 -0
- package/dist/core/objects/domain/changes/domain.security-label.js +61 -0
- package/dist/core/objects/domain/changes/domain.types.d.ts +2 -1
- package/dist/core/objects/domain/domain.diff.js +16 -0
- package/dist/core/objects/domain/domain.model.d.ts +10 -0
- package/dist/core/objects/domain/domain.model.js +19 -1
- package/dist/core/objects/event-trigger/changes/event-trigger.base.d.ts +1 -1
- package/dist/core/objects/event-trigger/changes/event-trigger.security-label.d.ts +28 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.security-label.js +61 -0
- package/dist/core/objects/event-trigger/changes/event-trigger.types.d.ts +2 -1
- package/dist/core/objects/event-trigger/event-trigger.diff.js +16 -0
- package/dist/core/objects/event-trigger/event-trigger.model.d.ts +10 -0
- package/dist/core/objects/event-trigger/event-trigger.model.js +19 -1
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.base.d.ts +1 -1
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.security-label.d.ts +28 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.security-label.js +61 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.types.d.ts +2 -1
- package/dist/core/objects/foreign-data-wrapper/foreign-table/foreign-table.diff.js +16 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/foreign-table.model.d.ts +22 -0
- package/dist/core/objects/foreign-data-wrapper/foreign-table/foreign-table.model.js +20 -1
- package/dist/core/objects/materialized-view/changes/materialized-view.base.d.ts +1 -1
- package/dist/core/objects/materialized-view/changes/materialized-view.security-label.d.ts +28 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.security-label.js +61 -0
- package/dist/core/objects/materialized-view/changes/materialized-view.types.d.ts +2 -1
- package/dist/core/objects/materialized-view/materialized-view.diff.js +18 -0
- package/dist/core/objects/materialized-view/materialized-view.model.d.ts +22 -0
- package/dist/core/objects/materialized-view/materialized-view.model.js +20 -1
- package/dist/core/objects/procedure/changes/procedure.base.d.ts +1 -1
- package/dist/core/objects/procedure/changes/procedure.security-label.d.ts +28 -0
- package/dist/core/objects/procedure/changes/procedure.security-label.js +69 -0
- package/dist/core/objects/procedure/changes/procedure.types.d.ts +2 -1
- package/dist/core/objects/procedure/procedure.diff.js +16 -0
- package/dist/core/objects/procedure/procedure.model.d.ts +10 -0
- package/dist/core/objects/procedure/procedure.model.js +19 -1
- package/dist/core/objects/publication/changes/publication.base.d.ts +1 -1
- package/dist/core/objects/publication/changes/publication.security-label.d.ts +28 -0
- package/dist/core/objects/publication/changes/publication.security-label.js +61 -0
- package/dist/core/objects/publication/changes/publication.types.d.ts +2 -1
- package/dist/core/objects/publication/publication.diff.js +16 -0
- package/dist/core/objects/publication/publication.model.d.ts +14 -0
- package/dist/core/objects/publication/publication.model.js +20 -1
- package/dist/core/objects/role/changes/role.base.d.ts +1 -1
- package/dist/core/objects/role/changes/role.security-label.d.ts +28 -0
- package/dist/core/objects/role/changes/role.security-label.js +61 -0
- package/dist/core/objects/role/changes/role.types.d.ts +2 -1
- package/dist/core/objects/role/role.diff.js +16 -0
- package/dist/core/objects/role/role.model.d.ts +10 -0
- package/dist/core/objects/role/role.model.js +29 -0
- package/dist/core/objects/schema/changes/schema.base.d.ts +1 -1
- package/dist/core/objects/schema/changes/schema.security-label.d.ts +28 -0
- package/dist/core/objects/schema/changes/schema.security-label.js +61 -0
- package/dist/core/objects/schema/changes/schema.types.d.ts +2 -1
- package/dist/core/objects/schema/schema.diff.js +24 -1
- package/dist/core/objects/schema/schema.model.d.ts +10 -0
- package/dist/core/objects/schema/schema.model.js +18 -1
- package/dist/core/objects/security-label.types.d.ts +20 -0
- package/dist/core/objects/security-label.types.js +46 -0
- package/dist/core/objects/sequence/changes/sequence.base.d.ts +1 -1
- package/dist/core/objects/sequence/changes/sequence.security-label.d.ts +28 -0
- package/dist/core/objects/sequence/changes/sequence.security-label.js +61 -0
- package/dist/core/objects/sequence/changes/sequence.types.d.ts +2 -1
- package/dist/core/objects/sequence/sequence.diff.js +16 -0
- package/dist/core/objects/sequence/sequence.model.d.ts +10 -0
- package/dist/core/objects/sequence/sequence.model.js +19 -1
- package/dist/core/objects/subscription/changes/subscription.base.d.ts +1 -1
- package/dist/core/objects/subscription/changes/subscription.security-label.d.ts +28 -0
- package/dist/core/objects/subscription/changes/subscription.security-label.js +61 -0
- package/dist/core/objects/subscription/changes/subscription.types.d.ts +2 -1
- package/dist/core/objects/subscription/subscription.diff.js +16 -0
- package/dist/core/objects/subscription/subscription.model.d.ts +10 -0
- package/dist/core/objects/subscription/subscription.model.js +19 -1
- package/dist/core/objects/table/changes/table.base.d.ts +1 -1
- package/dist/core/objects/table/changes/table.security-label.d.ts +63 -0
- package/dist/core/objects/table/changes/table.security-label.js +134 -0
- package/dist/core/objects/table/changes/table.types.d.ts +2 -1
- package/dist/core/objects/table/table.diff.js +49 -0
- package/dist/core/objects/table/table.model.d.ts +30 -0
- package/dist/core/objects/table/table.model.js +34 -2
- package/dist/core/objects/type/composite-type/changes/composite-type.base.d.ts +1 -1
- package/dist/core/objects/type/composite-type/changes/composite-type.security-label.d.ts +28 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.security-label.js +61 -0
- package/dist/core/objects/type/composite-type/changes/composite-type.types.d.ts +2 -1
- package/dist/core/objects/type/composite-type/composite-type.diff.js +16 -0
- package/dist/core/objects/type/composite-type/composite-type.model.d.ts +22 -0
- package/dist/core/objects/type/composite-type/composite-type.model.js +22 -2
- package/dist/core/objects/type/enum/changes/enum.base.d.ts +1 -1
- package/dist/core/objects/type/enum/changes/enum.security-label.d.ts +28 -0
- package/dist/core/objects/type/enum/changes/enum.security-label.js +61 -0
- package/dist/core/objects/type/enum/changes/enum.types.d.ts +2 -1
- package/dist/core/objects/type/enum/enum.diff.js +16 -0
- package/dist/core/objects/type/enum/enum.model.d.ts +10 -0
- package/dist/core/objects/type/enum/enum.model.js +20 -1
- package/dist/core/objects/type/range/changes/range.base.d.ts +1 -1
- package/dist/core/objects/type/range/changes/range.security-label.d.ts +28 -0
- package/dist/core/objects/type/range/changes/range.security-label.js +61 -0
- package/dist/core/objects/type/range/changes/range.types.d.ts +2 -1
- package/dist/core/objects/type/range/range.diff.js +16 -0
- package/dist/core/objects/type/range/range.model.d.ts +10 -0
- package/dist/core/objects/type/range/range.model.js +19 -1
- package/dist/core/objects/utils.d.ts +1 -0
- package/dist/core/objects/utils.js +3 -0
- package/dist/core/objects/view/changes/view.base.d.ts +1 -1
- package/dist/core/objects/view/changes/view.security-label.d.ts +28 -0
- package/dist/core/objects/view/changes/view.security-label.js +61 -0
- package/dist/core/objects/view/changes/view.types.d.ts +2 -1
- package/dist/core/objects/view/view.diff.js +13 -0
- package/dist/core/objects/view/view.model.d.ts +26 -0
- package/dist/core/objects/view/view.model.js +20 -1
- package/dist/core/plan/sql-format/fixtures.js +1 -0
- package/dist/core/post-diff-normalization.d.ts +7 -0
- package/dist/core/post-diff-normalization.js +33 -4
- package/dist/core/sort/cycle-breakers.js +139 -17
- package/package.json +1 -1
- package/src/core/catalog.model.ts +1 -0
- package/src/core/integrations/filter/dsl.test.ts +27 -0
- package/src/core/integrations/filter/flatten.ts +16 -0
- package/src/core/objects/aggregate/aggregate.diff.ts +33 -0
- package/src/core/objects/aggregate/aggregate.model.ts +22 -1
- package/src/core/objects/aggregate/changes/aggregate.base.ts +5 -1
- package/src/core/objects/aggregate/changes/aggregate.security-label.ts +99 -0
- package/src/core/objects/aggregate/changes/aggregate.types.ts +3 -1
- package/src/core/objects/base.model.ts +2 -0
- package/src/core/objects/domain/changes/domain.base.ts +5 -1
- package/src/core/objects/domain/changes/domain.security-label.test.ts +56 -0
- package/src/core/objects/domain/changes/domain.security-label.ts +77 -0
- package/src/core/objects/domain/changes/domain.types.ts +3 -1
- package/src/core/objects/domain/domain.diff.ts +33 -0
- package/src/core/objects/domain/domain.model.ts +22 -1
- package/src/core/objects/event-trigger/changes/event-trigger.base.ts +1 -1
- package/src/core/objects/event-trigger/changes/event-trigger.security-label.ts +95 -0
- package/src/core/objects/event-trigger/changes/event-trigger.types.ts +3 -1
- package/src/core/objects/event-trigger/event-trigger.diff.ts +33 -0
- package/src/core/objects/event-trigger/event-trigger.model.ts +22 -1
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.base.ts +5 -1
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.security-label.ts +95 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.types.ts +3 -1
- package/src/core/objects/foreign-data-wrapper/foreign-table/foreign-table.diff.ts +33 -0
- package/src/core/objects/foreign-data-wrapper/foreign-table/foreign-table.model.ts +24 -1
- package/src/core/objects/materialized-view/changes/materialized-view.base.ts +5 -1
- package/src/core/objects/materialized-view/changes/materialized-view.security-label.test.ts +63 -0
- package/src/core/objects/materialized-view/changes/materialized-view.security-label.ts +95 -0
- package/src/core/objects/materialized-view/changes/materialized-view.types.ts +3 -1
- package/src/core/objects/materialized-view/materialized-view.diff.ts +37 -0
- package/src/core/objects/materialized-view/materialized-view.model.ts +25 -4
- package/src/core/objects/procedure/changes/procedure.base.ts +5 -1
- package/src/core/objects/procedure/changes/procedure.security-label.ts +105 -0
- package/src/core/objects/procedure/changes/procedure.types.ts +3 -1
- package/src/core/objects/procedure/procedure.diff.ts +33 -0
- package/src/core/objects/procedure/procedure.model.ts +23 -2
- package/src/core/objects/publication/changes/publication.base.ts +1 -1
- package/src/core/objects/publication/changes/publication.security-label.ts +95 -0
- package/src/core/objects/publication/changes/publication.types.ts +3 -1
- package/src/core/objects/publication/publication.diff.ts +33 -0
- package/src/core/objects/publication/publication.model.ts +24 -1
- package/src/core/objects/role/changes/role.base.ts +2 -1
- package/src/core/objects/role/changes/role.security-label.ts +77 -0
- package/src/core/objects/role/changes/role.types.ts +3 -1
- package/src/core/objects/role/role.diff.ts +33 -0
- package/src/core/objects/role/role.model.ts +32 -0
- package/src/core/objects/schema/changes/schema.alter.test.ts +1 -0
- package/src/core/objects/schema/changes/schema.base.ts +5 -1
- package/src/core/objects/schema/changes/schema.create.test.ts +1 -0
- package/src/core/objects/schema/changes/schema.drop.test.ts +1 -0
- package/src/core/objects/schema/changes/schema.security-label.test.ts +76 -0
- package/src/core/objects/schema/changes/schema.security-label.ts +77 -0
- package/src/core/objects/schema/changes/schema.types.ts +3 -1
- package/src/core/objects/schema/schema.diff.test.ts +1 -0
- package/src/core/objects/schema/schema.diff.ts +43 -1
- package/src/core/objects/schema/schema.model.ts +21 -1
- package/src/core/objects/security-label.types.test.ts +106 -0
- package/src/core/objects/security-label.types.ts +61 -0
- package/src/core/objects/sequence/changes/sequence.base.ts +5 -1
- package/src/core/objects/sequence/changes/sequence.security-label.test.ts +58 -0
- package/src/core/objects/sequence/changes/sequence.security-label.ts +92 -0
- package/src/core/objects/sequence/changes/sequence.types.ts +3 -1
- package/src/core/objects/sequence/sequence.diff.ts +33 -0
- package/src/core/objects/sequence/sequence.model.ts +22 -1
- package/src/core/objects/subscription/changes/subscription.base.ts +1 -1
- package/src/core/objects/subscription/changes/subscription.security-label.ts +95 -0
- package/src/core/objects/subscription/changes/subscription.types.ts +3 -1
- package/src/core/objects/subscription/subscription.diff.ts +33 -0
- package/src/core/objects/subscription/subscription.model.ts +22 -1
- package/src/core/objects/table/changes/table.base.ts +5 -1
- package/src/core/objects/table/changes/table.security-label.test.ts +140 -0
- package/src/core/objects/table/changes/table.security-label.ts +183 -0
- package/src/core/objects/table/changes/table.types.ts +3 -1
- package/src/core/objects/table/table.diff.ts +87 -0
- package/src/core/objects/table/table.model.ts +42 -2
- package/src/core/objects/type/composite-type/changes/composite-type.base.ts +5 -1
- package/src/core/objects/type/composite-type/changes/composite-type.security-label.ts +95 -0
- package/src/core/objects/type/composite-type/changes/composite-type.types.ts +3 -1
- package/src/core/objects/type/composite-type/composite-type.diff.ts +33 -0
- package/src/core/objects/type/composite-type/composite-type.model.ts +26 -2
- package/src/core/objects/type/enum/changes/enum.base.ts +5 -1
- package/src/core/objects/type/enum/changes/enum.security-label.ts +77 -0
- package/src/core/objects/type/enum/changes/enum.types.ts +3 -1
- package/src/core/objects/type/enum/enum.diff.ts +33 -0
- package/src/core/objects/type/enum/enum.model.ts +25 -1
- package/src/core/objects/type/range/changes/range.base.ts +5 -1
- package/src/core/objects/type/range/changes/range.security-label.ts +77 -0
- package/src/core/objects/type/range/changes/range.types.ts +3 -1
- package/src/core/objects/type/range/range.diff.ts +33 -0
- package/src/core/objects/type/range/range.model.ts +22 -1
- package/src/core/objects/utils.ts +3 -0
- package/src/core/objects/view/changes/view.base.ts +5 -1
- package/src/core/objects/view/changes/view.security-label.test.ts +64 -0
- package/src/core/objects/view/changes/view.security-label.ts +77 -0
- package/src/core/objects/view/changes/view.types.ts +3 -1
- package/src/core/objects/view/view.diff.ts +31 -0
- package/src/core/objects/view/view.model.ts +25 -2
- package/src/core/plan/sql-format/fixtures.ts +1 -0
- package/src/core/post-diff-normalization.test.ts +123 -0
- package/src/core/post-diff-normalization.ts +40 -4
- package/src/core/sort/cycle-breakers.test.ts +236 -2
- package/src/core/sort/cycle-breakers.ts +184 -24
- package/src/core/sort/sort-changes.test.ts +317 -0
|
@@ -3,6 +3,7 @@ import type { CommentAggregate } from "./aggregate.comment.ts";
|
|
|
3
3
|
import type { CreateAggregate } from "./aggregate.create.ts";
|
|
4
4
|
import type { DropAggregate } from "./aggregate.drop.ts";
|
|
5
5
|
import type { AggregatePrivilege } from "./aggregate.privilege.ts";
|
|
6
|
+
import type { SecurityLabelAggregate } from "./aggregate.security-label.ts";
|
|
6
7
|
|
|
7
8
|
/** Union of all aggregate-related change variants (`objectType: "aggregate"`). @category Change Types */
|
|
8
9
|
export type AggregateChange =
|
|
@@ -10,4 +11,5 @@ export type AggregateChange =
|
|
|
10
11
|
| CommentAggregate
|
|
11
12
|
| CreateAggregate
|
|
12
13
|
| DropAggregate
|
|
13
|
-
| AggregatePrivilege
|
|
14
|
+
| AggregatePrivilege
|
|
15
|
+
| SecurityLabelAggregate;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
+
import { securityLabelPropsSchema } from "./security-label.types.ts";
|
|
2
3
|
import { deepEqual } from "./utils.ts";
|
|
3
4
|
|
|
4
5
|
export const columnPropsSchema = z.object({
|
|
@@ -18,6 +19,7 @@ export const columnPropsSchema = z.object({
|
|
|
18
19
|
collation: z.string().nullable(),
|
|
19
20
|
default: z.string().nullable(),
|
|
20
21
|
comment: z.string().nullable(),
|
|
22
|
+
security_labels: z.array(securityLabelPropsSchema).optional(),
|
|
21
23
|
});
|
|
22
24
|
|
|
23
25
|
export type ColumnProps = z.infer<typeof columnPropsSchema>;
|
|
@@ -3,7 +3,11 @@ import type { Domain } from "../domain.model.ts";
|
|
|
3
3
|
|
|
4
4
|
abstract class BaseDomainChange extends BaseChange {
|
|
5
5
|
abstract readonly domain: Domain;
|
|
6
|
-
abstract readonly scope:
|
|
6
|
+
abstract readonly scope:
|
|
7
|
+
| "object"
|
|
8
|
+
| "comment"
|
|
9
|
+
| "privilege"
|
|
10
|
+
| "security_label";
|
|
7
11
|
readonly objectType: "domain" = "domain";
|
|
8
12
|
}
|
|
9
13
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { assertValidSql } from "../../../test-utils/assert-valid-sql.ts";
|
|
3
|
+
import { stableId } from "../../utils.ts";
|
|
4
|
+
import { Domain, type DomainProps } from "../domain.model.ts";
|
|
5
|
+
import {
|
|
6
|
+
CreateSecurityLabelOnDomain,
|
|
7
|
+
DropSecurityLabelOnDomain,
|
|
8
|
+
} from "./domain.security-label.ts";
|
|
9
|
+
|
|
10
|
+
const makeDomain = (): Domain =>
|
|
11
|
+
new Domain({
|
|
12
|
+
schema: "public",
|
|
13
|
+
name: "email_t",
|
|
14
|
+
base_type: "text",
|
|
15
|
+
base_type_schema: "pg_catalog",
|
|
16
|
+
not_null: false,
|
|
17
|
+
type_modifier: -1,
|
|
18
|
+
array_dimensions: 0,
|
|
19
|
+
collation: null,
|
|
20
|
+
default_bin: null,
|
|
21
|
+
default_value: null,
|
|
22
|
+
owner: "postgres",
|
|
23
|
+
comment: null,
|
|
24
|
+
constraints: [],
|
|
25
|
+
privileges: [],
|
|
26
|
+
} as DomainProps);
|
|
27
|
+
|
|
28
|
+
describe("domain.security-label", () => {
|
|
29
|
+
test("create serializes", async () => {
|
|
30
|
+
const domain = makeDomain();
|
|
31
|
+
const change = new CreateSecurityLabelOnDomain({
|
|
32
|
+
domain,
|
|
33
|
+
securityLabel: { provider: "dummy", label: "classified" },
|
|
34
|
+
});
|
|
35
|
+
expect(change.scope).toBe("security_label");
|
|
36
|
+
expect(change.creates).toEqual([
|
|
37
|
+
stableId.securityLabel(domain.stableId, "dummy"),
|
|
38
|
+
]);
|
|
39
|
+
await assertValidSql(change.serialize());
|
|
40
|
+
expect(change.serialize()).toBe(
|
|
41
|
+
"SECURITY LABEL FOR dummy ON DOMAIN public.email_t IS 'classified'",
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("drop serializes to IS NULL", async () => {
|
|
46
|
+
const domain = makeDomain();
|
|
47
|
+
const change = new DropSecurityLabelOnDomain({
|
|
48
|
+
domain,
|
|
49
|
+
securityLabel: { provider: "dummy", label: "x" },
|
|
50
|
+
});
|
|
51
|
+
await assertValidSql(change.serialize());
|
|
52
|
+
expect(change.serialize()).toBe(
|
|
53
|
+
"SECURITY LABEL FOR dummy ON DOMAIN public.email_t IS NULL",
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { quoteLiteral } from "../../base.change.ts";
|
|
2
|
+
import type { SecurityLabelProps } from "../../security-label.types.ts";
|
|
3
|
+
import { stableId } from "../../utils.ts";
|
|
4
|
+
import type { Domain } from "../domain.model.ts";
|
|
5
|
+
import { CreateDomainChange, DropDomainChange } from "./domain.base.ts";
|
|
6
|
+
|
|
7
|
+
export type SecurityLabelDomain =
|
|
8
|
+
| CreateSecurityLabelOnDomain
|
|
9
|
+
| DropSecurityLabelOnDomain;
|
|
10
|
+
|
|
11
|
+
export class CreateSecurityLabelOnDomain extends CreateDomainChange {
|
|
12
|
+
public readonly domain: Domain;
|
|
13
|
+
public readonly securityLabel: SecurityLabelProps;
|
|
14
|
+
public readonly scope = "security_label" as const;
|
|
15
|
+
|
|
16
|
+
constructor(props: { domain: Domain; securityLabel: SecurityLabelProps }) {
|
|
17
|
+
super();
|
|
18
|
+
this.domain = props.domain;
|
|
19
|
+
this.securityLabel = props.securityLabel;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get creates() {
|
|
23
|
+
return [
|
|
24
|
+
stableId.securityLabel(this.domain.stableId, this.securityLabel.provider),
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get requires() {
|
|
29
|
+
return [this.domain.stableId];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
serialize(): string {
|
|
33
|
+
return [
|
|
34
|
+
"SECURITY LABEL FOR",
|
|
35
|
+
this.securityLabel.provider,
|
|
36
|
+
"ON DOMAIN",
|
|
37
|
+
`${this.domain.schema}.${this.domain.name}`,
|
|
38
|
+
"IS",
|
|
39
|
+
quoteLiteral(this.securityLabel.label),
|
|
40
|
+
].join(" ");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class DropSecurityLabelOnDomain extends DropDomainChange {
|
|
45
|
+
public readonly domain: Domain;
|
|
46
|
+
public readonly securityLabel: SecurityLabelProps;
|
|
47
|
+
public readonly scope = "security_label" as const;
|
|
48
|
+
|
|
49
|
+
constructor(props: { domain: Domain; securityLabel: SecurityLabelProps }) {
|
|
50
|
+
super();
|
|
51
|
+
this.domain = props.domain;
|
|
52
|
+
this.securityLabel = props.securityLabel;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get drops() {
|
|
56
|
+
return [
|
|
57
|
+
stableId.securityLabel(this.domain.stableId, this.securityLabel.provider),
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get requires() {
|
|
62
|
+
return [
|
|
63
|
+
stableId.securityLabel(this.domain.stableId, this.securityLabel.provider),
|
|
64
|
+
this.domain.stableId,
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
serialize(): string {
|
|
69
|
+
return [
|
|
70
|
+
"SECURITY LABEL FOR",
|
|
71
|
+
this.securityLabel.provider,
|
|
72
|
+
"ON DOMAIN",
|
|
73
|
+
`${this.domain.schema}.${this.domain.name}`,
|
|
74
|
+
"IS NULL",
|
|
75
|
+
].join(" ");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { CommentDomain } from "./domain.comment.ts";
|
|
|
3
3
|
import type { CreateDomain } from "./domain.create.ts";
|
|
4
4
|
import type { DropDomain } from "./domain.drop.ts";
|
|
5
5
|
import type { DomainPrivilege } from "./domain.privilege.ts";
|
|
6
|
+
import type { SecurityLabelDomain } from "./domain.security-label.ts";
|
|
6
7
|
|
|
7
8
|
/** Union of all domain-related change variants (`objectType: "domain"`). @category Change Types */
|
|
8
9
|
export type DomainChange =
|
|
@@ -10,4 +11,5 @@ export type DomainChange =
|
|
|
10
11
|
| CommentDomain
|
|
11
12
|
| CreateDomain
|
|
12
13
|
| DropDomain
|
|
13
|
-
| DomainPrivilege
|
|
14
|
+
| DomainPrivilege
|
|
15
|
+
| SecurityLabelDomain;
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
filterPublicBuiltInDefaults,
|
|
6
6
|
} from "../base.privilege-diff.ts";
|
|
7
7
|
import type { ObjectDiffContext } from "../diff-context.ts";
|
|
8
|
+
import { diffSecurityLabels } from "../security-label.types.ts";
|
|
8
9
|
import {
|
|
9
10
|
AlterDomainAddConstraint,
|
|
10
11
|
AlterDomainChangeOwner,
|
|
@@ -26,6 +27,10 @@ import {
|
|
|
26
27
|
RevokeDomainPrivileges,
|
|
27
28
|
RevokeGrantOptionDomainPrivileges,
|
|
28
29
|
} from "./changes/domain.privilege.ts";
|
|
30
|
+
import {
|
|
31
|
+
CreateSecurityLabelOnDomain,
|
|
32
|
+
DropSecurityLabelOnDomain,
|
|
33
|
+
} from "./changes/domain.security-label.ts";
|
|
29
34
|
import type { DomainChange } from "./changes/domain.types.ts";
|
|
30
35
|
import type { Domain } from "./domain.model.ts";
|
|
31
36
|
|
|
@@ -67,6 +72,14 @@ export function diffDomains(
|
|
|
67
72
|
if (newDomain.comment !== null) {
|
|
68
73
|
changes.push(new CreateCommentOnDomain({ domain: newDomain }));
|
|
69
74
|
}
|
|
75
|
+
for (const label of newDomain.security_labels) {
|
|
76
|
+
changes.push(
|
|
77
|
+
new CreateSecurityLabelOnDomain({
|
|
78
|
+
domain: newDomain,
|
|
79
|
+
securityLabel: label,
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
70
83
|
// For unvalidated constraints, CREATE DOMAIN cannot specify NOT VALID.
|
|
71
84
|
// Add them after creation and validate to match branch state semantics.
|
|
72
85
|
// For already validated constraints, they are emitted inline in CREATE DOMAIN.
|
|
@@ -255,6 +268,26 @@ export function diffDomains(
|
|
|
255
268
|
}
|
|
256
269
|
}
|
|
257
270
|
|
|
271
|
+
// SECURITY LABELS
|
|
272
|
+
changes.push(
|
|
273
|
+
...diffSecurityLabels<
|
|
274
|
+
CreateSecurityLabelOnDomain | DropSecurityLabelOnDomain
|
|
275
|
+
>(
|
|
276
|
+
mainDomain.security_labels,
|
|
277
|
+
branchDomain.security_labels,
|
|
278
|
+
(securityLabel) =>
|
|
279
|
+
new CreateSecurityLabelOnDomain({
|
|
280
|
+
domain: branchDomain,
|
|
281
|
+
securityLabel,
|
|
282
|
+
}),
|
|
283
|
+
(securityLabel) =>
|
|
284
|
+
new DropSecurityLabelOnDomain({
|
|
285
|
+
domain: mainDomain,
|
|
286
|
+
securityLabel,
|
|
287
|
+
}),
|
|
288
|
+
),
|
|
289
|
+
);
|
|
290
|
+
|
|
258
291
|
// PRIVILEGES
|
|
259
292
|
// Filter out PUBLIC's built-in default USAGE privilege from main catalog
|
|
260
293
|
// (PostgreSQL grants it automatically, so we shouldn't compare it)
|
|
@@ -6,6 +6,10 @@ import {
|
|
|
6
6
|
type PrivilegeProps,
|
|
7
7
|
privilegePropsSchema,
|
|
8
8
|
} from "../base.privilege-diff.ts";
|
|
9
|
+
import {
|
|
10
|
+
type SecurityLabelProps,
|
|
11
|
+
securityLabelPropsSchema,
|
|
12
|
+
} from "../security-label.types.ts";
|
|
9
13
|
|
|
10
14
|
const domainConstraintPropsSchema = z.object({
|
|
11
15
|
name: z.string(),
|
|
@@ -31,6 +35,7 @@ const domainPropsSchema = z.object({
|
|
|
31
35
|
comment: z.string().nullable(),
|
|
32
36
|
constraints: z.array(domainConstraintPropsSchema),
|
|
33
37
|
privileges: z.array(privilegePropsSchema),
|
|
38
|
+
security_labels: z.array(securityLabelPropsSchema).default([]).optional(),
|
|
34
39
|
});
|
|
35
40
|
|
|
36
41
|
export type DomainConstraintProps = z.infer<typeof domainConstraintPropsSchema>;
|
|
@@ -58,6 +63,7 @@ export class Domain extends BasePgModel {
|
|
|
58
63
|
public readonly comment: DomainProps["comment"];
|
|
59
64
|
public readonly constraints: DomainConstraintProps[];
|
|
60
65
|
public readonly privileges: DomainPrivilegeProps[];
|
|
66
|
+
public readonly security_labels: SecurityLabelProps[];
|
|
61
67
|
|
|
62
68
|
constructor(props: DomainProps) {
|
|
63
69
|
super();
|
|
@@ -80,6 +86,7 @@ export class Domain extends BasePgModel {
|
|
|
80
86
|
this.comment = props.comment;
|
|
81
87
|
this.constraints = props.constraints;
|
|
82
88
|
this.privileges = props.privileges;
|
|
89
|
+
this.security_labels = props.security_labels ?? [];
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
get stableId(): `domain:${string}` {
|
|
@@ -107,6 +114,7 @@ export class Domain extends BasePgModel {
|
|
|
107
114
|
comment: this.comment,
|
|
108
115
|
constraints: this.constraints,
|
|
109
116
|
privileges: this.privileges,
|
|
117
|
+
security_labels: this.security_labels,
|
|
110
118
|
};
|
|
111
119
|
}
|
|
112
120
|
}
|
|
@@ -170,7 +178,20 @@ export async function extractDomains(pool: Pool): Promise<Domain[]> {
|
|
|
170
178
|
)
|
|
171
179
|
from lateral aclexplode(COALESCE(t.typacl, acldefault('T', t.typowner))) as x(grantor, grantee, privilege_type, is_grantable)
|
|
172
180
|
), '[]'
|
|
173
|
-
) as privileges
|
|
181
|
+
) as privileges,
|
|
182
|
+
coalesce(
|
|
183
|
+
(
|
|
184
|
+
select json_agg(
|
|
185
|
+
json_build_object('provider', sl.provider, 'label', sl.label)
|
|
186
|
+
order by sl.provider
|
|
187
|
+
)
|
|
188
|
+
from pg_catalog.pg_seclabel sl
|
|
189
|
+
where sl.objoid = t.oid
|
|
190
|
+
and sl.classoid = 'pg_type'::regclass
|
|
191
|
+
and sl.objsubid = 0
|
|
192
|
+
),
|
|
193
|
+
'[]'::json
|
|
194
|
+
) as security_labels
|
|
174
195
|
from
|
|
175
196
|
pg_catalog.pg_type t
|
|
176
197
|
inner join pg_catalog.pg_type bt on bt.oid = t.typbasetype
|
|
@@ -3,7 +3,7 @@ import type { EventTrigger } from "../event-trigger.model.ts";
|
|
|
3
3
|
|
|
4
4
|
abstract class BaseEventTriggerChange extends BaseChange {
|
|
5
5
|
abstract readonly eventTrigger: EventTrigger;
|
|
6
|
-
abstract readonly scope: "object" | "comment";
|
|
6
|
+
abstract readonly scope: "object" | "comment" | "security_label";
|
|
7
7
|
readonly objectType = "event_trigger" as const;
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { quoteLiteral } from "../../base.change.ts";
|
|
2
|
+
import type { SecurityLabelProps } from "../../security-label.types.ts";
|
|
3
|
+
import { stableId } from "../../utils.ts";
|
|
4
|
+
import type { EventTrigger } from "../event-trigger.model.ts";
|
|
5
|
+
import {
|
|
6
|
+
CreateEventTriggerChange,
|
|
7
|
+
DropEventTriggerChange,
|
|
8
|
+
} from "./event-trigger.base.ts";
|
|
9
|
+
|
|
10
|
+
export type SecurityLabelEventTrigger =
|
|
11
|
+
| CreateSecurityLabelOnEventTrigger
|
|
12
|
+
| DropSecurityLabelOnEventTrigger;
|
|
13
|
+
|
|
14
|
+
export class CreateSecurityLabelOnEventTrigger extends CreateEventTriggerChange {
|
|
15
|
+
public readonly eventTrigger: EventTrigger;
|
|
16
|
+
public readonly securityLabel: SecurityLabelProps;
|
|
17
|
+
public readonly scope = "security_label" as const;
|
|
18
|
+
|
|
19
|
+
constructor(props: {
|
|
20
|
+
eventTrigger: EventTrigger;
|
|
21
|
+
securityLabel: SecurityLabelProps;
|
|
22
|
+
}) {
|
|
23
|
+
super();
|
|
24
|
+
this.eventTrigger = props.eventTrigger;
|
|
25
|
+
this.securityLabel = props.securityLabel;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get creates() {
|
|
29
|
+
return [
|
|
30
|
+
stableId.securityLabel(
|
|
31
|
+
this.eventTrigger.stableId,
|
|
32
|
+
this.securityLabel.provider,
|
|
33
|
+
),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get requires() {
|
|
38
|
+
return [this.eventTrigger.stableId];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
serialize(): string {
|
|
42
|
+
return [
|
|
43
|
+
"SECURITY LABEL FOR",
|
|
44
|
+
this.securityLabel.provider,
|
|
45
|
+
"ON EVENT TRIGGER",
|
|
46
|
+
this.eventTrigger.name,
|
|
47
|
+
"IS",
|
|
48
|
+
quoteLiteral(this.securityLabel.label),
|
|
49
|
+
].join(" ");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class DropSecurityLabelOnEventTrigger extends DropEventTriggerChange {
|
|
54
|
+
public readonly eventTrigger: EventTrigger;
|
|
55
|
+
public readonly securityLabel: SecurityLabelProps;
|
|
56
|
+
public readonly scope = "security_label" as const;
|
|
57
|
+
|
|
58
|
+
constructor(props: {
|
|
59
|
+
eventTrigger: EventTrigger;
|
|
60
|
+
securityLabel: SecurityLabelProps;
|
|
61
|
+
}) {
|
|
62
|
+
super();
|
|
63
|
+
this.eventTrigger = props.eventTrigger;
|
|
64
|
+
this.securityLabel = props.securityLabel;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get drops() {
|
|
68
|
+
return [
|
|
69
|
+
stableId.securityLabel(
|
|
70
|
+
this.eventTrigger.stableId,
|
|
71
|
+
this.securityLabel.provider,
|
|
72
|
+
),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get requires() {
|
|
77
|
+
return [
|
|
78
|
+
stableId.securityLabel(
|
|
79
|
+
this.eventTrigger.stableId,
|
|
80
|
+
this.securityLabel.provider,
|
|
81
|
+
),
|
|
82
|
+
this.eventTrigger.stableId,
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
serialize(): string {
|
|
87
|
+
return [
|
|
88
|
+
"SECURITY LABEL FOR",
|
|
89
|
+
this.securityLabel.provider,
|
|
90
|
+
"ON EVENT TRIGGER",
|
|
91
|
+
this.eventTrigger.name,
|
|
92
|
+
"IS NULL",
|
|
93
|
+
].join(" ");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -2,10 +2,12 @@ import type { AlterEventTrigger } from "./event-trigger.alter.ts";
|
|
|
2
2
|
import type { CommentEventTrigger } from "./event-trigger.comment.ts";
|
|
3
3
|
import type { CreateEventTrigger } from "./event-trigger.create.ts";
|
|
4
4
|
import type { DropEventTrigger } from "./event-trigger.drop.ts";
|
|
5
|
+
import type { SecurityLabelEventTrigger } from "./event-trigger.security-label.ts";
|
|
5
6
|
|
|
6
7
|
/** Union of all event-trigger-related change variants (`objectType: "event_trigger"`). @category Change Types */
|
|
7
8
|
export type EventTriggerChange =
|
|
8
9
|
| AlterEventTrigger
|
|
9
10
|
| CommentEventTrigger
|
|
10
11
|
| CreateEventTrigger
|
|
11
|
-
| DropEventTrigger
|
|
12
|
+
| DropEventTrigger
|
|
13
|
+
| SecurityLabelEventTrigger;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { diffObjects } from "../base.diff.ts";
|
|
2
2
|
import type { ObjectDiffContext } from "../diff-context.ts";
|
|
3
|
+
import { diffSecurityLabels } from "../security-label.types.ts";
|
|
3
4
|
import { deepEqual, hasNonAlterableChanges } from "../utils.ts";
|
|
4
5
|
import {
|
|
5
6
|
AlterEventTriggerChangeOwner,
|
|
@@ -11,6 +12,10 @@ import {
|
|
|
11
12
|
} from "./changes/event-trigger.comment.ts";
|
|
12
13
|
import { CreateEventTrigger } from "./changes/event-trigger.create.ts";
|
|
13
14
|
import { DropEventTrigger } from "./changes/event-trigger.drop.ts";
|
|
15
|
+
import {
|
|
16
|
+
CreateSecurityLabelOnEventTrigger,
|
|
17
|
+
DropSecurityLabelOnEventTrigger,
|
|
18
|
+
} from "./changes/event-trigger.security-label.ts";
|
|
14
19
|
import type { EventTriggerChange } from "./changes/event-trigger.types.ts";
|
|
15
20
|
import type { EventTrigger } from "./event-trigger.model.ts";
|
|
16
21
|
|
|
@@ -49,6 +54,14 @@ export function diffEventTriggers(
|
|
|
49
54
|
if (eventTrigger.comment !== null) {
|
|
50
55
|
changes.push(new CreateCommentOnEventTrigger({ eventTrigger }));
|
|
51
56
|
}
|
|
57
|
+
for (const label of eventTrigger.security_labels) {
|
|
58
|
+
changes.push(
|
|
59
|
+
new CreateSecurityLabelOnEventTrigger({
|
|
60
|
+
eventTrigger,
|
|
61
|
+
securityLabel: label,
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
52
65
|
}
|
|
53
66
|
|
|
54
67
|
for (const eventTriggerId of dropped) {
|
|
@@ -121,6 +134,26 @@ export function diffEventTriggers(
|
|
|
121
134
|
);
|
|
122
135
|
}
|
|
123
136
|
}
|
|
137
|
+
|
|
138
|
+
// SECURITY LABELS
|
|
139
|
+
changes.push(
|
|
140
|
+
...diffSecurityLabels<
|
|
141
|
+
CreateSecurityLabelOnEventTrigger | DropSecurityLabelOnEventTrigger
|
|
142
|
+
>(
|
|
143
|
+
mainEventTrigger.security_labels,
|
|
144
|
+
branchEventTrigger.security_labels,
|
|
145
|
+
(securityLabel) =>
|
|
146
|
+
new CreateSecurityLabelOnEventTrigger({
|
|
147
|
+
eventTrigger: branchEventTrigger,
|
|
148
|
+
securityLabel,
|
|
149
|
+
}),
|
|
150
|
+
(securityLabel) =>
|
|
151
|
+
new DropSecurityLabelOnEventTrigger({
|
|
152
|
+
eventTrigger: mainEventTrigger,
|
|
153
|
+
securityLabel,
|
|
154
|
+
}),
|
|
155
|
+
),
|
|
156
|
+
);
|
|
124
157
|
}
|
|
125
158
|
|
|
126
159
|
return changes;
|
|
@@ -2,6 +2,10 @@ import { sql } from "@ts-safeql/sql-tag";
|
|
|
2
2
|
import type { Pool } from "pg";
|
|
3
3
|
import z from "zod";
|
|
4
4
|
import { BasePgModel } from "../base.model.ts";
|
|
5
|
+
import {
|
|
6
|
+
type SecurityLabelProps,
|
|
7
|
+
securityLabelPropsSchema,
|
|
8
|
+
} from "../security-label.types.ts";
|
|
5
9
|
|
|
6
10
|
const EventTriggerEnabledSchema = z.enum([
|
|
7
11
|
"O", // ORIGIN - trigger fires in origin mode
|
|
@@ -19,6 +23,7 @@ const eventTriggerPropsSchema = z.object({
|
|
|
19
23
|
tags: z.array(z.string()).nullable(),
|
|
20
24
|
owner: z.string(),
|
|
21
25
|
comment: z.string().nullable(),
|
|
26
|
+
security_labels: z.array(securityLabelPropsSchema).default([]).optional(),
|
|
22
27
|
});
|
|
23
28
|
|
|
24
29
|
export type EventTriggerProps = z.infer<typeof eventTriggerPropsSchema>;
|
|
@@ -32,6 +37,7 @@ export class EventTrigger extends BasePgModel {
|
|
|
32
37
|
public readonly tags: EventTriggerProps["tags"];
|
|
33
38
|
public readonly owner: EventTriggerProps["owner"];
|
|
34
39
|
public readonly comment: EventTriggerProps["comment"];
|
|
40
|
+
public readonly security_labels: SecurityLabelProps[];
|
|
35
41
|
|
|
36
42
|
constructor(props: EventTriggerProps) {
|
|
37
43
|
super();
|
|
@@ -47,6 +53,7 @@ export class EventTrigger extends BasePgModel {
|
|
|
47
53
|
this.tags = props.tags;
|
|
48
54
|
this.owner = props.owner;
|
|
49
55
|
this.comment = props.comment;
|
|
56
|
+
this.security_labels = props.security_labels ?? [];
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
get stableId(): `eventTrigger:${string}` {
|
|
@@ -68,6 +75,7 @@ export class EventTrigger extends BasePgModel {
|
|
|
68
75
|
tags: this.tags,
|
|
69
76
|
owner: this.owner,
|
|
70
77
|
comment: this.comment,
|
|
78
|
+
security_labels: this.security_labels,
|
|
71
79
|
};
|
|
72
80
|
}
|
|
73
81
|
}
|
|
@@ -90,7 +98,20 @@ select
|
|
|
90
98
|
et.evtenabled as enabled,
|
|
91
99
|
et.evttags as tags,
|
|
92
100
|
et.evtowner::regrole::text as owner,
|
|
93
|
-
obj_description(et.oid, 'pg_event_trigger') as comment
|
|
101
|
+
obj_description(et.oid, 'pg_event_trigger') as comment,
|
|
102
|
+
coalesce(
|
|
103
|
+
(
|
|
104
|
+
select json_agg(
|
|
105
|
+
json_build_object('provider', sl.provider, 'label', sl.label)
|
|
106
|
+
order by sl.provider
|
|
107
|
+
)
|
|
108
|
+
from pg_catalog.pg_seclabel sl
|
|
109
|
+
where sl.objoid = et.oid
|
|
110
|
+
and sl.classoid = 'pg_event_trigger'::regclass
|
|
111
|
+
and sl.objsubid = 0
|
|
112
|
+
),
|
|
113
|
+
'[]'::json
|
|
114
|
+
) as security_labels
|
|
94
115
|
from pg_catalog.pg_event_trigger et
|
|
95
116
|
join pg_catalog.pg_proc p on p.oid = et.evtfoid
|
|
96
117
|
left join extension_oids e on e.objid = et.oid
|
|
@@ -3,7 +3,11 @@ import type { ForeignTable } from "../foreign-table.model.ts";
|
|
|
3
3
|
|
|
4
4
|
abstract class BaseForeignTableChange extends BaseChange {
|
|
5
5
|
abstract readonly foreignTable: ForeignTable;
|
|
6
|
-
abstract readonly scope:
|
|
6
|
+
abstract readonly scope:
|
|
7
|
+
| "object"
|
|
8
|
+
| "comment"
|
|
9
|
+
| "privilege"
|
|
10
|
+
| "security_label";
|
|
7
11
|
readonly objectType: "foreign_table" = "foreign_table";
|
|
8
12
|
}
|
|
9
13
|
|
package/src/core/objects/foreign-data-wrapper/foreign-table/changes/foreign-table.security-label.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { quoteLiteral } from "../../../base.change.ts";
|
|
2
|
+
import type { SecurityLabelProps } from "../../../security-label.types.ts";
|
|
3
|
+
import { stableId } from "../../../utils.ts";
|
|
4
|
+
import type { ForeignTable } from "../foreign-table.model.ts";
|
|
5
|
+
import {
|
|
6
|
+
CreateForeignTableChange,
|
|
7
|
+
DropForeignTableChange,
|
|
8
|
+
} from "./foreign-table.base.ts";
|
|
9
|
+
|
|
10
|
+
export type SecurityLabelForeignTable =
|
|
11
|
+
| CreateSecurityLabelOnForeignTable
|
|
12
|
+
| DropSecurityLabelOnForeignTable;
|
|
13
|
+
|
|
14
|
+
export class CreateSecurityLabelOnForeignTable extends CreateForeignTableChange {
|
|
15
|
+
public readonly foreignTable: ForeignTable;
|
|
16
|
+
public readonly securityLabel: SecurityLabelProps;
|
|
17
|
+
public readonly scope = "security_label" as const;
|
|
18
|
+
|
|
19
|
+
constructor(props: {
|
|
20
|
+
foreignTable: ForeignTable;
|
|
21
|
+
securityLabel: SecurityLabelProps;
|
|
22
|
+
}) {
|
|
23
|
+
super();
|
|
24
|
+
this.foreignTable = props.foreignTable;
|
|
25
|
+
this.securityLabel = props.securityLabel;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get creates() {
|
|
29
|
+
return [
|
|
30
|
+
stableId.securityLabel(
|
|
31
|
+
this.foreignTable.stableId,
|
|
32
|
+
this.securityLabel.provider,
|
|
33
|
+
),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get requires() {
|
|
38
|
+
return [this.foreignTable.stableId];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
serialize(): string {
|
|
42
|
+
return [
|
|
43
|
+
"SECURITY LABEL FOR",
|
|
44
|
+
this.securityLabel.provider,
|
|
45
|
+
"ON FOREIGN TABLE",
|
|
46
|
+
`${this.foreignTable.schema}.${this.foreignTable.name}`,
|
|
47
|
+
"IS",
|
|
48
|
+
quoteLiteral(this.securityLabel.label),
|
|
49
|
+
].join(" ");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class DropSecurityLabelOnForeignTable extends DropForeignTableChange {
|
|
54
|
+
public readonly foreignTable: ForeignTable;
|
|
55
|
+
public readonly securityLabel: SecurityLabelProps;
|
|
56
|
+
public readonly scope = "security_label" as const;
|
|
57
|
+
|
|
58
|
+
constructor(props: {
|
|
59
|
+
foreignTable: ForeignTable;
|
|
60
|
+
securityLabel: SecurityLabelProps;
|
|
61
|
+
}) {
|
|
62
|
+
super();
|
|
63
|
+
this.foreignTable = props.foreignTable;
|
|
64
|
+
this.securityLabel = props.securityLabel;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get drops() {
|
|
68
|
+
return [
|
|
69
|
+
stableId.securityLabel(
|
|
70
|
+
this.foreignTable.stableId,
|
|
71
|
+
this.securityLabel.provider,
|
|
72
|
+
),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get requires() {
|
|
77
|
+
return [
|
|
78
|
+
stableId.securityLabel(
|
|
79
|
+
this.foreignTable.stableId,
|
|
80
|
+
this.securityLabel.provider,
|
|
81
|
+
),
|
|
82
|
+
this.foreignTable.stableId,
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
serialize(): string {
|
|
87
|
+
return [
|
|
88
|
+
"SECURITY LABEL FOR",
|
|
89
|
+
this.securityLabel.provider,
|
|
90
|
+
"ON FOREIGN TABLE",
|
|
91
|
+
`${this.foreignTable.schema}.${this.foreignTable.name}`,
|
|
92
|
+
"IS NULL",
|
|
93
|
+
].join(" ");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { CommentForeignTable } from "./foreign-table.comment.ts";
|
|
|
3
3
|
import type { CreateForeignTable } from "./foreign-table.create.ts";
|
|
4
4
|
import type { DropForeignTable } from "./foreign-table.drop.ts";
|
|
5
5
|
import type { ForeignTablePrivilege } from "./foreign-table.privilege.ts";
|
|
6
|
+
import type { SecurityLabelForeignTable } from "./foreign-table.security-label.ts";
|
|
6
7
|
|
|
7
8
|
/** Union of all foreign-table-related change variants (`objectType: "foreign_table"`). @category Change Types */
|
|
8
9
|
export type ForeignTableChange =
|
|
@@ -10,4 +11,5 @@ export type ForeignTableChange =
|
|
|
10
11
|
| CommentForeignTable
|
|
11
12
|
| CreateForeignTable
|
|
12
13
|
| DropForeignTable
|
|
13
|
-
| ForeignTablePrivilege
|
|
14
|
+
| ForeignTablePrivilege
|
|
15
|
+
| SecurityLabelForeignTable;
|