wip:milestone 0 fixes
Some checks failed
CI/CD Pipeline / unit-tests (push) Failing after 1m16s
CI/CD Pipeline / integration-tests (push) Failing after 2m32s
CI/CD Pipeline / lint (push) Successful in 5m22s
CI/CD Pipeline / e2e-tests (push) Has been skipped
CI/CD Pipeline / build (push) Has been skipped

This commit is contained in:
2026-03-15 12:35:42 +02:00
parent 6708cf28a7
commit cffdf8af86
61266 changed files with 4511646 additions and 1938 deletions

9
control-plane-ui/node_modules/outvariant/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) 2021present Artem Zakharchenko
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

146
control-plane-ui/node_modules/outvariant/README.md generated vendored Normal file
View File

@@ -0,0 +1,146 @@
# `outvariant`
Type-safe implementation of invariant with positionals.
## Motivation
### Type-safely
This implementation asserts the given predicate expression so it's treated as non-nullable after the `invariant` call:
```ts
// Regular invariant:
invariant(user, 'Failed to fetch')
user?.firstName // "user" is possibly undefined
// Outvariant:
invariant(user, 'Failed to fetch')
user.firstName // OK, "invariant" ensured the "user" exists
```
### Positionals support
This implementation uses [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) to support dynamic number of positionals:
```js
invariant(predicate, 'Expected %s but got %s', 'one', false)
```
## What is this for?
Invariant is a shorthand function that asserts a given predicate and throws an error if that predicate is false.
Compare these two pieces of code identical in behavior:
```js
if (!token) {
throw new Error(`Expected a token to be set but got ${typeof token}`)
}
```
```js
import { invariant } from 'outvariant'
invariant(token, 'Expected a token to be set but got %s', typeof token)
```
Using `invariant` reduces the visual nesting of the code and leads to cleaner error messages thanks to formatted positionals (i.e. the `%s` (string) positional above).
## Usage
### Install
```sh
npm install outvariant
# or
yarn add outvariant
```
> You may want to install this library as a dev dependency (`-D`) based on your usage.
### Write an assertion
```js
import { invariant } from 'outvariant'
invariant(user, 'Failed to load: expected user, but got %o', user)
```
## Positionals
The following positional tokens are supported:
| Token | Expected value type |
| --------- | ------------------------------------------------------- |
| `%s` | String |
| `%d`/`%i` | Number |
| `%j` | JSON (non-stringified) |
| `%o` | Arbitrary object or object-like (i.e. a class instance) |
Whenever present in the error message, a positional token will look up the value to insert in its place from the arguments given to `invariant`.
```js
invariant(
false,
'Expected the "%s" property but got %j',
// Note that positionals are sensitive to order:
// - "firstName" replaces "%s" because it's first.
// - {"id":1} replaces "%j" because it's second.
'firstName',
{
id: 1,
}
)
```
## Polymorphic errors
It is possible to throw a custom `Error` instance using `invariant.as`:
```js
import { invariant } from 'outvariant'
class NetworkError extends Error {
constructor(message) {
super(message)
}
}
invariant.as(NetworkError, res.fulfilled, 'Failed to handle response')
```
Note that providing a custom error constructor as the argument to `invariant.as` requires the custom constructor's signature to be compatible with the `Error` class constructor.
If your error constructor has a different signature, you can pass a function as the first argument to `invariant.as` that creates a new custom error instance.
```js
import { invariant } from 'outvariant'
class NetworkError extends Error {
constructor(statusCode, message) {
super(message)
this.statusCode = statusCode
}
}
invariant.as(
(message) => new NetworkError(500, message),
res.fulfilled,
'Failed to handle response'
)
```
Abstract the error into helper functions for flexibility:
```js
function toNetworkError(statusCode) {
return (message) => new NetworkError(statusCode, message)
}
invariant.as(toNetworkError(404), res?.user?.id, 'User Not Found')
invariant.as(toNetworkError(500), res.fulfilled, 'Internal Server Error')
```
## Contributing
Please [open an issue](https://github.com/open-draft/outvariant/issues) or [submit a pull request](https://github.com/open-draft/outvariant/pulls) if you wish to contribute. Thank you.

View File

@@ -0,0 +1,21 @@
declare class InvariantError extends Error {
readonly message: string;
name: string;
constructor(message: string, ...positionals: any[]);
}
interface CustomErrorConstructor {
new (message: string): Error;
}
interface CustomErrorFactory {
(message: string): Error;
}
declare type CustomError = CustomErrorConstructor | CustomErrorFactory;
declare type Invariant = {
(predicate: unknown, message: string, ...positionals: any[]): asserts predicate;
as(ErrorConstructor: CustomError, predicate: unknown, message: string, ...positionals: unknown[]): asserts predicate;
};
declare const invariant: Invariant;
declare function format(message: string, ...positionals: any[]): string;
export { CustomError, CustomErrorConstructor, CustomErrorFactory, InvariantError, format, invariant };

120
control-plane-ui/node_modules/outvariant/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,120 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
InvariantError: () => InvariantError,
format: () => format,
invariant: () => invariant
});
module.exports = __toCommonJS(src_exports);
// src/format.ts
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
function serializePositional(positional, flag) {
switch (flag) {
case "s":
return positional;
case "d":
case "i":
return Number(positional);
case "j":
return JSON.stringify(positional);
case "o": {
if (typeof positional === "string") {
return positional;
}
const json = JSON.stringify(positional);
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
return positional;
}
return json;
}
}
}
function format(message, ...positionals) {
if (positionals.length === 0) {
return message;
}
let positionalIndex = 0;
let formattedMessage = message.replace(
POSITIONALS_EXP,
(match, isEscaped, _, flag) => {
const positional = positionals[positionalIndex];
const value = serializePositional(positional, flag);
if (!isEscaped) {
positionalIndex++;
return value;
}
return match;
}
);
if (positionalIndex < positionals.length) {
formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
}
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
return formattedMessage;
}
// src/invariant.ts
var STACK_FRAMES_TO_IGNORE = 2;
function cleanErrorStack(error) {
if (!error.stack) {
return;
}
const nextStack = error.stack.split("\n");
nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
error.stack = nextStack.join("\n");
}
var InvariantError = class extends Error {
constructor(message, ...positionals) {
super(message);
this.message = message;
this.name = "Invariant Violation";
this.message = format(message, ...positionals);
cleanErrorStack(this);
}
};
var invariant = (predicate, message, ...positionals) => {
if (!predicate) {
throw new InvariantError(message, ...positionals);
}
};
invariant.as = (ErrorConstructor, predicate, message, ...positionals) => {
if (!predicate) {
const formatMessage = positionals.length === 0 ? message : format(message, ...positionals);
let error;
try {
error = Reflect.construct(ErrorConstructor, [
formatMessage
]);
} catch (err) {
error = ErrorConstructor(formatMessage);
}
throw error;
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
InvariantError,
format,
invariant
});
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

91
control-plane-ui/node_modules/outvariant/lib/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,91 @@
// src/format.ts
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
function serializePositional(positional, flag) {
switch (flag) {
case "s":
return positional;
case "d":
case "i":
return Number(positional);
case "j":
return JSON.stringify(positional);
case "o": {
if (typeof positional === "string") {
return positional;
}
const json = JSON.stringify(positional);
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
return positional;
}
return json;
}
}
}
function format(message, ...positionals) {
if (positionals.length === 0) {
return message;
}
let positionalIndex = 0;
let formattedMessage = message.replace(
POSITIONALS_EXP,
(match, isEscaped, _, flag) => {
const positional = positionals[positionalIndex];
const value = serializePositional(positional, flag);
if (!isEscaped) {
positionalIndex++;
return value;
}
return match;
}
);
if (positionalIndex < positionals.length) {
formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
}
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
return formattedMessage;
}
// src/invariant.ts
var STACK_FRAMES_TO_IGNORE = 2;
function cleanErrorStack(error) {
if (!error.stack) {
return;
}
const nextStack = error.stack.split("\n");
nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
error.stack = nextStack.join("\n");
}
var InvariantError = class extends Error {
constructor(message, ...positionals) {
super(message);
this.message = message;
this.name = "Invariant Violation";
this.message = format(message, ...positionals);
cleanErrorStack(this);
}
};
var invariant = (predicate, message, ...positionals) => {
if (!predicate) {
throw new InvariantError(message, ...positionals);
}
};
invariant.as = (ErrorConstructor, predicate, message, ...positionals) => {
if (!predicate) {
const formatMessage = positionals.length === 0 ? message : format(message, ...positionals);
let error;
try {
error = Reflect.construct(ErrorConstructor, [
formatMessage
]);
} catch (err) {
error = ErrorConstructor(formatMessage);
}
throw error;
}
};
export {
InvariantError,
format,
invariant
};
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

47
control-plane-ui/node_modules/outvariant/package.json generated vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "outvariant",
"version": "1.4.3",
"description": "Type-safe implementation of invariant with positionals.",
"main": "lib/index.js",
"module": "lib/index.mjs",
"typings": "lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"require": "./lib/index.js",
"default": "./lib/index.mjs"
}
},
"author": "Artem Zakharchenko",
"license": "MIT",
"scripts": {
"test": "jest",
"clean": "rimraf ./lib",
"build": "yarn clean && tsup",
"prepublishOnly": "yarn test && yarn build",
"release": "release publish"
},
"files": [
"lib"
],
"keywords": [
"invariant",
"outvariant",
"exception",
"positional"
],
"devDependencies": {
"@ossjs/release": "^0.8.0",
"@types/jest": "^26.0.23",
"jest": "^27.0.6",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0",
"tsup": "^6.2.3",
"typescript": "^4.3.4"
},
"repository": {
"type": "git",
"url": "https://github.com/open-draft/outvariant"
}
}