-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add type signatures and type checker for CI
Signed-off-by: Manuel Schönlaub <[email protected]>
- Loading branch information
1 parent
c149a45
commit ffc59f8
Showing
11 changed files
with
148 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
type flagValue = bool | Numeric | String | Hash[String, untyped] | ||
type flagValueType = :bool | :integer | :float | :string | :object | ||
type evaluationContext = { targeting_key: String? } | ||
type evaluationDetails = { flag_key: String, flag_value?: flagValue } | ||
|
||
type hookContext[T] = { | ||
flag_key: String, | ||
flag_value_type: flagValueType, | ||
evaluation_context: evaluationContext, | ||
default_value: T, | ||
} | ||
|
||
type hookHints = Hash[String, flagValue] | ||
|
||
interface _BeforeHook | ||
def before: (evaluationContext, ?hookHints) -> (evaluationContext | void) | ||
end | ||
|
||
interface _AfterHook[T] | ||
def after: (hookContext[T], evaluationDetails, ?hookHints) -> void | ||
end | ||
|
||
interface _ErrorHook[T] | ||
def error: (hookContext[T], Exception, ?hookHints) -> void | ||
end | ||
|
||
interface _FinallyHook[T] | ||
def finally: (hookContext[T], ?hookHints) -> void | ||
end | ||
|
||
type hook = _BeforeHook | _AfterHook[flagValue] | _ErrorHook[flagValue] | _FinallyHook[flagValue] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module OpenFeature | ||
module SDK | ||
|
||
interface _Configuration | ||
def context: () -> void | ||
end | ||
|
||
class API | ||
include _Configuration | ||
extend Forwardable | ||
|
||
attr_reader configuration: Configuration | ||
|
||
def build_client: -> Client | ||
|
||
def configure: () { (Configuration) -> void } -> void | ||
|
||
# Singleton's RBS doesn't quite work | ||
def self.instance: () -> instance | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module OpenFeature | ||
module SDK | ||
class Client | ||
RESULT_TYPE: Array[Symbol] | ||
SUFFIXES: Array[Symbol] | ||
|
||
@context: evaluationContext | ||
@hooks: Array[hook] | ||
|
||
attr_accessor hooks: Array[hook] | ||
attr_reader metadata: Metadata? | ||
attr_reader provider: untyped | ||
|
||
def initialize: (provider: untyped , client_options: untyped, context: untyped) -> void | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
module Concurrent | ||
class Array[T] < ::Array[T] | ||
def initialize: (?::Array[T]) -> void | ||
end | ||
end | ||
|
||
module OpenFeature | ||
module SDK | ||
class Configuration | ||
extend Forwardable | ||
|
||
attr_accessor context: evaluationContext | ||
attr_accessor hooks: [hook] | ||
attr_accessor metadata: Metadata | ||
attr_accessor provider: untyped | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module OpenFeature | ||
module SDK | ||
class Metadata | ||
attr_reader name: String | ||
attr_reader version: String? | ||
|
||
def initialize: (name: String, ?version: String?) -> void | ||
|
||
def ==: (untyped other) -> untyped | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module OpenFeature | ||
module SDK | ||
module Provider | ||
class NoOpProvider | ||
REASON_NO_OP: String | ||
NAME: String | ||
|
||
class ResolutionDetails[T] < ::Struct[T] | ||
attr_reader value(): T | ||
attr_reader reason(): untyped | ||
attr_reader variant(): untyped | ||
attr_reader error_code(): untyped | ||
attr_reader error_message(): untyped | ||
end | ||
|
||
attr_reader metadata: Metadata | ||
|
||
def fetch_boolean_value: (flag_key: String, default_value: bool?, ?evaluation_context: evaluationContext?) -> ResolutionDetails[bool] | ||
|
||
def fetch_string_value: (flag_key: String, default_value: String?, ?evaluation_context: evaluationContext?) -> ResolutionDetails[String] | ||
|
||
def fetch_number_value: (flag_key: String, default_value: Numeric?, ?evaluation_context: evaluationContext?) -> ResolutionDetails[Numeric] | ||
|
||
def fetch_object_value: (flag_key: String, default_value: Hash[untyped, untyped]?, ?evaluation_context: evaluationContext?) -> ResolutionDetails[Hash[untyped, untyped]] | ||
|
||
private | ||
|
||
def no_op:(default_value: flagValue) -> ResolutionDetails[flagValue] | ||
end | ||
end | ||
end | ||
end |