Skip to content

Commit

Permalink
feat: add bridge connection storage for communication process
Browse files Browse the repository at this point in the history
  • Loading branch information
danpacho committed Aug 6, 2024
1 parent 2404fa7 commit 28e424f
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"obsidian-reference": {
"staticConfig": {
"name": "obsidian-reference",
"description": "convert obsidian image and audio reference to html tag and update link tag"
},
"dynamicConfig": null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"meta-validator": {
"staticConfig": {
"name": "meta-validator",
"description": "Validate meta information for the content"
},
"dynamicConfig": null
},
"meta-builder": {
"staticConfig": {
"name": "meta-builder",
"description": "Generate meta information for the content"
},
"dynamicConfig": null
},
"static-param-builder": {
"staticConfig": {
"name": "static-param-builder",
"description": "Inject static params to the content"
},
"dynamicConfig": null
},
"pagination-builder": {
"staticConfig": {
"name": "pagination-builder",
"description": "Generate pagination meta information for the content"
},
"dynamicConfig": null
},
"series-info-generator": {
"staticConfig": {
"name": "series-info-generator",
"description": "Generate series info for the content"
},
"dynamicConfig": null
},
"category-description-generator": {
"staticConfig": {
"name": "category-description-generator",
"description": "Generate category description from {{description}}.md",
"dynamicConfigDescriptions": [
{
"property": "categoryMeta",
"type": "\n {\n parser: (meta: unknown) => PolymorphicMeta\n generator: (meta: unknown) => PolymorphicMeta\n }\n "
},
{
"property": "path",
"type": "string"
},
{
"property": "descriptionFileName",
"type": "string",
"example": "description.md"
}
]
},
"dynamicConfig": {
"categoryMeta": {
"parser": "__FUNCTION__:(input) => {\n if (!IsCategoryMeta(input)) {\n throw new TypeError(\n `content meta error: invalid input, check ${prettyPrint(input)}`\n );\n }\n const { title, description, postCollection } = input;\n return {\n title,\n description,\n postCollection\n };\n}",
"generator": "__FUNCTION__:(meta) => ({\n ...__vite_ssr_import_0__.ContentMetaDefaultValueInjector(),\n ...meta\n})"
},
"descriptionFileName": "description.md"
}
}
}
161 changes: 161 additions & 0 deletions packages/plugin/src/core/__fixtures__/store/build/history.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{
"build_system::internal": [
{
"jobName": "sync-build-store",
"status": "success",
"startedAt": "2024-07-23T06:22:10.115Z",
"endedAt": "2024-07-23T06:22:10.120Z",
"response": [
{
"jobName": "build:internal",
"status": "success",
"startedAt": "2024-07-23T06:22:10.115Z",
"endedAt": "2024-07-23T06:22:10.119Z",
"execTime": 4
}
],
"execTime": 5
},
{
"jobName": "duplicate-obsidian-vault-into-source",
"status": "success",
"startedAt": "2024-07-23T06:22:10.120Z",
"endedAt": "2024-07-23T06:22:10.120Z",
"response": [
{
"jobName": "build:internal",
"status": "success",
"startedAt": "2024-07-23T06:22:10.120Z",
"endedAt": "2024-07-23T06:22:10.120Z",
"execTime": 0
}
],
"execTime": 0
},
{
"jobName": "inject-build-info-to-generated-tree",
"status": "success",
"startedAt": "2024-07-23T06:22:10.121Z",
"endedAt": "2024-07-23T06:22:10.121Z",
"response": [
{
"jobName": "build:internal",
"status": "success",
"startedAt": "2024-07-23T06:22:10.121Z",
"endedAt": "2024-07-23T06:22:10.121Z",
"execTime": 0
}
],
"execTime": 0
}
],
"build_system::build_tree": [],
"build_system::walk_tree": [
{
"jobName": "meta-validator",
"status": "success",
"startedAt": "2024-07-23T06:22:10.122Z",
"endedAt": "2024-07-23T06:22:10.122Z",
"response": [
{
"jobName": "walk:tree",
"status": "success",
"startedAt": "2024-07-23T06:22:10.122Z",
"endedAt": "2024-07-23T06:22:10.122Z",
"execTime": 2
}
],
"execTime": 0
},
{
"jobName": "meta-builder",
"status": "success",
"startedAt": "2024-07-23T06:22:10.123Z",
"endedAt": "2024-07-23T06:22:10.123Z",
"response": [
{
"jobName": "walk:tree",
"status": "success",
"startedAt": "2024-07-23T06:22:10.123Z",
"endedAt": "2024-07-23T06:22:10.123Z",
"execTime": 0
}
],
"execTime": 0
},
{
"jobName": "static-param-builder",
"status": "success",
"startedAt": "2024-07-23T06:22:10.123Z",
"endedAt": "2024-07-23T06:22:10.123Z",
"response": [
{
"jobName": "walk:tree",
"status": "success",
"startedAt": "2024-07-23T06:22:10.123Z",
"endedAt": "2024-07-23T06:22:10.123Z",
"execTime": 0
}
],
"execTime": 0
},
{
"jobName": "pagination-builder",
"status": "success",
"startedAt": "2024-07-23T06:22:10.123Z",
"endedAt": "2024-07-23T06:22:10.123Z",
"response": [
{
"jobName": "walk:tree",
"status": "success",
"startedAt": "2024-07-23T06:22:10.123Z",
"endedAt": "2024-07-23T06:22:10.123Z",
"execTime": 0
}
],
"execTime": 0
},
{
"jobName": "series-info-generator",
"status": "success",
"startedAt": "2024-07-23T06:22:10.124Z",
"endedAt": "2024-07-23T06:22:10.124Z",
"response": [
{
"jobName": "walk:tree",
"status": "success",
"startedAt": "2024-07-23T06:22:10.124Z",
"endedAt": "2024-07-23T06:22:10.124Z",
"execTime": 0
}
],
"execTime": 0
},
{
"jobName": "category-description-generator",
"status": "success",
"startedAt": "2024-07-23T06:22:10.124Z",
"endedAt": "2024-07-23T06:22:10.124Z",
"response": [
{
"jobName": "walk:tree",
"status": "success",
"startedAt": "2024-07-23T06:22:10.124Z",
"endedAt": "2024-07-23T06:22:10.124Z",
"execTime": 0
}
],
"execTime": 0
}
],
"build_system::build_contents": [
{
"jobName": "obsidian-reference",
"status": "success",
"startedAt": "2024-07-23T06:22:10.124Z",
"endedAt": "2024-07-23T06:22:10.125Z",
"response": [],
"execTime": 1
}
]
}
47 changes: 47 additions & 0 deletions packages/plugin/src/core/bridge.storage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { describe, expect, it } from 'vitest'
import { BuildBridgeStorage } from './bridge.storage'

describe('BridgeStorage', () => {
const storage = BuildBridgeStorage.create({
bridgeRoot: `${process.cwd()}/packages/plugin/src/core/__fixtures__`,
storePrefix: 'store/build',
configNames: [
'build_system::build_contents',
'build_system::build_tree',
'build_system::walk_tree',
],
})

it('should create a new instance of BuildBridgeStorage', () => {
expect(storage).toBeDefined()
})

it('should be initialized', async () => {
await storage.load()
expect(storage).toBeDefined()
})

it('should inquire configs', () => {
const res = storage.config('build_system::build_contents').storageRecord
expect(res).toEqual({
'obsidian-reference': {
staticConfig: {
name: 'obsidian-reference',
description:
'convert obsidian image and audio reference to html tag and update link tag',
},
dynamicConfig: null,
},
})
})

it('should inquire history', () => {
const historyKeys = [...storage.history.storage.keys()]
expect(historyKeys).toStrictEqual([
'build_system::internal',
'build_system::build_tree',
'build_system::walk_tree',
'build_system::build_contents',
])
})
})

0 comments on commit 28e424f

Please sign in to comment.