@justflows/sdk 1.2.0 → 1.2.1
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/README.md +96 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# @justflows/sdk
|
|
2
|
+
|
|
3
|
+
The public API for [Justflows](https://github.com/JustFlows/justflows-ce)
|
|
4
|
+
plugins and themes: TypeScript types for the plugin context, hooks and
|
|
5
|
+
manifest, the schemas the host validates packages with, and a few small
|
|
6
|
+
runtime helpers.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install --save-dev @justflows/sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Declare the SDK as a peer dependency too, at the lowest version whose features
|
|
15
|
+
you use:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"peerDependencies": { "@justflows/sdk": "^1.2.0" },
|
|
20
|
+
"devDependencies": { "@justflows/sdk": "^1.2.0" }
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The Justflows host provides the plugin runtime, so the SDK is what you build
|
|
25
|
+
against, not something you ship.
|
|
26
|
+
|
|
27
|
+
## A minimal plugin
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import type { PluginModule } from "@justflows/sdk";
|
|
31
|
+
|
|
32
|
+
const plugin: PluginModule = {
|
|
33
|
+
manifest: {
|
|
34
|
+
id: "acme.hello",
|
|
35
|
+
name: "Hello",
|
|
36
|
+
version: "1.0.0",
|
|
37
|
+
license: "GPL-2.0-or-later",
|
|
38
|
+
engines: { justflows: ">=1.1.0 <2.0.0" },
|
|
39
|
+
permissions: [],
|
|
40
|
+
main: "index.js",
|
|
41
|
+
},
|
|
42
|
+
activate(ctx) {
|
|
43
|
+
ctx.hooks.action("content.published", (event) => {
|
|
44
|
+
ctx.logger.info("published", { contentId: event.contentId });
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
async deleteData(ctx) {
|
|
48
|
+
await ctx.data.clear();
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default plugin;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`activate` receives a `PluginContext`: hooks, settings, plugin-scoped data and
|
|
56
|
+
secrets, HTTP routes, cache, mail, users and more, each behind the permissions
|
|
57
|
+
your manifest asks for.
|
|
58
|
+
|
|
59
|
+
## What is in it
|
|
60
|
+
|
|
61
|
+
- **Plugin contract:** `PluginModule`, `PluginContext`, `PluginManifestSchema`
|
|
62
|
+
and the permission names.
|
|
63
|
+
- **Hooks:** typed actions, gates and filters (`ActionEventMap`,
|
|
64
|
+
`FilterValueMap`, `GateEventMap`).
|
|
65
|
+
- **Package manifests:** `ExtensionEnginesSchema` for `engines.justflows`, plus
|
|
66
|
+
the theme template and pattern schemas.
|
|
67
|
+
- **Helpers:** `renderResponsiveImage` and `escapeHtml` for block output, and
|
|
68
|
+
`pluginApiUrl` to build your plugin's API URLs in the browser.
|
|
69
|
+
- **Versions:** `SDK_VERSION` and `SDK_API_VERSION`. At runtime, read
|
|
70
|
+
`ctx.runtime.sdk` and `ctx.runtime.justflows` for the host's versions.
|
|
71
|
+
|
|
72
|
+
## Versions
|
|
73
|
+
|
|
74
|
+
The SDK follows Semantic Versioning: minor releases only add, and breaking
|
|
75
|
+
changes wait for a major release after a deprecation period. Each release is
|
|
76
|
+
built and published from the Justflows repository by GitHub Actions, with npm
|
|
77
|
+
provenance.
|
|
78
|
+
|
|
79
|
+
| SDK | Justflows |
|
|
80
|
+
| ----- | ----------------------- |
|
|
81
|
+
| 1.2.x | the release after 1.1.0 |
|
|
82
|
+
| 1.0.x | 1.0.0 and 1.1.0 |
|
|
83
|
+
|
|
84
|
+
## Documentation
|
|
85
|
+
|
|
86
|
+
- [Plugin guide](https://github.com/JustFlows/justflows-ce/blob/main/docs/PLUGINS.md)
|
|
87
|
+
- [SDK compatibility and deprecation policy](https://github.com/JustFlows/justflows-ce/blob/main/docs/SDK-COMPATIBILITY.md)
|
|
88
|
+
- [Hooks](https://github.com/JustFlows/justflows-ce/blob/main/docs/HOOKS.md)
|
|
89
|
+
- [Themes](https://github.com/JustFlows/justflows-ce/blob/main/docs/THEMES.md)
|
|
90
|
+
|
|
91
|
+
For a plugin's admin screens, see
|
|
92
|
+
[`@justflows/admin-bridge`](https://www.npmjs.com/package/@justflows/admin-bridge).
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT
|
package/dist/version.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Version of the published `@justflows/sdk` package. */
|
|
2
|
-
export declare const SDK_VERSION = "1.2.
|
|
2
|
+
export declare const SDK_VERSION = "1.2.1";
|
|
3
3
|
/** Major revision of the runtime contract exposed through `PluginContext`. */
|
|
4
4
|
export declare const SDK_API_VERSION = 1;
|
|
5
5
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
/** Version of the published `@justflows/sdk` package. */
|
|
3
|
-
export const SDK_VERSION = "1.2.
|
|
3
|
+
export const SDK_VERSION = "1.2.1";
|
|
4
4
|
/** Major revision of the runtime contract exposed through `PluginContext`. */
|
|
5
5
|
export const SDK_API_VERSION = 1;
|
|
6
6
|
//# sourceMappingURL=version.js.map
|