@vivoa/plugin-sdk 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/index.d.mts +788 -0
- package/dist/index.d.ts +788 -0
- package/dist/index.js +563 -0
- package/dist/index.mjs +526 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vivoa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @vivoa/plugin-sdk
|
|
2
|
+
|
|
3
|
+
Public contracts for Vivoa plugins. Pure TypeScript types, DI tokens, and
|
|
4
|
+
runtime validators. No host coupling, no React, no framework imports.
|
|
5
|
+
|
|
6
|
+
A plugin author depends on this package; the Vivoa host re-exports it as its
|
|
7
|
+
single source of truth for plugin shapes.
|
|
8
|
+
|
|
9
|
+
> **Building a plugin?** Read [`AUTHORING.md`](./AUTHORING.md) — the complete,
|
|
10
|
+
> AI-legible guide (anatomy, `IPaymentPlugin`/`IShippingPlugin`, config, setup
|
|
11
|
+
> layout, permissions, build/publish, and the host landmines to avoid).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @vivoa/plugin-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## What's inside
|
|
20
|
+
|
|
21
|
+
| Module | Exports |
|
|
22
|
+
| ---------------- | ----------------------------------------------------------------------- |
|
|
23
|
+
| `types` | `IPlugin`, `IPaymentPlugin`, `IShippingPlugin`, payment/shipping models, DI tokens |
|
|
24
|
+
| `manifest` | `PluginManifest` |
|
|
25
|
+
| `config-schema` | `createPluginConfig`, `field` — declarative config + superstruct validation |
|
|
26
|
+
| `setup-layout` | `SetupLayout` types, `validateSetupLayout`, `crossValidateSetupLayout` |
|
|
27
|
+
|
|
28
|
+
All exported from the package root:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import {
|
|
32
|
+
IPaymentPlugin,
|
|
33
|
+
createPluginConfig,
|
|
34
|
+
field,
|
|
35
|
+
validateSetupLayout,
|
|
36
|
+
} from '@vivoa/plugin-sdk';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Defining a configurable plugin
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createPluginConfig, field } from '@vivoa/plugin-sdk';
|
|
43
|
+
|
|
44
|
+
const config = createPluginConfig({
|
|
45
|
+
apiKey: field({ label: 'API Key', type: 'password' }),
|
|
46
|
+
sandbox: field({ label: 'Sandbox', type: 'boolean', required: false }),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
config.configFields; // -> PluginConfigField[] for the admin UI
|
|
50
|
+
config.validate(input); // -> { success, data | errors }
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Validating a setup layout
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { validateSetupLayout, crossValidateSetupLayout } from '@vivoa/plugin-sdk';
|
|
57
|
+
|
|
58
|
+
const res = validateSetupLayout(manifest.setup);
|
|
59
|
+
if (!res.success) throw new Error(res.errors.join('\n'));
|
|
60
|
+
|
|
61
|
+
const keyErrors = crossValidateSetupLayout(res.data, config.configFields);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Versioning
|
|
65
|
+
|
|
66
|
+
Semver. Breaking changes to any exported type or validator bump the major.
|
|
67
|
+
Plugins should pin a caret range (`^0.1.0`).
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT
|