@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 z from "zod";
|
|
|
3
3
|
import { BasePgModel, type TableLikeObject } from "../base.model.ts";
|
|
4
4
|
import { type PrivilegeProps } from "../base.privilege-diff.ts";
|
|
5
5
|
import { type ExtractRetryOptions } from "../extract-with-retry.ts";
|
|
6
|
+
import { type SecurityLabelProps } from "../security-label.types.ts";
|
|
6
7
|
declare const materializedViewPropsSchema: z.ZodObject<{
|
|
7
8
|
schema: z.ZodString;
|
|
8
9
|
name: z.ZodString;
|
|
@@ -42,6 +43,10 @@ declare const materializedViewPropsSchema: z.ZodObject<{
|
|
|
42
43
|
collation: z.ZodNullable<z.ZodString>;
|
|
43
44
|
default: z.ZodNullable<z.ZodString>;
|
|
44
45
|
comment: z.ZodNullable<z.ZodString>;
|
|
46
|
+
security_labels: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
47
|
+
provider: z.ZodString;
|
|
48
|
+
label: z.ZodString;
|
|
49
|
+
}, z.z.core.$strip>>>;
|
|
45
50
|
}, z.z.core.$strip>>;
|
|
46
51
|
privileges: z.ZodArray<z.ZodObject<{
|
|
47
52
|
grantee: z.ZodString;
|
|
@@ -49,6 +54,10 @@ declare const materializedViewPropsSchema: z.ZodObject<{
|
|
|
49
54
|
grantable: z.ZodBoolean;
|
|
50
55
|
columns: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
51
56
|
}, z.z.core.$strip>>;
|
|
57
|
+
security_labels: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
58
|
+
provider: z.ZodString;
|
|
59
|
+
label: z.ZodString;
|
|
60
|
+
}, z.z.core.$strip>>>>;
|
|
52
61
|
}, z.z.core.$strip>;
|
|
53
62
|
type MaterializedViewPrivilegeProps = PrivilegeProps;
|
|
54
63
|
export type MaterializedViewProps = z.infer<typeof materializedViewPropsSchema>;
|
|
@@ -71,6 +80,7 @@ export declare class MaterializedView extends BasePgModel implements TableLikeOb
|
|
|
71
80
|
readonly comment: MaterializedViewProps["comment"];
|
|
72
81
|
readonly columns: MaterializedViewProps["columns"];
|
|
73
82
|
readonly privileges: MaterializedViewPrivilegeProps[];
|
|
83
|
+
readonly security_labels: SecurityLabelProps[];
|
|
74
84
|
constructor(props: MaterializedViewProps);
|
|
75
85
|
get stableId(): `materializedView:${string}`;
|
|
76
86
|
get identityFields(): {
|
|
@@ -109,6 +119,10 @@ export declare class MaterializedView extends BasePgModel implements TableLikeOb
|
|
|
109
119
|
collation: string | null;
|
|
110
120
|
default: string | null;
|
|
111
121
|
comment: string | null;
|
|
122
|
+
security_labels?: {
|
|
123
|
+
provider: string;
|
|
124
|
+
label: string;
|
|
125
|
+
}[] | undefined;
|
|
112
126
|
}[];
|
|
113
127
|
privileges: {
|
|
114
128
|
grantee: string;
|
|
@@ -116,6 +130,10 @@ export declare class MaterializedView extends BasePgModel implements TableLikeOb
|
|
|
116
130
|
grantable: boolean;
|
|
117
131
|
columns?: string[] | null | undefined;
|
|
118
132
|
}[];
|
|
133
|
+
security_labels: {
|
|
134
|
+
provider: string;
|
|
135
|
+
label: string;
|
|
136
|
+
}[];
|
|
119
137
|
};
|
|
120
138
|
stableSnapshot(): {
|
|
121
139
|
identity: {
|
|
@@ -126,6 +144,10 @@ export declare class MaterializedView extends BasePgModel implements TableLikeOb
|
|
|
126
144
|
columns: {
|
|
127
145
|
[x: string]: unknown;
|
|
128
146
|
}[];
|
|
147
|
+
security_labels: {
|
|
148
|
+
provider: string;
|
|
149
|
+
label: string;
|
|
150
|
+
}[];
|
|
129
151
|
definition: string;
|
|
130
152
|
row_security: boolean;
|
|
131
153
|
force_row_security: boolean;
|
|
@@ -3,6 +3,7 @@ import z from "zod";
|
|
|
3
3
|
import { BasePgModel, columnPropsSchema, } from "../base.model.js";
|
|
4
4
|
import { privilegePropsSchema, } from "../base.privilege-diff.js";
|
|
5
5
|
import { extractWithDefinitionRetry, } from "../extract-with-retry.js";
|
|
6
|
+
import { normalizeSecurityLabels, securityLabelPropsSchema, } from "../security-label.types.js";
|
|
6
7
|
import { ReplicaIdentitySchema } from "../table/table.model.js";
|
|
7
8
|
const materializedViewPropsSchema = z.object({
|
|
8
9
|
schema: z.string(),
|
|
@@ -23,6 +24,7 @@ const materializedViewPropsSchema = z.object({
|
|
|
23
24
|
comment: z.string().nullable(),
|
|
24
25
|
columns: z.array(columnPropsSchema),
|
|
25
26
|
privileges: z.array(privilegePropsSchema),
|
|
27
|
+
security_labels: z.array(securityLabelPropsSchema).default([]).optional(),
|
|
26
28
|
});
|
|
27
29
|
// pg_get_viewdef(oid) can return NULL when the underlying matview (or its
|
|
28
30
|
// pg_rewrite row) is dropped between catalog scan and resolution, or under
|
|
@@ -51,6 +53,7 @@ export class MaterializedView extends BasePgModel {
|
|
|
51
53
|
comment;
|
|
52
54
|
columns;
|
|
53
55
|
privileges;
|
|
56
|
+
security_labels;
|
|
54
57
|
constructor(props) {
|
|
55
58
|
super();
|
|
56
59
|
// Identity fields
|
|
@@ -73,6 +76,7 @@ export class MaterializedView extends BasePgModel {
|
|
|
73
76
|
this.comment = props.comment;
|
|
74
77
|
this.columns = props.columns;
|
|
75
78
|
this.privileges = props.privileges;
|
|
79
|
+
this.security_labels = props.security_labels ?? [];
|
|
76
80
|
}
|
|
77
81
|
get stableId() {
|
|
78
82
|
return `materializedView:${this.schema}.${this.name}`;
|
|
@@ -101,6 +105,7 @@ export class MaterializedView extends BasePgModel {
|
|
|
101
105
|
comment: this.comment,
|
|
102
106
|
columns: this.columns,
|
|
103
107
|
privileges: this.privileges,
|
|
108
|
+
security_labels: this.security_labels,
|
|
104
109
|
};
|
|
105
110
|
}
|
|
106
111
|
stableSnapshot() {
|
|
@@ -119,6 +124,7 @@ export class MaterializedView extends BasePgModel {
|
|
|
119
124
|
data: {
|
|
120
125
|
...this.dataFields,
|
|
121
126
|
columns: normalizeColumns(),
|
|
127
|
+
security_labels: normalizeSecurityLabels(this.security_labels),
|
|
122
128
|
},
|
|
123
129
|
};
|
|
124
130
|
}
|
|
@@ -219,7 +225,20 @@ select
|
|
|
219
225
|
join lateral aclexplode(src.acl) as x(grantor, grantee, privilege_type, is_grantable) on true
|
|
220
226
|
group by x.grantee, x.privilege_type
|
|
221
227
|
) as grp
|
|
222
|
-
), '[]') as privileges
|
|
228
|
+
), '[]') as privileges,
|
|
229
|
+
coalesce(
|
|
230
|
+
(
|
|
231
|
+
select json_agg(
|
|
232
|
+
json_build_object('provider', sl.provider, 'label', sl.label)
|
|
233
|
+
order by sl.provider
|
|
234
|
+
)
|
|
235
|
+
from pg_catalog.pg_seclabel sl
|
|
236
|
+
where sl.objoid = c.oid
|
|
237
|
+
and sl.classoid = 'pg_class'::regclass
|
|
238
|
+
and sl.objsubid = 0
|
|
239
|
+
),
|
|
240
|
+
'[]'::json
|
|
241
|
+
) as security_labels
|
|
223
242
|
from
|
|
224
243
|
pg_catalog.pg_class c
|
|
225
244
|
left outer join extension_oids e on c.oid = e.objid
|
|
@@ -2,7 +2,7 @@ import { BaseChange } from "../../base.change.ts";
|
|
|
2
2
|
import type { Procedure } from "../procedure.model.ts";
|
|
3
3
|
declare abstract class BaseProcedureChange extends BaseChange {
|
|
4
4
|
abstract readonly procedure: Procedure;
|
|
5
|
-
abstract readonly scope: "object" | "comment" | "privilege";
|
|
5
|
+
abstract readonly scope: "object" | "comment" | "privilege" | "security_label";
|
|
6
6
|
readonly objectType: "procedure";
|
|
7
7
|
}
|
|
8
8
|
export declare abstract class CreateProcedureChange extends BaseProcedureChange {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SecurityLabelProps } from "../../security-label.types.ts";
|
|
2
|
+
import type { Procedure } from "../procedure.model.ts";
|
|
3
|
+
import { CreateProcedureChange, DropProcedureChange } from "./procedure.base.ts";
|
|
4
|
+
export type SecurityLabelProcedure = CreateSecurityLabelOnProcedure | DropSecurityLabelOnProcedure;
|
|
5
|
+
export declare class CreateSecurityLabelOnProcedure extends CreateProcedureChange {
|
|
6
|
+
readonly procedure: Procedure;
|
|
7
|
+
readonly securityLabel: SecurityLabelProps;
|
|
8
|
+
readonly scope: "security_label";
|
|
9
|
+
constructor(props: {
|
|
10
|
+
procedure: Procedure;
|
|
11
|
+
securityLabel: SecurityLabelProps;
|
|
12
|
+
});
|
|
13
|
+
get creates(): `securityLabel:${string}::provider:${string}`[];
|
|
14
|
+
get requires(): `procedure:${string}`[];
|
|
15
|
+
serialize(): string;
|
|
16
|
+
}
|
|
17
|
+
export declare class DropSecurityLabelOnProcedure extends DropProcedureChange {
|
|
18
|
+
readonly procedure: Procedure;
|
|
19
|
+
readonly securityLabel: SecurityLabelProps;
|
|
20
|
+
readonly scope: "security_label";
|
|
21
|
+
constructor(props: {
|
|
22
|
+
procedure: Procedure;
|
|
23
|
+
securityLabel: SecurityLabelProps;
|
|
24
|
+
});
|
|
25
|
+
get drops(): `securityLabel:${string}::provider:${string}`[];
|
|
26
|
+
get requires(): (`securityLabel:${string}::provider:${string}` | `procedure:${string}`)[];
|
|
27
|
+
serialize(): string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { quoteLiteral } from "../../base.change.js";
|
|
2
|
+
import { stableId } from "../../utils.js";
|
|
3
|
+
import { CreateProcedureChange, DropProcedureChange, } from "./procedure.base.js";
|
|
4
|
+
function targetKeyword(p) {
|
|
5
|
+
return p.kind === "p" ? "PROCEDURE" : "FUNCTION";
|
|
6
|
+
}
|
|
7
|
+
function procedureIdentity(p) {
|
|
8
|
+
return `${p.schema}.${p.name}(${(p.argument_types ?? []).join(",")})`;
|
|
9
|
+
}
|
|
10
|
+
export class CreateSecurityLabelOnProcedure extends CreateProcedureChange {
|
|
11
|
+
procedure;
|
|
12
|
+
securityLabel;
|
|
13
|
+
scope = "security_label";
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super();
|
|
16
|
+
this.procedure = props.procedure;
|
|
17
|
+
this.securityLabel = props.securityLabel;
|
|
18
|
+
}
|
|
19
|
+
get creates() {
|
|
20
|
+
return [
|
|
21
|
+
stableId.securityLabel(this.procedure.stableId, this.securityLabel.provider),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
get requires() {
|
|
25
|
+
return [this.procedure.stableId];
|
|
26
|
+
}
|
|
27
|
+
serialize() {
|
|
28
|
+
return [
|
|
29
|
+
"SECURITY LABEL FOR",
|
|
30
|
+
this.securityLabel.provider,
|
|
31
|
+
"ON",
|
|
32
|
+
targetKeyword(this.procedure),
|
|
33
|
+
procedureIdentity(this.procedure),
|
|
34
|
+
"IS",
|
|
35
|
+
quoteLiteral(this.securityLabel.label),
|
|
36
|
+
].join(" ");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export class DropSecurityLabelOnProcedure extends DropProcedureChange {
|
|
40
|
+
procedure;
|
|
41
|
+
securityLabel;
|
|
42
|
+
scope = "security_label";
|
|
43
|
+
constructor(props) {
|
|
44
|
+
super();
|
|
45
|
+
this.procedure = props.procedure;
|
|
46
|
+
this.securityLabel = props.securityLabel;
|
|
47
|
+
}
|
|
48
|
+
get drops() {
|
|
49
|
+
return [
|
|
50
|
+
stableId.securityLabel(this.procedure.stableId, this.securityLabel.provider),
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
get requires() {
|
|
54
|
+
return [
|
|
55
|
+
stableId.securityLabel(this.procedure.stableId, this.securityLabel.provider),
|
|
56
|
+
this.procedure.stableId,
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
serialize() {
|
|
60
|
+
return [
|
|
61
|
+
"SECURITY LABEL FOR",
|
|
62
|
+
this.securityLabel.provider,
|
|
63
|
+
"ON",
|
|
64
|
+
targetKeyword(this.procedure),
|
|
65
|
+
procedureIdentity(this.procedure),
|
|
66
|
+
"IS NULL",
|
|
67
|
+
].join(" ");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -3,5 +3,6 @@ import type { CommentProcedure } from "./procedure.comment.ts";
|
|
|
3
3
|
import type { CreateProcedure } from "./procedure.create.ts";
|
|
4
4
|
import type { DropProcedure } from "./procedure.drop.ts";
|
|
5
5
|
import type { ProcedurePrivilege } from "./procedure.privilege.ts";
|
|
6
|
+
import type { SecurityLabelProcedure } from "./procedure.security-label.ts";
|
|
6
7
|
/** Union of all procedure-related change variants (`objectType: "procedure"`). @category Change Types */
|
|
7
|
-
export type ProcedureChange = AlterProcedure | CommentProcedure | CreateProcedure | DropProcedure | ProcedurePrivilege;
|
|
8
|
+
export type ProcedureChange = AlterProcedure | CommentProcedure | CreateProcedure | DropProcedure | ProcedurePrivilege | SecurityLabelProcedure;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { diffObjects } from "../base.diff.js";
|
|
2
2
|
import { diffPrivileges, emitObjectPrivilegeChanges, filterPublicBuiltInDefaults, } from "../base.privilege-diff.js";
|
|
3
|
+
import { diffSecurityLabels } from "../security-label.types.js";
|
|
3
4
|
import { deepEqual, hasNonAlterableChanges } from "../utils.js";
|
|
4
5
|
import { AlterProcedureChangeOwner, AlterProcedureSetConfig, AlterProcedureSetLeakproof, AlterProcedureSetParallel, AlterProcedureSetSecurity, AlterProcedureSetStrictness, AlterProcedureSetVolatility, } from "./changes/procedure.alter.js";
|
|
5
6
|
import { CreateCommentOnProcedure, DropCommentOnProcedure, } from "./changes/procedure.comment.js";
|
|
6
7
|
import { CreateProcedure } from "./changes/procedure.create.js";
|
|
7
8
|
import { DropProcedure } from "./changes/procedure.drop.js";
|
|
8
9
|
import { GrantProcedurePrivileges, RevokeGrantOptionProcedurePrivileges, RevokeProcedurePrivileges, } from "./changes/procedure.privilege.js";
|
|
10
|
+
import { CreateSecurityLabelOnProcedure, DropSecurityLabelOnProcedure, } from "./changes/procedure.security-label.js";
|
|
9
11
|
/**
|
|
10
12
|
* Diff two sets of procedures from main and branch catalogs.
|
|
11
13
|
*
|
|
@@ -30,6 +32,12 @@ export function diffProcedures(ctx, main, branch) {
|
|
|
30
32
|
if (proc.comment !== null) {
|
|
31
33
|
changes.push(new CreateCommentOnProcedure({ procedure: proc }));
|
|
32
34
|
}
|
|
35
|
+
for (const label of proc.security_labels) {
|
|
36
|
+
changes.push(new CreateSecurityLabelOnProcedure({
|
|
37
|
+
procedure: proc,
|
|
38
|
+
securityLabel: label,
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
33
41
|
// PRIVILEGES: For created objects, compare against default privileges state
|
|
34
42
|
// The migration script will run ALTER DEFAULT PRIVILEGES before CREATE (via constraint spec),
|
|
35
43
|
// so objects are created with the default privileges state in effect.
|
|
@@ -139,6 +147,14 @@ export function diffProcedures(ctx, main, branch) {
|
|
|
139
147
|
changes.push(new CreateCommentOnProcedure({ procedure: branchProcedure }));
|
|
140
148
|
}
|
|
141
149
|
}
|
|
150
|
+
// SECURITY LABELS
|
|
151
|
+
changes.push(...diffSecurityLabels(mainProcedure.security_labels, branchProcedure.security_labels, (securityLabel) => new CreateSecurityLabelOnProcedure({
|
|
152
|
+
procedure: branchProcedure,
|
|
153
|
+
securityLabel,
|
|
154
|
+
}), (securityLabel) => new DropSecurityLabelOnProcedure({
|
|
155
|
+
procedure: mainProcedure,
|
|
156
|
+
securityLabel,
|
|
157
|
+
})));
|
|
142
158
|
// SECURITY DEFINER/INVOKER
|
|
143
159
|
if (mainProcedure.security_definer !== branchProcedure.security_definer) {
|
|
144
160
|
changes.push(new AlterProcedureSetSecurity({
|
|
@@ -3,6 +3,7 @@ import z from "zod";
|
|
|
3
3
|
import { BasePgModel } from "../base.model.ts";
|
|
4
4
|
import { type PrivilegeProps } from "../base.privilege-diff.ts";
|
|
5
5
|
import { type ExtractRetryOptions } from "../extract-with-retry.ts";
|
|
6
|
+
import { type SecurityLabelProps } from "../security-label.types.ts";
|
|
6
7
|
declare const procedurePropsSchema: z.ZodObject<{
|
|
7
8
|
schema: z.ZodString;
|
|
8
9
|
name: z.ZodString;
|
|
@@ -57,6 +58,10 @@ declare const procedurePropsSchema: z.ZodObject<{
|
|
|
57
58
|
grantable: z.ZodBoolean;
|
|
58
59
|
columns: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
59
60
|
}, z.z.core.$strip>>;
|
|
61
|
+
security_labels: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
62
|
+
provider: z.ZodString;
|
|
63
|
+
label: z.ZodString;
|
|
64
|
+
}, z.z.core.$strip>>>>;
|
|
60
65
|
}, z.z.core.$strip>;
|
|
61
66
|
type ProcedurePrivilegeProps = PrivilegeProps;
|
|
62
67
|
export type ProcedureProps = z.infer<typeof procedurePropsSchema>;
|
|
@@ -90,6 +95,7 @@ export declare class Procedure extends BasePgModel {
|
|
|
90
95
|
readonly owner: ProcedureProps["owner"];
|
|
91
96
|
readonly comment: ProcedureProps["comment"];
|
|
92
97
|
readonly privileges: ProcedurePrivilegeProps[];
|
|
98
|
+
readonly security_labels: SecurityLabelProps[];
|
|
93
99
|
constructor(props: ProcedureProps);
|
|
94
100
|
get stableId(): `procedure:${string}`;
|
|
95
101
|
get identityFields(): {
|
|
@@ -127,6 +133,10 @@ export declare class Procedure extends BasePgModel {
|
|
|
127
133
|
grantable: boolean;
|
|
128
134
|
columns?: string[] | null | undefined;
|
|
129
135
|
}[];
|
|
136
|
+
security_labels: {
|
|
137
|
+
provider: string;
|
|
138
|
+
label: string;
|
|
139
|
+
}[];
|
|
130
140
|
};
|
|
131
141
|
}
|
|
132
142
|
export declare function extractProcedures(pool: Pool, options?: ExtractRetryOptions): Promise<Procedure[]>;
|
|
@@ -3,6 +3,7 @@ import z from "zod";
|
|
|
3
3
|
import { BasePgModel } from "../base.model.js";
|
|
4
4
|
import { privilegePropsSchema, } from "../base.privilege-diff.js";
|
|
5
5
|
import { extractWithDefinitionRetry, } from "../extract-with-retry.js";
|
|
6
|
+
import { securityLabelPropsSchema, } from "../security-label.types.js";
|
|
6
7
|
const FunctionKindSchema = z.enum([
|
|
7
8
|
"f", // function
|
|
8
9
|
"p", // procedure
|
|
@@ -56,6 +57,7 @@ const procedurePropsSchema = z.object({
|
|
|
56
57
|
owner: z.string(),
|
|
57
58
|
comment: z.string().nullable(),
|
|
58
59
|
privileges: z.array(privilegePropsSchema),
|
|
60
|
+
security_labels: z.array(securityLabelPropsSchema).default([]).optional(),
|
|
59
61
|
});
|
|
60
62
|
// pg_get_functiondef(oid) can return NULL when the function (its pg_proc
|
|
61
63
|
// row) is dropped between catalog scan and resolution, or under transient
|
|
@@ -95,6 +97,7 @@ export class Procedure extends BasePgModel {
|
|
|
95
97
|
owner;
|
|
96
98
|
comment;
|
|
97
99
|
privileges;
|
|
100
|
+
security_labels;
|
|
98
101
|
constructor(props) {
|
|
99
102
|
super();
|
|
100
103
|
// Identity fields
|
|
@@ -128,6 +131,7 @@ export class Procedure extends BasePgModel {
|
|
|
128
131
|
this.owner = props.owner;
|
|
129
132
|
this.comment = props.comment;
|
|
130
133
|
this.privileges = props.privileges;
|
|
134
|
+
this.security_labels = props.security_labels ?? [];
|
|
131
135
|
}
|
|
132
136
|
get stableId() {
|
|
133
137
|
const args = this.argument_types?.join(",") ?? "";
|
|
@@ -169,6 +173,7 @@ export class Procedure extends BasePgModel {
|
|
|
169
173
|
owner: this.owner,
|
|
170
174
|
comment: this.comment,
|
|
171
175
|
privileges: this.privileges,
|
|
176
|
+
security_labels: this.security_labels,
|
|
172
177
|
};
|
|
173
178
|
}
|
|
174
179
|
}
|
|
@@ -238,7 +243,20 @@ select
|
|
|
238
243
|
)
|
|
239
244
|
from lateral aclexplode(COALESCE(p.proacl, acldefault('f', p.proowner))) as x(grantor, grantee, privilege_type, is_grantable)
|
|
240
245
|
), '[]'
|
|
241
|
-
) as privileges
|
|
246
|
+
) as privileges,
|
|
247
|
+
coalesce(
|
|
248
|
+
(
|
|
249
|
+
select json_agg(
|
|
250
|
+
json_build_object('provider', sl.provider, 'label', sl.label)
|
|
251
|
+
order by sl.provider
|
|
252
|
+
)
|
|
253
|
+
from pg_catalog.pg_seclabel sl
|
|
254
|
+
where sl.objoid = p.oid
|
|
255
|
+
and sl.classoid = 'pg_proc'::regclass
|
|
256
|
+
and sl.objsubid = 0
|
|
257
|
+
),
|
|
258
|
+
'[]'::json
|
|
259
|
+
) as security_labels
|
|
242
260
|
from
|
|
243
261
|
pg_catalog.pg_proc p
|
|
244
262
|
inner join pg_catalog.pg_language l on l.oid = p.prolang
|
|
@@ -2,7 +2,7 @@ import { BaseChange } from "../../base.change.ts";
|
|
|
2
2
|
import type { Publication } from "../publication.model.ts";
|
|
3
3
|
declare abstract class BasePublicationChange extends BaseChange {
|
|
4
4
|
abstract readonly publication: Publication;
|
|
5
|
-
abstract readonly scope: "object" | "comment";
|
|
5
|
+
abstract readonly scope: "object" | "comment" | "security_label";
|
|
6
6
|
readonly objectType: "publication";
|
|
7
7
|
}
|
|
8
8
|
export declare abstract class CreatePublicationChange extends BasePublicationChange {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SecurityLabelProps } from "../../security-label.types.ts";
|
|
2
|
+
import type { Publication } from "../publication.model.ts";
|
|
3
|
+
import { CreatePublicationChange, DropPublicationChange } from "./publication.base.ts";
|
|
4
|
+
export type SecurityLabelPublication = CreateSecurityLabelOnPublication | DropSecurityLabelOnPublication;
|
|
5
|
+
export declare class CreateSecurityLabelOnPublication extends CreatePublicationChange {
|
|
6
|
+
readonly publication: Publication;
|
|
7
|
+
readonly securityLabel: SecurityLabelProps;
|
|
8
|
+
readonly scope: "security_label";
|
|
9
|
+
constructor(props: {
|
|
10
|
+
publication: Publication;
|
|
11
|
+
securityLabel: SecurityLabelProps;
|
|
12
|
+
});
|
|
13
|
+
get creates(): `securityLabel:${string}::provider:${string}`[];
|
|
14
|
+
get requires(): `publication:${string}`[];
|
|
15
|
+
serialize(): string;
|
|
16
|
+
}
|
|
17
|
+
export declare class DropSecurityLabelOnPublication extends DropPublicationChange {
|
|
18
|
+
readonly publication: Publication;
|
|
19
|
+
readonly securityLabel: SecurityLabelProps;
|
|
20
|
+
readonly scope: "security_label";
|
|
21
|
+
constructor(props: {
|
|
22
|
+
publication: Publication;
|
|
23
|
+
securityLabel: SecurityLabelProps;
|
|
24
|
+
});
|
|
25
|
+
get drops(): `securityLabel:${string}::provider:${string}`[];
|
|
26
|
+
get requires(): (`securityLabel:${string}::provider:${string}` | `publication:${string}`)[];
|
|
27
|
+
serialize(): string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { quoteLiteral } from "../../base.change.js";
|
|
2
|
+
import { stableId } from "../../utils.js";
|
|
3
|
+
import { CreatePublicationChange, DropPublicationChange, } from "./publication.base.js";
|
|
4
|
+
export class CreateSecurityLabelOnPublication extends CreatePublicationChange {
|
|
5
|
+
publication;
|
|
6
|
+
securityLabel;
|
|
7
|
+
scope = "security_label";
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super();
|
|
10
|
+
this.publication = props.publication;
|
|
11
|
+
this.securityLabel = props.securityLabel;
|
|
12
|
+
}
|
|
13
|
+
get creates() {
|
|
14
|
+
return [
|
|
15
|
+
stableId.securityLabel(this.publication.stableId, this.securityLabel.provider),
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
get requires() {
|
|
19
|
+
return [this.publication.stableId];
|
|
20
|
+
}
|
|
21
|
+
serialize() {
|
|
22
|
+
return [
|
|
23
|
+
"SECURITY LABEL FOR",
|
|
24
|
+
this.securityLabel.provider,
|
|
25
|
+
"ON PUBLICATION",
|
|
26
|
+
this.publication.name,
|
|
27
|
+
"IS",
|
|
28
|
+
quoteLiteral(this.securityLabel.label),
|
|
29
|
+
].join(" ");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class DropSecurityLabelOnPublication extends DropPublicationChange {
|
|
33
|
+
publication;
|
|
34
|
+
securityLabel;
|
|
35
|
+
scope = "security_label";
|
|
36
|
+
constructor(props) {
|
|
37
|
+
super();
|
|
38
|
+
this.publication = props.publication;
|
|
39
|
+
this.securityLabel = props.securityLabel;
|
|
40
|
+
}
|
|
41
|
+
get drops() {
|
|
42
|
+
return [
|
|
43
|
+
stableId.securityLabel(this.publication.stableId, this.securityLabel.provider),
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
get requires() {
|
|
47
|
+
return [
|
|
48
|
+
stableId.securityLabel(this.publication.stableId, this.securityLabel.provider),
|
|
49
|
+
this.publication.stableId,
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
serialize() {
|
|
53
|
+
return [
|
|
54
|
+
"SECURITY LABEL FOR",
|
|
55
|
+
this.securityLabel.provider,
|
|
56
|
+
"ON PUBLICATION",
|
|
57
|
+
this.publication.name,
|
|
58
|
+
"IS NULL",
|
|
59
|
+
].join(" ");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -2,5 +2,6 @@ import type { AlterPublicationAddSchemas, AlterPublicationAddTables, AlterPublic
|
|
|
2
2
|
import type { CommentPublication } from "./publication.comment.ts";
|
|
3
3
|
import type { CreatePublication } from "./publication.create.ts";
|
|
4
4
|
import type { DropPublication } from "./publication.drop.ts";
|
|
5
|
+
import type { SecurityLabelPublication } from "./publication.security-label.ts";
|
|
5
6
|
/** Union of all publication-related change variants (`objectType: "publication"`). @category Change Types */
|
|
6
|
-
export type PublicationChange = AlterPublicationAddSchemas | AlterPublicationAddTables | AlterPublicationDropSchemas | AlterPublicationDropTables | AlterPublicationSetList | AlterPublicationSetOptions | AlterPublicationSetOwner | CommentPublication | CreatePublication | DropPublication;
|
|
7
|
+
export type PublicationChange = AlterPublicationAddSchemas | AlterPublicationAddTables | AlterPublicationDropSchemas | AlterPublicationDropTables | AlterPublicationSetList | AlterPublicationSetOptions | AlterPublicationSetOwner | CommentPublication | CreatePublication | DropPublication | SecurityLabelPublication;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { diffObjects } from "../base.diff.js";
|
|
2
|
+
import { diffSecurityLabels } from "../security-label.types.js";
|
|
2
3
|
import { deepEqual } from "../utils.js";
|
|
3
4
|
import { AlterPublicationAddSchemas, AlterPublicationAddTables, AlterPublicationDropSchemas, AlterPublicationDropTables, AlterPublicationSetOptions, AlterPublicationSetOwner, } from "./changes/publication.alter.js";
|
|
4
5
|
import { CreateCommentOnPublication, DropCommentOnPublication, } from "./changes/publication.comment.js";
|
|
5
6
|
import { CreatePublication } from "./changes/publication.create.js";
|
|
6
7
|
import { DropPublication } from "./changes/publication.drop.js";
|
|
8
|
+
import { CreateSecurityLabelOnPublication, DropSecurityLabelOnPublication, } from "./changes/publication.security-label.js";
|
|
7
9
|
export function diffPublications(ctx, main, branch) {
|
|
8
10
|
const { created, dropped, altered } = diffObjects(main, branch);
|
|
9
11
|
const changes = [];
|
|
@@ -21,6 +23,12 @@ export function diffPublications(ctx, main, branch) {
|
|
|
21
23
|
if (publication.comment !== null) {
|
|
22
24
|
changes.push(new CreateCommentOnPublication({ publication }));
|
|
23
25
|
}
|
|
26
|
+
for (const label of publication.security_labels) {
|
|
27
|
+
changes.push(new CreateSecurityLabelOnPublication({
|
|
28
|
+
publication,
|
|
29
|
+
securityLabel: label,
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
for (const id of dropped) {
|
|
26
34
|
changes.push(new DropPublication({ publication: main[id] }));
|
|
@@ -107,6 +115,14 @@ export function diffPublications(ctx, main, branch) {
|
|
|
107
115
|
changes.push(new CreateCommentOnPublication({ publication: branchPublication }));
|
|
108
116
|
}
|
|
109
117
|
}
|
|
118
|
+
// SECURITY LABELS
|
|
119
|
+
changes.push(...diffSecurityLabels(mainPublication.security_labels, branchPublication.security_labels, (securityLabel) => new CreateSecurityLabelOnPublication({
|
|
120
|
+
publication: branchPublication,
|
|
121
|
+
securityLabel,
|
|
122
|
+
}), (securityLabel) => new DropSecurityLabelOnPublication({
|
|
123
|
+
publication: mainPublication,
|
|
124
|
+
securityLabel,
|
|
125
|
+
})));
|
|
110
126
|
}
|
|
111
127
|
return changes;
|
|
112
128
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Pool } from "pg";
|
|
2
2
|
import z from "zod";
|
|
3
3
|
import { BasePgModel } from "../base.model.ts";
|
|
4
|
+
import { type SecurityLabelProps } from "../security-label.types.ts";
|
|
4
5
|
declare const publicationTablePropsSchema: z.ZodObject<{
|
|
5
6
|
schema: z.ZodString;
|
|
6
7
|
name: z.ZodString;
|
|
@@ -24,6 +25,10 @@ declare const publicationPropsSchema: z.ZodObject<{
|
|
|
24
25
|
row_filter: z.ZodNullable<z.ZodString>;
|
|
25
26
|
}, z.z.core.$strip>>;
|
|
26
27
|
schemas: z.ZodArray<z.ZodString>;
|
|
28
|
+
security_labels: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
29
|
+
provider: z.ZodString;
|
|
30
|
+
label: z.ZodString;
|
|
31
|
+
}, z.z.core.$strip>>>>;
|
|
27
32
|
}, z.z.core.$strip>;
|
|
28
33
|
export type PublicationTableProps = z.infer<typeof publicationTablePropsSchema>;
|
|
29
34
|
export type PublicationProps = z.infer<typeof publicationPropsSchema>;
|
|
@@ -44,6 +49,7 @@ export declare class Publication extends BasePgModel {
|
|
|
44
49
|
readonly publish_via_partition_root: PublicationProps["publish_via_partition_root"];
|
|
45
50
|
readonly tables: PublicationTableProps[];
|
|
46
51
|
readonly schemas: PublicationProps["schemas"];
|
|
52
|
+
readonly security_labels: SecurityLabelProps[];
|
|
47
53
|
constructor(props: PublicationProps);
|
|
48
54
|
get stableId(): `publication:${string}`;
|
|
49
55
|
get identityFields(): {
|
|
@@ -65,6 +71,10 @@ export declare class Publication extends BasePgModel {
|
|
|
65
71
|
row_filter: string | null;
|
|
66
72
|
}[];
|
|
67
73
|
schemas: string[];
|
|
74
|
+
security_labels: {
|
|
75
|
+
provider: string;
|
|
76
|
+
label: string;
|
|
77
|
+
}[];
|
|
68
78
|
};
|
|
69
79
|
stableSnapshot(): {
|
|
70
80
|
identity: {
|
|
@@ -78,6 +88,10 @@ export declare class Publication extends BasePgModel {
|
|
|
78
88
|
row_filter: string | null;
|
|
79
89
|
}[];
|
|
80
90
|
schemas: string[];
|
|
91
|
+
security_labels: {
|
|
92
|
+
provider: string;
|
|
93
|
+
label: string;
|
|
94
|
+
}[];
|
|
81
95
|
owner: string;
|
|
82
96
|
comment: string | null;
|
|
83
97
|
all_tables: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sql } from "@ts-safeql/sql-tag";
|
|
2
2
|
import z from "zod";
|
|
3
3
|
import { BasePgModel } from "../base.model.js";
|
|
4
|
+
import { normalizeSecurityLabels, securityLabelPropsSchema, } from "../security-label.types.js";
|
|
4
5
|
const publicationTablePropsSchema = z.object({
|
|
5
6
|
schema: z.string(),
|
|
6
7
|
name: z.string(),
|
|
@@ -19,6 +20,7 @@ const publicationPropsSchema = z.object({
|
|
|
19
20
|
publish_via_partition_root: z.boolean(),
|
|
20
21
|
tables: z.array(publicationTablePropsSchema),
|
|
21
22
|
schemas: z.array(z.string()),
|
|
23
|
+
security_labels: z.array(securityLabelPropsSchema).default([]).optional(),
|
|
22
24
|
});
|
|
23
25
|
/**
|
|
24
26
|
* Logical replication publication definition extracted from pg_publication.
|
|
@@ -37,6 +39,7 @@ export class Publication extends BasePgModel {
|
|
|
37
39
|
publish_via_partition_root;
|
|
38
40
|
tables;
|
|
39
41
|
schemas;
|
|
42
|
+
security_labels;
|
|
40
43
|
constructor(props) {
|
|
41
44
|
super();
|
|
42
45
|
this.name = props.name;
|
|
@@ -60,6 +63,7 @@ export class Publication extends BasePgModel {
|
|
|
60
63
|
return a.schema.localeCompare(b.schema) || a.name.localeCompare(b.name);
|
|
61
64
|
});
|
|
62
65
|
this.schemas = [...props.schemas].sort((a, b) => a.localeCompare(b));
|
|
66
|
+
this.security_labels = props.security_labels ?? [];
|
|
63
67
|
}
|
|
64
68
|
get stableId() {
|
|
65
69
|
return `publication:${this.name}`;
|
|
@@ -81,6 +85,7 @@ export class Publication extends BasePgModel {
|
|
|
81
85
|
publish_via_partition_root: this.publish_via_partition_root,
|
|
82
86
|
tables: this.tables,
|
|
83
87
|
schemas: this.schemas,
|
|
88
|
+
security_labels: this.security_labels,
|
|
84
89
|
};
|
|
85
90
|
}
|
|
86
91
|
stableSnapshot() {
|
|
@@ -98,6 +103,7 @@ export class Publication extends BasePgModel {
|
|
|
98
103
|
...this.dataFields,
|
|
99
104
|
tables: normalizedTables.sort((a, b) => a.schema.localeCompare(b.schema) || a.name.localeCompare(b.name)),
|
|
100
105
|
schemas: [...this.schemas].sort((a, b) => a.localeCompare(b)),
|
|
106
|
+
security_labels: normalizeSecurityLabels(this.security_labels),
|
|
101
107
|
},
|
|
102
108
|
};
|
|
103
109
|
}
|
|
@@ -173,7 +179,20 @@ export async function extractPublications(pool) {
|
|
|
173
179
|
where s.pnpubid = p.oid
|
|
174
180
|
),
|
|
175
181
|
'[]'::json
|
|
176
|
-
) as schemas
|
|
182
|
+
) as schemas,
|
|
183
|
+
coalesce(
|
|
184
|
+
(
|
|
185
|
+
select json_agg(
|
|
186
|
+
json_build_object('provider', sl.provider, 'label', sl.label)
|
|
187
|
+
order by sl.provider
|
|
188
|
+
)
|
|
189
|
+
from pg_catalog.pg_seclabel sl
|
|
190
|
+
where sl.objoid = p.oid
|
|
191
|
+
and sl.classoid = 'pg_publication'::regclass
|
|
192
|
+
and sl.objsubid = 0
|
|
193
|
+
),
|
|
194
|
+
'[]'::json
|
|
195
|
+
) as security_labels
|
|
177
196
|
from pg_publication p
|
|
178
197
|
left join extension_oids e on e.objid = p.oid
|
|
179
198
|
where e.objid is null
|
|
@@ -2,7 +2,7 @@ import { BaseChange } from "../../base.change.ts";
|
|
|
2
2
|
import type { Role } from "../role.model.ts";
|
|
3
3
|
declare abstract class BaseRoleChange extends BaseChange {
|
|
4
4
|
abstract readonly role: Role;
|
|
5
|
-
abstract readonly scope: "object" | "comment" | "membership" | "default_privilege";
|
|
5
|
+
abstract readonly scope: "object" | "comment" | "membership" | "default_privilege" | "security_label";
|
|
6
6
|
readonly objectType: "role";
|
|
7
7
|
}
|
|
8
8
|
export declare abstract class CreateRoleChange extends BaseRoleChange {
|