-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add initial featurebase integration
TODO: - [x] Allow client integrations to be lazy loaded - [ ] Allow server integrations to be lazy loaded
- Loading branch information
Showing
43 changed files
with
606 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 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
27 changes: 27 additions & 0 deletions
27
apps/client/src/app/integrations/integrations.module.spec.ts
This file contains 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 { test, vitest } from 'vitest'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { IntegrationsModule } from './integrations.module'; | ||
|
||
test('register', async () => { | ||
// @ts-expect-error unnecessary | ||
const integrations = new IntegrationsModule(); | ||
integrations.process = vitest.fn(); | ||
|
||
@NgModule({}) | ||
class TestModule {} | ||
|
||
class TestConfig {} | ||
|
||
const config = new TestConfig(); | ||
|
||
await integrations.register(config, () => TestModule); | ||
|
||
const testBed = TestBed.configureTestingModule({ | ||
imports: [await integrations.configure()], | ||
}); | ||
|
||
const config2 = testBed.inject(TestConfig); | ||
expect(config2).toBe(config); | ||
}); |
This file contains 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 |
---|---|---|
@@ -1,24 +1,37 @@ | ||
import { ClassType } from '@deepkit/core'; | ||
|
||
import { DynamicNgModule, IntegrationsConfig } from '@apex/client'; | ||
import { SupabaseModule } from '@apex/integrations/supabase/client'; | ||
|
||
export class IntegrationsModule extends DynamicNgModule<IntegrationsModule> { | ||
constructor(private readonly config: IntegrationsConfig) { | ||
super(); | ||
} | ||
|
||
private register(config: any, module: ClassType): void { | ||
async register( | ||
config: any, | ||
loadModule: () => Promise<ClassType> | ClassType, | ||
): Promise<void> { | ||
if (config) { | ||
this.addImport(module); | ||
this.addImport(await loadModule()); | ||
this.addProvider({ | ||
provide: config.constructor, | ||
useValue: config, | ||
}); | ||
} | ||
} | ||
|
||
process(): void { | ||
this.register(this.config.supabase, SupabaseModule); | ||
async process(): Promise<void> { | ||
await Promise.all([ | ||
this.register(this.config.supabase, async () => | ||
import('@apex/integrations/supabase/client').then( | ||
m => m.SupabaseModule, | ||
), | ||
), | ||
this.register(this.config.featurebase, async () => | ||
import('@apex/integrations/featurebase/client').then( | ||
m => m.FeaturebaseModule, | ||
), | ||
), | ||
]); | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment | ||
globalThis.ngJest = { | ||
testEnvironmentOptions: { | ||
errorOnUnknownElements: true, | ||
errorOnUnknownProperties: true, | ||
}, | ||
}; | ||
import 'jest-preset-angular/setup-jest'; | ||
import '@analogjs/vite-plugin-angular/setup-vitest'; | ||
import '@testing-library/jest-dom/vitest'; | ||
|
||
/** | ||
* Initialize TestBed for all tests | ||
*/ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting, | ||
} from '@angular/platform-browser-dynamic/testing'; | ||
|
||
TestBed.initTestEnvironment( | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting(), | ||
); |
This file contains 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 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 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 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 |
---|---|---|
@@ -1,25 +1,49 @@ | ||
import { join } from 'path'; | ||
import { join } from 'node:path'; | ||
import { defineConfig } from 'vite'; | ||
import { deepkitType } from '@deepkit/vite'; | ||
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; | ||
import { angular } from '@analogjs/vite-plugin-angular/src/lib/angular-vite-plugin'; | ||
|
||
export default defineConfig({ | ||
optimizeDeps: { | ||
exclude: ['@deepkit/rpc'], | ||
esbuildOptions: { | ||
export default defineConfig(({ mode }) => { | ||
const isTestMode = mode === 'test'; | ||
const tsConfig = isTestMode ? join(__dirname, 'tsconfig.spec.json') : join(__dirname, 'tsconfig.app.json'); | ||
|
||
return { | ||
optimizeDeps: { | ||
exclude: ['@deepkit/rpc'], | ||
esbuildOptions: { | ||
target: 'esnext', | ||
}, | ||
}, | ||
build: { | ||
target: 'esnext', | ||
}, | ||
}, | ||
build: { | ||
target: 'esnext', | ||
}, | ||
plugins: [ | ||
nxViteTsPaths(), | ||
deepkitType({ | ||
compilerOptions: { | ||
sourceMap: true, | ||
plugins: [ | ||
nxViteTsPaths(), | ||
isTestMode && angular({ tsconfig: tsConfig }), | ||
deepkitType({ | ||
compilerOptions: { | ||
sourceMap: true, | ||
}, | ||
tsConfig, | ||
}), | ||
], | ||
test: { | ||
globals: true, | ||
cache: { | ||
dir: '../../node_modules/.vitest', | ||
}, | ||
tsConfig: join(__dirname, 'tsconfig.app.json'), | ||
}), | ||
], | ||
reporters: ['default'], | ||
environment: 'jsdom', | ||
setupFiles: ['src/test-setup.ts'], | ||
include: ['src/**/*.spec.ts'], | ||
deps: { | ||
optimizer: { | ||
web: { | ||
exclude: ['rxjs', '@deepkit/rpc'], | ||
}, | ||
} | ||
}, | ||
}, | ||
}; | ||
}); |
This file contains 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 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 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 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 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 @@ | ||
# [Featurebase](https://featurebase.app) Integration |
This file contains 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,33 @@ | ||
{ | ||
"extends": ["../../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"parserOptions": { | ||
"project": ["libs/integrations/featurebase/client/tsconfig.*?.json"] | ||
}, | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.json"], | ||
"parser": "jsonc-eslint-parser", | ||
"rules": { | ||
"@nx/dependency-checks": [ | ||
"error", | ||
{ | ||
"ignoredFiles": ["{projectRoot}/rollup.config.{js,ts,mjs,mts}"] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains 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 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'integrations-featurebase-client', | ||
preset: '../../../../jest.preset.js', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
testEnvironment: 'node', | ||
coverageDirectory: '../../../../coverage/libs/integrations/featurebase/client', | ||
}; |
Empty file.
Oops, something went wrong.