Skip to content

Commit

Permalink
feat: update resources to schema v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Jan 23, 2024
1 parent a597c75 commit 686e24a
Show file tree
Hide file tree
Showing 19 changed files with 5,427 additions and 5,692 deletions.
10,843 changes: 5,318 additions & 5,525 deletions gen/openapi.json

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions gen/schema.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable no-console */
import { readFileSync, writeFileSync } from 'fs'
import { snakeCase } from 'lodash'
import axios from 'axios'
import { resolve } from 'path'
import { sortObjectFields } from '../src/util'
import { inspect } from 'util'


// eslint-disable-next-line @typescript-eslint/no-var-requires
const Inflector = require('inflector-js')


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@types/jest": "^29.5.11",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.5",
"dotenv": "^16.3.1",
"dotenv": "^16.3.2",
"eslint": "^8.56.0",
"inflector-js": "^1.0.1",
"jest": "^29.7.0",
Expand Down
178 changes: 89 additions & 89 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions specs/resource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ describe('SDK:resource suite', () => {


it('resource.create', async () => {
const user_email = '[email protected]-role'
const user_email = '[email protected]'
const org = (await clp.organizations.list()).first()
const role = (await clp.roles.list()).first()
if (!org || !role) return
if (!org || !role) throw new Error('Missing role or organization')
const ms = await clp.memberships.create({
user_email,
organization: clp.organizations.relationship(org),
Expand Down
2 changes: 1 addition & 1 deletion specs/resources/api_credentials.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
* Source code generated automatically by SDK codegen
**/

Expand Down
24 changes: 1 addition & 23 deletions specs/resources/application_memberships.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
* Source code generated automatically by SDK codegen
**/

Expand Down Expand Up @@ -27,7 +27,6 @@ describe('ApplicationMemberships resource', () => {
const createAttributes = {
api_credential: clp.api_credentials.relationship(TestData.id),
membership: clp.memberships.relationship(TestData.id),
user: clp.user.relationship(TestData.id),
organization: clp.organizations.relationship(TestData.id),
role: clp.roles.relationship(TestData.id),
}
Expand Down Expand Up @@ -241,27 +240,6 @@ describe('ApplicationMemberships resource', () => {
/* relationship.membership stop */


/* relationship.user start */
it(resourceType + '.user', async () => {

const id = TestData.id
const params = { fields: { user: CommonData.paramsFields } }

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('get')
checkCommon(config, resourceType, id, currentAccessToken, 'user')
checkCommonParams(config, params)
return interceptRequest()
})

await clp[resourceType].user(id, params, CommonData.options)
.catch(handleError)
.finally(() => clp.removeInterceptor('request', intId))

})
/* relationship.user stop */


/* relationship.organization start */
it(resourceType + '.organization', async () => {

Expand Down
23 changes: 1 addition & 22 deletions specs/resources/memberships.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
* Source code generated automatically by SDK codegen
**/

Expand Down Expand Up @@ -261,27 +261,6 @@ describe('Memberships resource', () => {
/* relationship.application_memberships stop */


/* relationship.user start */
it(resourceType + '.user', async () => {

const id = TestData.id
const params = { fields: { user: CommonData.paramsFields } }

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('get')
checkCommon(config, resourceType, id, currentAccessToken, 'user')
checkCommonParams(config, params)
return interceptRequest()
})

await clp[resourceType].user(id, params, CommonData.options)
.catch(handleError)
.finally(() => clp.removeInterceptor('request', intId))

})
/* relationship.user stop */


/* relationship.versions start */
it(resourceType + '.versions', async () => {

Expand Down
2 changes: 1 addition & 1 deletion specs/resources/organizations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
* Source code generated automatically by SDK codegen
**/

Expand Down
2 changes: 1 addition & 1 deletion specs/resources/permissions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
* Source code generated automatically by SDK codegen
**/

Expand Down
2 changes: 1 addition & 1 deletion specs/resources/roles.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
* Source code generated automatically by SDK codegen
**/

Expand Down
2 changes: 1 addition & 1 deletion specs/resources/user.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
* Source code generated automatically by SDK codegen
**/

Expand Down
2 changes: 1 addition & 1 deletion specs/resources/versions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
* Source code generated automatically by SDK codegen
**/

Expand Down
7 changes: 6 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@








'user'

'user'
Expand All @@ -26,7 +31,7 @@ import type { VersionType } from './resources/versions'
// ##__API_RESOURCES_START__##
// ##__API_RESOURCES_TEMPLATE:: export { default as ##__RESOURCE_CLASS__## } from './resources/##__RESOURCE_TYPE__##'
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
**/
export { default as ApiCredentials } from './resources/api_credentials'
export { default as ApplicationMemberships } from './resources/application_memberships'
Expand Down
2 changes: 1 addition & 1 deletion src/commercelayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const debug = Debug('commercelayer')


// Autogenerated schema version number, do not remove this line
const OPEN_API_SCHEMA_VERSION = '1.0.0'
const OPEN_API_SCHEMA_VERSION = '1.0.1'
export { OPEN_API_SCHEMA_VERSION }


Expand Down
2 changes: 1 addition & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ##__MODEL_TYPES_START__##
// ##__MODEL_TYPES_TEMPLATE:: export type { ##__RESOURCE_MODELS__## } from './resources/##__RESOURCE_TYPE__##'
/**
* ©2023 Commerce Layer Inc.
* ©2024 Commerce Layer Inc.
**/
export type { ApiCredential, ApiCredentialCreate, ApiCredentialUpdate } from './resources/api_credentials'
export type { ApplicationMembership, ApplicationMembershipCreate, ApplicationMembershipUpdate } from './resources/application_memberships'
Expand Down
9 changes: 0 additions & 9 deletions src/resources/application_memberships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { QueryParamsRetrieve } from '../query'

import type { ApiCredential, ApiCredentialType } from './api_credentials'
import type { Membership, MembershipType } from './memberships'
import type { User, UserType } from './user'
import type { Organization, OrganizationType } from './organizations'
import type { Role, RoleType } from './roles'

Expand All @@ -13,7 +12,6 @@ type ApplicationMembershipType = 'application_memberships'
type ApplicationMembershipRel = ResourceRel & { type: ApplicationMembershipType }
type ApiCredentialRel = ResourceRel & { type: ApiCredentialType }
type MembershipRel = ResourceRel & { type: MembershipType }
type UserRel = ResourceRel & { type: UserType }
type OrganizationRel = ResourceRel & { type: OrganizationType }
type RoleRel = ResourceRel & { type: RoleType }

Expand All @@ -26,7 +24,6 @@ interface ApplicationMembership extends Resource {

api_credential?: ApiCredential | null
membership?: Membership | null
user?: User | null
organization?: Organization | null
role?: Role | null

Expand All @@ -39,7 +36,6 @@ interface ApplicationMembershipCreate extends ResourceCreate {

api_credential: ApiCredentialRel
membership: MembershipRel
user: UserRel
organization: OrganizationRel
role: RoleRel

Expand Down Expand Up @@ -81,11 +77,6 @@ class ApplicationMemberships extends ApiResource<ApplicationMembership> {
return this.resources.fetch<Membership>({ type: 'memberships' }, `application_memberships/${_applicationMembershipId}/membership`, params, options) as unknown as Membership
}

async user(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<User> {
const _applicationMembershipId = (applicationMembershipId as ApplicationMembership).id || applicationMembershipId as string
return this.resources.fetch<User>({ type: 'user' }, `application_memberships/${_applicationMembershipId}/user`, params, options) as unknown as User
}

async organization(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Organization> {
const _applicationMembershipId = (applicationMembershipId as ApplicationMembership).id || applicationMembershipId as string
return this.resources.fetch<Organization>({ type: 'organizations' }, `application_memberships/${_applicationMembershipId}/organization`, params, options) as unknown as Organization
Expand Down
7 changes: 0 additions & 7 deletions src/resources/memberships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { QueryParamsRetrieve, QueryParamsList } from '../query'
import type { Organization, OrganizationType } from './organizations'
import type { Role, RoleType } from './roles'
import type { ApplicationMembership, ApplicationMembershipType } from './application_memberships'
import type { User } from './user'
import type { Version } from './versions'


Expand All @@ -29,7 +28,6 @@ interface Membership extends Resource {
organization?: Organization | null
role?: Role | null
application_memberships?: ApplicationMembership[] | null
user?: User | null
versions?: Version[] | null

}
Expand Down Expand Up @@ -90,11 +88,6 @@ class Memberships extends ApiResource<Membership> {
return this.resources.fetch<ApplicationMembership>({ type: 'application_memberships' }, `memberships/${_membershipId}/application_memberships`, params, options) as unknown as ListResponse<ApplicationMembership>
}

async user(membershipId: string | Membership, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<User> {
const _membershipId = (membershipId as Membership).id || membershipId as string
return this.resources.fetch<User>({ type: 'user' }, `memberships/${_membershipId}/user`, params, options) as unknown as User
}

async versions(membershipId: string | Membership, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>> {
const _membershipId = (membershipId as Membership).id || membershipId as string
return this.resources.fetch<Version>({ type: 'versions' }, `memberships/${_membershipId}/versions`, params, options) as unknown as ListResponse<Version>
Expand Down
2 changes: 1 addition & 1 deletion src/resources/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ interface Organization extends Resource {
acceptance_disabled?: boolean | null
max_concurrent_promotions: number
max_concurrent_imports: number
associated_markets: Record<string, any>
region?: string | null
can_switch_live: boolean
subscription_totals: Record<string, any>

memberships?: Membership[] | null
roles?: Role[] | null
Expand Down

0 comments on commit 686e24a

Please sign in to comment.