@cequrebackends/cequre-ts 0.13.0 → 0.14.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.
@@ -0,0 +1,203 @@
1
+ // @bun
2
+ import {
3
+ CequreError
4
+ } from "./index-qzzg2p5r.js";
5
+ import {
6
+ init_logger,
7
+ logger
8
+ } from "./index-8bhn0nb4.js";
9
+
10
+ // shared/utils/queue-manager.ts
11
+ import { Queue as BullQueue, Worker as BullWorker, QueueEvents as BullQueueEvents } from "bullmq";
12
+ import { Effect } from "effect";
13
+ init_logger();
14
+
15
+ class BullMQQueueAdapter {
16
+ queue;
17
+ constructor(queue) {
18
+ this.queue = queue;
19
+ }
20
+ async add(name, data, opts) {
21
+ return this.queue.add(name, data, opts);
22
+ }
23
+ async addBulk(jobs) {
24
+ const bulkJobs = jobs.map((job) => ({
25
+ name: job.name,
26
+ data: job.data,
27
+ opts: job.opts
28
+ }));
29
+ return this.queue.addBulk(bulkJobs);
30
+ }
31
+ async getRepeatableJobs() {
32
+ return this.queue.getRepeatableJobs();
33
+ }
34
+ async removeRepeatableByKey(key) {
35
+ return this.queue.removeRepeatableByKey(key);
36
+ }
37
+ async disconnect() {
38
+ await this.queue.close();
39
+ }
40
+ }
41
+
42
+ class CequreQueueManager {
43
+ static instance;
44
+ queues = new Map;
45
+ workers = new Map;
46
+ queueEvents = new Map;
47
+ config;
48
+ closing = false;
49
+ constructor(config) {
50
+ this.config = config;
51
+ if (!this.config.bullmq?.connection) {
52
+ throw CequreError.NotConfigured('CequreQueueManager: bullmq provider requires "bullmq.connection"');
53
+ }
54
+ }
55
+ getBullMQBaseOptions() {
56
+ return {
57
+ ...this.config.bullmq.prefix ? { prefix: this.config.bullmq.prefix } : {},
58
+ connection: {
59
+ ...this.config.bullmq.connection,
60
+ maxRetriesPerRequest: null
61
+ }
62
+ };
63
+ }
64
+ static initialize(config) {
65
+ if (!CequreQueueManager.instance) {
66
+ CequreQueueManager.instance = new CequreQueueManager(config);
67
+ }
68
+ return CequreQueueManager.instance;
69
+ }
70
+ static getInstance() {
71
+ if (!CequreQueueManager.instance) {
72
+ throw CequreError.NotConfigured("CequreQueueManager not initialized. Call initialize() first.");
73
+ }
74
+ return CequreQueueManager.instance;
75
+ }
76
+ getQueue(name) {
77
+ const existing = this.queues.get(name);
78
+ if (existing)
79
+ return existing;
80
+ const queue = new BullQueue(name, {
81
+ ...this.config.defaultQueueOptions ?? {},
82
+ ...this.getBullMQBaseOptions()
83
+ });
84
+ queue.on("error", (err) => {
85
+ if (err?.message?.includes("Connection is closed"))
86
+ return;
87
+ logger.error(err, `[ ${name.toUpperCase()} QUEUE ] Error`);
88
+ });
89
+ const wrapped = new BullMQQueueAdapter(queue);
90
+ this.queues.set(name, wrapped);
91
+ return wrapped;
92
+ }
93
+ async addJob(queueName, jobName, data, opts) {
94
+ const queue = this.getQueue(queueName);
95
+ return queue.add(jobName, data, opts);
96
+ }
97
+ async addBulk(queueName, jobs) {
98
+ const queue = this.getQueue(queueName);
99
+ return queue.addBulk(jobs);
100
+ }
101
+ async registerWorker(queueName, handler, options) {
102
+ const existing = this.workers.get(queueName);
103
+ const queueNameForLogs = `[ ${queueName?.toUpperCase()} WORKER ]`;
104
+ if (existing) {
105
+ logger.warn(`${queueNameForLogs} Replacing existing worker for queue "${queueName}"`);
106
+ try {
107
+ await existing.close();
108
+ } catch (err) {
109
+ logger.error(err, `${queueNameForLogs} Error closing old worker for "${queueName}"`);
110
+ }
111
+ this.workers.delete(queueName);
112
+ }
113
+ const worker = new BullWorker(queueName, async (job) => await handler(job), {
114
+ ...this.config.defaultWorkerOptions ?? {},
115
+ ...options ?? {},
116
+ ...this.getBullMQBaseOptions()
117
+ });
118
+ worker.on("completed", (job) => {
119
+ logger.info(`${queueNameForLogs} Job ${job.id} completed`);
120
+ });
121
+ worker.on("failed", (job, err) => {
122
+ logger.error(err, `${queueNameForLogs} Job ${job?.id ?? "unknown"} failed`);
123
+ });
124
+ worker.on("error", (err) => {
125
+ if (err?.message?.includes("Connection is closed"))
126
+ return;
127
+ logger.error(err, `${queueNameForLogs} Worker error`);
128
+ });
129
+ await worker.waitUntilReady();
130
+ logger.info(`${queueNameForLogs} Worker is ready and listening . . .`);
131
+ const wrapped = {
132
+ close: async () => {
133
+ await worker.close();
134
+ },
135
+ waitUntilReady: async () => {
136
+ await worker.waitUntilReady();
137
+ }
138
+ };
139
+ this.workers.set(queueName, wrapped);
140
+ return wrapped;
141
+ }
142
+ getQueueEvents(name) {
143
+ const existing = this.queueEvents.get(name);
144
+ if (existing)
145
+ return existing;
146
+ const events = new BullQueueEvents(name, {
147
+ ...this.getBullMQBaseOptions()
148
+ });
149
+ events.on("error", (err) => {
150
+ if (err?.message?.includes("Connection is closed"))
151
+ return;
152
+ logger.error(err, `[ ${name.toUpperCase()} QUEUE EVENTS ] Error`);
153
+ });
154
+ const wrapped = {
155
+ disconnect: async () => {
156
+ await events.close();
157
+ }
158
+ };
159
+ this.queueEvents.set(name, wrapped);
160
+ return wrapped;
161
+ }
162
+ static _reset() {
163
+ CequreQueueManager.instance = undefined;
164
+ }
165
+ static async _resetAndClose() {
166
+ const existing = CequreQueueManager.instance;
167
+ CequreQueueManager.instance = undefined;
168
+ if (existing) {
169
+ await existing.close();
170
+ }
171
+ }
172
+ async close() {
173
+ if (this.closing)
174
+ return;
175
+ this.closing = true;
176
+ const closeItemEffect = (item, label) => Effect.tryPromise({
177
+ try: async () => {
178
+ if (item.close)
179
+ await item.close();
180
+ else if (item.disconnect)
181
+ await item.disconnect();
182
+ },
183
+ catch: (err) => err
184
+ }).pipe(Effect.catchAll((err) => Effect.sync(() => {
185
+ logger.error(err, `[QueueManager] Error closing ${label}`);
186
+ })));
187
+ const closeGroupEffect = (items, label) => Effect.all(items.map((item) => closeItemEffect(item, label)), { concurrency: "unbounded" });
188
+ const workers = Array.from(this.workers.values());
189
+ const queueEvents = Array.from(this.queueEvents.values());
190
+ const queues = Array.from(this.queues.values());
191
+ await Effect.runPromise(Effect.gen(function* () {
192
+ yield* closeGroupEffect(workers, "worker");
193
+ yield* closeGroupEffect(queueEvents, "queue events");
194
+ yield* closeGroupEffect(queues, "queue");
195
+ }));
196
+ this.workers.clear();
197
+ this.queueEvents.clear();
198
+ this.queues.clear();
199
+ this.closing = false;
200
+ }
201
+ }
202
+
203
+ export { CequreQueueManager };
@@ -1,11 +1,10 @@
1
1
  // @bun
2
2
  import {
3
- CequreError,
4
3
  __esm,
5
4
  __export,
6
5
  __require,
7
6
  __toCommonJS
8
- } from "./index-17yswtmg.js";
7
+ } from "./index-cpw1bjf1.js";
9
8
 
10
9
  // shared/utils/kv/adapters/memory.ts
11
10
  function getLog() {
@@ -356,6 +355,105 @@ class RedisAdapter {
356
355
  var _log = null;
357
356
  var init_bun_redis_cache = () => {};
358
357
 
358
+ // adapters/vercel/upstash-kv.ts
359
+ class UpstashKVAdapter {
360
+ url;
361
+ token;
362
+ constructor(options) {
363
+ this.url = options?.url || process.env.UPSTASH_REDIS_REST_URL || "";
364
+ this.token = options?.token || process.env.UPSTASH_REDIS_REST_TOKEN || "";
365
+ if (!this.url || !this.token) {
366
+ console.warn("[Cequre KV (Upstash)] UPSTASH_REDIS_REST_URL or UPSTASH_REDIS_REST_TOKEN not set \u2014 KV operations will fail.");
367
+ }
368
+ }
369
+ async command(args) {
370
+ const res = await fetch(this.url, {
371
+ method: "POST",
372
+ headers: {
373
+ Authorization: `Bearer ${this.token}`,
374
+ "Content-Type": "application/json"
375
+ },
376
+ body: JSON.stringify(args)
377
+ });
378
+ if (!res.ok) {
379
+ throw new Error(`Upstash Redis error: ${res.status} ${await res.text()}`);
380
+ }
381
+ const data = await res.json();
382
+ return data.result;
383
+ }
384
+ async get(key) {
385
+ const result = await this.command(["GET", key]);
386
+ if (result === null)
387
+ return null;
388
+ try {
389
+ return JSON.parse(result);
390
+ } catch {
391
+ return result;
392
+ }
393
+ }
394
+ async getMany(keys) {
395
+ const result = new Map;
396
+ if (keys.length === 0)
397
+ return result;
398
+ const values = await this.command(["MGET", ...keys]);
399
+ for (let i = 0;i < keys.length; i++) {
400
+ const key = keys[i];
401
+ if (key === undefined)
402
+ continue;
403
+ const value = values[i];
404
+ if (value !== null && value !== undefined) {
405
+ try {
406
+ result.set(key, JSON.parse(value));
407
+ } catch {
408
+ result.set(key, value);
409
+ }
410
+ }
411
+ }
412
+ return result;
413
+ }
414
+ async set(key, value, ttl) {
415
+ const serialized = JSON.stringify(value);
416
+ if (ttl != null && ttl > 0) {
417
+ await this.command(["SET", key, serialized, "EX", String(ttl)]);
418
+ } else {
419
+ await this.command(["SET", key, serialized]);
420
+ }
421
+ }
422
+ async setMany(entries) {
423
+ await Promise.all(entries.map(({ key, value, ttl }) => this.set(key, value, ttl)));
424
+ }
425
+ async delete(key) {
426
+ const deleted = await this.command(["DEL", key]);
427
+ return deleted > 0;
428
+ }
429
+ async deleteMany(keys) {
430
+ if (keys.length === 0)
431
+ return 0;
432
+ return await this.command(["DEL", ...keys]);
433
+ }
434
+ async has(key) {
435
+ const exists = await this.command(["EXISTS", key]);
436
+ return exists > 0;
437
+ }
438
+ async keys(prefix) {
439
+ if (!prefix) {
440
+ return await this.command(["KEYS", "*"]);
441
+ }
442
+ return await this.command(["KEYS", `${prefix}*`]);
443
+ }
444
+ async count() {
445
+ return await this.command(["DBSIZE"]);
446
+ }
447
+ async clear() {
448
+ await this.command(["FLUSHDB"]);
449
+ }
450
+ cleanup() {
451
+ return 0;
452
+ }
453
+ close() {}
454
+ }
455
+ var init_upstash_kv = () => {};
456
+
359
457
  // shared/utils/kv/types.ts
360
458
  var init_types = () => {};
361
459
 
@@ -372,6 +470,9 @@ class CequreKV {
372
470
  } else if (driver === "redis") {
373
471
  this.adapter = new RedisAdapter(options.redis);
374
472
  this.isCleanupNative = true;
473
+ } else if (driver === "upstash") {
474
+ this.adapter = new UpstashKVAdapter(options.upstash);
475
+ this.isCleanupNative = true;
375
476
  } else {
376
477
  this.adapter = new SQLiteAdapter(options.sqlite);
377
478
  this.isCleanupNative = false;
@@ -431,6 +532,7 @@ var init_kv = __esm(() => {
431
532
  init_memory();
432
533
  init_sqlite();
433
534
  init_bun_redis_cache();
535
+ init_upstash_kv();
434
536
  init_types();
435
537
  });
436
538
 
@@ -554,197 +656,4 @@ var init_logger = __esm(() => {
554
656
  }
555
657
  });
556
658
 
557
- // shared/utils/queue-manager.ts
558
- import { Queue as BullQueue, Worker as BullWorker, QueueEvents as BullQueueEvents } from "bullmq";
559
- import { Effect } from "effect";
560
- init_logger();
561
-
562
- class BullMQQueueAdapter {
563
- queue;
564
- constructor(queue) {
565
- this.queue = queue;
566
- }
567
- async add(name, data, opts) {
568
- return this.queue.add(name, data, opts);
569
- }
570
- async addBulk(jobs) {
571
- const bulkJobs = jobs.map((job) => ({
572
- name: job.name,
573
- data: job.data,
574
- opts: job.opts
575
- }));
576
- return this.queue.addBulk(bulkJobs);
577
- }
578
- async getRepeatableJobs() {
579
- return this.queue.getRepeatableJobs();
580
- }
581
- async removeRepeatableByKey(key) {
582
- return this.queue.removeRepeatableByKey(key);
583
- }
584
- async disconnect() {
585
- await this.queue.close();
586
- }
587
- }
588
-
589
- class CequreQueueManager {
590
- static instance;
591
- queues = new Map;
592
- workers = new Map;
593
- queueEvents = new Map;
594
- config;
595
- closing = false;
596
- constructor(config) {
597
- this.config = config;
598
- if (!this.config.bullmq?.connection) {
599
- throw CequreError.NotConfigured('CequreQueueManager: bullmq provider requires "bullmq.connection"');
600
- }
601
- }
602
- getBullMQBaseOptions() {
603
- return {
604
- ...this.config.bullmq.prefix ? { prefix: this.config.bullmq.prefix } : {},
605
- connection: {
606
- ...this.config.bullmq.connection,
607
- maxRetriesPerRequest: null
608
- }
609
- };
610
- }
611
- static initialize(config) {
612
- if (!CequreQueueManager.instance) {
613
- CequreQueueManager.instance = new CequreQueueManager(config);
614
- }
615
- return CequreQueueManager.instance;
616
- }
617
- static getInstance() {
618
- if (!CequreQueueManager.instance) {
619
- throw CequreError.NotConfigured("CequreQueueManager not initialized. Call initialize() first.");
620
- }
621
- return CequreQueueManager.instance;
622
- }
623
- getQueue(name) {
624
- const existing = this.queues.get(name);
625
- if (existing)
626
- return existing;
627
- const queue = new BullQueue(name, {
628
- ...this.config.defaultQueueOptions ?? {},
629
- ...this.getBullMQBaseOptions()
630
- });
631
- queue.on("error", (err) => {
632
- if (err?.message?.includes("Connection is closed"))
633
- return;
634
- logger.error(err, `[ ${name.toUpperCase()} QUEUE ] Error`);
635
- });
636
- const wrapped = new BullMQQueueAdapter(queue);
637
- this.queues.set(name, wrapped);
638
- return wrapped;
639
- }
640
- async addJob(queueName, jobName, data, opts) {
641
- const queue = this.getQueue(queueName);
642
- return queue.add(jobName, data, opts);
643
- }
644
- async addBulk(queueName, jobs) {
645
- const queue = this.getQueue(queueName);
646
- return queue.addBulk(jobs);
647
- }
648
- async registerWorker(queueName, handler, options) {
649
- const existing = this.workers.get(queueName);
650
- const queueNameForLogs = `[ ${queueName?.toUpperCase()} WORKER ]`;
651
- if (existing) {
652
- logger.warn(`${queueNameForLogs} Replacing existing worker for queue "${queueName}"`);
653
- try {
654
- await existing.close();
655
- } catch (err) {
656
- logger.error(err, `${queueNameForLogs} Error closing old worker for "${queueName}"`);
657
- }
658
- this.workers.delete(queueName);
659
- }
660
- const worker = new BullWorker(queueName, async (job) => await handler(job), {
661
- ...this.config.defaultWorkerOptions ?? {},
662
- ...options ?? {},
663
- ...this.getBullMQBaseOptions()
664
- });
665
- worker.on("completed", (job) => {
666
- logger.info(`${queueNameForLogs} Job ${job.id} completed`);
667
- });
668
- worker.on("failed", (job, err) => {
669
- logger.error(err, `${queueNameForLogs} Job ${job?.id ?? "unknown"} failed`);
670
- });
671
- worker.on("error", (err) => {
672
- if (err?.message?.includes("Connection is closed"))
673
- return;
674
- logger.error(err, `${queueNameForLogs} Worker error`);
675
- });
676
- await worker.waitUntilReady();
677
- logger.info(`${queueNameForLogs} Worker is ready and listening . . .`);
678
- const wrapped = {
679
- close: async () => {
680
- await worker.close();
681
- },
682
- waitUntilReady: async () => {
683
- await worker.waitUntilReady();
684
- }
685
- };
686
- this.workers.set(queueName, wrapped);
687
- return wrapped;
688
- }
689
- getQueueEvents(name) {
690
- const existing = this.queueEvents.get(name);
691
- if (existing)
692
- return existing;
693
- const events = new BullQueueEvents(name, {
694
- ...this.getBullMQBaseOptions()
695
- });
696
- events.on("error", (err) => {
697
- if (err?.message?.includes("Connection is closed"))
698
- return;
699
- logger.error(err, `[ ${name.toUpperCase()} QUEUE EVENTS ] Error`);
700
- });
701
- const wrapped = {
702
- disconnect: async () => {
703
- await events.close();
704
- }
705
- };
706
- this.queueEvents.set(name, wrapped);
707
- return wrapped;
708
- }
709
- static _reset() {
710
- CequreQueueManager.instance = undefined;
711
- }
712
- static async _resetAndClose() {
713
- const existing = CequreQueueManager.instance;
714
- CequreQueueManager.instance = undefined;
715
- if (existing) {
716
- await existing.close();
717
- }
718
- }
719
- async close() {
720
- if (this.closing)
721
- return;
722
- this.closing = true;
723
- const closeItemEffect = (item, label) => Effect.tryPromise({
724
- try: async () => {
725
- if (item.close)
726
- await item.close();
727
- else if (item.disconnect)
728
- await item.disconnect();
729
- },
730
- catch: (err) => err
731
- }).pipe(Effect.catchAll((err) => Effect.sync(() => {
732
- logger.error(err, `[QueueManager] Error closing ${label}`);
733
- })));
734
- const closeGroupEffect = (items, label) => Effect.all(items.map((item) => closeItemEffect(item, label)), { concurrency: "unbounded" });
735
- const workers = Array.from(this.workers.values());
736
- const queueEvents = Array.from(this.queueEvents.values());
737
- const queues = Array.from(this.queues.values());
738
- await Effect.runPromise(Effect.gen(function* () {
739
- yield* closeGroupEffect(workers, "worker");
740
- yield* closeGroupEffect(queueEvents, "queue events");
741
- yield* closeGroupEffect(queues, "queue");
742
- }));
743
- this.workers.clear();
744
- this.queueEvents.clear();
745
- this.queues.clear();
746
- this.closing = false;
747
- }
748
- }
749
-
750
- export { logger, CequreErrorLogs, createLogger, exports_logger, init_logger, RedisAdapter, init_bun_redis_cache, CequreKV, init_kv, CequreQueueManager };
659
+ export { logger, CequreErrorLogs, createLogger, exports_logger, init_logger, RedisAdapter, init_bun_redis_cache, UpstashKVAdapter, init_upstash_kv, CequreKV, init_kv };
@@ -0,0 +1,62 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ function __accessProp(key) {
7
+ return this[key];
8
+ }
9
+ var __toCommonJS = (from) => {
10
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
+ if (entry)
12
+ return entry;
13
+ entry = __defProp({}, "__esModule", { value: true });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (var key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(entry, key))
17
+ __defProp(entry, key, {
18
+ get: __accessProp.bind(from, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ __moduleCache.set(from, entry);
23
+ return entry;
24
+ };
25
+ var __moduleCache;
26
+ var __returnValue = (v) => v;
27
+ function __exportSetter(name, newValue) {
28
+ this[name] = __returnValue.bind(null, newValue);
29
+ }
30
+ var __export = (target, all) => {
31
+ for (var name in all)
32
+ __defProp(target, name, {
33
+ get: all[name],
34
+ enumerable: true,
35
+ configurable: true,
36
+ set: __exportSetter.bind(all, name)
37
+ });
38
+ };
39
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
40
+ var __require = import.meta.require;
41
+
42
+ // shared/core/ulid.ts
43
+ var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
44
+ var TIME_LEN = 10;
45
+ var RANDOM_LEN = 16;
46
+ function ulid(seedTime = Date.now()) {
47
+ let str = "";
48
+ let now = seedTime;
49
+ for (let len = TIME_LEN;len > 0; len--) {
50
+ const mod = now % 32;
51
+ str = ENCODING.charAt(mod) + str;
52
+ now = (now - mod) / 32;
53
+ }
54
+ const randomBytes = new Uint8Array(RANDOM_LEN);
55
+ crypto.getRandomValues(randomBytes);
56
+ for (let i = 0;i < RANDOM_LEN; i++) {
57
+ str += ENCODING.charAt(randomBytes[i] & 31);
58
+ }
59
+ return str;
60
+ }
61
+
62
+ export { __toCommonJS, __export, __esm, __require, ulid };
@@ -1,64 +1,4 @@
1
1
  // @bun
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- function __accessProp(key) {
7
- return this[key];
8
- }
9
- var __toCommonJS = (from) => {
10
- var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
- if (entry)
12
- return entry;
13
- entry = __defProp({}, "__esModule", { value: true });
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (var key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(entry, key))
17
- __defProp(entry, key, {
18
- get: __accessProp.bind(from, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- __moduleCache.set(from, entry);
23
- return entry;
24
- };
25
- var __moduleCache;
26
- var __returnValue = (v) => v;
27
- function __exportSetter(name, newValue) {
28
- this[name] = __returnValue.bind(null, newValue);
29
- }
30
- var __export = (target, all) => {
31
- for (var name in all)
32
- __defProp(target, name, {
33
- get: all[name],
34
- enumerable: true,
35
- configurable: true,
36
- set: __exportSetter.bind(all, name)
37
- });
38
- };
39
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
40
- var __require = import.meta.require;
41
-
42
- // shared/core/ulid.ts
43
- var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
44
- var TIME_LEN = 10;
45
- var RANDOM_LEN = 16;
46
- function ulid(seedTime = Date.now()) {
47
- let str = "";
48
- let now = seedTime;
49
- for (let len = TIME_LEN;len > 0; len--) {
50
- const mod = now % 32;
51
- str = ENCODING.charAt(mod) + str;
52
- now = (now - mod) / 32;
53
- }
54
- const randomBytes = new Uint8Array(RANDOM_LEN);
55
- crypto.getRandomValues(randomBytes);
56
- for (let i = 0;i < RANDOM_LEN; i++) {
57
- str += ENCODING.charAt(randomBytes[i] & 31);
58
- }
59
- return str;
60
- }
61
-
62
2
  // shared/utils/url.ts
63
3
  function extractPathname(url) {
64
4
  const protocolIndex = url.indexOf("://");
@@ -172,4 +112,4 @@ function toErrorResponse(error, request, adapter) {
172
112
  });
173
113
  }
174
114
 
175
- export { __toCommonJS, __export, __esm, __require, ulid, extractPathname, CequreError, parseConstraintError, getConstraintErrorMessage, getConstraintErrorStatus, buildErrorResponse, toErrorResponse };
115
+ export { extractPathname, CequreError, parseConstraintError, getConstraintErrorMessage, getConstraintErrorStatus, buildErrorResponse, toErrorResponse };