@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,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry of `@hartl-services/medusa-base/types`: the shop-facing types of the
|
|
3
|
+
* built-in E-Mail (shop branding, templates, SMTP) and Documents (merchant,
|
|
4
|
+
* HTML factory, wire types) modules.
|
|
5
|
+
*/
|
|
6
|
+
export * from "../email/types";
|
|
7
|
+
export * from "../documents/types";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Entry of `@hartl-services/medusa-base/types`: the shop-facing types of the
|
|
19
|
+
* built-in E-Mail (shop branding, templates, SMTP) and Documents (merchant,
|
|
20
|
+
* HTML factory, wire types) modules.
|
|
21
|
+
*/
|
|
22
|
+
__exportStar(require("../email/types"), exports);
|
|
23
|
+
__exportStar(require("../documents/types"), exports);
|
package/dist/public/types.d.ts
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
import type { DocumentPluginOptions } from "../modules/documents/domain/options";
|
|
2
|
+
import type { EmailPluginOptions } from "../email/types";
|
|
3
|
+
import type { FilesPluginOptions } from "../files/types";
|
|
4
|
+
/**
|
|
5
|
+
* Options of the base plugin (`plugins: [{ resolve, options }]`). Medusa hands
|
|
6
|
+
* the same options object to every module of the plugin; each module service
|
|
7
|
+
* reads only its own namespace (`email`, `documents`), the `/files` routes
|
|
8
|
+
* read `files`. `{}` is valid: E-Mail then boots but does not send, the
|
|
9
|
+
* documents numbering time zone defaults to "Europe/Vienna", and the `/files`
|
|
10
|
+
* routes answer that signing is not configured.
|
|
11
|
+
*/
|
|
12
|
+
export type BasePluginOptions = {
|
|
13
|
+
/**
|
|
14
|
+
* Key material for stored secret settings; set it from an environment
|
|
15
|
+
* variable of the shop. Defaults to `projectConfig.http.cookieSecret`.
|
|
16
|
+
* Changing it makes stored secrets undecryptable ("nicht gesetzt").
|
|
17
|
+
*/
|
|
18
|
+
readonly settingsSecret?: string;
|
|
19
|
+
/** Mail dispatch: shop branding/URLs and the JWT secret of the links. */
|
|
20
|
+
readonly email?: EmailPluginOptions;
|
|
21
|
+
/** Order documents: merchant fallback, numbering, PDF, HTML factory. */
|
|
22
|
+
readonly documents?: DocumentPluginOptions;
|
|
23
|
+
/** `/files` gateway signing; set from `createS3CacheStorageConfig`. */
|
|
24
|
+
readonly files?: FilesPluginOptions;
|
|
25
|
+
};
|
|
1
26
|
export type PluginFeatureDefinition<K extends string = string> = {
|
|
2
27
|
readonly key: K;
|
|
3
28
|
readonly label: string;
|
|
@@ -5,17 +30,75 @@ export type PluginFeatureDefinition<K extends string = string> = {
|
|
|
5
30
|
readonly default_enabled: boolean;
|
|
6
31
|
readonly parent_key?: K;
|
|
7
32
|
};
|
|
8
|
-
export type
|
|
33
|
+
export type PluginSettingType = "string" | "url" | "number" | "boolean" | "secret" | "select";
|
|
34
|
+
/** One allowed value of a `"select"` setting. */
|
|
35
|
+
export type PluginSettingOption = {
|
|
36
|
+
readonly value: string;
|
|
37
|
+
readonly label: string;
|
|
38
|
+
};
|
|
39
|
+
export type PluginSettingValue = string | number | boolean;
|
|
40
|
+
export type PluginSettingDefinition<S extends string = string> = {
|
|
41
|
+
readonly key: S;
|
|
42
|
+
readonly label: string;
|
|
43
|
+
readonly description?: string;
|
|
44
|
+
readonly type: PluginSettingType;
|
|
45
|
+
/** `false` when omitted. */
|
|
46
|
+
readonly required?: boolean;
|
|
47
|
+
/** Never for `"secret"`; must match `type` (and `options`/`min`/`max`). */
|
|
48
|
+
readonly default?: PluginSettingValue;
|
|
49
|
+
/** Required for `"select"` (non-empty, unique values); only there. */
|
|
50
|
+
readonly options?: readonly PluginSettingOption[];
|
|
51
|
+
/** Inclusive lower bound; only for `"number"`. */
|
|
52
|
+
readonly min?: number;
|
|
53
|
+
/** Inclusive upper bound; only for `"number"`. */
|
|
54
|
+
readonly max?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Secret settings of the same plugin whose stored values are deleted when
|
|
57
|
+
* this setting's stored value changes (also when it is cleared), e.g. an
|
|
58
|
+
* API key that must not be sent to a new URL.
|
|
59
|
+
*/
|
|
60
|
+
readonly invalidates?: readonly S[];
|
|
61
|
+
};
|
|
62
|
+
export type PluginActionMode = "sync" | "background";
|
|
63
|
+
export type PluginActionDefinition<A extends string = string> = {
|
|
64
|
+
readonly key: A;
|
|
65
|
+
readonly label: string;
|
|
66
|
+
readonly description?: string;
|
|
67
|
+
/** Registered workflow the base runs for this action. */
|
|
68
|
+
readonly workflow_id: string;
|
|
69
|
+
readonly mode: PluginActionMode;
|
|
70
|
+
/** Confirmation text shown before running. */
|
|
71
|
+
readonly confirm?: string;
|
|
72
|
+
};
|
|
73
|
+
export type PluginFeatureDescriptor<K extends string = string, S extends string = string, A extends string = string> = {
|
|
9
74
|
readonly plugin_key: string;
|
|
10
75
|
readonly label: string;
|
|
11
76
|
readonly description?: string;
|
|
12
77
|
/** Plugin switch default, `true` when omitted. */
|
|
13
78
|
readonly default_enabled?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* `false`: the plugin cannot be switched off. The Admin shows no plugin
|
|
81
|
+
* switch and `enabled` is always `true`. `true` when omitted.
|
|
82
|
+
*/
|
|
83
|
+
readonly switchable?: boolean;
|
|
14
84
|
readonly features: readonly PluginFeatureDefinition<K>[];
|
|
85
|
+
readonly settings?: readonly PluginSettingDefinition<S>[];
|
|
86
|
+
readonly actions?: readonly PluginActionDefinition<A>[];
|
|
87
|
+
/**
|
|
88
|
+
* The plugin's own Admin page, relative to the Admin root; the hub's
|
|
89
|
+
* "Öffnen" links there. Starts with `/settings/hartl-services/`, never with
|
|
90
|
+
* `/settings/hartl-services/plugin/` (the base's generic page, used when
|
|
91
|
+
* omitted).
|
|
92
|
+
*/
|
|
93
|
+
readonly admin_page?: string;
|
|
15
94
|
};
|
|
95
|
+
/** Values a plugin received from medusa-config; the base shows them as source "config". */
|
|
96
|
+
export type PluginSettingsFallback<S extends string = string> = Partial<Record<S, PluginSettingValue | null | undefined>>;
|
|
16
97
|
/** Implemented by a plugin's module service so the base can discover it. */
|
|
17
98
|
export interface PluginFeatureProvider {
|
|
18
99
|
readonly pluginFeatures: PluginFeatureDescriptor;
|
|
100
|
+
/** Optional medusa-config fallback for the declared settings. */
|
|
101
|
+
readonly pluginSettingsFallback?: PluginSettingsFallback;
|
|
19
102
|
}
|
|
20
103
|
export type EffectivePluginFeatures = {
|
|
21
104
|
plugin_key: string;
|
|
@@ -27,3 +110,32 @@ export type StoredPluginFeatures = {
|
|
|
27
110
|
enabled: boolean;
|
|
28
111
|
features: Record<string, boolean>;
|
|
29
112
|
};
|
|
113
|
+
/**
|
|
114
|
+
* Settings for server-side consumers. Secrets are decrypted. `values` holds
|
|
115
|
+
* every setting that has a value (stored > config > default).
|
|
116
|
+
*/
|
|
117
|
+
export type ResolvedPluginSettings<S extends string = string> = {
|
|
118
|
+
values: Partial<Record<S, PluginSettingValue>>;
|
|
119
|
+
/** Every required setting has a value. */
|
|
120
|
+
configured: boolean;
|
|
121
|
+
/** Keys of required settings without a value. */
|
|
122
|
+
missing: S[];
|
|
123
|
+
};
|
|
124
|
+
/** Input the base passes to an action's workflow. */
|
|
125
|
+
export type PluginActionWorkflowInput = {
|
|
126
|
+
plugin_key: string;
|
|
127
|
+
action_key: string;
|
|
128
|
+
/** Admin user id that triggered the action. */
|
|
129
|
+
triggered_by: string;
|
|
130
|
+
/** Recorded run; pass it to `reportPluginActionProgress`. */
|
|
131
|
+
run_id: string;
|
|
132
|
+
};
|
|
133
|
+
/** Progress a running action reports through `reportPluginActionProgress`. */
|
|
134
|
+
export type PluginActionProgressInput = {
|
|
135
|
+
/** Items (or pages) done so far; a non-negative integer. */
|
|
136
|
+
current: number;
|
|
137
|
+
/** Expected total; `null`/omitted = unknown. */
|
|
138
|
+
total?: number | null;
|
|
139
|
+
/** Short human-readable status, e.g. "Produkte: Seite 3". */
|
|
140
|
+
label?: string | null;
|
|
141
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineConfig } from "@medusajs/framework/utils";
|
|
2
|
+
import { withSentryErrorReporting } from "../public/sentry-logger";
|
|
3
|
+
import { type FoodShopConfigOptions } from "./options";
|
|
4
|
+
type ConfigInput = Parameters<typeof defineConfig>[0];
|
|
5
|
+
type ProjectConfigInput = NonNullable<Extract<NonNullable<ConfigInput>, {
|
|
6
|
+
projectConfig?: unknown;
|
|
7
|
+
}>["projectConfig"]>;
|
|
8
|
+
/** A plugin registration of the returned configuration. */
|
|
9
|
+
export type FoodShopPlugin = {
|
|
10
|
+
resolve: string;
|
|
11
|
+
options: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
/** A module registration of the returned configuration. */
|
|
14
|
+
export type FoodShopModule = {
|
|
15
|
+
key?: string;
|
|
16
|
+
resolve: string;
|
|
17
|
+
options?: Record<string, unknown>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The configuration input before `defineConfig`. `modules` and `plugins` are
|
|
21
|
+
* plain arrays so a caller (for example a test harness) can adjust them.
|
|
22
|
+
*/
|
|
23
|
+
export type FoodShopConfigInput = {
|
|
24
|
+
admin: {
|
|
25
|
+
path: `/${string}`;
|
|
26
|
+
};
|
|
27
|
+
logger: ReturnType<typeof withSentryErrorReporting>;
|
|
28
|
+
projectConfig: ProjectConfigInput;
|
|
29
|
+
modules: FoodShopModule[];
|
|
30
|
+
plugins: FoodShopPlugin[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Builds the plain `medusa-config.ts` input of a food shop: Medusa core
|
|
34
|
+
* settings, the Redis event bus, SMTP notifications, S3 file storage, tax and
|
|
35
|
+
* Stripe payment providers, and the Hartl Services plugins (the base plugin
|
|
36
|
+
* with its E-Mail, Documents and file storage modules plus five feature
|
|
37
|
+
* plugins). Deployment
|
|
38
|
+
* values are read and validated from `environment`; a missing or invalid one
|
|
39
|
+
* fails with its name.
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildFoodShopConfig(options: FoodShopConfigOptions, environment?: NodeJS.ProcessEnv): FoodShopConfigInput;
|
|
42
|
+
/** `defineConfig(buildFoodShopConfig(options))` for `module.exports`. */
|
|
43
|
+
export declare function defineFoodShopConfig(options: FoodShopConfigOptions, environment?: NodeJS.ProcessEnv): ReturnType<typeof defineConfig>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildFoodShopConfig = buildFoodShopConfig;
|
|
4
|
+
exports.defineFoodShopConfig = defineFoodShopConfig;
|
|
5
|
+
const logger_1 = require("@medusajs/framework/logger");
|
|
6
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
7
|
+
const config_1 = require("../public/config");
|
|
8
|
+
const sentry_logger_1 = require("../public/sentry-logger");
|
|
9
|
+
const options_1 = require("./options");
|
|
10
|
+
/**
|
|
11
|
+
* Builds the plain `medusa-config.ts` input of a food shop: Medusa core
|
|
12
|
+
* settings, the Redis event bus, SMTP notifications, S3 file storage, tax and
|
|
13
|
+
* Stripe payment providers, and the Hartl Services plugins (the base plugin
|
|
14
|
+
* with its E-Mail, Documents and file storage modules plus five feature
|
|
15
|
+
* plugins). Deployment
|
|
16
|
+
* values are read and validated from `environment`; a missing or invalid one
|
|
17
|
+
* fails with its name.
|
|
18
|
+
*/
|
|
19
|
+
function buildFoodShopConfig(options, environment = process.env) {
|
|
20
|
+
(0, options_1.assertFoodShopConfigOptions)(options);
|
|
21
|
+
const { merchant } = options;
|
|
22
|
+
if (options.loadEnvFile !== false) {
|
|
23
|
+
(0, utils_1.loadEnv)(process.env.NODE_ENV || "development", process.cwd());
|
|
24
|
+
}
|
|
25
|
+
const phase = environment.MEDUSA_BUILD_PHASE === "true" ? "build" : "runtime";
|
|
26
|
+
const allowInsecure = (0, config_1.allowsInsecureLocalServices)(environment, phase);
|
|
27
|
+
const env = (0, config_1.requireEnvironment)(environment, [
|
|
28
|
+
"DATABASE_URL",
|
|
29
|
+
"STORE_CORS",
|
|
30
|
+
"ADMIN_CORS",
|
|
31
|
+
"AUTH_CORS",
|
|
32
|
+
"JWT_SECRET",
|
|
33
|
+
"COOKIE_SECRET",
|
|
34
|
+
"MEDUSA_BACKEND_URL",
|
|
35
|
+
"STOREFRONT_URL",
|
|
36
|
+
...config_1.SMTP_ENVIRONMENT_VARIABLES,
|
|
37
|
+
"STRIPE_API_KEY",
|
|
38
|
+
"STRIPE_WEBHOOK_SECRET",
|
|
39
|
+
"S3_CACHE_STORAGE_BUCKET",
|
|
40
|
+
"S3_CACHE_STORAGE_REGION",
|
|
41
|
+
"DOCUMENT_PDF_EXECUTABLE",
|
|
42
|
+
], phase, {
|
|
43
|
+
...config_1.MEDUSA_BUILD_PLACEHOLDERS,
|
|
44
|
+
...config_1.SMTP_BUILD_PLACEHOLDERS,
|
|
45
|
+
...config_1.S3_BUILD_PLACEHOLDERS,
|
|
46
|
+
...config_1.DOCUMENTS_BUILD_PLACEHOLDERS,
|
|
47
|
+
});
|
|
48
|
+
const storefrontOrigin = (0, config_1.resolvePublicOrigin)(env.STOREFRONT_URL, "STOREFRONT_URL", allowInsecure);
|
|
49
|
+
const backendOrigin = (0, config_1.resolvePublicOrigin)(env.MEDUSA_BACKEND_URL, "MEDUSA_BACKEND_URL", allowInsecure);
|
|
50
|
+
const redis = (0, config_1.resolveRedisEventBus)(environment, phase);
|
|
51
|
+
const stripe = (0, config_1.resolveStripe)(env);
|
|
52
|
+
const storefrontPath = `/${options.storefrontCountryCode}`;
|
|
53
|
+
// S3 file storage: the File Module provider plus the `files.gateway` option
|
|
54
|
+
// of the base plugin that serves its /files routes, both from one validated
|
|
55
|
+
// configuration.
|
|
56
|
+
const s3CacheStorage = (0, config_1.createS3CacheStorageConfig)({
|
|
57
|
+
cache: {
|
|
58
|
+
cleanupIntervalMs: (0, config_1.integerEnvironment)(environment, "S3_CACHE_STORAGE_CLEANUP_INTERVAL_MS", 1, 86_400_000) ?? 900_000,
|
|
59
|
+
dir: (0, config_1.optionalEnvironment)(environment, "S3_CACHE_STORAGE_CACHE_DIR") ??
|
|
60
|
+
"./.medusa-s3-cache",
|
|
61
|
+
expirationStrategy: (0, config_1.resolveExpirationStrategy)(environment, "absolute"),
|
|
62
|
+
ttlMs: (0, config_1.integerEnvironment)(environment, "S3_CACHE_STORAGE_TTL_MS", 0, 604_800_000) ?? 3_600_000,
|
|
63
|
+
},
|
|
64
|
+
gateway: {
|
|
65
|
+
baseUrl: `${backendOrigin}/files`,
|
|
66
|
+
privateDownloadDurationSeconds: (0, config_1.integerEnvironment)(environment, "FILE_GATEWAY_PRIVATE_DOWNLOAD_DURATION_SECONDS", 1, 604_800) ?? 3_600,
|
|
67
|
+
signingSecret: env.JWT_SECRET,
|
|
68
|
+
},
|
|
69
|
+
s3: {
|
|
70
|
+
bucket: env.S3_CACHE_STORAGE_BUCKET,
|
|
71
|
+
credentials: (0, config_1.resolveS3Credentials)(environment, phase),
|
|
72
|
+
endpoint: (0, config_1.optionalEnvironment)(environment, "S3_CACHE_STORAGE_ENDPOINT"),
|
|
73
|
+
forcePathStyle: (0, config_1.booleanEnvironment)(environment, "S3_CACHE_STORAGE_FORCE_PATH_STYLE", false),
|
|
74
|
+
region: env.S3_CACHE_STORAGE_REGION,
|
|
75
|
+
storagePrefix: (0, config_1.optionalEnvironment)(environment, "S3_CACHE_STORAGE_PREFIX"),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
const modules = [
|
|
79
|
+
...(redis
|
|
80
|
+
? [
|
|
81
|
+
{
|
|
82
|
+
key: utils_1.Modules.EVENT_BUS,
|
|
83
|
+
resolve: "@medusajs/event-bus-redis",
|
|
84
|
+
options: {
|
|
85
|
+
redisUrl: redis.url,
|
|
86
|
+
jobOptions: {
|
|
87
|
+
attempts: 3,
|
|
88
|
+
backoff: {
|
|
89
|
+
delay: 1_000,
|
|
90
|
+
type: "exponential",
|
|
91
|
+
},
|
|
92
|
+
removeOnComplete: true,
|
|
93
|
+
removeOnFail: {
|
|
94
|
+
age: 3_600,
|
|
95
|
+
count: 1_000,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
]
|
|
101
|
+
: []),
|
|
102
|
+
(0, config_1.createSmtpNotificationModuleConfig)((0, config_1.resolveSmtp)(env, allowInsecure)),
|
|
103
|
+
s3CacheStorage.fileModule,
|
|
104
|
+
{
|
|
105
|
+
resolve: "@medusajs/medusa/tax",
|
|
106
|
+
options: {
|
|
107
|
+
providers: [
|
|
108
|
+
{
|
|
109
|
+
resolve: "@hartl-services/medusa-tax-compliance/providers/tax-compliance",
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
resolve: "@medusajs/medusa/payment",
|
|
116
|
+
options: {
|
|
117
|
+
providers: [
|
|
118
|
+
{
|
|
119
|
+
resolve: "@medusajs/medusa/payment-stripe",
|
|
120
|
+
id: "stripe",
|
|
121
|
+
options: {
|
|
122
|
+
apiKey: stripe.apiKey,
|
|
123
|
+
webhookSecret: stripe.webhookSecret,
|
|
124
|
+
// Capture immediately at checkout. Several enabled payment
|
|
125
|
+
// methods (e.g. SEPA Direct Debit, iDEAL, Klarna) do not
|
|
126
|
+
// support a separate manual-capture step, so authorize-only is
|
|
127
|
+
// not an option while automaticPaymentMethods exposes them.
|
|
128
|
+
capture: true,
|
|
129
|
+
// Which methods appear (card, SEPA, wallets, ...) is controlled
|
|
130
|
+
// in the Stripe Dashboard under Settings -> Payment methods.
|
|
131
|
+
automaticPaymentMethods: true,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
const plugins = [
|
|
139
|
+
{
|
|
140
|
+
// Always first: owns the plugin feature toggles the other plugins gate
|
|
141
|
+
// on, and carries E-Mail, Documents and the /files gateway.
|
|
142
|
+
resolve: "@hartl-services/medusa-base",
|
|
143
|
+
options: {
|
|
144
|
+
email: {
|
|
145
|
+
jwtSecret: env.JWT_SECRET,
|
|
146
|
+
shop: {
|
|
147
|
+
displayName: options.displayName,
|
|
148
|
+
affiliatePortalUrl: (0, config_1.shopUrl)(storefrontOrigin, `${storefrontPath}/partnerportal`),
|
|
149
|
+
// The Admin dashboard mounts "/invite" under admin.path ("/app").
|
|
150
|
+
inviteUrl: ({ token }) => {
|
|
151
|
+
const url = new URL("/app/invite", backendOrigin);
|
|
152
|
+
url.searchParams.set("token", token);
|
|
153
|
+
return url.toString();
|
|
154
|
+
},
|
|
155
|
+
orderNotificationEmail: options.orderNotificationEmail,
|
|
156
|
+
// The e-mail module appends "#token=<token>".
|
|
157
|
+
passwordResetUrl: () => (0, config_1.shopUrl)(storefrontOrigin, `${storefrontPath}/reset-password`),
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
documents: {
|
|
161
|
+
// Fallback only: the shop master data in the Admin ("Hartl Services
|
|
162
|
+
// Plugins" -> Shop-Stammdaten) wins per field.
|
|
163
|
+
merchant,
|
|
164
|
+
numbering: {
|
|
165
|
+
// Chooses the annual document-number period; matches the date the
|
|
166
|
+
// HTML factory prints.
|
|
167
|
+
timeZone: options.timeZone,
|
|
168
|
+
},
|
|
169
|
+
pdf: {
|
|
170
|
+
executablePath: env.DOCUMENT_PDF_EXECUTABLE,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
files: { gateway: s3CacheStorage.gateway },
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
resolve: "@hartl-services/medusa-tax-compliance",
|
|
178
|
+
options: { merchant },
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
resolve: "@hartl-services/medusa-free-shipping",
|
|
182
|
+
options: {},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
resolve: "@hartl-services/medusa-batch-management",
|
|
186
|
+
options: {},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
resolve: "@hartl-services/medusa-affiliate",
|
|
190
|
+
options: {
|
|
191
|
+
consignment_reminders: {
|
|
192
|
+
due_day: 10,
|
|
193
|
+
timezone: options.timeZone,
|
|
194
|
+
},
|
|
195
|
+
portal: {
|
|
196
|
+
referral_base_url: (0, config_1.shopUrl)(storefrontOrigin, storefrontPath),
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
resolve: "@hartl-services/medusa-payload-sync",
|
|
202
|
+
// URL, API key and auth collection are Admin settings of the base
|
|
203
|
+
// plugin ("Hartl Services Plugins" -> Payload-CMS-Sync); until they are
|
|
204
|
+
// stored the plugin boots "nicht konfiguriert".
|
|
205
|
+
options: {},
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
return {
|
|
209
|
+
admin: {
|
|
210
|
+
// Kept explicit: serving the Admin SPA at "/" instead breaks its own
|
|
211
|
+
// auth, since the SPA's client-side-routing fallback then catches real
|
|
212
|
+
// API routes like /auth/user/providers too. The invite URL depends on
|
|
213
|
+
// this path.
|
|
214
|
+
path: "/app",
|
|
215
|
+
},
|
|
216
|
+
// Medusa's own HTTP error-handler middleware fully "handles" every thrown
|
|
217
|
+
// route/workflow error via logger.error(...) before it can ever reach an
|
|
218
|
+
// uncaught-exception process hook, so Sentry's default Node integrations
|
|
219
|
+
// never see it. This bridges logger.error(...) itself so those errors
|
|
220
|
+
// still reach Sentry.
|
|
221
|
+
logger: (0, sentry_logger_1.withSentryErrorReporting)(logger_1.logger),
|
|
222
|
+
projectConfig: {
|
|
223
|
+
databaseUrl: env.DATABASE_URL,
|
|
224
|
+
http: {
|
|
225
|
+
storeCors: env.STORE_CORS,
|
|
226
|
+
adminCors: env.ADMIN_CORS,
|
|
227
|
+
authCors: env.AUTH_CORS,
|
|
228
|
+
jwtSecret: env.JWT_SECRET,
|
|
229
|
+
cookieSecret: env.COOKIE_SECRET,
|
|
230
|
+
},
|
|
231
|
+
// The storefront turns its customer JWT into a Medusa browser session
|
|
232
|
+
// at login, so its browser-side cart and payment calls carry the
|
|
233
|
+
// customer's identity. Kept at the JWT's own 24h lifetime (Medusa's
|
|
234
|
+
// default is 10h) so the two never disagree about whether the customer
|
|
235
|
+
// is logged in.
|
|
236
|
+
sessionOptions: {
|
|
237
|
+
ttl: 24 * 60 * 60 * 1000,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
modules,
|
|
241
|
+
plugins,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/** `defineConfig(buildFoodShopConfig(options))` for `module.exports`. */
|
|
245
|
+
function defineFoodShopConfig(options, environment = process.env) {
|
|
246
|
+
return (0, utils_1.defineConfig)(buildFoodShopConfig(options, environment));
|
|
247
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { DocumentMerchantOption } from "../documents/types";
|
|
2
|
+
/**
|
|
3
|
+
* The shop-specific facts of a food shop. Deployment values and secrets are
|
|
4
|
+
* not options: they come from the environment (see the README).
|
|
5
|
+
*/
|
|
6
|
+
export type FoodShopConfigOptions = Readonly<{
|
|
7
|
+
/**
|
|
8
|
+
* Fallback for the shop master data (Admin -> "Hartl Services Plugins" ->
|
|
9
|
+
* Shop-Stammdaten) that documents and tax compliance read per field. Its
|
|
10
|
+
* `legalName` is also the seeded store name.
|
|
11
|
+
*/
|
|
12
|
+
merchant: DocumentMerchantOption;
|
|
13
|
+
/** Shop name in the branding of the default e-mail templates. */
|
|
14
|
+
displayName: string;
|
|
15
|
+
/** Receives the shop's order notification e-mails. */
|
|
16
|
+
orderNotificationEmail: string;
|
|
17
|
+
/**
|
|
18
|
+
* IANA time zone (e.g. "Europe/Vienna"): chooses the annual document-number
|
|
19
|
+
* period, matches the dates printed on documents, and schedules the
|
|
20
|
+
* affiliate consignment reminders.
|
|
21
|
+
*/
|
|
22
|
+
timeZone: string;
|
|
23
|
+
/**
|
|
24
|
+
* Country code of the storefront route segment (e.g. "de"): e-mail links
|
|
25
|
+
* point to `/<code>/partnerportal` and `/<code>/reset-password`, and
|
|
26
|
+
* affiliate referral links to `/<code>`.
|
|
27
|
+
*/
|
|
28
|
+
storefrontCountryCode: string;
|
|
29
|
+
/**
|
|
30
|
+
* Load `.env.<NODE_ENV>` from the working directory into `process.env`
|
|
31
|
+
* like `medusa-config.ts` does by default. Pass `false` when the
|
|
32
|
+
* environment is already complete (tests, isolated child processes).
|
|
33
|
+
* Defaults to `true`.
|
|
34
|
+
*/
|
|
35
|
+
loadEnvFile?: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Throws a `TypeError` naming the first invalid option, so a misconfigured
|
|
39
|
+
* shop fails at boot.
|
|
40
|
+
*/
|
|
41
|
+
export declare function assertFoodShopConfigOptions(options: unknown): asserts options is FoodShopConfigOptions;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertFoodShopConfigOptions = assertFoodShopConfigOptions;
|
|
4
|
+
const fail = (name, expectation) => {
|
|
5
|
+
throw new TypeError(`Food shop option "${name}" must be ${expectation}.`);
|
|
6
|
+
};
|
|
7
|
+
const requireText = (value, name) => {
|
|
8
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
9
|
+
return fail(name, "a non-empty string");
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
13
|
+
const requireCountryCode = (value, name) => {
|
|
14
|
+
if (typeof value !== "string" || !/^[a-z]{2}$/.test(value)) {
|
|
15
|
+
return fail(name, 'a 2-letter lowercase country code such as "de"');
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
const requireTimeZone = (value, name) => {
|
|
20
|
+
const timeZone = requireText(value, name);
|
|
21
|
+
try {
|
|
22
|
+
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return fail(name, 'a valid IANA time zone such as "Europe/Vienna"');
|
|
26
|
+
}
|
|
27
|
+
return timeZone;
|
|
28
|
+
};
|
|
29
|
+
const requireEmail = (value, name) => {
|
|
30
|
+
const email = requireText(value, name);
|
|
31
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
|
32
|
+
return fail(name, "a valid e-mail address");
|
|
33
|
+
}
|
|
34
|
+
return email;
|
|
35
|
+
};
|
|
36
|
+
const requireObject = (value, name) => {
|
|
37
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
38
|
+
return fail(name, "an object");
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Throws a `TypeError` naming the first invalid option, so a misconfigured
|
|
44
|
+
* shop fails at boot.
|
|
45
|
+
*/
|
|
46
|
+
function assertFoodShopConfigOptions(options) {
|
|
47
|
+
const candidate = requireObject(options, "options");
|
|
48
|
+
const merchant = requireObject(candidate.merchant, "merchant");
|
|
49
|
+
requireText(merchant.legalName, "merchant.legalName");
|
|
50
|
+
requireCountryCode(merchant.countryCode, "merchant.countryCode");
|
|
51
|
+
if (merchant.vatNumber !== undefined) {
|
|
52
|
+
requireText(merchant.vatNumber, "merchant.vatNumber");
|
|
53
|
+
}
|
|
54
|
+
const address = requireObject(merchant.registeredAddress, "merchant.registeredAddress");
|
|
55
|
+
requireText(address.address1, "merchant.registeredAddress.address1");
|
|
56
|
+
if (address.address2 !== undefined) {
|
|
57
|
+
requireText(address.address2, "merchant.registeredAddress.address2");
|
|
58
|
+
}
|
|
59
|
+
requireText(address.city, "merchant.registeredAddress.city");
|
|
60
|
+
requireText(address.postalCode, "merchant.registeredAddress.postalCode");
|
|
61
|
+
requireCountryCode(address.countryCode, "merchant.registeredAddress.countryCode");
|
|
62
|
+
requireText(candidate.displayName, "displayName");
|
|
63
|
+
requireEmail(candidate.orderNotificationEmail, "orderNotificationEmail");
|
|
64
|
+
requireTimeZone(candidate.timeZone, "timeZone");
|
|
65
|
+
requireCountryCode(candidate.storefrontCountryCode, "storefrontCountryCode");
|
|
66
|
+
if (candidate.loadEnvFile !== undefined &&
|
|
67
|
+
typeof candidate.loadEnvFile !== "boolean") {
|
|
68
|
+
fail("loadEnvFile", "a boolean");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MedusaContainer } from "@medusajs/framework/types";
|
|
2
|
+
import type { PluginFeatureDescriptor, PluginSettingsFallback } from "../public/types";
|
|
3
|
+
export type RegisteredModule = {
|
|
4
|
+
key: string;
|
|
5
|
+
service: unknown;
|
|
6
|
+
};
|
|
7
|
+
/** A discovered declaring module service. */
|
|
8
|
+
export type PluginFeatureProviderEntry = {
|
|
9
|
+
module_key: string;
|
|
10
|
+
descriptor: PluginFeatureDescriptor;
|
|
11
|
+
service: unknown;
|
|
12
|
+
};
|
|
13
|
+
/** Every module listed in medusa-config that is registered in the container. */
|
|
14
|
+
export declare function listRegisteredModules(container: MedusaContainer): RegisteredModule[];
|
|
15
|
+
/**
|
|
16
|
+
* Finds every registered module whose service declares `pluginFeatures`.
|
|
17
|
+
* Fails closed: an invalid or duplicate declaration is `UNEXPECTED_STATE`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function discoverPluginFeatureDescriptors(container: MedusaContainer): PluginFeatureDescriptor[];
|
|
20
|
+
/** Like `discoverPluginFeatureDescriptors`, with the declaring service. */
|
|
21
|
+
export declare function discoverPluginFeatureProviders(container: MedusaContainer): PluginFeatureProviderEntry[];
|
|
22
|
+
export declare function findPluginFeatureDescriptor(container: MedusaContainer, pluginKey: string): PluginFeatureDescriptor | undefined;
|
|
23
|
+
export declare function findPluginFeatureProvider(container: MedusaContainer, pluginKey: string): PluginFeatureProviderEntry | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The medusa-config fallback a provider exposes as `pluginSettingsFallback`.
|
|
26
|
+
* Read on every call, since a service may compute it lazily.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readPluginSettingsFallback(provider: PluginFeatureProviderEntry): PluginSettingsFallback | undefined;
|