-
Notifications
You must be signed in to change notification settings - Fork 0
Beta #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Beta #160
Changes from 23 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
9c050b5
feat: v3 of salable api added
avst-perrygeorge aba2bfe
fix: created more global stripe and salable data to stop the test ove…
avst-perrygeorge a72d4e1
feat: wip v3 removed Salable class for initSalable function
avst-perrygeorge e8d5288
fix: removed clean up from tests
avst-perrygeorge 06eaab8
refactor: removed init methods which are no longer needed
avst-perrygeorge 887e8da
feat: entitlements method
avst-perrygeorge 1b354ba
fix: fixed imports
avst-perrygeorge 3922be1
refactor: removed /v2/schemas-v2.ts
avst-perrygeorge b6ff867
fix: moved v2 schemas into a single file
avst-perrygeorge 06eae2d
refactor: updated prisma schema with deprecated fields
avst-perrygeorge a36548f
refactor: debugging console logs
avst-perrygeorge 261b92e
refactor: debugging console logs
avst-perrygeorge c12f20d
docs: updated README.md
avst-perrygeorge 3fcfdc7
refactor: updated wrong docs links
avst-perrygeorge 22c9a98
test: added paid tests for per seat add/remove
avst-perrygeorge 37e3357
feat: paginate features and plans endpoints
avst-perrygeorge 7e9af6f
feat: cursor pagination on products endpoint
avst-perrygeorge 2b143a0
test: updated feature schema to include featureEnumOptions
avst-perrygeorge 93ae581
test: removed unused mock data files
avst-perrygeorge d74d2fe
chore(release): 5.0.0-beta.1 [skip ci]
semantic-release-bot 273b14d
fix: updated EntitlementsCheck return type
avst-perrygeorge e2a084f
Merge pull request #159 from Salable/fix/v3-types
avst-perrygeorge 7126730
chore(release): 5.0.0-beta.2 [skip ci]
semantic-release-bot 9a88a47
docs: updated changelog for v5.0.0
avst-perrygeorge 8aae55e
docs: added notice for add and remove seats in changelog
avst-perrygeorge e495ae4
test: updated pricing table tests to create the UUID in the test itself
avst-perrygeorge d17f0f2
Merge pull request #161 from Salable/docs/v3-changelog
avst-perrygeorge d9c606f
docs: updates to inconsistencies in the documentation
avst-perrygeorge bb9aec1
refactor: commitlint remove body-max-line-length rule
avst-perrygeorge 49563a4
refactor: added array value to commitlint rule
avst-perrygeorge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import objectBuilder from './object-builder'; | ||
|
|
||
| // deprecated | ||
| export const mockCapability = objectBuilder({ | ||
| name: 'test_capability', | ||
| status: 'ACTIVE', | ||
| description: 'Capability description', | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { CouponDuration, CouponStatus, DiscountType } from '@prisma/client'; | ||
| import objectBuilder from './object-builder'; | ||
|
|
||
| export const mockCoupon = objectBuilder({ | ||
| status: 'ACTIVE' as CouponStatus, | ||
| createdAt: new Date(), | ||
| updatedAt: new Date(), | ||
| name: 'Percentage Coupon', | ||
| duration: 'ONCE' as CouponDuration, | ||
| discountType: 'PERCENTAGE' as DiscountType, | ||
| paymentIntegrationCouponId: 'test-payment-integration-id', | ||
| percentOff: 10, | ||
| expiresAt: null, | ||
| maxRedemptions: null, | ||
| isTest: false, | ||
| durationInMonths: 1, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import objectBuilder from './object-builder'; | ||
|
|
||
| export const mockCurrency = objectBuilder({ | ||
| shortName: 'XXX', | ||
| longName: 'Mock Currency', | ||
| symbol: '@', | ||
| }); | ||
|
|
||
| export const mockProductCurrency = objectBuilder({ | ||
| defaultCurrency: true, | ||
| }); | ||
|
|
||
| export const mockPlanCurrency = objectBuilder({ | ||
| price: 500, | ||
| paymentIntegrationPlanId: 'test-payment-integration-id', | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import objectBuilder from './object-builder'; | ||
| import { EventStatus } from '@prisma/client'; | ||
| import { EventType } from '../lib/constants'; | ||
|
|
||
| export const mockSalableEvent = objectBuilder({ | ||
| type: EventType.CreateSeats, | ||
| organisation: 'xxxxx', | ||
| status: EventStatus.pending as EventStatus, | ||
| isTest: false, | ||
| retries: 0, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import objectBuilder from './object-builder'; | ||
|
|
||
| export const mockFeature = objectBuilder({ | ||
| name: 'Boolean Feature Name', | ||
| description: 'Feature description', | ||
| displayName: 'Boolean Feature Display Name', | ||
| variableName: 'boolean_feature', | ||
| status: 'ACTIVE', | ||
| visibility: 'public', | ||
| valueType: 'boolean', | ||
| defaultValue: 'false', | ||
| showUnlimited: false, | ||
| sortOrder: 0, | ||
| }); | ||
|
|
||
| export const mockPlanFeature = objectBuilder({ | ||
| value: 'xxxxx', | ||
| isUnlimited: undefined as boolean | undefined, | ||
| isUsage: undefined as boolean | undefined, // deprecated | ||
| pricePerUnit: 10, // deprecated | ||
| minUsage: 1, // deprecated | ||
| maxUsage: 100, // deprecated | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { LicensesUsageRecordType, Prisma } from '@prisma/client'; | ||
| import objectBuilder from './object-builder'; | ||
|
|
||
| // deprecated | ||
| export const mockLicenseCapability = objectBuilder({ | ||
| name: 'Export', | ||
| uuid: '38e63e2a-1269-4e9d-b712-28cfbf087285', | ||
| status: 'ACTIVE', | ||
| updatedAt: '2022-10-17T11:41:11.626Z', | ||
| description: null as string | null, | ||
| productUuid: 'c32f26e4-21d9-4456-a1f0-7e76039af518', | ||
| }); | ||
|
|
||
| export const mockLicenseUsageRecord = objectBuilder({ | ||
| unitCount: 0, | ||
| type: 'current' as LicensesUsageRecordType, | ||
| resetAt: null as Date | null, | ||
| recordedAt: null as Date | null, | ||
| }); | ||
|
|
||
| export const mockLicense = objectBuilder({ | ||
| name: null as string | null, | ||
| email: null as string | null, | ||
| status: 'ACTIVE', | ||
| granteeId: '123456' as string | null, | ||
| paymentService: 'ad-hoc', | ||
| purchaser: 'tester@testing.com', | ||
| type: 'licensed', | ||
| metadata: undefined as undefined | { member: string; granteeId: string }, | ||
| capabilities: [ | ||
| mockLicenseCapability({ name: 'CapabilityOne' }), | ||
| mockLicenseCapability({ name: 'CapabilityTwo' }), | ||
| ] as Prisma.InputJsonObject[], // deprecated | ||
| startTime: undefined as undefined | Date, | ||
| endTime: new Date(), | ||
| cancelAtPeriodEnd: false, | ||
| isTest: false, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T; | ||
|
|
||
| function isObject(obj?: unknown): obj is object { | ||
| return Boolean(obj) && (obj as object)?.constructor === Object; | ||
| } | ||
|
|
||
| function merge(target: Record<string, unknown>, source?: Record<string, unknown>) { | ||
| const clone = { ...target } as Record<string, unknown>; | ||
| if (!source) return clone; | ||
| for (const key of Object.keys(source)) { | ||
| if (isObject(source[key])) { | ||
| clone[key] = merge( | ||
| clone[key] as Record<string, unknown>, | ||
| source[key] as Record<string, unknown> | ||
| ); | ||
| } else { | ||
| clone[key] = source[key]; | ||
| } | ||
| } | ||
|
|
||
| return clone; | ||
| } | ||
|
|
||
| export default function objectBuilder<T>(defaultParameters: T) { | ||
| return (overrideParameters?: DeepPartial<T> | null): T => { | ||
| if (!overrideParameters) overrideParameters = {} as DeepPartial<T>; | ||
| return merge( | ||
| defaultParameters as Record<string, unknown>, | ||
| overrideParameters as Record<string, unknown> | ||
| ) as T; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import objectBuilder from './object-builder'; | ||
|
|
||
| export const mockPlan = objectBuilder({ | ||
| name: 'Free Plan Name', // deprecated | ||
| description: 'Free Plan description', | ||
| displayName: 'Free Plan Display Name', | ||
| slug: 'example-slug', | ||
| status: 'ACTIVE', | ||
| trialDays: 0, // deprecated | ||
| evaluation: false, // deprecated | ||
| evalDays: 0, | ||
| organisation: 'xxxxx', | ||
| visibility: 'public', | ||
| licenseType: 'licensed', | ||
| interval: 'month', | ||
| perSeatAmount: 1, | ||
| maxSeatAmount: -1, | ||
| length: 1, | ||
| active: true, // deprecated | ||
| planType: 'Standard', // deprecated | ||
| pricingType: 'free', | ||
| environment: 'dev', // deprecated | ||
| paddlePlanId: null, // deprecated | ||
| isTest: false, | ||
| hasAcceptedTransaction: false, | ||
| archivedAt: null as Date | null, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import objectBuilder from './object-builder'; | ||
|
|
||
| export const mockPricingTable = objectBuilder({ | ||
| name: 'Sample Pricing Table', | ||
| status: 'ACTIVE', | ||
| productUuid: 'xxxxxx', | ||
| featuredPlanUuid: 'xxxxxx', | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import objectBuilder from './object-builder'; | ||
| import { PaymentIntegration, PaymentIntegrationStatus } from '@prisma/client'; | ||
|
|
||
| export const mockProduct = objectBuilder({ | ||
| name: 'Sample Product', | ||
| description: 'This is a sample product for testing purposes', | ||
| logoUrl: 'https://example.com/logo.png', | ||
| displayName: 'Sample Product', | ||
| organisation: 'xxxxx', | ||
| slug: 'example-slug', | ||
| status: 'ACTIVE', | ||
| paid: false, | ||
| appType: 'CUSTOM', // deprecated | ||
| isTest: false, | ||
| archivedAt: null as null | Date, | ||
| }); | ||
|
|
||
| export const mockOrganisationPaymentIntegration = objectBuilder({ | ||
| organisation: 'xxxxx', | ||
| integrationName: 'stripe_existing' as PaymentIntegration, | ||
| accountData: { // deprecated | ||
| key: 'xxxxx', | ||
| encryptedData: 'xoxox', | ||
| }, | ||
| isTest: false, | ||
| accountName: 'Account Name', | ||
| accountId: 'acc_1234', | ||
| status: PaymentIntegrationStatus.active, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import objectBuilder from './object-builder'; | ||
|
|
||
| export const mockSession = objectBuilder({ | ||
| organisationId: 'xxxxx', | ||
| expiresAt: new Date(Date.now() + 10800000), | ||
| value: 'xxxx', | ||
| scope: '', | ||
| isTest: true, | ||
| metadata: {}, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import objectBuilder from './object-builder'; | ||
| import { randomUUID } from 'crypto'; | ||
| import { PaymentIntegration } from '@prisma/client'; | ||
|
|
||
| export const mockSubscription = objectBuilder({ | ||
| type: 'salable' as PaymentIntegration, | ||
| paymentIntegrationSubscriptionId: randomUUID(), | ||
| email: null as string | null, | ||
| owner: 'xxxxx', | ||
| organisation: 'xxxxx', | ||
| status: 'ACTIVE', | ||
| createdAt: new Date(), | ||
| updatedAt: new Date(), | ||
| expiryDate: new Date(Date.now() + 31536000000), | ||
| lineItemIds: ['xxxxx'] as string[] | undefined, | ||
| isTest: false, | ||
| quantity: 1, | ||
| cancelAtPeriodEnd: false, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.