-
Notifications
You must be signed in to change notification settings - Fork 1
Add product workflow and API preview #30
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
LukasParke
wants to merge
3
commits into
main
Choose a base branch
from
agent/finish-openapi-generator
base: main
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.
Open
Changes from all commits
Commits
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,13 +1,8 @@ | ||
| <script lang="ts"> | ||
| import { loadSpec, saveSpec, selectedSpec } from '$lib/db'; | ||
| import { saveDocumentNow } from '$lib/editorSession'; | ||
| import type { CssClasses } from '@skeletonlabs/skeleton'; | ||
|
|
||
| export let width: CssClasses = 'w-full'; | ||
|
|
||
| async function onSave(): Promise<void> { | ||
| const spec = await saveSpec($selectedSpec); | ||
| if (spec) loadSpec(spec); | ||
| } | ||
| </script> | ||
|
|
||
| <button class="btn variant-ghost-success {width}" on:click={onSave}> Save </button> | ||
| <button class="btn variant-ghost-success {width}" on:click={saveDocumentNow}> Save </button> |
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,114 @@ | ||
| <script lang="ts"> | ||
| import { goto } from '$app/navigation'; | ||
| import { selectedSpec } from '$lib/db'; | ||
| import { tick } from 'svelte'; | ||
|
|
||
| export let open = false; | ||
|
|
||
| interface SwitcherItem { | ||
| label: string; | ||
| detail: string; | ||
| href: string; | ||
| } | ||
|
|
||
| let query = ''; | ||
| let input: HTMLInputElement; | ||
|
|
||
| const sections: SwitcherItem[] = [ | ||
| { label: 'Dashboard', detail: 'Section', href: '/' }, | ||
| { label: 'Information', detail: 'Section', href: '/info' }, | ||
| { label: 'Servers', detail: 'Section', href: '/servers' }, | ||
| { label: 'Security', detail: 'Section', href: '/authentication' }, | ||
| { label: 'Paths', detail: 'Section', href: '/paths' }, | ||
| { label: 'Webhooks', detail: 'Section', href: '/webhooks' }, | ||
| { label: 'Components', detail: 'Section', href: '/components' }, | ||
| { label: 'Review', detail: 'Section', href: '/review' }, | ||
| { label: 'API Preview', detail: 'Interactive documentation', href: '/preview' } | ||
| ]; | ||
|
|
||
| $: pathItems = Object.keys($selectedSpec.spec.paths ?? {}).map((path, index) => ({ | ||
| label: path, | ||
| detail: 'API path', | ||
| href: `/paths/${index}` | ||
| })); | ||
| $: componentItems = Object.entries($selectedSpec.spec.components ?? {}).flatMap( | ||
| ([section, values]) => | ||
| Object.keys(values ?? {}).map((name) => ({ | ||
| label: name, | ||
| detail: `Component · ${section}`, | ||
| href: '/components' | ||
| })) | ||
| ); | ||
| $: items = [...sections, ...pathItems, ...componentItems]; | ||
| $: normalizedQuery = query.trim().toLowerCase(); | ||
| $: filteredItems = normalizedQuery | ||
| ? items | ||
| .filter((item) => `${item.label} ${item.detail}`.toLowerCase().includes(normalizedQuery)) | ||
| .slice(0, 12) | ||
| : items.slice(0, 12); | ||
|
|
||
| $: if (open) { | ||
| tick().then(() => input?.focus()); | ||
| } | ||
|
|
||
| const select = async (item: SwitcherItem) => { | ||
| open = false; | ||
| query = ''; | ||
| await goto(item.href); | ||
| }; | ||
| </script> | ||
|
|
||
| {#if open} | ||
| <div | ||
| class="fixed inset-0 z-50 flex justify-center bg-surface-900/60 p-4 pt-[12vh] backdrop-blur-sm" | ||
| role="presentation" | ||
| on:click={(event) => { | ||
| if (event.currentTarget === event.target) open = false; | ||
| }} | ||
| on:keydown={(event) => { | ||
| if (event.key === 'Escape') open = false; | ||
| }} | ||
| > | ||
| <div | ||
| class="card h-fit w-full max-w-2xl overflow-hidden shadow-2xl" | ||
| role="dialog" | ||
| aria-modal="true" | ||
| > | ||
| <div class="border-b border-surface-300-600-token p-3"> | ||
| <input | ||
| bind:this={input} | ||
| bind:value={query} | ||
| class="input border-0 text-lg focus:ring-0" | ||
| placeholder="Search sections, paths, and components…" | ||
| on:keydown={(event) => { | ||
| if (event.key === 'Enter' && filteredItems[0]) select(filteredItems[0]); | ||
| if (event.key === 'Escape') open = false; | ||
| }} | ||
| /> | ||
| </div> | ||
| <div class="max-h-[55vh] overflow-auto p-2"> | ||
| {#if filteredItems.length === 0} | ||
| <p class="p-6 text-center opacity-70">No matching destination</p> | ||
| {:else} | ||
| {#each filteredItems as item, index} | ||
| <button | ||
| type="button" | ||
| class="flex w-full items-center justify-between rounded-container-token p-3 text-left hover:variant-soft-primary" | ||
| class:variant-soft-primary={index === 0} | ||
| on:click={() => select(item)} | ||
| > | ||
| <span class="font-semibold">{item.label}</span> | ||
| <span class="text-xs opacity-60">{item.detail}</span> | ||
| </button> | ||
| {/each} | ||
| {/if} | ||
| </div> | ||
| <div | ||
| class="flex justify-between border-t border-surface-300-600-token p-2 text-xs opacity-60" | ||
| > | ||
| <span>Enter to open</span> | ||
| <span>Esc to close</span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {/if} |
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,57 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { createNewSpec } from './db'; | ||
| import { EditorHistory, PersistenceQueue } from './editorSession'; | ||
|
|
||
| describe('editor history', () => { | ||
| it('coalesces rapid edits and supports undo and redo', () => { | ||
| const history = new EditorHistory(); | ||
| const spec = createNewSpec(); | ||
| history.reset(spec); | ||
|
|
||
| spec.spec.info.title = 'P'; | ||
| history.observe(spec, 1_000); | ||
| spec.spec.info.title = 'Pets'; | ||
| history.observe(spec, 1_200); | ||
|
|
||
| expect(history.undo()?.spec.info.title).toBe(''); | ||
| expect(history.redo()?.spec.info.title).toBe('Pets'); | ||
| }); | ||
|
|
||
| it('resets history when a different saved specification is loaded', () => { | ||
| const history = new EditorHistory(); | ||
| const first = { ...createNewSpec(), id: '1' }; | ||
| const second = { ...createNewSpec(), id: '2' }; | ||
| history.reset(first); | ||
| first.spec.info.title = 'Changed'; | ||
| history.observe(first, 1_000); | ||
|
|
||
| expect(history.canUndo).toBe(true); | ||
| history.observe(second, 2_000); | ||
| expect(history.canUndo).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('persistence queue', () => { | ||
| it('finishes an older write before starting a newer write', async () => { | ||
| const queue = new PersistenceQueue(); | ||
| const writes: string[] = []; | ||
| let releaseOlderWrite: () => void = () => undefined; | ||
| const olderWriteBlocked = new Promise<void>((resolve) => { | ||
| releaseOlderWrite = resolve; | ||
| }); | ||
|
|
||
| const olderWrite = queue.enqueue(async () => { | ||
| await olderWriteBlocked; | ||
| writes.push('older'); | ||
| }); | ||
| const newerWrite = queue.enqueue(async () => { | ||
| writes.push('newer'); | ||
| }); | ||
|
|
||
| await Promise.resolve(); | ||
| expect(writes).toEqual([]); | ||
| releaseOlderWrite(); | ||
| await Promise.all([olderWrite, newerWrite]); | ||
| expect(writes).toEqual(['older', 'newer']); | ||
| }); | ||
| }); | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: LukasParke/OpenAPI.gg
Length of output: 1612
🏁 Script executed:
Repository: LukasParke/OpenAPI.gg
Length of output: 10880
🌐 Web query:
Dexie.js auto-increment ++id generated key type number explicit string key IndexedDB💡 Result:
In Dexie.js and the underlying IndexedDB, using an auto-incrementing primary key (defined via ++id in Dexie's schema) has specific behaviors regarding key types and explicit assignments. Key Types and Auto-Incrementing When you define a schema with ++id, you are using an IndexedDB object store with the autoIncrement flag enabled [1][2][3]. - The auto-incrementing key generator in IndexedDB is designed to produce positive integers [2][4]. - While you can explicitly provide a different key (such as a string) when adding or putting an object into a store, the key generator only tracks numeric keys [2][4]. - If you provide an explicit key that is a string, IndexedDB will use that specific string as the primary key for that record [4]. This does not interfere with the auto-increment counter, which only updates based on numeric keys [4]. Behavior when providing an explicit string key If you have a table defined with ++id and you attempt to add an object that contains a string value for that id field: 1. Dexie/IndexedDB will respect the explicit string key you provided [4]. 2. The object will be stored with that string as its primary key [4]. 3. The internal auto-increment counter will remain unaffected by the string key; the next time you add an object without an id, the generator will continue from its last numeric value [4]. Summary of key behaviors in Dexie.js: - ++id: Auto-incrementing integer primary key (inbound) [5][1]. - id: Explicit primary key (you must provide it yourself) [5][6]. -
@id: Globally unique string ID (requires dexie-cloud-addon) [5][6]. In practice, if you need the primary key to be a string and want it to be automatically generated, you should typically avoid the ++ syntax, which is specifically for numeric auto-incrementing, and instead manage the generation of string IDs in your application logic or use the@idsyntax if utilizing Dexie Cloud [5][6].Citations:
🏁 Script executed:
Repository: LukasParke/OpenAPI.gg
Length of output: 727
🌐 Web query:
Dexie Table.add autoIncrement generated key assigned to inbound keyPath object id💡 Result:
When you use table.add (or table.put) in Dexie.js with a schema that specifies an auto-incremented primary key (denoted by ++ in the schema definition) and an inbound keyPath, Dexie automatically assigns the generated key to the corresponding property on the object [1][2]. Key details regarding this behavior: 1. Automatic Assignment: If the primary key property is missing or undefined on the object being added, Dexie detects the auto-incremented status and the generated ID is injected into the object's keyPath property [1][3][2]. 2. Scope: This automatic assignment occurs specifically with table.add and table.put [1][2]. It does not happen with bulk operations such as table.bulkAdd or table.bulkPut [1][2]. 3. Promise Result: The promise returned by table.add resolves with the newly generated primary key [1][4]. 4. TypeScript Considerations: To maintain proper type safety in TypeScript (specifically for Dexie 4+), it is recommended to use the EntityTable helper or define an explicit InsertType that makes the primary key optional, allowing you to pass objects without the ID property while still enjoying full type inference after retrieval [5]. This functionality relies on the library internally handling the mutation of the provided object to populate the generated value [3]. If you need to perform custom logic or manual intervention during this process, the hook('creating') event is available [6].
Citations:
Align
APISpec.idwith the Dexie key type.APISpec.idisstring, so'1'and'2'are valid test values. However,++idgenerates numeric IDs for new records and conflicts with the declared type and string-based consumers.🤖 Prompt for AI Agents