@reyemtech/nimbus 2.12.5 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cjs/backup/index.d.ts.map +1 -1
- package/dist/cjs/backup/index.js +6 -1
- package/dist/cjs/backup/index.js.map +1 -1
- package/dist/cjs/cli/migrate-cnpg-ownership.d.ts +43 -0
- package/dist/cjs/cli/migrate-cnpg-ownership.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-cnpg-ownership.js +67 -0
- package/dist/cjs/cli/migrate-cnpg-ownership.js.map +1 -0
- package/dist/cjs/cli/migrate-cnpg-roles.d.ts +92 -0
- package/dist/cjs/cli/migrate-cnpg-roles.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-cnpg-roles.js +337 -0
- package/dist/cjs/cli/migrate-cnpg-roles.js.map +1 -0
- package/dist/cjs/cli/migrate-cnpg.d.ts +38 -0
- package/dist/cjs/cli/migrate-cnpg.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-cnpg.js +258 -0
- package/dist/cjs/cli/migrate-cnpg.js.map +1 -0
- package/dist/cjs/cli/migrate-exec.d.ts +45 -0
- package/dist/cjs/cli/migrate-exec.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-exec.js +104 -0
- package/dist/cjs/cli/migrate-exec.js.map +1 -0
- package/dist/cjs/cli/migrate-psql.d.ts +125 -0
- package/dist/cjs/cli/migrate-psql.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-psql.js +213 -0
- package/dist/cjs/cli/migrate-psql.js.map +1 -0
- package/dist/cjs/cli/migrate-report.d.ts +27 -0
- package/dist/cjs/cli/migrate-report.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-report.js +29 -0
- package/dist/cjs/cli/migrate-report.js.map +1 -0
- package/dist/cjs/cli/migrate-superuser.d.ts +22 -0
- package/dist/cjs/cli/migrate-superuser.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-superuser.js +73 -0
- package/dist/cjs/cli/migrate-superuser.js.map +1 -0
- package/dist/cjs/cli/migrate.d.ts +37 -0
- package/dist/cjs/cli/migrate.d.ts.map +1 -0
- package/dist/cjs/cli/migrate.js +67 -0
- package/dist/cjs/cli/migrate.js.map +1 -0
- package/dist/cjs/cli.d.ts +1 -0
- package/dist/cjs/cli.d.ts.map +1 -1
- package/dist/cjs/cli.js +6 -0
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/operator/cnpg-common.d.ts +56 -0
- package/dist/cjs/operator/cnpg-common.d.ts.map +1 -0
- package/dist/cjs/operator/cnpg-common.js +82 -0
- package/dist/cjs/operator/cnpg-common.js.map +1 -0
- package/dist/cjs/operator/cnpg-database.d.ts +66 -0
- package/dist/cjs/operator/cnpg-database.d.ts.map +1 -0
- package/dist/cjs/operator/cnpg-database.js +296 -0
- package/dist/cjs/operator/cnpg-database.js.map +1 -0
- package/dist/cjs/operator/cnpg-roles.d.ts +173 -0
- package/dist/cjs/operator/cnpg-roles.d.ts.map +1 -0
- package/dist/cjs/operator/cnpg-roles.js +225 -0
- package/dist/cjs/operator/cnpg-roles.js.map +1 -0
- package/dist/cjs/operator/cnpg.d.ts.map +1 -1
- package/dist/cjs/operator/cnpg.js +50 -162
- package/dist/cjs/operator/cnpg.js.map +1 -1
- package/dist/cjs/operator/connection-uri.d.ts +44 -0
- package/dist/cjs/operator/connection-uri.d.ts.map +1 -0
- package/dist/cjs/operator/connection-uri.js +49 -0
- package/dist/cjs/operator/connection-uri.js.map +1 -0
- package/dist/cjs/operator/credentials.d.ts +76 -0
- package/dist/cjs/operator/credentials.d.ts.map +1 -0
- package/dist/cjs/operator/credentials.js +106 -0
- package/dist/cjs/operator/credentials.js.map +1 -0
- package/dist/cjs/operator/database-options.d.ts +121 -0
- package/dist/cjs/operator/database-options.d.ts.map +1 -0
- package/dist/cjs/operator/database-options.js +131 -0
- package/dist/cjs/operator/database-options.js.map +1 -0
- package/dist/cjs/operator/grants/postgres-job.d.ts +109 -0
- package/dist/cjs/operator/grants/postgres-job.d.ts.map +1 -0
- package/dist/cjs/operator/grants/postgres-job.js +232 -0
- package/dist/cjs/operator/grants/postgres-job.js.map +1 -0
- package/dist/cjs/operator/grants/postgres-sql.d.ts +130 -0
- package/dist/cjs/operator/grants/postgres-sql.d.ts.map +1 -0
- package/dist/cjs/operator/grants/postgres-sql.js +305 -0
- package/dist/cjs/operator/grants/postgres-sql.js.map +1 -0
- package/dist/cjs/operator/grants/privileges.d.ts +24 -0
- package/dist/cjs/operator/grants/privileges.d.ts.map +1 -0
- package/dist/cjs/operator/grants/privileges.js +35 -0
- package/dist/cjs/operator/grants/privileges.js.map +1 -0
- package/dist/cjs/operator/grants/role-config.d.ts +80 -0
- package/dist/cjs/operator/grants/role-config.d.ts.map +1 -0
- package/dist/cjs/operator/grants/role-config.js +134 -0
- package/dist/cjs/operator/grants/role-config.js.map +1 -0
- package/dist/cjs/operator/index.d.ts +1 -1
- package/dist/cjs/operator/index.d.ts.map +1 -1
- package/dist/cjs/operator/index.js.map +1 -1
- package/dist/cjs/operator/interfaces.d.ts +223 -1
- package/dist/cjs/operator/interfaces.d.ts.map +1 -1
- package/dist/cjs/operator/interfaces.js.map +1 -1
- package/dist/cjs/operator/mariadb-common.d.ts +99 -0
- package/dist/cjs/operator/mariadb-common.d.ts.map +1 -0
- package/dist/cjs/operator/mariadb-common.js +141 -0
- package/dist/cjs/operator/mariadb-common.js.map +1 -0
- package/dist/cjs/operator/mariadb-database.d.ts +65 -0
- package/dist/cjs/operator/mariadb-database.d.ts.map +1 -0
- package/dist/cjs/operator/mariadb-database.js +285 -0
- package/dist/cjs/operator/mariadb-database.js.map +1 -0
- package/dist/cjs/operator/mariadb-roles.d.ts +264 -0
- package/dist/cjs/operator/mariadb-roles.d.ts.map +1 -0
- package/dist/cjs/operator/mariadb-roles.js +366 -0
- package/dist/cjs/operator/mariadb-roles.js.map +1 -0
- package/dist/cjs/operator/mariadb.d.ts.map +1 -1
- package/dist/cjs/operator/mariadb.js +35 -147
- package/dist/cjs/operator/mariadb.js.map +1 -1
- package/dist/cjs/operator/neo4j-common.d.ts +62 -0
- package/dist/cjs/operator/neo4j-common.d.ts.map +1 -0
- package/dist/cjs/operator/neo4j-common.js +89 -0
- package/dist/cjs/operator/neo4j-common.js.map +1 -0
- package/dist/cjs/operator/neo4j-database.d.ts +88 -0
- package/dist/cjs/operator/neo4j-database.d.ts.map +1 -0
- package/dist/cjs/operator/neo4j-database.js +274 -0
- package/dist/cjs/operator/neo4j-database.js.map +1 -0
- package/dist/cjs/operator/neo4j-roles.d.ts +203 -0
- package/dist/cjs/operator/neo4j-roles.d.ts.map +1 -0
- package/dist/cjs/operator/neo4j-roles.js +298 -0
- package/dist/cjs/operator/neo4j-roles.js.map +1 -0
- package/dist/cjs/operator/neo4j.d.ts.map +1 -1
- package/dist/cjs/operator/neo4j.js +32 -132
- package/dist/cjs/operator/neo4j.js.map +1 -1
- package/dist/cjs/operator/resource-identity.d.ts +170 -0
- package/dist/cjs/operator/resource-identity.d.ts.map +1 -0
- package/dist/cjs/operator/resource-identity.js +231 -0
- package/dist/cjs/operator/resource-identity.js.map +1 -0
- package/dist/cjs/operator/role-registry.d.ts +85 -0
- package/dist/cjs/operator/role-registry.d.ts.map +1 -0
- package/dist/cjs/operator/role-registry.js +72 -0
- package/dist/cjs/operator/role-registry.js.map +1 -0
- package/dist/cjs/platform/components/image-pruner.d.ts +3 -1
- package/dist/cjs/platform/components/image-pruner.d.ts.map +1 -1
- package/dist/cjs/platform/components/image-pruner.js +38 -19
- package/dist/cjs/platform/components/image-pruner.js.map +1 -1
- package/dist/cjs/types/errors.d.ts +3 -0
- package/dist/cjs/types/errors.d.ts.map +1 -1
- package/dist/cjs/types/errors.js +3 -0
- package/dist/cjs/types/errors.js.map +1 -1
- package/dist/esm/backup/index.d.ts.map +1 -1
- package/dist/esm/backup/index.js +6 -1
- package/dist/esm/backup/index.js.map +1 -1
- package/dist/esm/cli/migrate-cnpg-ownership.d.ts +43 -0
- package/dist/esm/cli/migrate-cnpg-ownership.d.ts.map +1 -0
- package/dist/esm/cli/migrate-cnpg-ownership.js +67 -0
- package/dist/esm/cli/migrate-cnpg-ownership.js.map +1 -0
- package/dist/esm/cli/migrate-cnpg-roles.d.ts +92 -0
- package/dist/esm/cli/migrate-cnpg-roles.d.ts.map +1 -0
- package/dist/esm/cli/migrate-cnpg-roles.js +337 -0
- package/dist/esm/cli/migrate-cnpg-roles.js.map +1 -0
- package/dist/esm/cli/migrate-cnpg.d.ts +38 -0
- package/dist/esm/cli/migrate-cnpg.d.ts.map +1 -0
- package/dist/esm/cli/migrate-cnpg.js +258 -0
- package/dist/esm/cli/migrate-cnpg.js.map +1 -0
- package/dist/esm/cli/migrate-exec.d.ts +45 -0
- package/dist/esm/cli/migrate-exec.d.ts.map +1 -0
- package/dist/esm/cli/migrate-exec.js +104 -0
- package/dist/esm/cli/migrate-exec.js.map +1 -0
- package/dist/esm/cli/migrate-psql.d.ts +125 -0
- package/dist/esm/cli/migrate-psql.d.ts.map +1 -0
- package/dist/esm/cli/migrate-psql.js +213 -0
- package/dist/esm/cli/migrate-psql.js.map +1 -0
- package/dist/esm/cli/migrate-report.d.ts +27 -0
- package/dist/esm/cli/migrate-report.d.ts.map +1 -0
- package/dist/esm/cli/migrate-report.js +29 -0
- package/dist/esm/cli/migrate-report.js.map +1 -0
- package/dist/esm/cli/migrate-superuser.d.ts +22 -0
- package/dist/esm/cli/migrate-superuser.d.ts.map +1 -0
- package/dist/esm/cli/migrate-superuser.js +73 -0
- package/dist/esm/cli/migrate-superuser.js.map +1 -0
- package/dist/esm/cli/migrate.d.ts +37 -0
- package/dist/esm/cli/migrate.d.ts.map +1 -0
- package/dist/esm/cli/migrate.js +67 -0
- package/dist/esm/cli/migrate.js.map +1 -0
- package/dist/esm/cli.d.ts +1 -0
- package/dist/esm/cli.d.ts.map +1 -1
- package/dist/esm/cli.js +6 -0
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operator/cnpg-common.d.ts +56 -0
- package/dist/esm/operator/cnpg-common.d.ts.map +1 -0
- package/dist/esm/operator/cnpg-common.js +82 -0
- package/dist/esm/operator/cnpg-common.js.map +1 -0
- package/dist/esm/operator/cnpg-database.d.ts +66 -0
- package/dist/esm/operator/cnpg-database.d.ts.map +1 -0
- package/dist/esm/operator/cnpg-database.js +296 -0
- package/dist/esm/operator/cnpg-database.js.map +1 -0
- package/dist/esm/operator/cnpg-roles.d.ts +173 -0
- package/dist/esm/operator/cnpg-roles.d.ts.map +1 -0
- package/dist/esm/operator/cnpg-roles.js +225 -0
- package/dist/esm/operator/cnpg-roles.js.map +1 -0
- package/dist/esm/operator/cnpg.d.ts.map +1 -1
- package/dist/esm/operator/cnpg.js +50 -162
- package/dist/esm/operator/cnpg.js.map +1 -1
- package/dist/esm/operator/connection-uri.d.ts +44 -0
- package/dist/esm/operator/connection-uri.d.ts.map +1 -0
- package/dist/esm/operator/connection-uri.js +49 -0
- package/dist/esm/operator/connection-uri.js.map +1 -0
- package/dist/esm/operator/credentials.d.ts +76 -0
- package/dist/esm/operator/credentials.d.ts.map +1 -0
- package/dist/esm/operator/credentials.js +106 -0
- package/dist/esm/operator/credentials.js.map +1 -0
- package/dist/esm/operator/database-options.d.ts +121 -0
- package/dist/esm/operator/database-options.d.ts.map +1 -0
- package/dist/esm/operator/database-options.js +131 -0
- package/dist/esm/operator/database-options.js.map +1 -0
- package/dist/esm/operator/grants/postgres-job.d.ts +109 -0
- package/dist/esm/operator/grants/postgres-job.d.ts.map +1 -0
- package/dist/esm/operator/grants/postgres-job.js +232 -0
- package/dist/esm/operator/grants/postgres-job.js.map +1 -0
- package/dist/esm/operator/grants/postgres-sql.d.ts +130 -0
- package/dist/esm/operator/grants/postgres-sql.d.ts.map +1 -0
- package/dist/esm/operator/grants/postgres-sql.js +305 -0
- package/dist/esm/operator/grants/postgres-sql.js.map +1 -0
- package/dist/esm/operator/grants/privileges.d.ts +24 -0
- package/dist/esm/operator/grants/privileges.d.ts.map +1 -0
- package/dist/esm/operator/grants/privileges.js +35 -0
- package/dist/esm/operator/grants/privileges.js.map +1 -0
- package/dist/esm/operator/grants/role-config.d.ts +80 -0
- package/dist/esm/operator/grants/role-config.d.ts.map +1 -0
- package/dist/esm/operator/grants/role-config.js +134 -0
- package/dist/esm/operator/grants/role-config.js.map +1 -0
- package/dist/esm/operator/index.d.ts +1 -1
- package/dist/esm/operator/index.d.ts.map +1 -1
- package/dist/esm/operator/index.js.map +1 -1
- package/dist/esm/operator/interfaces.d.ts +223 -1
- package/dist/esm/operator/interfaces.d.ts.map +1 -1
- package/dist/esm/operator/interfaces.js.map +1 -1
- package/dist/esm/operator/mariadb-common.d.ts +99 -0
- package/dist/esm/operator/mariadb-common.d.ts.map +1 -0
- package/dist/esm/operator/mariadb-common.js +141 -0
- package/dist/esm/operator/mariadb-common.js.map +1 -0
- package/dist/esm/operator/mariadb-database.d.ts +65 -0
- package/dist/esm/operator/mariadb-database.d.ts.map +1 -0
- package/dist/esm/operator/mariadb-database.js +285 -0
- package/dist/esm/operator/mariadb-database.js.map +1 -0
- package/dist/esm/operator/mariadb-roles.d.ts +264 -0
- package/dist/esm/operator/mariadb-roles.d.ts.map +1 -0
- package/dist/esm/operator/mariadb-roles.js +366 -0
- package/dist/esm/operator/mariadb-roles.js.map +1 -0
- package/dist/esm/operator/mariadb.d.ts.map +1 -1
- package/dist/esm/operator/mariadb.js +35 -147
- package/dist/esm/operator/mariadb.js.map +1 -1
- package/dist/esm/operator/neo4j-common.d.ts +62 -0
- package/dist/esm/operator/neo4j-common.d.ts.map +1 -0
- package/dist/esm/operator/neo4j-common.js +89 -0
- package/dist/esm/operator/neo4j-common.js.map +1 -0
- package/dist/esm/operator/neo4j-database.d.ts +88 -0
- package/dist/esm/operator/neo4j-database.d.ts.map +1 -0
- package/dist/esm/operator/neo4j-database.js +274 -0
- package/dist/esm/operator/neo4j-database.js.map +1 -0
- package/dist/esm/operator/neo4j-roles.d.ts +203 -0
- package/dist/esm/operator/neo4j-roles.d.ts.map +1 -0
- package/dist/esm/operator/neo4j-roles.js +298 -0
- package/dist/esm/operator/neo4j-roles.js.map +1 -0
- package/dist/esm/operator/neo4j.d.ts.map +1 -1
- package/dist/esm/operator/neo4j.js +32 -132
- package/dist/esm/operator/neo4j.js.map +1 -1
- package/dist/esm/operator/resource-identity.d.ts +170 -0
- package/dist/esm/operator/resource-identity.d.ts.map +1 -0
- package/dist/esm/operator/resource-identity.js +231 -0
- package/dist/esm/operator/resource-identity.js.map +1 -0
- package/dist/esm/operator/role-registry.d.ts +85 -0
- package/dist/esm/operator/role-registry.d.ts.map +1 -0
- package/dist/esm/operator/role-registry.js +72 -0
- package/dist/esm/operator/role-registry.js.map +1 -0
- package/dist/esm/platform/components/image-pruner.d.ts +3 -1
- package/dist/esm/platform/components/image-pruner.d.ts.map +1 -1
- package/dist/esm/platform/components/image-pruner.js +38 -19
- package/dist/esm/platform/components/image-pruner.js.map +1 -1
- package/dist/esm/types/errors.d.ts +3 -0
- package/dist/esm/types/errors.d.ts.map +1 -1
- package/dist/esm/types/errors.js +3 -0
- package/dist/esm/types/errors.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL roles inside a CloudNativePG cluster.
|
|
3
|
+
*
|
|
4
|
+
* Every role — the database owner created alongside the database, and every
|
|
5
|
+
* role added later via `addRole()` — is provisioned by the single function
|
|
6
|
+
* {@link provisionCnpgRole}. Only their names differ, and those names are the
|
|
7
|
+
* one genuinely dangerous part: Pulumi identifies a resource by its logical
|
|
8
|
+
* name, so renaming one deletes and recreates it, and for a credential Secret
|
|
9
|
+
* that regenerates the password and breaks every application already using it.
|
|
10
|
+
* {@link ownerRoleNaming} therefore pins the owner's names to the exact strings
|
|
11
|
+
* live stacks already carry.
|
|
12
|
+
*
|
|
13
|
+
* @module operator/cnpg-roles
|
|
14
|
+
*/
|
|
15
|
+
import * as k8s from "@pulumi/kubernetes";
|
|
16
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
17
|
+
import { type IRoleCredentials } from "./credentials.js";
|
|
18
|
+
import type { IResolvedRoleConfig } from "./grants/role-config.js";
|
|
19
|
+
/**
|
|
20
|
+
* Every name — Pulumi logical and Kubernetes — used by one provisioned role.
|
|
21
|
+
*
|
|
22
|
+
* Collecting them in one place keeps the replace-on-rename risk reviewable
|
|
23
|
+
* instead of scattered through the provisioning code.
|
|
24
|
+
*/
|
|
25
|
+
export interface ICnpgRoleNaming {
|
|
26
|
+
/** Pulumi logical name of the Opaque credential Secret. */
|
|
27
|
+
readonly credentialResource: string;
|
|
28
|
+
/** Kubernetes name of the Opaque credential Secret. */
|
|
29
|
+
readonly credentialSecret: string;
|
|
30
|
+
/** Pulumi logical name of the basic-auth projection Secret. */
|
|
31
|
+
readonly basicAuthResource: string;
|
|
32
|
+
/** Kubernetes name of the basic-auth projection Secret. */
|
|
33
|
+
readonly basicAuthSecret: string;
|
|
34
|
+
/** Pulumi logical name of the `DatabaseRole` custom resource. */
|
|
35
|
+
readonly roleResource: string;
|
|
36
|
+
/** Kubernetes name of the `DatabaseRole` custom resource. */
|
|
37
|
+
readonly roleMetadataName: string;
|
|
38
|
+
/** Pulumi logical name prefix of the replicated connection Secrets. */
|
|
39
|
+
readonly connectionResourcePrefix: string;
|
|
40
|
+
/** Kubernetes name of each replicated connection Secret. */
|
|
41
|
+
readonly connectionSecret: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Names for the database owner's role.
|
|
45
|
+
*
|
|
46
|
+
* These strings predate the shared provisioner and are reproduced verbatim:
|
|
47
|
+
* `-user-secret`, `-role-secret`, `-role-cr`, and `-secret-{namespace}` are the
|
|
48
|
+
* logical names live stacks already carry. Do not "tidy" them.
|
|
49
|
+
*
|
|
50
|
+
* @param clusterName - CNPG cluster name
|
|
51
|
+
* @param dbName - Database name
|
|
52
|
+
* @returns The owner role's pinned naming
|
|
53
|
+
*/
|
|
54
|
+
export declare function ownerRoleNaming(clusterName: string, dbName: string): ICnpgRoleNaming;
|
|
55
|
+
/**
|
|
56
|
+
* Names for a role added via `addRole()`.
|
|
57
|
+
*
|
|
58
|
+
* Every name is prefixed `{cluster}-{database}-role-{role}` so it can never
|
|
59
|
+
* collide with the owner's pinned names above — the owner's shortest stem is
|
|
60
|
+
* `{cluster}-{database}-role`, which this only matches for an empty role name.
|
|
61
|
+
*
|
|
62
|
+
* The role segment comes from {@link toIdentitySegment}, not from plain
|
|
63
|
+
* sanitizing: `Read_Only` and `read_only` are two distinct, simultaneously valid
|
|
64
|
+
* PostgreSQL roles that sanitize alike, and two resources deriving one logical
|
|
65
|
+
* name abort the entire preview with a duplicate-URN error. Every segment
|
|
66
|
+
* carries the hash, including names that needed no sanitizing, so no raw name
|
|
67
|
+
* can land on another's encoded form.
|
|
68
|
+
*
|
|
69
|
+
* Every name is then bounded by {@link toBoundedName}: cluster, database and
|
|
70
|
+
* role names are all caller-controlled and unbounded, and a `metadata.name` over
|
|
71
|
+
* {@link DNS_1123_SUBDOMAIN_MAX_LENGTH} is rejected by the Kubernetes API at
|
|
72
|
+
* apply time — after preview has passed, so the Secrets and the `DatabaseRole`
|
|
73
|
+
* the role needs are never created. The grant Job, which is bound by the
|
|
74
|
+
* stricter 63-character label limit, names itself: see `createPostgresGrantJob`.
|
|
75
|
+
*
|
|
76
|
+
* @param clusterName - CNPG cluster name
|
|
77
|
+
* @param dbName - Database name
|
|
78
|
+
* @param roleName - Role name as it exists in PostgreSQL
|
|
79
|
+
* @returns Naming for the additional role's resources, each within the DNS-1123
|
|
80
|
+
* subdomain limit
|
|
81
|
+
*/
|
|
82
|
+
export declare function additionalRoleNaming(clusterName: string, dbName: string, roleName: string): ICnpgRoleNaming;
|
|
83
|
+
/**
|
|
84
|
+
* PostgreSQL-specific role attributes.
|
|
85
|
+
*
|
|
86
|
+
* Mirrors `IDatabaseRoleConfig.engineOptions.postgresql`; declared separately so
|
|
87
|
+
* this module depends on a named shape rather than an inline anonymous one.
|
|
88
|
+
*/
|
|
89
|
+
export interface ICnpgPostgresRoleOptions {
|
|
90
|
+
/** Existing roles this role becomes a member of (e.g. `["pg_read_all_data"]`). */
|
|
91
|
+
readonly inRoles?: string[];
|
|
92
|
+
/** Maximum concurrent connections. Default: unlimited. */
|
|
93
|
+
readonly connectionLimit?: number;
|
|
94
|
+
/** Timestamp after which the password expires. */
|
|
95
|
+
readonly validUntil?: string;
|
|
96
|
+
}
|
|
97
|
+
/** Inputs for {@link provisionCnpgRole}. */
|
|
98
|
+
export interface ICnpgRoleOptions {
|
|
99
|
+
/** CNPG cluster the role belongs to. */
|
|
100
|
+
readonly clusterName: string;
|
|
101
|
+
/** Role name as it will exist in PostgreSQL, passed through verbatim. */
|
|
102
|
+
readonly roleName: string;
|
|
103
|
+
/** Pinned Pulumi and Kubernetes names for this role's resources. */
|
|
104
|
+
readonly naming: ICnpgRoleNaming;
|
|
105
|
+
/** Role configuration with defaults applied. */
|
|
106
|
+
readonly resolved: IResolvedRoleConfig;
|
|
107
|
+
/** Optional PostgreSQL-only role attributes. */
|
|
108
|
+
readonly postgresOptions?: ICnpgPostgresRoleOptions;
|
|
109
|
+
/** Labels applied to every created object. */
|
|
110
|
+
readonly labels: Record<string, string>;
|
|
111
|
+
/** The CNPG Cluster CR the role is created in. */
|
|
112
|
+
readonly cluster: k8s.apiextensions.CustomResource;
|
|
113
|
+
/** Kubernetes provider. */
|
|
114
|
+
readonly provider: k8s.Provider;
|
|
115
|
+
}
|
|
116
|
+
/** A provisioned role and the credentials backing it. */
|
|
117
|
+
export interface ICnpgProvisionedRole {
|
|
118
|
+
/** The `DatabaseRole` custom resource. */
|
|
119
|
+
readonly role: k8s.apiextensions.CustomResource;
|
|
120
|
+
/** The role's Opaque credential Secret and its stable password. */
|
|
121
|
+
readonly credentials: IRoleCredentials;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Provision one PostgreSQL role: a credential Secret, its basic-auth
|
|
125
|
+
* projection, and the `DatabaseRole` CR that reconciles the role itself.
|
|
126
|
+
*
|
|
127
|
+
* Two Secrets exist because `Secret.type` is immutable in Kubernetes: the
|
|
128
|
+
* Opaque credential Secret cannot be converted to `kubernetes.io/basic-auth`
|
|
129
|
+
* (the only shape the CNPG `DatabaseRole` controller reads) without a replace,
|
|
130
|
+
* which would regenerate the password.
|
|
131
|
+
*
|
|
132
|
+
* Adopting an existing role forces omitted attributes back to their defaults,
|
|
133
|
+
* so `login` is always set explicitly.
|
|
134
|
+
*
|
|
135
|
+
* @param options - Cluster, role name, pinned naming, and resolved config
|
|
136
|
+
* @returns The `DatabaseRole` CR plus the credentials it authenticates with
|
|
137
|
+
*/
|
|
138
|
+
export declare function provisionCnpgRole(options: ICnpgRoleOptions): ICnpgProvisionedRole;
|
|
139
|
+
/** Inputs for {@link replicateCnpgConnectionSecrets}. */
|
|
140
|
+
export interface ICnpgConnectionSecretOptions {
|
|
141
|
+
/** Pinned naming for the role whose credentials are replicated. */
|
|
142
|
+
readonly naming: ICnpgRoleNaming;
|
|
143
|
+
/** Namespaces to replicate into. */
|
|
144
|
+
readonly namespaces: ReadonlyArray<string>;
|
|
145
|
+
/** Database the connection points at. */
|
|
146
|
+
readonly dbName: string;
|
|
147
|
+
/** Role the connection authenticates as. */
|
|
148
|
+
readonly username: string;
|
|
149
|
+
/** The role's password, read back from its credential Secret. */
|
|
150
|
+
readonly password: pulumi.Output<string>;
|
|
151
|
+
/** Cluster read-write endpoint. */
|
|
152
|
+
readonly endpoint: pulumi.Output<string>;
|
|
153
|
+
/** Cluster port. */
|
|
154
|
+
readonly port: pulumi.Output<number>;
|
|
155
|
+
/** Labels applied to each Secret. */
|
|
156
|
+
readonly labels: Record<string, string>;
|
|
157
|
+
/** Kubernetes provider. */
|
|
158
|
+
readonly provider: k8s.Provider;
|
|
159
|
+
/** Resources each Secret must be created after — always includes the `Database` CR. */
|
|
160
|
+
readonly dependsOn: ReadonlyArray<pulumi.Resource>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Replicate a role's connection details into each consuming namespace.
|
|
164
|
+
*
|
|
165
|
+
* The `username`, `password` and `database` keys carry raw values; only the
|
|
166
|
+
* composed `uri` percent-encodes them, because there a `@` or `:` in a role name
|
|
167
|
+
* would otherwise be read as a URI delimiter. See {@link encodeUriComponentValue}.
|
|
168
|
+
*
|
|
169
|
+
* @param options - Naming, namespaces, connection details, and dependencies
|
|
170
|
+
* @returns Map of namespace → created Secret name
|
|
171
|
+
*/
|
|
172
|
+
export declare function replicateCnpgConnectionSecrets(options: ICnpgConnectionSecretOptions): Record<string, pulumi.Output<string>>;
|
|
173
|
+
//# sourceMappingURL=cnpg-roles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cnpg-roles.d.ts","sourceRoot":"","sources":["../../../src/operator/cnpg-roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAQzC,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAO1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAOnE;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,uDAAuD;IACvD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,+DAA+D;IAC/D,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,2DAA2D;IAC3D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,iEAA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G;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,4BAA4B,GACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CA2BvC"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PostgreSQL roles inside a CloudNativePG cluster.
|
|
4
|
+
*
|
|
5
|
+
* Every role — the database owner created alongside the database, and every
|
|
6
|
+
* role added later via `addRole()` — is provisioned by the single function
|
|
7
|
+
* {@link provisionCnpgRole}. Only their names differ, and those names are the
|
|
8
|
+
* one genuinely dangerous part: Pulumi identifies a resource by its logical
|
|
9
|
+
* name, so renaming one deletes and recreates it, and for a credential Secret
|
|
10
|
+
* that regenerates the password and breaks every application already using it.
|
|
11
|
+
* {@link ownerRoleNaming} therefore pins the owner's names to the exact strings
|
|
12
|
+
* live stacks already carry.
|
|
13
|
+
*
|
|
14
|
+
* @module operator/cnpg-roles
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
33
|
+
var ownKeys = function(o) {
|
|
34
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
35
|
+
var ar = [];
|
|
36
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
return ownKeys(o);
|
|
40
|
+
};
|
|
41
|
+
return function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
45
|
+
__setModuleDefault(result, mod);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.ownerRoleNaming = ownerRoleNaming;
|
|
51
|
+
exports.additionalRoleNaming = additionalRoleNaming;
|
|
52
|
+
exports.provisionCnpgRole = provisionCnpgRole;
|
|
53
|
+
exports.replicateCnpgConnectionSecrets = replicateCnpgConnectionSecrets;
|
|
54
|
+
const k8s = __importStar(require("@pulumi/kubernetes"));
|
|
55
|
+
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
56
|
+
const cnpg_common_js_1 = require("./cnpg-common.js");
|
|
57
|
+
const credentials_js_1 = require("./credentials.js");
|
|
58
|
+
const connection_uri_js_1 = require("./connection-uri.js");
|
|
59
|
+
const resource_identity_js_1 = require("./resource-identity.js");
|
|
60
|
+
/** CNPG reads role passwords from Secrets of this type (username + password keys). */
|
|
61
|
+
const BASIC_AUTH_SECRET_TYPE = "kubernetes.io/basic-auth";
|
|
62
|
+
/** SSL mode embedded in the replicated connection URI. */
|
|
63
|
+
const CONNECTION_SSL_MODE = "require";
|
|
64
|
+
/**
|
|
65
|
+
* Names for the database owner's role.
|
|
66
|
+
*
|
|
67
|
+
* These strings predate the shared provisioner and are reproduced verbatim:
|
|
68
|
+
* `-user-secret`, `-role-secret`, `-role-cr`, and `-secret-{namespace}` are the
|
|
69
|
+
* logical names live stacks already carry. Do not "tidy" them.
|
|
70
|
+
*
|
|
71
|
+
* @param clusterName - CNPG cluster name
|
|
72
|
+
* @param dbName - Database name
|
|
73
|
+
* @returns The owner role's pinned naming
|
|
74
|
+
*/
|
|
75
|
+
function ownerRoleNaming(clusterName, dbName) {
|
|
76
|
+
const base = `${clusterName}-${dbName}`;
|
|
77
|
+
return {
|
|
78
|
+
credentialResource: `${base}-user-secret`,
|
|
79
|
+
credentialSecret: `${base}-user`,
|
|
80
|
+
basicAuthResource: `${base}-role-secret`,
|
|
81
|
+
basicAuthSecret: `${base}-role`,
|
|
82
|
+
roleResource: `${base}-role-cr`,
|
|
83
|
+
roleMetadataName: (0, cnpg_common_js_1.toResourceName)(`${base}-role`),
|
|
84
|
+
connectionResourcePrefix: `${base}-secret`,
|
|
85
|
+
connectionSecret: `${base}-pg`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Names for a role added via `addRole()`.
|
|
90
|
+
*
|
|
91
|
+
* Every name is prefixed `{cluster}-{database}-role-{role}` so it can never
|
|
92
|
+
* collide with the owner's pinned names above — the owner's shortest stem is
|
|
93
|
+
* `{cluster}-{database}-role`, which this only matches for an empty role name.
|
|
94
|
+
*
|
|
95
|
+
* The role segment comes from {@link toIdentitySegment}, not from plain
|
|
96
|
+
* sanitizing: `Read_Only` and `read_only` are two distinct, simultaneously valid
|
|
97
|
+
* PostgreSQL roles that sanitize alike, and two resources deriving one logical
|
|
98
|
+
* name abort the entire preview with a duplicate-URN error. Every segment
|
|
99
|
+
* carries the hash, including names that needed no sanitizing, so no raw name
|
|
100
|
+
* can land on another's encoded form.
|
|
101
|
+
*
|
|
102
|
+
* Every name is then bounded by {@link toBoundedName}: cluster, database and
|
|
103
|
+
* role names are all caller-controlled and unbounded, and a `metadata.name` over
|
|
104
|
+
* {@link DNS_1123_SUBDOMAIN_MAX_LENGTH} is rejected by the Kubernetes API at
|
|
105
|
+
* apply time — after preview has passed, so the Secrets and the `DatabaseRole`
|
|
106
|
+
* the role needs are never created. The grant Job, which is bound by the
|
|
107
|
+
* stricter 63-character label limit, names itself: see `createPostgresGrantJob`.
|
|
108
|
+
*
|
|
109
|
+
* @param clusterName - CNPG cluster name
|
|
110
|
+
* @param dbName - Database name
|
|
111
|
+
* @param roleName - Role name as it exists in PostgreSQL
|
|
112
|
+
* @returns Naming for the additional role's resources, each within the DNS-1123
|
|
113
|
+
* subdomain limit
|
|
114
|
+
*/
|
|
115
|
+
function additionalRoleNaming(clusterName, dbName, roleName) {
|
|
116
|
+
const base = `${clusterName}-${dbName}-role-${(0, resource_identity_js_1.toIdentitySegment)(roleName)}`;
|
|
117
|
+
const bounded = (name) => (0, resource_identity_js_1.toBoundedName)(name, resource_identity_js_1.DNS_1123_SUBDOMAIN_MAX_LENGTH);
|
|
118
|
+
return {
|
|
119
|
+
credentialResource: bounded(`${base}-secret`),
|
|
120
|
+
credentialSecret: bounded(base),
|
|
121
|
+
basicAuthResource: bounded(`${base}-auth-secret`),
|
|
122
|
+
basicAuthSecret: bounded(`${base}-auth`),
|
|
123
|
+
roleResource: bounded(`${base}-cr`),
|
|
124
|
+
roleMetadataName: bounded((0, cnpg_common_js_1.toResourceName)(base)),
|
|
125
|
+
connectionResourcePrefix: bounded(`${base}-connection`),
|
|
126
|
+
connectionSecret: bounded(`${base}-pg`),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Provision one PostgreSQL role: a credential Secret, its basic-auth
|
|
131
|
+
* projection, and the `DatabaseRole` CR that reconciles the role itself.
|
|
132
|
+
*
|
|
133
|
+
* Two Secrets exist because `Secret.type` is immutable in Kubernetes: the
|
|
134
|
+
* Opaque credential Secret cannot be converted to `kubernetes.io/basic-auth`
|
|
135
|
+
* (the only shape the CNPG `DatabaseRole` controller reads) without a replace,
|
|
136
|
+
* which would regenerate the password.
|
|
137
|
+
*
|
|
138
|
+
* Adopting an existing role forces omitted attributes back to their defaults,
|
|
139
|
+
* so `login` is always set explicitly.
|
|
140
|
+
*
|
|
141
|
+
* @param options - Cluster, role name, pinned naming, and resolved config
|
|
142
|
+
* @returns The `DatabaseRole` CR plus the credentials it authenticates with
|
|
143
|
+
*/
|
|
144
|
+
function provisionCnpgRole(options) {
|
|
145
|
+
const { naming, resolved, postgresOptions, provider, roleName } = options;
|
|
146
|
+
const credentials = (0, credentials_js_1.createRoleCredentials)({
|
|
147
|
+
resourceName: naming.credentialResource,
|
|
148
|
+
secretName: naming.credentialSecret,
|
|
149
|
+
namespace: cnpg_common_js_1.DATA_NAMESPACE,
|
|
150
|
+
username: roleName,
|
|
151
|
+
labels: options.labels,
|
|
152
|
+
provider,
|
|
153
|
+
dependsOn: [options.cluster],
|
|
154
|
+
});
|
|
155
|
+
const basicAuthSecret = new k8s.core.v1.Secret(naming.basicAuthResource, {
|
|
156
|
+
metadata: {
|
|
157
|
+
name: naming.basicAuthSecret,
|
|
158
|
+
namespace: cnpg_common_js_1.DATA_NAMESPACE,
|
|
159
|
+
labels: options.labels,
|
|
160
|
+
},
|
|
161
|
+
type: BASIC_AUTH_SECRET_TYPE,
|
|
162
|
+
stringData: {
|
|
163
|
+
username: roleName,
|
|
164
|
+
password: credentials.stablePassword,
|
|
165
|
+
},
|
|
166
|
+
}, { provider, dependsOn: [credentials.userSecret] });
|
|
167
|
+
const role = new k8s.apiextensions.CustomResource(naming.roleResource, {
|
|
168
|
+
apiVersion: cnpg_common_js_1.CNPG_API_VERSION,
|
|
169
|
+
kind: cnpg_common_js_1.DATABASE_ROLE_KIND,
|
|
170
|
+
metadata: {
|
|
171
|
+
name: naming.roleMetadataName,
|
|
172
|
+
namespace: cnpg_common_js_1.DATA_NAMESPACE,
|
|
173
|
+
labels: options.labels,
|
|
174
|
+
},
|
|
175
|
+
spec: {
|
|
176
|
+
cluster: { name: options.clusterName },
|
|
177
|
+
name: roleName,
|
|
178
|
+
ensure: cnpg_common_js_1.ENSURE_PRESENT,
|
|
179
|
+
login: resolved.login,
|
|
180
|
+
passwordSecret: { name: naming.basicAuthSecret },
|
|
181
|
+
databaseRoleReclaimPolicy: resolved.reclaimPolicy,
|
|
182
|
+
...(postgresOptions?.inRoles ? { inRoles: postgresOptions.inRoles } : {}),
|
|
183
|
+
...(postgresOptions?.connectionLimit !== undefined
|
|
184
|
+
? { connectionLimit: postgresOptions.connectionLimit }
|
|
185
|
+
: {}),
|
|
186
|
+
...(postgresOptions?.validUntil ? { validUntil: postgresOptions.validUntil } : {}),
|
|
187
|
+
},
|
|
188
|
+
}, { provider, dependsOn: [options.cluster, basicAuthSecret] });
|
|
189
|
+
return { role, credentials };
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Replicate a role's connection details into each consuming namespace.
|
|
193
|
+
*
|
|
194
|
+
* The `username`, `password` and `database` keys carry raw values; only the
|
|
195
|
+
* composed `uri` percent-encodes them, because there a `@` or `:` in a role name
|
|
196
|
+
* would otherwise be read as a URI delimiter. See {@link encodeUriComponentValue}.
|
|
197
|
+
*
|
|
198
|
+
* @param options - Naming, namespaces, connection details, and dependencies
|
|
199
|
+
* @returns Map of namespace → created Secret name
|
|
200
|
+
*/
|
|
201
|
+
function replicateCnpgConnectionSecrets(options) {
|
|
202
|
+
const { dbName, username, password, endpoint, port } = options;
|
|
203
|
+
const uriUsername = (0, connection_uri_js_1.encodeUriComponentValue)(username);
|
|
204
|
+
const uriDatabase = (0, connection_uri_js_1.encodeUriComponentValue)(dbName);
|
|
205
|
+
return (0, credentials_js_1.replicateConnectionSecrets)({
|
|
206
|
+
namespaces: options.namespaces,
|
|
207
|
+
resourcePrefix: options.naming.connectionResourcePrefix,
|
|
208
|
+
secretName: options.naming.connectionSecret,
|
|
209
|
+
stringData: {
|
|
210
|
+
host: endpoint,
|
|
211
|
+
port: port.apply((p) => String(p)),
|
|
212
|
+
username,
|
|
213
|
+
password,
|
|
214
|
+
database: dbName,
|
|
215
|
+
uri: pulumi
|
|
216
|
+
.all([endpoint, port, password])
|
|
217
|
+
.apply(([h, p, pw]) => `postgresql://${uriUsername}:${(0, connection_uri_js_1.encodeUriComponentValue)(pw)}@${h}:${p}/` +
|
|
218
|
+
`${uriDatabase}?sslmode=${CONNECTION_SSL_MODE}`),
|
|
219
|
+
},
|
|
220
|
+
labels: options.labels,
|
|
221
|
+
provider: options.provider,
|
|
222
|
+
dependsOn: options.dependsOn,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=cnpg-roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cnpg-roles.js","sourceRoot":"","sources":["../../../src/operator/cnpg-roles.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEH,0CAYC;AA6BD,oDAiBC;AA4DD,8CA0DC;AAoCD,wEA6BC;AAhTD,wDAA0C;AAC1C,uDAAyC;AACzC,qDAM0B;AAC1B,qDAI0B;AAC1B,2DAA8D;AAC9D,iEAIgC;AAGhC,sFAAsF;AACtF,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAC1D,0DAA0D;AAC1D,MAAM,mBAAmB,GAAG,SAAS,CAAC;AA2BtC;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAAC,WAAmB,EAAE,MAAc;IACjE,MAAM,IAAI,GAAG,GAAG,WAAW,IAAI,MAAM,EAAE,CAAC;IACxC,OAAO;QACL,kBAAkB,EAAE,GAAG,IAAI,cAAc;QACzC,gBAAgB,EAAE,GAAG,IAAI,OAAO;QAChC,iBAAiB,EAAE,GAAG,IAAI,cAAc;QACxC,eAAe,EAAE,GAAG,IAAI,OAAO;QAC/B,YAAY,EAAE,GAAG,IAAI,UAAU;QAC/B,gBAAgB,EAAE,IAAA,+BAAc,EAAC,GAAG,IAAI,OAAO,CAAC;QAChD,wBAAwB,EAAE,GAAG,IAAI,SAAS;QAC1C,gBAAgB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E,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;gBACvE,GAAG,WAAW,YAAY,mBAAmB,EAAE,CAClD;SACJ;QACD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cnpg.d.ts","sourceRoot":"","sources":["../../../src/operator/cnpg.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"cnpg.d.ts","sourceRoot":"","sources":["../../../src/operator/cnpg.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAG1C,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAGjB,MAAM,cAAc,CAAC;AA+QtB;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,sBAAsB,GAAG,SAAS,EAC1C,cAAc,EAAE,eAAe,GAAG,SAAS,EAC3C,QAAQ,EAAE,GAAG,CAAC,QAAQ,EACtB,eAAe,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EACpC,YAAY,CAAC,EAAE,cAAc,GAC5B,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAyCrD"}
|