-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add bridge connection storage for communication process
- Loading branch information
Showing
5 changed files
with
283 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
packages/plugin/src/core/__fixtures__/store/build/build_system::build_contents.json
This file contains 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,9 @@ | ||
{ | ||
"obsidian-reference": { | ||
"staticConfig": { | ||
"name": "obsidian-reference", | ||
"description": "convert obsidian image and audio reference to html tag and update link tag" | ||
}, | ||
"dynamicConfig": null | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/plugin/src/core/__fixtures__/store/build/build_system::build_tree.json
This file contains 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 @@ | ||
{} |
65 changes: 65 additions & 0 deletions
65
packages/plugin/src/core/__fixtures__/store/build/build_system::walk_tree.json
This file contains 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,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
161
packages/plugin/src/core/__fixtures__/store/build/history.json
This file contains 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,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 | ||
} | ||
] | ||
} |
This file contains 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,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', | ||
]) | ||
}) | ||
}) |