@momentumcms/server-express 0.5.1 → 0.5.3

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/index.cjs CHANGED
@@ -1660,6 +1660,7 @@ __export(src_exports3, {
1660
1660
  createProtectMiddleware: () => createProtectMiddleware,
1661
1661
  createSessionResolverMiddleware: () => createSessionResolverMiddleware,
1662
1662
  createSetupMiddleware: () => createSetupMiddleware,
1663
+ getPluginMiddleware: () => getPluginMiddleware,
1663
1664
  getPluginProviders: () => getPluginProviders,
1664
1665
  initializeMomentum: () => initializeMomentum,
1665
1666
  momentumApiMiddleware: () => momentumApiMiddleware
@@ -2143,6 +2144,31 @@ function validateRowCount(name, label, count, minRows, maxRows, errors) {
2143
2144
  }
2144
2145
 
2145
2146
  // libs/core/src/lib/collections/media.collection.ts
2147
+ var validateFocalPoint = (value) => {
2148
+ if (value === null || value === void 0)
2149
+ return true;
2150
+ if (typeof value !== "object" || Array.isArray(value)) {
2151
+ return "Focal point must be an object with x and y coordinates";
2152
+ }
2153
+ const fp = Object.fromEntries(Object.entries(value));
2154
+ if (!("x" in fp) || !("y" in fp)) {
2155
+ return "Focal point must have both x and y properties";
2156
+ }
2157
+ const { x, y } = fp;
2158
+ if (typeof x !== "number" || !Number.isFinite(x)) {
2159
+ return "Focal point x must be a finite number";
2160
+ }
2161
+ if (typeof y !== "number" || !Number.isFinite(y)) {
2162
+ return "Focal point y must be a finite number";
2163
+ }
2164
+ if (x < 0 || x > 1) {
2165
+ return `Focal point x must be between 0 and 1 (received ${x})`;
2166
+ }
2167
+ if (y < 0 || y > 1) {
2168
+ return `Focal point y must be between 0 and 1 (received ${y})`;
2169
+ }
2170
+ return true;
2171
+ };
2146
2172
  var MediaCollection = defineCollection({
2147
2173
  slug: "media",
2148
2174
  labels: {
@@ -2197,6 +2223,14 @@ var MediaCollection = defineCollection({
2197
2223
  json("focalPoint", {
2198
2224
  label: "Focal Point",
2199
2225
  description: "Focal point coordinates for image cropping",
2226
+ validate: validateFocalPoint,
2227
+ admin: {
2228
+ hidden: true
2229
+ }
2230
+ }),
2231
+ json("sizes", {
2232
+ label: "Image Sizes",
2233
+ description: "Generated image size variants",
2200
2234
  admin: {
2201
2235
  hidden: true
2202
2236
  }
@@ -3055,6 +3089,15 @@ function deepEqual(a, b) {
3055
3089
  (key) => Object.prototype.hasOwnProperty.call(bRec, key) && deepEqual(aRec[key], bRec[key])
3056
3090
  );
3057
3091
  }
3092
+ function stripTransientKeys(data) {
3093
+ const result = {};
3094
+ for (const [key, value] of Object.entries(data)) {
3095
+ if (!key.startsWith("_")) {
3096
+ result[key] = value;
3097
+ }
3098
+ }
3099
+ return result;
3100
+ }
3058
3101
  function flattenWhereClause(where) {
3059
3102
  if (!where)
3060
3103
  return {};
@@ -3218,6 +3261,7 @@ var CollectionOperationsImpl = class _CollectionOperationsImpl {
3218
3261
  );
3219
3262
  }
3220
3263
  processedData = await this.runHooks("beforeChange", processedData, "create");
3264
+ processedData = stripTransientKeys(processedData);
3221
3265
  const doc = await this.adapter.create(this.slug, processedData);
3222
3266
  await this.runHooks("afterChange", doc, "create");
3223
3267
  if (hasFieldHooks(this.collectionConfig.fields)) {
@@ -3278,6 +3322,7 @@ var CollectionOperationsImpl = class _CollectionOperationsImpl {
3278
3322
  );
3279
3323
  }
3280
3324
  processedData = await this.runHooks("beforeChange", processedData, "update", originalDoc);
3325
+ processedData = stripTransientKeys(processedData);
3281
3326
  const doc = await this.adapter.update(this.slug, id, processedData);
3282
3327
  await this.runHooks("afterChange", doc, "update", originalDoc);
3283
3328
  if (hasFieldHooks(this.collectionConfig.fields)) {
@@ -5392,7 +5437,8 @@ async function handleUpload(config, request) {
5392
5437
  filesize: file.size,
5393
5438
  path: storedFile.path,
5394
5439
  url: storedFile.url,
5395
- alt: alt ?? ""
5440
+ alt: alt ?? "",
5441
+ _file: file
5396
5442
  };
5397
5443
  const api = getMomentumAPI().setContext({ user });
5398
5444
  const doc = await api.collection(collection).create(mediaData);
@@ -5459,7 +5505,8 @@ async function handleCollectionUpload(globalConfig, request) {
5459
5505
  mimeType: file.mimeType,
5460
5506
  filesize: file.size,
5461
5507
  path: storedFile.path,
5462
- url: storedFile.url
5508
+ url: storedFile.url,
5509
+ _file: file
5463
5510
  };
5464
5511
  const api = getMomentumAPI().setContext({ user });
5465
5512
  const doc = await api.collection(collectionSlug).create(docData);
@@ -5496,6 +5543,7 @@ function getMimeTypeFromPath(path) {
5496
5543
  png: "image/png",
5497
5544
  gif: "image/gif",
5498
5545
  webp: "image/webp",
5546
+ avif: "image/avif",
5499
5547
  svg: "image/svg+xml",
5500
5548
  pdf: "application/pdf",
5501
5549
  json: "application/json",
@@ -8785,6 +8833,7 @@ async function createMomentumServer(options) {
8785
8833
  createProtectMiddleware,
8786
8834
  createSessionResolverMiddleware,
8787
8835
  createSetupMiddleware,
8836
+ getPluginMiddleware,
8788
8837
  getPluginProviders,
8789
8838
  initializeMomentum,
8790
8839
  momentumApiMiddleware
package/index.js CHANGED
@@ -2100,6 +2100,31 @@ function validateRowCount(name, label, count, minRows, maxRows, errors) {
2100
2100
  }
2101
2101
 
2102
2102
  // libs/core/src/lib/collections/media.collection.ts
2103
+ var validateFocalPoint = (value) => {
2104
+ if (value === null || value === void 0)
2105
+ return true;
2106
+ if (typeof value !== "object" || Array.isArray(value)) {
2107
+ return "Focal point must be an object with x and y coordinates";
2108
+ }
2109
+ const fp = Object.fromEntries(Object.entries(value));
2110
+ if (!("x" in fp) || !("y" in fp)) {
2111
+ return "Focal point must have both x and y properties";
2112
+ }
2113
+ const { x, y } = fp;
2114
+ if (typeof x !== "number" || !Number.isFinite(x)) {
2115
+ return "Focal point x must be a finite number";
2116
+ }
2117
+ if (typeof y !== "number" || !Number.isFinite(y)) {
2118
+ return "Focal point y must be a finite number";
2119
+ }
2120
+ if (x < 0 || x > 1) {
2121
+ return `Focal point x must be between 0 and 1 (received ${x})`;
2122
+ }
2123
+ if (y < 0 || y > 1) {
2124
+ return `Focal point y must be between 0 and 1 (received ${y})`;
2125
+ }
2126
+ return true;
2127
+ };
2103
2128
  var MediaCollection = defineCollection({
2104
2129
  slug: "media",
2105
2130
  labels: {
@@ -2154,6 +2179,14 @@ var MediaCollection = defineCollection({
2154
2179
  json("focalPoint", {
2155
2180
  label: "Focal Point",
2156
2181
  description: "Focal point coordinates for image cropping",
2182
+ validate: validateFocalPoint,
2183
+ admin: {
2184
+ hidden: true
2185
+ }
2186
+ }),
2187
+ json("sizes", {
2188
+ label: "Image Sizes",
2189
+ description: "Generated image size variants",
2157
2190
  admin: {
2158
2191
  hidden: true
2159
2192
  }
@@ -3012,6 +3045,15 @@ function deepEqual(a, b) {
3012
3045
  (key) => Object.prototype.hasOwnProperty.call(bRec, key) && deepEqual(aRec[key], bRec[key])
3013
3046
  );
3014
3047
  }
3048
+ function stripTransientKeys(data) {
3049
+ const result = {};
3050
+ for (const [key, value] of Object.entries(data)) {
3051
+ if (!key.startsWith("_")) {
3052
+ result[key] = value;
3053
+ }
3054
+ }
3055
+ return result;
3056
+ }
3015
3057
  function flattenWhereClause(where) {
3016
3058
  if (!where)
3017
3059
  return {};
@@ -3175,6 +3217,7 @@ var CollectionOperationsImpl = class _CollectionOperationsImpl {
3175
3217
  );
3176
3218
  }
3177
3219
  processedData = await this.runHooks("beforeChange", processedData, "create");
3220
+ processedData = stripTransientKeys(processedData);
3178
3221
  const doc = await this.adapter.create(this.slug, processedData);
3179
3222
  await this.runHooks("afterChange", doc, "create");
3180
3223
  if (hasFieldHooks(this.collectionConfig.fields)) {
@@ -3235,6 +3278,7 @@ var CollectionOperationsImpl = class _CollectionOperationsImpl {
3235
3278
  );
3236
3279
  }
3237
3280
  processedData = await this.runHooks("beforeChange", processedData, "update", originalDoc);
3281
+ processedData = stripTransientKeys(processedData);
3238
3282
  const doc = await this.adapter.update(this.slug, id, processedData);
3239
3283
  await this.runHooks("afterChange", doc, "update", originalDoc);
3240
3284
  if (hasFieldHooks(this.collectionConfig.fields)) {
@@ -5362,7 +5406,8 @@ async function handleUpload(config, request) {
5362
5406
  filesize: file.size,
5363
5407
  path: storedFile.path,
5364
5408
  url: storedFile.url,
5365
- alt: alt ?? ""
5409
+ alt: alt ?? "",
5410
+ _file: file
5366
5411
  };
5367
5412
  const api = getMomentumAPI().setContext({ user });
5368
5413
  const doc = await api.collection(collection).create(mediaData);
@@ -5429,7 +5474,8 @@ async function handleCollectionUpload(globalConfig, request) {
5429
5474
  mimeType: file.mimeType,
5430
5475
  filesize: file.size,
5431
5476
  path: storedFile.path,
5432
- url: storedFile.url
5477
+ url: storedFile.url,
5478
+ _file: file
5433
5479
  };
5434
5480
  const api = getMomentumAPI().setContext({ user });
5435
5481
  const doc = await api.collection(collectionSlug).create(docData);
@@ -5466,6 +5512,7 @@ function getMimeTypeFromPath(path) {
5466
5512
  png: "image/png",
5467
5513
  gif: "image/gif",
5468
5514
  webp: "image/webp",
5515
+ avif: "image/avif",
5469
5516
  svg: "image/svg+xml",
5470
5517
  pdf: "application/pdf",
5471
5518
  json: "application/json",
@@ -8754,6 +8801,7 @@ export {
8754
8801
  createProtectMiddleware,
8755
8802
  createSessionResolverMiddleware,
8756
8803
  createSetupMiddleware,
8804
+ getPluginMiddleware,
8757
8805
  getPluginProviders,
8758
8806
  initializeMomentum,
8759
8807
  momentumApiMiddleware
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momentumcms/server-express",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Express adapter for Momentum CMS with Angular SSR support",
5
5
  "license": "MIT",
6
6
  "author": "Momentum CMS Contributors",
package/src/index.d.ts CHANGED
@@ -3,5 +3,5 @@ export { createAuthMiddleware, createProtectMiddleware, createSessionResolverMid
3
3
  export { createSetupMiddleware, type SetupStatus, type SetupMiddlewareConfig, } from './lib/setup-middleware';
4
4
  export { createApiKeyResolverMiddleware, createApiKeyRoutes, type ApiKeyMiddlewareConfig, } from './lib/api-key-middleware';
5
5
  export { initializeMomentum, createHealthMiddleware, type MomentumInitResult, type SeedingStatus, type InitializeMomentumOptions, type HealthMiddlewareOptions, type HealthResponse, } from './lib/init-helpers';
6
- export { getPluginProviders } from './lib/plugin-middleware-registry';
6
+ export { getPluginMiddleware, getPluginProviders } from './lib/plugin-middleware-registry';
7
7
  export { createMomentumServer, type CreateMomentumServerOptions, type MomentumServer, } from './lib/create-momentum-server';