@sfxcode/mongocamp-server-core 2.7.1 → 2.7.2

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
@@ -1904,14 +1904,7 @@ declare class ConfigPersistence {
1904
1904
  private persistentDefinitions;
1905
1905
  /** Registers the missing keys with their defaults (`registerConfig`) and reads the stored values; the refresh starts if wanted. */
1906
1906
  initialize(refreshMillis?: number | false): Promise<void>;
1907
- /**
1908
- * 2.6.0: a database created before 2.2.0 stored the old default 401 of `AUTH_GRANT_DENIED_STATUS` at its first start, and kept answering
1909
- * 401 for a missing grant. A stored 401 that no update set (no `changedAt`, written since 2.6.0) becomes the default 403 once; an
1910
- * administrator who wants 401 patches it again (then it is marked and stays).
1911
- *
1912
- * 2.7.1: the same for an old default of `CORS_HEADERS_EXPOSED` (see `LegacyCorsHeadersExposed`). Without `x-pagination-next` a browser
1913
- * cannot read the cursor, and a cursor read (nuxt-ui-mongocamp `fetchAllDocuments`) ends after the first page without saying so.
1914
- */
1907
+ /** Replaces the stored old defaults of `LegacyDefaults` that nobody set (no `changedAt`, written since 2.6.0) by the current ones. */
1915
1908
  private upgradeLegacyDefaults;
1916
1909
  /** Reads the stored values; at startup also the keys that need a restart, later only the ones that are active at once. */
1917
1910
  refresh(startup: boolean): Promise<void>;
package/dist/index.mjs CHANGED
@@ -1973,6 +1973,19 @@ const LegacyCorsHeadersExposed = [
1973
1973
  ["Content-Type", "x-pagination-rows-per-page", "x-pagination-current-page", "x-pagination-count-rows", "x-pagination-count-pages", "x-request-id"],
1974
1974
  ["Content-Type", "x-pagination-rows-per-page", "x-pagination-current-page", "x-pagination-count-rows", "x-pagination-count-pages", "x-pagination-next", "x-request-id"]
1975
1975
  ];
1976
+ const LegacyAggregationStagesDenied = [
1977
+ ["$function", "$accumulator", "$where", "$out", "$merge", "$currentOp", "$listSessions"]
1978
+ ];
1979
+ const LegacyDefaults = [
1980
+ // a database created before 2.2.0 kept answering 401 for a missing grant
1981
+ { key: ConfigKeys.AuthGrantDeniedStatus, since: "2.6.0", values: [401] },
1982
+ // without x-pagination-next a browser cannot read the cursor, and a cursor read ends after the first page without saying so
1983
+ { key: ConfigKeys.CorsHeadersExposed, since: "2.7.1", values: LegacyCorsHeadersExposed },
1984
+ // the Scala server allowed $collStats and $indexStats
1985
+ { key: ConfigKeys.AggregationStagesDenied, since: "2.7.2", values: LegacyAggregationStagesDenied },
1986
+ // the Scala server served the API reference by default
1987
+ { key: ConfigKeys.DocsSwagger, since: "2.7.2", values: [true] }
1988
+ ];
1976
1989
  const RefreshIntervalMillis = 6e4;
1977
1990
  function plainNumber(value) {
1978
1991
  if (typeof value === "number") {
@@ -2070,21 +2083,16 @@ class ConfigPersistence {
2070
2083
  this.timer.unref?.();
2071
2084
  }
2072
2085
  }
2073
- /**
2074
- * 2.6.0: a database created before 2.2.0 stored the old default 401 of `AUTH_GRANT_DENIED_STATUS` at its first start, and kept answering
2075
- * 401 for a missing grant. A stored 401 that no update set (no `changedAt`, written since 2.6.0) becomes the default 403 once; an
2076
- * administrator who wants 401 patches it again (then it is marked and stays).
2077
- *
2078
- * 2.7.1: the same for an old default of `CORS_HEADERS_EXPOSED` (see `LegacyCorsHeadersExposed`). Without `x-pagination-next` a browser
2079
- * cannot read the cursor, and a cursor read (nuxt-ui-mongocamp `fetchAllDocuments`) ends after the first page without saying so.
2080
- */
2086
+ /** Replaces the stored old defaults of `LegacyDefaults` that nobody set (no `changedAt`, written since 2.6.0) by the current ones. */
2081
2087
  async upgradeLegacyDefaults() {
2082
- await this.collection.updateOne({ key: "AUTH_GRANT_DENIED_STATUS", value: 401, changedAt: { $exists: false } }, { $set: { value: 403 } });
2083
- const corsHeadersExposed = this.config.definition(ConfigKeys.CorsHeadersExposed);
2084
- if (corsHeadersExposed) {
2088
+ for (const { key, values } of LegacyDefaults) {
2089
+ const definition = this.config.definition(key);
2090
+ if (!definition) {
2091
+ continue;
2092
+ }
2085
2093
  await this.collection.updateOne(
2086
- { key: corsHeadersExposed.key, value: { $in: LegacyCorsHeadersExposed }, changedAt: { $exists: false } },
2087
- { $set: { value: toStored(corsHeadersExposed.type, defaultOf(corsHeadersExposed)) } }
2094
+ { key, value: { $in: values }, changedAt: { $exists: false } },
2095
+ { $set: { value: toStored(definition.type, defaultOf(definition)) } }
2088
2096
  );
2089
2097
  }
2090
2098
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/mongocamp-server-core",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {