feat: Application types generation from project GQL schema's (#8995)
This commit is contained in:
committed by
GitHub
parent
ac30a989f4
commit
2c5e72d141
@@ -1,12 +1,12 @@
|
||||
import { IApiKeyModuleService } from "@medusajs/types"
|
||||
import { ApiKeyType, Module, Modules } from "@medusajs/utils"
|
||||
import { ApiKeyModuleService } from "@services"
|
||||
import crypto from "crypto"
|
||||
import { moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
import {
|
||||
createPublishableKeyFixture,
|
||||
createSecretKeyFixture,
|
||||
} from "../__fixtures__"
|
||||
import { ApiKeyModuleService } from "@services"
|
||||
|
||||
jest.setTimeout(100000)
|
||||
|
||||
@@ -47,7 +47,9 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
|
||||
|
||||
expect(Object.keys(linkable)).toEqual(["apiKey"])
|
||||
|
||||
linkable.apiKey.toJSON = undefined
|
||||
Object.keys(linkable).forEach((key) => {
|
||||
delete linkable[key].toJSON
|
||||
})
|
||||
|
||||
expect(linkable.apiKey).toEqual({
|
||||
id: {
|
||||
@@ -56,6 +58,12 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
|
||||
serviceName: "apiKey",
|
||||
field: "apiKey",
|
||||
},
|
||||
publishable_key_id: {
|
||||
field: "apiKey",
|
||||
linkable: "publishable_key_id",
|
||||
primaryKey: "publishable_key_id",
|
||||
serviceName: "apiKey",
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
8
packages/modules/api-key/src/joiner-config.ts
Normal file
8
packages/modules/api-key/src/joiner-config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
||||
|
||||
export const joinerConfig = defineJoinerConfig(Modules.API_KEY, {
|
||||
linkableKeys: {
|
||||
// Merged with the autogenerated ones to maintain backward compatibility
|
||||
publishable_key_id: "ApiKey",
|
||||
},
|
||||
})
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
FindConfig,
|
||||
IApiKeyModuleService,
|
||||
InternalModuleDeclaration,
|
||||
ModuleJoinerConfig,
|
||||
ModulesSdkTypes,
|
||||
} from "@medusajs/types"
|
||||
import { ApiKey } from "@models"
|
||||
@@ -28,6 +29,7 @@ import {
|
||||
MedusaService,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import { joinerConfig } from "../joiner-config"
|
||||
|
||||
const scrypt = util.promisify(crypto.scrypt)
|
||||
|
||||
@@ -55,6 +57,10 @@ export class ApiKeyModuleService
|
||||
this.apiKeyService_ = apiKeyService
|
||||
}
|
||||
|
||||
__joinerConfig(): ModuleJoinerConfig {
|
||||
return joinerConfig
|
||||
}
|
||||
|
||||
//@ts-expect-error
|
||||
createApiKeys(
|
||||
data: ApiKeyTypes.CreateApiKeyDTO[],
|
||||
|
||||
Reference in New Issue
Block a user