From 8c8ab430ce72797b9b4e3d84e04ca55f84292fa3 Mon Sep 17 00:00:00 2001 From: Yulian Kuncheff Date: Mon, 29 Jul 2024 15:25:45 -0700 Subject: [PATCH] Some changes before release --- CHANGELOG.md | 10 ++++++++++ lib/enums.dart | 7 +++++-- lib/uuid.dart | 11 +++++++++++ lib/uuid_value.dart | 12 ++++++++++++ lib/v5.dart | 11 +++++++++++ pubspec.yaml | 2 +- 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80869e7..f54ff93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +v4.5.0 + +* Deprecate the use of `Uuid.NAMESPACE*` and `UuidV5.NAMESPACE`, and switch to using a proper const enum for this. (thanks @bymoye) + * These will be removed once sufficient time has been made for the deprecation notice to be seen. Most likely v5.0. + * Please use the new `Namespace` enum in `enums.dart`. +* Re-add `Uuid.NAMESPACE*` and `UuidV5.NAMESPACE` in order to give deprecation time. +* Add missing MAX UUID option from RFC9562 +* Add `bytes` getter to `Namespace` enum. +* **[PARTIAL BREAKING CHANGE]** `Namespace` is now an enum, and the entries are now of the `Namespace` type. They all have a `value` function to return the internal `string` + v4.4.2 * Revert meta depenency version upgrade, was breaking flutter_test. (thanks @techouse) diff --git a/lib/enums.dart b/lib/enums.dart index d8eedda..7c24507 100644 --- a/lib/enums.dart +++ b/lib/enums.dart @@ -1,20 +1,23 @@ // ignore_for_file: constant_identifier_names +import 'package:uuid/uuid.dart'; import 'package:uuid/uuid_value.dart'; /// The options for UUID Validation strictness enum ValidationMode { nonStrict, strictRFC4122 } +/// RFC4122 & RFC9562 provided namespaces for v3, v5, and v8 namespace based UUIDs enum Namespace { - // RFC4122 provided namespaces for v3 and v5 namespace based UUIDs DNS("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), URL("6ba7b811-9dad-11d1-80b4-00c04fd430c8"), OID("6ba7b812-9dad-11d1-80b4-00c04fd430c8"), X500("6ba7b814-9dad-11d1-80b4-00c04fd430c8"), - NIL("00000000-0000-0000-0000-000000000000"); + NIL("00000000-0000-0000-0000-000000000000"), + MAX("ffffffff-ffff-ffff-ffff-ffffffffffff"); const Namespace(this.value); final String value; UuidValue get uuidValue => UuidValue.raw(value); + List get bytes => Uuid.parse(value, validate: false); } diff --git a/lib/uuid.dart b/lib/uuid.dart index ce217fa..5daaf2e 100644 --- a/lib/uuid.dart +++ b/lib/uuid.dart @@ -32,6 +32,17 @@ export 'enums.dart'; class Uuid { final GlobalOptions? goptions; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_OID = '6ba7b812-9dad-11d1-80b4-00c04fd430c8'; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_X500 = '6ba7b814-9dad-11d1-80b4-00c04fd430c8'; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_NIL = '00000000-0000-0000-0000-000000000000'; + /// Creates a new instance of the Uuid class. /// Optionally you can pass in a [GlobalOptions] object to set global options /// for all UUID generation. diff --git a/lib/uuid_value.dart b/lib/uuid_value.dart index 0569c23..0491fe5 100644 --- a/lib/uuid_value.dart +++ b/lib/uuid_value.dart @@ -2,6 +2,7 @@ import 'dart:typed_data'; import 'package:meta/meta.dart'; +import 'enums.dart'; import 'parsing.dart'; import 'uuid.dart'; import 'validation.dart'; @@ -10,6 +11,17 @@ import 'validation.dart'; class UuidValue { final String uuid; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const dns = UuidValue.raw(Uuid.NAMESPACE_DNS); + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const url = UuidValue.raw(Uuid.NAMESPACE_URL); + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const oid = UuidValue.raw(Uuid.NAMESPACE_OID); + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const x500 = UuidValue.raw(Uuid.NAMESPACE_X500); + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const nil = UuidValue.raw(Uuid.NAMESPACE_NIL); + /// fromString() creates a UuidValue from a [String] with no validation. factory UuidValue.fromString(String uuid) { return UuidValue.raw(uuid.toLowerCase()); diff --git a/lib/v5.dart b/lib/v5.dart index ce87b7c..f83ca8e 100644 --- a/lib/v5.dart +++ b/lib/v5.dart @@ -12,6 +12,17 @@ import 'package:crypto/crypto.dart' as crypto; class UuidV5 { final GlobalOptions? goptions; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_OID = '6ba7b812-9dad-11d1-80b4-00c04fd430c8'; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_X500 = '6ba7b814-9dad-11d1-80b4-00c04fd430c8'; + @Deprecated('Please use the Namespace enum in enums.dart instead.') + static const NAMESPACE_NIL = '00000000-0000-0000-0000-000000000000'; + const UuidV5({this.goptions}); /// v5() Generates a namspace & name-based version 5 UUID diff --git a/pubspec.yaml b/pubspec.yaml index 730838e..481c9a1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: uuid -version: 4.4.2 +version: 4.5.0 description: > RFC4122 (v1, v4, v5, v6, v7, v8) UUID Generator and Parser for Dart documentation: https://daegalus.github.io/dart-uuid/index.html