-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83d6429
commit 195cf88
Showing
20 changed files
with
277 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { v4 } from "uuid"; | ||
import { PaymentMethodData, PaymentMethod } from "./types"; | ||
import { setPaymentMethod } from "./set-payment-method"; | ||
|
||
export async function addPaymentMethod(data: PaymentMethodData): Promise<PaymentMethod> { | ||
const paymentMethodId = v4(); | ||
return setPaymentMethod({ | ||
...data, | ||
paymentMethodId, | ||
}); | ||
} |
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,6 @@ | ||
import { getPaymentMethodStore } from "./store"; | ||
|
||
export function getPaymentMethod(id: string) { | ||
const store = getPaymentMethodStore(); | ||
return store.get(id); | ||
} |
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,7 @@ | ||
export * from "./store"; | ||
export * from "./types"; | ||
export * from "./get-payment-method"; | ||
export * from "./list-payment-methods"; | ||
export * from "./add-payment-method"; | ||
export * from "./set-payment-method"; | ||
export * as paymentMethodSchema from "./schema"; |
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,11 @@ | ||
import { PaymentMethod } from "./types"; | ||
import { getPaymentMethodStore } from "./store"; | ||
|
||
export interface ListPaymentMethodsInput {} | ||
|
||
export async function listPaymentMethods({}: ListPaymentMethodsInput = {}): Promise< | ||
PaymentMethod[] | ||
> { | ||
const store = getPaymentMethodStore(); | ||
return store.values(); | ||
} |
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,34 @@ | ||
export const paymentMethodStatus = { | ||
type: "string", | ||
enum: [ | ||
"pending", | ||
"available", | ||
"expired", | ||
"void" | ||
] | ||
} | ||
|
||
export const paymentMethodData = { | ||
type: "object", | ||
properties: { | ||
status: paymentMethodStatus, | ||
}, | ||
required: ["status"], | ||
} as const; | ||
|
||
export const paymentMethod = { | ||
type: "object", | ||
properties: { | ||
paymentMethodId: { | ||
type: "string", | ||
}, | ||
createdAt: { | ||
type: "string", | ||
}, | ||
updatedAt: { | ||
type: "string", | ||
}, | ||
...paymentMethodData.properties, | ||
}, | ||
required: ["paymentMethodId", "createdAt", "updatedAt", ...paymentMethodData.required], | ||
} as const; |
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 { PaymentMethod, PaymentMethodData } from "./types"; | ||
import { getPaymentMethodStore } from "./store"; | ||
|
||
export async function setPaymentMethod( | ||
data: PaymentMethodData & Pick<PaymentMethod, "paymentMethodId"> & Partial<PaymentMethod> | ||
): Promise<PaymentMethod> { | ||
const store = await getPaymentMethodStore(); | ||
const updatedAt = new Date().toISOString(); | ||
const document: PaymentMethod = { | ||
createdAt: data.createdAt || updatedAt, | ||
...data, | ||
updatedAt, | ||
}; | ||
await store.set(data.paymentMethodId, document); | ||
return document; | ||
} |
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,8 @@ | ||
import { getKeyValueStore } from "../kv"; | ||
import { PaymentMethod } from "./types"; | ||
|
||
const STORE_NAME = "paymentMethod" as const; | ||
|
||
export function getPaymentMethodStore() { | ||
return getKeyValueStore<PaymentMethod>(STORE_NAME); | ||
} |
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,11 @@ | ||
export type PaymentMethodStatus = "pending" | "available" | "expired" | "void"; | ||
|
||
export interface PaymentMethodData extends Record<string, unknown> { | ||
status: PaymentMethodStatus; | ||
} | ||
|
||
export interface PaymentMethod extends PaymentMethodData { | ||
paymentMethodId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
} |
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,11 @@ | ||
import { v4 } from "uuid"; | ||
import { PaymentData, Payment } from "./types"; | ||
import { setPayment } from "./set-payment"; | ||
|
||
export async function addPayment(data: PaymentData): Promise<Payment> { | ||
const paymentId = v4(); | ||
return setPayment({ | ||
...data, | ||
paymentId, | ||
}); | ||
} |
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,6 @@ | ||
import { getPaymentStore } from "./store"; | ||
|
||
export function getPayment(id: string) { | ||
const store = getPaymentStore(); | ||
return store.get(id); | ||
} |
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,7 @@ | ||
export * from "./store"; | ||
export * from "./types"; | ||
export * from "./get-payment"; | ||
export * from "./list-payments"; | ||
export * from "./add-payment"; | ||
export * from "./set-payment"; | ||
export * as paymentSchema from "./schema"; |
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,11 @@ | ||
import { Payment } from "./types"; | ||
import { getPaymentStore } from "./store"; | ||
|
||
export interface ListPaymentsInput {} | ||
|
||
export async function listPayments({}: ListPaymentsInput = {}): Promise< | ||
Payment[] | ||
> { | ||
const store = getPaymentStore(); | ||
return store.values(); | ||
} |
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,34 @@ | ||
export const paymentStatus = { | ||
type: "string", | ||
enum: [ | ||
"pending", | ||
"processing", | ||
"paid", | ||
"void" | ||
] | ||
} | ||
|
||
export const paymentData = { | ||
type: "object", | ||
properties: { | ||
status: paymentStatus, | ||
}, | ||
required: ["status"], | ||
} as const; | ||
|
||
export const payment = { | ||
type: "object", | ||
properties: { | ||
paymentId: { | ||
type: "string", | ||
}, | ||
createdAt: { | ||
type: "string", | ||
}, | ||
updatedAt: { | ||
type: "string", | ||
}, | ||
...paymentData.properties, | ||
}, | ||
required: ["paymentId", "createdAt", "updatedAt", ...paymentData.required], | ||
} as const; |
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 { Payment, PaymentData } from "./types"; | ||
import { getPaymentStore } from "./store"; | ||
|
||
export async function setPayment( | ||
data: PaymentData & Pick<Payment, "paymentId"> & Partial<Payment> | ||
): Promise<Payment> { | ||
const store = await getPaymentStore(); | ||
const updatedAt = new Date().toISOString(); | ||
const document: Payment = { | ||
createdAt: data.createdAt || updatedAt, | ||
...data, | ||
updatedAt, | ||
}; | ||
await store.set(data.paymentId, document); | ||
return document; | ||
} |
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,8 @@ | ||
import { getKeyValueStore } from "../kv"; | ||
import { Payment } from "./types"; | ||
|
||
const STORE_NAME = "payment" as const; | ||
|
||
export function getPaymentStore() { | ||
return getKeyValueStore<Payment>(STORE_NAME); | ||
} |
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,13 @@ | ||
export type PaymentStatus = "pending" | "processing" | "paid" | "void"; | ||
|
||
export interface PaymentData extends Record<string, unknown> { | ||
status: PaymentStatus; | ||
paymentMethodId: string; | ||
reference?: string; | ||
} | ||
|
||
export interface Payment extends PaymentData { | ||
paymentId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
} |
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
// File generated by scripts/pre-build.js | ||
|
||
export const commit = "5f4d3f32f71f701d32d53171e27ac0b12b18bdce"; | ||
export const commitShort = "5f4d3f3"; | ||
export const commit = "83d642984e47c8a70000dd4e02e625a18c9bb03f"; | ||
export const commitShort = "83d6429"; | ||
export const commitAuthor = "Fabian Cook"; | ||
export const commitEmail = "[email protected]"; | ||
export const commitMessage = "1.0.0-alpha.24"; | ||
export const commitAt = "2023-06-16T22:48:03.000Z"; | ||
export const secondsBetweenCommitAndBuild = 47576.66; | ||
export const minutesBetweenCommitAndBuild = 792.94; | ||
export const timeBetweenCommitAndBuild = "792 minutes and 56 seconds"; | ||
export const commitMessage = "Order, pick, pack, ship scenario"; | ||
export const commitAt = "2023-06-17T12:02:23.000Z"; | ||
export const secondsBetweenCommitAndBuild = 43435.77; | ||
export const minutesBetweenCommitAndBuild = 723.93; | ||
export const timeBetweenCommitAndBuild = "723 minutes and 55 seconds"; | ||
// Variables to be replaced after tests | ||
export const secondsBetweenCommitAndTestCompletion = "47593.24"; | ||
export const minutesBetweenCommitAndTestCompletion = "793.22"; | ||
export const timeBetweenCommitAndTestCompletion = "793 minutes and 13 seconds"; | ||
export const secondsBetweenCommitAndTestCompletion = ""; | ||
export const minutesBetweenCommitAndTestCompletion = ""; | ||
export const timeBetweenCommitAndTestCompletion = ""; |