-
Notifications
You must be signed in to change notification settings - Fork 191
Feat: multi-terminology support #2413
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
Open
ItzNotABug
wants to merge
93
commits into
8.x
Choose a base branch
from
multiple-terminologies
base: 8.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,045
−1,980
Open
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit
Hold shift + click to select a range
f6f2d94
feat: multi-terminology support [wip].
ItzNotABug 3fae9d6
update: restructure dirs.
ItzNotABug bc16dea
update: abstracted indexes for base views.
ItzNotABug cd5c781
remove: duplicate components.
ItzNotABug 801eed8
move filters button to right side and fix search placeholder
HarshMN2345 e451f18
Merge branch 'index-suggestions' into 'multiple-terminologies'.
ItzNotABug a3eb1c8
fix: import.
ItzNotABug 5eca86e
update: imports and folder structure.
ItzNotABug aca5241
lint.
ItzNotABug 88a153e
Merge branch 'main' into multiple-terminologies
ItzNotABug d00e280
misc: changes, docs update, svelte5 migration.
ItzNotABug b8a472f
lint issue
HarshMN2345 69d2cd6
removed button and using link in updateTopics
HarshMN2345 5cb9b63
Unnecessary padding above Name input
HarshMN2345 448ab66
Remove unnecessary extra spacing here
HarshMN2345 dbee85e
Read the guide in the docs should open a new tab
HarshMN2345 13c68f0
Add wizard footer with Create button (Currently we have a divider and…
HarshMN2345 a41cfd8
fix subscribers screen
HarshMN2345 8a9efc1
fixed the width of provider popup
HarshMN2345 77b01de
fixed align action menu issue
HarshMN2345 6bfa007
refactor the flow for push notifcations
HarshMN2345 3393329
Fix topics modal target counts based on provider typr
HarshMN2345 71997d2
remove any
HarshMN2345 7410780
Merge branch 'main' into 'multiple-terminologies'.
ItzNotABug 8f5f4c1
simplify.
ItzNotABug 645ae62
update: migrate empty sheet as a reusable component.
ItzNotABug 6cecb2c
lint.
ItzNotABug 4354c90
update: misc, address a todo.
ItzNotABug e87894d
update: make breadcrumbs and header reusable.
ItzNotABug ef7d6d4
update: improved context and terminology sharing.
ItzNotABug d2c2870
lint.
ItzNotABug d5afa9b
remove: leftover log
ItzNotABug 466cc8d
address: todo.
ItzNotABug 31aa0ff
address: todo for `trackError`.
ItzNotABug e1aa598
fixes, stricter params.
ItzNotABug 74e6eae
fixes, stricter params.
ItzNotABug e06980a
fix: `getContext` undefined issue.
ItzNotABug fde78df
improvements
HarshMN2345 95bbe56
update: resizing on indexes.
ItzNotABug 4288215
fix: accessor.
ItzNotABug ce3d0e0
done changes liek replacing anchor with Links and removing bad empty …
HarshMN2345 8ea21ad
lint issue
HarshMN2345 920d4f7
svelte 5 migartion
HarshMN2345 c470fc4
lint error
HarshMN2345 a871810
fix: slash issues on routes causing flawed selection on tabs.
ItzNotABug 470a4e1
Merge branch 'main' into 'multiple-terminologies'.
ItzNotABug 7d7dfab
use: `creatingEntity`.
ItzNotABug 33db74b
clarify effect deps
HarshMN2345 fc78c44
remove: legacy logic.
ItzNotABug 6fef9a2
update: proper type.
ItzNotABug 7f5c0df
replace div with Layout.Stack in popoverContent and inline maxWidth s…
HarshMN2345 4ef68a4
update: migrate.
ItzNotABug 2ce3811
remove: database derived store.
ItzNotABug db8420d
address comments, fix nav bug.
ItzNotABug aea5e82
misc.
ItzNotABug 2abb2bc
address comment with hardcoded paths for `nonSheetPages` checks.
ItzNotABug 9d1f4ce
misc: fixes.
ItzNotABug ea665d7
misc: fixes.
ItzNotABug 8a449d5
update: moreee changes!
ItzNotABug 43eff98
feat: wrapped sdk support.
ItzNotABug e97ef6c
bump: sdk for `DocumentsDB`.
ItzNotABug f0d1a5d
update: sdks side updates.
ItzNotABug f49f888
update: sdks side updates.
ItzNotABug 1f254a6
address comments.
ItzNotABug 604f0ab
Merge branch 'main' into multiple-terminologies
ItzNotABug d53c8ef
fix: add fallback.
ItzNotABug ae9aa07
fix: infy-loop
ItzNotABug 0e7938a
fix: `$derived` overuse.
ItzNotABug 222eb9a
fix: relationships.
ItzNotABug 7c4c256
address: pending todo.
ItzNotABug 83a8870
address rabbits comment.
ItzNotABug f1712be
address rabbits comment.
ItzNotABug 72d4494
Remove pnpm store caching from Docker build
TorstenDittmann f0931a2
Merge pull request #2468 from appwrite/fix-dockerfile-railway
TorstenDittmann d982b81
Enable email verificaiton on Stage
Meldiron 3b9d688
Merge pull request #2469 from appwrite/chore-enable-stage-emai-verifi…
Meldiron 8c3b1b6
use page currentPlan for limits to refresh button state on org switch
HarshMN2345 8c405c4
fix: prevent redirect loop on verify-email page
HarshMN2345 bafa3c7
Merge pull request #2470 from appwrite/fix-disabled-button-stae
ItzNotABug 0039c38
Merge pull request #2471 from appwrite/fix-redirect-loop-issue
Meldiron f60a231
Disable email veirifaction on prod, for rolling update
Meldiron 47d697d
Merge pull request #2473 from appwrite/chore-rolling-update-email-ver…
Meldiron 3c434ac
Update src/routes/(console)/project-[region]-[project]/messaging/topi…
HarshMN2345 48038c9
Merge pull request #2422 from appwrite/fix-SER-416-issues-in-messagin…
Meldiron bccbf5d
fix: platform created props flow.
ItzNotABug aa34fce
fix: type.
ItzNotABug 74f168f
Apply suggestion from @ItzNotABug
ItzNotABug 2ad36d4
update: svelte, diff titles, new prop.
ItzNotABug 8cdf6ed
fix: platform type.
ItzNotABug 2748012
fix: param.
ItzNotABug f350ecb
lint.
ItzNotABug 1590206
Merge pull request #2476 from appwrite/fix-dat-807
ItzNotABug 7a4f9a9
Merge branch 'main' into 'multiple-terminologies'.
ItzNotABug 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
Some comments aren't visible on the classic Files Changed page.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
import { resolve } from '$app/paths'; | ||
import { goto } from '$app/navigation'; | ||
import { writable } from 'svelte/store'; | ||
import type { Pathname, RouteId, RouteParams } from '$app/types'; | ||
|
||
export const navigationCancelled = writable(false); | ||
|
||
// taken directly from svelte's source! | ||
type ResolveArgs<T extends RouteId | Pathname> = T extends RouteId | ||
? RouteParams<T> extends Record<string, never> | ||
? [route: T] | ||
: [route: T, params: RouteParams<T>] | ||
: [route: T]; | ||
|
||
export function navigate<T extends RouteId>( | ||
route: T, | ||
params?: Record<string, string> | ||
): Promise<void> { | ||
// type cast is necessary here! | ||
const resolveArgs = params ? ([route, params] as [T, RouteParams<T>]) : [route]; | ||
const resolvedPathname = resolve(...(resolveArgs as ResolveArgs<T>)); | ||
|
||
return goto(resolvedPathname); | ||
} |
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
51 changes: 51 additions & 0 deletions
51
...e)/project-[region]-[project]/databases/database-[database]/(entity)/helpers/analytics.ts
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,51 @@ | ||
import type { Page } from '@sveltejs/kit'; | ||
import { page as pageState } from '$app/state'; | ||
|
||
import { useTerminology } from './terminology'; | ||
import { Submit, Click } from '$lib/actions/analytics'; | ||
import type { AnalyticsResult, TerminologyResult, TerminologyShape } from './types'; | ||
|
||
export function useAnalytics(pageOrTerms: Page | TerminologyResult = pageState): AnalyticsResult { | ||
const terminology = 'source' in pageOrTerms ? pageOrTerms : useTerminology(pageOrTerms); | ||
|
||
const createSubmitHandler = <TAction extends string>(termType: keyof TerminologyShape) => { | ||
return (action: TAction) => { | ||
const term = terminology.source[termType]; | ||
if (!term) { | ||
throw new Error(`No ${termType} terminology found`); | ||
} | ||
const enumKey = `${term.title.singular}${action}`; | ||
return Submit[enumKey as keyof typeof Submit]; | ||
abnegate marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
}; | ||
|
||
const createClickHandler = <TAction extends string>(termType: keyof TerminologyShape) => { | ||
return (action: TAction) => { | ||
const term = terminology.source[termType]; | ||
if (!term) { | ||
throw new Error(`No ${termType} terminology found`); | ||
} | ||
const enumKey = `Database${term.title.singular}${action}`; | ||
return Click[enumKey as keyof typeof Click]; | ||
abnegate marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
}; | ||
|
||
const result: AnalyticsResult = { submit: {}, click: {} }; | ||
|
||
if (terminology.entity) { | ||
result.click.entity = createClickHandler('entity'); | ||
result.submit.entity = createSubmitHandler('entity'); | ||
} | ||
|
||
if (terminology.field) { | ||
result.click.field = createClickHandler('field'); | ||
result.submit.field = createSubmitHandler('field'); | ||
} | ||
|
||
if (terminology.record) { | ||
result.click.record = createClickHandler('record'); | ||
result.submit.record = createSubmitHandler('record'); | ||
} | ||
|
||
return result; | ||
} |
24 changes: 24 additions & 0 deletions
24
...project-[region]-[project]/databases/database-[database]/(entity)/helpers/dependencies.ts
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,24 @@ | ||
import type { Page } from '@sveltejs/kit'; | ||
import { page as pageState } from '$app/state'; | ||
|
||
import { useTerminology } from './terminology'; | ||
import { Dependencies } from '$lib/constants'; | ||
import type { DependenciesResult, Term, TerminologyResult } from './types'; | ||
|
||
export function useDependencies( | ||
pageOrTerms: Page | TerminologyResult = pageState | ||
): DependenciesResult { | ||
// source is in `TerminologyResult`. | ||
const terminology = 'source' in pageOrTerms ? pageOrTerms : useTerminology(pageOrTerms); | ||
|
||
const getDependencies = (term: { title: Term }) => ({ | ||
singular: Dependencies[term.title.singular.toUpperCase() as keyof typeof Dependencies], | ||
plural: Dependencies[term.title.plural.toUpperCase() as keyof typeof Dependencies] | ||
}); | ||
|
||
return { | ||
entity: terminology.entity ? getDependencies(terminology.entity) : undefined, | ||
field: terminology.field ? getDependencies(terminology.field) : undefined, | ||
record: terminology.record ? getDependencies(terminology.record) : undefined | ||
}; | ||
} |
4 changes: 4 additions & 0 deletions
4
...nsole)/project-[region]-[project]/databases/database-[database]/(entity)/helpers/index.ts
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,4 @@ | ||
export * from './types'; | ||
export * from './analytics'; | ||
export * from './terminology'; | ||
export * from './dependencies'; |
67 changes: 67 additions & 0 deletions
67
.../project-[region]-[project]/databases/database-[database]/(entity)/helpers/terminology.ts
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,67 @@ | ||
import type { Page } from '@sveltejs/kit'; | ||
import { page as pageStage } from '$app/state'; | ||
|
||
import { type Models } from '@appwrite.io/console'; | ||
import { capitalize, plural } from '$lib/helpers/string'; | ||
import type { Columns } from '$database/table-[table]/store'; | ||
import type { Term, TerminologyResult, TerminologyShape } from '$database/(entity)/helpers/types'; | ||
|
||
export type DatabaseType = 'legacy' | 'tablesdb' | 'documentsdb' | 'vectordb'; | ||
export type Entity = Partial<Models.Table>; | ||
export type Field = Partial<Columns>; | ||
|
||
export const baseTerminology = { | ||
tablesdb: { | ||
entity: 'table', | ||
field: 'column', | ||
record: 'row' | ||
}, | ||
documentsdb: { | ||
entity: 'collection', | ||
record: 'document' | ||
ItzNotABug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
legacy: { | ||
entity: 'collection', | ||
field: 'attribute', | ||
record: 'document' | ||
}, | ||
vectordb: {} | ||
abnegate marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} as const; | ||
|
||
const createTerm = (singular: string, pluralForm: string): Term => { | ||
return { singular, plural: pluralForm }; | ||
}; | ||
|
||
// transforms a base into lower/title variants | ||
const createTermVariants = (baseTerm: string) => ({ | ||
lower: createTerm(baseTerm, plural(baseTerm)), | ||
title: createTerm(capitalize(baseTerm), plural(capitalize(baseTerm))) | ||
}); | ||
|
||
// transforms terminology for a database type | ||
const transformDatabaseTerms = (terms: Partial<TerminologyShape>) => | ||
Object.fromEntries( | ||
Object.entries(terms).map(([key, term]) => [ | ||
key, | ||
term ? createTermVariants(term) : undefined | ||
]) | ||
); | ||
|
||
// build the terminology data | ||
const terminologyData = Object.fromEntries( | ||
Object.entries(baseTerminology).map(([dbType, terms]) => [ | ||
dbType, | ||
transformDatabaseTerms(terms) | ||
]) | ||
); | ||
|
||
export function useTerminology(page: Page = pageStage): TerminologyResult { | ||
const type = page.data?.database?.type as DatabaseType; | ||
const dbTerminologies = terminologyData[type] || {}; | ||
return { | ||
source: dbTerminologies, | ||
field: dbTerminologies.field, | ||
record: dbTerminologies.record, | ||
entity: dbTerminologies.entity | ||
}; | ||
} |
66 changes: 66 additions & 0 deletions
66
...nsole)/project-[region]-[project]/databases/database-[database]/(entity)/helpers/types.ts
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,66 @@ | ||
import { Click, Submit } from '$lib/actions/analytics'; | ||
import type { baseTerminology } from './terminology'; | ||
import { Dependencies } from '$lib/constants'; | ||
|
||
export type TerminologyShape = { | ||
entity: string; | ||
field?: string; | ||
record?: string; | ||
}; | ||
|
||
export type Term = { singular: string; plural: string }; | ||
|
||
export type TerminologyResult = { | ||
source: { | ||
entity?: { lower: Term; title: Term }; | ||
field?: { lower: Term; title: Term }; | ||
record?: { lower: Term; title: Term }; | ||
}; | ||
entity: { lower: Term; title: Term }; | ||
field?: { lower: Term; title: Term }; | ||
record?: { lower: Term; title: Term }; | ||
}; | ||
|
||
// for derived analytics! | ||
type ExtractActionsForPrefix<TPrefix extends string> = { | ||
[K in keyof typeof Submit]: K extends `${TPrefix}${infer Action}` ? Action : never; | ||
}[keyof typeof Submit]; | ||
|
||
type ExtractClickActionsForPrefix<TPrefix extends string> = { | ||
[K in keyof typeof Click]: K extends `Database${TPrefix}${infer Action}` ? Action : never; | ||
}[keyof typeof Click]; | ||
|
||
type TermValuesForKey<TKey extends keyof TerminologyShape> = { | ||
[K in keyof typeof baseTerminology]: TKey extends keyof (typeof baseTerminology)[K] | ||
? (typeof baseTerminology)[K][TKey] | ||
: never; | ||
}[keyof typeof baseTerminology]; | ||
|
||
type SubmitActionsFor<TKey extends keyof TerminologyShape> = ExtractActionsForPrefix< | ||
Capitalize<TermValuesForKey<TKey>> | ||
>; | ||
|
||
type ClickActionsFor<TKey extends keyof TerminologyShape> = ExtractClickActionsForPrefix< | ||
Capitalize<TermValuesForKey<TKey>> | ||
>; | ||
|
||
export type AnalyticsResult = { | ||
submit: { | ||
entity?: (action: SubmitActionsFor<'entity'>) => Submit; | ||
field?: (action: SubmitActionsFor<'field'>) => Submit; | ||
record?: (action: SubmitActionsFor<'record'>) => Submit; | ||
}; | ||
click: { | ||
entity?: (action: ClickActionsFor<'entity'>) => Click; | ||
field?: (action: ClickActionsFor<'field'>) => Click; | ||
record?: (action: ClickActionsFor<'record'>) => Click; | ||
}; | ||
}; | ||
|
||
// for derived dependencies! | ||
export type DependenciesResult = { | ||
[K in keyof Omit<TerminologyResult, 'source'>]: { | ||
singular: Dependencies; | ||
plural: Dependencies; | ||
}; | ||
}; |
4 changes: 4 additions & 0 deletions
4
...utes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/index.ts
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,4 @@ | ||
export * from './helpers'; | ||
export * from './settings'; | ||
export { default as Usage } from './usage/view.svelte'; | ||
export { default as EntityContainer } from './view/container.svelte'; |
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.