Skip to content

Commit

Permalink
Some changes before release
Browse files Browse the repository at this point in the history
  • Loading branch information
daegalus committed Jul 29, 2024
1 parent 42b2b47 commit 8c8ab43
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 5 additions & 2 deletions lib/enums.dart
Original file line number Diff line number Diff line change
@@ -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<int> get bytes => Uuid.parse(value, validate: false);
}
11 changes: 11 additions & 0 deletions lib/uuid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions lib/uuid_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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());
Expand Down
11 changes: 11 additions & 0 deletions lib/v5.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 8c8ab43

Please sign in to comment.