@hartl-services/medusa-base 0.3.0 → 1.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/.medusa/server/src/admin/index.js +2164 -29
- package/.medusa/server/src/admin/index.mjs +2166 -31
- package/.medusa/server/src/api/admin/email/messages/[id]/resends/route.js +24 -0
- package/.medusa/server/src/api/admin/email/messages/[id]/route.js +12 -0
- package/.medusa/server/src/api/admin/email/messages/route.js +12 -0
- package/.medusa/server/src/api/admin/email/terms-versions/[id]/download/route.js +16 -0
- package/.medusa/server/src/api/admin/email/terms-versions/route.js +47 -0
- package/.medusa/server/src/api/admin/orders/[id]/documents/[document_id]/download/route.js +21 -0
- package/.medusa/server/src/api/admin/orders/[id]/documents/[document_id]/regenerate/route.js +38 -0
- package/.medusa/server/src/api/admin/orders/[id]/documents/regenerate/route.js +32 -0
- package/.medusa/server/src/api/admin/orders/[id]/documents/route.js +36 -0
- package/.medusa/server/src/api/admin/orders/[id]/packing-lists/[fulfillment_id]/download/route.js +24 -0
- package/.medusa/server/src/api/admin/orders/[id]/packing-lists/[fulfillment_id]/retry/route.js +44 -0
- package/.medusa/server/src/api/admin/orders/[id]/packing-lists/route.js +82 -0
- package/.medusa/server/src/api/admin/plugin-features/[plugin_key]/actions/[action_key]/route.js +31 -0
- package/.medusa/server/src/api/admin/plugin-features/[plugin_key]/actions/[action_key]/runs/route.js +16 -0
- package/.medusa/server/src/api/admin/plugin-features/[plugin_key]/route.js +14 -0
- package/.medusa/server/src/api/admin/plugin-features/[plugin_key]/settings/route.js +22 -0
- package/.medusa/server/src/api/admin/plugin-features/route.js +6 -4
- package/.medusa/server/src/api/document-download-response.js +16 -0
- package/.medusa/server/src/api/document-response.js +23 -0
- package/.medusa/server/src/api/files/[asset]/route.js +24 -0
- package/.medusa/server/src/api/files/file-response.js +43 -0
- package/.medusa/server/src/api/files/gateway-options.js +31 -0
- package/.medusa/server/src/api/files/private/[token]/route.js +29 -0
- package/.medusa/server/src/api/files/upload/[token]/route.js +66 -0
- package/.medusa/server/src/api/middlewares.js +186 -5
- package/.medusa/server/src/api/packing-list-response.js +22 -0
- package/.medusa/server/src/api/plugin-actions.js +221 -0
- package/.medusa/server/src/api/plugin-features-http.js +67 -8
- package/.medusa/server/src/api/route.js +27 -0
- package/.medusa/server/src/api/store/documents/[id]/download/route.js +21 -0
- package/.medusa/server/src/api/store/documents/[id]/route.js +15 -0
- package/.medusa/server/src/api/store/documents/route.js +11 -0
- package/.medusa/server/src/api/terms-download-response.js +12 -0
- package/.medusa/server/src/documents/config/index.js +18 -0
- package/.medusa/server/src/documents/paths/documents.js +6 -0
- package/.medusa/server/src/documents/paths/index.js +18 -0
- package/.medusa/server/src/documents/plugin-features.js +24 -0
- package/.medusa/server/src/documents/schemas/documents.js +18 -0
- package/.medusa/server/src/documents/schemas/index.js +18 -0
- package/.medusa/server/src/documents/scripts/verify-documents-file-storage.js +55 -0
- package/.medusa/server/src/documents/templates/financial-document.js +142 -0
- package/.medusa/server/src/documents/templates/format.js +31 -0
- package/.medusa/server/src/documents/templates/html-factory.js +40 -0
- package/.medusa/server/src/documents/templates/html-utils.js +13 -0
- package/.medusa/server/src/documents/templates/layout.js +97 -0
- package/.medusa/server/src/documents/templates/packing-list.js +50 -0
- package/.medusa/server/src/documents/types/admin-api.js +3 -0
- package/.medusa/server/src/documents/types/document-summary.js +3 -0
- package/.medusa/server/src/documents/types/documents.js +3 -0
- package/.medusa/server/src/documents/types/html-factory.js +6 -0
- package/.medusa/server/src/documents/types/index.js +22 -0
- package/.medusa/server/src/documents/types/store-api.js +3 -0
- package/.medusa/server/src/documents/utils/document-merchant.js +22 -0
- package/.medusa/server/src/documents/utils/html-to-pdf.js +61 -0
- package/.medusa/server/src/documents/utils/private-file-storage.js +64 -0
- package/.medusa/server/src/documents/utils/resolve-services.js +7 -0
- package/.medusa/server/src/email/application/handle-invite-event.js +312 -0
- package/.medusa/server/src/email/application/handle-password-reset-event.js +354 -0
- package/.medusa/server/src/email/config/index.js +84 -0
- package/.medusa/server/src/email/config/notification-module.js +20 -0
- package/.medusa/server/src/email/domain/business-keys.js +50 -0
- package/.medusa/server/src/email/domain/documents-fact-fingerprint.js +7 -0
- package/.medusa/server/src/email/domain/event-schemas.js +36 -0
- package/.medusa/server/src/email/domain/failure-classification.js +53 -0
- package/.medusa/server/src/email/plugin-features.js +31 -0
- package/.medusa/server/src/email/rendering/default-templates.js +91 -0
- package/.medusa/server/src/email/rendering/render-email.js +37 -0
- package/.medusa/server/src/email/rendering/resolve-shop-configuration.js +48 -0
- package/.medusa/server/src/email/types/email-kinds.js +18 -0
- package/.medusa/server/src/email/types/index.js +21 -0
- package/.medusa/server/src/email/types/shop-configuration.js +3 -0
- package/.medusa/server/src/email/types/smtp-configuration.js +3 -0
- package/.medusa/server/src/email/types/template-data.js +79 -0
- package/.medusa/server/src/files/config/index.js +256 -0
- package/.medusa/server/src/files/gateway/index.js +115 -0
- package/.medusa/server/src/files/types/index.js +6 -0
- package/.medusa/server/src/files/types/public.js +6 -0
- package/.medusa/server/src/jobs/document-fact-publication-reconciliation.js +18 -0
- package/.medusa/server/src/jobs/document-resolution-reconciliation.js +20 -0
- package/.medusa/server/src/jobs/packing-list-reconciliation.js +49 -0
- package/.medusa/server/src/jobs/reconcile-email-attempts.js +63 -0
- package/.medusa/server/src/jobs/reconcile-pending-email-messages.js +41 -0
- package/.medusa/server/src/jobs/retry-email-messages.js +27 -0
- package/.medusa/server/src/migration-scripts/dismiss-orphaned-cart-promotion-links.js +26 -0
- package/.medusa/server/src/modules/documents/domain/cancellation-snapshot.js +97 -0
- package/.medusa/server/src/modules/documents/domain/document-number.js +36 -0
- package/.medusa/server/src/modules/documents/domain/document-resolution.js +24 -0
- package/.medusa/server/src/modules/documents/domain/issuance-rules.js +37 -0
- package/.medusa/server/src/modules/documents/domain/merchant.js +86 -0
- package/.medusa/server/src/modules/documents/domain/options.js +40 -0
- package/.medusa/server/src/modules/documents/domain/packing-list.js +90 -0
- package/.medusa/server/src/modules/documents/domain/snapshot-normalization.js +17 -0
- package/.medusa/server/src/modules/documents/domain/tax-breakdown.js +66 -0
- package/.medusa/server/src/modules/documents/index.js +15 -0
- package/.medusa/server/src/modules/documents/loaders/assert-private-file-storage.js +20 -0
- package/.medusa/server/src/modules/documents/migrations/Migration20260827061749.js +75 -0
- package/.medusa/server/src/modules/documents/migrations/Migration20260830111207.js +28 -0
- package/.medusa/server/src/modules/documents/models/document-artifact.js +25 -0
- package/.medusa/server/src/modules/documents/models/document-number-sequence.js +29 -0
- package/.medusa/server/src/modules/documents/models/document.js +82 -0
- package/.medusa/server/src/modules/documents/models/order-cancellation-resolution.js +51 -0
- package/.medusa/server/src/modules/documents/models/packing-list-revision.js +36 -0
- package/.medusa/server/src/modules/documents/models/packing-list.js +27 -0
- package/.medusa/server/src/modules/documents/models/refund-document-resolution.js +66 -0
- package/.medusa/server/src/modules/documents/models/shipment-invoice-assignment.js +51 -0
- package/.medusa/server/src/modules/documents/models/shipment-invoice-coordinator.js +44 -0
- package/.medusa/server/src/modules/documents/service.js +1701 -0
- package/.medusa/server/src/modules/email/domain/attachment.js +25 -0
- package/.medusa/server/src/modules/email/domain/message-state.js +69 -0
- package/.medusa/server/src/modules/email/index.js +13 -0
- package/.medusa/server/src/modules/email/migrations/Migration20260826173422.js +32 -0
- package/.medusa/server/src/modules/email/migrations/Migration20260827172945.js +16 -0
- package/.medusa/server/src/modules/email/migrations/Migration20260827194804.js +22 -0
- package/.medusa/server/src/modules/email/migrations/Migration20260906195205.js +16 -0
- package/.medusa/server/src/modules/email/models/email-attempt.js +56 -0
- package/.medusa/server/src/modules/email/models/email-message.js +71 -0
- package/.medusa/server/src/modules/email/models/email-terms-version.js +37 -0
- package/.medusa/server/src/modules/email/service.js +1285 -0
- package/.medusa/server/src/modules/plugin-features/domain/plugin-action-runs.js +92 -0
- package/.medusa/server/src/modules/plugin-features/domain/plugin-settings.js +213 -0
- package/.medusa/server/src/modules/plugin-features/domain/secret-box.js +56 -0
- package/.medusa/server/src/modules/plugin-features/migrations/Migration20260928205031.js +16 -0
- package/.medusa/server/src/modules/plugin-features/migrations/Migration20260928215428.js +17 -0
- package/.medusa/server/src/modules/plugin-features/models/plugin-action-run.js +43 -0
- package/.medusa/server/src/modules/plugin-features/models/plugin-setting-state.js +32 -0
- package/.medusa/server/src/modules/plugin-features/service.js +419 -17
- package/.medusa/server/src/providers/s3-cache/cache/atomic-write.js +25 -0
- package/.medusa/server/src/providers/s3-cache/cache/cache-manager.js +115 -0
- package/.medusa/server/src/providers/s3-cache/cache/keyed-lock.js +28 -0
- package/.medusa/server/src/providers/s3-cache/index.js +8 -0
- package/.medusa/server/src/providers/s3-cache/object-key.js +53 -0
- package/.medusa/server/src/providers/s3-cache/s3-cache-file.js +229 -0
- package/.medusa/server/src/providers/s3-cache/s3-object-store.js +86 -0
- package/.medusa/server/src/providers/smtp/index.js +8 -0
- package/.medusa/server/src/providers/smtp/service.js +236 -0
- package/.medusa/server/src/providers/smtp/types.js +11 -0
- package/.medusa/server/src/public/action-progress.js +67 -0
- package/.medusa/server/src/public/config.js +186 -0
- package/.medusa/server/src/public/descriptor.js +199 -2
- package/.medusa/server/src/public/effective-features.js +9 -5
- package/.medusa/server/src/public/enforcement.js +18 -8
- package/.medusa/server/src/public/gateway.js +19 -0
- package/.medusa/server/src/public/index.js +10 -2
- package/.medusa/server/src/public/instrumentation.js +56 -0
- package/.medusa/server/src/public/module-access.js +14 -0
- package/.medusa/server/src/public/settings.js +17 -0
- package/.medusa/server/src/public/shop-config.js +12 -0
- package/.medusa/server/src/public/shop-master-data.js +95 -0
- package/.medusa/server/src/public/shop-types.js +24 -0
- package/.medusa/server/src/shop-config/build-food-shop-config.js +248 -0
- package/.medusa/server/src/shop-config/options.js +71 -0
- package/.medusa/server/src/subscribers/affiliate-consignment-reminder-due.js +26 -0
- package/.medusa/server/src/subscribers/documents-order-canceled.js +24 -0
- package/.medusa/server/src/subscribers/documents-order-cancellation-ready.js +26 -0
- package/.medusa/server/src/subscribers/documents-refund-ready.js +24 -0
- package/.medusa/server/src/subscribers/documents-shipment-created.js +36 -0
- package/.medusa/server/src/subscribers/documents-shipment-invoice-assignment-decided.js +26 -0
- package/.medusa/server/src/subscribers/email-order-canceled.js +28 -0
- package/.medusa/server/src/subscribers/email-shipment-created.js +32 -0
- package/.medusa/server/src/subscribers/order-placed.js +27 -0
- package/.medusa/server/src/subscribers/packing-list-allocation-revised.js +32 -0
- package/.medusa/server/src/subscribers/packing-list-fulfillment-canceled.js +54 -0
- package/.medusa/server/src/subscribers/packing-list-fulfillment-created.js +31 -0
- package/.medusa/server/src/subscribers/password-reset.js +23 -0
- package/.medusa/server/src/subscribers/payment-refunded.js +38 -0
- package/.medusa/server/src/subscribers/return-received.js +27 -0
- package/.medusa/server/src/subscribers/return-requested.js +27 -0
- package/.medusa/server/src/subscribers/user-invite.js +23 -0
- package/.medusa/server/src/utils/cart-promotion-links.js +101 -0
- package/.medusa/server/src/utils/discover-complete-cart-participants.js +9 -2
- package/.medusa/server/src/utils/discover-plugin-features.js +47 -9
- package/.medusa/server/src/workflows/documents/issue-cancellation-after-refund.js +246 -0
- package/.medusa/server/src/workflows/documents/issue-document.js +163 -0
- package/.medusa/server/src/workflows/documents/issue-invoice-after-shipment.js +521 -0
- package/.medusa/server/src/workflows/documents/issue-packing-list.js +384 -0
- package/.medusa/server/src/workflows/documents/publish-document-facts.js +53 -0
- package/.medusa/server/src/workflows/documents/reconcile-document-resolutions.js +48 -0
- package/.medusa/server/src/workflows/documents/reconcile-order-cancellation.js +92 -0
- package/.medusa/server/src/workflows/documents/regenerate-issued-document.js +61 -0
- package/.medusa/server/src/workflows/email/dispatch-email-message.js +299 -0
- package/.medusa/server/src/workflows/email/documents-required-facts.js +30 -0
- package/.medusa/server/src/workflows/email/prepare-affiliate-reminder-email.js +58 -0
- package/.medusa/server/src/workflows/email/prepare-order-canceled-email.js +64 -0
- package/.medusa/server/src/workflows/email/prepare-order-received-email.js +56 -0
- package/.medusa/server/src/workflows/email/prepare-refund-email.js +47 -0
- package/.medusa/server/src/workflows/email/prepare-return-email.js +75 -0
- package/.medusa/server/src/workflows/email/prepare-shipment-email.js +82 -0
- package/.medusa/server/src/workflows/email/retry-email-messages.js +31 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-participants.js +28 -16
- package/.medusa/server/src/workflows/hooks/dismiss-deleted-promotion-cart-links.js +23 -0
- package/README.md +2004 -11
- package/dist/admin-components/features/plugin-features/components/PluginActionsSection.d.ts +6 -0
- package/dist/admin-components/features/plugin-features/components/PluginActionsSection.js +66 -0
- package/dist/admin-components/features/plugin-features/components/PluginDetailPage.d.ts +2 -0
- package/dist/admin-components/features/plugin-features/components/PluginDetailPage.js +9 -0
- package/dist/admin-components/features/plugin-features/components/PluginFeatureGate.d.ts +22 -0
- package/dist/admin-components/features/plugin-features/components/PluginFeatureGate.js +18 -0
- package/dist/admin-components/features/plugin-features/components/PluginFeatureSections.d.ts +11 -0
- package/dist/admin-components/features/plugin-features/components/PluginFeatureSections.js +19 -0
- package/dist/admin-components/features/plugin-features/components/PluginFeaturesCard.d.ts +12 -0
- package/dist/admin-components/features/plugin-features/components/PluginFeaturesCard.js +34 -0
- package/dist/admin-components/features/plugin-features/components/PluginFeaturesSettingsPage.d.ts +5 -0
- package/dist/admin-components/features/plugin-features/components/PluginFeaturesSettingsPage.js +16 -0
- package/dist/admin-components/features/plugin-features/components/PluginHubCard.d.ts +7 -0
- package/dist/admin-components/features/plugin-features/components/PluginHubCard.js +21 -0
- package/dist/admin-components/features/plugin-features/components/PluginPageShell.d.ts +13 -0
- package/dist/admin-components/features/plugin-features/components/PluginPageShell.js +20 -0
- package/dist/admin-components/features/plugin-features/components/PluginSettingsForm.d.ts +7 -0
- package/dist/admin-components/features/plugin-features/components/PluginSettingsForm.js +39 -0
- package/dist/admin-components/features/plugin-features/components/PluginStatusChips.d.ts +5 -0
- package/dist/admin-components/features/plugin-features/components/PluginStatusChips.js +8 -0
- package/dist/admin-components/features/plugin-features/hooks/usePluginFeatureEnabled.d.ts +114 -0
- package/dist/admin-components/features/plugin-features/hooks/usePluginFeatureEnabled.js +40 -0
- package/dist/admin-components/features/plugin-features/hooks/usePluginFeatures.d.ts +392 -0
- package/dist/admin-components/features/plugin-features/hooks/usePluginFeatures.js +128 -0
- package/dist/admin-components/features/plugin-features/hooks/usePluginSettingsForm.d.ts +93 -0
- package/dist/admin-components/features/plugin-features/hooks/usePluginSettingsForm.js +44 -0
- package/dist/admin-components/features/plugin-features/lib/action-runs.d.ts +19 -0
- package/dist/admin-components/features/plugin-features/lib/action-runs.js +74 -0
- package/dist/admin-components/features/plugin-features/lib/plugin-features-admin-client.d.ts +363 -0
- package/dist/admin-components/features/plugin-features/lib/plugin-features-admin-client.js +9 -0
- package/dist/admin-components/features/plugin-features/lib/plugin-paths.d.ts +4 -0
- package/dist/admin-components/features/plugin-features/lib/plugin-paths.js +4 -0
- package/dist/admin-components/features/plugin-features/lib/settings-draft.d.ts +28 -0
- package/dist/admin-components/features/plugin-features/lib/settings-draft.js +86 -0
- package/dist/admin-components/features/plugin-features/queries/pluginFeatureKeys.d.ts +7 -0
- package/dist/admin-components/features/plugin-features/queries/pluginFeatureKeys.js +7 -0
- package/dist/admin-components/i18n/texts.d.ts +90 -0
- package/dist/admin-components/i18n/texts.js +90 -0
- package/dist/admin-components/index.d.ts +14 -0
- package/dist/admin-components/index.js +14 -0
- package/dist/admin-components/lib/errors.d.ts +6 -0
- package/dist/admin-components/lib/errors.js +27 -0
- package/dist/admin-components/lib/sdk.d.ts +2 -0
- package/dist/admin-components/lib/sdk.js +13 -0
- package/dist/documents/config/index.d.ts +11 -0
- package/dist/documents/config/index.js +17 -0
- package/dist/documents/templates/financial-document.d.ts +3 -0
- package/dist/documents/templates/financial-document.js +141 -0
- package/dist/documents/templates/format.d.ts +16 -0
- package/dist/documents/templates/format.js +30 -0
- package/dist/documents/templates/html-factory.d.ts +11 -0
- package/dist/documents/templates/html-factory.js +39 -0
- package/dist/documents/templates/html-utils.d.ts +2 -0
- package/dist/documents/templates/html-utils.js +12 -0
- package/dist/documents/templates/layout.d.ts +17 -0
- package/dist/documents/templates/layout.js +96 -0
- package/dist/documents/templates/packing-list.d.ts +3 -0
- package/dist/documents/templates/packing-list.js +49 -0
- package/dist/documents/types/admin-api.d.ts +1 -0
- package/dist/documents/types/admin-api.js +2 -0
- package/dist/documents/types/document-summary.d.ts +1 -0
- package/dist/documents/types/document-summary.js +2 -0
- package/dist/documents/types/documents.d.ts +174 -0
- package/dist/documents/types/documents.js +2 -0
- package/dist/documents/types/html-factory.d.ts +7 -0
- package/dist/documents/types/html-factory.js +5 -0
- package/dist/documents/types/index.d.ts +5 -0
- package/dist/documents/types/index.js +21 -0
- package/dist/documents/types/store-api.d.ts +1 -0
- package/dist/documents/types/store-api.js +2 -0
- package/dist/email/config/index.d.ts +17 -0
- package/dist/email/config/index.js +83 -0
- package/dist/email/config/notification-module.d.ts +22 -0
- package/dist/email/config/notification-module.js +19 -0
- package/dist/email/types/email-kinds.d.ts +15 -0
- package/dist/email/types/email-kinds.js +17 -0
- package/dist/email/types/index.d.ts +4 -0
- package/dist/email/types/index.js +20 -0
- package/dist/email/types/shop-configuration.d.ts +43 -0
- package/dist/email/types/shop-configuration.js +2 -0
- package/dist/email/types/smtp-configuration.d.ts +9 -0
- package/dist/email/types/smtp-configuration.js +2 -0
- package/dist/email/types/template-data.d.ts +100 -0
- package/dist/email/types/template-data.js +78 -0
- package/dist/files/config/index.d.ts +32 -0
- package/dist/files/config/index.js +255 -0
- package/dist/files/gateway/index.d.ts +30 -0
- package/dist/files/gateway/index.js +114 -0
- package/dist/files/types/index.d.ts +2 -0
- package/dist/files/types/index.js +5 -0
- package/dist/files/types/public.d.ts +90 -0
- package/dist/files/types/public.js +5 -0
- package/dist/modules/documents/domain/merchant.d.ts +22 -0
- package/dist/modules/documents/domain/merchant.js +85 -0
- package/dist/modules/documents/domain/options.d.ts +34 -0
- package/dist/modules/documents/domain/options.js +39 -0
- package/dist/public/action-progress.d.ts +25 -0
- package/dist/public/action-progress.js +66 -0
- package/dist/public/config.d.ts +59 -0
- package/dist/public/config.js +185 -0
- package/dist/public/descriptor.d.ts +3 -2
- package/dist/public/descriptor.js +198 -1
- package/dist/public/effective-features.d.ts +2 -1
- package/dist/public/effective-features.js +8 -4
- package/dist/public/enforcement.d.ts +7 -0
- package/dist/public/enforcement.js +17 -7
- package/dist/public/gateway.d.ts +2 -0
- package/dist/public/gateway.js +18 -0
- package/dist/public/index.d.ts +5 -2
- package/dist/public/index.js +9 -1
- package/dist/public/instrumentation.d.ts +12 -0
- package/dist/public/instrumentation.js +55 -0
- package/dist/public/module-access.d.ts +3 -0
- package/dist/public/module-access.js +13 -0
- package/dist/public/settings.d.ts +11 -0
- package/dist/public/settings.js +16 -0
- package/dist/public/shop-config.d.ts +8 -0
- package/dist/public/shop-config.js +11 -0
- package/dist/public/shop-master-data.d.ts +25 -0
- package/dist/public/shop-master-data.js +94 -0
- package/dist/public/shop-types.d.ts +7 -0
- package/dist/public/shop-types.js +23 -0
- package/dist/public/types.d.ts +113 -1
- package/dist/shop-config/build-food-shop-config.d.ts +44 -0
- package/dist/shop-config/build-food-shop-config.js +247 -0
- package/dist/shop-config/options.d.ts +41 -0
- package/dist/shop-config/options.js +70 -0
- package/dist/utils/discover-plugin-features.d.ts +28 -0
- package/dist/utils/discover-plugin-features.js +96 -0
- package/package.json +53 -6
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toDocumentMerchant = exports.merchantOptionToFallback = exports.MERCHANT_VAT_PLACEHOLDER = exports.DOCUMENT_MERCHANT_REQUIRED_FIELDS = void 0;
|
|
4
|
+
/** Without these a financial document or packing list has no legal sender. */
|
|
5
|
+
exports.DOCUMENT_MERCHANT_REQUIRED_FIELDS = [
|
|
6
|
+
"legal_name",
|
|
7
|
+
"address_line1",
|
|
8
|
+
"postal_code",
|
|
9
|
+
"city",
|
|
10
|
+
"country_code",
|
|
11
|
+
];
|
|
12
|
+
/** Development placeholder UID: never printed on a document. */
|
|
13
|
+
exports.MERCHANT_VAT_PLACEHOLDER = "ATU00000000";
|
|
14
|
+
const text = (value) => {
|
|
15
|
+
if (typeof value !== "string") {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const trimmed = value.trim();
|
|
19
|
+
return trimmed ? trimmed : null;
|
|
20
|
+
};
|
|
21
|
+
const vatNumber = (value) => {
|
|
22
|
+
const normalized = text(value);
|
|
23
|
+
return normalized &&
|
|
24
|
+
normalized.replace(/\s+/g, "").toUpperCase() === exports.MERCHANT_VAT_PLACEHOLDER
|
|
25
|
+
? null
|
|
26
|
+
: normalized;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The plugin's `merchant` option as a per-field fallback for the shop master
|
|
30
|
+
* data. Empty values are left out so they never shadow a declared default.
|
|
31
|
+
*/
|
|
32
|
+
const merchantOptionToFallback = (option) => {
|
|
33
|
+
if (!option) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
const address = option.registeredAddress;
|
|
37
|
+
const entries = [
|
|
38
|
+
["legal_name", option.legalName],
|
|
39
|
+
["address_line1", address?.address1],
|
|
40
|
+
["address_line2", address?.address2],
|
|
41
|
+
["postal_code", address?.postalCode],
|
|
42
|
+
["city", address?.city],
|
|
43
|
+
[
|
|
44
|
+
"country_code",
|
|
45
|
+
text(address?.countryCode ?? option.countryCode)?.toLowerCase(),
|
|
46
|
+
],
|
|
47
|
+
["vat_number", option.vatNumber],
|
|
48
|
+
];
|
|
49
|
+
const fallback = {};
|
|
50
|
+
for (const [key, value] of entries) {
|
|
51
|
+
const normalized = text(value);
|
|
52
|
+
if (normalized) {
|
|
53
|
+
fallback[key] = normalized;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return fallback;
|
|
57
|
+
};
|
|
58
|
+
exports.merchantOptionToFallback = merchantOptionToFallback;
|
|
59
|
+
/** Maps resolved shop master data to the render input's `merchant`. */
|
|
60
|
+
const toDocumentMerchant = (values) => {
|
|
61
|
+
const missing = exports.DOCUMENT_MERCHANT_REQUIRED_FIELDS.filter((key) => !text(values[key]));
|
|
62
|
+
if (missing.length > 0) {
|
|
63
|
+
return { merchant: null, missing };
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
merchant: {
|
|
67
|
+
legal_name: text(values.legal_name),
|
|
68
|
+
address_line1: text(values.address_line1),
|
|
69
|
+
address_line2: text(values.address_line2),
|
|
70
|
+
postal_code: text(values.postal_code),
|
|
71
|
+
city: text(values.city),
|
|
72
|
+
country_code: text(values.country_code).toLowerCase(),
|
|
73
|
+
vat_number: vatNumber(values.vat_number),
|
|
74
|
+
email: text(values.email),
|
|
75
|
+
phone: text(values.phone),
|
|
76
|
+
website: text(values.website),
|
|
77
|
+
iban: text(values.iban),
|
|
78
|
+
bic: text(values.bic),
|
|
79
|
+
company_register_number: text(values.company_register_number),
|
|
80
|
+
company_register_court: text(values.company_register_court),
|
|
81
|
+
},
|
|
82
|
+
missing: [],
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
exports.toDocumentMerchant = toDocumentMerchant;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DocumentHtmlFactory } from "../../../documents/types/html-factory";
|
|
2
|
+
import type { DocumentMerchantOption, DocumentPdfOptions } from "../../../documents/types/documents";
|
|
3
|
+
import { type DocumentMerchantValues } from "./merchant";
|
|
4
|
+
/** Used when the `documents.numbering.timeZone` option is not given. */
|
|
5
|
+
export declare const DEFAULT_NUMBERING_TIME_ZONE = "Europe/Vienna";
|
|
6
|
+
/** The `documents` namespace of the base plugin options. */
|
|
7
|
+
export type DocumentPluginOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Replaces the built-in German document markup. Omit it to use
|
|
10
|
+
* `createDefaultDocumentHtmlFactory` with the `numbering.timeZone`.
|
|
11
|
+
*/
|
|
12
|
+
htmlFactory?: DocumentHtmlFactory;
|
|
13
|
+
/**
|
|
14
|
+
* Fallback for the shop master data of the base plugin: used per field
|
|
15
|
+
* only where no value is stored there.
|
|
16
|
+
*/
|
|
17
|
+
merchant?: DocumentMerchantOption;
|
|
18
|
+
numbering?: {
|
|
19
|
+
timeZone?: string;
|
|
20
|
+
};
|
|
21
|
+
pdf?: DocumentPdfOptions;
|
|
22
|
+
};
|
|
23
|
+
export type ResolvedDocumentPluginOptions = {
|
|
24
|
+
htmlFactory: DocumentHtmlFactory;
|
|
25
|
+
/** The `merchant` option keyed by shop master data field. */
|
|
26
|
+
merchantFallback: DocumentMerchantValues;
|
|
27
|
+
numbering: {
|
|
28
|
+
timeZone: string;
|
|
29
|
+
};
|
|
30
|
+
pdf: {
|
|
31
|
+
executablePath: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const resolveDocumentPluginOptions: (options: DocumentPluginOptions | undefined) => ResolvedDocumentPluginOptions;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveDocumentPluginOptions = exports.DEFAULT_NUMBERING_TIME_ZONE = void 0;
|
|
4
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
5
|
+
const html_factory_1 = require("../../../documents/templates/html-factory");
|
|
6
|
+
const merchant_1 = require("./merchant");
|
|
7
|
+
/** Used when the `documents.numbering.timeZone` option is not given. */
|
|
8
|
+
exports.DEFAULT_NUMBERING_TIME_ZONE = "Europe/Vienna";
|
|
9
|
+
const resolveDocumentPluginOptions = (options) => {
|
|
10
|
+
const configuredTimeZone = options?.numbering?.timeZone;
|
|
11
|
+
const timeZone = configuredTimeZone === undefined
|
|
12
|
+
? exports.DEFAULT_NUMBERING_TIME_ZONE
|
|
13
|
+
: configuredTimeZone.trim();
|
|
14
|
+
if (!timeZone) {
|
|
15
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "The documents plugin requires a numbering time zone.");
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
new Intl.DateTimeFormat("en", { timeZone }).format();
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `The documents numbering time zone '${timeZone}' is invalid.`);
|
|
22
|
+
}
|
|
23
|
+
if (options?.htmlFactory !== undefined &&
|
|
24
|
+
typeof options.htmlFactory !== "function") {
|
|
25
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "The documents 'htmlFactory' option must be a function.");
|
|
26
|
+
}
|
|
27
|
+
if (options?.merchant !== undefined &&
|
|
28
|
+
(typeof options.merchant !== "object" || options.merchant === null)) {
|
|
29
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "The documents 'merchant' option must be an object.");
|
|
30
|
+
}
|
|
31
|
+
const executablePath = options?.pdf?.executablePath?.trim() || "google-chrome";
|
|
32
|
+
return {
|
|
33
|
+
htmlFactory: options?.htmlFactory ?? (0, html_factory_1.createDefaultDocumentHtmlFactory)({ timeZone }),
|
|
34
|
+
merchantFallback: (0, merchant_1.merchantOptionToFallback)(options?.merchant),
|
|
35
|
+
numbering: { timeZone },
|
|
36
|
+
pdf: { executablePath },
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.resolveDocumentPluginOptions = resolveDocumentPluginOptions;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MedusaContainer } from "@medusajs/framework/types";
|
|
2
|
+
import type { PluginActionProgressInput } from "./types";
|
|
3
|
+
/** Stored shape of a run's progress. */
|
|
4
|
+
export type PluginActionProgress = {
|
|
5
|
+
current: number;
|
|
6
|
+
total: number | null;
|
|
7
|
+
label: string | null;
|
|
8
|
+
};
|
|
9
|
+
/** Longest stored progress label; longer labels are cut. */
|
|
10
|
+
export declare const PLUGIN_ACTION_PROGRESS_LABEL_MAX_LENGTH = 200;
|
|
11
|
+
/**
|
|
12
|
+
* Validates and normalizes reported progress: `current` and `total` are
|
|
13
|
+
* non-negative integers (`total` may be unknown), a blank label is `null`
|
|
14
|
+
* and a long one is cut. Throws `INVALID_DATA`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeActionProgress(progress: PluginActionProgressInput): PluginActionProgress;
|
|
17
|
+
/**
|
|
18
|
+
* Stores the progress of a running action (shown in the Admin while it
|
|
19
|
+
* runs). Call it from the action's workflow with `input.run_id`. Without a
|
|
20
|
+
* `run_id` (e.g. the same workflow run from a script) it does nothing. An
|
|
21
|
+
* unknown or finished run, a failed write and invalid progress (negative
|
|
22
|
+
* or non-integer numbers) are logged as a warning and dropped; progress
|
|
23
|
+
* never fails the action.
|
|
24
|
+
*/
|
|
25
|
+
export declare function reportPluginActionProgress(container: MedusaContainer, runId: string | null | undefined, progress: PluginActionProgressInput): Promise<void>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLUGIN_ACTION_PROGRESS_LABEL_MAX_LENGTH = void 0;
|
|
4
|
+
exports.normalizeActionProgress = normalizeActionProgress;
|
|
5
|
+
exports.reportPluginActionProgress = reportPluginActionProgress;
|
|
6
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
7
|
+
const module_access_1 = require("./module-access");
|
|
8
|
+
/** Longest stored progress label; longer labels are cut. */
|
|
9
|
+
exports.PLUGIN_ACTION_PROGRESS_LABEL_MAX_LENGTH = 200;
|
|
10
|
+
const isCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
11
|
+
/**
|
|
12
|
+
* Validates and normalizes reported progress: `current` and `total` are
|
|
13
|
+
* non-negative integers (`total` may be unknown), a blank label is `null`
|
|
14
|
+
* and a long one is cut. Throws `INVALID_DATA`.
|
|
15
|
+
*/
|
|
16
|
+
function normalizeActionProgress(progress) {
|
|
17
|
+
if (!isCount(progress?.current)) {
|
|
18
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Fortschritt: current muss eine nicht-negative ganze Zahl sein.");
|
|
19
|
+
}
|
|
20
|
+
const total = progress.total ?? null;
|
|
21
|
+
if (total !== null && !isCount(total)) {
|
|
22
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Fortschritt: total muss eine nicht-negative ganze Zahl oder null sein.");
|
|
23
|
+
}
|
|
24
|
+
const label = typeof progress.label === "string" && progress.label.trim()
|
|
25
|
+
? progress.label.trim().slice(0, exports.PLUGIN_ACTION_PROGRESS_LABEL_MAX_LENGTH)
|
|
26
|
+
: null;
|
|
27
|
+
return { current: progress.current, total, label };
|
|
28
|
+
}
|
|
29
|
+
const warn = (container, message) => {
|
|
30
|
+
try {
|
|
31
|
+
container.resolve(utils_1.ContainerRegistrationKeys.LOGGER).warn(message);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Progress is informational; logging must not fail the action.
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Stores the progress of a running action (shown in the Admin while it
|
|
39
|
+
* runs). Call it from the action's workflow with `input.run_id`. Without a
|
|
40
|
+
* `run_id` (e.g. the same workflow run from a script) it does nothing. An
|
|
41
|
+
* unknown or finished run, a failed write and invalid progress (negative
|
|
42
|
+
* or non-integer numbers) are logged as a warning and dropped; progress
|
|
43
|
+
* never fails the action.
|
|
44
|
+
*/
|
|
45
|
+
async function reportPluginActionProgress(container, runId, progress) {
|
|
46
|
+
let normalized;
|
|
47
|
+
try {
|
|
48
|
+
normalized = normalizeActionProgress(progress);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
warn(container, `Ungültiger Fortschritt${runId ? ` für Aktionslauf "${runId}"` : ""} verworfen: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!runId) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const updated = await (0, module_access_1.resolveBaseModule)(container).reportPluginActionRunProgress(runId, normalized);
|
|
59
|
+
if (!updated) {
|
|
60
|
+
warn(container, `Fortschritt für Aktionslauf "${runId}" verworfen: Lauf unbekannt oder nicht mehr aktiv.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
warn(container, `Fortschritt für Aktionslauf "${runId}" konnte nicht gespeichert werden: ${error instanceof Error ? error.message : String(error)}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment helpers for a shop's `medusa-config.ts`. The configuration
|
|
3
|
+
* itself (which plugins run, static shop facts, defaults) lives in the shop;
|
|
4
|
+
* these helpers only read and validate deployment values so a misconfigured
|
|
5
|
+
* deployment fails at startup with the variable's name.
|
|
6
|
+
*/
|
|
7
|
+
export type ConfigurationPhase = "build" | "runtime";
|
|
8
|
+
/**
|
|
9
|
+
* Placeholders for the variables Medusa core and the Stripe payment provider
|
|
10
|
+
* need. `medusa build` loads the configuration without deployment secrets;
|
|
11
|
+
* pass these (merged with the placeholders of the shop's other plugins) as
|
|
12
|
+
* `buildPlaceholders` to `requireEnvironment` so required-variable checks pass
|
|
13
|
+
* during the build. They never reach a running server.
|
|
14
|
+
*/
|
|
15
|
+
export declare const MEDUSA_BUILD_PLACEHOLDERS: Readonly<Record<string, string>>;
|
|
16
|
+
export declare const optionalEnvironment: (environment: NodeJS.ProcessEnv, name: string) => string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns every named value or throws one error listing all missing names.
|
|
19
|
+
* During the build phase, the given `buildPlaceholders` stand in for
|
|
20
|
+
* deployment values; at runtime they are ignored.
|
|
21
|
+
*/
|
|
22
|
+
export declare const requireEnvironment: <Name extends string>(environment: NodeJS.ProcessEnv, names: readonly Name[], phase: ConfigurationPhase, buildPlaceholders: Readonly<Record<string, string>>) => Readonly<Record<Name, string>>;
|
|
23
|
+
export declare const integerEnvironment: (environment: NodeJS.ProcessEnv, name: string, minimum: number, maximum: number) => number | undefined;
|
|
24
|
+
export declare const booleanEnvironment: (environment: NodeJS.ProcessEnv, name: string, defaultValue: boolean) => boolean;
|
|
25
|
+
/** Local development, tests and builds may use plain HTTP and SMTP. */
|
|
26
|
+
export declare const allowsInsecureLocalServices: (environment: NodeJS.ProcessEnv, phase: ConfigurationPhase) => boolean;
|
|
27
|
+
export declare const resolvePublicOrigin: (value: string, name: string, allowHttp: boolean) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Builds an absolute URL on a validated origin from a path that may contain
|
|
30
|
+
* customer-controlled parts (e.g. a locale). Protocol-relative paths, queries,
|
|
31
|
+
* fragments and backslashes are rejected so the URL can never leave the origin.
|
|
32
|
+
*/
|
|
33
|
+
export declare const shopUrl: (origin: string, path: string) => string;
|
|
34
|
+
export declare const resolveStripe: (values: {
|
|
35
|
+
readonly STRIPE_API_KEY: string;
|
|
36
|
+
readonly STRIPE_WEBHOOK_SECRET: string;
|
|
37
|
+
}) => {
|
|
38
|
+
readonly apiKey: string;
|
|
39
|
+
readonly webhookSecret: string;
|
|
40
|
+
};
|
|
41
|
+
export type RedisEventBusConfiguration = {
|
|
42
|
+
readonly url: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Redis is optional in development (Medusa then uses its local Event Bus),
|
|
46
|
+
* required at runtime everywhere else, and never used during a build.
|
|
47
|
+
* Production requires authenticated `rediss://` unless an insecure private
|
|
48
|
+
* network is explicitly accepted.
|
|
49
|
+
*/
|
|
50
|
+
export declare const resolveRedisEventBus: (environment: NodeJS.ProcessEnv, phase: ConfigurationPhase) => RedisEventBusConfiguration | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Boot-time registrations of the plugin's built-in modules, from the same
|
|
53
|
+
* `@hartl-services/medusa-base/config` entry: the SMTP notification provider
|
|
54
|
+
* (E-Mail), the S3 file storage provider with its `/files` gateway part, and
|
|
55
|
+
* the default document markup.
|
|
56
|
+
*/
|
|
57
|
+
export * from "../email/config";
|
|
58
|
+
export * from "../files/config";
|
|
59
|
+
export * from "../documents/config";
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @medusajs/use-medusa-error-not-generic-error -- Startup configuration errors are not HTTP responses. */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.resolveRedisEventBus = exports.resolveStripe = exports.shopUrl = exports.resolvePublicOrigin = exports.allowsInsecureLocalServices = exports.booleanEnvironment = exports.integerEnvironment = exports.requireEnvironment = exports.optionalEnvironment = exports.MEDUSA_BUILD_PLACEHOLDERS = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* Placeholders for the variables Medusa core and the Stripe payment provider
|
|
21
|
+
* need. `medusa build` loads the configuration without deployment secrets;
|
|
22
|
+
* pass these (merged with the placeholders of the shop's other plugins) as
|
|
23
|
+
* `buildPlaceholders` to `requireEnvironment` so required-variable checks pass
|
|
24
|
+
* during the build. They never reach a running server.
|
|
25
|
+
*/
|
|
26
|
+
exports.MEDUSA_BUILD_PLACEHOLDERS = {
|
|
27
|
+
ADMIN_CORS: "http://localhost",
|
|
28
|
+
AUTH_CORS: "http://localhost",
|
|
29
|
+
COOKIE_SECRET: "build-placeholder",
|
|
30
|
+
DATABASE_URL: "postgres://build:build@localhost:5432/build",
|
|
31
|
+
JWT_SECRET: "build-placeholder",
|
|
32
|
+
MEDUSA_BACKEND_URL: "http://localhost",
|
|
33
|
+
STOREFRONT_URL: "http://localhost:8000",
|
|
34
|
+
STORE_CORS: "http://localhost",
|
|
35
|
+
STRIPE_API_KEY: "sk_test_build-placeholder",
|
|
36
|
+
STRIPE_WEBHOOK_SECRET: "whsec_build-placeholder",
|
|
37
|
+
};
|
|
38
|
+
const optionalEnvironment = (environment, name) => {
|
|
39
|
+
const value = environment[name]?.trim();
|
|
40
|
+
return value ? value : undefined;
|
|
41
|
+
};
|
|
42
|
+
exports.optionalEnvironment = optionalEnvironment;
|
|
43
|
+
/**
|
|
44
|
+
* Returns every named value or throws one error listing all missing names.
|
|
45
|
+
* During the build phase, the given `buildPlaceholders` stand in for
|
|
46
|
+
* deployment values; at runtime they are ignored.
|
|
47
|
+
*/
|
|
48
|
+
const requireEnvironment = (environment, names, phase, buildPlaceholders) => {
|
|
49
|
+
const source = phase === "build" ? { ...environment, ...buildPlaceholders } : environment;
|
|
50
|
+
const missing = names.filter((name) => (0, exports.optionalEnvironment)(source, name) === undefined);
|
|
51
|
+
if (missing.length > 0) {
|
|
52
|
+
throw new TypeError(`Missing required environment variables: ${missing.join(", ")}.`);
|
|
53
|
+
}
|
|
54
|
+
return Object.fromEntries(names.map((name) => [name, (0, exports.optionalEnvironment)(source, name)]));
|
|
55
|
+
};
|
|
56
|
+
exports.requireEnvironment = requireEnvironment;
|
|
57
|
+
const integerEnvironment = (environment, name, minimum, maximum) => {
|
|
58
|
+
const value = (0, exports.optionalEnvironment)(environment, name);
|
|
59
|
+
if (value === undefined) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const parsed = Number(value);
|
|
63
|
+
if (!Number.isInteger(parsed) || parsed < minimum || parsed > maximum) {
|
|
64
|
+
throw new TypeError(`${name} must be an integer from ${minimum} through ${maximum}.`);
|
|
65
|
+
}
|
|
66
|
+
return parsed;
|
|
67
|
+
};
|
|
68
|
+
exports.integerEnvironment = integerEnvironment;
|
|
69
|
+
const booleanEnvironment = (environment, name, defaultValue) => {
|
|
70
|
+
const value = (0, exports.optionalEnvironment)(environment, name);
|
|
71
|
+
if (value === undefined) {
|
|
72
|
+
return defaultValue;
|
|
73
|
+
}
|
|
74
|
+
if (value !== "true" && value !== "false") {
|
|
75
|
+
throw new TypeError(`${name} must be either "true" or "false".`);
|
|
76
|
+
}
|
|
77
|
+
return value === "true";
|
|
78
|
+
};
|
|
79
|
+
exports.booleanEnvironment = booleanEnvironment;
|
|
80
|
+
/** Local development, tests and builds may use plain HTTP and SMTP. */
|
|
81
|
+
const allowsInsecureLocalServices = (environment, phase) => phase === "build" ||
|
|
82
|
+
environment.NODE_ENV === "development" ||
|
|
83
|
+
environment.NODE_ENV === "test";
|
|
84
|
+
exports.allowsInsecureLocalServices = allowsInsecureLocalServices;
|
|
85
|
+
const resolvePublicOrigin = (value, name, allowHttp) => {
|
|
86
|
+
let url;
|
|
87
|
+
try {
|
|
88
|
+
url = new URL(value);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
throw new TypeError(`${name} must be a valid HTTP(S) origin.`);
|
|
92
|
+
}
|
|
93
|
+
if ((url.protocol !== "https:" && url.protocol !== "http:") ||
|
|
94
|
+
url.username ||
|
|
95
|
+
url.password ||
|
|
96
|
+
url.pathname !== "/" ||
|
|
97
|
+
url.search ||
|
|
98
|
+
url.hash) {
|
|
99
|
+
throw new TypeError(`${name} must be a valid HTTP(S) origin.`);
|
|
100
|
+
}
|
|
101
|
+
if (!allowHttp && url.protocol !== "https:") {
|
|
102
|
+
throw new TypeError(`${name} must use HTTPS outside development and test.`);
|
|
103
|
+
}
|
|
104
|
+
return url.origin;
|
|
105
|
+
};
|
|
106
|
+
exports.resolvePublicOrigin = resolvePublicOrigin;
|
|
107
|
+
/**
|
|
108
|
+
* Builds an absolute URL on a validated origin from a path that may contain
|
|
109
|
+
* customer-controlled parts (e.g. a locale). Protocol-relative paths, queries,
|
|
110
|
+
* fragments and backslashes are rejected so the URL can never leave the origin.
|
|
111
|
+
*/
|
|
112
|
+
const shopUrl = (origin, path) => {
|
|
113
|
+
if (!path ||
|
|
114
|
+
path !== path.trim() ||
|
|
115
|
+
!path.startsWith("/") ||
|
|
116
|
+
path.startsWith("//") ||
|
|
117
|
+
path.includes("?") ||
|
|
118
|
+
path.includes("#") ||
|
|
119
|
+
path.includes("\\")) {
|
|
120
|
+
throw new TypeError(`Shop URL path "${path}" is not a plain absolute path.`);
|
|
121
|
+
}
|
|
122
|
+
return new URL(path, origin).toString();
|
|
123
|
+
};
|
|
124
|
+
exports.shopUrl = shopUrl;
|
|
125
|
+
const resolveStripe = (values) => {
|
|
126
|
+
if (!values.STRIPE_API_KEY.startsWith("sk_")) {
|
|
127
|
+
throw new TypeError("STRIPE_API_KEY must be a Stripe secret key (sk_...), not a publishable key.");
|
|
128
|
+
}
|
|
129
|
+
if (!values.STRIPE_WEBHOOK_SECRET.startsWith("whsec_")) {
|
|
130
|
+
throw new TypeError("STRIPE_WEBHOOK_SECRET must be a Stripe webhook signing secret (whsec_...).");
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
apiKey: values.STRIPE_API_KEY,
|
|
134
|
+
webhookSecret: values.STRIPE_WEBHOOK_SECRET,
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
exports.resolveStripe = resolveStripe;
|
|
138
|
+
/**
|
|
139
|
+
* Redis is optional in development (Medusa then uses its local Event Bus),
|
|
140
|
+
* required at runtime everywhere else, and never used during a build.
|
|
141
|
+
* Production requires authenticated `rediss://` unless an insecure private
|
|
142
|
+
* network is explicitly accepted.
|
|
143
|
+
*/
|
|
144
|
+
const resolveRedisEventBus = (environment, phase) => {
|
|
145
|
+
if (phase === "build") {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
const url = (0, exports.optionalEnvironment)(environment, "REDIS_URL");
|
|
149
|
+
if (!url) {
|
|
150
|
+
if (environment.NODE_ENV !== "development") {
|
|
151
|
+
throw new TypeError("Missing required environment variables: REDIS_URL.");
|
|
152
|
+
}
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
let parsed;
|
|
156
|
+
try {
|
|
157
|
+
parsed = new URL(url);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
throw new TypeError("REDIS_URL must be a valid Redis URL.");
|
|
161
|
+
}
|
|
162
|
+
if (parsed.protocol !== "redis:" && parsed.protocol !== "rediss:") {
|
|
163
|
+
throw new TypeError("REDIS_URL must use redis:// or rediss://.");
|
|
164
|
+
}
|
|
165
|
+
if (environment.NODE_ENV === "production") {
|
|
166
|
+
if (!parsed.password) {
|
|
167
|
+
throw new TypeError("Production REDIS_URL must include authentication.");
|
|
168
|
+
}
|
|
169
|
+
if (parsed.protocol !== "rediss:" &&
|
|
170
|
+
!(0, exports.booleanEnvironment)(environment, "REDIS_ALLOW_INSECURE_PRIVATE_NETWORK", false)) {
|
|
171
|
+
throw new TypeError("Production REDIS_URL must use rediss:// unless REDIS_ALLOW_INSECURE_PRIVATE_NETWORK=true.");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return { url };
|
|
175
|
+
};
|
|
176
|
+
exports.resolveRedisEventBus = resolveRedisEventBus;
|
|
177
|
+
/**
|
|
178
|
+
* Boot-time registrations of the plugin's built-in modules, from the same
|
|
179
|
+
* `@hartl-services/medusa-base/config` entry: the SMTP notification provider
|
|
180
|
+
* (E-Mail), the S3 file storage provider with its `/files` gateway part, and
|
|
181
|
+
* the default document markup.
|
|
182
|
+
*/
|
|
183
|
+
__exportStar(require("../email/config"), exports);
|
|
184
|
+
__exportStar(require("../files/config"), exports);
|
|
185
|
+
__exportStar(require("../documents/config"), exports);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { PluginFeatureDescriptor } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Checks key format, unique feature keys, existing parents and the single
|
|
4
|
-
* allowed nesting level
|
|
4
|
+
* allowed nesting level, plus the optional settings, actions and Admin page.
|
|
5
|
+
* Throws `INVALID_DATA`.
|
|
5
6
|
*/
|
|
6
7
|
export declare function validatePluginFeatureDescriptor(descriptor: PluginFeatureDescriptor): void;
|
|
7
8
|
/**
|
|
8
9
|
* Declares a plugin's feature switches. Validates at import time so a broken
|
|
9
10
|
* declaration fails the boot instead of a request.
|
|
10
11
|
*/
|
|
11
|
-
export declare function definePluginFeatures<const K extends string>(descriptor: PluginFeatureDescriptor<K>): PluginFeatureDescriptor<K>;
|
|
12
|
+
export declare function definePluginFeatures<const K extends string, const S extends string = never, const A extends string = never>(descriptor: PluginFeatureDescriptor<K, S, A>): PluginFeatureDescriptor<K, S, A>;
|