@bernierllc/content-management-suite 0.10.0 → 2.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/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts","../src/errors.ts"],"sourcesContent":["/*\nCopyright (c) 2025 Bernier LLC\n\nThis file is licensed to the client under a limited-use license.\nThe client may use and modify this code *only within the scope of the project it was delivered for*.\nRedistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.\n*/\n\nimport {\n ContentManagementError,\n ValidationError,\n NotFoundError,\n UnauthorizedError,\n ForbiddenError,\n ConflictError,\n InternalError,\n} from './errors';\n\nexport function getSecurityHeaders(): Record<string, string> {\n return {\n 'X-Content-Type-Options': 'nosniff',\n 'X-Frame-Options': 'DENY',\n 'X-XSS-Protection': '1; mode=block',\n 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',\n 'Referrer-Policy': 'strict-origin-when-cross-origin',\n 'Content-Security-Policy': \"default-src 'self'\",\n 'X-Permitted-Cross-Domain-Policies': 'none',\n 'X-Download-Options': 'noopen',\n };\n}\n\nexport function getCorsConfig(origins?: string[]): {\n allowedOrigins: string[];\n allowedMethods: string[];\n allowedHeaders: string[];\n} {\n return {\n allowedOrigins: origins ?? ['*'],\n allowedMethods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],\n allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'],\n };\n}\n\nexport function errorToHttpStatus(error: Error): number {\n if (error instanceof ValidationError) return 400;\n if (error instanceof UnauthorizedError) return 401;\n if (error instanceof ForbiddenError) return 403;\n if (error instanceof NotFoundError) return 404;\n if (error instanceof ConflictError) return 409;\n if (error instanceof InternalError) return 500;\n if (error instanceof ContentManagementError) return 500;\n return 500;\n}\n","/*\nCopyright (c) 2025 Bernier LLC\n\nThis file is licensed to the client under a limited-use license.\nThe client may use and modify this code *only within the scope of the project it was delivered for*.\nRedistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.\n*/\n\nexport class ContentManagementError extends Error {\n readonly code: string;\n readonly details?: Record<string, unknown>;\n\n constructor(message: string, options?: {\n cause?: Error;\n code?: string;\n details?: Record<string, unknown>;\n }) {\n super(message);\n // Attach cause manually (ES2022 feature; tsconfig targets ES2020 so we set it post-construction)\n if (options?.cause !== undefined) {\n (this as unknown as { cause: Error }).cause = options.cause;\n }\n this.name = this.constructor.name;\n this.code = options?.code ?? 'CONTENT_MANAGEMENT_ERROR';\n if (options?.details !== undefined) {\n this.details = options.details;\n }\n }\n}\n\nexport class ValidationError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'VALIDATION_ERROR' });\n }\n}\n\nexport class NotFoundError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'NOT_FOUND' });\n }\n}\n\nexport class UnauthorizedError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'UNAUTHORIZED' });\n }\n}\n\nexport class ForbiddenError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'FORBIDDEN' });\n }\n}\n\nexport class ConflictError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'CONFLICT' });\n }\n}\n\nexport class InternalError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'INTERNAL_ERROR' });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,yBAAN,cAAqC,MAAM;AAAA,EAIhD,YAAY,SAAiB,SAI1B;AACD,UAAM,OAAO;AAEb,QAAI,SAAS,UAAU,QAAW;AAChC,MAAC,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,EACxB;AACF;AAEO,SAAS,cAAc,SAI5B;AACA,SAAO;AAAA,IACL,gBAAgB,WAAW,CAAC,GAAG;AAAA,IAC/B,gBAAgB,CAAC,OAAO,QAAQ,OAAO,UAAU,SAAS,SAAS;AAAA,IACnE,gBAAgB,CAAC,gBAAgB,iBAAiB,kBAAkB;AAAA,EACtE;AACF;AAEO,SAAS,kBAAkB,OAAsB;AACtD,MAAI,iBAAiB;AAAiB,WAAO;AAC7C,MAAI,iBAAiB;AAAmB,WAAO;AAC/C,MAAI,iBAAiB;AAAgB,WAAO;AAC5C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAwB,WAAO;AACpD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/utils.ts","../src/errors.ts"],"sourcesContent":["/*\nCopyright (c) 2025 Bernier LLC\n\nThis file is licensed to the client under a limited-use license.\nThe client may use and modify this code *only within the scope of the project it was delivered for*.\nRedistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.\n*/\n\nimport {\n ContentManagementError,\n ValidationError,\n NotFoundError,\n UnauthorizedError,\n ForbiddenError,\n ConflictError,\n InternalError,\n} from './errors';\n\nexport function getSecurityHeaders(): Record<string, string> {\n return {\n 'X-Content-Type-Options': 'nosniff',\n 'X-Frame-Options': 'DENY',\n 'X-XSS-Protection': '1; mode=block',\n 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',\n 'Referrer-Policy': 'strict-origin-when-cross-origin',\n 'Content-Security-Policy': \"default-src 'self'\",\n 'X-Permitted-Cross-Domain-Policies': 'none',\n 'X-Download-Options': 'noopen',\n };\n}\n\nexport function getCorsConfig(origins?: string[]): {\n allowedOrigins: string[];\n allowedMethods: string[];\n allowedHeaders: string[];\n} {\n return {\n allowedOrigins: origins ?? ['*'],\n allowedMethods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],\n allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'],\n };\n}\n\nexport function errorToHttpStatus(error: Error): number {\n if (error instanceof ValidationError) return 400;\n if (error instanceof UnauthorizedError) return 401;\n if (error instanceof ForbiddenError) return 403;\n if (error instanceof NotFoundError) return 404;\n if (error instanceof ConflictError) return 409;\n if (error instanceof InternalError) return 500;\n if (error instanceof ContentManagementError) return 500;\n return 500;\n}\n","/*\nCopyright (c) 2025 Bernier LLC\n\nThis file is licensed to the client under a limited-use license.\nThe client may use and modify this code *only within the scope of the project it was delivered for*.\nRedistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.\n*/\n\n/**\n * Typed error code union for content-management-suite errors.\n */\nexport type ContentManagementErrorCode =\n | 'CONTENT_MANAGEMENT_ERROR'\n | 'VALIDATION_ERROR'\n | 'NOT_FOUND'\n | 'UNAUTHORIZED'\n | 'FORBIDDEN'\n | 'CONFLICT'\n | 'INTERNAL_ERROR';\n\n/**\n * Options bag accepted by `ContentManagementError`.\n *\n * - `cause`: chained underlying error (ES2022 Error.cause).\n * - `code`: a typed error code from {@link ContentManagementErrorCode}.\n * - `context`: arbitrary structured context.\n */\nexport interface ContentManagementErrorOptions {\n cause?: Error;\n code?: ContentManagementErrorCode;\n context?: Record<string, unknown>;\n}\n\n/**\n * Custom error class for content-management-suite errors.\n *\n * Uses native ES2022 `Error.cause` for error chaining read the underlying\n * error via `error.cause`. Structured context lives on `error.context`.\n */\nexport class ContentManagementError extends Error {\n public readonly code: ContentManagementErrorCode;\n public readonly context?: Record<string, unknown>;\n\n constructor(message: string, options?: ContentManagementErrorOptions) {\n super(message, options?.cause ? { cause: options.cause } : undefined);\n this.name = this.constructor.name;\n this.code = options?.code ?? 'CONTENT_MANAGEMENT_ERROR';\n if (options?.context !== undefined) {\n this.context = options.context;\n }\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\nexport class ValidationError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'VALIDATION_ERROR' });\n }\n}\n\nexport class NotFoundError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'NOT_FOUND' });\n }\n}\n\nexport class UnauthorizedError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'UNAUTHORIZED' });\n }\n}\n\nexport class ForbiddenError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'FORBIDDEN' });\n }\n}\n\nexport class ConflictError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'CONFLICT' });\n }\n}\n\nexport class InternalError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'INTERNAL_ERROR' });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACuCO,IAAM,yBAAN,cAAqC,MAAM;AAAA,EAChC;AAAA,EACA;AAAA,EAEhB,YAAY,SAAiB,SAAyC;AACpE,UAAM,SAAS,SAAS,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,MAAS;AACpE,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,OAAO,SAAS,QAAQ;AAC7B,QAAI,SAAS,YAAY,QAAW;AAClC,WAAK,UAAU,QAAQ;AAAA,IACzB;AACA,UAAM,oBAAoB,MAAM,KAAK,WAAW;AAAA,EAClD;AACF;AAEO,IAAM,kBAAN,cAA8B,uBAAuB;AAAA,EAC1D,YAAY,SAAiB,SAAgE;AAC3F,UAAM,SAAS,EAAE,GAAG,SAAS,MAAM,mBAAmB,CAAC;AAAA,EACzD;AACF;AAEO,IAAM,gBAAN,cAA4B,uBAAuB;AAAA,EACxD,YAAY,SAAiB,SAAgE;AAC3F,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iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAwB,WAAO;AACpD,SAAO;AACT;","names":[]}
package/dist/utils.mjs CHANGED
@@ -1,15 +1,15 @@
1
1
  // src/errors.ts
2
2
  var ContentManagementError = class extends Error {
3
+ code;
4
+ context;
3
5
  constructor(message, options) {
4
- super(message);
5
- if (options?.cause !== void 0) {
6
- this.cause = options.cause;
7
- }
6
+ super(message, options?.cause ? { cause: options.cause } : void 0);
8
7
  this.name = this.constructor.name;
9
8
  this.code = options?.code ?? "CONTENT_MANAGEMENT_ERROR";
10
- if (options?.details !== void 0) {
11
- this.details = options.details;
9
+ if (options?.context !== void 0) {
10
+ this.context = options.context;
12
11
  }
12
+ Error.captureStackTrace?.(this, this.constructor);
13
13
  }
14
14
  };
15
15
  var ValidationError = class extends ContentManagementError {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/utils.ts"],"sourcesContent":["/*\nCopyright (c) 2025 Bernier LLC\n\nThis file is licensed to the client under a limited-use license.\nThe client may use and modify this code *only within the scope of the project it was delivered for*.\nRedistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.\n*/\n\nexport class ContentManagementError extends Error {\n readonly code: string;\n readonly details?: Record<string, unknown>;\n\n constructor(message: string, options?: {\n cause?: Error;\n code?: string;\n details?: Record<string, unknown>;\n }) {\n super(message);\n // Attach cause manually (ES2022 feature; tsconfig targets ES2020 so we set it post-construction)\n if (options?.cause !== undefined) {\n (this as unknown as { cause: Error }).cause = options.cause;\n }\n this.name = this.constructor.name;\n this.code = options?.code ?? 'CONTENT_MANAGEMENT_ERROR';\n if (options?.details !== undefined) {\n this.details = options.details;\n }\n }\n}\n\nexport class ValidationError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'VALIDATION_ERROR' });\n }\n}\n\nexport class NotFoundError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'NOT_FOUND' });\n }\n}\n\nexport class UnauthorizedError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'UNAUTHORIZED' });\n }\n}\n\nexport class ForbiddenError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'FORBIDDEN' });\n }\n}\n\nexport class ConflictError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'CONFLICT' });\n }\n}\n\nexport class InternalError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; details?: Record<string, unknown> }) {\n super(message, { ...options, code: 'INTERNAL_ERROR' });\n }\n}\n","/*\nCopyright (c) 2025 Bernier LLC\n\nThis file is licensed to the client under a limited-use license.\nThe client may use and modify this code *only within the scope of the project it was delivered for*.\nRedistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.\n*/\n\nimport {\n ContentManagementError,\n ValidationError,\n NotFoundError,\n UnauthorizedError,\n ForbiddenError,\n ConflictError,\n InternalError,\n} from './errors';\n\nexport function getSecurityHeaders(): Record<string, string> {\n return {\n 'X-Content-Type-Options': 'nosniff',\n 'X-Frame-Options': 'DENY',\n 'X-XSS-Protection': '1; mode=block',\n 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',\n 'Referrer-Policy': 'strict-origin-when-cross-origin',\n 'Content-Security-Policy': \"default-src 'self'\",\n 'X-Permitted-Cross-Domain-Policies': 'none',\n 'X-Download-Options': 'noopen',\n };\n}\n\nexport function getCorsConfig(origins?: string[]): {\n allowedOrigins: string[];\n allowedMethods: string[];\n allowedHeaders: string[];\n} {\n return {\n allowedOrigins: origins ?? ['*'],\n allowedMethods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],\n allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'],\n };\n}\n\nexport function errorToHttpStatus(error: Error): number {\n if (error instanceof ValidationError) return 400;\n if (error instanceof UnauthorizedError) return 401;\n if (error instanceof ForbiddenError) return 403;\n if (error instanceof NotFoundError) return 404;\n if (error instanceof ConflictError) return 409;\n if (error instanceof InternalError) return 500;\n if (error instanceof ContentManagementError) return 500;\n return 500;\n}\n"],"mappings":";AAQO,IAAM,yBAAN,cAAqC,MAAM;AAAA,EAIhD,YAAY,SAAiB,SAI1B;AACD,UAAM,OAAO;AAEb,QAAI,SAAS,UAAU,QAAW;AAChC,MAAC,KAAqC,QAAQ,QAAQ;AAAA,IACxD;AACA,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,OAAO,SAAS,QAAQ;AAC7B,QAAI,SAAS,YAAY,QAAW;AAClC,WAAK,UAAU,QAAQ;AAAA,IACzB;AAAA,EACF;AACF;AAEO,IAAM,kBAAN,cAA8B,uBAAuB;AAAA,EAC1D,YAAY,SAAiB,SAAgE;AAC3F,UAAM,SAAS,EAAE,GAAG,SAAS,MAAM,mBAAmB,CAAC;AAAA,EACzD;AACF;AAEO,IAAM,gBAAN,cAA4B,uBAAuB;AAAA,EACxD,YAAY,SAAiB,SAAgE;AAC3F,UAAM,SAAS,EAAE,GAAG,SAAS,MAAM,YAAY,CAAC;AAAA,EAClD;AACF;AAEO,IAAM,oBAAN,cAAgC,uBAAuB;AAAA,EAC5D,YAAY,SAAiB,SAAgE;AAC3F,UAAM,SAAS,EAAE,GAAG,SAAS,MAAM,eAAe,CAAC;AAAA,EACrD;AACF;AAEO,IAAM,iBAAN,cAA6B,uBAAuB;AAAA,EACzD,YAAY,SAAiB,SAAgE;AAC3F,UAAM,SAAS,EAAE,GAAG,SAAS,MAAM,YAAY,CAAC;AAAA,EAClD;AACF;AAEO,IAAM,gBAAN,cAA4B,uBAAuB;AAAA,EACxD,YAAY,SAAiB,SAAgE;AAC3F,UAAM,SAAS,EAAE,GAAG,SAAS,MAAM,WAAW,CAAC;AAAA,EACjD;AACF;AAEO,IAAM,gBAAN,cAA4B,uBAAuB;AAAA,EACxD,YAAY,SAAiB,SAAgE;AAC3F,UAAM,SAAS,EAAE,GAAG,SAAS,MAAM,iBAAiB,CAAC;AAAA,EACvD;AACF;;;AC9CO,SAAS,qBAA6C;AAC3D,SAAO;AAAA,IACL,0BAA0B;AAAA,IAC1B,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,6BAA6B;AAAA,IAC7B,mBAAmB;AAAA,IACnB,2BAA2B;AAAA,IAC3B,qCAAqC;AAAA,IACrC,sBAAsB;AAAA,EACxB;AACF;AAEO,SAAS,cAAc,SAI5B;AACA,SAAO;AAAA,IACL,gBAAgB,WAAW,CAAC,GAAG;AAAA,IAC/B,gBAAgB,CAAC,OAAO,QAAQ,OAAO,UAAU,SAAS,SAAS;AAAA,IACnE,gBAAgB,CAAC,gBAAgB,iBAAiB,kBAAkB;AAAA,EACtE;AACF;AAEO,SAAS,kBAAkB,OAAsB;AACtD,MAAI,iBAAiB;AAAiB,WAAO;AAC7C,MAAI,iBAAiB;AAAmB,WAAO;AAC/C,MAAI,iBAAiB;AAAgB,WAAO;AAC5C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAwB,WAAO;AACpD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/utils.ts"],"sourcesContent":["/*\nCopyright (c) 2025 Bernier LLC\n\nThis file is licensed to the client under a limited-use license.\nThe client may use and modify this code *only within the scope of the project it was delivered for*.\nRedistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.\n*/\n\n/**\n * Typed error code union for content-management-suite errors.\n */\nexport type ContentManagementErrorCode =\n | 'CONTENT_MANAGEMENT_ERROR'\n | 'VALIDATION_ERROR'\n | 'NOT_FOUND'\n | 'UNAUTHORIZED'\n | 'FORBIDDEN'\n | 'CONFLICT'\n | 'INTERNAL_ERROR';\n\n/**\n * Options bag accepted by `ContentManagementError`.\n *\n * - `cause`: chained underlying error (ES2022 Error.cause).\n * - `code`: a typed error code from {@link ContentManagementErrorCode}.\n * - `context`: arbitrary structured context.\n */\nexport interface ContentManagementErrorOptions {\n cause?: Error;\n code?: ContentManagementErrorCode;\n context?: Record<string, unknown>;\n}\n\n/**\n * Custom error class for content-management-suite errors.\n *\n * Uses native ES2022 `Error.cause` for error chaining read the underlying\n * error via `error.cause`. Structured context lives on `error.context`.\n */\nexport class ContentManagementError extends Error {\n public readonly code: ContentManagementErrorCode;\n public readonly context?: Record<string, unknown>;\n\n constructor(message: string, options?: ContentManagementErrorOptions) {\n super(message, options?.cause ? { cause: options.cause } : undefined);\n this.name = this.constructor.name;\n this.code = options?.code ?? 'CONTENT_MANAGEMENT_ERROR';\n if (options?.context !== undefined) {\n this.context = options.context;\n }\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\n\nexport class ValidationError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'VALIDATION_ERROR' });\n }\n}\n\nexport class NotFoundError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'NOT_FOUND' });\n }\n}\n\nexport class UnauthorizedError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'UNAUTHORIZED' });\n }\n}\n\nexport class ForbiddenError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'FORBIDDEN' });\n }\n}\n\nexport class ConflictError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'CONFLICT' });\n }\n}\n\nexport class InternalError extends ContentManagementError {\n constructor(message: string, options?: { cause?: Error; context?: Record<string, unknown> }) {\n super(message, { ...options, code: 'INTERNAL_ERROR' });\n }\n}\n","/*\nCopyright (c) 2025 Bernier LLC\n\nThis file is licensed to the client under a limited-use license.\nThe client may use and modify this code *only within the scope of the project it was delivered for*.\nRedistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.\n*/\n\nimport {\n ContentManagementError,\n ValidationError,\n NotFoundError,\n UnauthorizedError,\n ForbiddenError,\n ConflictError,\n InternalError,\n} from './errors';\n\nexport function getSecurityHeaders(): Record<string, string> {\n return {\n 'X-Content-Type-Options': 'nosniff',\n 'X-Frame-Options': 'DENY',\n 'X-XSS-Protection': '1; mode=block',\n 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',\n 'Referrer-Policy': 'strict-origin-when-cross-origin',\n 'Content-Security-Policy': \"default-src 'self'\",\n 'X-Permitted-Cross-Domain-Policies': 'none',\n 'X-Download-Options': 'noopen',\n };\n}\n\nexport function getCorsConfig(origins?: string[]): {\n allowedOrigins: string[];\n allowedMethods: string[];\n allowedHeaders: string[];\n} {\n return {\n allowedOrigins: origins ?? ['*'],\n allowedMethods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],\n allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'],\n };\n}\n\nexport function errorToHttpStatus(error: Error): number {\n if (error instanceof ValidationError) return 400;\n if (error instanceof UnauthorizedError) return 401;\n if (error instanceof ForbiddenError) return 403;\n if (error instanceof NotFoundError) return 404;\n if (error instanceof ConflictError) return 409;\n if (error instanceof InternalError) return 500;\n if (error instanceof ContentManagementError) return 500;\n return 500;\n}\n"],"mappings":";AAuCO,IAAM,yBAAN,cAAqC,MAAM;AAAA,EAChC;AAAA,EACA;AAAA,EAEhB,YAAY,SAAiB,SAAyC;AACpE,UAAM,SAAS,SAAS,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,MAAS;AACpE,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,OAAO,SAAS,QAAQ;AAC7B,QAAI,SAAS,YAAY,QAAW;AAClC,WAAK,UAAU,QAAQ;AAAA,IACz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Q,OAAO,UAAU,SAAS,SAAS;AAAA,IACnE,gBAAgB,CAAC,gBAAgB,iBAAiB,kBAAkB;AAAA,EACtE;AACF;AAEO,SAAS,kBAAkB,OAAsB;AACtD,MAAI,iBAAiB;AAAiB,WAAO;AAC7C,MAAI,iBAAiB;AAAmB,WAAO;AAC/C,MAAI,iBAAiB;AAAgB,WAAO;AAC5C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAe,WAAO;AAC3C,MAAI,iBAAiB;AAAwB,WAAO;AACpD,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/content-management-suite",
3
- "version": "0.10.0",
3
+ "version": "2.0.0",
4
4
  "description": "Comprehensive content management suite with editorial workflows, content types, and admin UI",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -46,12 +46,12 @@
46
46
  "dependencies": {
47
47
  "zod": "^3.22.0",
48
48
  "@bernierllc/content-autosave-manager": "1.6.0",
49
+ "@bernierllc/content-editorial-workflow": "0.5.0",
49
50
  "@bernierllc/content-soft-delete": "1.6.0",
50
51
  "@bernierllc/content-type-audio": "1.5.0",
51
52
  "@bernierllc/content-type-image": "1.5.0",
52
53
  "@bernierllc/content-type-registry": "1.6.0",
53
54
  "@bernierllc/content-type-text": "1.5.0",
54
- "@bernierllc/content-editorial-workflow": "0.5.0",
55
55
  "@bernierllc/content-type-video": "1.5.0",
56
56
  "@bernierllc/content-workflow-ui": "0.5.0"
57
57
  },