@infuro/cms-core 1.0.53 → 1.0.54

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { emitOrderNotificationTrigger, fireOrderNotificationTrigger } from './chunk-MXIWUFBP.js';
2
- import { checkMultiVendorEnabled, loadUserVendorContext, getPublicSettingsGroup, BlogGeneratorService } from './chunk-UO5Q5RXB.js';
3
- export { Address, Attendee, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, BlogGeneratorService, Brand, CMS_ENTITY_MAP, Cart, CartItem, Category, ChatConversation, ChatMessage, Collection, Combo, ComboItem, Comment, Config, Contact, Currency, CurrencyExchange, Customer, Customer_Contacts, Discount, DiscountRules, Event, EventProduct, Form, FormField, FormSubmission, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, LlmAgent, LlmAgentKnowledgeDocument, Media, MessageTemplate, Order, OrderAddresses, OrderDiscounts, OrderItem, OrderNotificationBinding, OrderNotificationTrigger, OtpChallenge, Page, PasswordResetToken, Payment, Permission, Product, ProductAttribute, ProductCategory, ProductConfig, ProductVariant, RefundPolicy, RefundRequest, RssArticle, RssFeed, Seo, Tag, Tax, User, UserDeviceToken, UserGroup, Vendor, VendorCustomer, VendorRole, VendorRolePermission, VendorUser, VendorUserProfile, Wishlist, WishlistItem, ZIP_MIME_TYPES, applyApprovalStatusSideEffects, applyEventApprovalStatusSideEffects, applyRotatingVendorInvite, applyVendorCustomersContactFilter, applyVendorEventCreateApproval, applyVendorProductCreateApproval, assertCaptchaOk, assertContactAllowedForVendorOrder, assertEventApprovalUpdate, assertProductApprovalUpdate, buildBlogMetadataUserPrompt, buildCronFromSchedule, buildRssUserPromptFromFeeds, buildUserInviteLink, buildVendorInviteLink, calculateOrderRefundPreview, calculateRefundFromPolicy, checkAndIncrementDiscountUsage, checkEventsEnabled, checkMultiVendorEnabled, completeUserInviteAccept, consumeAppliedDiscountUsages, contactIsVendorCustomer, countDiscountOrdersForContact, countRecentOtpSends, createAnalyticsHandlers, createBlogBySlugHandler, createChangePasswordHandler, createCmsApiHandler, createCmsApp, createCmsAppWithMessaging, createCrudByIdHandler, createCrudHandler, createDashboardStatsHandler, createEcommerceAnalyticsHandler, createEventOrderMessageTemplateHandlers, createForgotPasswordHandler, createFormBySlugHandler, createInviteAcceptHandler, createJobScheduleHandlers, createLlmAgentKnowledgeHandlers, createMediaZipExtractHandler, createMessageTemplateRowLoader, createOtpChallenge, createSetPasswordHandler, createSettingsApiHandlers, createSocialMediaHandlers, createStorefrontApiHandler, createUploadHandler, createUserAuthApiRouter, createUserAvatarHandler, createUserProfileHandler, createUsersApiHandlers, createVendorDashboardHandler, createVendorOnboardHandlers, daysBeforeEventStart, decrementDiscountUsage, describeEventTierPolicy, ensureMessagingPluginsOnCms, ensureScheduleQueueWorker, ensureVendorCustomerForOrderContact, ensureVendorCustomersForOrder, findActiveRefundPolicyForVendor, findUserByInviteToken, findVendorByInviteToken, formatTierRange, generateNumericOtp, getPublicSettingsGroup, getRequireEventApproval, getRequireProductApproval, getRssArticleSummaryFromItem, getVendorCatalogCreateFlags, hashOtpCode, hydrateVendorSessionUser, invalidateEventsCache, invalidateMultiVendorCache, invalidateRequireEventApprovalCache, invalidateRequireProductApprovalCache, invalidateVendorCatalogCreateFlagsCache, isCustomerTypeContact, isMaxPerUserUsageReached, isMaxTotalUsageReached, isZipMedia, llmAgentToChatAgentOptions, loadSettingsGroupFromDb, loadUserVendorContext, mergeGuardrailsIntoSystemPrompt, messagingPlugins, metaFetchUserManagedPages, metaPostPageFeed, metaPostPagePhoto, metaResolvePageAccessToken, newUserInviteToken, normalizePhoneE164, normalizeRefundTiers, overlayCmsPlugins, parseBlogGeneratorAgentContent, parseBlogGeneratorModelOutput, parseBlogMetadataEnrichmentJson, parseLlmAgentValidationRules, pgBossScheduleNameForId, queueErpCreateContactIfEnabled, queueJobScheduleNow, queuePlugin, queueSms, recordDiscountUsage, registerJobRunnerWorker, registerMessagingQueueProcessors, registerSmsQueueProcessor, relativePathFromMediaParentId, resolveBlogCategoryIdByName, resolveSettingsEncryptionKey, resolveVendorIdForContactCheck, sanitizeMediaFolderPath, sanitizeStorageSegment, sendVendorOnboardEmails, simpleDecrypt, simpleEncrypt, syncJobScheduleToPgBoss, validateRefundTiers, validateScheduleInput, validateUserMessageAgainstAgentRules, validateUserMessageAgainstStructuredRules, verifyAndConsumeOtpChallenge, verifyOtpCodeHash, whatsappPlugin, wrapGetCmsWithMessaging } from './chunk-UO5Q5RXB.js';
2
+ import { checkMultiVendorEnabled, loadUserVendorContext, getPublicSettingsGroup, BlogGeneratorService } from './chunk-PDA4L2LS.js';
3
+ export { Address, Attendee, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, BlogGeneratorService, Brand, CMS_ENTITY_MAP, Cart, CartItem, Category, ChatConversation, ChatMessage, Collection, Combo, ComboItem, Comment, Config, Contact, Currency, CurrencyExchange, Customer, Customer_Contacts, Discount, DiscountRules, Event, EventProduct, Form, FormField, FormSubmission, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, LlmAgent, LlmAgentKnowledgeDocument, Media, MessageTemplate, Order, OrderAddresses, OrderDiscounts, OrderItem, OrderNotificationBinding, OrderNotificationTrigger, OtpChallenge, Page, PasswordResetToken, Payment, Permission, Product, ProductAttribute, ProductCategory, ProductConfig, ProductVariant, RefundPolicy, RefundRequest, RssArticle, RssFeed, Seo, Tag, Tax, User, UserDeviceToken, UserGroup, Vendor, VendorCustomer, VendorRole, VendorRolePermission, VendorUser, VendorUserProfile, Wishlist, WishlistItem, ZIP_MIME_TYPES, applyApprovalStatusSideEffects, applyEventApprovalStatusSideEffects, applyRotatingVendorInvite, applyVendorCustomersContactFilter, applyVendorEventCreateApproval, applyVendorProductCreateApproval, assertCaptchaOk, assertContactAllowedForVendorOrder, assertEventApprovalUpdate, assertProductApprovalUpdate, buildBlogMetadataUserPrompt, buildCronFromSchedule, buildRssUserPromptFromFeeds, buildUserInviteLink, buildVendorInviteLink, calculateOrderRefundPreview, calculateRefundFromPolicy, checkAndIncrementDiscountUsage, checkEventsEnabled, checkMultiVendorEnabled, completeUserInviteAccept, consumeAppliedDiscountUsages, contactIsVendorCustomer, countDiscountOrdersForContact, countRecentOtpSends, createAnalyticsHandlers, createBlogBySlugHandler, createChangePasswordHandler, createCmsApiHandler, createCmsApp, createCmsAppWithMessaging, createCrudByIdHandler, createCrudHandler, createDashboardStatsHandler, createEcommerceAnalyticsHandler, createEventOrderMessageTemplateHandlers, createForgotPasswordHandler, createFormBySlugHandler, createInviteAcceptHandler, createJobScheduleHandlers, createLlmAgentKnowledgeHandlers, createMediaZipExtractHandler, createMessageTemplateRowLoader, createOtpChallenge, createSetPasswordHandler, createSettingsApiHandlers, createSocialMediaHandlers, createStorefrontApiHandler, createUploadHandler, createUserAuthApiRouter, createUserAvatarHandler, createUserProfileHandler, createUsersApiHandlers, createVendorDashboardHandler, createVendorOnboardHandlers, daysBeforeEventStart, decrementDiscountUsage, describeEventTierPolicy, ensureMessagingPluginsOnCms, ensureScheduleQueueWorker, ensureVendorCustomerForOrderContact, ensureVendorCustomersForOrder, findActiveRefundPolicyForVendor, findUserByInviteToken, findVendorByInviteToken, formatTierRange, generateNumericOtp, getPublicSettingsGroup, getRequireEventApproval, getRequireProductApproval, getRssArticleSummaryFromItem, getVendorCatalogCreateFlags, hashOtpCode, hydrateVendorSessionUser, invalidateEventsCache, invalidateMultiVendorCache, invalidateRequireEventApprovalCache, invalidateRequireProductApprovalCache, invalidateVendorCatalogCreateFlagsCache, isCustomerTypeContact, isMaxPerUserUsageReached, isMaxTotalUsageReached, isZipMedia, llmAgentToChatAgentOptions, loadSettingsGroupFromDb, loadUserVendorContext, mergeGuardrailsIntoSystemPrompt, messagingPlugins, metaFetchUserManagedPages, metaPostPageFeed, metaPostPagePhoto, metaResolvePageAccessToken, newUserInviteToken, normalizePhoneE164, normalizeRefundTiers, overlayCmsPlugins, parseBlogGeneratorAgentContent, parseBlogGeneratorModelOutput, parseBlogMetadataEnrichmentJson, parseLlmAgentValidationRules, pgBossScheduleNameForId, queueErpCreateContactIfEnabled, queueJobScheduleNow, queuePlugin, queueSms, recordDiscountUsage, registerJobRunnerWorker, registerMessagingQueueProcessors, registerSmsQueueProcessor, relativePathFromMediaParentId, resolveBlogCategoryIdByName, resolveSettingsEncryptionKey, resolveVendorIdForContactCheck, sanitizeMediaFolderPath, sanitizeStorageSegment, sendVendorOnboardEmails, simpleDecrypt, simpleEncrypt, syncJobScheduleToPgBoss, validateRefundTiers, validateScheduleInput, validateUserMessageAgainstAgentRules, validateUserMessageAgainstStructuredRules, verifyAndConsumeOtpChallenge, verifyOtpCodeHash, whatsappPlugin, wrapGetCmsWithMessaging } from './chunk-PDA4L2LS.js';
4
4
  import { PgBossService } from './chunk-GO7PPYNU.js';
5
5
  export { JOB_RUNNER_QUEUE, PgBossService } from './chunk-GO7PPYNU.js';
6
6
  export { deductInventoryForConfirmedOrder, mergeInventoryLines, orderInventorySnapshotFromRow, orderStatusHoldsStock, reconcileOrderInventoryBetweenSnapshots, restoreInventoryForCancelledOrder, validateInventoryForConfirmedOrderLines, validateInventoryForOrderBecomingConfirmed } from './chunk-3K5AIEIZ.js';
@@ -1046,6 +1046,76 @@ function paymentPlugin(config) {
1046
1046
  __name(paymentPlugin, "paymentPlugin");
1047
1047
 
1048
1048
  // src/plugins/storage/s3.ts
1049
+ var LOG = "[s3]";
1050
+ function serializeS3Error(err) {
1051
+ if (!err || typeof err !== "object") {
1052
+ return {
1053
+ error: String(err)
1054
+ };
1055
+ }
1056
+ const e = err;
1057
+ return {
1058
+ name: e.name,
1059
+ message: e.message,
1060
+ code: e.Code ?? e.code,
1061
+ httpStatus: e.$metadata?.httpStatusCode,
1062
+ requestId: e.$metadata?.requestId,
1063
+ extendedRequestId: e.$metadata?.extendedRequestId,
1064
+ cfId: e.$metadata?.cfId
1065
+ };
1066
+ }
1067
+ __name(serializeS3Error, "serializeS3Error");
1068
+ function publicObjectUrl(config, fullKey) {
1069
+ if (config.baseUrl) {
1070
+ return `${config.baseUrl.replace(/\/$/, "")}/${fullKey}`;
1071
+ }
1072
+ return `https://s3.${config.region}.amazonaws.com/${config.bucket}/${fullKey}`;
1073
+ }
1074
+ __name(publicObjectUrl, "publicObjectUrl");
1075
+ async function probePublicUrl(url) {
1076
+ try {
1077
+ const head = await fetch(url, {
1078
+ method: "HEAD",
1079
+ redirect: "manual"
1080
+ });
1081
+ const headInfo = {
1082
+ url,
1083
+ status: head.status,
1084
+ ok: head.ok,
1085
+ contentType: head.headers.get("content-type"),
1086
+ location: head.headers.get("location")
1087
+ };
1088
+ if (head.ok) {
1089
+ console.info(LOG, "public URL reachable (HEAD)", headInfo);
1090
+ return;
1091
+ }
1092
+ const getRes = await fetch(url, {
1093
+ method: "GET",
1094
+ headers: {
1095
+ Range: "bytes=0-0"
1096
+ },
1097
+ redirect: "manual"
1098
+ });
1099
+ let bodySnippet = "";
1100
+ try {
1101
+ bodySnippet = (await getRes.text()).slice(0, 400);
1102
+ } catch {
1103
+ }
1104
+ console.error(LOG, "public URL not readable \u2014 admin images will not display", {
1105
+ ...headInfo,
1106
+ getStatus: getRes.status,
1107
+ getOk: getRes.ok,
1108
+ getContentType: getRes.headers.get("content-type"),
1109
+ bodySnippet
1110
+ });
1111
+ } catch (err) {
1112
+ console.error(LOG, "public URL probe failed", {
1113
+ url,
1114
+ error: err instanceof Error ? err.message : String(err)
1115
+ });
1116
+ }
1117
+ }
1118
+ __name(probePublicUrl, "probePublicUrl");
1049
1119
  function getS3Storage(config) {
1050
1120
  const prefix = (config.prefix ?? "uploads").replace(/\/$/, "");
1051
1121
  const keyPrefix = prefix ? `${prefix}/` : "";
@@ -1060,16 +1130,38 @@ function getS3Storage(config) {
1060
1130
  }
1061
1131
  });
1062
1132
  const fullKey = keyPrefix + key.replace(/^\/+/, "");
1063
- await client.send(new PutObjectCommand({
1064
- Bucket: config.bucket,
1065
- Key: fullKey,
1066
- Body: buffer,
1067
- ContentType: contentType
1068
- }));
1069
- if (config.baseUrl) {
1070
- return `${config.baseUrl.replace(/\/$/, "")}/${fullKey}`;
1133
+ const started = Date.now();
1134
+ try {
1135
+ await client.send(new PutObjectCommand({
1136
+ Bucket: config.bucket,
1137
+ Key: fullKey,
1138
+ Body: buffer,
1139
+ ContentType: contentType
1140
+ }));
1141
+ } catch (err) {
1142
+ console.error(LOG, "PutObject failed", {
1143
+ bucket: config.bucket,
1144
+ region: config.region,
1145
+ key: fullKey,
1146
+ contentType,
1147
+ bytes: buffer.length,
1148
+ ...serializeS3Error(err)
1149
+ });
1150
+ throw err;
1071
1151
  }
1072
- return `https://s3.${config.region}.amazonaws.com/${config.bucket}/${fullKey}`;
1152
+ const url = publicObjectUrl(config, fullKey);
1153
+ console.info(LOG, "PutObject ok", {
1154
+ bucket: config.bucket,
1155
+ region: config.region,
1156
+ key: fullKey,
1157
+ contentType,
1158
+ bytes: buffer.length,
1159
+ ms: Date.now() - started,
1160
+ url,
1161
+ hasCustomBaseUrl: Boolean(config.baseUrl)
1162
+ });
1163
+ void probePublicUrl(url);
1164
+ return url;
1073
1165
  }
1074
1166
  };
1075
1167
  }
@@ -1086,8 +1178,29 @@ function s3StoragePlugin(config) {
1086
1178
  const baseUrl = config.baseUrl ?? context.config.S3_MEDIA_URL ?? context.config.S3_CUSTOM_DOMAIN;
1087
1179
  const resolvedBaseUrl = typeof baseUrl === "string" && baseUrl ? baseUrl.startsWith("http") ? baseUrl : `https://${baseUrl}` : void 0;
1088
1180
  if (!region || !accessKeyId || !secretAccessKey || !bucket) {
1181
+ console.error(LOG, "plugin init missing config", {
1182
+ hasRegion: Boolean(region),
1183
+ hasAccessKeyId: Boolean(accessKeyId),
1184
+ hasSecretAccessKey: Boolean(secretAccessKey),
1185
+ hasBucket: Boolean(bucket),
1186
+ hasBaseUrl: Boolean(resolvedBaseUrl)
1187
+ });
1089
1188
  throw new Error("S3 storage plugin: missing region, accessKeyId, secretAccessKey or bucket");
1090
1189
  }
1190
+ let baseUrlHost = null;
1191
+ try {
1192
+ baseUrlHost = resolvedBaseUrl ? new URL(resolvedBaseUrl).host : null;
1193
+ } catch {
1194
+ baseUrlHost = resolvedBaseUrl ?? null;
1195
+ }
1196
+ console.info(LOG, "plugin ready", {
1197
+ region,
1198
+ bucket,
1199
+ prefix: config.prefix ?? "uploads",
1200
+ hasBaseUrl: Boolean(resolvedBaseUrl),
1201
+ baseUrlHost,
1202
+ accessKeyIdLast4: accessKeyId.slice(-4)
1203
+ });
1091
1204
  return getS3Storage({
1092
1205
  region,
1093
1206
  accessKeyId,
@@ -1121,7 +1234,14 @@ function getLocalStorage(config) {
1121
1234
  recursive: true
1122
1235
  });
1123
1236
  await fs.writeFile(filePath, buffer);
1124
- return `${publicPath.replace(/\/$/, "")}/${fileName}`;
1237
+ const url = `${publicPath.replace(/\/$/, "")}/${fileName}`;
1238
+ console.info("[storage:local] wrote file", {
1239
+ dir: fullDir,
1240
+ key: fileName,
1241
+ bytes: buffer.length,
1242
+ url
1243
+ });
1244
+ return url;
1125
1245
  }
1126
1246
  };
1127
1247
  }
@@ -1132,6 +1252,9 @@ function localStoragePlugin(config = {}) {
1132
1252
  version: "1.0.0",
1133
1253
  async init(context) {
1134
1254
  const dir = config.dir ?? context.config.UPLOAD_DIR ?? "public/uploads";
1255
+ console.info("[storage:local] plugin ready", {
1256
+ dir
1257
+ });
1135
1258
  return getLocalStorage({
1136
1259
  ...config,
1137
1260
  dir
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infuro/cms-core",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",