* chore: Move factories and helpers to a better place * align factory product variant * fix factory cart * add simple store fac * fix tests * fix tests * fix * fix cart seeder
27 lines
619 B
TypeScript
27 lines
619 B
TypeScript
import faker from "faker"
|
|
import { DataSource } from "typeorm"
|
|
|
|
import { PublishableApiKey } from "@medusajs/medusa"
|
|
|
|
export type PublishableApiKeyData = {
|
|
id?: string
|
|
revoked_at?: Date
|
|
revoked_by?: string
|
|
created_by?: string
|
|
title?: string
|
|
}
|
|
|
|
export const simplePublishableApiKeyFactory = async (
|
|
dataSource: DataSource,
|
|
data: PublishableApiKeyData = {}
|
|
): Promise<PublishableApiKey> => {
|
|
const manager = dataSource.manager
|
|
|
|
const pubKey = manager.create(PublishableApiKey, {
|
|
...data,
|
|
title: data.title || `${faker.commerce.department()} API key`,
|
|
})
|
|
|
|
return await manager.save(pubKey)
|
|
}
|