Files
medusa-store/integration-tests/api/factories/simple-publishable-api-key-factory.ts
Frane Polić 03fc9e18e9 feat(medusa, medusa-js, medusa-react): PublishableApiKey "update" endpoint & add "title" property (#2609)
**What**
- update PK endpoint
  - medusa-js/react implementation
- add a title property to the entity
  - update the migration file
  - pass a title on create
  - list PKs by title
  - update the client libs with new param signatures
- change id prefix to: "pk_"
2022-11-16 04:35:22 +00:00

27 lines
619 B
TypeScript

import faker from "faker"
import { Connection } 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 (
connection: Connection,
data: PublishableApiKeyData = {}
): Promise<PublishableApiKey> => {
const manager = connection.manager
const pubKey = manager.create(PublishableApiKey, {
...data,
title: data.title || `${faker.commerce.department()} API key`,
})
return await manager.save(pubKey)
}