@git.zone/cli 7.4.1 → 8.1.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.
Files changed (39) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/mod_services/classes.dockercontainer.d.ts +13 -2
  3. package/dist_ts/mod_services/classes.dockercontainer.js +40 -40
  4. package/dist_ts/mod_services/classes.globalregistry.d.ts +12 -0
  5. package/dist_ts/mod_services/classes.globalregistry.js +96 -13
  6. package/dist_ts/mod_services/classes.globalregistrystore.d.ts +7 -1
  7. package/dist_ts/mod_services/classes.globalregistrystore.js +6 -6
  8. package/dist_ts/mod_services/classes.legacymongomigration.d.ts +239 -0
  9. package/dist_ts/mod_services/classes.legacymongomigration.js +970 -0
  10. package/dist_ts/mod_services/classes.serviceconfiguration.d.ts +112 -15
  11. package/dist_ts/mod_services/classes.serviceconfiguration.js +274 -62
  12. package/dist_ts/mod_services/classes.servicedatamarker.d.ts +42 -1
  13. package/dist_ts/mod_services/classes.servicedatamarker.js +101 -8
  14. package/dist_ts/mod_services/classes.servicemanager.d.ts +99 -33
  15. package/dist_ts/mod_services/classes.servicemanager.js +652 -384
  16. package/dist_ts/mod_services/classes.servicepruner.js +27 -20
  17. package/dist_ts/mod_services/index.js +62 -13
  18. package/dist_ts/mod_services/mod.plugins.d.ts +2 -1
  19. package/dist_ts/mod_services/mod.plugins.js +4 -2
  20. package/dist_ts_migration/002.runtime-config.d.ts +1 -1
  21. package/dist_ts_migration/002.runtime-config.js +8 -2
  22. package/dist_ts_migration/003.service-data-marker.js +125 -30
  23. package/dist_ts_migration/004.global-registry.js +30 -8
  24. package/package.json +1 -1
  25. package/readme.md +197 -32
  26. package/ts/00_commitinfo_data.ts +1 -1
  27. package/ts/mod_services/classes.dockercontainer.ts +58 -50
  28. package/ts/mod_services/classes.globalregistry.ts +115 -14
  29. package/ts/mod_services/classes.globalregistrystore.ts +16 -6
  30. package/ts/mod_services/classes.legacymongomigration.ts +1308 -0
  31. package/ts/mod_services/classes.serviceconfiguration.ts +387 -69
  32. package/ts/mod_services/classes.servicedatamarker.ts +149 -8
  33. package/ts/mod_services/classes.servicemanager.ts +877 -454
  34. package/ts/mod_services/classes.servicepruner.ts +27 -19
  35. package/ts/mod_services/index.ts +81 -12
  36. package/ts/mod_services/mod.plugins.ts +4 -1
  37. package/ts_migration/002.runtime-config.ts +8 -1
  38. package/ts_migration/003.service-data-marker.ts +168 -29
  39. package/ts_migration/004.global-registry.ts +38 -7
@@ -8,7 +8,45 @@ export declare const isValidS3BucketName: (bucketArg: unknown) => bucketArg is s
8
8
  * alphabet than custom S3 names. Long names retain a stable hash suffix.
9
9
  */
10
10
  export declare const deriveS3BucketName: (projectNameArg: string) => string;
11
- export interface IServiceConfig {
11
+ /**
12
+ * The serve.zone capability environment
13
+ * (`serve.zone/docs/developers/app-integration.md`, "Capability environment")
14
+ * that GitZone does not already manage under the same name. `MONGODB_HOST`,
15
+ * `MONGODB_PORT`, `MONGODB_URL`, `S3_PORT`, `S3_REGION` and `S3_BUCKET` share
16
+ * their platform name and meaning with the GitZone fields. `S3_ENDPOINT` shares
17
+ * the name only: GitZone keeps the user's value (a host, `host:port`, or an
18
+ * origin, see `resolveS3Endpoint`), and `AWS_ENDPOINT_URL` carries the endpoint
19
+ * origin. Every value is derived from the GitZone fields and rewritten on each
20
+ * reconciliation.
21
+ */
22
+ export interface IServicePlatformEnvironment {
23
+ /** Identical to `MONGODB_URL` and `MONGO_URL`. */
24
+ MONGODB_URI: string;
25
+ MONGO_URL: string;
26
+ MONGODB_DATABASE: string;
27
+ MONGO_DBNAME: string;
28
+ /** The four credential names are present only while MongoDB auth is enabled. */
29
+ MONGODB_USERNAME?: string;
30
+ MONGO_DBUSER?: string;
31
+ MONGODB_PASSWORD?: string;
32
+ MONGO_DBPASS?: string;
33
+ /** Endpoint origin, e.g. `http://localhost:29000`. */
34
+ AWS_ENDPOINT_URL: string;
35
+ /** Host of `AWS_ENDPOINT_URL`; an IPv6 address without brackets. */
36
+ S3_ENDPOINT_HOST: string;
37
+ /** `true` or `false`, the scheme of `AWS_ENDPOINT_URL`. */
38
+ S3_USE_SSL: string;
39
+ AWS_REGION: string;
40
+ /** Always `true`. */
41
+ AWS_S3_FORCE_PATH_STYLE: string;
42
+ S3_ACCESS_KEY: string;
43
+ S3_ACCESS_KEY_ID: string;
44
+ AWS_ACCESS_KEY_ID: string;
45
+ S3_SECRET_KEY: string;
46
+ S3_SECRET_ACCESS_KEY: string;
47
+ AWS_SECRET_ACCESS_KEY: string;
48
+ }
49
+ export interface IServiceConfig extends IServicePlatformEnvironment {
12
50
  PROJECT_NAME: string;
13
51
  MONGODB_HOST: string;
14
52
  MONGODB_NAME: string;
@@ -17,11 +55,16 @@ export interface IServiceConfig {
17
55
  MONGODB_PASS: string;
18
56
  MONGODB_URL: string;
19
57
  /**
20
- * When false, mongod runs without authentication and is published on
21
- * loopback only. Opt-in, for runtimes whose `node:crypto` cannot complete a
22
- * SCRAM handshake (notably Deno). Defaults to true.
58
+ * When false, the NoSQLDB engine runs without authentication. It is always
59
+ * published on loopback only. Opt-in, for runtimes whose `node:crypto` cannot
60
+ * complete a SCRAM handshake (notably Deno). Defaults to true.
23
61
  */
24
62
  MONGODB_AUTH_ENABLED: boolean;
63
+ /**
64
+ * Password of the NoSQLDB engine's management UI. Generated per project,
65
+ * never printed, and never published: the UI port stays inside the container.
66
+ */
67
+ MONGODB_ADMIN_PASSWORD: string;
25
68
  S3_HOST: string;
26
69
  S3_PORT: string;
27
70
  S3_UI_PORT: string;
@@ -38,6 +81,56 @@ export interface IServiceConfig {
38
81
  ELASTICSEARCH_PASS: string;
39
82
  ELASTICSEARCH_URL: string;
40
83
  }
84
+ /** The fields derived from GitZone's database and object-storage primitives. */
85
+ export type TDerivedServiceConnectionEnvironment = IServicePlatformEnvironment & Pick<IServiceConfig, 'MONGODB_URL'>;
86
+ /** Every runtime field that is not derived by `deriveServiceConnectionEnvironment`. */
87
+ export type TServiceConfigPrimitives = Omit<IServiceConfig, keyof TDerivedServiceConnectionEnvironment>;
88
+ /** The primitives the connection environment is derived from. */
89
+ export type TServiceConnectionPrimitives = Pick<IServiceConfig, 'MONGODB_HOST' | 'MONGODB_PORT' | 'MONGODB_NAME' | 'MONGODB_USER' | 'MONGODB_PASS' | 'MONGODB_AUTH_ENABLED' | 'S3_HOST' | 'S3_ENDPOINT' | 'S3_PORT' | 'S3_USESSL' | 'S3_REGION' | 'S3_ACCESSKEY' | 'S3_SECRETKEY'>;
90
+ /** Names of every derived connection field, in `.nogit/env.json` order. */
91
+ export declare const serviceDerivedConnectionFieldNames: Array<keyof TDerivedServiceConnectionEnvironment>;
92
+ /** Runtime fields whose value is or contains a secret; `services config --json` redacts them. */
93
+ export declare const serviceSecretEnvironmentNames: ReadonlyArray<keyof IServiceConfig>;
94
+ /**
95
+ * The MongoDB connection URI. The credential lives in `admin`, so a local URI
96
+ * authenticates there; the path names the database, and `directConnection`
97
+ * matches the standalone NoSQLDB node. Credentials and `authSource` are
98
+ * omitted when auth is disabled.
99
+ */
100
+ export declare const buildMongoConnectionUri: (primitivesArg: TServiceConnectionPrimitives, hostArg?: string) => string;
101
+ /** The object-storage endpoint the platform names describe. */
102
+ export interface IS3Endpoint {
103
+ /** Host only, exactly as written; an IPv6 address without brackets. */
104
+ host: string;
105
+ /** Endpoint origin, e.g. `http://localhost:29000`; the scheme's default port is omitted. */
106
+ origin: string;
107
+ useSsl: boolean;
108
+ }
109
+ /**
110
+ * Resolve the object-storage endpoint from `S3_ENDPOINT`, read but never
111
+ * rewritten. It is user-controlled and accepted in three forms:
112
+ *
113
+ * - a bare host or IP address (`localhost`, `::1`): scheme from `S3_USESSL`,
114
+ * port from `S3_PORT`;
115
+ * - `host:port` or `[ipv6]:port`: its port wins over `S3_PORT`, the scheme
116
+ * comes from `S3_USESSL`;
117
+ * - an origin, `http(s)://host[:port]`: a complete origin, so its scheme wins
118
+ * over `S3_USESSL` and its port, or the scheme's default port, over `S3_PORT`.
119
+ *
120
+ * The host is taken as written, so no URL normalization rewrites IPv4
121
+ * shorthand, IPv4-mapped IPv6, or letter case. User info, a path, a query, a
122
+ * fragment, a scheme other than `http`/`https`, and a port outside 1-65535 are
123
+ * not part of an origin and are not carried over. An endpoint without a host
124
+ * (`:9000`) takes its host from `S3_HOST`, as a missing `S3_ENDPOINT` does.
125
+ * Never throws: 8.0.0 loaded any non-empty `S3_ENDPOINT`.
126
+ */
127
+ export declare const resolveS3Endpoint: (primitivesArg: TServiceConnectionPrimitives) => IS3Endpoint;
128
+ /**
129
+ * Derive `MONGODB_URL` and the serve.zone capability environment from the
130
+ * primitives GitZone manages. The single mapping from primitives to both name
131
+ * sets.
132
+ */
133
+ export declare const deriveServiceConnectionEnvironment: (primitivesArg: TServiceConnectionPrimitives) => TDerivedServiceConnectionEnvironment;
41
134
  /** Validate the complete canonical env.json shape before runtime use or persistence. */
42
135
  export declare const assertCanonicalServiceRuntimeConfig: (configArg: unknown) => asserts configArg is IServiceConfig;
43
136
  export declare class ServiceConfiguration {
@@ -65,29 +158,30 @@ export declare class ServiceConfiguration {
65
158
  */
66
159
  getConfig(): IServiceConfig;
67
160
  /**
68
- * Whether mongod should enforce authentication. Defaults to true; only an
161
+ * Whether the NoSQLDB engine should enforce authentication. Defaults to true; only an
69
162
  * explicit `false` in `.nogit/env.json` disables it.
70
163
  */
71
164
  isMongoAuthEnabled(): boolean;
72
- /**
73
- * Build MONGODB_URL from the current fields.
74
- *
75
- * Credentials are omitted entirely when auth is disabled, so the stored URL
76
- * never advertises a username that mongod would not accept.
77
- */
78
- private buildMongoUrl;
79
165
  /**
80
166
  * Recompute every derived field from the primitive ones.
81
167
  */
82
168
  private updateDerivedFields;
83
169
  /**
84
- * Refuse an unauthenticated mongod that would be reachable off-host.
170
+ * Rewrite `MONGODB_URL` and the serve.zone capability environment from the
171
+ * primitives, in place, and drop the platform database credential names while
172
+ * auth is disabled. Returns the names whose value changed, never the values.
173
+ */
174
+ private reconcileDerivedConnectionFields;
175
+ /**
176
+ * Refuse an unauthenticated database that would be reachable off-host.
85
177
  *
86
178
  * Disabling auth is only defensible while the database is bound to loopback.
87
179
  * Rather than trusting the operator to keep MONGODB_HOST local, this fails
88
180
  * closed on the combination.
89
181
  */
90
182
  assertMongoExposureIsSafe(): void;
183
+ /** Reject NoSQLDB's prohibited defaults and credential reuse before Docker mutation. */
184
+ assertNoSqlDbCredentialsAreSafe(): void;
91
185
  /** Reject ObjectStorage's prohibited defaults and credential reuse before Docker mutation. */
92
186
  assertObjectStorageCredentialsAreSafe(): void;
93
187
  /**
@@ -130,7 +224,8 @@ export declare class ServiceConfiguration {
130
224
  * Get container names
131
225
  */
132
226
  getContainerNames(): {
133
- mongo: string;
227
+ nosqldb: string;
228
+ legacyMongo: string;
134
229
  objectstorage: string;
135
230
  legacyMinio: string;
136
231
  elasticsearch: string;
@@ -142,7 +237,7 @@ export declare class ServiceConfiguration {
142
237
  * reclamation in `ServicePruner` can never disagree about the shape.
143
238
  */
144
239
  getDataDirectories(): {
145
- mongo: string;
240
+ nosqldb: string;
146
241
  objectstorage: string;
147
242
  elasticsearch: string;
148
243
  };
@@ -154,6 +249,8 @@ export declare class ServiceConfiguration {
154
249
  * Validate and update ports if they're not available
155
250
  */
156
251
  validateAndUpdatePorts(): Promise<boolean>;
252
+ /** Validate the NoSQLDB host port only after legacy/conflict checks pass. */
253
+ validateNoSqlDbPort(): Promise<boolean>;
157
254
  /** Validate ObjectStorage host ports only after legacy/conflict checks pass. */
158
255
  validateObjectStoragePorts(): Promise<boolean>;
159
256
  /**