@akterjs/cli 0.0.0-stage → 0.1.0
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 +201 -0
- package/README.md +47 -2
- package/dist/Argument-D81dqizB.mjs +57 -0
- package/dist/Array-B4kuTQeW.mjs +2323 -0
- package/dist/Boolean-kILIvmhE.mjs +26 -0
- package/dist/ChildProcess-BCIwxPGc.mjs +577 -0
- package/dist/CliError-Cf5xqkkj.mjs +633 -0
- package/dist/Command-Dzq9KM-h.mjs +5135 -0
- package/dist/Config-B6OND9WR.mjs +854 -0
- package/dist/Console-BKHUkH6a.mjs +141 -0
- package/dist/Data-CeCULr0-.mjs +251 -0
- package/dist/Digest-CBd3uv5B.mjs +348 -0
- package/dist/Duration-EH9Vy4U6.mjs +791 -0
- package/dist/Effect-CKFpqbmw.mjs +12911 -0
- package/dist/FileSystem-4pPcEb_i.mjs +1366 -0
- package/dist/HttpClientError-BUeMWx70.mjs +303 -0
- package/dist/HttpClientResponse-D5ZKICVV.mjs +855 -0
- package/dist/Match-CGPLZYrV.mjs +434 -0
- package/dist/MutableHashMap-f8nW8AJR.mjs +376 -0
- package/dist/MutableHashSet-_HI572Ya.mjs +155 -0
- package/dist/MutableRef-D4Qv592C.mjs +107 -0
- package/dist/Number-BvkRkfc-.mjs +137 -0
- package/dist/Option-DkxSnBhp.mjs +3967 -0
- package/dist/Order-C1JC991I.mjs +481 -0
- package/dist/Path-Djdv_eF5.mjs +130 -0
- package/dist/Queue-CO5UQ6os.mjs +1394 -0
- package/dist/Redacted-RkJrG5Me.mjs +160 -0
- package/dist/Ref-BIPOxJNH.mjs +267 -0
- package/dist/Runtime-BInIAwK3.mjs +297 -0
- package/dist/Schema-MiKt5K1v.mjs +10999 -0
- package/dist/SecureRandom-B_U4ysO3.mjs +279 -0
- package/dist/Semaphore-DOVJ4ZGS.mjs +177 -0
- package/dist/Stdio-KylmOBX_.mjs +74 -0
- package/dist/Stream-bK9QIETN.mjs +4012 -0
- package/dist/String-q5dcsVe4.mjs +351 -0
- package/dist/TerminalCapabilities-w_44MAca.mjs +1769 -0
- package/dist/WebCrypto-ZI_GNVlw.mjs +33 -0
- package/dist/actor-call.service-CGM_vD9u.mjs +1269 -0
- package/dist/actor-client.adapter-Coem7gF1.mjs +3691 -0
- package/dist/akter-program.config-C4cXx4Fr.mjs +7034 -0
- package/dist/akter.cli.mjs +5 -0
- package/dist/app-cli.config.mjs +49 -0
- package/dist/app-entry.pure.mjs +31 -0
- package/dist/archive/akter-archive.schema.mjs +65 -0
- package/dist/archive/akter-archive.service.mjs +309 -0
- package/dist/archive/archive-cli.config.mjs +45 -0
- package/dist/archive/archive-invalid.errors.mjs +5 -0
- package/dist/archive/archived-lineage.pure.mjs +13 -0
- package/dist/archive/tar.pure.mjs +291 -0
- package/dist/archive/zstd.adapter.mjs +46 -0
- package/dist/bench/bench-report.pure.mjs +120 -0
- package/dist/bench/bench-runner.pure.mjs +89 -0
- package/dist/bench/bench.service.mjs +301 -0
- package/dist/cli-runtime.layer-BqK2mmVL.mjs +1191 -0
- package/dist/cli-runtime.layer.mjs +1 -0
- package/dist/cloud-client.adapter-Cy1BjDbG.mjs +3186 -0
- package/dist/cloud-client.adapter-DOVMoYAj.mjs +304 -0
- package/dist/command/akter-commands.config.mjs +32 -0
- package/dist/command/akter-program.config.mjs +1 -0
- package/dist/credentials/credentials.service.mjs +226 -0
- package/dist/credentials/keychain.adapter.mjs +92 -0
- package/dist/credentials/login.config.mjs +251 -0
- package/dist/deploy/auth/api-attempt.service.mjs +30 -0
- package/dist/deploy/auth/token-refresh.errors.mjs +4 -0
- package/dist/deploy/build-bundle.adapter.mjs +133 -0
- package/dist/deploy/build-manifest.pure.mjs +44 -0
- package/dist/deploy/cloud-client.adapter.mjs +1 -0
- package/dist/deploy/cloud-url.pure.mjs +17 -0
- package/dist/deploy/deploy-failed.errors.mjs +17 -0
- package/dist/deploy/deploy.service.mjs +156 -0
- package/dist/deploy/request-failure.pure.mjs +87 -0
- package/dist/dev-runner.pure.mjs +30 -0
- package/dist/docs/doc-topics.pure.mjs +21 -0
- package/dist/docs/docs.config.mjs +1 -0
- package/dist/docs.config-_21Xi6HU.mjs +190 -0
- package/dist/export/actor-export.service.mjs +267 -0
- package/dist/export/export-failed.errors.mjs +4 -0
- package/dist/export/export-failure.pure.mjs +18 -0
- package/dist/export/ordered-lines.pure.mjs +43 -0
- package/dist/export/ranged-download.pure.mjs +66 -0
- package/dist/export/snapshot-download.pure.mjs +86 -0
- package/dist/history-runner.pure.mjs +186 -0
- package/dist/history-since.pure.mjs +17 -0
- package/dist/hosted-runtime.layer-Cx3IPsEd.mjs +16358 -0
- package/dist/local/environment-cli.config.mjs +90 -0
- package/dist/local/environment-runner.pure.mjs +75 -0
- package/dist/local/local-cli.config.mjs +159 -0
- package/dist/logs/log-follow.config.mjs +21 -0
- package/dist/logs/log-follow.service.mjs +87 -0
- package/dist/logs/log-lines.pure.mjs +44 -0
- package/dist/migrate-runner.pure.mjs +28 -0
- package/dist/operation-input.pure-CS9iUhqK.mjs +1383 -0
- package/dist/operation-registry.pure-DVC8EDgj.mjs +283 -0
- package/dist/registry/actor-call.service.mjs +1 -0
- package/dist/registry/actor-commands.config.mjs +127 -0
- package/dist/registry/actor-refusal.pure.mjs +34 -0
- package/dist/registry/approval.service.mjs +80 -0
- package/dist/registry/cloud-commands.config.mjs +151 -0
- package/dist/registry/cloud-served.pure.mjs +31 -0
- package/dist/registry/operation-call.service.mjs +262 -0
- package/dist/registry/operation-input.pure.mjs +1 -0
- package/dist/registry/operation-output.pure.mjs +91 -0
- package/dist/registry/served-command.config.mjs +57 -0
- package/dist/runner-exited.errors.mjs +10 -0
- package/dist/terminal/cli-exit.errors.mjs +38 -0
- package/dist/terminal/cli-failure.pure.mjs +31 -0
- package/dist/terminal/confirm.adapter.mjs +27 -0
- package/package.json +61 -3
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { Vn as effect, Xt as succeed, aa as Service, en as sync, w as clockWith } from "./Effect-CKFpqbmw.mjs";
|
|
2
|
+
import { t as WebCrypto } from "./WebCrypto-ZI_GNVlw.mjs";
|
|
3
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/ulid.js
|
|
4
|
+
const maxTimestamp = 2 ** 48 - 1;
|
|
5
|
+
const base32Chars = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
6
|
+
/** @internal */
|
|
7
|
+
const ulidString = (timestampMillis, bytes) => {
|
|
8
|
+
if (bytes.length !== 10) throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`);
|
|
9
|
+
const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp);
|
|
10
|
+
let out = "";
|
|
11
|
+
for (let shift = 45; shift >= 0; shift -= 5) out += base32Chars[Math.floor(timestamp / 2 ** shift) & 31];
|
|
12
|
+
let accumulator = 0;
|
|
13
|
+
let bits = 0;
|
|
14
|
+
for (const byte of bytes) {
|
|
15
|
+
accumulator = accumulator << 8 | byte;
|
|
16
|
+
bits += 8;
|
|
17
|
+
while (bits >= 5) {
|
|
18
|
+
bits -= 5;
|
|
19
|
+
out += base32Chars[accumulator >>> bits & 31];
|
|
20
|
+
}
|
|
21
|
+
accumulator &= (1 << bits) - 1;
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Makes a ULID generator in the ULID spec's monotonic mode: within a
|
|
27
|
+
* millisecond, or when the clock moves back, the 80-bit random part of the last
|
|
28
|
+
* ULID is incremented. The ordering ends at the maximum timestamp, 2^48 − 1 ms,
|
|
29
|
+
* which overflow cannot advance. `randomBytes` is only called for fresh
|
|
30
|
+
* randomness.
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
const makeMonotonic = () => {
|
|
35
|
+
let lastTimestamp = -1;
|
|
36
|
+
const random = /* @__PURE__ */ new Uint8Array(10);
|
|
37
|
+
return (timestampMillis, randomBytes) => {
|
|
38
|
+
const timestamp = timestampMillis >= 0 ? Math.min(Math.trunc(timestampMillis), maxTimestamp) : 0;
|
|
39
|
+
if (timestamp > lastTimestamp) {
|
|
40
|
+
lastTimestamp = timestamp;
|
|
41
|
+
random.set(randomBytes());
|
|
42
|
+
} else if (!increment(random)) {
|
|
43
|
+
lastTimestamp = Math.min(lastTimestamp + 1, maxTimestamp);
|
|
44
|
+
random.set(randomBytes());
|
|
45
|
+
}
|
|
46
|
+
return ulidString(lastTimestamp, random);
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const increment = (bytes) => {
|
|
50
|
+
for (let i = bytes.length - 1; i >= 0; i--) {
|
|
51
|
+
if (bytes[i] !== 255) {
|
|
52
|
+
bytes[i]++;
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
bytes[i] = 0;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
};
|
|
59
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/uuid.js
|
|
60
|
+
const hex = /*#__PURE__*/ Array.from({ length: 256 }, (_, byte) => byte.toString(16).padStart(2, "0"));
|
|
61
|
+
/** @internal */
|
|
62
|
+
const stringify = (bytes) => {
|
|
63
|
+
if (bytes.length < 16) return [
|
|
64
|
+
bytes.subarray(0, 4),
|
|
65
|
+
bytes.subarray(4, 6),
|
|
66
|
+
bytes.subarray(6, 8),
|
|
67
|
+
bytes.subarray(8, 10),
|
|
68
|
+
bytes.subarray(10, 16)
|
|
69
|
+
].map((segment) => Array.from(segment, (byte) => hex[byte]).join("")).join("-");
|
|
70
|
+
return hex[bytes[0]] + hex[bytes[1]] + hex[bytes[2]] + hex[bytes[3]] + "-" + hex[bytes[4]] + hex[bytes[5]] + "-" + hex[bytes[6]] + hex[bytes[7]] + "-" + hex[bytes[8]] + hex[bytes[9]] + "-" + hex[bytes[10]] + hex[bytes[11]] + hex[bytes[12]] + hex[bytes[13]] + hex[bytes[14]] + hex[bytes[15]];
|
|
71
|
+
};
|
|
72
|
+
/** @internal */
|
|
73
|
+
const v4Bytes = (bytes) => {
|
|
74
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
75
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
76
|
+
return bytes;
|
|
77
|
+
};
|
|
78
|
+
const maxV7Timestamp = 2 ** 48 - 1;
|
|
79
|
+
/** @internal */
|
|
80
|
+
const v7Bytes = (timestampMillis, bytes) => {
|
|
81
|
+
const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp);
|
|
82
|
+
bytes[0] = Math.floor(timestamp / 2 ** 40);
|
|
83
|
+
bytes[1] = Math.floor(timestamp / 2 ** 32) & 255;
|
|
84
|
+
bytes[2] = Math.floor(timestamp / 2 ** 24) & 255;
|
|
85
|
+
bytes[3] = Math.floor(timestamp / 2 ** 16) & 255;
|
|
86
|
+
bytes[4] = Math.floor(timestamp / 256) & 255;
|
|
87
|
+
bytes[5] = timestamp & 255;
|
|
88
|
+
bytes[6] = bytes[6] & 15 | 112;
|
|
89
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
90
|
+
return bytes;
|
|
91
|
+
};
|
|
92
|
+
const clampV7Timestamp = (timestampMillis) => timestampMillis >= 0 ? Math.min(Math.trunc(timestampMillis), maxV7Timestamp) : 0;
|
|
93
|
+
const maxV7Counter = 2 ** 42 - 1;
|
|
94
|
+
/**
|
|
95
|
+
* Makes a UUIDv7 generator that orders the UUIDs it returns, following RFC
|
|
96
|
+
* 9562 §6.2 Method 1. A 42-bit counter fills the 12 bits of `rand_a` and the
|
|
97
|
+
* top 30 bits of `rand_b`; the last 32 bits stay random. The ordering ends at
|
|
98
|
+
* the maximum timestamp, 2^48 − 1 ms, which counter overflow cannot advance.
|
|
99
|
+
*
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
const makeV7Monotonic = () => {
|
|
103
|
+
let lastTimestamp = -1;
|
|
104
|
+
let counter = 0;
|
|
105
|
+
return (timestampMillis, bytes) => {
|
|
106
|
+
const timestamp = clampV7Timestamp(timestampMillis);
|
|
107
|
+
if (timestamp > lastTimestamp) {
|
|
108
|
+
lastTimestamp = timestamp;
|
|
109
|
+
counter = seedV7Counter(bytes);
|
|
110
|
+
} else if (counter < maxV7Counter) counter++;
|
|
111
|
+
else {
|
|
112
|
+
lastTimestamp = Math.min(lastTimestamp + 1, maxV7Timestamp);
|
|
113
|
+
counter = seedV7Counter(bytes);
|
|
114
|
+
}
|
|
115
|
+
v7Bytes(lastTimestamp, bytes);
|
|
116
|
+
const high = Math.floor(counter / 2 ** 30);
|
|
117
|
+
const low = counter - high * 2 ** 30;
|
|
118
|
+
bytes[6] = 112 | high >>> 8;
|
|
119
|
+
bytes[7] = high & 255;
|
|
120
|
+
bytes[8] = 128 | low >>> 24;
|
|
121
|
+
bytes[9] = low >>> 16 & 255;
|
|
122
|
+
bytes[10] = low >>> 8 & 255;
|
|
123
|
+
bytes[11] = low & 255;
|
|
124
|
+
return bytes;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const seedV7Counter = (bytes) => ((bytes[6] & 7) << 8 | bytes[7]) * 2 ** 30 + ((bytes[8] & 63) << 24 | bytes[9] << 16 | bytes[10] << 8 | bytes[11]);
|
|
128
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/crypto/SecureRandom.js
|
|
129
|
+
/**
|
|
130
|
+
* Cryptographically secure randomness: random bytes, uniform integers,
|
|
131
|
+
* shuffles, UUIDv4, UUIDv7, and ULIDs.
|
|
132
|
+
*
|
|
133
|
+
* The {@link SecureRandom} service is built from one `randomBytes` primitive
|
|
134
|
+
* with {@link make}. {@link layerWebCrypto} draws from `getRandomValues` on
|
|
135
|
+
* the `WebCrypto` reference. The `*Unsafe` functions draw synchronously from
|
|
136
|
+
* `globalThis.crypto` for code that cannot use a service, such as constructors
|
|
137
|
+
* and model defaults.
|
|
138
|
+
*
|
|
139
|
+
* Every operation has a `never` error channel. A bad size or an empty range is
|
|
140
|
+
* a defect.
|
|
141
|
+
*
|
|
142
|
+
* **Gotchas**
|
|
143
|
+
*
|
|
144
|
+
* There are no float, boolean, or full-range integer helpers. Insecure random
|
|
145
|
+
* numbers belong to `effect/Random`, and a secure bit is `randomBytes(1)`.
|
|
146
|
+
*
|
|
147
|
+
* @stability unstable
|
|
148
|
+
* @since 4.0.0
|
|
149
|
+
*/
|
|
150
|
+
/**
|
|
151
|
+
* Service that generates cryptographically secure random values.
|
|
152
|
+
*
|
|
153
|
+
* **Details**
|
|
154
|
+
*
|
|
155
|
+
* Every operation is derived from `randomBytes`. See {@link make}.
|
|
156
|
+
*
|
|
157
|
+
* @stability unstable
|
|
158
|
+
* @category services
|
|
159
|
+
* @since 4.0.0
|
|
160
|
+
*/
|
|
161
|
+
var SecureRandom = class extends (/*#__PURE__*/ Service()("effect/crypto/SecureRandom")) {};
|
|
162
|
+
const checkSize = (size) => {
|
|
163
|
+
if (!Number.isSafeInteger(size) || size < 0) throw new RangeError("size must be a non-negative safe integer");
|
|
164
|
+
};
|
|
165
|
+
const readUint53 = (bytes) => (bytes[0] & 31) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 256 + bytes[6];
|
|
166
|
+
const intBetweenUnsafe = (min, max, halfOpen, draw) => {
|
|
167
|
+
const minInt = Math.ceil(min);
|
|
168
|
+
const maxInt = Math.floor(max);
|
|
169
|
+
if (!Number.isSafeInteger(minInt) || !Number.isSafeInteger(maxInt)) throw new RangeError("bounds must round to safe integers");
|
|
170
|
+
if (maxInt - minInt < Number.MAX_SAFE_INTEGER) {
|
|
171
|
+
const count = maxInt - minInt + (halfOpen ? 0 : 1);
|
|
172
|
+
if (count <= 0) throw new RangeError("range must contain at least one integer");
|
|
173
|
+
if (count === 1) return minInt + 0;
|
|
174
|
+
const bucketSize = (2 ** 53 - 2 ** 53 % count) / count;
|
|
175
|
+
const limit = bucketSize * count;
|
|
176
|
+
while (true) {
|
|
177
|
+
const value = readUint53(draw());
|
|
178
|
+
if (value < limit) return minInt + (value - value % bucketSize) / bucketSize;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const lower = BigInt(minInt);
|
|
182
|
+
const count = BigInt(maxInt) - lower + (halfOpen ? BigInt(0) : BigInt(1));
|
|
183
|
+
const wide = count > BigInt(1) << BigInt(53);
|
|
184
|
+
const bucketSize = (wide ? BigInt(1) << BigInt(54) : BigInt(1) << BigInt(53)) / count;
|
|
185
|
+
const limit = bucketSize * count;
|
|
186
|
+
while (true) {
|
|
187
|
+
const bytes = draw();
|
|
188
|
+
const value = BigInt(readUint53(bytes)) + (wide && (bytes[0] & 32) !== 0 ? BigInt(1) << BigInt(53) : BigInt(0));
|
|
189
|
+
if (value < limit) return Number(lower + value / bucketSize);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const makeUuid = (bytes, randomBytes, format) => {
|
|
193
|
+
const uuid = bytes(randomBytes(16));
|
|
194
|
+
return format === "bytes" ? uuid : stringify(uuid);
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Creates a `SecureRandom` service from a secure byte source.
|
|
198
|
+
*
|
|
199
|
+
* **When to use**
|
|
200
|
+
*
|
|
201
|
+
* Use to build the service for a platform integration, a custom runtime, or a
|
|
202
|
+
* seeded test double.
|
|
203
|
+
*
|
|
204
|
+
* **Details**
|
|
205
|
+
*
|
|
206
|
+
* Every operation is derived from `randomBytes`. Sizes are checked before it
|
|
207
|
+
* is called, and an exception it throws is a defect. Each service orders its
|
|
208
|
+
* own UUIDv7s and ULIDs, independently of other services and of the
|
|
209
|
+
* `*Unsafe` functions.
|
|
210
|
+
*
|
|
211
|
+
* **Gotchas**
|
|
212
|
+
*
|
|
213
|
+
* `randomBytes` must return a fresh array of exactly `size` secure random
|
|
214
|
+
* bytes. UUID formatting mutates the returned array.
|
|
215
|
+
*
|
|
216
|
+
* **Example** (Creating a SecureRandom service)
|
|
217
|
+
*
|
|
218
|
+
* ```ts import.meta.vitest
|
|
219
|
+
* import { Effect } from "effect"
|
|
220
|
+
* import { SecureRandom } from "effect/crypto"
|
|
221
|
+
*
|
|
222
|
+
* const random = SecureRandom.make((size) => globalThis.crypto.getRandomValues(new Uint8Array(size)))
|
|
223
|
+
*
|
|
224
|
+
* const bytes = await Effect.runPromise(random.randomBytes(4))
|
|
225
|
+
* bytes.length // => 4
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @stability unstable
|
|
229
|
+
* @category constructors
|
|
230
|
+
* @since 4.0.0
|
|
231
|
+
*/
|
|
232
|
+
const make = (randomBytes) => {
|
|
233
|
+
const randomBytesChecked = (size) => {
|
|
234
|
+
checkSize(size);
|
|
235
|
+
return randomBytes(size);
|
|
236
|
+
};
|
|
237
|
+
const draw = () => randomBytes(7);
|
|
238
|
+
const uuidV7 = makeV7Monotonic();
|
|
239
|
+
const ulid = makeMonotonic();
|
|
240
|
+
const ulidRandomBytes = () => randomBytes(10);
|
|
241
|
+
return {
|
|
242
|
+
randomBytes: (size) => sync(() => randomBytesChecked(size)),
|
|
243
|
+
intBetween: (min, max, options) => sync(() => intBetweenUnsafe(min, max, options?.halfOpen ?? false, draw)),
|
|
244
|
+
shuffle: (elements) => sync(() => {
|
|
245
|
+
const buffer = Array.from(elements);
|
|
246
|
+
for (let i = buffer.length - 1; i >= 1; i--) {
|
|
247
|
+
const index = intBetweenUnsafe(0, i, false, draw);
|
|
248
|
+
const value = buffer[i];
|
|
249
|
+
buffer[i] = buffer[index];
|
|
250
|
+
buffer[index] = value;
|
|
251
|
+
}
|
|
252
|
+
return buffer;
|
|
253
|
+
}),
|
|
254
|
+
uuidV4: (options) => sync(() => makeUuid(v4Bytes, randomBytes, options?.format)),
|
|
255
|
+
uuidV7: (options) => clockWith((clock) => sync(() => makeUuid((bytes) => uuidV7(clock.currentTimeMillisUnsafe(), bytes), randomBytes, options?.format))),
|
|
256
|
+
ulid: clockWith((clock) => sync(() => ulid(clock.currentTimeMillisUnsafe(), ulidRandomBytes)))
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
const fillRandom = (crypto, size) => {
|
|
260
|
+
const bytes = new Uint8Array(size);
|
|
261
|
+
for (let offset = 0; offset < size; offset += 65536) crypto.getRandomValues(bytes.subarray(offset, offset + 65536));
|
|
262
|
+
return bytes;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Layer that provides `SecureRandom` from `getRandomValues` on the `WebCrypto`
|
|
266
|
+
* reference.
|
|
267
|
+
*
|
|
268
|
+
* **Details**
|
|
269
|
+
*
|
|
270
|
+
* Requests above the 65,536-byte `getRandomValues` limit are filled in chunks.
|
|
271
|
+
* Only `getRandomValues` is needed, so the layer also works in insecure browser
|
|
272
|
+
* contexts, which have no `crypto.subtle`.
|
|
273
|
+
*
|
|
274
|
+
* @stability unstable
|
|
275
|
+
* @category layers
|
|
276
|
+
* @since 4.0.0
|
|
277
|
+
*/
|
|
278
|
+
const layerWebCrypto = /*#__PURE__*/ effect(SecureRandom, /*#__PURE__*/ WebCrypto.use((crypto) => succeed(make((size) => fillRandom(crypto, size)))));
|
|
279
|
+
export { layerWebCrypto as n, SecureRandom as t };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { Sn as identity, mt as withFiber } from "./Option-DkxSnBhp.mjs";
|
|
2
|
+
import { Ai as getCurrentFiber, Bi as scope, Gi as sync, Hi as succeed, Ii as onExitPrimitive, Ki as uninterruptibleMask, Li as onExitUnsafe, Oi as flatMap, Ui as succeedNone, Vi as scopeAddFinalizer, Wi as suspend, mi as callback, pi as asSome, qi as void_ } from "./Effect-CKFpqbmw.mjs";
|
|
3
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Semaphore.js
|
|
4
|
+
/**
|
|
5
|
+
* Creates a `Semaphore` synchronously with the specified total
|
|
6
|
+
* number of permits.
|
|
7
|
+
*
|
|
8
|
+
* **When to use**
|
|
9
|
+
*
|
|
10
|
+
* Use to construct a semaphore synchronously when an immediate value is
|
|
11
|
+
* required outside an Effect workflow.
|
|
12
|
+
*
|
|
13
|
+
* **Example** (Creating an unsafe semaphore)
|
|
14
|
+
*
|
|
15
|
+
* ```ts import.meta.vitest
|
|
16
|
+
* import { Effect, Semaphore } from "effect"
|
|
17
|
+
*
|
|
18
|
+
* const semaphore = Semaphore.makeUnsafe(3)
|
|
19
|
+
*
|
|
20
|
+
* const task = (id: number) =>
|
|
21
|
+
* semaphore.withPermits(1)(
|
|
22
|
+
* Effect.gen(function*() {
|
|
23
|
+
* yield* Effect.yieldNow
|
|
24
|
+
* return id
|
|
25
|
+
* })
|
|
26
|
+
* )
|
|
27
|
+
*
|
|
28
|
+
* // Only 3 tasks can run concurrently
|
|
29
|
+
* const program = Effect.all([
|
|
30
|
+
* task(1),
|
|
31
|
+
* task(2),
|
|
32
|
+
* task(3),
|
|
33
|
+
* task(4),
|
|
34
|
+
* task(5)
|
|
35
|
+
* ], { concurrency: "unbounded" })
|
|
36
|
+
*
|
|
37
|
+
* await Effect.runPromise(program) // => [1, 2, 3, 4, 5]
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @stability stable
|
|
41
|
+
* @category constructors
|
|
42
|
+
* @since 4.0.0
|
|
43
|
+
*/
|
|
44
|
+
const makeUnsafe = (permits) => new SemaphoreImpl(permits);
|
|
45
|
+
const firstAvailableWaiter = (self) => {
|
|
46
|
+
for (const waiter of self.waiters) if (waiter.permits <= self.free) return waiter;
|
|
47
|
+
};
|
|
48
|
+
const takePermits = (self, n, onAcquire, restore = identity) => withFiber((fiber) => {
|
|
49
|
+
if (self.free >= n && firstAvailableWaiter(self) === void 0) {
|
|
50
|
+
self.taken += n;
|
|
51
|
+
return onAcquire();
|
|
52
|
+
}
|
|
53
|
+
const waiter = {
|
|
54
|
+
permits: n,
|
|
55
|
+
resume: void 0
|
|
56
|
+
};
|
|
57
|
+
const remove = () => {
|
|
58
|
+
if (self.waiters.delete(waiter)) self.releaseUnsafe(fiber, 0);
|
|
59
|
+
};
|
|
60
|
+
self.waiters.add(waiter);
|
|
61
|
+
onExitUnsafe(fiber, remove);
|
|
62
|
+
const wait = restore(callback((resume) => {
|
|
63
|
+
if (firstAvailableWaiter(self) === waiter) resume(void_);
|
|
64
|
+
else waiter.resume = resume;
|
|
65
|
+
}));
|
|
66
|
+
const loop = flatMap(wait, () => {
|
|
67
|
+
if (firstAvailableWaiter(self) !== waiter) return loop;
|
|
68
|
+
self.taken += n;
|
|
69
|
+
remove();
|
|
70
|
+
return onAcquire();
|
|
71
|
+
});
|
|
72
|
+
return loop;
|
|
73
|
+
});
|
|
74
|
+
var SemaphoreImpl = class {
|
|
75
|
+
waiters = /*#__PURE__*/ new Set();
|
|
76
|
+
taken = 0;
|
|
77
|
+
permits;
|
|
78
|
+
constructor(permits) {
|
|
79
|
+
this.permits = permits;
|
|
80
|
+
}
|
|
81
|
+
get free() {
|
|
82
|
+
return this.permits - this.taken;
|
|
83
|
+
}
|
|
84
|
+
take(n) {
|
|
85
|
+
return takePermits(this, n, () => succeed(n));
|
|
86
|
+
}
|
|
87
|
+
takeScoped(n) {
|
|
88
|
+
return uninterruptibleMask((restore) => flatMap(scope, (scope) => takePermits(this, n, () => scopeAddFinalizer(scope, this.release(n)), restore)));
|
|
89
|
+
}
|
|
90
|
+
takeIfAvailable(n) {
|
|
91
|
+
return suspend(() => {
|
|
92
|
+
if (this.free < n) return succeed(false);
|
|
93
|
+
this.taken += n;
|
|
94
|
+
return succeed(true);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
releaseUnsafe(fiber, n) {
|
|
98
|
+
this.taken -= n;
|
|
99
|
+
if (this.waiters.size > 0) fiber.currentDispatcher.scheduleTask(() => {
|
|
100
|
+
let remaining = this.free;
|
|
101
|
+
for (const waiter of Array.from(this.waiters)) {
|
|
102
|
+
if (!this.waiters.has(waiter) || waiter.permits > remaining) continue;
|
|
103
|
+
remaining -= waiter.permits;
|
|
104
|
+
const resume = waiter.resume;
|
|
105
|
+
waiter.resume = void 0;
|
|
106
|
+
resume?.(void_);
|
|
107
|
+
}
|
|
108
|
+
}, 0);
|
|
109
|
+
return this.free;
|
|
110
|
+
}
|
|
111
|
+
resize(permits) {
|
|
112
|
+
return withFiber((fiber) => {
|
|
113
|
+
this.permits = permits;
|
|
114
|
+
if (this.free < 0) return void_;
|
|
115
|
+
this.releaseUnsafe(fiber, 0);
|
|
116
|
+
return void_;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
release(n) {
|
|
120
|
+
return withFiber((fiber) => succeed(this.releaseUnsafe(fiber, n)));
|
|
121
|
+
}
|
|
122
|
+
get releaseAll() {
|
|
123
|
+
return withFiber((fiber) => succeed(this.releaseUnsafe(fiber, this.taken)));
|
|
124
|
+
}
|
|
125
|
+
withPermits(n) {
|
|
126
|
+
return (self) => uninterruptibleMask((restore) => takePermits(this, n, () => onExitPrimitive(restore(self), () => {
|
|
127
|
+
this.releaseUnsafe(getCurrentFiber(), n);
|
|
128
|
+
}, true), restore));
|
|
129
|
+
}
|
|
130
|
+
withPermit = /*#__PURE__*/ this.withPermits(1);
|
|
131
|
+
withPermitsIfAvailable(n) {
|
|
132
|
+
return (self) => uninterruptibleMask((restore) => {
|
|
133
|
+
if (this.free < n) return succeedNone;
|
|
134
|
+
this.taken += n;
|
|
135
|
+
return onExitPrimitive(restore(asSome(self)), () => {
|
|
136
|
+
this.releaseUnsafe(getCurrentFiber(), n);
|
|
137
|
+
}, true);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Creates a `Semaphore` initialized with the specified total number of permits.
|
|
143
|
+
*
|
|
144
|
+
* **When to use**
|
|
145
|
+
*
|
|
146
|
+
* Use to create a semaphore inside Effect code for bounding concurrency with
|
|
147
|
+
* automatic or manual permit management.
|
|
148
|
+
*
|
|
149
|
+
* **Example** (Creating a semaphore)
|
|
150
|
+
*
|
|
151
|
+
* ```ts import.meta.vitest
|
|
152
|
+
* import { Effect, Semaphore } from "effect"
|
|
153
|
+
*
|
|
154
|
+
* const program = Effect.gen(function*() {
|
|
155
|
+
* const semaphore = yield* Semaphore.make(2)
|
|
156
|
+
*
|
|
157
|
+
* const task = (id: number) =>
|
|
158
|
+
* semaphore.withPermits(1)(
|
|
159
|
+
* Effect.gen(function*() {
|
|
160
|
+
* yield* Effect.yieldNow
|
|
161
|
+
* return id
|
|
162
|
+
* })
|
|
163
|
+
* )
|
|
164
|
+
*
|
|
165
|
+
* // Run 4 tasks, but only 2 can run concurrently
|
|
166
|
+
* return yield* Effect.all([task(1), task(2), task(3), task(4)])
|
|
167
|
+
* })
|
|
168
|
+
*
|
|
169
|
+
* await Effect.runPromise(program) // => [1, 2, 3, 4]
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @stability stable
|
|
173
|
+
* @category constructors
|
|
174
|
+
* @since 4.0.0
|
|
175
|
+
*/
|
|
176
|
+
const make = (permits) => sync(() => new SemaphoreImpl(permits));
|
|
177
|
+
export { makeUnsafe as n, make as t };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Xt as succeed, aa as Service } from "./Effect-CKFpqbmw.mjs";
|
|
2
|
+
// ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Stdio.js
|
|
3
|
+
/**
|
|
4
|
+
* Service contract for command-line arguments and standard input, output, and
|
|
5
|
+
* error output. It lets programs depend on standard I/O through the Effect
|
|
6
|
+
* environment instead of reading from or writing to global process handles
|
|
7
|
+
* directly.
|
|
8
|
+
*
|
|
9
|
+
* The service exposes arguments as an `Effect`, stdout and stderr as `Sink`s
|
|
10
|
+
* that accept strings or bytes, and stdin as a byte `Stream`. This module also
|
|
11
|
+
* provides a constructor for service values and a small test layer with
|
|
12
|
+
* overridable defaults.
|
|
13
|
+
*
|
|
14
|
+
* @stability unstable
|
|
15
|
+
* @since 4.0.0
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Runtime identifier stored on `Stdio` service implementations.
|
|
19
|
+
*
|
|
20
|
+
* **Details**
|
|
21
|
+
*
|
|
22
|
+
* This marker is part of the runtime representation of `Stdio` service
|
|
23
|
+
* implementations.
|
|
24
|
+
*
|
|
25
|
+
* @stability unstable
|
|
26
|
+
* @category type IDs
|
|
27
|
+
* @since 4.0.0
|
|
28
|
+
*/
|
|
29
|
+
const TypeId = "~effect/Stdio";
|
|
30
|
+
/**
|
|
31
|
+
* Service tag for process standard I/O.
|
|
32
|
+
*
|
|
33
|
+
* **When to use**
|
|
34
|
+
*
|
|
35
|
+
* Use when you need command-line arguments or standard I/O streams supplied by
|
|
36
|
+
* an effect's environment.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link make} for constructing a `Stdio` service directly
|
|
39
|
+
* @see {@link layerTest} for a test layer with defaults and overrides
|
|
40
|
+
*
|
|
41
|
+
* @stability unstable
|
|
42
|
+
* @category services
|
|
43
|
+
* @since 4.0.0
|
|
44
|
+
*/
|
|
45
|
+
const Stdio = /*#__PURE__*/ Service(TypeId);
|
|
46
|
+
/**
|
|
47
|
+
* Creates a `Stdio` service implementation from the provided fields and
|
|
48
|
+
* attaches the `Stdio` type identifier.
|
|
49
|
+
*
|
|
50
|
+
* **When to use**
|
|
51
|
+
*
|
|
52
|
+
* Use when you need to assemble a concrete `Stdio` service from command-line
|
|
53
|
+
* arguments and standard I/O implementations.
|
|
54
|
+
*
|
|
55
|
+
* **Details**
|
|
56
|
+
*
|
|
57
|
+
* The returned service reuses the supplied fields unchanged and adds the
|
|
58
|
+
* `Stdio` type identifier. Omitted terminal-detection fields default to
|
|
59
|
+
* effects that succeed with `false`.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link layerTest} for a test layer with default fields that can be overridden
|
|
62
|
+
*
|
|
63
|
+
* @stability unstable
|
|
64
|
+
* @category constructors
|
|
65
|
+
* @since 4.0.0
|
|
66
|
+
*/
|
|
67
|
+
const make = (options) => ({
|
|
68
|
+
[TypeId]: TypeId,
|
|
69
|
+
stdinIsTerminal: succeed(false),
|
|
70
|
+
stdoutIsTerminal: succeed(false),
|
|
71
|
+
stderrIsTerminal: succeed(false),
|
|
72
|
+
...options
|
|
73
|
+
});
|
|
74
|
+
export { make as n, Stdio as t };
|