@sfxcode/mongocamp-server-core 2.7.2 → 2.9.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/dist/index.d.mts CHANGED
@@ -295,12 +295,19 @@ declare class AuthorizedUser {
295
295
  * behaviours (owner, timestamps, versioned, audit), the read scopes and the events see this user.
296
296
  */
297
297
  readonly actingFor?: AuthorizedUser;
298
- constructor(user: UserInformation, roles: Role[], actingFor?: AuthorizedUser);
298
+ /**
299
+ * The request asks to keep the change fields it sends (2.8.0, header `X-MONGOCAMP-KEEP-TIMESTAMPS`); only for administrators, and only
300
+ * on collections whose `timestamps` allow it (`preserveOnUpdate`).
301
+ */
302
+ readonly keepTimestamps: boolean;
303
+ constructor(user: UserInformation, roles: Role[], actingFor?: AuthorizedUser, keepTimestamps?: boolean);
299
304
  get userId(): string;
300
305
  /** The user the request acts for: the one of `X-AUTH-ACT-AS`, else the logged in user itself. */
301
306
  get acting(): AuthorizedUser;
302
307
  /** This user acting for another one (2.7.0). */
303
308
  actingAs(other: AuthorizedUser): AuthorizedUser;
309
+ /** This user asking to keep the sent change fields (2.8.0); has no effect for a user who is no administrator. */
310
+ keepingTimestamps(): AuthorizedUser;
304
311
  /** Collection grants, and the bucket meta grants as grants for the `.files` collection of the bucket. */
305
312
  get collectionGrants(): Grant[];
306
313
  get bucketGrants(): Grant[];
@@ -346,8 +353,10 @@ declare class MongoAuthHolder implements AuthHolder {
346
353
  /**
347
354
  * Unique index for the api-key lookup, partial on string values (users without a key store `null`). A database in which two users share
348
355
  * a key (possible with the Scala server, which had no index) gets a non-unique index instead, so the start never fails on old data.
356
+ * 2.9.0: an empty key means no key — stored `""` (Scala server, admin UIs that sent `""` for "none") becomes `null` first, otherwise
357
+ * every such user shares the key `""` and the index can never be unique.
349
358
  */
350
- createApiKeyIndex(warn?: (message: string) => void): Promise<void>;
359
+ createApiKeyIndex(warn?: (message: string) => void, log?: (message: string) => void): Promise<void>;
351
360
  allUsers(filter: string | undefined, paging: Paging): Promise<{
352
361
  items: UserInformation[];
353
362
  info: PaginationInfo;
@@ -431,6 +440,8 @@ interface LoginResult {
431
440
  * rights stay the administrator's. Refused (403) for every caller that is no administrator, 401 for a user that does not exist.
432
441
  */
433
442
  declare const ActAsHeader = "X-AUTH-ACT-AS";
443
+ /** 2.8.0: an administrator's write keeps the `updatedAt` / `updatedBy` it sends where `timestamps.preserveOnUpdate` allows it. */
444
+ declare const KeepTimestampsHeader = "X-MONGOCAMP-KEEP-TIMESTAMPS";
434
445
  declare class AuthService {
435
446
  private readonly config;
436
447
  private readonly version;
@@ -516,6 +527,12 @@ interface TimestampsOptions {
516
527
  * Default false.
517
528
  */
518
529
  preserveOnInsert?: boolean;
530
+ /**
531
+ * An update or replace by an administrator — also one acting for a user — keeps the `updatedAt` / `updatedBy` it sends (2.8.0; scripts
532
+ * that mark their writes or keep the change time of a document); missing ones are written as usual. With `versioned` in mode
533
+ * `timestamp` a sent `updatedAt` is also the expected version, so such a write is checked and does not advance the version. Default false.
534
+ */
535
+ preserveOnUpdate?: boolean;
519
536
  }
520
537
  /** The documents a user may read when the read rule is a function: a filter combined with every read (it can only narrow). */
521
538
  type ReadScope = (context: {
@@ -570,6 +587,7 @@ interface ResolvedBehaviours {
570
587
  createdBy?: string;
571
588
  updatedBy?: string;
572
589
  preserveOnInsert?: boolean;
590
+ preserveOnUpdate?: boolean;
573
591
  };
574
592
  owner?: {
575
593
  field: string;
@@ -1073,6 +1091,11 @@ interface components {
1073
1091
  count: number;
1074
1092
  /** Format: int32 */
1075
1093
  indexes: number;
1094
+ /**
1095
+ * Format: int32
1096
+ * @description 2.8.0: own indexes of a declaration (mongocamp_idx_*) that were not copied, because the target is not declared (no index sync would manage them there)
1097
+ */
1098
+ skippedIndexes?: number;
1076
1099
  };
1077
1100
  /** CountResponse */
1078
1101
  CountResponse: {
@@ -1343,6 +1366,15 @@ interface components {
1343
1366
  configType: string;
1344
1367
  comment: string;
1345
1368
  needsRestartForActivation: boolean;
1369
+ /**
1370
+ * @description 2.8.0: where the active value comes from — env, an option of the server, an administrator's update (patched), a value stored without update (stored, e.g. the default an older server wrote at the first start), or the default
1371
+ * @enum {string}
1372
+ */
1373
+ source?: "env" | "option" | "patched" | "stored" | "default";
1374
+ /** @description 2.8.0: the current default in the form of value; left out for a generated default (AUTH_SECRET) */
1375
+ defaultValue?: unknown;
1376
+ /** @description 2.8.0: value is the current default */
1377
+ isDefault?: boolean;
1346
1378
  };
1347
1379
  /** MongoFindRequest */
1348
1380
  MongoFindRequest: {
@@ -1659,6 +1691,13 @@ interface components {
1659
1691
  version: string;
1660
1692
  /** Format: date-time */
1661
1693
  builtAt: string;
1694
+ /** @description 2.8.0: the package of the server core that runs (name and version of the application above may differ) */
1695
+ core?: components["schemas"]["CoreVersion"];
1696
+ };
1697
+ /** CoreVersion */
1698
+ CoreVersion: {
1699
+ name: string;
1700
+ version: string;
1662
1701
  };
1663
1702
  };
1664
1703
  responses: never;
@@ -1887,25 +1926,45 @@ declare class EventBus {
1887
1926
  * Differences to the Scala server: an env (or programmatic) value wins without being written into the collection (the Scala server
1888
1927
  * replaced the document with comment "updated by env"), and an update is checked against the type of the configuration.
1889
1928
  */
1929
+ /**
1930
+ * 2.8.0: where the active value of a configuration comes from — the env, an option of `createMongocampServer`, an administrator's
1931
+ * update (`changedAt`), a value stored without update (written as the default by a first start, possibly by an older server), or the
1932
+ * default (nothing stored, or not persistent).
1933
+ */
1934
+ type ConfigurationSource = 'env' | 'option' | 'patched' | 'stored' | 'default';
1890
1935
  interface MongoCampConfiguration {
1891
1936
  key: string;
1892
1937
  value: unknown;
1893
1938
  configType: string;
1894
1939
  comment: string;
1895
1940
  needsRestartForActivation: boolean;
1941
+ /** 2.8.0 */
1942
+ source: ConfigurationSource;
1943
+ /** 2.8.0: the current default in the form of `value`; left out for a generated default (`AUTH_SECRET`). */
1944
+ defaultValue?: unknown;
1945
+ /** 2.8.0: `value` is the current default (always true for a generated default that nobody changed). */
1946
+ isDefault: boolean;
1896
1947
  }
1897
1948
  declare class ConfigPersistence {
1898
1949
  private readonly database;
1899
1950
  private readonly config;
1900
1951
  private readonly events?;
1952
+ private readonly logger?;
1901
1953
  private timer;
1902
- constructor(database: MongocampDatabase, config: ConfigStore, events?: EventBus | undefined);
1954
+ constructor(database: MongocampDatabase, config: ConfigStore, events?: EventBus | undefined, logger?: MongocampLogger | undefined);
1903
1955
  get collection(): Collection;
1904
1956
  private persistentDefinitions;
1905
1957
  /** Registers the missing keys with their defaults (`registerConfig`) and reads the stored values; the refresh starts if wanted. */
1906
1958
  initialize(refreshMillis?: number | false): Promise<void>;
1907
1959
  /** Replaces the stored old defaults of `LegacyDefaults` that nobody set (no `changedAt`, written since 2.6.0) by the current ones. */
1908
1960
  private upgradeLegacyDefaults;
1961
+ /**
1962
+ * 2.8.0: the keys whose stored value nobody set (no `changedAt`) and that differ from the current default — written as the default by
1963
+ * an older server at the first start, or set before 2.6.0. An env or option override hides the stored value, so it is not listed.
1964
+ */
1965
+ unmarkedNonDefaults(): Promise<string[]>;
1966
+ /** 2.8.0: one warning at the start, keys only (values can be secret). */
1967
+ private warnUnmarkedNonDefaults;
1909
1968
  /** Reads the stored values; at startup also the keys that need a restart, later only the ones that are active at once. */
1910
1969
  refresh(startup: boolean): Promise<void>;
1911
1970
  /** A configuration as answered by the API: the stored one, the one of the env, or a non persistent one. */
@@ -1953,6 +2012,11 @@ interface InterceptorBase {
1953
2012
  * ones of the user it acts for.
1954
2013
  */
1955
2014
  actedBy?: UserInformation;
2015
+ /**
2016
+ * An administrator asked to keep the `updatedAt` / `updatedBy` it sends (2.8.0, header `X-MONGOCAMP-KEEP-TIMESTAMPS`, or the option
2017
+ * `keepTimestamps` of a server collection); honoured where `timestamps.preserveOnUpdate` is set.
2018
+ */
2019
+ keepTimestamps?: true;
1956
2020
  }
1957
2021
  interface WriteInterceptorPayloads {
1958
2022
  /** Documents to insert: one for `PUT …/documents`, all of the request for `insertMany`, one batch for an import. */
@@ -2366,6 +2430,11 @@ interface MongocampContext {
2366
2430
  type ServerCollectionUser = string | AuthorizedUser | Request | 'system';
2367
2431
  interface ServerCollectionOptions {
2368
2432
  user: ServerCollectionUser;
2433
+ /**
2434
+ * Updates and replaces keep the `updatedAt` / `updatedBy` they send (2.8.0), where the collection's `timestamps.preserveOnUpdate`
2435
+ * allows it and the user is an administrator (or `'system'`). Like the header `X-MONGOCAMP-KEEP-TIMESTAMPS` of the API.
2436
+ */
2437
+ keepTimestamps?: boolean;
2369
2438
  }
2370
2439
  interface ServerFindOptions {
2371
2440
  /** A MongoDB filter, or a Lucene filter as text (`status:open AND qty:[1 TO 5]`). */
@@ -2508,6 +2577,11 @@ interface MongocampServer {
2508
2577
  /** Creates and connects a MongoCamp server. */
2509
2578
  declare function createMongocampServer(options?: MongocampServerOptions): Promise<MongocampServer>;
2510
2579
 
2580
+ declare const CoreVersion: {
2581
+ readonly name: "@sfxcode/mongocamp-server-core";
2582
+ readonly version: "2.9.0";
2583
+ };
2584
+
2511
2585
  /** Error codes of the API (`mongocamp-library/.../exception/ErrorCodes.scala`), sent in `ErrorDescription.code` and `x-error-code`. */
2512
2586
  declare const ErrorCodes: {
2513
2587
  /** A request that could not be decoded (body, query or header with an invalid value). */
@@ -2867,7 +2941,7 @@ declare function stripDocument(document: Document$2, paths: readonly string[]):
2867
2941
  * An update without the guarded paths: keys at or below a guarded path are removed; a `$set` of an object on a parent of a field of a
2868
2942
  * behaviour is set field by field, without the guarded fields; other operators on such a parent are removed.
2869
2943
  */
2870
- declare function stripUpdate(update: Document$2, guarded: readonly string[], system: readonly string[]): Document$2;
2944
+ declare function stripUpdate(update: Document$2, guarded: readonly string[], system: readonly string[], setOnly?: readonly string[]): Document$2;
2871
2945
 
2872
2946
  /**
2873
2947
  * The behaviour `softDelete` (2.3.0): a delete sets the deleted mark (`deletedAt`) instead of removing the document, every read hides
@@ -2940,9 +3014,9 @@ declare function stampInsert(document: Document$2, timestamps: Timestamps, stamp
2940
3014
  * Sets the change fields of a replacing document; the creation fields stay as stored (put back by the guard), a document without them
2941
3015
  * (stored before the behaviour was switched on) gets the values of this write.
2942
3016
  */
2943
- declare function stampReplace(document: Document$2, timestamps: Timestamps, stamp: WriteStamp): void;
3017
+ declare function stampReplace(document: Document$2, timestamps: Timestamps, stamp: WriteStamp, keepSent?: boolean): void;
2944
3018
  /** An update with the change fields set (`$set` with dot paths, so the creation fields next to them stay). */
2945
- declare function stampUpdate(update: Document$2, timestamps: Timestamps, stamp: WriteStamp): Document$2;
3019
+ declare function stampUpdate(update: Document$2, timestamps: Timestamps, stamp: WriteStamp, keepSent?: boolean): Document$2;
2946
3020
 
2947
- export { ActAsHeader, AuditCollection, AuthService, AuthorizedUser, BehaviourDefaults, CleanUpTokenJob, CleanUpTokenJobClass, CollectionRegistry, ConfigKeys, ConfigPersistence, ConfigStore, ConfigurationError, DefaultRowsPerPage, DefaultValidationMode, DocumentService, ErrorCodes, EventBus, FilterDefaultField, HookPrefix, InfoCache, InternalErrorMessage, JobScheduler, LuceneQueryError, MaxExpands, MongocampDatabase, MongocampError, MongocampMetrics, OwnIndexPrefix, PaginationHeaders, SyncValidationLevel, SystemUser, TextMarker, WriteInterceptors, auditCollectionOf, auditRecords, bsonMarkerOptions, collections, combineScopes, configDefinitions, connectHooks, consoleLogger, convertFields, convertIdValue, createMongocampServer, createServerCollection, decodeAny, defineMongocampCollection, documentToJson, ensureAuditIndexes, filterParameter, forwardEventsToHooks, forwardInterceptorsToHooks, guardedPaths, luceneQueryToFilter, luceneToFilter, metrics, notDeleted, ownedBy, parseExtendedJsonMode, parseJson, parseLuceneQuery, pathIdFilter, purgeIndexName, readScope, refsOf, requestFields, requestLogging, resolveBehaviours, resolveIndexes, resolveRefs, restoreUpdate, sameValidator, stampInsert, stampReplace, stampUpdate, stringifyJson, stripDocument, stripUpdate, syncIndexes, syncPurgeIndex, syncValidator, systemFields, toErrorResponse, toMongoJsonSchema, validatorOf, versionInDocument, versionInUpdate, withDeletedOf, withIncrement, withSystemFields, withVersion };
3021
+ export { ActAsHeader, AuditCollection, AuthService, AuthorizedUser, BehaviourDefaults, CleanUpTokenJob, CleanUpTokenJobClass, CollectionRegistry, ConfigKeys, ConfigPersistence, ConfigStore, ConfigurationError, CoreVersion, DefaultRowsPerPage, DefaultValidationMode, DocumentService, ErrorCodes, EventBus, FilterDefaultField, HookPrefix, InfoCache, InternalErrorMessage, JobScheduler, KeepTimestampsHeader, LuceneQueryError, MaxExpands, MongocampDatabase, MongocampError, MongocampMetrics, OwnIndexPrefix, PaginationHeaders, SyncValidationLevel, SystemUser, TextMarker, WriteInterceptors, auditCollectionOf, auditRecords, bsonMarkerOptions, collections, combineScopes, configDefinitions, connectHooks, consoleLogger, convertFields, convertIdValue, createMongocampServer, createServerCollection, decodeAny, defineMongocampCollection, documentToJson, ensureAuditIndexes, filterParameter, forwardEventsToHooks, forwardInterceptorsToHooks, guardedPaths, luceneQueryToFilter, luceneToFilter, metrics, notDeleted, ownedBy, parseExtendedJsonMode, parseJson, parseLuceneQuery, pathIdFilter, purgeIndexName, readScope, refsOf, requestFields, requestLogging, resolveBehaviours, resolveIndexes, resolveRefs, restoreUpdate, sameValidator, stampInsert, stampReplace, stampUpdate, stringifyJson, stripDocument, stripUpdate, syncIndexes, syncPurgeIndex, syncValidator, systemFields, toErrorResponse, toMongoJsonSchema, validatorOf, versionInDocument, versionInUpdate, withDeletedOf, withIncrement, withSystemFields, withVersion };
2948
3022
  export type { AuditOperation, AuditOptions, AuditRecord, BehaviourFlags, ConfigDefinition, ConfigKey, ConfigType, ConversionResult, ConvertOptions, DeclaredCollection, ErrorDescription, ErrorResponseOptions, EventListener, EventName, EventTarget, ExpandedDocument, ExtendedJsonMode, FetchOptions, Grant, HookSystem, IndexDeclaration, IndexDirection, IndexOptions, IndexSyncResult, InferDocument, InferDocumentInput, InferRefs, InterceptorBase, InterceptorName, InterceptorStage, InterceptorTarget, JobConfig, JobHandler, JobInformation, JobRun, LuceneQuery, MongocampCollectionDefinition, MongocampContext, MongocampEvent, MongocampEvents, MongocampFeature, MongocampHooks, MongocampLogger, MongocampRequestFields, MongocampServer, MongocampServerOptions, OwnerOptions, PaginationInfo, Paging, ReadOperation, ReadScope, RefDeclaration, RefTargets, RequestLog, ResolvedBehaviours, ResolvedIndex, ResolvedRef, Role, ScopeOptions, ServerCollection, ServerCollectionOptions, ServerCollectionUser, ServerDocumentIdentity, ServerFindOptions, ServerPage, SoftDeleteOptions, SystemFields, SystemInfo, TimestampsOptions, UserInformation, ValidationIssue, ValidationMode, ValidatorSyncAction, ValidatorSyncResult, VersionInfo, VersionedOptions, WriteInterceptor, WriteInterceptorPayloads, WriteStamp };
package/dist/index.mjs CHANGED
@@ -37,7 +37,7 @@ function mergeGrants(roles) {
37
37
  return [...merged.values()].sort((a, b) => a.name.localeCompare(b.name) || a.grantType.localeCompare(b.grantType));
38
38
  }
39
39
  class AuthorizedUser {
40
- constructor(user, roles, actingFor) {
40
+ constructor(user, roles, actingFor, keepTimestamps = false) {
41
41
  this.user = user;
42
42
  this.roles = roles;
43
43
  this.grants = mergeGrants(roles);
@@ -45,6 +45,7 @@ class AuthorizedUser {
45
45
  if (actingFor !== void 0) {
46
46
  this.actingFor = actingFor;
47
47
  }
48
+ this.keepTimestamps = keepTimestamps;
48
49
  }
49
50
  grants;
50
51
  isAdmin;
@@ -53,6 +54,11 @@ class AuthorizedUser {
53
54
  * behaviours (owner, timestamps, versioned, audit), the read scopes and the events see this user.
54
55
  */
55
56
  actingFor;
57
+ /**
58
+ * The request asks to keep the change fields it sends (2.8.0, header `X-MONGOCAMP-KEEP-TIMESTAMPS`); only for administrators, and only
59
+ * on collections whose `timestamps` allow it (`preserveOnUpdate`).
60
+ */
61
+ keepTimestamps;
56
62
  get userId() {
57
63
  return this.user.userId;
58
64
  }
@@ -62,7 +68,11 @@ class AuthorizedUser {
62
68
  }
63
69
  /** This user acting for another one (2.7.0). */
64
70
  actingAs(other) {
65
- return new AuthorizedUser(this.user, this.roles, other);
71
+ return new AuthorizedUser(this.user, this.roles, other, this.keepTimestamps);
72
+ }
73
+ /** This user asking to keep the sent change fields (2.8.0); has no effect for a user who is no administrator. */
74
+ keepingTimestamps() {
75
+ return new AuthorizedUser(this.user, this.roles, this.actingFor, this.isAdmin);
66
76
  }
67
77
  /** Collection grants, and the bucket meta grants as grants for the `.files` collection of the bucket. */
68
78
  get collectionGrants() {
@@ -108,7 +118,7 @@ function actingUser(user) {
108
118
  return user.actingFor === void 0 ? { user: user.user } : { user: user.actingFor.user, actedBy: user.user };
109
119
  }
110
120
  function actingIdentity(user) {
111
- return { ...actingUser(user), isAdmin: user.acting.isAdmin };
121
+ return { ...actingUser(user), isAdmin: user.acting.isAdmin, ...user.keepTimestamps ? { keepTimestamps: true } : {} };
112
122
  }
113
123
  function toUserProfile(user, roles) {
114
124
  return {
@@ -123,7 +133,8 @@ function toUserInformation(document) {
123
133
  return {
124
134
  userId: String(document.userId ?? ""),
125
135
  password: String(document.password ?? ""),
126
- apiKey: typeof document.apiKey === "string" ? document.apiKey : null,
136
+ // an empty key is no key (2.9.0)
137
+ apiKey: typeof document.apiKey === "string" && document.apiKey !== "" ? document.apiKey : null,
127
138
  roles: Array.isArray(document.roles) ? document.roles.map(String) : []
128
139
  };
129
140
  }
@@ -1265,13 +1276,19 @@ class MongoAuthHolder {
1265
1276
  }
1266
1277
  await this.users.createIndex({ userId: 1 }, { unique: true });
1267
1278
  await this.rolesCollection.createIndex({ name: 1 }, { unique: true });
1268
- await this.createApiKeyIndex(warn);
1279
+ await this.createApiKeyIndex(warn, log);
1269
1280
  }
1270
1281
  /**
1271
1282
  * Unique index for the api-key lookup, partial on string values (users without a key store `null`). A database in which two users share
1272
1283
  * a key (possible with the Scala server, which had no index) gets a non-unique index instead, so the start never fails on old data.
1284
+ * 2.9.0: an empty key means no key — stored `""` (Scala server, admin UIs that sent `""` for "none") becomes `null` first, otherwise
1285
+ * every such user shares the key `""` and the index can never be unique.
1273
1286
  */
1274
- async createApiKeyIndex(warn = console.warn) {
1287
+ async createApiKeyIndex(warn = console.warn, log = console.info) {
1288
+ const cleared = await this.users.updateMany({ apiKey: "" }, { $set: { apiKey: null } });
1289
+ if (cleared.modifiedCount > 0) {
1290
+ log(`${cleared.modifiedCount} users had an empty apiKey, stored as no key (null)`);
1291
+ }
1275
1292
  try {
1276
1293
  await this.users.createIndex(ApiKeyIndex.key, { name: ApiKeyIndex.uniqueName, unique: true, partialFilterExpression: ApiKeyIndex.partialFilter });
1277
1294
  } catch (error) {
@@ -1598,6 +1615,7 @@ class TokenCache {
1598
1615
 
1599
1616
  const ApiKeyHeader = "X-AUTH-APIKEY";
1600
1617
  const ActAsHeader = "X-AUTH-ACT-AS";
1618
+ const KeepTimestampsHeader = "X-MONGOCAMP-KEEP-TIMESTAMPS";
1601
1619
  function readCredentials(request) {
1602
1620
  const credentials = {};
1603
1621
  const authorization = request.headers.get("authorization")?.trim();
@@ -1691,7 +1709,9 @@ class AuthService {
1691
1709
  async authenticate(request) {
1692
1710
  const user = await this.authenticateUser(readCredentials(request));
1693
1711
  this.requestUsers.set(request, user.userId);
1694
- const authorized = new AuthorizedUser(user, await this.holder.findRoles(user.roles));
1712
+ const roles = await this.holder.findRoles(user.roles);
1713
+ const keep = request.headers.get(KeepTimestampsHeader)?.trim().toLowerCase() === "true";
1714
+ const authorized = keep ? new AuthorizedUser(user, roles).keepingTimestamps() : new AuthorizedUser(user, roles);
1695
1715
  const actAs = request.headers.get(ActAsHeader)?.trim();
1696
1716
  if (actAs === void 0 || actAs === "") {
1697
1717
  return authorized;
@@ -2048,10 +2068,11 @@ function valueForUpdate(definition, value) {
2048
2068
  return converted;
2049
2069
  }
2050
2070
  class ConfigPersistence {
2051
- constructor(database, config, events) {
2071
+ constructor(database, config, events, logger) {
2052
2072
  this.database = database;
2053
2073
  this.config = config;
2054
2074
  this.events = events;
2075
+ this.logger = logger;
2055
2076
  }
2056
2077
  timer;
2057
2078
  get collection() {
@@ -2075,6 +2096,7 @@ class ConfigPersistence {
2075
2096
  await this.collection.updateOne({ key: definition.key }, { $setOnInsert: document }, { upsert: true });
2076
2097
  }
2077
2098
  await this.upgradeLegacyDefaults();
2099
+ await this.warnUnmarkedNonDefaults();
2078
2100
  await this.refresh(true);
2079
2101
  if (refreshMillis !== false) {
2080
2102
  this.timer = setInterval(() => {
@@ -2096,6 +2118,23 @@ class ConfigPersistence {
2096
2118
  );
2097
2119
  }
2098
2120
  }
2121
+ /**
2122
+ * 2.8.0: the keys whose stored value nobody set (no `changedAt`) and that differ from the current default — written as the default by
2123
+ * an older server at the first start, or set before 2.6.0. An env or option override hides the stored value, so it is not listed.
2124
+ */
2125
+ async unmarkedNonDefaults() {
2126
+ return (await this.list()).filter((entry) => entry.source === "stored" && !entry.isDefault).map((entry) => entry.key);
2127
+ }
2128
+ /** 2.8.0: one warning at the start, keys only (values can be secret). */
2129
+ async warnUnmarkedNonDefaults() {
2130
+ if (!this.logger) {
2131
+ return;
2132
+ }
2133
+ const keys = await this.unmarkedNonDefaults();
2134
+ if (keys.length > 0) {
2135
+ this.logger.warn(`[mongocamp] stored configurations that nobody changed differ from the current default (an old default or a value set before 2.6.0): ${keys.join(", ")}. Check GET /system/configurations (isDefault: false), reset with DELETE /system/configurations/{key} or patch to keep.`);
2136
+ }
2137
+ }
2099
2138
  /** Reads the stored values; at startup also the keys that need a restart, later only the ones that are active at once. */
2100
2139
  async refresh(startup) {
2101
2140
  const documents = await this.collection.find({}).toArray();
@@ -2120,15 +2159,23 @@ class ConfigPersistence {
2120
2159
  const converted = fromStored(definition.type, stored.value);
2121
2160
  value = converted === void 0 ? stored.value ?? null : toStored(definition.type, converted);
2122
2161
  }
2123
- if (SecretKeys.has(definition.key) && value !== null && value !== "") {
2124
- value = SecretMask;
2162
+ const source = override === "env" ? "env" : override === "programmatic" ? "option" : !definition.persistent || !stored ? "default" : stored.changedAt !== void 0 ? "patched" : "stored";
2163
+ const generated = typeof definition.defaultValue === "function";
2164
+ let defaultValue = generated ? void 0 : toStored(definition.type, definition.defaultValue);
2165
+ const isDefault = generated ? source === "stored" || source === "default" : sameStoredValue(value, defaultValue);
2166
+ if (SecretKeys.has(definition.key)) {
2167
+ value = masked(value);
2168
+ defaultValue = masked(defaultValue);
2125
2169
  }
2126
2170
  return {
2127
2171
  key: definition.key,
2128
2172
  value,
2129
2173
  configType: definition.type,
2130
2174
  comment: override === "env" ? EnvComment : String(stored?.comment ?? ""),
2131
- needsRestartForActivation: definition.needsRestartForActivation
2175
+ needsRestartForActivation: definition.needsRestartForActivation,
2176
+ source,
2177
+ ...generated ? {} : { defaultValue },
2178
+ isDefault
2132
2179
  };
2133
2180
  }
2134
2181
  /** All configurations sorted by key (`getAllRegisteredConfigurations`). */
@@ -2190,6 +2237,20 @@ class ConfigPersistence {
2190
2237
  }
2191
2238
  }
2192
2239
  }
2240
+ function masked(value) {
2241
+ return value !== null && value !== void 0 && value !== "" ? SecretMask : value;
2242
+ }
2243
+ function sameStoredValue(a, b) {
2244
+ if (Array.isArray(a) || Array.isArray(b)) {
2245
+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((entry, index) => sameStoredValue(entry, b[index]));
2246
+ }
2247
+ const numberA = plainNumber(a);
2248
+ const numberB = plainNumber(b);
2249
+ if (numberA !== void 0 || numberB !== void 0) {
2250
+ return numberA === numberB;
2251
+ }
2252
+ return (a ?? null) === (b ?? null);
2253
+ }
2193
2254
  function defaultOf(definition) {
2194
2255
  return typeof definition.defaultValue === "function" ? definition.defaultValue() : definition.defaultValue;
2195
2256
  }
@@ -2871,7 +2932,7 @@ const BehaviourDefaults = {
2871
2932
  auditRetentionDays: 365
2872
2933
  };
2873
2934
  const optionKeys = {
2874
- timestamps: ["createdAt", "updatedAt", "createdBy", "updatedBy", "preserveOnInsert"],
2935
+ timestamps: ["createdAt", "updatedAt", "createdBy", "updatedBy", "preserveOnInsert", "preserveOnUpdate"],
2875
2936
  owner: ["field", "read", "adminBypass", "preserveOnInsert"],
2876
2937
  softDelete: ["field", "purgeAfterDays"],
2877
2938
  versioned: ["mode", "field", "required"],
@@ -2928,12 +2989,14 @@ function resolveBehaviours(flags) {
2928
2989
  ...timestamps.createdBy !== void 0 ? { createdBy: field(timestamps.createdBy, BehaviourDefaults.createdBy, "timestamps.createdBy") } : {},
2929
2990
  ...timestamps.updatedBy !== void 0 ? { updatedBy: field(timestamps.updatedBy, BehaviourDefaults.updatedBy, "timestamps.updatedBy") } : {}
2930
2991
  };
2931
- if (timestamps.preserveOnInsert !== void 0) {
2932
- if (typeof timestamps.preserveOnInsert !== "boolean") {
2933
- throw new TypeError("timestamps.preserveOnInsert must be true or false");
2934
- }
2935
- if (timestamps.preserveOnInsert) {
2936
- resolved.timestamps.preserveOnInsert = true;
2992
+ for (const flag of ["preserveOnInsert", "preserveOnUpdate"]) {
2993
+ if (timestamps[flag] !== void 0) {
2994
+ if (typeof timestamps[flag] !== "boolean") {
2995
+ throw new TypeError(`timestamps.${flag} must be true or false`);
2996
+ }
2997
+ if (timestamps[flag]) {
2998
+ resolved.timestamps[flag] = true;
2999
+ }
2937
3000
  }
2938
3001
  }
2939
3002
  }
@@ -3013,6 +3076,12 @@ function byAdministrator(event) {
3013
3076
  function preservesOnInsert(timestamps, event) {
3014
3077
  return timestamps?.preserveOnInsert === true && byAdministrator(event);
3015
3078
  }
3079
+ function preservesOnUpdate(timestamps, event) {
3080
+ return timestamps?.preserveOnUpdate === true && event.keepTimestamps === true && byAdministrator(event);
3081
+ }
3082
+ function changePaths(timestamps) {
3083
+ return [timestamps.updatedAt, timestamps.updatedBy].filter((path) => path !== void 0);
3084
+ }
3016
3085
  function preservesOwnerOnInsert(owner, event) {
3017
3086
  return owner?.preserveOnInsert === true && byAdministrator(event);
3018
3087
  }
@@ -3666,7 +3735,7 @@ function flatten(value, prefix) {
3666
3735
  return isPlainObject(entry) && Object.keys(entry).length > 0 ? flatten(entry, path) : [[path, entry]];
3667
3736
  });
3668
3737
  }
3669
- function stripUpdate(update, guarded, system) {
3738
+ function stripUpdate(update, guarded, system, setOnly = []) {
3670
3739
  const result = {};
3671
3740
  for (const [operator, fields] of Object.entries(update)) {
3672
3741
  if (!operator.startsWith("$") || !isPlainObject(fields)) {
@@ -3675,7 +3744,7 @@ function stripUpdate(update, guarded, system) {
3675
3744
  }
3676
3745
  const kept = {};
3677
3746
  for (const [path, value] of Object.entries(fields)) {
3678
- if (guarded.some((entry) => isAtOrBelow(path, entry))) {
3747
+ if (guarded.some((entry) => isAtOrBelow(path, entry)) || operator !== "$set" && setOnly.some((entry) => isAtOrBelow(path, entry))) {
3679
3748
  continue;
3680
3749
  }
3681
3750
  const parentOfSystem = system.some((entry) => entry.startsWith(`${path}.`));
@@ -3725,7 +3794,9 @@ function registerGuard(context, own) {
3725
3794
  return;
3726
3795
  }
3727
3796
  const stored = await collectionOf(context.database, event.collectionName).findOne(event.filter, { projection: Object.fromEntries(guard.all.map((path) => [path, 1])) });
3728
- const document = stripDocument(event.document, guard.all);
3797
+ const { timestamps } = guard.declared.behaviours;
3798
+ const kept = timestamps !== void 0 && preservesOnUpdate(timestamps, event) ? changePaths(timestamps).filter((path) => getPath(event.document, path) !== void 0) : [];
3799
+ const document = stripDocument(event.document, guard.all.filter((path) => !kept.includes(path)));
3729
3800
  for (const path of guard.protected) {
3730
3801
  const value = stored === null ? void 0 : getPath(stored, path);
3731
3802
  if (value !== void 0) {
@@ -3733,7 +3804,7 @@ function registerGuard(context, own) {
3733
3804
  }
3734
3805
  }
3735
3806
  if (stored !== null) {
3736
- preservedSystemValues.set(event, guard.system.map((path) => [path, getPath(stored, path)]).filter(([, value]) => value !== void 0));
3807
+ preservedSystemValues.set(event, guard.system.filter((path) => !kept.includes(path)).map((path) => [path, getPath(stored, path)]).filter(([, value]) => value !== void 0));
3737
3808
  }
3738
3809
  event.document = document;
3739
3810
  }, { stage: "guard" }),
@@ -3747,7 +3818,9 @@ function registerGuard(context, own) {
3747
3818
  context.interceptors.on("document:beforeUpdate", (event) => {
3748
3819
  const guard = guardedFor(event.collectionName);
3749
3820
  if (guard !== void 0) {
3750
- event.update = stripUpdate(event.update, guard.all, guard.system);
3821
+ const { timestamps } = guard.declared.behaviours;
3822
+ const kept = timestamps !== void 0 && preservesOnUpdate(timestamps, event) ? changePaths(timestamps) : [];
3823
+ event.update = stripUpdate(event.update, guard.all.filter((path) => !kept.includes(path)), guard.system, kept);
3751
3824
  }
3752
3825
  }, { stage: "guard" })
3753
3826
  ];
@@ -3906,22 +3979,26 @@ function stampInsert(document, timestamps, stamp, keepSent = false) {
3906
3979
  write(timestamps.updatedBy, stamp.userId);
3907
3980
  }
3908
3981
  }
3909
- function stampReplace(document, timestamps, stamp) {
3982
+ function stampReplace(document, timestamps, stamp, keepSent = false) {
3910
3983
  if (getPath(document, timestamps.createdAt) === void 0) {
3911
3984
  setPath(document, timestamps.createdAt, stamp.now);
3912
3985
  }
3913
3986
  if (timestamps.createdBy !== void 0 && getPath(document, timestamps.createdBy) === void 0) {
3914
3987
  setPath(document, timestamps.createdBy, stamp.userId);
3915
3988
  }
3916
- setPath(document, timestamps.updatedAt, stamp.now);
3917
- if (timestamps.updatedBy !== void 0) {
3989
+ if (!keepSent || getPath(document, timestamps.updatedAt) === void 0) {
3990
+ setPath(document, timestamps.updatedAt, stamp.now);
3991
+ }
3992
+ if (timestamps.updatedBy !== void 0 && (!keepSent || getPath(document, timestamps.updatedBy) === void 0)) {
3918
3993
  setPath(document, timestamps.updatedBy, stamp.userId);
3919
3994
  }
3920
3995
  }
3921
- function stampUpdate(update, timestamps, stamp) {
3996
+ function stampUpdate(update, timestamps, stamp, keepSent = false) {
3922
3997
  const set = isPlainObject(update.$set) ? { ...update.$set } : {};
3923
- set[timestamps.updatedAt] = stamp.now;
3924
- if (timestamps.updatedBy !== void 0) {
3998
+ if (!keepSent || set[timestamps.updatedAt] === void 0) {
3999
+ set[timestamps.updatedAt] = stamp.now;
4000
+ }
4001
+ if (timestamps.updatedBy !== void 0 && (!keepSent || set[timestamps.updatedBy] === void 0)) {
3925
4002
  set[timestamps.updatedBy] = stamp.userId;
3926
4003
  }
3927
4004
  return { ...update, $set: set };
@@ -3946,13 +4023,13 @@ function registerTimestamps(context, own, clock = () => /* @__PURE__ */ new Date
3946
4023
  context.interceptors.on("document:beforeReplace", (event) => {
3947
4024
  const timestamps = timestampsFor(event.collectionName);
3948
4025
  if (timestamps !== void 0) {
3949
- stampReplace(event.document, timestamps, stampOf(event.user));
4026
+ stampReplace(event.document, timestamps, stampOf(event.user), preservesOnUpdate(timestamps, event));
3950
4027
  }
3951
4028
  }, { stage: "system" }),
3952
4029
  context.interceptors.on("document:beforeUpdate", (event) => {
3953
4030
  const timestamps = timestampsFor(event.collectionName);
3954
4031
  if (timestamps !== void 0) {
3955
- event.update = stampUpdate(event.update, timestamps, stampOf(event.user));
4032
+ event.update = stampUpdate(event.update, timestamps, stampOf(event.user), preservesOnUpdate(timestamps, event));
3956
4033
  }
3957
4034
  }, { stage: "system" })
3958
4035
  ];
@@ -6750,24 +6827,25 @@ function createServerCollection(context, name, options) {
6750
6827
  const service = context.documents;
6751
6828
  let resolved;
6752
6829
  const user = () => {
6753
- resolved ??= (async () => {
6754
- const given = options.user;
6755
- if (given === "system") {
6756
- return SystemUser;
6757
- }
6758
- if (given instanceof AuthorizedUser) {
6759
- return given;
6760
- }
6761
- if (given instanceof Request) {
6762
- return context.auth.authenticate(given);
6763
- }
6764
- if (typeof given === "string" && given !== "") {
6765
- return context.auth.authorizedUser(given);
6766
- }
6767
- throw MongocampError.unauthorized("the server collection needs a user (an id, a request or 'system')");
6768
- })();
6830
+ resolved ??= resolveUser().then((authorized) => options.keepTimestamps === true ? authorized.keepingTimestamps() : authorized);
6769
6831
  return resolved;
6770
6832
  };
6833
+ const resolveUser = async () => {
6834
+ const given = options.user;
6835
+ if (given === "system") {
6836
+ return SystemUser;
6837
+ }
6838
+ if (given instanceof AuthorizedUser) {
6839
+ return given;
6840
+ }
6841
+ if (given instanceof Request) {
6842
+ return context.auth.authenticate(given);
6843
+ }
6844
+ if (typeof given === "string" && given !== "") {
6845
+ return context.auth.authorizedUser(given);
6846
+ }
6847
+ throw MongocampError.unauthorized("the server collection needs a user (an id, a request or 'system')");
6848
+ };
6771
6849
  const filterOf = (filter) => {
6772
6850
  if (filter === void 0) {
6773
6851
  return {};
@@ -7215,7 +7293,8 @@ function readUserInformation(body) {
7215
7293
  return {
7216
7294
  userId: requiredString(object, "userId"),
7217
7295
  password: requiredString(object, "password"),
7218
- apiKey: optionalString(object, "apiKey") ?? null,
7296
+ // 2.9.0: an empty key means no key (admin UIs send `""` for none); `""` would be one key shared by all such users
7297
+ apiKey: optionalString(object, "apiKey") || null,
7219
7298
  roles: object.roles === void 0 || object.roles === null ? [] : stringList$1(object.roles, "roles")
7220
7299
  };
7221
7300
  }
@@ -7867,8 +7946,9 @@ function registerBucketRoutes(app, context) {
7867
7946
  });
7868
7947
  }
7869
7948
 
7870
- async function copyIndexes(source, target) {
7871
- const indexes = (await source.listIndexes().toArray()).filter((index) => index.name !== "_id_");
7949
+ async function copyIndexes(source, target, withOwnIndexes) {
7950
+ const all = (await source.listIndexes().toArray()).filter((index) => index.name !== "_id_");
7951
+ const indexes = withOwnIndexes ? all : all.filter((index) => !String(index.name).startsWith(OwnIndexPrefix));
7872
7952
  if (indexes.length > 0) {
7873
7953
  const specifications = indexes.map((index) => {
7874
7954
  const { v: _version, ns: _namespace, ...specification } = index;
@@ -7876,9 +7956,9 @@ async function copyIndexes(source, target) {
7876
7956
  });
7877
7957
  await target.db.command({ createIndexes: target.collectionName, indexes: specifications });
7878
7958
  }
7879
- return indexes.length;
7959
+ return { indexes: indexes.length, skippedIndexes: all.length - indexes.length };
7880
7960
  }
7881
- async function copyCollection(database, source, target, filter, withIndexes, replaceTarget, temporaryPrefix) {
7961
+ async function copyCollection(database, source, target, filter, withIndexes, replaceTarget, temporaryPrefix, targetDeclared = false) {
7882
7962
  const db = databaseOf(database, source);
7883
7963
  const temporaryName = `${temporaryPrefix}copy_${randomUUID().replaceAll("-", "")}`;
7884
7964
  try {
@@ -7888,9 +7968,9 @@ async function copyCollection(database, source, target, filter, withIndexes, rep
7888
7968
  if (!(await collectionNames(db)).includes(temporaryName)) {
7889
7969
  await db.createCollection(temporaryName);
7890
7970
  }
7891
- const indexes = withIndexes ? await copyIndexes(db.collection(source.name), db.collection(temporaryName)) : 0;
7971
+ const copied = withIndexes ? await copyIndexes(db.collection(source.name), db.collection(temporaryName), targetDeclared) : { indexes: 0, skippedIndexes: 0 };
7892
7972
  await db.collection(temporaryName).rename(target.name, { dropTarget: replaceTarget });
7893
- return { count: await db.collection(target.name).countDocuments(), indexes };
7973
+ return { count: await db.collection(target.name).countDocuments(), ...copied };
7894
7974
  } finally {
7895
7975
  if ((await collectionNames(db)).includes(temporaryName)) {
7896
7976
  await db.collection(temporaryName).drop();
@@ -7898,7 +7978,7 @@ async function copyCollection(database, source, target, filter, withIndexes, rep
7898
7978
  }
7899
7979
  }
7900
7980
  function copyResponse(target, result) {
7901
- return { name: fullName(target), count: result.count, indexes: result.indexes };
7981
+ return { name: fullName(target), count: result.count, indexes: result.indexes, skippedIndexes: result.skippedIndexes };
7902
7982
  }
7903
7983
 
7904
7984
  const ValidationLevels = ["off", "moderate", "strict"];
@@ -8812,7 +8892,8 @@ function registerCollectionRoutes(app, context) {
8812
8892
  }
8813
8893
  const filter = bodyFilter(request.filter, filterOptions(queryParams(event), config, context.collections.refFields(context, collection)));
8814
8894
  const targetExists = await checkTarget(user, target, request.dropTarget);
8815
- const result = await copyCollection(database, source, target, filter, request.withIndexes, targetExists, systemPrefix());
8895
+ const targetDeclared = context.collections.resolve(context, fullName(target)) !== void 0;
8896
+ const result = await copyCollection(database, source, target, filter, request.withIndexes, targetExists, systemPrefix(), targetDeclared);
8816
8897
  context.events.publish("collection:copy", { user: user.user, collectionName: fullName(source), newCollectionName: fullName(target) });
8817
8898
  return jsonResponse(copyResponse(target, result));
8818
8899
  });
@@ -14487,6 +14568,17 @@ paths:
14487
14568
  required: true
14488
14569
  schema:
14489
14570
  type: string
14571
+ - name: extendedJson
14572
+ in: query
14573
+ description: '2.8.0 in the spec (read since 2.6.0): the mode of the document current of a version conflict (409, code 4092):
14574
+ relaxed (default) or canonical Extended JSON, or plain.'
14575
+ required: false
14576
+ schema:
14577
+ type: string
14578
+ enum:
14579
+ - relaxed
14580
+ - canonical
14581
+ - plain
14490
14582
  requestBody:
14491
14583
  content:
14492
14584
  application/json:
@@ -14556,6 +14648,17 @@ paths:
14556
14648
  required: true
14557
14649
  schema:
14558
14650
  type: string
14651
+ - name: extendedJson
14652
+ in: query
14653
+ description: '2.8.0 in the spec (read since 2.6.0): the mode of the document current of a version conflict (409, code 4092):
14654
+ relaxed (default) or canonical Extended JSON, or plain.'
14655
+ required: false
14656
+ schema:
14657
+ type: string
14658
+ enum:
14659
+ - relaxed
14660
+ - canonical
14661
+ - plain
14559
14662
  requestBody:
14560
14663
  content:
14561
14664
  application/json:
@@ -16462,6 +16565,11 @@ components:
16462
16565
  indexes:
16463
16566
  type: integer
16464
16567
  format: int32
16568
+ skippedIndexes:
16569
+ description: '2.8.0: own indexes of a declaration (mongocamp_idx_*) that were not copied, because the target is not
16570
+ declared (no index sync would manage them there)'
16571
+ type: integer
16572
+ format: int32
16465
16573
  CountResponse:
16466
16574
  title: CountResponse
16467
16575
  type: object
@@ -17017,6 +17125,22 @@ components:
17017
17125
  type: string
17018
17126
  needsRestartForActivation:
17019
17127
  type: boolean
17128
+ source:
17129
+ description: '2.8.0: where the active value comes from \u2014 env, an option of the server, an administrator''s
17130
+ update (patched), a value stored without update (stored, e.g. the default an older server wrote at the first
17131
+ start), or the default'
17132
+ type: string
17133
+ enum:
17134
+ - env
17135
+ - option
17136
+ - patched
17137
+ - stored
17138
+ - default
17139
+ defaultValue:
17140
+ description: '2.8.0: the current default in the form of value; left out for a generated default (AUTH_SECRET)'
17141
+ isDefault:
17142
+ description: '2.8.0: value is the current default'
17143
+ type: boolean
17020
17144
  MongoFindRequest:
17021
17145
  title: MongoFindRequest
17022
17146
  type: object
@@ -17676,6 +17800,20 @@ components:
17676
17800
  builtAt:
17677
17801
  type: string
17678
17802
  format: date-time
17803
+ core:
17804
+ description: '2.8.0: the package of the server core that runs (name and version of the application above may differ)'
17805
+ $ref: '#/components/schemas/CoreVersion'
17806
+ CoreVersion:
17807
+ title: CoreVersion
17808
+ type: object
17809
+ required:
17810
+ - name
17811
+ - version
17812
+ properties:
17813
+ name:
17814
+ type: string
17815
+ version:
17816
+ type: string
17679
17817
  securitySchemes:
17680
17818
  apiKeyAuth:
17681
17819
  type: apiKey
@@ -18555,14 +18693,17 @@ function registerIndexRoutes(app, context) {
18555
18693
  const collection = await administrated(event);
18556
18694
  return jsonResponse((await collection.listIndexes().toArray()).map(indexInfo));
18557
18695
  });
18558
- app.get(`${base}/:indexName`, async (event) => {
18696
+ const existingIndex = async (event) => {
18559
18697
  const collection = await administrated(event);
18560
18698
  const name = pathParam(event, "indexName");
18561
18699
  const index = (await collection.listIndexes().toArray()).find((entry) => entry.name === name);
18562
18700
  if (!index) {
18563
18701
  throw MongocampError.notFound(`index not found with name [${name}]`, 27);
18564
18702
  }
18565
- return jsonResponse(mongoIndex(index));
18703
+ return { collection, name, index };
18704
+ };
18705
+ app.get(`${base}/:indexName`, async (event) => {
18706
+ return jsonResponse(mongoIndex((await existingIndex(event)).index));
18566
18707
  });
18567
18708
  app.put(base, async (event) => {
18568
18709
  const collection = await administrated(event);
@@ -18596,8 +18737,8 @@ function registerIndexRoutes(app, context) {
18596
18737
  return created(await collection.createIndex({ [pathParam(event, "fieldName")]: "text" }, options));
18597
18738
  });
18598
18739
  app.delete(`${base}/:indexName`, async (event) => {
18599
- const collection = await administrated(event);
18600
- await collection.dropIndex(pathParam(event, "indexName"));
18740
+ const { collection, name } = await existingIndex(event);
18741
+ await collection.dropIndex(name);
18601
18742
  return jsonResponse({ dropped: true });
18602
18743
  });
18603
18744
  }
@@ -19029,11 +19170,14 @@ function metrics() {
19029
19170
  };
19030
19171
  }
19031
19172
 
19173
+ const CoreVersion = { name: "@sfxcode/mongocamp-server-core", version: "2.9.0" };
19174
+
19032
19175
  function registerInformationRoutes(app, context) {
19033
19176
  app.get("/version", () => jsonResponse({
19034
19177
  name: context.version.name,
19035
19178
  version: context.version.version,
19036
- builtAt: instantString(context.version.builtAt)
19179
+ builtAt: instantString(context.version.builtAt),
19180
+ core: { name: CoreVersion.name, version: CoreVersion.version }
19037
19181
  }));
19038
19182
  }
19039
19183
 
@@ -19483,7 +19627,7 @@ async function createMongocampServer(options = {}) {
19483
19627
  for (const [name, interceptor] of Object.entries(options.intercept ?? {})) {
19484
19628
  interceptors.on(name, interceptor);
19485
19629
  }
19486
- const configurations = new ConfigPersistence(database, config, events);
19630
+ const configurations = new ConfigPersistence(database, config, events, logger);
19487
19631
  const auth = new AuthService(database, config, version);
19488
19632
  const jobOptions = typeof options.jobs === "object" ? options.jobs : { enabled: options.jobs ?? true };
19489
19633
  const handlers = new Map([
@@ -19618,4 +19762,4 @@ async function connectHooks(server, hooks) {
19618
19762
  };
19619
19763
  }
19620
19764
 
19621
- export { ActAsHeader, AuditCollection, AuthorizedUser, BehaviourDefaults, CleanUpTokenJob, CleanUpTokenJobClass, CollectionRegistry, ConfigKeys, ConfigStore, ConfigurationError, DefaultRowsPerPage, DefaultValidationMode, DocumentService, ErrorCodes, EventBus, FilterDefaultField, HookPrefix, InternalErrorMessage, JobScheduler, LuceneQueryError, MaxExpands, MongocampError, OwnIndexPrefix, PaginationHeaders, SyncValidationLevel, SystemUser, TextMarker, WriteInterceptors, auditCollectionOf, auditRecords, bsonMarkerOptions, collections, combineScopes, configDefinitions, connectHooks, consoleLogger, convertFields, convertIdValue, createMongocampServer, createServerCollection, decodeAny, defineMongocampCollection, documentToJson, ensureAuditIndexes, filterParameter, forwardEventsToHooks, forwardInterceptorsToHooks, guardedPaths, luceneQueryToFilter, luceneToFilter, metrics, notDeleted, ownedBy, parseExtendedJsonMode, parseJson, parseLuceneQuery, pathIdFilter, purgeIndexName, readScope, refsOf, requestFields, requestLogging, resolveBehaviours, resolveIndexes, resolveRefs, restoreUpdate, sameValidator, stampInsert, stampReplace, stampUpdate, stringifyJson, stripDocument, stripUpdate, syncIndexes, syncPurgeIndex, syncValidator, systemFields, toErrorResponse, toMongoJsonSchema, validatorOf$1 as validatorOf, versionInDocument, versionInUpdate, withDeletedOf, withIncrement, withSystemFields, withVersion };
19765
+ export { ActAsHeader, AuditCollection, AuthorizedUser, BehaviourDefaults, CleanUpTokenJob, CleanUpTokenJobClass, CollectionRegistry, ConfigKeys, ConfigStore, ConfigurationError, CoreVersion, DefaultRowsPerPage, DefaultValidationMode, DocumentService, ErrorCodes, EventBus, FilterDefaultField, HookPrefix, InternalErrorMessage, JobScheduler, KeepTimestampsHeader, LuceneQueryError, MaxExpands, MongocampError, OwnIndexPrefix, PaginationHeaders, SyncValidationLevel, SystemUser, TextMarker, WriteInterceptors, auditCollectionOf, auditRecords, bsonMarkerOptions, collections, combineScopes, configDefinitions, connectHooks, consoleLogger, convertFields, convertIdValue, createMongocampServer, createServerCollection, decodeAny, defineMongocampCollection, documentToJson, ensureAuditIndexes, filterParameter, forwardEventsToHooks, forwardInterceptorsToHooks, guardedPaths, luceneQueryToFilter, luceneToFilter, metrics, notDeleted, ownedBy, parseExtendedJsonMode, parseJson, parseLuceneQuery, pathIdFilter, purgeIndexName, readScope, refsOf, requestFields, requestLogging, resolveBehaviours, resolveIndexes, resolveRefs, restoreUpdate, sameValidator, stampInsert, stampReplace, stampUpdate, stringifyJson, stripDocument, stripUpdate, syncIndexes, syncPurgeIndex, syncValidator, systemFields, toErrorResponse, toMongoJsonSchema, validatorOf$1 as validatorOf, versionInDocument, versionInUpdate, withDeletedOf, withIncrement, withSystemFields, withVersion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/mongocamp-server-core",
3
- "version": "2.7.2",
3
+ "version": "2.9.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {