piral-configs 1.0.0-pre.2217 → 1.0.1-beta.5640

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 - 2021 smapiot
3
+ Copyright (c) 2019 - 2023 smapiot
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- [![Piral Logo](https://github.com/smapiot/piral/raw/master/docs/assets/logo.png)](https://piral.io)
1
+ [![Piral Logo](https://github.com/smapiot/piral/raw/main/docs/assets/logo.png)](https://piral.io)
2
2
 
3
- # [Piral Configs](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-configs.svg?style=flat)](https://www.npmjs.com/package/piral-configs) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
3
+ # [Piral Configs](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-configs.svg?style=flat)](https://www.npmjs.com/package/piral-configs) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
4
4
 
5
5
  This is a plugin that only has a peer dependency to `piral-core`. What `piral-configs` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
6
6
 
@@ -17,6 +17,12 @@ This plugin does not make any statement how the configuration is retrieved. Usua
17
17
 
18
18
  Alternatives: Pilets can ready configuration values from the global data store or state container. They are responsible for evaluating these values and falling back to another value.
19
19
 
20
+ ## Video
21
+
22
+ We also have a video for this plugin:
23
+
24
+ @[youtube](https://youtu.be/mrf886cnBRk)
25
+
20
26
  ## Documentation
21
27
 
22
28
  The following functions are brought to the Pilet API.
package/esm/create.js CHANGED
@@ -1,13 +1,11 @@
1
- import { __assign } from "tslib";
2
1
  import { Validator } from 'jsonschema';
3
- export function createConfigsApi(config) {
4
- if (config === void 0) { config = {}; }
5
- var readConfig = function (name, defaultConfig) {
2
+ export function createConfigsApi(config = {}) {
3
+ const readConfig = (name, defaultConfig) => {
6
4
  var _a;
7
- var key = "config-" + name;
8
- var current = (_a = config.retrieve) === null || _a === void 0 ? void 0 : _a.call(config, key);
5
+ const key = `config-${name}`;
6
+ const current = (_a = config.retrieve) === null || _a === void 0 ? void 0 : _a.call(config, key);
9
7
  if (typeof current === 'object') {
10
- return __assign(__assign({}, defaultConfig), current);
8
+ return Object.assign(Object.assign({}, defaultConfig), current);
11
9
  }
12
10
  else if (typeof current !== 'undefined') {
13
11
  return current;
@@ -16,28 +14,26 @@ export function createConfigsApi(config) {
16
14
  return undefined;
17
15
  }
18
16
  };
19
- var validate = function (schema, proposedConfig, defaultConfig) {
20
- var validator = new Validator();
21
- var result = validator.validate(proposedConfig, schema);
17
+ const validate = (schema, proposedConfig, defaultConfig) => {
18
+ const validator = new Validator();
19
+ const result = validator.validate(proposedConfig, schema);
22
20
  if (!result.valid) {
23
- console.warn("The given configuration does not match the provided schema. Taking the default configuration.", proposedConfig, result);
21
+ console.warn(`The given configuration does not match the provided schema. Taking the default configuration.`, proposedConfig, result);
24
22
  return defaultConfig;
25
23
  }
26
24
  return proposedConfig;
27
25
  };
28
- return function (ctx) { return function (_, meta) { return ({
29
- defineConfigSchema: function (schema, defaultConfig) {
30
- var proposedConfig = readConfig(meta.name, defaultConfig);
31
- var current = validate(schema, proposedConfig, defaultConfig);
32
- ctx.dispatch(function (state) {
33
- var _a;
34
- return (__assign(__assign({}, state), { configs: __assign(__assign({}, state.configs), (_a = {}, _a[meta.name] = current, _a)) }));
35
- });
26
+ return (ctx) => (_, meta) => ({
27
+ defineConfigSchema(schema, defaultConfig) {
28
+ const proposedConfig = readConfig(meta.name, defaultConfig);
29
+ const current = proposedConfig ? validate(schema, proposedConfig, defaultConfig) : defaultConfig;
30
+ ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { configs: Object.assign(Object.assign({}, state.configs), { [meta.name]: current }) })));
31
+ return current;
36
32
  },
37
- getCurrentConfig: function () {
33
+ getCurrentConfig() {
38
34
  var _a;
39
- return (_a = ctx.readState(function (s) { return s.configs[meta.name]; })) !== null && _a !== void 0 ? _a : {};
35
+ return (_a = ctx.readState((s) => s.configs[meta.name])) !== null && _a !== void 0 ? _a : {};
40
36
  },
41
- }); }; };
37
+ });
42
38
  }
43
39
  //# sourceMappingURL=create.js.map
package/esm/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAU,MAAM,YAAY,CAAC;AAc/C,MAAM,UAAU,gBAAgB,CAAC,MAA0B;IAA1B,uBAAA,EAAA,WAA0B;IACzD,IAAM,UAAU,GAAG,UAAC,IAAY,EAAE,aAAkB;;QAClD,IAAM,GAAG,GAAG,YAAU,IAAM,CAAC;QAC7B,IAAM,OAAO,SAAG,MAAM,CAAC,QAAQ,+CAAf,MAAM,EAAY,GAAG,CAAC,CAAC;QAEvC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,6BACK,aAAa,GACb,OAAO,EACV;SACH;aAAM,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;YACzC,OAAO,OAAO,CAAC;SAChB;aAAM;YACL,OAAO,SAAS,CAAC;SAClB;IACH,CAAC,CAAC;IAEF,IAAM,QAAQ,GAAG,UAAC,MAAc,EAAE,cAAmB,EAAE,aAAkB;QACvE,IAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAClC,IA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,OAAO,MAAA,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,mCAAI,EAAE,CAAC;QAC1D,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
package/esm/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Dict } from 'piral-core';
2
- import { Schema } from 'jsonschema';
1
+ import type { Dict } from 'piral-core';
2
+ import type { Schema } from 'jsonschema';
3
3
  declare module 'piral-core/lib/types/custom' {
4
4
  interface PiletCustomApi extends PiletConfigsApi {
5
5
  }
@@ -18,8 +18,10 @@ export interface PiletConfigsApi {
18
18
  * Defines the available configuration options for the pilet.
19
19
  * @param schema The schema to use for allowing configurations.
20
20
  * @param defaultConfig The default configuration to use.
21
+ * @returns The current configuration, which may be either the
22
+ * default configuration or an override.
21
23
  */
22
- defineConfigSchema<T = any>(schema: Schema, defaultConfig?: T): void;
24
+ defineConfigSchema<T = any>(schema: Schema, defaultConfig?: T): T;
23
25
  /**
24
26
  * Gets the currently available configuration.
25
27
  */
package/lib/create.js CHANGED
@@ -1,16 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createConfigsApi = void 0;
4
- var tslib_1 = require("tslib");
5
- var jsonschema_1 = require("jsonschema");
6
- function createConfigsApi(config) {
7
- if (config === void 0) { config = {}; }
8
- var readConfig = function (name, defaultConfig) {
4
+ const jsonschema_1 = require("jsonschema");
5
+ function createConfigsApi(config = {}) {
6
+ const readConfig = (name, defaultConfig) => {
9
7
  var _a;
10
- var key = "config-" + name;
11
- var current = (_a = config.retrieve) === null || _a === void 0 ? void 0 : _a.call(config, key);
8
+ const key = `config-${name}`;
9
+ const current = (_a = config.retrieve) === null || _a === void 0 ? void 0 : _a.call(config, key);
12
10
  if (typeof current === 'object') {
13
- return tslib_1.__assign(tslib_1.__assign({}, defaultConfig), current);
11
+ return Object.assign(Object.assign({}, defaultConfig), current);
14
12
  }
15
13
  else if (typeof current !== 'undefined') {
16
14
  return current;
@@ -19,29 +17,27 @@ function createConfigsApi(config) {
19
17
  return undefined;
20
18
  }
21
19
  };
22
- var validate = function (schema, proposedConfig, defaultConfig) {
23
- var validator = new jsonschema_1.Validator();
24
- var result = validator.validate(proposedConfig, schema);
20
+ const validate = (schema, proposedConfig, defaultConfig) => {
21
+ const validator = new jsonschema_1.Validator();
22
+ const result = validator.validate(proposedConfig, schema);
25
23
  if (!result.valid) {
26
- console.warn("The given configuration does not match the provided schema. Taking the default configuration.", proposedConfig, result);
24
+ console.warn(`The given configuration does not match the provided schema. Taking the default configuration.`, proposedConfig, result);
27
25
  return defaultConfig;
28
26
  }
29
27
  return proposedConfig;
30
28
  };
31
- return function (ctx) { return function (_, meta) { return ({
32
- defineConfigSchema: function (schema, defaultConfig) {
33
- var proposedConfig = readConfig(meta.name, defaultConfig);
34
- var current = validate(schema, proposedConfig, defaultConfig);
35
- ctx.dispatch(function (state) {
36
- var _a;
37
- return (tslib_1.__assign(tslib_1.__assign({}, state), { configs: tslib_1.__assign(tslib_1.__assign({}, state.configs), (_a = {}, _a[meta.name] = current, _a)) }));
38
- });
29
+ return (ctx) => (_, meta) => ({
30
+ defineConfigSchema(schema, defaultConfig) {
31
+ const proposedConfig = readConfig(meta.name, defaultConfig);
32
+ const current = proposedConfig ? validate(schema, proposedConfig, defaultConfig) : defaultConfig;
33
+ ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { configs: Object.assign(Object.assign({}, state.configs), { [meta.name]: current }) })));
34
+ return current;
39
35
  },
40
- getCurrentConfig: function () {
36
+ getCurrentConfig() {
41
37
  var _a;
42
- return (_a = ctx.readState(function (s) { return s.configs[meta.name]; })) !== null && _a !== void 0 ? _a : {};
38
+ return (_a = ctx.readState((s) => s.configs[meta.name])) !== null && _a !== void 0 ? _a : {};
43
39
  },
44
- }); }; };
40
+ });
45
41
  }
46
42
  exports.createConfigsApi = createConfigsApi;
47
43
  //# sourceMappingURL=create.js.map
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;;AACA,yCAA+C;AAc/C,SAAgB,gBAAgB,CAAC,MAA0B;IAA1B,uBAAA,EAAA,WAA0B;IACzD,IAAM,UAAU,GAAG,UAAC,IAAY,EAAE,aAAkB;;QAClD,IAAM,GAAG,GAAG,YAAU,IAAM,CAAC;QAC7B,IAAM,OAAO,SAAG,MAAM,CAAC,QAAQ,+CAAf,MAAM,EAAY,GAAG,CAAC,CAAC;QAEvC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,6CACK,aAAa,GACb,OAAO,EACV;SACH;aAAM,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;YACzC,OAAO,OAAO,CAAC;SAChB;aAAM;YACL,OAAO,SAAS,CAAC;SAClB;IACH,CAAC,CAAC;IAEF,IAAM,QAAQ,GAAG,UAAC,MAAc,EAAE,cAAmB,EAAE,aAAkB;QACvE,IAAM,SAAS,GAAG,IAAI,sBAAS,EAAE,CAAC;QAClC,IAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;YACjB,OAAO,CAAC,IAAI,CACV,+FAA+F,EAC/F,cAAc,EACd,MAAM,CACP,CAAC;YACF,OAAO,aAAa,CAAC;SACtB;QAED,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;IAEF,OAAO,UAAC,GAAG,IAAK,OAAA,UAAC,CAAC,EAAE,IAAI,IAAK,OAAA,CAAC;QAC5B,kBAAkB,YAAC,MAAM,EAAE,aAAa;YACtC,IAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;YAC5D,IAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,aAAa,CAAC,C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,+FAA+F,EAC/F,cAAc,EACd,MAAM,CACP,CAAC;YACF,OAAO,aAAa,CAAC;SACtB;QAED,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;IAEF,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5B,kBAAkB,CAAC,MAAM,EAAE,aAAa;YACtC,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;YAC5D,MAAM,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YAEjG,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,OAAO,kCACF,KAAK,CAAC,OAAO,KAChB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,OAEtB,CAAC,CAAC;YAEJ,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,gBAAgB;;YACd,OAAO,MAAA,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,mCAAI,EAAE,CAAC;QAC1D,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AApDD,4CAoDC"}
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
3
+ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./create"), exports);
5
5
  tslib_1.__exportStar(require("./types"), exports);
6
6
  //# sourceMappingURL=index.js.map
package/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Dict } from 'piral-core';
2
- import { Schema } from 'jsonschema';
1
+ import type { Dict } from 'piral-core';
2
+ import type { Schema } from 'jsonschema';
3
3
  declare module 'piral-core/lib/types/custom' {
4
4
  interface PiletCustomApi extends PiletConfigsApi {
5
5
  }
@@ -18,8 +18,10 @@ export interface PiletConfigsApi {
18
18
  * Defines the available configuration options for the pilet.
19
19
  * @param schema The schema to use for allowing configurations.
20
20
  * @param defaultConfig The default configuration to use.
21
+ * @returns The current configuration, which may be either the
22
+ * default configuration or an override.
21
23
  */
22
- defineConfigSchema<T = any>(schema: Schema, defaultConfig?: T): void;
24
+ defineConfigSchema<T = any>(schema: Schema, defaultConfig?: T): T;
23
25
  /**
24
26
  * Gets the currently available configuration.
25
27
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-configs",
3
- "version": "1.0.0-pre.2217",
3
+ "version": "1.0.1-beta.5640",
4
4
  "description": "Plugin for dynamic configurations of pilets in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -19,11 +19,29 @@
19
19
  "module": "esm/index.js",
20
20
  "main": "lib/index.js",
21
21
  "typings": "lib/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./esm/index.js",
25
+ "require": "./lib/index.js"
26
+ },
27
+ "./esm/*": {
28
+ "import": "./esm/*"
29
+ },
30
+ "./lib/*": {
31
+ "require": "./lib/*"
32
+ },
33
+ "./_/*": {
34
+ "import": "./esm/*.js",
35
+ "require": "./lib/*.js"
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
22
39
  "sideEffects": false,
23
40
  "files": [
24
41
  "esm",
25
42
  "lib",
26
- "src"
43
+ "src",
44
+ "piral-configs.min.js"
27
45
  ],
28
46
  "repository": {
29
47
  "type": "git",
@@ -33,20 +51,20 @@
33
51
  "url": "https://github.com/smapiot/piral/issues"
34
52
  },
35
53
  "scripts": {
36
- "build": "yarn build:commonjs && yarn build:esnext",
54
+ "cleanup": "rimraf esm lib piral-configs.min.js",
55
+ "build": "yarn build:bundle && yarn build:commonjs && yarn build:esnext",
56
+ "build:bundle": "esbuild src/index.ts --outfile=piral-configs.min.js --bundle --external:piral-core --minify --global-name=piralConfigs",
37
57
  "build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
38
58
  "build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
39
59
  "typedoc": "typedoc --json ../../../docs/types/piral-configs.json src --exclude \"src/**/*.test.*\"",
40
60
  "test": "echo \"Error: run tests from root\" && exit 1"
41
61
  },
42
62
  "dependencies": {
43
- "jsonschema": "1.2.6"
63
+ "jsonschema": "^1.4.0",
64
+ "url": "^0.11.0"
44
65
  },
45
66
  "devDependencies": {
46
- "piral-core": "^1.0.0-pre.2217"
47
- },
48
- "peerDependencies": {
49
- "piral-core": "1.x"
67
+ "piral-core": "1.0.1-beta.5640"
50
68
  },
51
- "gitHead": "39479fee9a718f9f2fec97ce1a119fc0818805da"
69
+ "gitHead": "fa0a72b28fd0a20afec7ef491ec19e93c090fc72"
52
70
  }
@@ -0,0 +1,4 @@
1
+ var piralConfigs=(()=>{var gr=Object.create;var pe=Object.defineProperty,Ar=Object.defineProperties,Fr=Object.getOwnPropertyDescriptor,br=Object.getOwnPropertyDescriptors,wr=Object.getOwnPropertyNames,Ie=Object.getOwnPropertySymbols,xr=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable;var Ne=(t,r,e)=>r in t?pe(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,me=(t,r)=>{for(var e in r||(r={}))Ve.call(r,e)&&Ne(t,e,r[e]);if(Ie)for(var e of Ie(r))Er.call(r,e)&&Ne(t,e,r[e]);return t},Se=(t,r)=>Ar(t,br(r)),Te=t=>pe(t,"__esModule",{value:!0});var D=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports),Sr=(t,r)=>{Te(t);for(var e in r)pe(t,e,{get:r[e],enumerable:!0})},zr=(t,r,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of wr(r))!Ve.call(t,i)&&i!=="default"&&pe(t,i,{get:()=>r[i],enumerable:!(e=Fr(r,i))||e.enumerable});return t},Zr=t=>zr(Te(pe(t!=null?gr(xr(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var De=D((ue,fe)=>{(function(t){var r=typeof ue=="object"&&ue&&!ue.nodeType&&ue,e=typeof fe=="object"&&fe&&!fe.nodeType&&fe,i=typeof global=="object"&&global;(i.global===i||i.window===i||i.self===i)&&(t=i);var n,a=2147483647,s=36,o=1,f=26,u=38,l=700,A=72,h=128,c="-",E=/^xn--/,Q=/[^\x20-\x7E]/,Z=/[\x2E\u3002\uFF0E\uFF61]/g,ee={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=s-o,F=Math.floor,O=String.fromCharCode,$;function x(d){throw RangeError(ee[d])}function ne(d,m){for(var g=d.length,b=[];g--;)b[g]=m(d[g]);return b}function V(d,m){var g=d.split("@"),b="";g.length>1&&(b=g[0]+"@",d=g[1]),d=d.replace(Z,".");var w=d.split("."),C=ne(w,m).join(".");return b+C}function j(d){for(var m=[],g=0,b=d.length,w,C;g<b;)w=d.charCodeAt(g++),w>=55296&&w<=56319&&g<b?(C=d.charCodeAt(g++),(C&64512)==56320?m.push(((w&1023)<<10)+(C&1023)+65536):(m.push(w),g--)):m.push(w);return m}function k(d){return ne(d,function(m){var g="";return m>65535&&(m-=65536,g+=O(m>>>10&1023|55296),m=56320|m&1023),g+=O(m),g}).join("")}function de(d){return d-48<10?d-22:d-65<26?d-65:d-97<26?d-97:s}function Ae(d,m){return d+22+75*(d<26)-((m!=0)<<5)}function W(d,m,g){var b=0;for(d=g?F(d/l):d>>1,d+=F(d/m);d>p*f>>1;b+=s)d=F(d/p);return F(b+(p+1)*d/(d+u))}function ae(d){var m=[],g=d.length,b,w=0,C=h,z=A,M,N,L,G,P,q,T,X,re;for(M=d.lastIndexOf(c),M<0&&(M=0),N=0;N<M;++N)d.charCodeAt(N)>=128&&x("not-basic"),m.push(d.charCodeAt(N));for(L=M>0?M+1:0;L<g;){for(G=w,P=1,q=s;L>=g&&x("invalid-input"),T=de(d.charCodeAt(L++)),(T>=s||T>F((a-w)/P))&&x("overflow"),w+=T*P,X=q<=z?o:q>=z+f?f:q-z,!(T<X);q+=s)re=s-X,P>F(a/re)&&x("overflow"),P*=re;b=m.length+1,z=W(w-G,b,G==0),F(w/b)>a-C&&x("overflow"),C+=F(w/b),w%=b,m.splice(w++,0,C)}return k(m)}function oe(d){var m,g,b,w,C,z,M,N,L,G,P,q=[],T,X,re,Ee;for(d=j(d),T=d.length,m=h,g=0,C=A,z=0;z<T;++z)P=d[z],P<128&&q.push(O(P));for(b=w=q.length,w&&q.push(c);b<T;){for(M=a,z=0;z<T;++z)P=d[z],P>=m&&P<M&&(M=P);for(X=b+1,M-m>F((a-g)/X)&&x("overflow"),g+=(M-m)*X,m=M,z=0;z<T;++z)if(P=d[z],P<m&&++g>a&&x("overflow"),P==m){for(N=g,L=s;G=L<=C?o:L>=C+f?f:L-C,!(N<G);L+=s)Ee=N-G,re=s-G,q.push(O(Ae(G+Ee%re,0))),N=F(Ee/re);q.push(O(Ae(N,0))),C=W(g,X,b==w),g=0,++b}++g,++m}return q.join("")}function se(d){return V(d,function(m){return E.test(m)?ae(m.slice(4).toLowerCase()):m})}function xe(d){return V(d,function(m){return Q.test(m)?"xn--"+oe(m):m})}if(n={version:"1.3.2",ucs2:{decode:j,encode:k},decode:ae,encode:oe,toASCII:xe,toUnicode:se},typeof define=="function"&&typeof define.amd=="object"&&define.amd)define("punycode",function(){return n});else if(r&&e)if(fe.exports==r)e.exports=n;else for($ in n)n.hasOwnProperty($)&&(r[$]=n[$]);else t.punycode=n})(ue)});var Le=D((Qr,Ue)=>{"use strict";Ue.exports={isString:function(t){return typeof t=="string"},isObject:function(t){return typeof t=="object"&&t!==null},isNull:function(t){return t===null},isNullOrUndefined:function(t){return t==null}}});var Je=D((et,Be)=>{"use strict";function Or(t,r){return Object.prototype.hasOwnProperty.call(t,r)}Be.exports=function(t,r,e,i){r=r||"&",e=e||"=";var n={};if(typeof t!="string"||t.length===0)return n;var a=/\+/g;t=t.split(r);var s=1e3;i&&typeof i.maxKeys=="number"&&(s=i.maxKeys);var o=t.length;s>0&&o>s&&(o=s);for(var f=0;f<o;++f){var u=t[f].replace(a,"%20"),l=u.indexOf(e),A,h,c,E;l>=0?(A=u.substr(0,l),h=u.substr(l+1)):(A=u,h=""),c=decodeURIComponent(A),E=decodeURIComponent(h),Or(n,c)?Array.isArray(n[c])?n[c].push(E):n[c]=[n[c],E]:n[c]=E}return n}});var Ge=D((rt,ke)=>{"use strict";var ce=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};ke.exports=function(t,r,e,i){return r=r||"&",e=e||"=",t===null&&(t=void 0),typeof t=="object"?Object.keys(t).map(function(n){var a=encodeURIComponent(ce(n))+e;return Array.isArray(t[n])?t[n].map(function(s){return a+encodeURIComponent(ce(s))}).join(r):a+encodeURIComponent(ce(t[n]))}).join(r):i?encodeURIComponent(ce(i))+e+encodeURIComponent(ce(t)):""}});var Ke=D(ve=>{"use strict";ve.decode=ve.parse=Je();ve.encode=ve.stringify=Ge()});var Fe=D(he=>{"use strict";var $r=De(),B=Le();he.parse=ye;he.resolve=Nr;he.resolveObject=Tr;he.format=Vr;he.Url=I;function I(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Pr=/^([a-z0-9.+-]+:)/i,Cr=/:[0-9]*$/,jr=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Mr=["<",">",'"',"`"," ","\r",`
2
+ `," "],Rr=["{","}","|","\\","^","`"].concat(Mr),ze=["'"].concat(Rr),We=["%","/","?",";","#"].concat(ze),Xe=["/","?","#"],_r=255,Ye=/^[+a-z0-9A-Z_-]{0,63}$/,qr=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Ir={javascript:!0,"javascript:":!0},Ze={javascript:!0,"javascript:":!0},le={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Oe=Ke();function ye(t,r,e){if(t&&B.isObject(t)&&t instanceof I)return t;var i=new I;return i.parse(t,r,e),i}I.prototype.parse=function(t,r,e){if(!B.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),n=i!==-1&&i<t.indexOf("#")?"?":"#",a=t.split(n),s=/\\/g;a[0]=a[0].replace(s,"/"),t=a.join(n);var o=t;if(o=o.trim(),!e&&t.split("#").length===1){var f=jr.exec(o);if(f)return this.path=o,this.href=o,this.pathname=f[1],f[2]?(this.search=f[2],r?this.query=Oe.parse(this.search.substr(1)):this.query=this.search.substr(1)):r&&(this.search="",this.query={}),this}var u=Pr.exec(o);if(u){u=u[0];var l=u.toLowerCase();this.protocol=l,o=o.substr(u.length)}if(e||u||o.match(/^\/\/[^@\/]+@[^@\/]+/)){var A=o.substr(0,2)==="//";A&&!(u&&Ze[u])&&(o=o.substr(2),this.slashes=!0)}if(!Ze[u]&&(A||u&&!le[u])){for(var h=-1,c=0;c<Xe.length;c++){var E=o.indexOf(Xe[c]);E!==-1&&(h===-1||E<h)&&(h=E)}var Q,Z;h===-1?Z=o.lastIndexOf("@"):Z=o.lastIndexOf("@",h),Z!==-1&&(Q=o.slice(0,Z),o=o.slice(Z+1),this.auth=decodeURIComponent(Q)),h=-1;for(var c=0;c<We.length;c++){var E=o.indexOf(We[c]);E!==-1&&(h===-1||E<h)&&(h=E)}h===-1&&(h=o.length),this.host=o.slice(0,h),o=o.slice(h),this.parseHost(),this.hostname=this.hostname||"";var ee=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!ee)for(var p=this.hostname.split(/\./),c=0,F=p.length;c<F;c++){var O=p[c];if(!!O&&!O.match(Ye)){for(var $="",x=0,ne=O.length;x<ne;x++)O.charCodeAt(x)>127?$+="x":$+=O[x];if(!$.match(Ye)){var V=p.slice(0,c),j=p.slice(c+1),k=O.match(qr);k&&(V.push(k[1]),j.unshift(k[2])),j.length&&(o="/"+j.join(".")+o),this.hostname=V.join(".");break}}}this.hostname.length>_r?this.hostname="":this.hostname=this.hostname.toLowerCase(),ee||(this.hostname=$r.toASCII(this.hostname));var de=this.port?":"+this.port:"",Ae=this.hostname||"";this.host=Ae+de,this.href+=this.host,ee&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),o[0]!=="/"&&(o="/"+o))}if(!Ir[l])for(var c=0,F=ze.length;c<F;c++){var W=ze[c];if(o.indexOf(W)!==-1){var ae=encodeURIComponent(W);ae===W&&(ae=escape(W)),o=o.split(W).join(ae)}}var oe=o.indexOf("#");oe!==-1&&(this.hash=o.substr(oe),o=o.slice(0,oe));var se=o.indexOf("?");if(se!==-1?(this.search=o.substr(se),this.query=o.substr(se+1),r&&(this.query=Oe.parse(this.query)),o=o.slice(0,se)):r&&(this.search="",this.query={}),o&&(this.pathname=o),le[l]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var de=this.pathname||"",xe=this.search||"";this.path=de+xe}return this.href=this.format(),this};function Vr(t){return B.isString(t)&&(t=ye(t)),t instanceof I?t.format():I.prototype.format.call(t)}I.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var r=this.protocol||"",e=this.pathname||"",i=this.hash||"",n=!1,a="";this.host?n=t+this.host:this.hostname&&(n=t+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(n+=":"+this.port)),this.query&&B.isObject(this.query)&&Object.keys(this.query).length&&(a=Oe.stringify(this.query));var s=this.search||a&&"?"+a||"";return r&&r.substr(-1)!==":"&&(r+=":"),this.slashes||(!r||le[r])&&n!==!1?(n="//"+(n||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):n||(n=""),i&&i.charAt(0)!=="#"&&(i="#"+i),s&&s.charAt(0)!=="?"&&(s="?"+s),e=e.replace(/[?#]/g,function(o){return encodeURIComponent(o)}),s=s.replace("#","%23"),r+n+e+s+i};function Nr(t,r){return ye(t,!1,!0).resolve(r)}I.prototype.resolve=function(t){return this.resolveObject(ye(t,!1,!0)).format()};function Tr(t,r){return t?ye(t,!1,!0).resolveObject(r):r}I.prototype.resolveObject=function(t){if(B.isString(t)){var r=new I;r.parse(t,!1,!0),t=r}for(var e=new I,i=Object.keys(this),n=0;n<i.length;n++){var a=i[n];e[a]=this[a]}if(e.hash=t.hash,t.href==="")return e.href=e.format(),e;if(t.slashes&&!t.protocol){for(var s=Object.keys(t),o=0;o<s.length;o++){var f=s[o];f!=="protocol"&&(e[f]=t[f])}return le[e.protocol]&&e.hostname&&!e.pathname&&(e.path=e.pathname="/"),e.href=e.format(),e}if(t.protocol&&t.protocol!==e.protocol){if(!le[t.protocol]){for(var u=Object.keys(t),l=0;l<u.length;l++){var A=u[l];e[A]=t[A]}return e.href=e.format(),e}if(e.protocol=t.protocol,!t.host&&!Ze[t.protocol]){for(var F=(t.pathname||"").split("/");F.length&&!(t.host=F.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),F[0]!==""&&F.unshift(""),F.length<2&&F.unshift(""),e.pathname=F.join("/")}else e.pathname=t.pathname;if(e.search=t.search,e.query=t.query,e.host=t.host||"",e.auth=t.auth,e.hostname=t.hostname||t.host,e.port=t.port,e.pathname||e.search){var h=e.pathname||"",c=e.search||"";e.path=h+c}return e.slashes=e.slashes||t.slashes,e.href=e.format(),e}var E=e.pathname&&e.pathname.charAt(0)==="/",Q=t.host||t.pathname&&t.pathname.charAt(0)==="/",Z=Q||E||e.host&&t.pathname,ee=Z,p=e.pathname&&e.pathname.split("/")||[],F=t.pathname&&t.pathname.split("/")||[],O=e.protocol&&!le[e.protocol];if(O&&(e.hostname="",e.port=null,e.host&&(p[0]===""?p[0]=e.host:p.unshift(e.host)),e.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(F[0]===""?F[0]=t.host:F.unshift(t.host)),t.host=null),Z=Z&&(F[0]===""||p[0]==="")),Q)e.host=t.host||t.host===""?t.host:e.host,e.hostname=t.hostname||t.hostname===""?t.hostname:e.hostname,e.search=t.search,e.query=t.query,p=F;else if(F.length)p||(p=[]),p.pop(),p=p.concat(F),e.search=t.search,e.query=t.query;else if(!B.isNullOrUndefined(t.search)){if(O){e.hostname=e.host=p.shift();var $=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;$&&(e.auth=$.shift(),e.host=e.hostname=$.shift())}return e.search=t.search,e.query=t.query,(!B.isNull(e.pathname)||!B.isNull(e.search))&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!p.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var x=p.slice(-1)[0],ne=(e.host||t.host||p.length>1)&&(x==="."||x==="..")||x==="",V=0,j=p.length;j>=0;j--)x=p[j],x==="."?p.splice(j,1):x===".."?(p.splice(j,1),V++):V&&(p.splice(j,1),V--);if(!Z&&!ee)for(;V--;V)p.unshift("..");Z&&p[0]!==""&&(!p[0]||p[0].charAt(0)!=="/")&&p.unshift(""),ne&&p.join("/").substr(-1)!=="/"&&p.push("");var k=p[0]===""||p[0]&&p[0].charAt(0)==="/";if(O){e.hostname=e.host=k?"":p.length?p.shift():"";var $=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;$&&(e.auth=$.shift(),e.host=e.hostname=$.shift())}return Z=Z||e.host&&p.length,Z&&!k&&p.unshift(""),p.length?e.pathname=p.join("/"):(e.pathname=null,e.path=null),(!B.isNull(e.pathname)||!B.isNull(e.search))&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=t.auth||e.auth,e.slashes=e.slashes||t.slashes,e.href=e.format(),e};I.prototype.parseHost=function(){var t=this.host,r=Cr.exec(t);r&&(r=r[0],r!==":"&&(this.port=r.substr(1)),t=t.substr(0,t.length-r.length)),t&&(this.hostname=t)}});var Y=D((R,je)=>{"use strict";var He=Fe(),$e=R.ValidationError=function(r,e,i,n,a,s){if(Array.isArray(n)?(this.path=n,this.property=n.reduce(function(f,u){return f+er(u)},"instance")):n!==void 0&&(this.property=n),r&&(this.message=r),i){var o=i.$id||i.id;this.schema=o||i}e!==void 0&&(this.instance=e),this.name=a,this.argument=s,this.stack=this.toString()};$e.prototype.toString=function(){return this.property+" "+this.message};var be=R.ValidatorResult=function(r,e,i,n){this.instance=r,this.schema=e,this.options=i,this.path=n.path,this.propertyPath=n.propertyPath,this.errors=[],this.throwError=i&&i.throwError,this.throwFirst=i&&i.throwFirst,this.throwAll=i&&i.throwAll,this.disableFormat=i&&i.disableFormat===!0};be.prototype.addError=function(r){var e;if(typeof r=="string")e=new $e(r,this.instance,this.schema,this.path);else{if(!r)throw new Error("Missing error detail");if(!r.message)throw new Error("Missing error message");if(!r.name)throw new Error("Missing validator type");e=new $e(r.message,this.instance,this.schema,this.path,r.name,r.argument)}if(this.errors.push(e),this.throwFirst)throw new te(this);if(this.throwError)throw e;return e};be.prototype.importErrors=function(r){typeof r=="string"||r&&r.validatorType?this.addError(r):r&&r.errors&&(this.errors=this.errors.concat(r.errors))};function Dr(t,r){return r+": "+t.toString()+`
3
+ `}be.prototype.toString=function(r){return this.errors.map(Dr).join("")};Object.defineProperty(be.prototype,"valid",{get:function(){return!this.errors.length}});je.exports.ValidatorResultError=te;function te(t){Error.captureStackTrace&&Error.captureStackTrace(this,te),this.instance=t.instance,this.schema=t.schema,this.options=t.options,this.errors=t.errors}te.prototype=new Error;te.prototype.constructor=te;te.prototype.name="Validation Error";var Qe=R.SchemaError=function t(r,e){this.message=r,this.schema=e,Error.call(this,r),Error.captureStackTrace(this,t)};Qe.prototype=Object.create(Error.prototype,{constructor:{value:Qe,enumerable:!1},name:{value:"SchemaError",enumerable:!1}});var Pe=R.SchemaContext=function(r,e,i,n,a){this.schema=r,this.options=e,Array.isArray(i)?(this.path=i,this.propertyPath=i.reduce(function(s,o){return s+er(o)},"instance")):this.propertyPath=i,this.base=n,this.schemas=a};Pe.prototype.resolve=function(r){return He.resolve(this.base,r)};Pe.prototype.makeChild=function(r,e){var i=e===void 0?this.path:this.path.concat([e]),n=r.$id||r.id,a=He.resolve(this.base,n||""),s=new Pe(r,this.options,i,a,Object.create(this.schemas));return n&&!s.schemas[a]&&(s.schemas[a]=r),s};var U=R.FORMAT_REGEXPS={"date-time":/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/,date:/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])$/,time:/^(2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])$/,duration:/P(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S)|\d+(D|M(\d+D)?|Y(\d+M(\d+D)?)?)(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S))?|\d+W)/i,email:/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/,"idn-email":/^("(?:[!#-\[\]-\u{10FFFF}]|\\[\t -\u{10FFFF}])*"|[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*)@([!#-'*+\-/-9=?A-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*:?)?$/u,uuid:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,"uri-template":/(%[0-9a-f]{2}|[!#$&(-;=?@\[\]_a-z~]|\{[!#&+,./;=?@|]?(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?(,(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?)*\})*/iu,"json-pointer":/^(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*$/iu,"relative-json-pointer":/^\d+(#|(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*)$/iu,hostname:/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"host-name":/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"utc-millisec":function(t){return typeof t=="string"&&parseFloat(t)===parseInt(t,10)&&!isNaN(t)},regex:function(t){var r=!0;try{new RegExp(t)}catch{r=!1}return r},style:/[\r\n\t ]*[^\r\n\t ][^:]*:[\r\n\t ]*[^\r\n\t ;]*[\r\n\t ]*;?/,color:/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,phone:/^\+(?:[0-9] ?){6,14}[0-9]$/,alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/};U.regexp=U.regex;U.pattern=U.regex;U.ipv4=U["ip-address"];R.isFormat=function(r,e,i){if(typeof r=="string"&&U[e]!==void 0){if(U[e]instanceof RegExp)return U[e].test(r);if(typeof U[e]=="function")return U[e](r)}else if(i&&i.customFormats&&typeof i.customFormats[e]=="function")return i.customFormats[e](r);return!0};var er=R.makeSuffix=function(r){return r=r.toString(),!r.match(/[.\s\[\]]/)&&!r.match(/^[\d]/)?"."+r:r.match(/^\d+$/)?"["+r+"]":"["+JSON.stringify(r)+"]"};R.deepCompareStrict=function t(r,e){if(typeof r!=typeof e)return!1;if(Array.isArray(r))return!Array.isArray(e)||r.length!==e.length?!1:r.every(function(a,s){return t(r[s],e[s])});if(typeof r=="object"){if(!r||!e)return r===e;var i=Object.keys(r),n=Object.keys(e);return i.length!==n.length?!1:i.every(function(a){return t(r[a],e[a])})}return r===e};function Ur(t,r,e,i){typeof e=="object"?r[i]=Ce(t[i],e):t.indexOf(e)===-1&&r.push(e)}function Lr(t,r,e){r[e]=t[e]}function Br(t,r,e,i){typeof r[i]!="object"||!r[i]?e[i]=r[i]:t[i]?e[i]=Ce(t[i],r[i]):e[i]=r[i]}function Ce(t,r){var e=Array.isArray(r),i=e&&[]||{};return e?(t=t||[],i=i.concat(t),r.forEach(Ur.bind(null,t,i))):(t&&typeof t=="object"&&Object.keys(t).forEach(Lr.bind(null,t,i)),Object.keys(r).forEach(Br.bind(null,t,r,i))),i}je.exports.deepMerge=Ce;R.objectGetPath=function(r,e){for(var i=e.split("/").slice(1),n;typeof(n=i.shift())=="string";){var a=decodeURIComponent(n.replace(/~0/,"~").replace(/~1/g,"/"));if(!(a in r))return;r=r[a]}return r};function Jr(t){return"/"+encodeURIComponent(t).replace(/~/g,"%7E")}R.encodePath=function(r){return r.map(Jr).join("")};R.getDecimalPlaces=function(r){var e=0;if(isNaN(r))return e;typeof r!="number"&&(r=Number(r));var i=r.toString().split("e");if(i.length===2){if(i[1][0]!=="-")return e;e=Number(i[1].slice(1))}var n=i[0].split(".");return n.length===2&&(e+=n[1].length),e};R.isSchema=function(r){return typeof r=="object"&&r||typeof r=="boolean"}});var nr=D((nt,ir)=>{"use strict";var _=Y(),v=_.ValidatorResult,H=_.SchemaError,Me={};Me.ignoreProperties={id:!0,default:!0,description:!0,title:!0,additionalItems:!0,then:!0,else:!0,$schema:!0,$ref:!0,extends:!0};var y=Me.validators={};y.type=function(r,e,i,n){if(r===void 0)return null;var a=new v(r,e,i,n),s=Array.isArray(e.type)?e.type:[e.type];if(!s.some(this.testType.bind(this,r,e,i,n))){var o=s.map(function(f){if(!!f){var u=f.$id||f.id;return u?"<"+u+">":f+""}});a.addError({name:"type",argument:o,message:"is not of a type(s) "+o})}return a};function Re(t,r,e,i,n){var a=r.throwError,s=r.throwAll;r.throwError=!1,r.throwAll=!1;var o=this.validateSchema(t,n,r,e);return r.throwError=a,r.throwAll=s,!o.valid&&i instanceof Function&&i(o),o.valid}y.anyOf=function(r,e,i,n){if(r===void 0)return null;var a=new v(r,e,i,n),s=new v(r,e,i,n);if(!Array.isArray(e.anyOf))throw new H("anyOf must be an array");if(!e.anyOf.some(Re.bind(this,r,i,n,function(f){s.importErrors(f)}))){var o=e.anyOf.map(function(f,u){var l=f.$id||f.id;return l?"<"+l+">":f.title&&JSON.stringify(f.title)||f.$ref&&"<"+f.$ref+">"||"[subschema "+u+"]"});i.nestedErrors&&a.importErrors(s),a.addError({name:"anyOf",argument:o,message:"is not any of "+o.join(",")})}return a};y.allOf=function(r,e,i,n){if(r===void 0)return null;if(!Array.isArray(e.allOf))throw new H("allOf must be an array");var a=new v(r,e,i,n),s=this;return e.allOf.forEach(function(o,f){var u=s.validateSchema(r,o,i,n);if(!u.valid){var l=o.$id||o.id,A=l||o.title&&JSON.stringify(o.title)||o.$ref&&"<"+o.$ref+">"||"[subschema "+f+"]";a.addError({name:"allOf",argument:{id:A,length:u.errors.length,valid:u},message:"does not match allOf schema "+A+" with "+u.errors.length+" error[s]:"}),a.importErrors(u)}}),a};y.oneOf=function(r,e,i,n){if(r===void 0)return null;if(!Array.isArray(e.oneOf))throw new H("oneOf must be an array");var a=new v(r,e,i,n),s=new v(r,e,i,n),o=e.oneOf.filter(Re.bind(this,r,i,n,function(u){s.importErrors(u)})).length,f=e.oneOf.map(function(u,l){var A=u.$id||u.id;return A||u.title&&JSON.stringify(u.title)||u.$ref&&"<"+u.$ref+">"||"[subschema "+l+"]"});return o!==1&&(i.nestedErrors&&a.importErrors(s),a.addError({name:"oneOf",argument:f,message:"is not exactly one from "+f.join(",")})),a};y.if=function(r,e,i,n){if(r===void 0)return null;if(!_.isSchema(e.if))throw new Error('Expected "if" keyword to be a schema');var a=Re.call(this,r,i,n,null,e.if),s=new v(r,e,i,n),o;if(a){if(e.then===void 0)return;if(!_.isSchema(e.then))throw new Error('Expected "then" keyword to be a schema');o=this.validateSchema(r,e.then,i,n.makeChild(e.then)),s.importErrors(o)}else{if(e.else===void 0)return;if(!_.isSchema(e.else))throw new Error('Expected "else" keyword to be a schema');o=this.validateSchema(r,e.else,i,n.makeChild(e.else)),s.importErrors(o)}return s};function _e(t,r){if(Object.hasOwnProperty.call(t,r))return t[r];if(r in t){for(;t=Object.getPrototypeOf(t);)if(Object.propertyIsEnumerable.call(t,r))return t[r]}}y.propertyNames=function(r,e,i,n){if(!!this.types.object(r)){var a=new v(r,e,i,n),s=e.propertyNames!==void 0?e.propertyNames:{};if(!_.isSchema(s))throw new H('Expected "propertyNames" to be a schema (object or boolean)');for(var o in r)if(_e(r,o)!==void 0){var f=this.validateSchema(o,s,i,n.makeChild(s));a.importErrors(f)}return a}};y.properties=function(r,e,i,n){if(!!this.types.object(r)){var a=new v(r,e,i,n),s=e.properties||{};for(var o in s){var f=s[o];if(f!==void 0){if(f===null)throw new H('Unexpected null, expected schema in "properties"');typeof i.preValidateProperty=="function"&&i.preValidateProperty(r,o,f,i,n);var u=_e(r,o),l=this.validateSchema(u,f,i,n.makeChild(f,o));l.instance!==a.instance[o]&&(a.instance[o]=l.instance),a.importErrors(l)}}return a}};function rr(t,r,e,i,n,a){if(!!this.types.object(t)&&!(r.properties&&r.properties[n]!==void 0))if(r.additionalProperties===!1)a.addError({name:"additionalProperties",argument:n,message:"is not allowed to have the additional property "+JSON.stringify(n)});else{var s=r.additionalProperties||{};typeof e.preValidateProperty=="function"&&e.preValidateProperty(t,n,s,e,i);var o=this.validateSchema(t[n],s,e,i.makeChild(s,n));o.instance!==a.instance[n]&&(a.instance[n]=o.instance),a.importErrors(o)}}y.patternProperties=function(r,e,i,n){if(!!this.types.object(r)){var a=new v(r,e,i,n),s=e.patternProperties||{};for(var o in r){var f=!0;for(var u in s){var l=s[u];if(l!==void 0){if(l===null)throw new H('Unexpected null, expected schema in "patternProperties"');try{var A=new RegExp(u,"u")}catch{A=new RegExp(u)}if(!!A.test(o)){f=!1,typeof i.preValidateProperty=="function"&&i.preValidateProperty(r,o,l,i,n);var h=this.validateSchema(r[o],l,i,n.makeChild(l,o));h.instance!==a.instance[o]&&(a.instance[o]=h.instance),a.importErrors(h)}}}f&&rr.call(this,r,e,i,n,o,a)}return a}};y.additionalProperties=function(r,e,i,n){if(!!this.types.object(r)){if(e.patternProperties)return null;var a=new v(r,e,i,n);for(var s in r)rr.call(this,r,e,i,n,s,a);return a}};y.minProperties=function(r,e,i,n){if(!!this.types.object(r)){var a=new v(r,e,i,n),s=Object.keys(r);return s.length>=e.minProperties||a.addError({name:"minProperties",argument:e.minProperties,message:"does not meet minimum property length of "+e.minProperties}),a}};y.maxProperties=function(r,e,i,n){if(!!this.types.object(r)){var a=new v(r,e,i,n),s=Object.keys(r);return s.length<=e.maxProperties||a.addError({name:"maxProperties",argument:e.maxProperties,message:"does not meet maximum property length of "+e.maxProperties}),a}};y.items=function(r,e,i,n){var a=this;if(!!this.types.array(r)&&e.items!==void 0){var s=new v(r,e,i,n);return r.every(function(o,f){if(Array.isArray(e.items))var u=e.items[f]===void 0?e.additionalItems:e.items[f];else var u=e.items;if(u===void 0)return!0;if(u===!1)return s.addError({name:"items",message:"additionalItems not permitted"}),!1;var l=a.validateSchema(o,u,i,n.makeChild(u,f));return l.instance!==s.instance[f]&&(s.instance[f]=l.instance),s.importErrors(l),!0}),s}};y.contains=function(r,e,i,n){var a=this;if(!!this.types.array(r)&&e.contains!==void 0){if(!_.isSchema(e.contains))throw new Error('Expected "contains" keyword to be a schema');var s=new v(r,e,i,n),o=r.some(function(f,u){var l=a.validateSchema(f,e.contains,i,n.makeChild(e.contains,u));return l.errors.length===0});return o===!1&&s.addError({name:"contains",argument:e.contains,message:"must contain an item matching given schema"}),s}};y.minimum=function(r,e,i,n){if(!!this.types.number(r)){var a=new v(r,e,i,n);return e.exclusiveMinimum&&e.exclusiveMinimum===!0?r>e.minimum||a.addError({name:"minimum",argument:e.minimum,message:"must be greater than "+e.minimum}):r>=e.minimum||a.addError({name:"minimum",argument:e.minimum,message:"must be greater than or equal to "+e.minimum}),a}};y.maximum=function(r,e,i,n){if(!!this.types.number(r)){var a=new v(r,e,i,n);return e.exclusiveMaximum&&e.exclusiveMaximum===!0?r<e.maximum||a.addError({name:"maximum",argument:e.maximum,message:"must be less than "+e.maximum}):r<=e.maximum||a.addError({name:"maximum",argument:e.maximum,message:"must be less than or equal to "+e.maximum}),a}};y.exclusiveMinimum=function(r,e,i,n){if(typeof e.exclusiveMinimum!="boolean"&&!!this.types.number(r)){var a=new v(r,e,i,n),s=r>e.exclusiveMinimum;return s||a.addError({name:"exclusiveMinimum",argument:e.exclusiveMinimum,message:"must be strictly greater than "+e.exclusiveMinimum}),a}};y.exclusiveMaximum=function(r,e,i,n){if(typeof e.exclusiveMaximum!="boolean"&&!!this.types.number(r)){var a=new v(r,e,i,n),s=r<e.exclusiveMaximum;return s||a.addError({name:"exclusiveMaximum",argument:e.exclusiveMaximum,message:"must be strictly less than "+e.exclusiveMaximum}),a}};var tr=function(r,e,i,n,a,s){if(!!this.types.number(r)){var o=e[a];if(o==0)throw new H(a+" cannot be zero");var f=new v(r,e,i,n),u=_.getDecimalPlaces(r),l=_.getDecimalPlaces(o),A=Math.max(u,l),h=Math.pow(10,A);return Math.round(r*h)%Math.round(o*h)!=0&&f.addError({name:a,argument:o,message:s+JSON.stringify(o)}),f}};y.multipleOf=function(r,e,i,n){return tr.call(this,r,e,i,n,"multipleOf","is not a multiple of (divisible by) ")};y.divisibleBy=function(r,e,i,n){return tr.call(this,r,e,i,n,"divisibleBy","is not divisible by (multiple of) ")};y.required=function(r,e,i,n){var a=new v(r,e,i,n);return r===void 0&&e.required===!0?a.addError({name:"required",message:"is required"}):this.types.object(r)&&Array.isArray(e.required)&&e.required.forEach(function(s){_e(r,s)===void 0&&a.addError({name:"required",argument:s,message:"requires property "+JSON.stringify(s)})}),a};y.pattern=function(r,e,i,n){if(!!this.types.string(r)){var a=new v(r,e,i,n),s=e.pattern;try{var o=new RegExp(s,"u")}catch{o=new RegExp(s)}return r.match(o)||a.addError({name:"pattern",argument:e.pattern,message:"does not match pattern "+JSON.stringify(e.pattern.toString())}),a}};y.format=function(r,e,i,n){if(r!==void 0){var a=new v(r,e,i,n);return!a.disableFormat&&!_.isFormat(r,e.format,this)&&a.addError({name:"format",argument:e.format,message:"does not conform to the "+JSON.stringify(e.format)+" format"}),a}};y.minLength=function(r,e,i,n){if(!!this.types.string(r)){var a=new v(r,e,i,n),s=r.match(/[\uDC00-\uDFFF]/g),o=r.length-(s?s.length:0);return o>=e.minLength||a.addError({name:"minLength",argument:e.minLength,message:"does not meet minimum length of "+e.minLength}),a}};y.maxLength=function(r,e,i,n){if(!!this.types.string(r)){var a=new v(r,e,i,n),s=r.match(/[\uDC00-\uDFFF]/g),o=r.length-(s?s.length:0);return o<=e.maxLength||a.addError({name:"maxLength",argument:e.maxLength,message:"does not meet maximum length of "+e.maxLength}),a}};y.minItems=function(r,e,i,n){if(!!this.types.array(r)){var a=new v(r,e,i,n);return r.length>=e.minItems||a.addError({name:"minItems",argument:e.minItems,message:"does not meet minimum length of "+e.minItems}),a}};y.maxItems=function(r,e,i,n){if(!!this.types.array(r)){var a=new v(r,e,i,n);return r.length<=e.maxItems||a.addError({name:"maxItems",argument:e.maxItems,message:"does not meet maximum length of "+e.maxItems}),a}};function kr(t,r,e){var i,n=e.length;for(i=r+1,n;i<n;i++)if(_.deepCompareStrict(t,e[i]))return!1;return!0}y.uniqueItems=function(r,e,i,n){if(e.uniqueItems===!0&&!!this.types.array(r)){var a=new v(r,e,i,n);return r.every(kr)||a.addError({name:"uniqueItems",message:"contains duplicate item"}),a}};y.dependencies=function(r,e,i,n){if(!!this.types.object(r)){var a=new v(r,e,i,n);for(var s in e.dependencies)if(r[s]!==void 0){var o=e.dependencies[s],f=n.makeChild(o,s);if(typeof o=="string"&&(o=[o]),Array.isArray(o))o.forEach(function(l){r[l]===void 0&&a.addError({name:"dependencies",argument:f.propertyPath,message:"property "+l+" not found, required by "+f.propertyPath})});else{var u=this.validateSchema(r,o,i,f);a.instance!==u.instance&&(a.instance=u.instance),u&&u.errors.length&&(a.addError({name:"dependencies",argument:f.propertyPath,message:"does not meet dependency required by "+f.propertyPath}),a.importErrors(u))}}return a}};y.enum=function(r,e,i,n){if(r===void 0)return null;if(!Array.isArray(e.enum))throw new H("enum expects an array",e);var a=new v(r,e,i,n);return e.enum.some(_.deepCompareStrict.bind(null,r))||a.addError({name:"enum",argument:e.enum,message:"is not one of enum values: "+e.enum.map(String).join(",")}),a};y.const=function(r,e,i,n){if(r===void 0)return null;var a=new v(r,e,i,n);return _.deepCompareStrict(e.const,r)||a.addError({name:"const",argument:e.const,message:"does not exactly match expected constant: "+e.const}),a};y.not=y.disallow=function(r,e,i,n){var a=this;if(r===void 0)return null;var s=new v(r,e,i,n),o=e.not||e.disallow;return o?(Array.isArray(o)||(o=[o]),o.forEach(function(f){if(a.testType(r,e,i,n,f)){var u=f&&(f.$id||f.id),l=u||f;s.addError({name:"not",argument:l,message:"is of prohibited type "+l})}}),s):null};ir.exports=Me});var we=D((at,qe)=>{"use strict";var ar=Fe(),Gr=Y();qe.exports.SchemaScanResult=or;function or(t,r){this.id=t,this.ref=r}qe.exports.scan=function(r,e){function i(f,u){if(!(!u||typeof u!="object")){if(u.$ref){var l=ar.resolve(f,u.$ref);o[l]=o[l]?o[l]+1:0;return}var A=u.$id||u.id,h=A?ar.resolve(f,A):f;if(h){if(h.indexOf("#")<0&&(h+="#"),s[h]){if(!Gr.deepCompareStrict(s[h],u))throw new Error("Schema <"+h+"> already exists with different definition");return s[h]}s[h]=u,h[h.length-1]=="#"&&(s[h.substring(0,h.length-1)]=u)}n(h+"/items",Array.isArray(u.items)?u.items:[u.items]),n(h+"/extends",Array.isArray(u.extends)?u.extends:[u.extends]),i(h+"/additionalItems",u.additionalItems),a(h+"/properties",u.properties),i(h+"/additionalProperties",u.additionalProperties),a(h+"/definitions",u.definitions),a(h+"/patternProperties",u.patternProperties),a(h+"/dependencies",u.dependencies),n(h+"/disallow",u.disallow),n(h+"/allOf",u.allOf),n(h+"/anyOf",u.anyOf),n(h+"/oneOf",u.oneOf),i(h+"/not",u.not)}}function n(f,u){if(!!Array.isArray(u))for(var l=0;l<u.length;l++)i(f+"/"+l,u[l])}function a(f,u){if(!(!u||typeof u!="object"))for(var l in u)i(f+"/"+l,u[l])}var s={},o={};return i(r,e),new or(s,o)}});var cr=D((ot,mr)=>{"use strict";var sr=Fe(),ur=nr(),ie=Y(),fr=we().scan,lr=ie.ValidatorResult,Kr=ie.ValidatorResultError,ge=ie.SchemaError,hr=ie.SchemaContext,dr="/",S=function t(){this.customFormats=Object.create(t.prototype.customFormats),this.schemas={},this.unresolvedRefs=[],this.types=Object.create(J),this.attributes=Object.create(ur.validators)};S.prototype.customFormats={};S.prototype.schemas=null;S.prototype.types=null;S.prototype.attributes=null;S.prototype.unresolvedRefs=null;S.prototype.addSchema=function(r,e){var i=this;if(!r)return null;var n=fr(e||dr,r),a=e||r.$id||r.id;for(var s in n.id)this.schemas[s]=n.id[s];for(var s in n.ref)this.unresolvedRefs.push(s);return this.unresolvedRefs=this.unresolvedRefs.filter(function(o){return typeof i.schemas[o]=="undefined"}),this.schemas[a]};S.prototype.addSubSchemaArray=function(r,e){if(!!Array.isArray(e))for(var i=0;i<e.length;i++)this.addSubSchema(r,e[i])};S.prototype.addSubSchemaObject=function(r,e){if(!(!e||typeof e!="object"))for(var i in e)this.addSubSchema(r,e[i])};S.prototype.setSchemas=function(r){this.schemas=r};S.prototype.getSchema=function(r){return this.schemas[r]};S.prototype.validate=function(r,e,i,n){if(typeof e!="boolean"&&typeof e!="object"||e===null)throw new ge("Expected `schema` to be an object or boolean");i||(i={});var a=e.$id||e.id,s=sr.resolve(i.base||dr,a||"");if(!n){n=new hr(e,i,[],s,Object.create(this.schemas)),n.schemas[s]||(n.schemas[s]=e);var o=fr(s,e);for(var f in o.id){var u=o.id[f];n.schemas[f]=u}}if(i.required&&r===void 0){var l=new lr(r,e,i,n);return l.addError("is required, but is undefined"),l}var l=this.validateSchema(r,e,i,n);if(l){if(i.throwAll&&l.errors.length)throw new Kr(l)}else throw new Error("Result undefined");return l};function pr(t){var r=typeof t=="string"?t:t.$ref;return typeof r=="string"?r:!1}S.prototype.validateSchema=function(r,e,i,n){var a=new lr(r,e,i,n);if(typeof e=="boolean")e===!0?e={}:e===!1&&(e={type:[]});else if(!e)throw new Error("schema is undefined");if(e.extends)if(Array.isArray(e.extends)){var s={schema:e,ctx:n};e.extends.forEach(this.schemaTraverser.bind(this,s)),e=s.schema,s.schema=null,s.ctx=null,s=null}else e=ie.deepMerge(e,this.superResolve(e.extends,n));var o=pr(e);if(o){var f=this.resolve(e,o,n),u=new hr(f.subschema,i,n.path,f.switchSchema,n.schemas);return this.validateSchema(r,f.subschema,i,u)}var l=i&&i.skipAttributes||[];for(var A in e)if(!ur.ignoreProperties[A]&&l.indexOf(A)<0){var h=null,c=this.attributes[A];if(c)h=c.call(this,r,e,i,n);else if(i.allowUnknownAttributes===!1)throw new ge("Unsupported attribute: "+A,e);h&&a.importErrors(h)}if(typeof i.rewrite=="function"){var E=i.rewrite.call(this,r,e,i,n);a.instance=E}return a};S.prototype.schemaTraverser=function(r,e){r.schema=ie.deepMerge(r.schema,this.superResolve(e,r.ctx))};S.prototype.superResolve=function(r,e){var i=pr(r);return i?this.resolve(r,i,e).subschema:r};S.prototype.resolve=function(r,e,i){if(e=i.resolve(e),i.schemas[e])return{subschema:i.schemas[e],switchSchema:e};var n=sr.parse(e),a=n&&n.hash,s=a&&a.length&&e.substr(0,e.length-a.length);if(!s||!i.schemas[s])throw new ge("no such schema <"+e+">",r);var o=ie.objectGetPath(i.schemas[s],a.substr(1));if(o===void 0)throw new ge("no such schema "+a+" located in <"+s+">",r);return{subschema:o,switchSchema:e}};S.prototype.testType=function(r,e,i,n,a){if(a!==void 0){if(a===null)throw new ge('Unexpected null in "type" keyword');if(typeof this.types[a]=="function")return this.types[a].call(this,r);if(a&&typeof a=="object"){var s=this.validateSchema(r,a,i,n);return s===void 0||!(s&&s.errors.length)}return!0}};var J=S.prototype.types={};J.string=function(r){return typeof r=="string"};J.number=function(r){return typeof r=="number"&&isFinite(r)};J.integer=function(r){return typeof r=="number"&&r%1==0};J.boolean=function(r){return typeof r=="boolean"};J.array=function(r){return Array.isArray(r)};J.null=function(r){return r===null};J.date=function(r){return r instanceof Date};J.any=function(r){return!0};J.object=function(r){return r&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)};mr.exports=S});var vr=D((st,K)=>{"use strict";var Wr=K.exports.Validator=cr();K.exports.ValidatorResult=Y().ValidatorResult;K.exports.ValidatorResultError=Y().ValidatorResultError;K.exports.ValidationError=Y().ValidationError;K.exports.SchemaError=Y().SchemaError;K.exports.SchemaScanResult=we().SchemaScanResult;K.exports.scan=we().scan;K.exports.validate=function(t,r,e){var i=new Wr;return i.validate(t,r,e)}});var Yr={};Sr(Yr,{createConfigsApi:()=>Xr});var yr=Zr(vr());function Xr(t={}){let r=(i,n)=>{var o;let a=`config-${i}`,s=(o=t.retrieve)==null?void 0:o.call(t,a);return typeof s=="object"?me(me({},n),s):typeof s!="undefined"?s:void 0},e=(i,n,a)=>{let o=new yr.Validator().validate(n,i);return o.valid?n:(console.warn("The given configuration does not match the provided schema. Taking the default configuration.",n,o),a)};return i=>(n,a)=>({defineConfigSchema(s,o){let f=r(a.name,o),u=f?e(s,f,o):o;return i.dispatch(l=>Se(me({},l),{configs:Se(me({},l.configs),{[a.name]:u})})),u},getCurrentConfig(){var s;return(s=i.readState(o=>o.configs[a.name]))!=null?s:{}}})}return Yr;})();
4
+ /*! https://mths.be/punycode v1.3.2 by @mathias */
package/src/create.ts CHANGED
@@ -49,7 +49,7 @@ export function createConfigsApi(config: ConfigsConfig = {}): PiralPlugin<PiletC
49
49
  return (ctx) => (_, meta) => ({
50
50
  defineConfigSchema(schema, defaultConfig) {
51
51
  const proposedConfig = readConfig(meta.name, defaultConfig);
52
- const current = validate(schema, proposedConfig, defaultConfig);
52
+ const current = proposedConfig ? validate(schema, proposedConfig, defaultConfig) : defaultConfig;
53
53
 
54
54
  ctx.dispatch((state) => ({
55
55
  ...state,
@@ -58,6 +58,8 @@ export function createConfigsApi(config: ConfigsConfig = {}): PiralPlugin<PiletC
58
58
  [meta.name]: current,
59
59
  },
60
60
  }));
61
+
62
+ return current;
61
63
  },
62
64
  getCurrentConfig() {
63
65
  return ctx.readState((s) => s.configs[meta.name]) ?? {};
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Dict } from 'piral-core';
2
- import { Schema } from 'jsonschema';
1
+ import type { Dict } from 'piral-core';
2
+ import type { Schema } from 'jsonschema';
3
3
 
4
4
  declare module 'piral-core/lib/types/custom' {
5
5
  interface PiletCustomApi extends PiletConfigsApi {}
@@ -20,8 +20,10 @@ export interface PiletConfigsApi {
20
20
  * Defines the available configuration options for the pilet.
21
21
  * @param schema The schema to use for allowing configurations.
22
22
  * @param defaultConfig The default configuration to use.
23
+ * @returns The current configuration, which may be either the
24
+ * default configuration or an override.
23
25
  */
24
- defineConfigSchema<T = any>(schema: Schema, defaultConfig?: T): void;
26
+ defineConfigSchema<T = any>(schema: Schema, defaultConfig?: T): T;
25
27
  /**
26
28
  * Gets the currently available configuration.
27
29
  */