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_"
This commit is contained in:
Frane Polić
2022-11-16 04:35:22 +00:00
committed by GitHub
parent ccfc5f666d
commit 03fc9e18e9
17 changed files with 390 additions and 30 deletions
@@ -3,7 +3,6 @@ import {
MoneyAmount,
PriceListType,
PriceListStatus,
CustomerGroup,
} from "@medusajs/medusa"
import faker from "faker"
import { Connection } from "typeorm"
@@ -1,4 +1,6 @@
import faker from "faker"
import { Connection } from "typeorm"
import { PublishableApiKey } from "@medusajs/medusa"
export type PublishableApiKeyData = {
@@ -6,6 +8,7 @@ export type PublishableApiKeyData = {
revoked_at?: Date
revoked_by?: string
created_by?: string
title?: string
}
export const simplePublishableApiKeyFactory = async (
@@ -14,7 +17,10 @@ export const simplePublishableApiKeyFactory = async (
): Promise<PublishableApiKey> => {
const manager = connection.manager
const pubKey = manager.create(PublishableApiKey, data)
const pubKey = manager.create(PublishableApiKey, {
...data,
title: data.title || `${faker.commerce.department()} API key`,
})
return await manager.save(pubKey)
}