-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename functions, create service for fulfillment
- Loading branch information
1 parent
019be81
commit 5b5bf1f
Showing
13 changed files
with
140 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
49 changes: 49 additions & 0 deletions
49
packages/infrastructure/src/public/saleor/fulfillment/grapqhql/mutations/generated.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type * as Types from '@nimara/codegen/schema'; | ||
|
||
import type { DocumentTypeDecoration } from '@graphql-typed-document-node/core'; | ||
export type FulfillmentReturnProducts_orderFulfillmentReturnProducts_FulfillmentReturnProducts_returnFulfillment_Fulfillment = { status: Types.FulfillmentStatus }; | ||
|
||
export type FulfillmentReturnProducts_orderFulfillmentReturnProducts_FulfillmentReturnProducts_errors_OrderError = { field: string | null, message: string | null, code: Types.OrderErrorCode }; | ||
|
||
export type FulfillmentReturnProducts_orderFulfillmentReturnProducts_FulfillmentReturnProducts = { returnFulfillment: FulfillmentReturnProducts_orderFulfillmentReturnProducts_FulfillmentReturnProducts_returnFulfillment_Fulfillment | null, errors: Array<FulfillmentReturnProducts_orderFulfillmentReturnProducts_FulfillmentReturnProducts_errors_OrderError> }; | ||
|
||
export type FulfillmentReturnProducts_Mutation = { orderFulfillmentReturnProducts: FulfillmentReturnProducts_orderFulfillmentReturnProducts_FulfillmentReturnProducts | null }; | ||
|
||
|
||
export type FulfillmentReturnProductsVariables = Types.Exact<{ | ||
order: Types.Scalars['ID']['input']; | ||
input: Types.OrderReturnProductsInput; | ||
}>; | ||
|
||
|
||
export type FulfillmentReturnProducts = FulfillmentReturnProducts_Mutation; | ||
|
||
export class TypedDocumentString<TResult, TVariables> | ||
extends String | ||
implements DocumentTypeDecoration<TResult, TVariables> | ||
{ | ||
__apiType?: DocumentTypeDecoration<TResult, TVariables>['__apiType']; | ||
|
||
constructor(private value: string, public __meta__?: Record<string, any>) { | ||
super(value); | ||
} | ||
|
||
toString(): string & DocumentTypeDecoration<TResult, TVariables> { | ||
return this.value; | ||
} | ||
} | ||
|
||
export const FulfillmentReturnProductsDocument = new TypedDocumentString(` | ||
mutation FulfillmentReturnProducts($order: ID!, $input: OrderReturnProductsInput!) { | ||
orderFulfillmentReturnProducts(order: $order, input: $input) { | ||
returnFulfillment { | ||
status | ||
} | ||
errors { | ||
field | ||
message | ||
code | ||
} | ||
} | ||
} | ||
`) as unknown as TypedDocumentString<FulfillmentReturnProducts, FulfillmentReturnProductsVariables>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/infrastructure/src/public/saleor/fulfillment/service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { fulfillmentReturnProductsUseCase } from "#root/use-cases/fulfillment/fulfillment-return-products-use-case"; | ||
|
||
import { saleorFulfillmentReturnProductsInfra } from "../fulfillment/infrastructure/fulfillment-return-products-infra"; | ||
import type { | ||
FulfillmentService, | ||
SaleorFulfillmentServiceConfig, | ||
} from "./types"; | ||
|
||
export const saleorFulfillmentService: FulfillmentService< | ||
SaleorFulfillmentServiceConfig | ||
> = (serviceConfig) => ({ | ||
fulfillmentReturnProducts: fulfillmentReturnProductsUseCase({ | ||
fulfillmentReturnProducts: | ||
saleorFulfillmentReturnProductsInfra(serviceConfig), | ||
}), | ||
}); |
36 changes: 36 additions & 0 deletions
36
packages/infrastructure/src/public/saleor/fulfillment/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { BaseError } from "@nimara/domain/objects/Error"; | ||
|
||
export type FulfillmentReturnProductsOptions = { | ||
input: { | ||
orderLines: { | ||
orderLineId: string; | ||
quantity: number; | ||
}[]; | ||
}; | ||
order: string; | ||
}; | ||
|
||
export type FulfillmentReturnProductsInfra = ( | ||
opts: FulfillmentReturnProductsOptions, | ||
) => Promise< | ||
| { isSuccess: true } | ||
| { isSuccess: false } | ||
| { | ||
isSuccess: false; | ||
serverError: BaseError; | ||
} | ||
| { | ||
isSuccess: false; | ||
validationErrors: { code: string; field: string | null }[]; | ||
} | ||
>; | ||
export type FulfillmentReturnProductsUseCase = FulfillmentReturnProductsInfra; | ||
|
||
export type SaleorFulfillmentServiceConfig = { | ||
apiURL: string; | ||
appToken: string; | ||
}; | ||
|
||
export type FulfillmentService<Config> = (config: Config) => { | ||
fulfillmentReturnProducts: FulfillmentReturnProductsInfra; | ||
}; |
15 changes: 0 additions & 15 deletions
15
packages/infrastructure/src/use-cases/checkout/order-return-products-use-case.ts
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
packages/infrastructure/src/use-cases/fulfillment/fulfillment-return-products-use-case.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { | ||
FulfillmentReturnProductsInfra, | ||
FulfillmentReturnProductsOptions, | ||
FulfillmentReturnProductsUseCase, | ||
} from "#root/public/saleor/fulfillment/types"; | ||
|
||
export const fulfillmentReturnProductsUseCase = | ||
({ | ||
fulfillmentReturnProducts, | ||
}: { | ||
fulfillmentReturnProducts: FulfillmentReturnProductsInfra; | ||
}): FulfillmentReturnProductsUseCase => | ||
async (opts: FulfillmentReturnProductsOptions) => { | ||
return fulfillmentReturnProducts(opts); | ||
}; |