@camera.ui/browser 0.0.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/CHANGELOG.md +8 -0
- package/LICENSE.md +22 -0
- package/README.md +1 -0
- package/dist/bundle.browser.js +1 -0
- package/dist/client/node/src/api.d.ts +5 -0
- package/dist/client/node/src/api.js +27 -0
- package/dist/client/node/src/api.js.map +1 -0
- package/dist/client/node/src/client.d.ts +20 -0
- package/dist/client/node/src/client.js +106 -0
- package/dist/client/node/src/client.js.map +1 -0
- package/dist/client/node/src/index.d.ts +2 -0
- package/dist/client/node/src/index.js +19 -0
- package/dist/client/node/src/index.js.map +1 -0
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.browser.d.ts +48 -0
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.browser.js +176 -0
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.browser.js.map +1 -0
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.mock.d.ts +1 -0
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.mock.js +3 -0
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.mock.js.map +1 -0
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.node.d.ts +11 -0
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.node.js +51 -0
- package/dist/client/node/src/proxy/cameraDevice/cameraDevice.node.js.map +1 -0
- package/dist/client/node/src/proxy/cameraDevice/index.d.ts +6 -0
- package/dist/client/node/src/proxy/cameraDevice/index.js +11 -0
- package/dist/client/node/src/proxy/cameraDevice/index.js.map +1 -0
- package/dist/client/node/src/proxy/deviceManager.d.ts +15 -0
- package/dist/client/node/src/proxy/deviceManager.js +67 -0
- package/dist/client/node/src/proxy/deviceManager.js.map +1 -0
- package/dist/client/node/src/proxy/index.d.ts +4 -0
- package/dist/client/node/src/proxy/index.js +21 -0
- package/dist/client/node/src/proxy/index.js.map +1 -0
- package/dist/client/node/src/proxy/pluginsManager.d.ts +9 -0
- package/dist/client/node/src/proxy/pluginsManager.js +25 -0
- package/dist/client/node/src/proxy/pluginsManager.js.map +1 -0
- package/dist/client/node/src/proxy/systemManager.d.ts +9 -0
- package/dist/client/node/src/proxy/systemManager.js +25 -0
- package/dist/client/node/src/proxy/systemManager.js.map +1 -0
- package/dist/client/node/src/socket.d.ts +9 -0
- package/dist/client/node/src/socket.js +45 -0
- package/dist/client/node/src/socket.js.map +1 -0
- package/dist/client/node/src/types.d.ts +22 -0
- package/dist/client/node/src/types.js +3 -0
- package/dist/client/node/src/types.js.map +1 -0
- package/dist/package.json +149 -0
- package/dist/shared/common/utils.d.ts +6 -0
- package/dist/shared/common/utils.js +66 -0
- package/dist/shared/common/utils.js.map +1 -0
- package/dist/shared/types/index.d.ts +8 -0
- package/dist/shared/types/index.js +23 -0
- package/dist/shared/types/index.js.map +1 -0
- package/dist/src/api/database/index.d.ts +25 -0
- package/dist/src/api/database/index.js +203 -0
- package/dist/src/api/database/index.js.map +1 -0
- package/dist/src/api/database/types.d.ts +153 -0
- package/dist/src/api/database/types.js +3 -0
- package/dist/src/api/database/types.js.map +1 -0
- package/dist/src/api/go2rtc/api/application.d.ts +8 -0
- package/dist/src/api/go2rtc/api/application.js +32 -0
- package/dist/src/api/go2rtc/api/application.js.map +1 -0
- package/dist/src/api/go2rtc/api/index.d.ts +3 -0
- package/dist/src/api/go2rtc/api/index.js +33 -0
- package/dist/src/api/go2rtc/api/index.js.map +1 -0
- package/dist/src/api/go2rtc/api/snapshot.d.ts +6 -0
- package/dist/src/api/go2rtc/api/snapshot.js +22 -0
- package/dist/src/api/go2rtc/api/snapshot.js.map +1 -0
- package/dist/src/api/go2rtc/api/streams.d.ts +10 -0
- package/dist/src/api/go2rtc/api/streams.js +32 -0
- package/dist/src/api/go2rtc/api/streams.js.map +1 -0
- package/dist/src/api/go2rtc/index.d.ts +3 -0
- package/dist/src/api/go2rtc/index.js +13 -0
- package/dist/src/api/go2rtc/index.js.map +1 -0
- package/dist/src/api/go2rtc/types.d.ts +43 -0
- package/dist/src/api/go2rtc/types.js +3 -0
- package/dist/src/api/go2rtc/types.js.map +1 -0
- package/dist/src/api/middlewares/socketAuth.middleware.d.ts +41 -0
- package/dist/src/api/middlewares/socketAuth.middleware.js +90 -0
- package/dist/src/api/middlewares/socketAuth.middleware.js.map +1 -0
- package/dist/src/api/schemas/backup.schema.d.ts +220 -0
- package/dist/src/api/schemas/backup.schema.js +94 -0
- package/dist/src/api/schemas/backup.schema.js.map +1 -0
- package/dist/src/api/schemas/cameras.schema.d.ts +316 -0
- package/dist/src/api/schemas/cameras.schema.js +124 -0
- package/dist/src/api/schemas/cameras.schema.js.map +1 -0
- package/dist/src/api/schemas/config.schema.d.ts +202 -0
- package/dist/src/api/schemas/config.schema.js +94 -0
- package/dist/src/api/schemas/config.schema.js.map +1 -0
- package/dist/src/api/schemas/go2rtc.schema.d.ts +604 -0
- package/dist/src/api/schemas/go2rtc.schema.js +204 -0
- package/dist/src/api/schemas/go2rtc.schema.js.map +1 -0
- package/dist/src/api/schemas/users.schema.d.ts +515 -0
- package/dist/src/api/schemas/users.schema.js +131 -0
- package/dist/src/api/schemas/users.schema.js.map +1 -0
- package/dist/src/api/services/auth.service.d.ts +20 -0
- package/dist/src/api/services/auth.service.js +104 -0
- package/dist/src/api/services/auth.service.js.map +1 -0
- package/dist/src/api/services/cameras.service.d.ts +40 -0
- package/dist/src/api/services/cameras.service.js +535 -0
- package/dist/src/api/services/cameras.service.js.map +1 -0
- package/dist/src/api/services/plugins.service.d.ts +23 -0
- package/dist/src/api/services/plugins.service.js +115 -0
- package/dist/src/api/services/plugins.service.js.map +1 -0
- package/dist/src/api/services/users.service.d.ts +13 -0
- package/dist/src/api/services/users.service.js +54 -0
- package/dist/src/api/services/users.service.js.map +1 -0
- package/dist/src/api/types/index.d.ts +522 -0
- package/dist/src/api/types/index.js +12 -0
- package/dist/src/api/types/index.js.map +1 -0
- package/dist/src/api/utils/cert.d.ts +17 -0
- package/dist/src/api/utils/cert.js +437 -0
- package/dist/src/api/utils/cert.js.map +1 -0
- package/dist/src/api/ws/index.d.ts +15 -0
- package/dist/src/api/ws/index.js +89 -0
- package/dist/src/api/ws/index.js.map +1 -0
- package/dist/src/api/ws/nsp/logs.d.ts +11 -0
- package/dist/src/api/ws/nsp/logs.js +121 -0
- package/dist/src/api/ws/nsp/logs.js.map +1 -0
- package/dist/src/api/ws/nsp/main.d.ts +9 -0
- package/dist/src/api/ws/nsp/main.js +49 -0
- package/dist/src/api/ws/nsp/main.js.map +1 -0
- package/dist/src/api/ws/nsp/metrics.d.ts +33 -0
- package/dist/src/api/ws/nsp/metrics.js +225 -0
- package/dist/src/api/ws/nsp/metrics.js.map +1 -0
- package/dist/src/api/ws/nsp/notifications.d.ts +11 -0
- package/dist/src/api/ws/nsp/notifications.js +39 -0
- package/dist/src/api/ws/nsp/notifications.js.map +1 -0
- package/dist/src/api/ws/nsp/plugins.d.ts +13 -0
- package/dist/src/api/ws/nsp/plugins.js +33 -0
- package/dist/src/api/ws/nsp/plugins.js.map +1 -0
- package/dist/src/api/ws/nsp/status.d.ts +12 -0
- package/dist/src/api/ws/nsp/status.js +41 -0
- package/dist/src/api/ws/nsp/status.js.map +1 -0
- package/dist/src/api/ws/nsp/streams.d.ts +30 -0
- package/dist/src/api/ws/nsp/streams.js +140 -0
- package/dist/src/api/ws/nsp/streams.js.map +1 -0
- package/dist/src/api/ws/types.d.ts +82 -0
- package/dist/src/api/ws/types.js +3 -0
- package/dist/src/api/ws/types.js.map +1 -0
- package/dist/src/api.d.ts +60 -0
- package/dist/src/api.js +66 -0
- package/dist/src/api.js.map +1 -0
- package/dist/src/camera/index.d.ts +54 -0
- package/dist/src/camera/index.js +210 -0
- package/dist/src/camera/index.js.map +1 -0
- package/dist/src/camera/streaming/peer-connection.d.ts +31 -0
- package/dist/src/camera/streaming/peer-connection.js +157 -0
- package/dist/src/camera/streaming/peer-connection.js.map +1 -0
- package/dist/src/camera/streaming/streaming-session.d.ts +32 -0
- package/dist/src/camera/streaming/streaming-session.js +172 -0
- package/dist/src/camera/streaming/streaming-session.js.map +1 -0
- package/dist/src/camera/streaming/webrtc-connection.d.ts +33 -0
- package/dist/src/camera/streaming/webrtc-connection.js +156 -0
- package/dist/src/camera/streaming/webrtc-connection.js.map +1 -0
- package/dist/src/camera/subscribed.d.ts +6 -0
- package/dist/src/camera/subscribed.js +14 -0
- package/dist/src/camera/subscribed.js.map +1 -0
- package/dist/src/camera/types.d.ts +130 -0
- package/dist/src/camera/types.js +3 -0
- package/dist/src/camera/types.js.map +1 -0
- package/dist/src/go2rtc/index.d.ts +24 -0
- package/dist/src/go2rtc/index.js +220 -0
- package/dist/src/go2rtc/index.js.map +1 -0
- package/dist/src/go2rtc/types.d.ts +14 -0
- package/dist/src/go2rtc/types.js +76 -0
- package/dist/src/go2rtc/types.js.map +1 -0
- package/dist/src/plugins/base.d.ts +19 -0
- package/dist/src/plugins/base.js +26 -0
- package/dist/src/plugins/base.js.map +1 -0
- package/dist/src/plugins/cameraStorage.d.ts +97 -0
- package/dist/src/plugins/cameraStorage.js +290 -0
- package/dist/src/plugins/cameraStorage.js.map +1 -0
- package/dist/src/plugins/child.d.ts +18 -0
- package/dist/src/plugins/child.js +140 -0
- package/dist/src/plugins/child.js.map +1 -0
- package/dist/src/plugins/config.d.ts +113 -0
- package/dist/src/plugins/config.js +234 -0
- package/dist/src/plugins/config.js.map +1 -0
- package/dist/src/plugins/index.d.ts +36 -0
- package/dist/src/plugins/index.js +328 -0
- package/dist/src/plugins/index.js.map +1 -0
- package/dist/src/plugins/plugin.d.ts +47 -0
- package/dist/src/plugins/plugin.js +215 -0
- package/dist/src/plugins/plugin.js.map +1 -0
- package/dist/src/plugins/schema.d.ts +268 -0
- package/dist/src/plugins/schema.js +717 -0
- package/dist/src/plugins/schema.js.map +1 -0
- package/dist/src/plugins/storage.d.ts +28 -0
- package/dist/src/plugins/storage.js +45 -0
- package/dist/src/plugins/storage.js.map +1 -0
- package/dist/src/plugins/types.d.ts +162 -0
- package/dist/src/plugins/types.js +21 -0
- package/dist/src/plugins/types.js.map +1 -0
- package/dist/src/plugins/worker.d.ts +27 -0
- package/dist/src/plugins/worker.js +236 -0
- package/dist/src/plugins/worker.js.map +1 -0
- package/dist/src/proxy/client/cameraDevice.d.ts +29 -0
- package/dist/src/proxy/client/cameraDevice.js +171 -0
- package/dist/src/proxy/client/cameraDevice.js.map +1 -0
- package/dist/src/proxy/client/deviceManager.d.ts +40 -0
- package/dist/src/proxy/client/deviceManager.js +239 -0
- package/dist/src/proxy/client/deviceManager.js.map +1 -0
- package/dist/src/proxy/client/index.d.ts +4 -0
- package/dist/src/proxy/client/index.js +21 -0
- package/dist/src/proxy/client/index.js.map +1 -0
- package/dist/src/proxy/client/pluginsManager.d.ts +35 -0
- package/dist/src/proxy/client/pluginsManager.js +237 -0
- package/dist/src/proxy/client/pluginsManager.js.map +1 -0
- package/dist/src/proxy/client/systemManager.d.ts +29 -0
- package/dist/src/proxy/client/systemManager.js +163 -0
- package/dist/src/proxy/client/systemManager.js.map +1 -0
- package/dist/src/proxy/index.d.ts +20 -0
- package/dist/src/proxy/index.js +98 -0
- package/dist/src/proxy/index.js.map +1 -0
- package/dist/src/proxy/proxies/camera.d.ts +26 -0
- package/dist/src/proxy/proxies/camera.js +72 -0
- package/dist/src/proxy/proxies/camera.js.map +1 -0
- package/dist/src/proxy/proxies/plugin.d.ts +30 -0
- package/dist/src/proxy/proxies/plugin.js +110 -0
- package/dist/src/proxy/proxies/plugin.js.map +1 -0
- package/dist/src/proxy/proxies/server.d.ts +34 -0
- package/dist/src/proxy/proxies/server.js +92 -0
- package/dist/src/proxy/proxies/server.js.map +1 -0
- package/dist/src/proxy/types.d.ts +189 -0
- package/dist/src/proxy/types.js +3 -0
- package/dist/src/proxy/types.js.map +1 -0
- package/dist/src/proxy/utils/generateKeys.d.ts +5 -0
- package/dist/src/proxy/utils/generateKeys.js +13 -0
- package/dist/src/proxy/utils/generateKeys.js.map +1 -0
- package/dist/src/proxy/ws/index.d.ts +21 -0
- package/dist/src/proxy/ws/index.js +75 -0
- package/dist/src/proxy/ws/index.js.map +1 -0
- package/dist/src/services/config/index.d.ts +60 -0
- package/dist/src/services/config/index.js +319 -0
- package/dist/src/services/config/index.js.map +1 -0
- package/dist/src/services/config/types.d.ts +153 -0
- package/dist/src/services/config/types.js +13 -0
- package/dist/src/services/config/types.js.map +1 -0
- package/dist/src/services/logger/index.d.ts +37 -0
- package/dist/src/services/logger/index.js +181 -0
- package/dist/src/services/logger/index.js.map +1 -0
- package/package.json +46 -0
- package/webpack.config.js +29 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @url https://github.com/homebridge/homebridge/blob/src/plugin.ts
|
|
4
|
+
* (c) Homebridge <https://github.com/homebridge>
|
|
5
|
+
*
|
|
6
|
+
**/
|
|
7
|
+
import { PluginConfigService } from './config';
|
|
8
|
+
import type { CameraUiAPI, PluginConstructor } from '../api';
|
|
9
|
+
import type { IPackageJson, CameraUiPlugin } from '../api/types';
|
|
10
|
+
import type { PluginContract } from './types';
|
|
11
|
+
export interface Context {
|
|
12
|
+
engines?: Record<string, string>;
|
|
13
|
+
dependencies?: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents a loaded camera.ui plugin.
|
|
17
|
+
*/
|
|
18
|
+
export declare class Plugin {
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
private logger;
|
|
21
|
+
private configService;
|
|
22
|
+
private _info;
|
|
23
|
+
private _contract;
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly pluginName: string;
|
|
26
|
+
readonly displayName: string;
|
|
27
|
+
readonly scope?: string;
|
|
28
|
+
private readonly isESM;
|
|
29
|
+
config: PluginConfigService;
|
|
30
|
+
readonly isSymLink: boolean;
|
|
31
|
+
readonly installPath: string;
|
|
32
|
+
readonly configFile: string;
|
|
33
|
+
readonly storagePath: string;
|
|
34
|
+
private readonly main;
|
|
35
|
+
private loadContext?;
|
|
36
|
+
private pluginInitializer?;
|
|
37
|
+
private pluginConstructor;
|
|
38
|
+
get info(): CameraUiPlugin;
|
|
39
|
+
get contract(): PluginContract;
|
|
40
|
+
constructor(pluginName: string, installPath: string, packageJSON: IPackageJson, pluginId: string, scope?: string, storagePath?: string);
|
|
41
|
+
getPluginConstructor(pluginName: string): PluginConstructor;
|
|
42
|
+
initialize(api: CameraUiAPI): void | Promise<void>;
|
|
43
|
+
load(): Promise<void>;
|
|
44
|
+
registerPlugin(constructor: PluginConstructor, contract: PluginContract): void;
|
|
45
|
+
reparsePackageJson(): CameraUiPlugin;
|
|
46
|
+
private parsePackageJson;
|
|
47
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @url https://github.com/homebridge/homebridge/blob/src/plugin.ts
|
|
5
|
+
* (c) Homebridge <https://github.com/homebridge>
|
|
6
|
+
*
|
|
7
|
+
**/
|
|
8
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
9
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
|
+
};
|
|
14
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.Plugin = void 0;
|
|
22
|
+
const assert_1 = __importDefault(require("assert"));
|
|
23
|
+
const compare_versions_1 = __importDefault(require("compare-versions"));
|
|
24
|
+
const path_1 = __importDefault(require("path"));
|
|
25
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
26
|
+
const url_1 = require("url");
|
|
27
|
+
const tsyringe_1 = require("tsyringe");
|
|
28
|
+
const _1 = require(".");
|
|
29
|
+
const config_1 = require("./config");
|
|
30
|
+
const config_2 = require("../services/config");
|
|
31
|
+
// Workaround for https://github.com/microsoft/TypeScript/issues/43329
|
|
32
|
+
const _importDynamic = new Function('modulePath', 'return import(modulePath)');
|
|
33
|
+
/**
|
|
34
|
+
* Represents a loaded camera.ui plugin.
|
|
35
|
+
*/
|
|
36
|
+
let Plugin = class Plugin {
|
|
37
|
+
disabled = false;
|
|
38
|
+
logger;
|
|
39
|
+
configService;
|
|
40
|
+
// private _id!: string;
|
|
41
|
+
_info;
|
|
42
|
+
_contract;
|
|
43
|
+
id;
|
|
44
|
+
pluginName;
|
|
45
|
+
displayName;
|
|
46
|
+
scope;
|
|
47
|
+
isESM;
|
|
48
|
+
config;
|
|
49
|
+
isSymLink;
|
|
50
|
+
installPath;
|
|
51
|
+
configFile;
|
|
52
|
+
storagePath;
|
|
53
|
+
main;
|
|
54
|
+
loadContext;
|
|
55
|
+
pluginInitializer; // default exported function from the plugin that initializes it
|
|
56
|
+
pluginConstructor = new Map();
|
|
57
|
+
get info() {
|
|
58
|
+
return this._info;
|
|
59
|
+
}
|
|
60
|
+
get contract() {
|
|
61
|
+
return this._contract;
|
|
62
|
+
}
|
|
63
|
+
constructor(pluginName, installPath, packageJSON, pluginId, scope, storagePath) {
|
|
64
|
+
this.logger = tsyringe_1.container.resolve('logger');
|
|
65
|
+
this.configService = tsyringe_1.container.resolve('configService');
|
|
66
|
+
this.id = pluginId;
|
|
67
|
+
this._info = this.parsePackageJson(packageJSON, installPath);
|
|
68
|
+
this.pluginName = pluginName;
|
|
69
|
+
this.displayName = this.info.displayName;
|
|
70
|
+
this.scope = scope;
|
|
71
|
+
this.installPath = installPath;
|
|
72
|
+
this.main = '';
|
|
73
|
+
this.isSymLink = fs_extra_1.default.lstatSync(this.installPath).isSymbolicLink();
|
|
74
|
+
this.storagePath = path_1.default.resolve(storagePath || this.configService.PLUGINS_STORAGE_PATH, this.pluginName);
|
|
75
|
+
this.configFile = path_1.default.resolve(this.storagePath, 'config.json');
|
|
76
|
+
this.config = new config_1.PluginConfigService(this.configFile);
|
|
77
|
+
// figure out the main module
|
|
78
|
+
// exports is available - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_package_entry_points
|
|
79
|
+
if (packageJSON.exports) {
|
|
80
|
+
// main entrypoint - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_main_entry_point_export
|
|
81
|
+
if (typeof packageJSON.exports === 'string') {
|
|
82
|
+
this.main = packageJSON.exports;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// subpath export - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_subpath_exports
|
|
86
|
+
// conditional exports - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_conditional_exports
|
|
87
|
+
const exports = packageJSON.exports.import || packageJSON.exports.require || packageJSON.exports.node || packageJSON.exports.default || packageJSON.exports['.'];
|
|
88
|
+
// check if conditional export is nested
|
|
89
|
+
if (typeof exports !== 'string') {
|
|
90
|
+
if (exports.import) {
|
|
91
|
+
this.main = exports.import;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.main = exports.require || exports.node || exports.default;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.main = exports;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// exports search was not successful, fallback to package.main, using index.js as fallback
|
|
103
|
+
if (!this.main) {
|
|
104
|
+
this.main = packageJSON.main || './index.js';
|
|
105
|
+
}
|
|
106
|
+
// check if it is a ESM module
|
|
107
|
+
this.isESM = this.main.endsWith('.mjs') || (this.main.endsWith('.js') && packageJSON.type === 'module');
|
|
108
|
+
this.loadContext = {
|
|
109
|
+
engines: packageJSON.engines,
|
|
110
|
+
dependencies: packageJSON.dependencies,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
getPluginConstructor(pluginName) {
|
|
114
|
+
const constructor = this.pluginConstructor.get(pluginName);
|
|
115
|
+
if (!constructor) {
|
|
116
|
+
throw new Error(`The requested plugin '${pluginName}' was not registered by the plugin '${this.pluginName}'.`);
|
|
117
|
+
}
|
|
118
|
+
return constructor;
|
|
119
|
+
}
|
|
120
|
+
initialize(api) {
|
|
121
|
+
if (!this.pluginInitializer) {
|
|
122
|
+
throw new Error("Tried to initialize a plugin which hasn't been loaded yet!");
|
|
123
|
+
}
|
|
124
|
+
return this.pluginInitializer(api);
|
|
125
|
+
}
|
|
126
|
+
async load() {
|
|
127
|
+
const context = this.loadContext;
|
|
128
|
+
(0, assert_1.default)(context, 'Reached illegal state. Plugin state is undefined!');
|
|
129
|
+
this.loadContext = undefined;
|
|
130
|
+
// pluck out the camera.ui version requirement
|
|
131
|
+
if (!context.engines || !context.engines['camera.ui']) {
|
|
132
|
+
throw new Error(`Plugin ${this.installPath} does not contain the 'camera.ui' package in 'engines'.`);
|
|
133
|
+
}
|
|
134
|
+
const versionRequired = context.engines['camera.ui'];
|
|
135
|
+
const nodeVersionRequired = context.engines.node;
|
|
136
|
+
// make sure the version is satisfied by the currently running version of camera.ui
|
|
137
|
+
if (!compare_versions_1.default.compare(config_2.ConfigService.VERSION.replace(/[^\d.]/g, ''), versionRequired.replace(/[^\d.]/g, ''), '>=')) {
|
|
138
|
+
this.logger.warn(`The plugin "${this.pluginName}" requires a camera.ui version of ${versionRequired} which does \
|
|
139
|
+
not satisfy the current camera.ui version of ${config_2.ConfigService.VERSION}. You may need to update this plugin (or camera.ui) to a newer version. \
|
|
140
|
+
You may face unexpected issues or stability problems running this plugin.`);
|
|
141
|
+
}
|
|
142
|
+
// make sure the version is satisfied by the currently running version of Node
|
|
143
|
+
if (nodeVersionRequired && !compare_versions_1.default.compare(process.version, nodeVersionRequired.replace(/[^\d.]/g, ''), '>=')) {
|
|
144
|
+
this.logger.warn(`The plugin "${this.pluginName}" requires Node.js version of ${nodeVersionRequired} which does \
|
|
145
|
+
not satisfy the current Node.js version of ${process.version}. You may need to upgrade your installation of Node.js`);
|
|
146
|
+
}
|
|
147
|
+
const dependencies = context.dependencies || {};
|
|
148
|
+
if (dependencies['camera.ui']) {
|
|
149
|
+
this.logger.error(`The plugin "${this.pluginName}" defines 'camera.ui' in their 'dependencies' section, \
|
|
150
|
+
meaning they carry an additional copy of camera.ui. This not only wastes disk space, but also can cause \
|
|
151
|
+
major incompatibility issues and thus is considered bad practice. Please inform the developer to update their plugin!`);
|
|
152
|
+
}
|
|
153
|
+
const mainPath = path_1.default.join(this.installPath, this.main);
|
|
154
|
+
const pluginModules = this.isESM ? await _importDynamic((0, url_1.pathToFileURL)(mainPath).href) : require(mainPath);
|
|
155
|
+
if (typeof pluginModules === 'function') {
|
|
156
|
+
this.pluginInitializer = pluginModules;
|
|
157
|
+
}
|
|
158
|
+
else if (pluginModules && typeof pluginModules.default === 'function') {
|
|
159
|
+
this.pluginInitializer = pluginModules.default;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
throw new Error(`Plugin ${this.installPath} does not export a initializer function from main.`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
registerPlugin(constructor, contract) {
|
|
166
|
+
if (this.pluginConstructor.has(contract.pluginName)) {
|
|
167
|
+
throw new Error(`Plugin '${contract.pluginName}' tried to register '${contract.pluginName}' which has already been registered!`);
|
|
168
|
+
}
|
|
169
|
+
this._contract = {
|
|
170
|
+
// displayName: contract.displayName,
|
|
171
|
+
pluginName: contract.pluginName,
|
|
172
|
+
builtIns: contract.builtIns || [],
|
|
173
|
+
extension: contract.extension,
|
|
174
|
+
};
|
|
175
|
+
this.pluginConstructor.set(contract.pluginName, constructor);
|
|
176
|
+
}
|
|
177
|
+
reparsePackageJson() {
|
|
178
|
+
const pjson = _1.PluginManager.loadPackageJSON(this.installPath);
|
|
179
|
+
this._info = this.parsePackageJson(pjson, this.installPath);
|
|
180
|
+
return this._info;
|
|
181
|
+
}
|
|
182
|
+
parsePackageJson(pjson, installPath) {
|
|
183
|
+
const pluginPackageJson = {
|
|
184
|
+
id: this.id,
|
|
185
|
+
disabled: this.configService.config?.plugins?.disabledPlugins?.includes(this.pluginName) || false,
|
|
186
|
+
private: pjson.private || false,
|
|
187
|
+
pluginName: pjson.name,
|
|
188
|
+
displayName: pjson.displayName || _1.PluginManager.transformDisplaName(pjson.name),
|
|
189
|
+
author: pjson.author ? (typeof pjson.author === 'string' ? pjson.author : pjson.author.name) : undefined,
|
|
190
|
+
description: pjson.description ? pjson.description.replace(/(?:https?|ftp):\/\/[\n\S]+/g, '').trim() : pjson.name,
|
|
191
|
+
installedVersion: pjson.version || '0.0.0',
|
|
192
|
+
latestVersion: pjson.version || '0.0.0',
|
|
193
|
+
globalInstall: false,
|
|
194
|
+
publicPackage: pjson.private || false,
|
|
195
|
+
engines: pjson.engines,
|
|
196
|
+
installPath,
|
|
197
|
+
links: {
|
|
198
|
+
npm: `https://www.npmjs.com/package/${this.pluginName}`,
|
|
199
|
+
homepage: pjson.homepage,
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
return pluginPackageJson;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
exports.Plugin = Plugin;
|
|
206
|
+
exports.Plugin = Plugin = __decorate([
|
|
207
|
+
(0, tsyringe_1.registry)([
|
|
208
|
+
{
|
|
209
|
+
token: 'configService',
|
|
210
|
+
useValue: (0, tsyringe_1.delay)(() => config_2.ConfigService),
|
|
211
|
+
},
|
|
212
|
+
]),
|
|
213
|
+
__metadata("design:paramtypes", [String, String, Object, String, String, String])
|
|
214
|
+
], Plugin);
|
|
215
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../../src/plugins/plugin.ts"],"names":[],"mappings":";AAAA;;;;;IAKI;;;;;;;;;;;;;;;AAEJ,oDAA4B;AAC5B,wEAA+C;AAC/C,gDAAwB;AACxB,wDAA0B;AAC1B,6BAAoC;AACpC,uCAAsD;AAEtD,wBAAkC;AAClC,qCAA+C;AAC/C,+CAAmD;AAanD,sEAAsE;AACtE,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAC,CAAC;AAE/E;;GAEG;AAOI,IAAM,MAAM,GAAZ,MAAM,MAAM;IACV,QAAQ,GAAG,KAAK,CAAC;IAEhB,MAAM,CAAS;IACf,aAAa,CAAgB;IAErC,wBAAwB;IAChB,KAAK,CAAkB;IACvB,SAAS,CAAkB;IAEnB,EAAE,CAAS;IAEX,UAAU,CAAS;IACnB,WAAW,CAAS;IACpB,KAAK,CAAU;IACd,KAAK,CAAU;IAEzB,MAAM,CAAsB;IAEnB,SAAS,CAAU;IACnB,WAAW,CAAS;IACpB,UAAU,CAAS;IACnB,WAAW,CAAS;IAEnB,IAAI,CAAS;IACtB,WAAW,CAAW;IAEtB,iBAAiB,CAAqB,CAAC,gEAAgE;IACvG,iBAAiB,GAAG,IAAI,GAAG,EAA6B,CAAC;IAEjE,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,YAAY,UAAkB,EAAE,WAAmB,EAAE,WAAyB,EAAE,QAAgB,EAAE,KAAc,EAAE,WAAoB;QACpI,IAAI,CAAC,MAAM,GAAG,oBAAS,CAAC,OAAO,CAAS,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,oBAA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C,6BAA6B,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;YACjH,gBAAgB,EAAE,KAAK,CAAC,OAAO,IAAI,OAAO;YAC1C,aAAa,EAAE,KAAK,CAAC,OAAO,IAAI,OAAO;YACvC,aAAa,EAAE,KAAK;YACpB,aAAa,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK;YACrC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,WAAW;YACX,KAAK,EAAE;gBACL,GAAG,EAAE,iCAAiC,IAAI,CAAC,UAAU,EAAE;gBACvD,QAAQ,EAAE,KAAK,CAAC,QAAQ;aACzB;SACF,CAAC;QAEF,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF,CAAA;AA5MY,wBAAM;iBAAN,MAAM;IANlB,IAAA,mBAAQ,EAAC;QACR;YACE,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE,IAAA,gBAAK,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC;SACrC;KACF,CAAC;;GACW,MAAM,CA4MlB"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { type ZodTypeAny, z } from 'zod';
|
|
2
|
+
import type { RootSchema, JsonSchema, JsonSchemaString, JsonSchemaAnyOf, JsonSchemaArray, JsonSchemaBoolean, JsonSchemaButton, JsonSchemaEnum, JsonSchemaNumber, JsonSchemaObject, JsonSchemaObjectWithButtons, PluginJsonSchema, PluginRootSchema, PluginJsonSchemaForm } from './types';
|
|
3
|
+
type RootZodSchema = z.ZodObject<Record<string, ZodTypeAny>, 'strict', ZodTypeAny, {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
}, {
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
}>;
|
|
8
|
+
type OptionalZodString = z.ZodOptional<z.ZodString> | z.ZodString | z.ZodOptional<z.ZodEffects<z.ZodString, string, string>> | z.ZodEffects<z.ZodString, string, string>;
|
|
9
|
+
type OptionalZodNumber = z.ZodOptional<z.ZodNumber> | z.ZodNumber | z.ZodOptional<z.ZodEffects<z.ZodNumber, number, number>> | z.ZodEffects<z.ZodNumber, number, number>;
|
|
10
|
+
type OptionalZodBoolean = z.ZodOptional<z.ZodBoolean> | z.ZodBoolean;
|
|
11
|
+
type OptionalZodZobject = z.ZodOptional<z.ZodObject<Record<string, z.ZodTypeAny>, 'strict', z.ZodTypeAny, {
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
}, {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
}>> | z.ZodObject<Record<string, z.ZodTypeAny>, 'strict', z.ZodTypeAny, {
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
}, {
|
|
18
|
+
[x: string]: any;
|
|
19
|
+
}> | z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>> | z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
20
|
+
type OptionalZodArray = z.ZodOptional<z.ZodType<any, any, any>> | z.ZodType<any, any, any>;
|
|
21
|
+
type OptionalZodEnum = z.ZodOptional<z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>> | z.ZodUnion<[z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>;
|
|
22
|
+
type OptionalZodEnumMultiple = z.ZodOptional<z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'>> | z.ZodArray<z.ZodUnion<[ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>, 'many'>;
|
|
23
|
+
type ZodAny = z.ZodType<any, any, any>;
|
|
24
|
+
/**
|
|
25
|
+
* Generate root JSON schema from value.
|
|
26
|
+
*
|
|
27
|
+
* @param value - Value.
|
|
28
|
+
* @returns - Root JSON schema.
|
|
29
|
+
*/
|
|
30
|
+
export declare const generateRootSchema: (value: Record<string, any>) => RootSchema;
|
|
31
|
+
/**
|
|
32
|
+
* Generate JSON schema from value.
|
|
33
|
+
*
|
|
34
|
+
* @param value - Value.
|
|
35
|
+
* @returns - JSON schema.
|
|
36
|
+
*/
|
|
37
|
+
export declare const generateSchema: (value: any) => JsonSchema;
|
|
38
|
+
/**
|
|
39
|
+
* Generate a JSON object from a given Root JSON schema.
|
|
40
|
+
*
|
|
41
|
+
* @param rootSchema - The Root JSON schema.
|
|
42
|
+
* @returns - The generated JSON object.
|
|
43
|
+
*/
|
|
44
|
+
export declare const generateJsonFromRootSchema: (rootSchema: RootSchema | PluginRootSchema) => Record<string, any>;
|
|
45
|
+
/**
|
|
46
|
+
* Generate a JSON object from a JSON schema.
|
|
47
|
+
*
|
|
48
|
+
* @param jsonSchema - The JSON schema.
|
|
49
|
+
* @returns - The generated JSON object.
|
|
50
|
+
*/
|
|
51
|
+
export declare const generateJsonFromSchema: (jsonSchema: JsonSchema | PluginJsonSchema) => any;
|
|
52
|
+
/**
|
|
53
|
+
* Generate a JSON object from a given JSON schema and use values from a config file.
|
|
54
|
+
*
|
|
55
|
+
* @param jsonSchema - The JSON schema.
|
|
56
|
+
* @param config - The config file with values to use.
|
|
57
|
+
* @returns - The generated JSON object.
|
|
58
|
+
*/
|
|
59
|
+
export declare const generateJsonFromSchemaWithConfig: (jsonSchema: JsonSchema | PluginJsonSchema, config: Record<string, any>, path?: string) => any;
|
|
60
|
+
/**
|
|
61
|
+
* Removes all functions from a given Plugin JSON schema form.
|
|
62
|
+
*
|
|
63
|
+
* @param schemaForm - The Plugin JSON schema form from which the functions should be removed.
|
|
64
|
+
* @returns - The Plugin JSON schema form without functions.
|
|
65
|
+
*/
|
|
66
|
+
export declare const removeFunctionsFromSchemaForm: (schemaForm: PluginJsonSchemaForm) => PluginJsonSchemaForm;
|
|
67
|
+
/**
|
|
68
|
+
* Removes all functions from a given Plugin JSON schema.
|
|
69
|
+
*
|
|
70
|
+
* @param jsonSchema - The JSON schema from which the functions should be removed.
|
|
71
|
+
* @returns - The JSON schema without functions.
|
|
72
|
+
*/
|
|
73
|
+
export declare const removeFunctionsFromSchema: (jsonSchema: PluginJsonSchema) => PluginJsonSchema;
|
|
74
|
+
/**
|
|
75
|
+
* Converts a config path to a schema path.
|
|
76
|
+
*
|
|
77
|
+
* @param configPath - The config path to be converted.
|
|
78
|
+
* @returns - The converted schema path.
|
|
79
|
+
*/
|
|
80
|
+
export declare const configPathToSchemaPath: (configPath: string) => string;
|
|
81
|
+
/**
|
|
82
|
+
* Converts a schema path to a config path.
|
|
83
|
+
*
|
|
84
|
+
* @param schemaPath - The schema path to be converted.
|
|
85
|
+
* @returns - The converted config path.
|
|
86
|
+
*/
|
|
87
|
+
export declare const schemaPathToConfigPath: (schemaPath: string) => string;
|
|
88
|
+
/**
|
|
89
|
+
* Recursively searches a JSON object for a specific, potentially nested key path and returns its value.
|
|
90
|
+
*
|
|
91
|
+
* @param obj - The JSON object to be searched.
|
|
92
|
+
* @param path - The key path to search for.
|
|
93
|
+
* @returns - The value of the searched key path, if found, otherwise undefined.
|
|
94
|
+
*/
|
|
95
|
+
export declare const getValueByPath: (obj: any, path: string) => any;
|
|
96
|
+
/**
|
|
97
|
+
* Generates a Zod schema from a given JSON schema.
|
|
98
|
+
*
|
|
99
|
+
* @param jsonSchema - The JSON schema from which the Zod schema should be generated.
|
|
100
|
+
* @returns - The generated Zod schema.
|
|
101
|
+
*/
|
|
102
|
+
export declare const generateZodSchemaFromRoot: (rootSchema: RootSchema) => RootZodSchema;
|
|
103
|
+
/**
|
|
104
|
+
* Generates a Zod schema from a given JSON schema.
|
|
105
|
+
*
|
|
106
|
+
* @param jsonSchema - The JSON schema from which the Zod schema should be generated.
|
|
107
|
+
* @param initial - A boolean indicating whether this is the initial call to the function.
|
|
108
|
+
* This is used for handling nested schemas.
|
|
109
|
+
* @returns - The generated Zod schema.
|
|
110
|
+
*/
|
|
111
|
+
export declare const generateZodSchema: (jsonSchema: JsonSchema) => ZodAny;
|
|
112
|
+
/**
|
|
113
|
+
* Generates a JSON schema for a number.
|
|
114
|
+
*
|
|
115
|
+
* @param value - The number for which the JSON schema should be generated.
|
|
116
|
+
* @returns - The generated JSON schema for the number.
|
|
117
|
+
*/
|
|
118
|
+
export declare const generateNumberSchema: (value: number) => JsonSchemaNumber;
|
|
119
|
+
/**
|
|
120
|
+
* Generates a JSON schema for a boolean.
|
|
121
|
+
*
|
|
122
|
+
* @param value - The boolean for which the JSON schema should be generated.
|
|
123
|
+
* @returns - The generated JSON schema for the boolean.
|
|
124
|
+
*/
|
|
125
|
+
export declare const genereateBooleanSchema: (value: boolean) => JsonSchemaBoolean;
|
|
126
|
+
/**
|
|
127
|
+
* Generates a JSON schema for a string.
|
|
128
|
+
*
|
|
129
|
+
* @param value - The string for which the JSON schema should be generated.
|
|
130
|
+
* @returns - The generated JSON schema for the string.
|
|
131
|
+
*/
|
|
132
|
+
export declare const generateStringSchema: (value: string) => JsonSchemaString;
|
|
133
|
+
/**
|
|
134
|
+
* Generates a JSON schema for an enum.
|
|
135
|
+
*
|
|
136
|
+
* @param value - The enum for which the JSON schema should be generated.
|
|
137
|
+
* @param type - The type of the enum.
|
|
138
|
+
* @returns - The generated JSON schema for the enum.
|
|
139
|
+
*/
|
|
140
|
+
export declare const generateEnumSchema: (value: (string | number | boolean)[], type: 'string' | 'number' | 'boolean') => JsonSchemaEnum;
|
|
141
|
+
/**
|
|
142
|
+
* Generates a JSON schema for an object.
|
|
143
|
+
*
|
|
144
|
+
* @param value - The object for which the JSON schema should be generated.
|
|
145
|
+
* @returns - The generated JSON schema for the object.
|
|
146
|
+
*/
|
|
147
|
+
export declare const generateObjectSchema: (value: Record<string, any>) => JsonSchemaObject;
|
|
148
|
+
/**
|
|
149
|
+
* Generates a JSON schema for an object including up to two buttons.
|
|
150
|
+
*
|
|
151
|
+
* @param value - The object for which the JSON schema should be generated.
|
|
152
|
+
* @param buttons - Array of min one button and up to two buttons to be included in the schema.
|
|
153
|
+
* @returns - The generated JSON schema for the object.
|
|
154
|
+
*/
|
|
155
|
+
export declare const generateObjectSchemaWithButtons: (value: Record<string, any>, buttons: [JsonSchemaButton, JsonSchemaButton?]) => JsonSchemaObjectWithButtons;
|
|
156
|
+
/**
|
|
157
|
+
* Generates a JSON schema for an array.
|
|
158
|
+
*
|
|
159
|
+
* @param array - The array for which the JSON schema should be generated.
|
|
160
|
+
* @returns - The generated JSON schema for the array.
|
|
161
|
+
*/
|
|
162
|
+
export declare const generateArraySchema: (array: any[]) => JsonSchemaArray;
|
|
163
|
+
/**
|
|
164
|
+
* Checks if the given JSON schema is of string type.
|
|
165
|
+
*
|
|
166
|
+
* @param jsonSchema - The JSON schema to check.
|
|
167
|
+
* @returns - True if the JSON schema is of string type, false otherwise.
|
|
168
|
+
*/
|
|
169
|
+
export declare const isStringType: (jsonSchema: Partial<JsonSchema>) => jsonSchema is JsonSchemaString;
|
|
170
|
+
/**
|
|
171
|
+
* Checks if the given JSON schema is of number type.
|
|
172
|
+
*
|
|
173
|
+
* @param jsonSchema - The JSON schema to check.
|
|
174
|
+
* @returns - True if the JSON schema is of number type, false otherwise.
|
|
175
|
+
*/
|
|
176
|
+
export declare const isNumberType: (jsonSchema: Partial<JsonSchema>) => jsonSchema is JsonSchemaNumber;
|
|
177
|
+
/**
|
|
178
|
+
* Checks if the given JSON schema is of boolean type.
|
|
179
|
+
*
|
|
180
|
+
* @param jsonSchema - The JSON schema to check.
|
|
181
|
+
* @returns - True if the JSON schema is of boolean type, false otherwise.
|
|
182
|
+
*/
|
|
183
|
+
export declare const isBooleanType: (jsonSchema: Partial<JsonSchema>) => jsonSchema is JsonSchemaBoolean;
|
|
184
|
+
/**
|
|
185
|
+
* Checks if the given JSON schema is of enum type.
|
|
186
|
+
*
|
|
187
|
+
* @param jsonSchema - The JSON schema to check.
|
|
188
|
+
* @returns - True if the JSON schema is of enum type, false otherwise.
|
|
189
|
+
*/
|
|
190
|
+
export declare const isEnumType: (jsonSchema: Partial<JsonSchema>) => jsonSchema is JsonSchemaEnum;
|
|
191
|
+
/**
|
|
192
|
+
* Checks if the given JSON schema is of object type.
|
|
193
|
+
*
|
|
194
|
+
* @param jsonSchema - The JSON schema to check.
|
|
195
|
+
* @returns - True if the JSON schema is of object type, false otherwise.
|
|
196
|
+
*/
|
|
197
|
+
export declare const isObjectType: (jsonSchema: Partial<JsonSchema>) => jsonSchema is JsonSchemaObject;
|
|
198
|
+
/**
|
|
199
|
+
* Checks if the given JSON schema is of object type with buttons.
|
|
200
|
+
*
|
|
201
|
+
* @param jsonSchema - The JSON schema to check.
|
|
202
|
+
* @returns - True if the JSON schema is of object type with buttons, false otherwise.
|
|
203
|
+
*/
|
|
204
|
+
export declare const isObjectTypeWithButtons: (jsonSchema: Partial<JsonSchema>) => jsonSchema is JsonSchemaObjectWithButtons;
|
|
205
|
+
/**
|
|
206
|
+
* Checks if the given JSON schema is of array type.
|
|
207
|
+
*
|
|
208
|
+
* @param jsonSchema - The JSON schema to check.
|
|
209
|
+
* @returns - True if the JSON schema is of array type, false otherwise.
|
|
210
|
+
*/
|
|
211
|
+
export declare const isArrayType: (jsonSchema: Partial<JsonSchema>) => jsonSchema is JsonSchemaArray;
|
|
212
|
+
/**
|
|
213
|
+
* Checks if the given value is a JSON AnyOf Schema.
|
|
214
|
+
*
|
|
215
|
+
* @param value - The value to check.
|
|
216
|
+
* @returns - True if the value is a JSON AnyOf schema, false otherwise.
|
|
217
|
+
*/
|
|
218
|
+
export declare const isAnyOfSchema: (value: any) => value is JsonSchemaAnyOf;
|
|
219
|
+
/**
|
|
220
|
+
* Checks if the given value is a JSON Primitive schema.
|
|
221
|
+
*
|
|
222
|
+
* @param value - The value to check.
|
|
223
|
+
* @returns - True if the value is a JSON schema, false otherwise.
|
|
224
|
+
*/
|
|
225
|
+
export declare const isPrimitiveType: (value: any) => value is JsonSchemaString | JsonSchemaNumber | JsonSchemaBoolean | JsonSchemaEnum;
|
|
226
|
+
/**
|
|
227
|
+
* Creates a Zod string schema from a given JSON schema.
|
|
228
|
+
*
|
|
229
|
+
* @param jsonSchema - The JSON schema from which the Zod schema should be created.
|
|
230
|
+
* @returns - The created Zod string schema.
|
|
231
|
+
*/
|
|
232
|
+
export declare const createZodStringSchema: (jsonSchema: JsonSchemaString) => OptionalZodString;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a Zod number schema from a given JSON schema.
|
|
235
|
+
*
|
|
236
|
+
* @param jsonSchema - The JSON schema from which the Zod schema should be created.
|
|
237
|
+
* @returns - The created Zod number schema.
|
|
238
|
+
*/
|
|
239
|
+
export declare const createZodNumberSchema: (jsonSchema: JsonSchemaNumber) => OptionalZodNumber;
|
|
240
|
+
/**
|
|
241
|
+
* Creates a Zod boolean schema from a given JSON schema.
|
|
242
|
+
*
|
|
243
|
+
* @param jsonSchema - The JSON schema from which the Zod schema should be created.
|
|
244
|
+
* @returns - The created Zod boolean schema.
|
|
245
|
+
*/
|
|
246
|
+
export declare const createZodBooleanSchema: (jsonSchema: JsonSchemaBoolean) => OptionalZodBoolean;
|
|
247
|
+
/**
|
|
248
|
+
* Creates a Zod union schema from a given JSON schema.
|
|
249
|
+
*
|
|
250
|
+
* @param jsonSchema - The JSON schema from which the Zod schema should be created.
|
|
251
|
+
* @returns - The created Zod union schema.
|
|
252
|
+
*/
|
|
253
|
+
export declare const createEnumSchema: (jsonSchema: JsonSchemaEnum) => OptionalZodEnum | OptionalZodEnumMultiple;
|
|
254
|
+
/**
|
|
255
|
+
* Creates a Zod object schema from a given JSON schema.
|
|
256
|
+
*
|
|
257
|
+
* @param jsonSchema - The JSON schema from which the Zod schema should be created.
|
|
258
|
+
* @returns - The created Zod object schema.
|
|
259
|
+
*/
|
|
260
|
+
export declare const createZodObjectSchema: (jsonSchema: JsonSchemaObject) => OptionalZodZobject;
|
|
261
|
+
/**
|
|
262
|
+
* Creates a Zod array schema from a given JSON schema.
|
|
263
|
+
*
|
|
264
|
+
* @param jsonSchema - The JSON schema from which the Zod schema should be created.
|
|
265
|
+
* @returns - The created Zod array schema.
|
|
266
|
+
*/
|
|
267
|
+
export declare const createZodArraySchema: (jsonSchema: JsonSchemaArray) => OptionalZodArray;
|
|
268
|
+
export {};
|