Skip to content

Commit

Permalink
Merge branch 'main' into heesu/website-mention
Browse files Browse the repository at this point in the history
  • Loading branch information
glowingjade committed Oct 23, 2024
2 parents e50607b + 00c67d3 commit 7baa587
Show file tree
Hide file tree
Showing 52 changed files with 6,153 additions and 2,170 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ version-bump.mjs
versions.json
package.json
manifest.json
compile-migration.js
import-meta-url-shim.js

# Obsidian
.obsidian
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ main.js
data.json

# Exclude macOS Finder (System Explorer) View States
.DS_Store
.DS_Store
6 changes: 6 additions & 0 deletions __mocks__/obsidian.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const App = jest.fn()
export const Editor = jest.fn()
export const MarkdownView = jest.fn()
export const TFile = jest.fn()
export const TFolder = jest.fn()
export const Vault = jest.fn()
12 changes: 12 additions & 0 deletions compile-migration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { readMigrationFiles } = require('drizzle-orm/migrator')
const fs = require('node:fs/promises')

async function compileMigrations() {
const migrations = readMigrationFiles({ migrationsFolder: './drizzle/' })

await fs.writeFile('./src/db/migrations.json', JSON.stringify(migrations))

console.log('Migrations compiled!')
}

compileMigrations().catch(console.error)
6 changes: 6 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from 'drizzle-kit'

export default defineConfig({
dialect: 'postgresql',
schema: './src/db/schema.ts',
})
2 changes: 2 additions & 0 deletions drizzle/0000_add_vector_extension.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Custom SQL migration file, put you code below! --
CREATE EXTENSION IF NOT EXISTS vector;
19 changes: 19 additions & 0 deletions drizzle/0001_create_vector_data_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE IF NOT EXISTS "vector_data_text_embedding_3_small" (
"id" serial PRIMARY KEY NOT NULL,
"path" text NOT NULL,
"mtime" bigint NOT NULL,
"content" text NOT NULL,
"embedding" vector(1536),
"metadata" jsonb NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "vector_data_text_embedding_3_large" (
"id" serial PRIMARY KEY NOT NULL,
"path" text NOT NULL,
"mtime" bigint NOT NULL,
"content" text NOT NULL,
"embedding" vector(3072),
"metadata" jsonb NOT NULL
);
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "embeddingIndex_text_embedding_3_small" ON "vector_data_text_embedding_3_small" USING hnsw ("embedding" vector_cosine_ops);
16 changes: 16 additions & 0 deletions drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "8344dba7-b655-4009-9c56-894062c17ea6",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {},
"enums": {},
"schemas": {},
"views": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
128 changes: 128 additions & 0 deletions drizzle/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"id": "1084161a-8de5-4452-ba8b-6ffc3549d411",
"prevId": "8344dba7-b655-4009-9c56-894062c17ea6",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.vector_data_text_embedding_3_small": {
"name": "vector_data_text_embedding_3_small",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"path": {
"name": "path",
"type": "text",
"primaryKey": false,
"notNull": true
},
"mtime": {
"name": "mtime",
"type": "bigint",
"primaryKey": false,
"notNull": true
},
"content": {
"name": "content",
"type": "text",
"primaryKey": false,
"notNull": true
},
"embedding": {
"name": "embedding",
"type": "vector(1536)",
"primaryKey": false,
"notNull": false
},
"metadata": {
"name": "metadata",
"type": "jsonb",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
"embeddingIndex_text_embedding_3_small": {
"name": "embeddingIndex_text_embedding_3_small",
"columns": [
{
"expression": "embedding",
"isExpression": false,
"asc": true,
"nulls": "last",
"opclass": "vector_cosine_ops"
}
],
"isUnique": false,
"concurrently": false,
"method": "hnsw",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"public.vector_data_text_embedding_3_large": {
"name": "vector_data_text_embedding_3_large",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"path": {
"name": "path",
"type": "text",
"primaryKey": false,
"notNull": true
},
"mtime": {
"name": "mtime",
"type": "bigint",
"primaryKey": false,
"notNull": true
},
"content": {
"name": "content",
"type": "text",
"primaryKey": false,
"notNull": true
},
"embedding": {
"name": "embedding",
"type": "vector(3072)",
"primaryKey": false,
"notNull": false
},
"metadata": {
"name": "metadata",
"type": "jsonb",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"enums": {},
"schemas": {},
"sequences": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
20 changes: 20 additions & 0 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1729509950412,
"tag": "0000_add_vector_extension",
"breakpoints": true
},
{
"idx": 1,
"version": "7",
"when": 1729509994653,
"tag": "0001_create_vector_data_tables",
"breakpoints": true
}
]
}
14 changes: 11 additions & 3 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path'
import esbuild from 'esbuild'
import process from 'process'
import builtins from 'builtin-modules'
Expand All @@ -14,7 +15,7 @@ const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ['src/main.ts'], // Change this line
entryPoints: ['src/main.ts'],
bundle: true,
external: [
'obsidian',
Expand All @@ -33,12 +34,19 @@ const context = await esbuild.context({
...builtins,
],
format: 'cjs',
target: 'es2018',
define: {
'import.meta.url': 'import_meta_url',
process: '{}',
'process.env.NODE_ENV': JSON.stringify(prod ? 'production' : 'development'),
},
inject: [path.resolve('import-meta-url-shim.js')],
target: 'es2020',
logLevel: 'info',
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js', // Changed back to main.js
outfile: 'main.js',
minify: prod,
// logLevel: 'debug',
})

if (prod) {
Expand Down
7 changes: 7 additions & 0 deletions import-meta-url-shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const import_meta_url =
typeof document === 'undefined'
? require('url').pathToFileURL(__filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href

export { import_meta_url }
Loading

0 comments on commit 7baa587

Please sign in to comment.