Compare commits
10 Commits
2ab57a0fea
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40344e4e74 | ||
|
|
99d0c8935c | ||
|
|
debbd2c01f | ||
|
|
9adcd1fc3f | ||
|
|
e4a4b78b12 | ||
|
|
b1f6f31f00 | ||
|
|
4f6f466fd7 | ||
|
|
ea31829329 | ||
|
|
2e2728cea1 | ||
|
|
44010ef123 |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@takerofnotes/plugin-sdk",
|
"name": "@takerofnotes/plugin-sdk",
|
||||||
"version": "0.2.0",
|
"version": "0.3.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@takerofnotes/plugin-sdk",
|
"name": "@takerofnotes/plugin-sdk",
|
||||||
"version": "0.2.0",
|
"version": "0.3.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"zod": "^4.3.6"
|
"zod": "^4.3.6"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@takerofnotes/plugin-sdk",
|
"name": "@takerofnotes/plugin-sdk",
|
||||||
"version": "0.2.0",
|
"version": "0.3.1",
|
||||||
"description": "SDK to create a storage plugin for Taker of Notes",
|
"description": "SDK to create a storage plugin for Taker of Notes",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
import { validatePlugin } from './validatePlugin'
|
import { SUPPORTED_API_VERSION, validatePlugin } from './validatePlugin'
|
||||||
|
|
||||||
export interface TestNote {
|
export interface TestNote {
|
||||||
id: string
|
id: string
|
||||||
title: string
|
data: string
|
||||||
content: string
|
|
||||||
createdAt: string
|
|
||||||
updatedAt: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createTestNote = (id: string = 'test-note-1'): TestNote => ({
|
export const createTestNote = (
|
||||||
|
id: string = 'test-note-1',
|
||||||
|
data?: string,
|
||||||
|
): TestNote => ({
|
||||||
id,
|
id,
|
||||||
title: 'Test Note',
|
data: data || 'test-data',
|
||||||
content: 'Test content',
|
|
||||||
createdAt: new Date().toISOString(),
|
|
||||||
updatedAt: new Date().toISOString(),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export interface TestPluginOptions {
|
export interface TestPluginOptions {
|
||||||
@@ -42,7 +39,7 @@ export const runPluginTests = ({ plugin, adapter }: TestPluginOptions) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
it('should have correct apiVersion', () => {
|
it('should have correct apiVersion', () => {
|
||||||
equal(plugin.apiVersion, '0.1.0')
|
equal(plugin.apiVersion, SUPPORTED_API_VERSION)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -82,19 +79,19 @@ export const runPluginTests = ({ plugin, adapter }: TestPluginOptions) => {
|
|||||||
it('should update a note without errors', async () => {
|
it('should update a note without errors', async () => {
|
||||||
const note = createTestNote('test-update-note')
|
const note = createTestNote('test-update-note')
|
||||||
await adapter.create(note)
|
await adapter.create(note)
|
||||||
const updatedNote = { ...note, content: 'Updated content' }
|
const updatedNote = { ...note, data: 'Updated data' }
|
||||||
await adapter.update(updatedNote)
|
await adapter.update(updatedNote)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updated note should reflect changes', async () => {
|
it('updated note should reflect changes', async () => {
|
||||||
const note = createTestNote('test-update-note-2')
|
const note = createTestNote('test-update-note-2')
|
||||||
await adapter.create(note)
|
await adapter.create(note)
|
||||||
const updatedNote = { ...note, title: 'Updated Title' }
|
const updatedNote = { ...note, data: 'Updated data v2' }
|
||||||
await adapter.update(updatedNote)
|
await adapter.update(updatedNote)
|
||||||
const notes = await adapter.getAll()
|
const notes = await adapter.getAll()
|
||||||
const found = notes.find((n: any) => n.id === note.id)
|
const found = notes.find((n: any) => n.id === note.id)
|
||||||
if (found?.title !== 'Updated Title') {
|
if (found?.data !== 'Updated data v2') {
|
||||||
throw new Error('Updated note title does not match')
|
throw new Error('Updated note data does not match')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -128,14 +125,14 @@ export const runPluginTests = ({ plugin, adapter }: TestPluginOptions) => {
|
|||||||
throw new Error('Created note not found')
|
throw new Error('Created note not found')
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedNote = { ...note, title: 'CRUD update' }
|
const updatedNote = { ...note, data: 'CRUD update' }
|
||||||
await adapter.update(updatedNote)
|
await adapter.update(updatedNote)
|
||||||
notes = await adapter.getAll()
|
notes = await adapter.getAll()
|
||||||
if (
|
if (
|
||||||
notes.find((n: any) => n.id === note.id)?.title !==
|
notes.find((n: any) => n.id === note.id)?.data !==
|
||||||
'CRUD update'
|
'CRUD update'
|
||||||
) {
|
) {
|
||||||
throw new Error('Updated note content does not match')
|
throw new Error('Updated note data does not match')
|
||||||
}
|
}
|
||||||
|
|
||||||
await adapter.delete(note.id)
|
await adapter.delete(note.id)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
export const SUPPORTED_API_VERSION = '0.1.0'
|
export const SUPPORTED_API_VERSION = '0.3.1'
|
||||||
|
|
||||||
const ConfigFieldSchema = z.object({
|
const ConfigFieldSchema = z.object({
|
||||||
key: z.string(),
|
key: z.string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user