@lookiero/checkout 0.3.18 → 0.3.19

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.
Files changed (26) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/domain/checkoutFeedback/command/giveCheckoutFeedback.d.ts +15 -0
  3. package/dist/src/domain/checkoutFeedback/command/giveCheckoutFeedback.js +7 -0
  4. package/dist/src/domain/checkoutFeedback/model/checkoutFeedback.d.ts +9 -0
  5. package/dist/src/domain/checkoutFeedback/model/checkoutFeedback.js +10 -0
  6. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbackGiven.d.ts +13 -0
  7. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbackGiven.js +4 -0
  8. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbacks.d.ts +7 -0
  9. package/dist/src/domain/checkoutFeedback/model/checkoutFeedbacks.js +1 -0
  10. package/dist/src/domain/checkoutFeedback/model/feedbacks.d.ts +3 -0
  11. package/dist/src/domain/checkoutFeedback/model/feedbacks.js +1 -0
  12. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacks.d.ts +16 -0
  13. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacks.js +14 -0
  14. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacksGive.d.ts +5 -0
  15. package/dist/src/infrastructure/domain/checkoutFeedback/model/httpCheckoutFeedbacksGive.js +13 -0
  16. package/dist/src/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.d.ts +17 -0
  17. package/dist/src/infrastructure/domain/checkoutFeedback/react/useGiveCheckoutFeedback.js +13 -0
  18. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByIdView.d.ts +12 -0
  19. package/dist/src/infrastructure/projection/checkoutFeedback/httpCheckoutFeedbackByIdView.js +9 -0
  20. package/dist/src/projection/checkoutFeedback/checkoutFeedback.d.ts +6 -0
  21. package/dist/src/projection/checkoutFeedback/checkoutFeedback.js +1 -0
  22. package/dist/src/projection/checkoutFeedback/feedback.d.ts +3 -0
  23. package/dist/src/projection/checkoutFeedback/feedback.js +1 -0
  24. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackById.d.ts +25 -0
  25. package/dist/src/projection/checkoutFeedback/viewCheckoutFeedbackById.js +8 -0
  26. package/package.json +1 -1
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.18",
3
+ "version": "0.3.19",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -0,0 +1,15 @@
1
+ import { Command } from "@lookiero/messaging";
2
+ import { Feedbacks } from "../model/feedbacks";
3
+ declare const GIVE_CHECKOUT_FEEDBACK = "give_checkout_feedback";
4
+ interface GiveCheckoutFeedbackPayload {
5
+ readonly aggregateId: string;
6
+ readonly feedbacks: Feedbacks;
7
+ }
8
+ interface GiveCheckoutFeedback extends Command<typeof GIVE_CHECKOUT_FEEDBACK>, GiveCheckoutFeedbackPayload {
9
+ }
10
+ interface GiveCheckoutFeedbackFunction {
11
+ (payload: GiveCheckoutFeedbackPayload): GiveCheckoutFeedback;
12
+ }
13
+ declare const giveCheckoutFeedback: GiveCheckoutFeedbackFunction;
14
+ export type { GiveCheckoutFeedback };
15
+ export { GIVE_CHECKOUT_FEEDBACK, giveCheckoutFeedback };
@@ -0,0 +1,7 @@
1
+ import { command } from "@lookiero/messaging";
2
+ const GIVE_CHECKOUT_FEEDBACK = "give_checkout_feedback";
3
+ const giveCheckoutFeedback = ({ aggregateId, ...payload }) => ({
4
+ ...command({ aggregateId, name: GIVE_CHECKOUT_FEEDBACK }),
5
+ ...payload,
6
+ });
7
+ export { GIVE_CHECKOUT_FEEDBACK, giveCheckoutFeedback };
@@ -0,0 +1,9 @@
1
+ import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
+ import { GiveCheckoutFeedback } from "../command/giveCheckoutFeedback";
3
+ import { Feedbacks } from "./feedbacks";
4
+ interface CheckoutFeedback extends AggregateRoot {
5
+ readonly feedbacks: Feedbacks;
6
+ }
7
+ declare const giveCheckoutFeedbackHandler: CommandHandlerFunction<GiveCheckoutFeedback, CheckoutFeedback>;
8
+ export type { CheckoutFeedback };
9
+ export { giveCheckoutFeedbackHandler };
@@ -0,0 +1,10 @@
1
+ import { checkoutFeedbackGiven } from "./checkoutFeedbackGiven";
2
+ const giveCheckoutFeedbackHandler = () => async ({ aggregateRoot, command }) => {
3
+ const { aggregateId, feedbacks } = command;
4
+ return {
5
+ ...aggregateRoot,
6
+ feedbacks,
7
+ domainEvents: [checkoutFeedbackGiven({ aggregateId })],
8
+ };
9
+ };
10
+ export { giveCheckoutFeedbackHandler };
@@ -0,0 +1,13 @@
1
+ import { DomainEvent } from "@lookiero/messaging";
2
+ declare const CHECKOUT_FEEDBACK_GIVEN = "checkout_feedback_given";
3
+ interface CheckoutFeedbackGivenPayload {
4
+ readonly aggregateId: string;
5
+ }
6
+ interface CheckoutFeedbackGiven extends DomainEvent<typeof CHECKOUT_FEEDBACK_GIVEN>, CheckoutFeedbackGivenPayload {
7
+ }
8
+ interface CheckoutFeedbackGivenFunction {
9
+ (payload: CheckoutFeedbackGivenPayload): CheckoutFeedbackGiven;
10
+ }
11
+ declare const checkoutFeedbackGiven: CheckoutFeedbackGivenFunction;
12
+ export type { CheckoutFeedbackGiven };
13
+ export { CHECKOUT_FEEDBACK_GIVEN, checkoutFeedbackGiven };
@@ -0,0 +1,4 @@
1
+ import { domainEvent } from "@lookiero/messaging";
2
+ const CHECKOUT_FEEDBACK_GIVEN = "checkout_feedback_given";
3
+ const checkoutFeedbackGiven = ({ aggregateId }) => domainEvent({ aggregateId, name: CHECKOUT_FEEDBACK_GIVEN });
4
+ export { CHECKOUT_FEEDBACK_GIVEN, checkoutFeedbackGiven };
@@ -0,0 +1,7 @@
1
+ import { RepositoryGetFunction, RepositoryGetFunctionArgs, RepositorySaveFunction, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedback } from "./checkoutFeedback";
3
+ interface CheckoutFeedbacksGetFunction<CheckoutFeedbacksGetFunctionArgs extends RepositoryGetFunctionArgs> extends RepositoryGetFunction<CheckoutFeedback, CheckoutFeedbacksGetFunctionArgs> {
4
+ }
5
+ interface CheckoutFeedbacksSaveFunction<CheckoutFeedbacksSaveFunctionArgs extends RepositorySaveFunctionArgs> extends RepositorySaveFunction<CheckoutFeedback, CheckoutFeedbacksSaveFunctionArgs> {
6
+ }
7
+ export type { CheckoutFeedbacksGetFunction, CheckoutFeedbacksSaveFunction };
@@ -0,0 +1,3 @@
1
+ type CheckoutQuestionId = string;
2
+ type Feedbacks = Record<CheckoutQuestionId, CheckoutQuestionId | string>;
3
+ export type { Feedbacks };
@@ -0,0 +1,16 @@
1
+ import { RepositoryGetFunctionArgs, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedbacksGetFunction, CheckoutFeedbacksSaveFunction } from "../../../../domain/checkoutFeedback/model/checkoutFeedbacks";
3
+ import { HttpPostFunction } from "../../../delivery/http/httpClient";
4
+ interface HttpCheckoutFeedbacksGetFunctionArgs extends RepositoryGetFunctionArgs {
5
+ }
6
+ interface HttpCheckoutFeedbacksGetFunction extends CheckoutFeedbacksGetFunction<HttpCheckoutFeedbacksGetFunctionArgs> {
7
+ }
8
+ declare const getCheckoutFeedback: HttpCheckoutFeedbacksGetFunction;
9
+ interface HttpCheckoutFeedbacksSaveFunctionArgs extends RepositorySaveFunctionArgs {
10
+ readonly httpPost: HttpPostFunction;
11
+ }
12
+ interface HttpCheckoutFeedbacksSaveFunction extends CheckoutFeedbacksSaveFunction<HttpCheckoutFeedbacksSaveFunctionArgs> {
13
+ }
14
+ declare const saveCheckoutFeedback: HttpCheckoutFeedbacksSaveFunction;
15
+ export type { HttpCheckoutFeedbacksSaveFunction };
16
+ export { getCheckoutFeedback, saveCheckoutFeedback };
@@ -0,0 +1,14 @@
1
+ import invariant from "tiny-invariant";
2
+ import { viewCheckoutFeedbackById, } from "../../../../projection/checkoutFeedback/viewCheckoutFeedbackById";
3
+ import { httpCheckoutFeedbacksGive } from "./httpCheckoutFeedbacksGive";
4
+ const toDomain = (checkoutFeedback) => {
5
+ invariant(checkoutFeedback, "Not checkoutFeedback found!");
6
+ return {
7
+ aggregateId: checkoutFeedback.id,
8
+ feedbacks: checkoutFeedback.feedbacks,
9
+ domainEvents: [],
10
+ };
11
+ };
12
+ const getCheckoutFeedback = ({ queryBus }) => async (aggregateId) => toDomain(await queryBus(viewCheckoutFeedbackById({ checkoutFeedbackId: aggregateId })));
13
+ const saveCheckoutFeedback = ({ httpPost }) => async (aggregateRoot) => await httpCheckoutFeedbacksGive({ httpPost })(aggregateRoot);
14
+ export { getCheckoutFeedback, saveCheckoutFeedback };
@@ -0,0 +1,5 @@
1
+ import { HttpCheckoutFeedbacksSaveFunction } from "./httpCheckoutFeedbacks";
2
+ interface HttpCheckoutFeedbackGiveFunction extends HttpCheckoutFeedbacksSaveFunction {
3
+ }
4
+ declare const httpCheckoutFeedbacksGive: HttpCheckoutFeedbackGiveFunction;
5
+ export { httpCheckoutFeedbacksGive };
@@ -0,0 +1,13 @@
1
+ import { CHECKOUT_FEEDBACK_GIVEN, } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
2
+ const isCheckoutFeedbackGiven = (event) => event.name === CHECKOUT_FEEDBACK_GIVEN;
3
+ const httpCheckoutFeedbacksGive = ({ httpPost }) => async ({ aggregateId, feedbacks, domainEvents }) => {
4
+ const checkoutFeedbackGiven = domainEvents.find(isCheckoutFeedbackGiven);
5
+ if (!checkoutFeedbackGiven) {
6
+ return;
7
+ }
8
+ await httpPost({
9
+ endpoint: "/give-checkout-feedback",
10
+ body: { checkoutId: aggregateId, feedbacks },
11
+ });
12
+ };
13
+ export { httpCheckoutFeedbacksGive };
@@ -0,0 +1,17 @@
1
+ import { CommandStatus } from "@lookiero/messaging-react";
2
+ import { Feedbacks } from "../../../../domain/checkoutFeedback/model/feedbacks";
3
+ interface GiveCheckoutFeedbackFunctionArgs {
4
+ readonly feedbacks: Feedbacks;
5
+ }
6
+ interface GiveCheckoutFeedbackFunction {
7
+ (args: GiveCheckoutFeedbackFunctionArgs): Promise<void>;
8
+ }
9
+ type UseGiveCheckoutFeedback = [giveCheckoutFeedback: GiveCheckoutFeedbackFunction, status: CommandStatus];
10
+ interface UseGiveCheckoutFeedbackFunctionArgs {
11
+ readonly checkoutId: string;
12
+ }
13
+ interface UseGiveCheckoutFeedbackFunction {
14
+ (args: UseGiveCheckoutFeedbackFunctionArgs): UseGiveCheckoutFeedback;
15
+ }
16
+ declare const useGiveCheckoutFeedback: UseGiveCheckoutFeedbackFunction;
17
+ export { useGiveCheckoutFeedback };
@@ -0,0 +1,13 @@
1
+ import { useCommand } from "@lookiero/messaging-react";
2
+ import { useCallback } from "react";
3
+ import { giveCheckoutFeedback as giveCheckoutFeedbackCommand } from "../../../../domain/checkoutFeedback/command/giveCheckoutFeedback";
4
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
+ const useGiveCheckoutFeedback = ({ checkoutId }) => {
6
+ const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
7
+ const giveCheckoutFeedback = useCallback(({ feedbacks }) => commandBus(giveCheckoutFeedbackCommand({
8
+ aggregateId: checkoutId,
9
+ feedbacks,
10
+ })), [checkoutId, commandBus]);
11
+ return [giveCheckoutFeedback, status];
12
+ };
13
+ export { useGiveCheckoutFeedback };
@@ -0,0 +1,12 @@
1
+ import { CheckoutFeedbackByIdView } from "../../../projection/checkoutFeedback/viewCheckoutFeedbackById";
2
+ import { HttpPostFunction } from "../../delivery/http/httpClient";
3
+ interface HttpCheckoutFeebackByIdView extends CheckoutFeedbackByIdView {
4
+ }
5
+ interface HttpCheckoutFeebackByIdViewFunctionArgs {
6
+ readonly httpPost: HttpPostFunction;
7
+ }
8
+ interface HttpCheckoutFeebackByIdViewFunction {
9
+ (args: HttpCheckoutFeebackByIdViewFunctionArgs): HttpCheckoutFeebackByIdView;
10
+ }
11
+ declare const httpCheckoutFeebackByIdView: HttpCheckoutFeebackByIdViewFunction;
12
+ export { httpCheckoutFeebackByIdView };
@@ -0,0 +1,9 @@
1
+ const httpCheckoutFeebackByIdView = ({ httpPost }) => async ({ checkoutFeedbackId, signal }) => {
2
+ const response = await httpPost({
3
+ endpoint: "/view-checkout-feedback-by-id",
4
+ body: { checkoutFeedbackId },
5
+ signal,
6
+ });
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
+ };
9
+ export { httpCheckoutFeebackByIdView };
@@ -0,0 +1,6 @@
1
+ import { FeedbackProjection } from "./feedback";
2
+ interface CheckoutFeedbackProjection {
3
+ readonly id: string;
4
+ readonly feedbacks: FeedbackProjection;
5
+ }
6
+ export type { CheckoutFeedbackProjection };
@@ -0,0 +1,3 @@
1
+ type CheckoutQuestionId = string;
2
+ type FeedbackProjection = Record<CheckoutQuestionId, CheckoutQuestionId | string>;
3
+ export type { FeedbackProjection };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutFeedbackProjection } from "./checkoutFeedback";
3
+ declare const VIEW_CHECKOUT_FEEDBACK_BY_ID = "view_checkout_feedback_by_id";
4
+ interface ViewCheckoutFeedbackByIdPayload {
5
+ readonly checkoutFeedbackId: string;
6
+ }
7
+ interface ViewCheckoutFeedbackById extends Query<typeof VIEW_CHECKOUT_FEEDBACK_BY_ID>, ViewCheckoutFeedbackByIdPayload {
8
+ }
9
+ interface ViewCheckoutFeedbackByIdFunction {
10
+ (payload: ViewCheckoutFeedbackByIdPayload): ViewCheckoutFeedbackById;
11
+ }
12
+ declare const viewCheckoutFeedbackById: ViewCheckoutFeedbackByIdFunction;
13
+ type ViewCheckoutFeedbackByIdResult = CheckoutFeedbackProjection | null;
14
+ interface CheckoutFeedbackByIdViewArgs extends CancelableQueryViewArgs {
15
+ readonly checkoutFeedbackId: string;
16
+ }
17
+ interface CheckoutFeedbackByIdView {
18
+ (args: CheckoutFeedbackByIdViewArgs): Promise<ViewCheckoutFeedbackByIdResult>;
19
+ }
20
+ interface ViewCheckoutFeedbackByIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
+ readonly view: CheckoutFeedbackByIdView;
22
+ }
23
+ declare const viewCheckoutFeedbackByIdHandler: QueryHandlerFunction<ViewCheckoutFeedbackById, ViewCheckoutFeedbackByIdResult, ViewCheckoutFeedbackByIdHandlerFunctionArgs>;
24
+ export type { ViewCheckoutFeedbackById, CheckoutFeedbackByIdView, ViewCheckoutFeedbackByIdResult };
25
+ export { VIEW_CHECKOUT_FEEDBACK_BY_ID, viewCheckoutFeedbackById, viewCheckoutFeedbackByIdHandler };
@@ -0,0 +1,8 @@
1
+ import { query, } from "@lookiero/messaging";
2
+ const VIEW_CHECKOUT_FEEDBACK_BY_ID = "view_checkout_feedback_by_id";
3
+ const viewCheckoutFeedbackById = (payload) => ({
4
+ ...query({ name: VIEW_CHECKOUT_FEEDBACK_BY_ID }),
5
+ ...payload,
6
+ });
7
+ const viewCheckoutFeedbackByIdHandler = ({ view, signal }) => async ({ checkoutFeedbackId }) => view({ checkoutFeedbackId, signal });
8
+ export { VIEW_CHECKOUT_FEEDBACK_BY_ID, viewCheckoutFeedbackById, viewCheckoutFeedbackByIdHandler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.18",
3
+ "version": "0.3.19",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [