@sandbox-kit/sandbox 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -46
- package/dist/client/client.d.ts +7 -126
- package/dist/client/client.js +37 -564
- package/dist/client/errors.d.ts +35 -0
- package/dist/client/errors.js +88 -0
- package/dist/client/operation.d.ts +12 -0
- package/dist/client/operation.js +73 -0
- package/dist/client/sandbox.d.ts +33 -0
- package/dist/client/sandbox.js +160 -0
- package/dist/client/types.d.ts +63 -0
- package/dist/client/types.js +3 -0
- package/dist/client/validation.d.ts +9 -0
- package/dist/client/validation.js +221 -0
- package/dist/contracts/sandbox_data_contracts.d.ts +10 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/net_validate.d.ts +4 -0
- package/dist/internal/net_validate.js +53 -0
- package/package.json +9 -3
|
@@ -22,13 +22,16 @@ export type SecretReference = StripProto<ProtoSecretReference>;
|
|
|
22
22
|
export type ObservabilityConfig = StripProto<ProtoObservabilityConfig>;
|
|
23
23
|
export type SandboxInfo = StripProto<ProtoSandboxInfo>;
|
|
24
24
|
export type CreateResult = StripProto<ProtoCreateResult>;
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export type
|
|
30
|
-
export type
|
|
31
|
-
export type
|
|
25
|
+
/**
|
|
26
|
+
* Public lifecycle options for `Backend` and provider adapters (ms timeouts).
|
|
27
|
+
* Same duration remapping as {@link CreateOptions}; wire `Duration` stays private.
|
|
28
|
+
*/
|
|
29
|
+
export type StartOptions = DurationFieldsToMs<StripProto<ProtoStartOptions>>;
|
|
30
|
+
export type StopOptions = DurationFieldsToMs<StripProto<ProtoStopOptions>>;
|
|
31
|
+
export type PauseOptions = DurationFieldsToMs<StripProto<ProtoPauseOptions>>;
|
|
32
|
+
export type TerminateOptions = DurationFieldsToMs<StripProto<ProtoTerminateOptions>>;
|
|
33
|
+
export type ArchiveOptions = DurationFieldsToMs<StripProto<ProtoArchiveOptions>>;
|
|
34
|
+
export type DeleteOptions = DurationFieldsToMs<StripProto<ProtoDeleteOptions>>;
|
|
32
35
|
export type ExitResult = StripProto<ProtoExitResult>;
|
|
33
36
|
export type MetadataValue = StripProto<ProtoMetadataValue>;
|
|
34
37
|
export type MetadataList = StripProto<ProtoMetadataList>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Shared network / env name validators used by provider create checks. */
|
|
2
|
+
export function validEnvName(value) {
|
|
3
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(value);
|
|
4
|
+
}
|
|
5
|
+
export function validDomain(value) {
|
|
6
|
+
const domain = value.startsWith("*.") ? value.slice(2) : value;
|
|
7
|
+
return (domain.length <= 253 &&
|
|
8
|
+
/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.?$/i.test(domain));
|
|
9
|
+
}
|
|
10
|
+
export function validCidr(value) {
|
|
11
|
+
const separator = value.lastIndexOf("/");
|
|
12
|
+
if (separator <= 0)
|
|
13
|
+
return false;
|
|
14
|
+
const address = value.slice(0, separator);
|
|
15
|
+
const prefix = Number(value.slice(separator + 1));
|
|
16
|
+
if (!Number.isInteger(prefix))
|
|
17
|
+
return false;
|
|
18
|
+
return address.includes(":")
|
|
19
|
+
? prefix >= 0 && prefix <= 128 && validIpv6(address)
|
|
20
|
+
: prefix >= 0 && prefix <= 32 && validIpv4(address);
|
|
21
|
+
}
|
|
22
|
+
function validIpv4(value) {
|
|
23
|
+
const parts = value.split(".");
|
|
24
|
+
return (parts.length === 4 &&
|
|
25
|
+
parts.every((part) => /^(0|[1-9][0-9]{0,2})$/.test(part) && Number(part) <= 255));
|
|
26
|
+
}
|
|
27
|
+
function validIpv6(value) {
|
|
28
|
+
if ((value.match(/::/g)?.length ?? 0) > 1)
|
|
29
|
+
return false;
|
|
30
|
+
const halves = value.split("::");
|
|
31
|
+
if (halves.length > 2)
|
|
32
|
+
return false;
|
|
33
|
+
const count = (part) => {
|
|
34
|
+
if (part === "")
|
|
35
|
+
return 0;
|
|
36
|
+
const groups = part.split(":");
|
|
37
|
+
let total = 0;
|
|
38
|
+
for (const group of groups) {
|
|
39
|
+
if (/^[0-9a-f]{1,4}$/i.test(group))
|
|
40
|
+
total++;
|
|
41
|
+
else if (validIpv4(group))
|
|
42
|
+
total += 2;
|
|
43
|
+
else
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return total;
|
|
47
|
+
};
|
|
48
|
+
const left = count(halves[0] ?? "");
|
|
49
|
+
const right = count(halves[1] ?? "");
|
|
50
|
+
return (left !== undefined &&
|
|
51
|
+
right !== undefined &&
|
|
52
|
+
(halves.length === 2 ? left + right < 8 : left === 8));
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sandbox-kit/sandbox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "one pluggable sdk for all your sandbox providers",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sandbox-kit",
|
|
7
|
+
"sandbox",
|
|
8
|
+
"sdk"
|
|
9
|
+
],
|
|
5
10
|
"license": "MIT",
|
|
6
11
|
"type": "module",
|
|
7
12
|
"packageManager": "npm@11.19.0",
|
|
@@ -54,11 +59,12 @@
|
|
|
54
59
|
"dependencies": {
|
|
55
60
|
"@bufbuild/protobuf": "2.16.0",
|
|
56
61
|
"@bufbuild/protovalidate": "1.3.0",
|
|
57
|
-
"@sandbox-kit/contracts": "0.1.
|
|
62
|
+
"@sandbox-kit/contracts": "0.1.2"
|
|
58
63
|
},
|
|
59
64
|
"scripts": {
|
|
65
|
+
"clean": "rm -rf dist",
|
|
60
66
|
"build": "tsc -p tsconfig.build.json",
|
|
61
|
-
"prepublishOnly": "npm run build",
|
|
67
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
62
68
|
"test": "vitest run"
|
|
63
69
|
},
|
|
64
70
|
"devDependencies": {
|