Unify uuid under uxbox.common.uuid.

This commit is contained in:
Andrey Antukh 2020-04-11 11:37:52 +02:00 committed by Alonso Torres
parent a91a8401d6
commit 9649d67883
59 changed files with 289 additions and 349 deletions

View file

@ -20,12 +20,12 @@
[uxbox.migrations]
[uxbox.services.mutations.profile :as mt.profile]
[uxbox.util.blob :as blob]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[vertx.util :as vu]))
(defn- mk-uuid
[prefix & args]
(uuid/namespaced uuid/oid (apply str prefix (interpose "-" args))))
(uuid/namespaced uuid/zero (apply str prefix (interpose "-" args))))
;; --- Profiles creation

View file

@ -11,7 +11,7 @@
[promesa.core :as p]
[uxbox.http.errors :as errors]
[uxbox.http.session :as session]
[uxbox.util.uuid :as uuid]))
[uxbox.common.uuid :as uuid]))
(defn emails-list
[req]

View file

@ -13,7 +13,7 @@
[uxbox.services.init]
[uxbox.services.mutations :as sm]
[uxbox.services.queries :as sq]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[vertx.web :as vw]
[vertx.eventbus :as ve]))
@ -75,7 +75,7 @@
(defn logout-handler
[req]
(some-> (get-in req [:cookies "auth-token"])
(uuid/from-string)
(uuid/uuid)
(session/delete)
(p/then' (fn [token]
{:status 204

View file

@ -9,7 +9,7 @@
[promesa.core :as p]
[vertx.core :as vc]
[uxbox.db :as db]
[uxbox.util.uuid :as uuid]))
[uxbox.common.uuid :as uuid]))
;; --- Main API
@ -40,7 +40,7 @@
[request]
(try
(when-let [token (get-in request [:cookies "auth-token"])]
(uuid/from-string token))
(uuid/uuid token))
(catch java.lang.IllegalArgumentException e
nil)))

View file

@ -17,7 +17,7 @@
[uxbox.services.queries :as sq]
[uxbox.util.blob :as blob]
[uxbox.util.transit :as t]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[vertx.eventbus :as ve]
[vertx.http :as vh]
[vertx.util :as vu]

View file

@ -28,7 +28,7 @@
[uxbox.util.svg :as svg]
[uxbox.util.transit :as t]
[uxbox.util.blob :as blob]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[uxbox.util.data :as data]
[uxbox.services.mutations.colors :as colors]
[uxbox.services.mutations.icons :as icons]

View file

@ -18,7 +18,7 @@
[uxbox.services.queries.teams :as teams]
[uxbox.services.mutations :as sm]
[uxbox.services.util :as su]
[uxbox.util.uuid :as uuid]))
[uxbox.common.uuid :as uuid]))
;; --- Helpers & Specs

View file

@ -19,7 +19,7 @@
[uxbox.services.mutations :as sm]
[uxbox.services.mutations.profile :as profile]
[uxbox.tasks :as tasks]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[uxbox.util.time :as tm]))
(sm/defmutation ::create-demo-profile

View file

@ -26,7 +26,7 @@
[uxbox.services.mutations.images :as imgs]
[uxbox.services.util :as su]
[uxbox.util.blob :as blob]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[uxbox.util.storage :as ust]
[vertx.util :as vu]))

View file

@ -20,7 +20,7 @@
[uxbox.services.util :as su]
[uxbox.tasks :as tasks]
[uxbox.util.blob :as blob]
[uxbox.util.uuid :as uuid]))
[uxbox.common.uuid :as uuid]))
;; --- Helpers & Specs

View file

@ -22,7 +22,7 @@
[uxbox.services.queries.teams :as teams]
[uxbox.services.mutations :as sm]
[uxbox.services.util :as su]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[uxbox.util.storage :as ust]
[vertx.util :as vu]))

View file

@ -23,7 +23,7 @@
[uxbox.tasks :as tasks]
[uxbox.util.blob :as blob]
[uxbox.util.sql :as sql]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[vertx.eventbus :as ve]))
;; --- Helpers & Specs

View file

@ -33,7 +33,7 @@
[uxbox.services.util :as su]
[uxbox.util.blob :as blob]
[uxbox.util.storage :as ust]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[uxbox.util.time :as tm]
[vertx.util :as vu]))

View file

@ -19,7 +19,7 @@
[uxbox.services.mutations :as sm]
[uxbox.services.util :as su]
[uxbox.util.blob :as blob]
[uxbox.util.uuid :as uuid]))
[uxbox.common.uuid :as uuid]))
;; --- Helpers & Specs

View file

@ -17,7 +17,7 @@
[uxbox.services.mutations :as sm]
[uxbox.services.util :as su]
[uxbox.util.blob :as blob]
[uxbox.util.uuid :as uuid]))
[uxbox.common.uuid :as uuid]))
;; --- Helpers & Specs

View file

@ -22,7 +22,7 @@
[uxbox.services.util :as su]
[uxbox.util.blob :as blob]
[uxbox.util.data :as data]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[vertx.core :as vc]))
;; --- Helpers & Specs

View file

@ -22,7 +22,7 @@
[uxbox.services.util :as su]
[uxbox.util.blob :as blob]
[uxbox.util.data :as data]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[vertx.core :as vc]))
;; --- Helpers & Specs

View file

@ -15,7 +15,7 @@
[uxbox.images :as images]
[uxbox.services.queries :as sq]
[uxbox.services.util :as su]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[uxbox.util.blob :as blob]))
;; --- Helpers & Specs

View file

@ -17,7 +17,7 @@
[uxbox.services.queries :as sq]
[uxbox.services.util :as su]
[uxbox.util.blob :as blob]
[uxbox.util.uuid :as uuid]))
[uxbox.common.uuid :as uuid]))
;; --- Team Edition Permissions

View file

@ -23,7 +23,7 @@
[uxbox.services.util :as su]
[uxbox.util.blob :as blob]
[uxbox.util.data :as data]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[vertx.core :as vc]))
;; --- Helpers & Specs

View file

@ -11,7 +11,7 @@
[vertx.util :as vu]
[uxbox.core :refer [system]]
[uxbox.common.exceptions :as ex]
[uxbox.util.uuid :as uuid]
[uxbox.common.uuid :as uuid]
[uxbox.util.dispatcher :as uds]))
(defn raise-not-found-if-nil

View file

@ -1,42 +0,0 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; This Source Code Form is "Incompatible With Secondary Licenses", as
;; defined by the Mozilla Public License, v. 2.0.
;;
;; Copyright (c) 2020 UXBOX Labs SL
(ns uxbox.util.uuid
(:refer-clojure :exclude [next])
(:require [clj-uuid :as uuid])
(:import java.util.UUID))
(def ^:const zero uuid/+null+)
(def ^:const oid uuid/+namespace-oid+)
(defmacro next
[]
`(uuid/v1))
(defmacro random
"Alias for clj-uuid/v4."
[]
`(uuid/v4))
(defmacro namespaced
[ns data]
`(uuid/v5 ~ns ~data))
(defmacro str->uuid
[s]
`(UUID/fromString ~s))
(defn from-string
"Parse string uuid representation into proper UUID instance."
[s]
(UUID/fromString s))
(defn custom
([a] (UUID. 0 a))
([b a] (UUID. b a)))