@typed/id 1.0.0-beta.6 → 1.0.0-beta.8
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 +21 -0
- package/README.md +9 -7
- package/dist/Cuid.d.ts +6 -6
- package/dist/Cuid.js +5 -5
- package/dist/DateTimes.d.ts +5 -5
- package/dist/DateTimes.js +5 -5
- package/dist/Ids.d.ts +8 -47
- package/dist/Ids.d.ts.map +1 -1
- package/dist/Ids.js +11 -55
- package/dist/IdsTest.d.ts +34 -0
- package/dist/IdsTest.d.ts.map +1 -0
- package/dist/IdsTest.js +44 -0
- package/dist/Ksuid.d.ts +3 -3
- package/dist/Ksuid.js +3 -3
- package/dist/NanoId.d.ts +3 -3
- package/dist/NanoId.js +3 -3
- package/dist/RandomValues.d.ts +4 -4
- package/dist/RandomValues.js +4 -4
- package/dist/Ulid.d.ts +3 -3
- package/dist/Ulid.js +3 -3
- package/dist/Uuid4.d.ts +3 -3
- package/dist/Uuid4.js +3 -3
- package/dist/Uuid5.d.ts +13 -13
- package/dist/Uuid5.js +8 -8
- package/dist/Uuid7.d.ts +6 -6
- package/dist/Uuid7.js +5 -5
- package/dist/internal/Ids.d.ts +23 -0
- package/dist/internal/Ids.d.ts.map +1 -0
- package/dist/internal/Ids.js +29 -0
- package/package.json +8 -4
package/dist/Ksuid.js
CHANGED
|
@@ -24,7 +24,7 @@ const STRING_LENGTH = 27;
|
|
|
24
24
|
* import { Schema } from "effect"
|
|
25
25
|
* const id = Schema.decodeUnknownSync(Ksuid)("0ujtsYcgvSTl8PAuAdqWYSMnLOv")
|
|
26
26
|
* ```
|
|
27
|
-
* @category
|
|
27
|
+
* @category ID schemas
|
|
28
28
|
* @since 1.0.0
|
|
29
29
|
*/
|
|
30
30
|
export const Ksuid = Schema.String.pipe(Schema.check(Schema.isPattern(/^[0-9A-Za-z]{27}$/)), Schema.brand("@typed/id/KSUID"));
|
|
@@ -40,7 +40,7 @@ export const Ksuid = Schema.String.pipe(Schema.check(Schema.isPattern(/^[0-9A-Za
|
|
|
40
40
|
* import { isKsuid } from "@typed/id/Ksuid"
|
|
41
41
|
* isKsuid("0ujtsYcgvSTl8PAuAdqWYSMnLOv")
|
|
42
42
|
* ```
|
|
43
|
-
* @category
|
|
43
|
+
* @category ID validation
|
|
44
44
|
* @since 1.0.0
|
|
45
45
|
*/
|
|
46
46
|
export const isKsuid = Schema.is(Ksuid);
|
|
@@ -60,7 +60,7 @@ export const isKsuid = Schema.is(Ksuid);
|
|
|
60
60
|
* import { Effect, Layer } from "effect"
|
|
61
61
|
* const id = Effect.provide(ksuid, Layer.merge(DateTimes.Default, RandomValues.Default))
|
|
62
62
|
* ```
|
|
63
|
-
* @category
|
|
63
|
+
* @category ID generation
|
|
64
64
|
* @since 1.0.0
|
|
65
65
|
*/
|
|
66
66
|
export const ksuid = Effect.gen(function* () {
|
package/dist/NanoId.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { RandomValues } from "./RandomValues.js";
|
|
|
13
13
|
* import { NanoId } from "@typed/id/NanoId"
|
|
14
14
|
* const id = NanoId.make("V1StGXR8_Z5jdHi6B-myT")
|
|
15
15
|
* ```
|
|
16
|
-
* @category
|
|
16
|
+
* @category ID schemas
|
|
17
17
|
* @since 1.0.0
|
|
18
18
|
*/
|
|
19
19
|
export declare const NanoId: Schema.brand<Schema.String, "@typed/id/NanoId">;
|
|
@@ -30,7 +30,7 @@ export type NanoId = typeof NanoId.Type;
|
|
|
30
30
|
* import { isNanoId } from "@typed/id/NanoId"
|
|
31
31
|
* isNanoId("V1StGXR8_Z5jdHi6B-myT")
|
|
32
32
|
* ```
|
|
33
|
-
* @category
|
|
33
|
+
* @category ID validation
|
|
34
34
|
* @since 1.0.0
|
|
35
35
|
*/
|
|
36
36
|
export declare const isNanoId: (value: string) => value is NanoId;
|
|
@@ -48,7 +48,7 @@ export declare const isNanoId: (value: string) => value is NanoId;
|
|
|
48
48
|
* import { Effect } from "effect"
|
|
49
49
|
* const id = Effect.provide(nanoId, RandomValues.Default)
|
|
50
50
|
* ```
|
|
51
|
-
* @category
|
|
51
|
+
* @category ID generation
|
|
52
52
|
* @since 1.0.0
|
|
53
53
|
*/
|
|
54
54
|
export declare const nanoId: Effect.Effect<NanoId, never, RandomValues>;
|
package/dist/NanoId.js
CHANGED
|
@@ -13,7 +13,7 @@ import { RandomValues } from "./RandomValues.js";
|
|
|
13
13
|
* import { NanoId } from "@typed/id/NanoId"
|
|
14
14
|
* const id = NanoId.make("V1StGXR8_Z5jdHi6B-myT")
|
|
15
15
|
* ```
|
|
16
|
-
* @category
|
|
16
|
+
* @category ID schemas
|
|
17
17
|
* @since 1.0.0
|
|
18
18
|
*/
|
|
19
19
|
export const NanoId = Schema.String.pipe(Schema.check(Schema.isPattern(/^[0-9a-zA-Z_-]+$/)), Schema.brand("@typed/id/NanoId"));
|
|
@@ -29,7 +29,7 @@ export const NanoId = Schema.String.pipe(Schema.check(Schema.isPattern(/^[0-9a-z
|
|
|
29
29
|
* import { isNanoId } from "@typed/id/NanoId"
|
|
30
30
|
* isNanoId("V1StGXR8_Z5jdHi6B-myT")
|
|
31
31
|
* ```
|
|
32
|
-
* @category
|
|
32
|
+
* @category ID validation
|
|
33
33
|
* @since 1.0.0
|
|
34
34
|
*/
|
|
35
35
|
export const isNanoId = Schema.is(NanoId);
|
|
@@ -47,7 +47,7 @@ export const isNanoId = Schema.is(NanoId);
|
|
|
47
47
|
* import { Effect } from "effect"
|
|
48
48
|
* const id = Effect.provide(nanoId, RandomValues.Default)
|
|
49
49
|
* ```
|
|
50
|
-
* @category
|
|
50
|
+
* @category ID generation
|
|
51
51
|
* @since 1.0.0
|
|
52
52
|
*/
|
|
53
53
|
export const nanoId = Effect.map(RandomValues.call(21), (seed) => NanoId.make(Array.from(seed, numToCharacter).join("")));
|
package/dist/RandomValues.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare const RandomValues_base: Context.ServiceClass<RandomValues, "@typed/id/R
|
|
|
22
22
|
* import { Effect } from "effect"
|
|
23
23
|
* const bytes = Effect.provide(RandomValues.call(16), RandomValues.Default)
|
|
24
24
|
* ```
|
|
25
|
-
* @category
|
|
25
|
+
* @category Entropy services
|
|
26
26
|
* @since 1.0.0
|
|
27
27
|
*/
|
|
28
28
|
export declare class RandomValues extends RandomValues_base {
|
|
@@ -39,7 +39,7 @@ export declare class RandomValues extends RandomValues_base {
|
|
|
39
39
|
* import { Effect } from "effect"
|
|
40
40
|
* const bytes = RandomValues.call(32).pipe(Effect.provide(RandomValues.Default))
|
|
41
41
|
* ```
|
|
42
|
-
* @category
|
|
42
|
+
* @category Entropy services
|
|
43
43
|
* @since 1.0.0
|
|
44
44
|
*/
|
|
45
45
|
static readonly call: <const N extends number>(length: N) => Effect.Effect<Uint8Array & {
|
|
@@ -52,7 +52,7 @@ export declare class RandomValues extends RandomValues_base {
|
|
|
52
52
|
* Production IDs need platform entropy. Missing `globalThis.crypto.getRandomValues` and platform exceptions are Effect defects, not typed errors, rather than silently weakening randomness.
|
|
53
53
|
* ## Ownership and lifetime
|
|
54
54
|
* The Layer owns no mutable generator state; each request returns a fresh buffer. The runtime must provide Web Crypto or the request defects.
|
|
55
|
-
* @category
|
|
55
|
+
* @category Entropy layers
|
|
56
56
|
* @since 1.0.0
|
|
57
57
|
*/
|
|
58
58
|
static readonly Default: Layer.Layer<RandomValues, never, never>;
|
|
@@ -63,7 +63,7 @@ export declare class RandomValues extends RandomValues_base {
|
|
|
63
63
|
* Deterministic tests and simulations need replaceable entropy; this Layer is not cryptographically secure.
|
|
64
64
|
* ## Ownership and lifetime
|
|
65
65
|
* The provided Effect Random service owns sequence state for the Layer lifetime; each request returns a fresh buffer.
|
|
66
|
-
* @category
|
|
66
|
+
* @category Entropy layers
|
|
67
67
|
* @since 1.0.0
|
|
68
68
|
*/
|
|
69
69
|
static readonly Random: Layer.Layer<RandomValues, never, never>;
|
package/dist/RandomValues.js
CHANGED
|
@@ -32,7 +32,7 @@ const fromRandom = (random) => RandomValues.of((length) => Effect.sync(() => all
|
|
|
32
32
|
* import { Effect } from "effect"
|
|
33
33
|
* const bytes = Effect.provide(RandomValues.call(16), RandomValues.Default)
|
|
34
34
|
* ```
|
|
35
|
-
* @category
|
|
35
|
+
* @category Entropy services
|
|
36
36
|
* @since 1.0.0
|
|
37
37
|
*/
|
|
38
38
|
export class RandomValues extends Context.Service()("@typed/id/RandomValues", {
|
|
@@ -51,7 +51,7 @@ export class RandomValues extends Context.Service()("@typed/id/RandomValues", {
|
|
|
51
51
|
* import { Effect } from "effect"
|
|
52
52
|
* const bytes = RandomValues.call(32).pipe(Effect.provide(RandomValues.Default))
|
|
53
53
|
* ```
|
|
54
|
-
* @category
|
|
54
|
+
* @category Entropy services
|
|
55
55
|
* @since 1.0.0
|
|
56
56
|
*/
|
|
57
57
|
static call = (length) => RandomValues.pipe(Effect.flatMap((randomValues) => randomValues(length)));
|
|
@@ -62,7 +62,7 @@ export class RandomValues extends Context.Service()("@typed/id/RandomValues", {
|
|
|
62
62
|
* Production IDs need platform entropy. Missing `globalThis.crypto.getRandomValues` and platform exceptions are Effect defects, not typed errors, rather than silently weakening randomness.
|
|
63
63
|
* ## Ownership and lifetime
|
|
64
64
|
* The Layer owns no mutable generator state; each request returns a fresh buffer. The runtime must provide Web Crypto or the request defects.
|
|
65
|
-
* @category
|
|
65
|
+
* @category Entropy layers
|
|
66
66
|
* @since 1.0.0
|
|
67
67
|
*/
|
|
68
68
|
static Default = Layer.effect(RandomValues, RandomValues.make);
|
|
@@ -73,7 +73,7 @@ export class RandomValues extends Context.Service()("@typed/id/RandomValues", {
|
|
|
73
73
|
* Deterministic tests and simulations need replaceable entropy; this Layer is not cryptographically secure.
|
|
74
74
|
* ## Ownership and lifetime
|
|
75
75
|
* The provided Effect Random service owns sequence state for the Layer lifetime; each request returns a fresh buffer.
|
|
76
|
-
* @category
|
|
76
|
+
* @category Entropy layers
|
|
77
77
|
* @since 1.0.0
|
|
78
78
|
*/
|
|
79
79
|
static Random = Layer.effect(RandomValues, Effect.gen(function* () {
|
package/dist/Ulid.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { RandomValues } from "./RandomValues.js";
|
|
|
15
15
|
* import { Ulid } from "@typed/id/Ulid"
|
|
16
16
|
* const id = Ulid.make("01ARZ3NDEKTSV4RRFFQ69G5FAV")
|
|
17
17
|
* ```
|
|
18
|
-
* @category
|
|
18
|
+
* @category ID schemas
|
|
19
19
|
* @since 1.0.0
|
|
20
20
|
*/
|
|
21
21
|
export declare const Ulid: Schema.brand<Schema.String, "@typed/id/ULID">;
|
|
@@ -32,7 +32,7 @@ export type Ulid = typeof Ulid.Type;
|
|
|
32
32
|
* import { isUlid } from "@typed/id/Ulid"
|
|
33
33
|
* isUlid("01ARZ3NDEKTSV4RRFFQ69G5FAV")
|
|
34
34
|
* ```
|
|
35
|
-
* @category
|
|
35
|
+
* @category ID validation
|
|
36
36
|
* @since 1.0.0
|
|
37
37
|
*/
|
|
38
38
|
export declare const isUlid: (value: string) => value is Ulid;
|
|
@@ -50,7 +50,7 @@ export declare const isUlid: (value: string) => value is Ulid;
|
|
|
50
50
|
* import { Effect } from "effect"
|
|
51
51
|
* const id = Effect.provide(ulid, Ids.Default)
|
|
52
52
|
* ```
|
|
53
|
-
* @category
|
|
53
|
+
* @category ID generation
|
|
54
54
|
* @since 1.0.0
|
|
55
55
|
*/
|
|
56
56
|
export declare const ulid: Effect.Effect<Ulid, Cause.IllegalArgumentError, RandomValues | DateTimes>;
|
package/dist/Ulid.js
CHANGED
|
@@ -15,7 +15,7 @@ import { RandomValues } from "./RandomValues.js";
|
|
|
15
15
|
* import { Ulid } from "@typed/id/Ulid"
|
|
16
16
|
* const id = Ulid.make("01ARZ3NDEKTSV4RRFFQ69G5FAV")
|
|
17
17
|
* ```
|
|
18
|
-
* @category
|
|
18
|
+
* @category ID schemas
|
|
19
19
|
* @since 1.0.0
|
|
20
20
|
*/
|
|
21
21
|
export const Ulid = Schema.String.pipe(Schema.check(Schema.isULID()), Schema.brand("@typed/id/ULID"));
|
|
@@ -31,7 +31,7 @@ export const Ulid = Schema.String.pipe(Schema.check(Schema.isULID()), Schema.bra
|
|
|
31
31
|
* import { isUlid } from "@typed/id/Ulid"
|
|
32
32
|
* isUlid("01ARZ3NDEKTSV4RRFFQ69G5FAV")
|
|
33
33
|
* ```
|
|
34
|
-
* @category
|
|
34
|
+
* @category ID validation
|
|
35
35
|
* @since 1.0.0
|
|
36
36
|
*/
|
|
37
37
|
export const isUlid = Schema.is(Ulid);
|
|
@@ -55,7 +55,7 @@ const RANDOM_LEN = 16;
|
|
|
55
55
|
* import { Effect } from "effect"
|
|
56
56
|
* const id = Effect.provide(ulid, Ids.Default)
|
|
57
57
|
* ```
|
|
58
|
-
* @category
|
|
58
|
+
* @category ID generation
|
|
59
59
|
* @since 1.0.0
|
|
60
60
|
*/
|
|
61
61
|
export const ulid = Effect.gen(function* () {
|
package/dist/Uuid4.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { RandomValues } from "./RandomValues.js";
|
|
|
13
13
|
* import { Uuid4 } from "@typed/id/Uuid4"
|
|
14
14
|
* const id = Uuid4.make("550e8400-e29b-41d4-a716-446655440000")
|
|
15
15
|
* ```
|
|
16
|
-
* @category
|
|
16
|
+
* @category ID schemas
|
|
17
17
|
* @since 1.0.0
|
|
18
18
|
*/
|
|
19
19
|
export declare const Uuid4: Schema.brand<Schema.String, "@typed/id/UUID4">;
|
|
@@ -30,7 +30,7 @@ export type Uuid4 = typeof Uuid4.Type;
|
|
|
30
30
|
* import { isUuid4 } from "@typed/id/Uuid4"
|
|
31
31
|
* isUuid4("550e8400-e29b-41d4-a716-446655440000")
|
|
32
32
|
* ```
|
|
33
|
-
* @category
|
|
33
|
+
* @category ID validation
|
|
34
34
|
* @since 1.0.0
|
|
35
35
|
*/
|
|
36
36
|
export declare const isUuid4: (value: string) => value is Uuid4;
|
|
@@ -48,7 +48,7 @@ export declare const isUuid4: (value: string) => value is Uuid4;
|
|
|
48
48
|
* import { Effect } from "effect"
|
|
49
49
|
* const id = Effect.provide(uuid4, RandomValues.Default)
|
|
50
50
|
* ```
|
|
51
|
-
* @category
|
|
51
|
+
* @category ID generation
|
|
52
52
|
* @since 1.0.0
|
|
53
53
|
*/
|
|
54
54
|
export declare const uuid4: Effect.Effect<Uuid4, never, RandomValues>;
|
package/dist/Uuid4.js
CHANGED
|
@@ -14,7 +14,7 @@ import { RandomValues } from "./RandomValues.js";
|
|
|
14
14
|
* import { Uuid4 } from "@typed/id/Uuid4"
|
|
15
15
|
* const id = Uuid4.make("550e8400-e29b-41d4-a716-446655440000")
|
|
16
16
|
* ```
|
|
17
|
-
* @category
|
|
17
|
+
* @category ID schemas
|
|
18
18
|
* @since 1.0.0
|
|
19
19
|
*/
|
|
20
20
|
export const Uuid4 = Schema.String.pipe(Schema.check(Schema.isUUID(4)), Schema.brand("@typed/id/UUID4"));
|
|
@@ -30,7 +30,7 @@ export const Uuid4 = Schema.String.pipe(Schema.check(Schema.isUUID(4)), Schema.b
|
|
|
30
30
|
* import { isUuid4 } from "@typed/id/Uuid4"
|
|
31
31
|
* isUuid4("550e8400-e29b-41d4-a716-446655440000")
|
|
32
32
|
* ```
|
|
33
|
-
* @category
|
|
33
|
+
* @category ID validation
|
|
34
34
|
* @since 1.0.0
|
|
35
35
|
*/
|
|
36
36
|
export const isUuid4 = Schema.is(Uuid4);
|
|
@@ -48,7 +48,7 @@ export const isUuid4 = Schema.is(Uuid4);
|
|
|
48
48
|
* import { Effect } from "effect"
|
|
49
49
|
* const id = Effect.provide(uuid4, RandomValues.Default)
|
|
50
50
|
* ```
|
|
51
|
-
* @category
|
|
51
|
+
* @category ID generation
|
|
52
52
|
* @since 1.0.0
|
|
53
53
|
*/
|
|
54
54
|
export const uuid4 = Effect.map(RandomValues.call(16), (seed) => {
|
package/dist/Uuid5.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import * as Schema from "effect/Schema";
|
|
|
14
14
|
* import { Schema } from "effect"
|
|
15
15
|
* const id = Schema.decodeUnknownSync(Uuid5)("21f7f8de-8051-5b89-8680-0195ef798b6a")
|
|
16
16
|
* ```
|
|
17
|
-
* @category
|
|
17
|
+
* @category ID schemas
|
|
18
18
|
* @since 1.0.0
|
|
19
19
|
*/
|
|
20
20
|
export declare const Uuid5: Schema.brand<Schema.String, "@typed/id/UUID5">;
|
|
@@ -31,7 +31,7 @@ export type Uuid5 = typeof Uuid5.Type;
|
|
|
31
31
|
* import { isUuid5 } from "@typed/id/Uuid5"
|
|
32
32
|
* isUuid5("21f7f8de-8051-5b89-8680-0195ef798b6a")
|
|
33
33
|
* ```
|
|
34
|
-
* @category
|
|
34
|
+
* @category ID validation
|
|
35
35
|
* @since 1.0.0
|
|
36
36
|
*/
|
|
37
37
|
export declare const isUuid5: (value: string) => value is Uuid5;
|
|
@@ -42,7 +42,7 @@ export declare const isUuid5: (value: string) => value is Uuid5;
|
|
|
42
42
|
* Namespace bytes are part of deterministic identity; caller canonicalization of names and namespace selection must remain explicit.
|
|
43
43
|
* ## Ownership and lifetime
|
|
44
44
|
* This type acquires no resources. Callers own and may mutate their byte array; generation reads exactly 16 bytes.
|
|
45
|
-
* @category
|
|
45
|
+
* @category ID types
|
|
46
46
|
* @since 1.0.0
|
|
47
47
|
*/
|
|
48
48
|
export type Uuid5Namespace = Uint8Array;
|
|
@@ -58,7 +58,7 @@ export type Uuid5Namespace = Uint8Array;
|
|
|
58
58
|
* import { Uuid5Namespace } from "@typed/id/Uuid5"
|
|
59
59
|
* const namespace = Uuid5Namespace.DNS
|
|
60
60
|
* ```
|
|
61
|
-
* @category
|
|
61
|
+
* @category Name-based identity
|
|
62
62
|
* @since 1.0.0
|
|
63
63
|
*/
|
|
64
64
|
export declare const Uuid5Namespace: {
|
|
@@ -69,7 +69,7 @@ export declare const Uuid5Namespace: {
|
|
|
69
69
|
* DNS names need a stable namespace distinct from URLs, OIDs, and X.500 names.
|
|
70
70
|
* ## Ownership and lifetime
|
|
71
71
|
* Each access allocates a mutable byte array owned by the caller.
|
|
72
|
-
* @category
|
|
72
|
+
* @category Name-based identity
|
|
73
73
|
* @since 1.0.0
|
|
74
74
|
*/
|
|
75
75
|
readonly DNS: Uint8Array<ArrayBuffer>;
|
|
@@ -80,7 +80,7 @@ export declare const Uuid5Namespace: {
|
|
|
80
80
|
* URL names need a stable namespace distinct from DNS, OID, and X.500 names.
|
|
81
81
|
* ## Ownership and lifetime
|
|
82
82
|
* Each access allocates a mutable byte array owned by the caller.
|
|
83
|
-
* @category
|
|
83
|
+
* @category Name-based identity
|
|
84
84
|
* @since 1.0.0
|
|
85
85
|
*/
|
|
86
86
|
readonly URL: Uint8Array<ArrayBuffer>;
|
|
@@ -91,7 +91,7 @@ export declare const Uuid5Namespace: {
|
|
|
91
91
|
* Object identifiers need a stable namespace distinct from DNS, URL, and X.500 names.
|
|
92
92
|
* ## Ownership and lifetime
|
|
93
93
|
* Each access allocates a mutable byte array owned by the caller.
|
|
94
|
-
* @category
|
|
94
|
+
* @category Name-based identity
|
|
95
95
|
* @since 1.0.0
|
|
96
96
|
*/
|
|
97
97
|
readonly OID: Uint8Array<ArrayBuffer>;
|
|
@@ -102,7 +102,7 @@ export declare const Uuid5Namespace: {
|
|
|
102
102
|
* X.500 names need a stable namespace distinct from DNS, URL, and OID names.
|
|
103
103
|
* ## Ownership and lifetime
|
|
104
104
|
* Each access allocates a mutable byte array owned by the caller.
|
|
105
|
-
* @category
|
|
105
|
+
* @category Name-based identity
|
|
106
106
|
* @since 1.0.0
|
|
107
107
|
*/
|
|
108
108
|
readonly X500: Uint8Array<ArrayBuffer>;
|
|
@@ -119,7 +119,7 @@ export declare const Uuid5Namespace: {
|
|
|
119
119
|
* import { uuid5, Uuid5Namespace } from "@typed/id/Uuid5"
|
|
120
120
|
* const id = uuid5("example.com", Uuid5Namespace.DNS)
|
|
121
121
|
* ```
|
|
122
|
-
* @category
|
|
122
|
+
* @category ID generation
|
|
123
123
|
* @since 1.0.0
|
|
124
124
|
*/
|
|
125
125
|
export declare const uuid5: {
|
|
@@ -138,7 +138,7 @@ export declare const uuid5: {
|
|
|
138
138
|
* import { dnsUuid5 } from "@typed/id/Uuid5"
|
|
139
139
|
* const id = dnsUuid5("example.com")
|
|
140
140
|
* ```
|
|
141
|
-
* @category
|
|
141
|
+
* @category ID generation
|
|
142
142
|
* @since 1.0.0
|
|
143
143
|
*/
|
|
144
144
|
export declare const dnsUuid5: (name: string) => Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
|
@@ -154,7 +154,7 @@ export declare const dnsUuid5: (name: string) => Effect.Effect<Uuid5, Cause.Ille
|
|
|
154
154
|
* import { urlUuid5 } from "@typed/id/Uuid5"
|
|
155
155
|
* const id = urlUuid5("https://example.com")
|
|
156
156
|
* ```
|
|
157
|
-
* @category
|
|
157
|
+
* @category ID generation
|
|
158
158
|
* @since 1.0.0
|
|
159
159
|
*/
|
|
160
160
|
export declare const urlUuid5: (name: string) => Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
|
@@ -170,7 +170,7 @@ export declare const urlUuid5: (name: string) => Effect.Effect<Uuid5, Cause.Ille
|
|
|
170
170
|
* import { oidUuid5 } from "@typed/id/Uuid5"
|
|
171
171
|
* const id = oidUuid5("1.3.6.1.4.1")
|
|
172
172
|
* ```
|
|
173
|
-
* @category
|
|
173
|
+
* @category ID generation
|
|
174
174
|
* @since 1.0.0
|
|
175
175
|
*/
|
|
176
176
|
export declare const oidUuid5: (name: string) => Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
|
@@ -186,7 +186,7 @@ export declare const oidUuid5: (name: string) => Effect.Effect<Uuid5, Cause.Ille
|
|
|
186
186
|
* import { x500Uuid5 } from "@typed/id/Uuid5"
|
|
187
187
|
* const id = x500Uuid5("CN=example")
|
|
188
188
|
* ```
|
|
189
|
-
* @category
|
|
189
|
+
* @category ID generation
|
|
190
190
|
* @since 1.0.0
|
|
191
191
|
*/
|
|
192
192
|
export declare const x500Uuid5: (name: string) => Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
package/dist/Uuid5.js
CHANGED
|
@@ -17,7 +17,7 @@ import { uuidStringify } from "./_uuid-stringify.js";
|
|
|
17
17
|
* import { Schema } from "effect"
|
|
18
18
|
* const id = Schema.decodeUnknownSync(Uuid5)("21f7f8de-8051-5b89-8680-0195ef798b6a")
|
|
19
19
|
* ```
|
|
20
|
-
* @category
|
|
20
|
+
* @category ID schemas
|
|
21
21
|
* @since 1.0.0
|
|
22
22
|
*/
|
|
23
23
|
export const Uuid5 = Schema.String.pipe(Schema.check(Schema.isUUID(5)), Schema.brand("@typed/id/UUID5"));
|
|
@@ -33,7 +33,7 @@ export const Uuid5 = Schema.String.pipe(Schema.check(Schema.isUUID(5)), Schema.b
|
|
|
33
33
|
* import { isUuid5 } from "@typed/id/Uuid5"
|
|
34
34
|
* isUuid5("21f7f8de-8051-5b89-8680-0195ef798b6a")
|
|
35
35
|
* ```
|
|
36
|
-
* @category
|
|
36
|
+
* @category ID validation
|
|
37
37
|
* @since 1.0.0
|
|
38
38
|
*/
|
|
39
39
|
export const isUuid5 = Schema.is(Uuid5);
|
|
@@ -63,7 +63,7 @@ const X500 = new Uint8Array([
|
|
|
63
63
|
* import { Uuid5Namespace } from "@typed/id/Uuid5"
|
|
64
64
|
* const namespace = Uuid5Namespace.DNS
|
|
65
65
|
* ```
|
|
66
|
-
* @category
|
|
66
|
+
* @category Name-based identity
|
|
67
67
|
* @since 1.0.0
|
|
68
68
|
*/
|
|
69
69
|
export const Uuid5Namespace = Object.freeze({
|
|
@@ -92,7 +92,7 @@ export const Uuid5Namespace = Object.freeze({
|
|
|
92
92
|
* import { uuid5, Uuid5Namespace } from "@typed/id/Uuid5"
|
|
93
93
|
* const id = uuid5("example.com", Uuid5Namespace.DNS)
|
|
94
94
|
* ```
|
|
95
|
-
* @category
|
|
95
|
+
* @category ID generation
|
|
96
96
|
* @since 1.0.0
|
|
97
97
|
*/
|
|
98
98
|
export const uuid5 = dual(2, function uuid5(name, namespace) {
|
|
@@ -130,7 +130,7 @@ export const uuid5 = dual(2, function uuid5(name, namespace) {
|
|
|
130
130
|
* import { dnsUuid5 } from "@typed/id/Uuid5"
|
|
131
131
|
* const id = dnsUuid5("example.com")
|
|
132
132
|
* ```
|
|
133
|
-
* @category
|
|
133
|
+
* @category ID generation
|
|
134
134
|
* @since 1.0.0
|
|
135
135
|
*/
|
|
136
136
|
export const dnsUuid5 = uuid5(Uuid5Namespace.DNS);
|
|
@@ -146,7 +146,7 @@ export const dnsUuid5 = uuid5(Uuid5Namespace.DNS);
|
|
|
146
146
|
* import { urlUuid5 } from "@typed/id/Uuid5"
|
|
147
147
|
* const id = urlUuid5("https://example.com")
|
|
148
148
|
* ```
|
|
149
|
-
* @category
|
|
149
|
+
* @category ID generation
|
|
150
150
|
* @since 1.0.0
|
|
151
151
|
*/
|
|
152
152
|
export const urlUuid5 = uuid5(Uuid5Namespace.URL);
|
|
@@ -162,7 +162,7 @@ export const urlUuid5 = uuid5(Uuid5Namespace.URL);
|
|
|
162
162
|
* import { oidUuid5 } from "@typed/id/Uuid5"
|
|
163
163
|
* const id = oidUuid5("1.3.6.1.4.1")
|
|
164
164
|
* ```
|
|
165
|
-
* @category
|
|
165
|
+
* @category ID generation
|
|
166
166
|
* @since 1.0.0
|
|
167
167
|
*/
|
|
168
168
|
export const oidUuid5 = uuid5(Uuid5Namespace.OID);
|
|
@@ -178,7 +178,7 @@ export const oidUuid5 = uuid5(Uuid5Namespace.OID);
|
|
|
178
178
|
* import { x500Uuid5 } from "@typed/id/Uuid5"
|
|
179
179
|
* const id = x500Uuid5("CN=example")
|
|
180
180
|
* ```
|
|
181
|
-
* @category
|
|
181
|
+
* @category ID generation
|
|
182
182
|
* @since 1.0.0
|
|
183
183
|
*/
|
|
184
184
|
export const x500Uuid5 = uuid5(Uuid5Namespace.X500);
|
package/dist/Uuid7.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { RandomValues } from "./RandomValues.js";
|
|
|
18
18
|
* import { Schema } from "effect"
|
|
19
19
|
* const id = Schema.decodeUnknownSync(Uuid7)("01890f2e-7d6c-7cc0-98c4-dc0c0c07398f")
|
|
20
20
|
* ```
|
|
21
|
-
* @category
|
|
21
|
+
* @category ID schemas
|
|
22
22
|
* @since 1.0.0
|
|
23
23
|
*/
|
|
24
24
|
export declare const Uuid7: Schema.brand<Schema.String, "@typed/id/UUID7">;
|
|
@@ -35,7 +35,7 @@ export type Uuid7 = typeof Uuid7.Type;
|
|
|
35
35
|
* import { isUuid7 } from "@typed/id/Uuid7"
|
|
36
36
|
* const valid = isUuid7("01890f2e-7d6c-7cc0-98c4-dc0c0c07398f")
|
|
37
37
|
* ```
|
|
38
|
-
* @category
|
|
38
|
+
* @category ID validation
|
|
39
39
|
* @since 1.0.0
|
|
40
40
|
*/
|
|
41
41
|
export declare const isUuid7: (value: string) => value is Uuid7;
|
|
@@ -51,7 +51,7 @@ export declare const isUuid7: (value: string) => value is Uuid7;
|
|
|
51
51
|
* import type { Uuid7Seed } from "@typed/id/Uuid7"
|
|
52
52
|
* const seed: Uuid7Seed = { timestamp: 0, seq: 0, randomBytes: new Uint8Array(16) as Uuid7Seed["randomBytes"] }
|
|
53
53
|
* ```
|
|
54
|
-
* @category
|
|
54
|
+
* @category Sequence state
|
|
55
55
|
* @since 1.0.0
|
|
56
56
|
*/
|
|
57
57
|
export type Uuid7Seed = {
|
|
@@ -96,7 +96,7 @@ declare const Uuid7State_base: Context.ServiceClass<Uuid7State, "@typed/id/Uuid7
|
|
|
96
96
|
* import { Effect } from "effect"
|
|
97
97
|
* const id = Effect.provide(uuid7, Uuid7State.Default)
|
|
98
98
|
* ```
|
|
99
|
-
* @category
|
|
99
|
+
* @category Sequence state
|
|
100
100
|
* @since 1.0.0
|
|
101
101
|
*/
|
|
102
102
|
export declare class Uuid7State extends Uuid7State_base {
|
|
@@ -124,7 +124,7 @@ export declare class Uuid7State extends Uuid7State_base {
|
|
|
124
124
|
* The production default is explicit while remaining replaceable by deterministic service layers.
|
|
125
125
|
* ## Ownership and lifetime
|
|
126
126
|
* Layer acquisition creates one mutable sequence state owned by the surrounding Layer Scope.
|
|
127
|
-
* @category
|
|
127
|
+
* @category Production layers
|
|
128
128
|
* @since 1.0.0
|
|
129
129
|
*/
|
|
130
130
|
static readonly Default: Layer.Layer<Uuid7State, never, never>;
|
|
@@ -142,7 +142,7 @@ export declare class Uuid7State extends Uuid7State_base {
|
|
|
142
142
|
* import { Effect } from "effect"
|
|
143
143
|
* const id = Effect.provide(uuid7, Uuid7State.Default)
|
|
144
144
|
* ```
|
|
145
|
-
* @category
|
|
145
|
+
* @category ID generation
|
|
146
146
|
* @since 1.0.0
|
|
147
147
|
*/
|
|
148
148
|
export declare const uuid7: Effect.Effect<Uuid7, Cause.IllegalArgumentError, Uuid7State>;
|
package/dist/Uuid7.js
CHANGED
|
@@ -19,7 +19,7 @@ import { RandomValues } from "./RandomValues.js";
|
|
|
19
19
|
* import { Schema } from "effect"
|
|
20
20
|
* const id = Schema.decodeUnknownSync(Uuid7)("01890f2e-7d6c-7cc0-98c4-dc0c0c07398f")
|
|
21
21
|
* ```
|
|
22
|
-
* @category
|
|
22
|
+
* @category ID schemas
|
|
23
23
|
* @since 1.0.0
|
|
24
24
|
*/
|
|
25
25
|
export const Uuid7 = Schema.String.pipe(Schema.check(Schema.isUUID(7)), Schema.brand("@typed/id/UUID7"));
|
|
@@ -35,7 +35,7 @@ export const Uuid7 = Schema.String.pipe(Schema.check(Schema.isUUID(7)), Schema.b
|
|
|
35
35
|
* import { isUuid7 } from "@typed/id/Uuid7"
|
|
36
36
|
* const valid = isUuid7("01890f2e-7d6c-7cc0-98c4-dc0c0c07398f")
|
|
37
37
|
* ```
|
|
38
|
-
* @category
|
|
38
|
+
* @category ID validation
|
|
39
39
|
* @since 1.0.0
|
|
40
40
|
*/
|
|
41
41
|
export const isUuid7 = Schema.is(Uuid7);
|
|
@@ -53,7 +53,7 @@ const maximumTimestamp = 2 ** 48 - 1;
|
|
|
53
53
|
* import { Effect } from "effect"
|
|
54
54
|
* const id = Effect.provide(uuid7, Uuid7State.Default)
|
|
55
55
|
* ```
|
|
56
|
-
* @category
|
|
56
|
+
* @category Sequence state
|
|
57
57
|
* @since 1.0.0
|
|
58
58
|
*/
|
|
59
59
|
export class Uuid7State extends Context.Service()("@typed/id/Uuid7State", {
|
|
@@ -130,7 +130,7 @@ export class Uuid7State extends Context.Service()("@typed/id/Uuid7State", {
|
|
|
130
130
|
* The production default is explicit while remaining replaceable by deterministic service layers.
|
|
131
131
|
* ## Ownership and lifetime
|
|
132
132
|
* Layer acquisition creates one mutable sequence state owned by the surrounding Layer Scope.
|
|
133
|
-
* @category
|
|
133
|
+
* @category Production layers
|
|
134
134
|
* @since 1.0.0
|
|
135
135
|
*/
|
|
136
136
|
static Default = Layer.effect(Uuid7State, Uuid7State.make).pipe(Layer.provide([DateTimes.Default, RandomValues.Default]));
|
|
@@ -148,7 +148,7 @@ export class Uuid7State extends Context.Service()("@typed/id/Uuid7State", {
|
|
|
148
148
|
* import { Effect } from "effect"
|
|
149
149
|
* const id = Effect.provide(uuid7, Uuid7State.Default)
|
|
150
150
|
* ```
|
|
151
|
-
* @category
|
|
151
|
+
* @category ID generation
|
|
152
152
|
* @since 1.0.0
|
|
153
153
|
*/
|
|
154
154
|
export const uuid7 = Effect.map(Uuid7State.next, uuid7FromSeed);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as Cause from "effect/Cause";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import type { Uuid5 } from "../Uuid5.js";
|
|
4
|
+
import { Uuid5Namespace } from "../Uuid5.js";
|
|
5
|
+
import { DateTimes } from "../DateTimes.js";
|
|
6
|
+
import { RandomValues } from "../RandomValues.js";
|
|
7
|
+
export declare const makeLazyIds: (envData: string) => Effect.Effect<{
|
|
8
|
+
cuid: Effect.Effect<string & import("effect/Brand").Brand<"@typed/id/CUID">, never, never>;
|
|
9
|
+
ksuid: Effect.Effect<string & import("effect/Brand").Brand<"@typed/id/KSUID">, Cause.IllegalArgumentError, never>;
|
|
10
|
+
nanoId: Effect.Effect<string & import("effect/Brand").Brand<"@typed/id/NanoId">, never, never>;
|
|
11
|
+
ulid: Effect.Effect<string & import("effect/Brand").Brand<"@typed/id/ULID">, Cause.IllegalArgumentError, never>;
|
|
12
|
+
uuid4: Effect.Effect<string & import("effect/Brand").Brand<"@typed/id/UUID4">, never, never>;
|
|
13
|
+
uuid5: {
|
|
14
|
+
(namespace: Uuid5Namespace): (name: string) => Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
|
15
|
+
(name: string, namespace: Uuid5Namespace): Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
|
16
|
+
readonly dns: (name: string) => Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
|
17
|
+
readonly url: (name: string) => Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
|
18
|
+
readonly oid: (name: string) => Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
|
19
|
+
readonly x500: (name: string) => Effect.Effect<Uuid5, Cause.IllegalArgumentError>;
|
|
20
|
+
};
|
|
21
|
+
uuid7: Effect.Effect<string & import("effect/Brand").Brand<"@typed/id/UUID7">, Cause.IllegalArgumentError, never>;
|
|
22
|
+
}, never, DateTimes | RandomValues>;
|
|
23
|
+
//# sourceMappingURL=Ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ids.d.ts","sourceRoot":"","sources":["../../src/internal/Ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAS,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKlD,eAAO,MAAM,WAAW,YAAa,MAAM;;;;;;;oBAQxB,cAAc,GACxB,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC;eAC9D,MAAM,aAAa,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC;sBAC7E,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC;sBAClE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC;sBAClE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC;uBACjE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC;;;mCAwBnF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { dual } from "effect/Function";
|
|
3
|
+
import { Uuid5Namespace, uuid5 } from "../Uuid5.js";
|
|
4
|
+
import { CuidState, cuid } from "../Cuid.js";
|
|
5
|
+
import { ksuid } from "../Ksuid.js";
|
|
6
|
+
import { nanoId } from "../NanoId.js";
|
|
7
|
+
import { ulid } from "../Ulid.js";
|
|
8
|
+
import { uuid4 } from "../Uuid4.js";
|
|
9
|
+
import { Uuid7State, uuid7 } from "../Uuid7.js";
|
|
10
|
+
export const makeLazyIds = (envData) => Effect.gen(function* () {
|
|
11
|
+
const services = yield* Effect.context();
|
|
12
|
+
const getCuidState = yield* Effect.cached(Effect.provide(CuidState.make(envData), services));
|
|
13
|
+
const getUuid7State = yield* Effect.cached(Effect.provide(Uuid7State.make, services));
|
|
14
|
+
const uuid5_ = Object.assign(dual(2, (name, namespace) => Effect.provide(uuid5(name, namespace), services)), {
|
|
15
|
+
dns: uuid5(Uuid5Namespace.DNS),
|
|
16
|
+
url: uuid5(Uuid5Namespace.URL),
|
|
17
|
+
oid: uuid5(Uuid5Namespace.OID),
|
|
18
|
+
x500: uuid5(Uuid5Namespace.X500),
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
cuid: Effect.flatMap(getCuidState, (state) => Effect.provideService(cuid, CuidState, state)),
|
|
22
|
+
ksuid: Effect.provide(ksuid, services),
|
|
23
|
+
nanoId: Effect.provide(nanoId, services),
|
|
24
|
+
ulid: Effect.provide(ulid, services),
|
|
25
|
+
uuid4: Effect.provide(uuid4, services),
|
|
26
|
+
uuid5: uuid5_,
|
|
27
|
+
uuid7: Effect.flatMap(getUuid7State, (state) => Effect.provideService(uuid7, Uuid7State, state)),
|
|
28
|
+
};
|
|
29
|
+
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed/id",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.8",
|
|
4
4
|
"description": "Branded ID generators and facades for Typed applications.",
|
|
5
|
+
"homepage": "https://github.com/TylorS/typed/tree/development/packages/id#readme",
|
|
6
|
+
"bugs": "https://github.com/TylorS/typed/issues",
|
|
5
7
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://github.com/TylorS/typed-smol/tree/main/packages/id#readme",
|
|
7
|
-
"bugs": "https://github.com/TylorS/typed-smol/issues",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/TylorS/typed
|
|
10
|
+
"url": "git+https://github.com/TylorS/typed.git",
|
|
11
11
|
"directory": "packages/id"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"types": "./dist/Ids.d.ts",
|
|
33
33
|
"import": "./dist/Ids.js"
|
|
34
34
|
},
|
|
35
|
+
"./IdsTest": {
|
|
36
|
+
"types": "./dist/IdsTest.d.ts",
|
|
37
|
+
"import": "./dist/IdsTest.js"
|
|
38
|
+
},
|
|
35
39
|
"./Ksuid": {
|
|
36
40
|
"types": "./dist/Ksuid.d.ts",
|
|
37
41
|
"import": "./dist/Ksuid.js"
|