diff --git a/apps/lenra/lib/lenra/apps/webhook.ex b/apps/lenra/lib/lenra/apps/webhook.ex
index db1760f0..cd7b30f6 100644
--- a/apps/lenra/lib/lenra/apps/webhook.ex
+++ b/apps/lenra/lib/lenra/apps/webhook.ex
@@ -9,13 +9,13 @@ defmodule Lenra.Apps.Webhook do
alias Lenra.Accounts.User
alias Lenra.Apps.{Environment, Webhook}
- @derive {Jason.Encoder, only: [:uuid, :action, :props, :environment_id, :user_id]}
+ @derive {Jason.Encoder, only: [:uuid, :listener, :props, :environment_id, :user_id]}
@primary_key {:uuid, Ecto.UUID, autogenerate: true}
schema "webhooks" do
belongs_to(:environment, Environment)
belongs_to(:user, User)
- field(:action, :string)
+ field(:listener, :string)
field(:props, :map)
timestamps()
@@ -23,8 +23,8 @@ defmodule Lenra.Apps.Webhook do
def changeset(webhook, params \\ %{}) do
webhook
- |> cast(params, [:action, :props, :user_id])
- |> validate_required([:environment_id, :action])
+ |> cast(params, [:listener, :props, :user_id])
+ |> validate_required([:environment_id, :listener])
|> foreign_key_constraint(:environment_id)
|> foreign_key_constraint(:user_id)
end
@@ -39,8 +39,8 @@ defmodule Lenra.Apps.Webhook do
changeset =
%__MODULE__{}
- |> cast(webhook_map, [:uuid, :action, :props, :user_id, :environment_id, :inserted_at, :updated_at])
- |> validate_required([:environment_id, :action])
+ |> cast(webhook_map, [:uuid, :listener, :props, :user_id, :environment_id, :inserted_at, :updated_at])
+ |> validate_required([:environment_id, :listener])
|> foreign_key_constraint(:environment_id)
|> foreign_key_constraint(:user_id)
diff --git a/apps/lenra/lib/lenra/errors/technical_error.ex b/apps/lenra/lib/lenra/errors/technical_error.ex
index f58f6364..eacf7a23 100644
--- a/apps/lenra/lib/lenra/errors/technical_error.ex
+++ b/apps/lenra/lib/lenra/errors/technical_error.ex
@@ -11,12 +11,10 @@ defmodule Lenra.Errors.TechnicalError do
{:openfaas_not_reachable, "Openfaas could not be reached."},
{:unhandled_resource_type, "Unknown resource."},
{:application_not_found, "The application was not found in Openfaas."},
- {:listener_not_found, "No listener found in app manifest."},
{:openfaas_delete_error, "Openfaas could not delete the application."},
{:timeout, "Openfaas timeout."},
{:no_app_found, "No application found for the current link."},
{:environment_not_built, "This application was not yet build."},
- {:widget_not_found, "No Widget found in app manifest."},
{:invalid_ui, "Invalid UI"},
{:datastore_not_found, "Datastore cannot be found"},
{:data_not_found, "Data cannot be found"},
diff --git a/apps/lenra/lib/lenra/services/openfaas_services.ex b/apps/lenra/lib/lenra/services/openfaas_services.ex
index 176c7a8e..d289acaf 100644
--- a/apps/lenra/lib/lenra/services/openfaas_services.ex
+++ b/apps/lenra/lib/lenra/services/openfaas_services.ex
@@ -1,6 +1,6 @@
defmodule Lenra.OpenfaasServices do
@moduledoc """
- The service that manage calls to an Openfaas action with `run_action/3`
+ The service that manage calls to an Openfaas function with `run_action/3`
"""
alias Lenra.Apps
@@ -114,14 +114,14 @@ defmodule Lenra.OpenfaasServices do
TechnicalError.openfaas_delete_error_tuple()
end
- defp response({:error, %Mint.TransportError{reason: reason}}, _action) do
+ defp response({:error, %Mint.TransportError{reason: reason}}, _function) do
Logger.error("Openfaas could not be reached. It should not happen. \n\t\t reason: #{reason}")
TechnicalError.openfaas_not_reachable_tuple()
end
defp response(
{:ok, %Finch.Response{status: status_code, body: body}},
- _action
+ _function
)
when status_code not in [200, 202] do
case status_code do
diff --git a/apps/lenra_web/test/channels/app_channel_test.exs b/apps/lenra_web/test/channels/app_channel_test.exs
index e4518123..0228f4a0 100644
--- a/apps/lenra_web/test/channels/app_channel_test.exs
+++ b/apps/lenra_web/test/channels/app_channel_test.exs
@@ -16,8 +16,8 @@ defmodule LenraWeb.AppChannelTest do
# alias LenraWeb.UserSocket
# @build_number 1
- # @listener_name "HiBob"
- # @listener_code Crypto.hash({@listener_name, %{}})
+ # @_listener "HiBob"
+ # @listener_code Crypto.hash({@_listener, %{}})
# @manifest %{"manifest" => %{"rootWidget" => "test"}}
@@ -25,15 +25,21 @@ defmodule LenraWeb.AppChannelTest do
# @data2 %{"data" => %{"user" => %{"name" => "Bob"}}}
# @textfield %{
- # "type" => "textfield",
+ # "_type" => "textfield",
# "value" => "Hello World",
- # "onChanged" => %{"action" => @listener_name}
+ # "onChanged" => %{
+ # "_type" => "listener",
+ # "name" => @_listener
+ # }
# }
# @textfield2 %{
# "type" => "textfield",
# "value" => "Hello Bob",
- # "onChanged" => %{"action" => @listener_name}
+ # "onChanged" => %{
+ # "_type" => "listener",
+ # "name" => @_listener
+ # }
# }
# @transformed_textfield %{
diff --git a/apps/lenra_web/test/controllers/webhooks_controller_test.exs b/apps/lenra_web/test/controllers/webhooks_controller_test.exs
index 945dd6e9..2e8d2488 100644
--- a/apps/lenra_web/test/controllers/webhooks_controller_test.exs
+++ b/apps/lenra_web/test/controllers/webhooks_controller_test.exs
@@ -29,26 +29,26 @@ defmodule LenraWeb.WebhooksControllerTest do
@tag auth_user_with_cgu: :dev
test "Get env webhooks should work properly", %{conn: conn, env: env} do
- WebhookServices.create(env.id, %{"action" => "test"})
+ WebhookServices.create(env.id, %{"listener" => "test"})
conn = get(conn, Routes.webhooks_path(conn, :index), %{"env_id" => env.id})
assert [webhook] = json_response(conn, 200)
- assert webhook["action"] == "test"
+ assert webhook["listener"] == "test"
assert webhook["environment_id"] == env.id
end
@tag auth_user_with_cgu: :dev
test "Get session webhooks should work properly", %{conn: conn, user: user, env: env} do
WebhookServices.create(env.id, %{
- "action" => "test",
+ "listener" => "test",
"user_id" => user.id
})
conn = get(conn, Routes.webhooks_path(conn, :index), %{"env_id" => env.id, "user_id" => user.id})
assert [webhook] = json_response(conn, 200)
- assert webhook["action"] == "test"
+ assert webhook["listener"] == "test"
assert webhook["environment_id"] == env.id
assert webhook["user_id"] == user.id
end
@@ -65,16 +65,16 @@ defmodule LenraWeb.WebhooksControllerTest do
conn =
post(conn, Routes.webhooks_path(conn, :api_create), %{
"env_id" => env.id,
- "action" => "test",
+ "listener" => "test",
"user_id" => user.id
})
- assert %{"action" => "test"} = json_response(conn, 200)
+ assert %{"listener" => "test"} = json_response(conn, 200)
conn! = get(conn, Routes.webhooks_path(conn, :index), %{"env_id" => env.id})
assert [webhook] = json_response(conn!, 200)
- assert webhook["action"] == "test"
+ assert webhook["listener"] == "test"
assert webhook["environment_id"] == env.id
end
@@ -82,7 +82,7 @@ defmodule LenraWeb.WebhooksControllerTest do
test "Create webhook without env_id as parameter should fail", %{conn: conn, user: user} do
conn =
post(conn, Routes.webhooks_path(conn, :api_create), %{
- "action" => "test",
+ "listener" => "test",
"user_id" => user.id
})
@@ -102,8 +102,8 @@ defmodule LenraWeb.WebhooksControllerTest do
callback.(body_decoded)
case body_decoded do
- # Listeners "action" in body
- %{"action" => _action} ->
+ # Listeners "listener" in body
+ %{"listener" => _listener} ->
Plug.Conn.resp(conn, 200, "")
end
end
@@ -123,7 +123,7 @@ defmodule LenraWeb.WebhooksControllerTest do
{:ok, webhook} =
WebhookServices.create(env.id, %{
- "action" => "test"
+ "listener" => "test"
})
bypass = Bypass.open(port: 1234)
@@ -134,7 +134,7 @@ defmodule LenraWeb.WebhooksControllerTest do
"/function/test",
&handle_request(&1, fn body ->
assert body["props"] == nil
- assert body["action"] == "test"
+ assert body["listener"] == "test"
assert body["event"] == %{"payloadData" => "Value"}
end)
)
@@ -158,7 +158,7 @@ defmodule LenraWeb.WebhooksControllerTest do
} do
{:ok, webhook} =
WebhookServices.create(env.id, %{
- "action" => "test"
+ "listener" => "test"
})
conn =
diff --git a/libs/application_runner/.gitignore b/libs/application_runner/.gitignore
index 51539dd8..e541adc1 100644
--- a/libs/application_runner/.gitignore
+++ b/libs/application_runner/.gitignore
@@ -21,10 +21,3 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
application_runner-*.tar
-
-
-# Temporary files for e.g. tests
-/tmp
-
-.DS_Store
-.iex.exs
\ No newline at end of file
diff --git a/libs/application_runner/LICENSE b/libs/application_runner/LICENSE
deleted file mode 100644
index be3f7b28..00000000
--- a/libs/application_runner/LICENSE
+++ /dev/null
@@ -1,661 +0,0 @@
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-.
diff --git a/libs/application_runner/benchmarks/json_validator.exs b/libs/application_runner/benchmarks/json_validator.exs
index 4c8b27b0..c3f34a26 100644
--- a/libs/application_runner/benchmarks/json_validator.exs
+++ b/libs/application_runner/benchmarks/json_validator.exs
@@ -8,20 +8,21 @@ root = fn json -> %{
end
text = %{
- "type" => "text",
+ "_type" => "text",
"value" => "machin"
}
error_text = %{
- "type" => "text"
+ "_type" => "text"
}
button = %{
- "type" => "button",
+ "_type" => "button",
"value" => "azaz",
"listeners" => %{
"onClick" => %{
- "action" => "anyaction",
+ "_type" => "listener",
+ "name" => "anyaction",
"props" => %{
"number" => 10,
"value" => "value"
@@ -31,7 +32,7 @@ button = %{
}
container = %{
- "type" => "container",
+ "_type" => "container",
"children" => [
text,
text,
@@ -43,7 +44,7 @@ container = %{
}
error_container = %{
- "type" => "container",
+ "_type" => "container",
"children" => [
text,
text,
diff --git a/libs/application_runner/config/config.exs b/libs/application_runner/config/config.exs
index 42a2e7b3..44b18641 100644
--- a/libs/application_runner/config/config.exs
+++ b/libs/application_runner/config/config.exs
@@ -34,6 +34,9 @@ config :application_runner, :mongo,
port: "27017",
ssl: false
+config :application_runner,
+ ecto_repos: [ApplicationRunner.Repo]
+
config :application_runner, ApplicationRunner.Repo,
database: "file::memory:?cache=shared",
log: false
diff --git a/libs/application_runner/docker-compose.yml b/libs/application_runner/docker-compose.yml
deleted file mode 100644
index 50fe6b55..00000000
--- a/libs/application_runner/docker-compose.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-services:
- postgres:
- image: postgres:13
- ports:
- - 5432:5432
- environment:
- POSTGRES_DB: lenra_dev
- POSTGRES_PASSWORD: postgres
- healthcheck:
- test:
- - CMD
- - pg_isready
- - -U
- - postgres
- interval: 1s
- retries: 5
- start_period: 5s
- mongodb:
- image: mongo:5
- ports:
- - 27017:27017
- environment:
- MONGO_INITDB_DATABASE: test
- CONFIG: '{"_id" : "rs0", "members" : [{"_id" : 0,"host" : "localhost:27017"}]}'
- command: mongod --replSet rs0
- healthcheck:
- test: test $$(echo "rs.initiate($$CONFIG).ok || rs.status().ok" | mongo --quiet) -eq 1
- interval: 1s
- retries: 5
- start_period: 5s
\ No newline at end of file
diff --git a/libs/application_runner/docs/AppRunnerExplained.md b/libs/application_runner/docs/AppRunnerExplained.md
index fff17255..b65d945f 100644
--- a/libs/application_runner/docs/AppRunnerExplained.md
+++ b/libs/application_runner/docs/AppRunnerExplained.md
@@ -158,7 +158,7 @@ sequenceDiagram
User->>Client: Trigger Listener (press button)
Client->>RouteChannel: send listener with code
RouteChannel->>Session.EventHandler: send_client_event(code)
- Session.EventHandler-->>Session.EventHandler: Translate code to action/props
+ Session.EventHandler-->>Session.EventHandler: Translate code to listener/props
Session.EventHandler->>App: Http call listener (actio, props)
opt if listener call data api
loop Any number of call
diff --git a/libs/application_runner/lib/channels/routes_channel.ex b/libs/application_runner/lib/channels/routes_channel.ex
index 37bebff0..e08292d6 100644
--- a/libs/application_runner/lib/channels/routes_channel.ex
+++ b/libs/application_runner/lib/channels/routes_channel.ex
@@ -11,6 +11,7 @@ defmodule ApplicationRunner.RoutesChannel do
alias ApplicationRunner.Environment
alias ApplicationRunner.Guardian.AppGuardian
alias ApplicationRunner.Session
+ alias ApplicationRunner.Session.UiBuilders.JsonBuilder
alias ApplicationRunner.Session.UiBuilders.LenraBuilder
alias LenraCommonWeb.ErrorHelpers
@@ -21,7 +22,6 @@ defmodule ApplicationRunner.RoutesChannel do
def join("routes", %{"mode" => "lenra"}, socket) do
env_id = socket.assigns.env_id
- manifest = Environment.ManifestHandler.get_manifest(env_id)
session_id = socket.assigns.session_id
res = %{
@@ -50,9 +50,8 @@ defmodule ApplicationRunner.RoutesChannel do
def join("routes", %{"mode" => "json"}, socket) do
env_id = socket.assigns.env_id
- manifest = Environment.ManifestHandler.get_manifest(env_id)
- res = %{"jsonRoutes" => Map.get(manifest, "jsonRoutes")}
+ res = %{"jsonRoutes" => JsonBuilder.get_routes(env_id)}
{:ok, res, socket}
end
diff --git a/libs/application_runner/lib/crons.ex b/libs/application_runner/lib/crons.ex
index 780755b3..4d558573 100644
--- a/libs/application_runner/lib/crons.ex
+++ b/libs/application_runner/lib/crons.ex
@@ -11,7 +11,7 @@ defmodule ApplicationRunner.Crons do
alias Crontab.CronExpression.{Composer, Parser}
def run_env_cron(
- action,
+ listener,
props,
event,
env_id,
@@ -22,11 +22,11 @@ defmodule ApplicationRunner.Crons do
env_id: env_id,
function_name: function_name
}) do
- EventHandler.send_env_event(env_id, action, props, event)
+ EventHandler.send_env_event(env_id, listener, props, event)
end
end
- def create(env_id, function_name, %{"listener_name" => _action} = params) do
+ def create(env_id, function_name, %{"listener" => _listener} = params) do
with {:ok, cron} <-
env_id
|> Cron.new(function_name, params)
@@ -98,7 +98,7 @@ defmodule ApplicationRunner.Crons do
task:
{ApplicationRunner.Crons, :run_env_cron,
[
- cron.listener_name,
+ cron.listener,
cron.props,
%{},
cron.environment_id,
@@ -113,10 +113,10 @@ defmodule ApplicationRunner.Crons do
overlap: overlap,
schedule: schedule,
state: state,
- task: {_, _, [listener_name, props, _, env_id, function_name]}
+ task: {_, _, [listener, props, _, env_id, function_name]}
}) do
Cron.new(env_id, function_name, %{
- "listener_name" => listener_name,
+ "listener" => listener,
"schedule" => Composer.compose(schedule),
"props" => props,
"name" => name,
diff --git a/libs/application_runner/lib/crons/cron.ex b/libs/application_runner/lib/crons/cron.ex
index 1aa6645b..3c797ff9 100644
--- a/libs/application_runner/lib/crons/cron.ex
+++ b/libs/application_runner/lib/crons/cron.ex
@@ -13,7 +13,7 @@ defmodule ApplicationRunner.Crons.Cron do
only: [
:id,
:name,
- :listener_name,
+ :listener,
:schedule,
:props,
:should_run_missed_steps,
@@ -27,7 +27,7 @@ defmodule ApplicationRunner.Crons.Cron do
belongs_to(:environment, Environment)
belongs_to(:user, User)
- field(:listener_name, :string)
+ field(:listener, :string)
field(:schedule, :string)
field(:props, :map, default: %{})
@@ -44,7 +44,7 @@ defmodule ApplicationRunner.Crons.Cron do
def changeset(cron, params \\ %{}) do
cron
|> cast(params, [
- :listener_name,
+ :listener,
:schedule,
:props,
:should_run_missed_steps,
@@ -53,7 +53,7 @@ defmodule ApplicationRunner.Crons.Cron do
:overlap,
:state
])
- |> validate_required([:environment_id, :listener_name, :schedule])
+ |> validate_required([:environment_id, :listener, :schedule])
|> validate_change(:schedule, fn :schedule, cron ->
case Parser.parse(cron) do
{:ok, _cron_expr} -> []
diff --git a/libs/application_runner/lib/environment/manifest_handler.ex b/libs/application_runner/lib/environment/manifest_handler.ex
index 9ca5568b..bf06f991 100644
--- a/libs/application_runner/lib/environment/manifest_handler.ex
+++ b/libs/application_runner/lib/environment/manifest_handler.ex
@@ -56,29 +56,27 @@ defmodule ApplicationRunner.Environment.ManifestHandler do
{:reply, Map.get(state, :manifest), state}
end
- @default_routes [%{"path" => "/", "view" => %{"type" => "view", "name" => "main"}}]
+ @default_routes [%{"path" => "/", "view" => %{"_type" => "view", "name" => "main"}}]
+
def handle_call(:get_lenra_routes, _from, state) do
Logger.debug("#{__MODULE__} handle call for :get_lenra_routes with #{inspect(state)}")
manifest = Map.get(state, :manifest)
- {:reply, get_routes(manifest), state}
+ {:reply, get_exposer_routes(manifest, "lenra"), state}
end
- @default_json_routes [%{"path" => "/", "view" => %{"type" => "view", "name" => "main"}}]
def handle_call(:get_json_routes, _from, state) do
Logger.debug("#{__MODULE__} handle call for :get_json_routes with #{inspect(state)}")
manifest = Map.get(state, :manifest)
- {:reply, Map.get(manifest, "jsonRoutes", @default_json_routes), state}
- end
-
- defp get_routes(%{"rootView" => rootView}) do
- [%{"path" => "/", "view" => %{"type" => "view", "name" => rootView}}]
+ {:reply, get_exposer_routes(manifest, "json"), state}
end
- defp get_routes(manifest) do
- Map.get(manifest, "lenraRoutes", @default_routes)
+ defp get_exposer_routes(manifest, exposer) do
+ manifest
+ |> Map.get(exposer, %{"routes" => @default_routes})
+ |> Map.get("routes", @default_routes)
end
end
diff --git a/libs/application_runner/lib/errors/business_error.ex b/libs/application_runner/lib/errors/business_error.ex
index a33777f6..d4111283 100644
--- a/libs/application_runner/lib/errors/business_error.ex
+++ b/libs/application_runner/lib/errors/business_error.ex
@@ -17,7 +17,7 @@ defmodule ApplicationRunner.Errors.BusinessError do
{:no_app_found, "No application found for the current link"},
{:not_an_object_id, "The given id is not a valid object id"},
{:incorrect_view_mode, "The view mode should be one of 'lenra', 'json'."},
- {:no_action_in_listener, "Your listener does not have the required property 'action'"},
+ {:no_name_in_listener, "Your listener does not have the required property 'name'"},
{:route_does_not_exist, "The given route does not exist. Please check your manifest."},
{:invalid_channel_name, "The given channel name does not exist."},
{:invalid_params, "Invalid params"},
diff --git a/libs/application_runner/lib/event_handler.ex b/libs/application_runner/lib/event_handler.ex
index 7af6388d..e9381831 100644
--- a/libs/application_runner/lib/event_handler.ex
+++ b/libs/application_runner/lib/event_handler.ex
@@ -19,33 +19,33 @@ defmodule ApplicationRunner.EventHandler do
@doc """
Send async call to application,
- the call will run listeners with the given `action` `props` `event`
+ the call will run listeners with the given `listener` `props` `event`
"""
- def send_env_event(env_id, action, props, event) do
+ def send_env_event(env_id, listener, props, event) do
uuid = Ecto.UUID.generate()
GenServer.call(
get_full_name({:env, env_id}),
- {:send_event, action, props, event, env_id, uuid},
+ {:send_event, listener, props, event, env_id, uuid},
Application.fetch_env!(:application_runner, :listeners_timeout)
)
end
- def send_session_event(session_id, action, props, event) do
+ def send_session_event(session_id, listener, props, event) do
uuid = Ecto.UUID.generate()
GenServer.call(
get_full_name({:session, session_id}),
- {:send_event, action, props, event, session_id, uuid},
+ {:send_event, listener, props, event, session_id, uuid},
Application.fetch_env!(:application_runner, :listeners_timeout)
)
end
def send_client_event(session_id, code, event) do
with {:ok, listener} <- Session.ListenersCache.fetch_listener(session_id, code),
- {:ok, action} <- Map.fetch(listener, "action"),
+ {:ok, name} <- Map.fetch(listener, "name"),
props <- Map.get(listener, "props", %{}) do
- send_session_event(session_id, action, props, event)
+ send_session_event(session_id, name, props, event)
end
end
@@ -70,15 +70,15 @@ defmodule ApplicationRunner.EventHandler do
@impl true
def handle_call(
- {:send_event, "@lenra:" <> action, props, event, uuid, session_id},
+ {:send_event, "@lenra:" <> listener, props, event, uuid, session_id},
_from,
state
) do
Logger.debug(
- "#{__MODULE__} handle_call for @lenra action: #{inspect(action)} with props #{inspect(props)} and event #{inspect(event)}"
+ "#{__MODULE__} handle_call for @lenra listener: #{inspect(listener)} with props #{inspect(props)} and event #{inspect(event)}"
)
- case action do
+ case listener do
"navTo" ->
ApplicationRunner.RoutesChannel.get_name(session_id)
|> Swarm.send({:send, :navTo, props})
@@ -89,17 +89,17 @@ defmodule ApplicationRunner.EventHandler do
@impl true
def handle_call(
- {:send_event, action, props, event, _id, uuid},
+ {:send_event, listener, props, event, _id, uuid},
_from,
%{mode: mode, id: id} = state
) do
Logger.debug(
- "#{__MODULE__} handle_call for action: #{inspect(action)} with props #{inspect(props)} and event #{inspect(event)}"
+ "#{__MODULE__} handle_call for listener: #{inspect(listener)} with props #{inspect(props)} and event #{inspect(event)}"
)
%{function_name: function_name, token: token} = get_metadata(mode, id) |> create_token(uuid)
- res = ApplicationServices.run_listener(function_name, action, props, event, token)
+ res = ApplicationServices.run_listener(function_name, listener, props, event, token)
{:reply, res, state}
after
diff --git a/libs/application_runner/lib/monitor.ex b/libs/application_runner/lib/monitor.ex
index 67f9283e..449c3be4 100644
--- a/libs/application_runner/lib/monitor.ex
+++ b/libs/application_runner/lib/monitor.ex
@@ -6,12 +6,12 @@ defmodule ApplicationRunner.Monitor do
#### Measurements
* start_time.
#### Metadata
- * `:user_id` - The id of the user who executed the action.
- * `:env_id` - The name of the application from which the action was executed.
+ * `:user_id` - The id of the user who executed the function.
+ * `:env_id` - The name of the application from which the function was executed.
* `[:ApplicationRunner, :app_session, :stop]` - Executed after socket closed.
#### Measurements
* end_time.
- * `:duration` - The time took by the openfaas action in `:native` unit of time.
+ * `:duration` - The time took by the openfaas function in `:native` unit of time.
"""
import Ecto.Query, only: [from: 2]
diff --git a/libs/application_runner/lib/router.ex b/libs/application_runner/lib/router.ex
index af62a8e4..d48e6a80 100644
--- a/libs/application_runner/lib/router.ex
+++ b/libs/application_runner/lib/router.ex
@@ -7,28 +7,30 @@ defmodule ApplicationRunner.Router do
plug(EnsureAuthenticatedAppPipeline)
end
- scope "/app", ApplicationRunner do
+ scope "/app-api/v1", ApplicationRunner do
pipe_through([:api, :ensure_auth_app])
- delete("/colls/:coll", CollsController, :delete)
- get("/colls/:coll/docs", DocsController, :get_all)
- post("/colls/:coll/docs", DocsController, :create)
- get("/colls/:coll/docs/:docId", DocsController, :get)
- put("/colls/:coll/docs/:docId", DocsController, :update)
- delete("/colls/:coll/docs/:docId", DocsController, :delete)
- post("/colls/:coll/docs/find", DocsController, :find)
- post("/colls/:coll/updateMany", DocsController, :update_many)
+ ### Data
+ # CRUD
+ delete("/data/colls/:coll", CollsController, :delete)
+ get("/data/colls/:coll/docs", DocsController, :get_all)
+ post("/data/colls/:coll/docs", DocsController, :create)
+ get("/data/colls/:coll/docs/:docId", DocsController, :get)
+ put("/data/colls/:coll/docs/:docId", DocsController, :update)
+ delete("/data/colls/:coll/docs/:docId", DocsController, :delete)
+ # Mongo functions
+ post("/data/colls/:coll/find", DocsController, :find)
+ post("/data/colls/:coll/updateMany", DocsController, :update_many)
+ # Transactions
+ post("/data/transaction", DocsController, :transaction)
+ post("/data/transaction/commit", DocsController, :commit_transaction)
+ post("/data/transaction/abort", DocsController, :abort_transaction)
resources("/crons", CronController,
only: [:create, :index, :update, :delete],
param: "name"
)
- post("/transaction", DocsController, :transaction)
- post("/transaction/commit", DocsController, :commit_transaction)
-
- post("/transaction/abort", DocsController, :abort_transaction)
-
post("/webhooks", Webhooks.WebhooksController, :create)
end
end
diff --git a/libs/application_runner/lib/services/application_services.ex b/libs/application_runner/lib/services/application_services.ex
index 889860b5..6727df89 100644
--- a/libs/application_runner/lib/services/application_services.ex
+++ b/libs/application_runner/lib/services/application_services.ex
@@ -1,6 +1,6 @@
defmodule ApplicationRunner.ApplicationServices do
@moduledoc """
- The service that manages calls to an Openfaas action with `run_action/3`
+ The service that manages calls to an Openfaas function with `run_action/3`
"""
alias ApplicationRunner.Errors.TechnicalError
alias ApplicationRunner.Guardian.AppGuardian
@@ -28,7 +28,7 @@ defmodule ApplicationRunner.ApplicationServices do
end
@doc """
- Run a HTTP POST request with needed headers and body to call an Openfaas Action and decode the response body.
+ Run a HTTP POST request with needed headers and body to call an Openfaas function and decode the response body.
Returns `:ok` if the HTTP Post succeed
Returns `{:error, reason}` if the HTTP Post fail
@@ -37,7 +37,7 @@ defmodule ApplicationRunner.ApplicationServices do
:ok | {:error, any()}
def run_listener(
function_name,
- action,
+ listener,
props,
event,
token
@@ -48,7 +48,7 @@ defmodule ApplicationRunner.ApplicationServices do
body =
Jason.encode!(%{
- action: action,
+ listener: listener,
props: props,
event: event,
api: %{url: Application.fetch_env!(:application_runner, :url), token: token}
@@ -61,7 +61,7 @@ defmodule ApplicationRunner.ApplicationServices do
Logger.debug("Call to Openfaas : #{function_name}")
- Logger.debug("Run app #{function_name} with action #{action}")
+ Logger.debug("Run app #{function_name} with listener #{listener}")
peeked_token = AppGuardian.peek(token)
start_time = Telemetry.start(:app_listener, peeked_token.claims)
@@ -135,7 +135,7 @@ defmodule ApplicationRunner.ApplicationServices do
)
|> response(:manifest)
|> case do
- {:ok, %{"manifest" => manifest}} ->
+ {:ok, manifest} ->
Logger.debug("Got manifest : #{inspect(manifest)}")
{:ok, manifest}
@@ -333,7 +333,7 @@ defmodule ApplicationRunner.ApplicationServices do
{:ok, Jason.decode!(body)}
end
- defp response({:error, %Mint.TransportError{reason: reason}}, _action) do
+ defp response({:error, %Mint.TransportError{reason: reason}}, _listener) do
Telemetry.event(
:alert,
%{},
@@ -345,7 +345,7 @@ defmodule ApplicationRunner.ApplicationServices do
defp response(
{:ok, %Finch.Response{status: status_code, body: body}},
- _action
+ _listener
)
when status_code not in [200, 202] do
case status_code do
diff --git a/libs/application_runner/lib/session/listeners_cache.ex b/libs/application_runner/lib/session/listeners_cache.ex
index 810f98b6..e08edafc 100644
--- a/libs/application_runner/lib/session/listeners_cache.ex
+++ b/libs/application_runner/lib/session/listeners_cache.ex
@@ -1,8 +1,8 @@
defmodule ApplicationRunner.Session.ListenersCache do
@moduledoc """
This module creates a Cache for all the listeners.
- It save the listener props/action using a hash the value (sha256) as key.
- Then we can retrieve the listener (action/props) by giving the key.
+ It save the listener props/name using a hash the value (sha256) as key.
+ Then we can retrieve the listener (name/props) by giving the key.
"""
use Agent
use SwarmNamed
@@ -15,8 +15,8 @@ defmodule ApplicationRunner.Session.ListenersCache do
end
@spec create_code(String.t(), map()) :: String.t()
- def create_code(action, props) do
- Crypto.hash({action, props})
+ def create_code(name, props) do
+ Crypto.hash({name, props})
end
@spec save_listener(any(), String.t(), map()) :: :ok
diff --git a/libs/application_runner/lib/session/metadata.ex b/libs/application_runner/lib/session/metadata.ex
index b6b0252b..1af6ade2 100644
--- a/libs/application_runner/lib/session/metadata.ex
+++ b/libs/application_runner/lib/session/metadata.ex
@@ -1,6 +1,6 @@
defmodule ApplicationRunner.Session.Metadata do
@moduledoc """
- The Action struct.
+ The Metadata struct.
"""
@enforce_keys [:session_id, :env_id, :user_id, :function_name, :context]
defstruct [
diff --git a/libs/application_runner/lib/session/route_server.ex b/libs/application_runner/lib/session/route_server.ex
index edc76d2d..e6ba4a18 100644
--- a/libs/application_runner/lib/session/route_server.ex
+++ b/libs/application_runner/lib/session/route_server.ex
@@ -268,17 +268,17 @@ defmodule ApplicationRunner.Session.RouteServer do
{:ok, map()} | {:error, Errors.BusinessError.t()}
def build_listener(session_metadata, listener) do
case listener do
- %{"action" => action} ->
+ %{"name" => name} ->
props = Map.get(listener, "props", %{})
- code = Session.ListenersCache.create_code(action, props)
+ code = Session.ListenersCache.create_code(name, props)
Session.ListenersCache.save_listener(session_metadata.session_id, code, listener)
- {:ok, listener |> Map.drop(["action", "props", "type"]) |> Map.put("code", code)}
+ {:ok, listener |> Map.drop(["name", "props", "type"]) |> Map.put("code", code)}
%{"navTo" => nav_to} ->
{:ok, %{"navTo" => nav_to}}
_ ->
- BusinessError.no_action_in_listener_tuple(listener)
+ BusinessError.no_name_in_listener_tuple(listener)
end
end
diff --git a/libs/application_runner/lib/session/session_state.ex b/libs/application_runner/lib/session/session_state.ex
index 301fd984..11cf9338 100644
--- a/libs/application_runner/lib/session/session_state.ex
+++ b/libs/application_runner/lib/session/session_state.ex
@@ -1,6 +1,6 @@
defmodule ApplicationRunner.Session.State do
@moduledoc """
- The Action struct.
+ The State struct.
"""
@enforce_keys [:session_id, :env_id, :user_id, :function_name]
defstruct [
diff --git a/libs/application_runner/lib/session/ui_builders/json_builder.ex b/libs/application_runner/lib/session/ui_builders/json_builder.ex
index ff1d8587..dd237532 100644
--- a/libs/application_runner/lib/session/ui_builders/json_builder.ex
+++ b/libs/application_runner/lib/session/ui_builders/json_builder.ex
@@ -36,7 +36,7 @@ defmodule ApplicationRunner.Session.UiBuilders.JsonBuilder do
Enum.map(list, &do_build_listeners(session_metadata, &1))
end
- defp do_build_listeners(session_metadata, %{"type" => "listener"} = listener) do
+ defp do_build_listeners(session_metadata, %{"_type" => "listener"} = listener) do
case RouteServer.build_listener(session_metadata, listener) do
{:ok, built_listener} ->
built_listener
diff --git a/libs/application_runner/lib/session/ui_builders/lenra_builder.ex b/libs/application_runner/lib/session/ui_builders/lenra_builder.ex
index 085ff273..827b79b3 100644
--- a/libs/application_runner/lib/session/ui_builders/lenra_builder.ex
+++ b/libs/application_runner/lib/session/ui_builders/lenra_builder.ex
@@ -76,7 +76,7 @@ defmodule ApplicationRunner.Session.UiBuilders.LenraBuilder do
{:ok, component(), Ui.Context.t()} | {:error, UiBuilderAdapter.common_error()}
defp build_component(
session_metadata,
- %{"type" => comp_type} = component,
+ %{"_type" => comp_type} = component,
ui_context,
view_uid
) do
@@ -262,7 +262,7 @@ defmodule ApplicationRunner.Session.UiBuilders.LenraBuilder do
{:cont, {child_map, ui_context_acc}}
child_comp ->
- com_type = Map.get(component, "type")
+ com_type = Map.get(component, "_type")
child_path = "#{prefix_path}/#{com_type}##{child_key}"
build_comp_and_format(
@@ -335,7 +335,7 @@ defmodule ApplicationRunner.Session.UiBuilders.LenraBuilder do
{%{}, ui_context},
fn children_key, {children_map, app_context_acc} = acc ->
if Map.has_key?(component, children_key) do
- comp_type = Map.get(component, "type")
+ comp_type = Map.get(component, "_type")
children_path = "#{prefix_path}/#{comp_type}##{children_key}"
case build_children(
diff --git a/libs/application_runner/lib/storage.ex b/libs/application_runner/lib/storage.ex
index 1858cc0d..8c39cc5d 100644
--- a/libs/application_runner/lib/storage.ex
+++ b/libs/application_runner/lib/storage.ex
@@ -27,7 +27,7 @@ defmodule ApplicationRunner.Storage do
Repo.insert(changeset,
on_conflict:
{:replace,
- [:schedule, :listener_name, :props, :should_run_missed_steps, :overlap, :state]},
+ [:schedule, :listener, :props, :should_run_missed_steps, :overlap, :state]},
conflict_target: [:id]
) do
:ok
diff --git a/libs/application_runner/lib/webhooks/webhook_services.ex b/libs/application_runner/lib/webhooks/webhook_services.ex
index 7d2534da..6c45f9af 100644
--- a/libs/application_runner/lib/webhooks/webhook_services.ex
+++ b/libs/application_runner/lib/webhooks/webhook_services.ex
@@ -50,7 +50,7 @@ defmodule ApplicationRunner.Webhooks.WebhookServices do
webhook ->
EventHandler.send_env_event(
webhook.environment_id,
- webhook.action,
+ webhook.listener,
webhook.props,
payload
)
diff --git a/libs/application_runner/lib/webhooks/webhooks.ex b/libs/application_runner/lib/webhooks/webhooks.ex
index af979786..c7d29767 100644
--- a/libs/application_runner/lib/webhooks/webhooks.ex
+++ b/libs/application_runner/lib/webhooks/webhooks.ex
@@ -9,13 +9,13 @@ defmodule ApplicationRunner.Webhooks.Webhook do
alias ApplicationRunner.Contract.{Environment, User}
alias ApplicationRunner.Webhooks.Webhook
- @derive {Jason.Encoder, only: [:uuid, :action, :props, :environment_id, :user_id]}
+ @derive {Jason.Encoder, only: [:uuid, :listener, :props, :environment_id, :user_id]}
@primary_key {:uuid, Ecto.UUID, autogenerate: true}
schema "webhooks" do
belongs_to(:environment, Environment)
belongs_to(:user, User)
- field(:action, :string)
+ field(:listener, :string)
field(:props, :map)
timestamps()
@@ -23,8 +23,8 @@ defmodule ApplicationRunner.Webhooks.Webhook do
def changeset(webhook, params \\ %{}) do
webhook
- |> cast(params, [:action, :props, :user_id])
- |> validate_required([:environment_id, :action])
+ |> cast(params, [:listener, :props, :user_id])
+ |> validate_required([:environment_id, :listener])
|> foreign_key_constraint(:environment_id)
|> foreign_key_constraint(:user_id)
end
@@ -41,14 +41,14 @@ defmodule ApplicationRunner.Webhooks.Webhook do
%__MODULE__{}
|> cast(webhook_map, [
:uuid,
- :action,
+ :listener,
:props,
:user_id,
:environment_id,
:inserted_at,
:updated_at
])
- |> validate_required([:environment_id, :action])
+ |> validate_required([:environment_id, :listener])
|> foreign_key_constraint(:environment_id)
|> foreign_key_constraint(:user_id)
diff --git a/libs/application_runner/mix.exs b/libs/application_runner/mix.exs
index e03daee6..fef87167 100644
--- a/libs/application_runner/mix.exs
+++ b/libs/application_runner/mix.exs
@@ -35,7 +35,7 @@ defmodule ApplicationRunner.MixProject do
{:credo, "~> 1.6.7", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.2", only: [:dev, :test], runtime: false},
{:ex_component_schema,
- git: "https://github.com/lenra-io/ex_component_schema", ref: "v1.0.0-beta.5"},
+ git: "https://github.com/lenra-io/ex_component_schema", ref: "v1.0.0-beta.6"},
{:jason, "~> 1.4"},
{:json_diff, "~> 0.1.3"},
{:telemetry, "~> 1.2.0"},
diff --git a/libs/application_runner/mix.lock b/libs/application_runner/mix.lock
index 009123fe..ef5773ec 100644
--- a/libs/application_runner/mix.lock
+++ b/libs/application_runner/mix.lock
@@ -14,7 +14,7 @@
"ecto": {:hex, :ecto, "3.9.6", "2f420c173efcb2e22fa4f8fc41e75e02b3c5bd4cffef12085cae5418c12e530d", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "df17bc06ba6f78a7b764e4a14ef877fe5f4499332c5a105ace11fe7013b72c84"},
"ecto_sql": {:hex, :ecto_sql, "3.9.2", "34227501abe92dba10d9c3495ab6770e75e79b836d114c41108a4bf2ce200ad5", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9.2", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.6.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.16.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1eb5eeb4358fdbcd42eac11c1fbd87e3affd7904e639d77903c1358b2abd3f70"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
- "ex_component_schema": {:git, "https://github.com/lenra-io/ex_component_schema", "3b8d70d1f2ede5973c7875e6681fb9993f861826", [ref: "v1.0.0-beta.5"]},
+ "ex_component_schema": {:git, "https://github.com/lenra-io/ex_component_schema", "374b17c0aea3e88cce4f0c9bcf3f17184bd9da30", [ref: "v1.0.0-beta.6"]},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"finch": {:hex, :finch, "0.16.0", "40733f02c89f94a112518071c0a91fe86069560f5dbdb39f9150042f44dcfb1a", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f660174c4d519e5fec629016054d60edd822cdfe2b7270836739ac2f97735ec5"},
"gen_stage": {:hex, :gen_stage, "1.2.1", "19d8b5e9a5996d813b8245338a28246307fd8b9c99d1237de199d21efc4c76a1", [:mix], [], "hexpm", "83e8be657fa05b992ffa6ac1e3af6d57aa50aace8f691fcf696ff02f8335b001"},
diff --git a/libs/application_runner/priv/components-api b/libs/application_runner/priv/components-api
index 9e8519fe..c6584e75 160000
--- a/libs/application_runner/priv/components-api
+++ b/libs/application_runner/priv/components-api
@@ -1 +1 @@
-Subproject commit 9e8519fe0fff995e86d4957e849a9e05702dc09a
+Subproject commit c6584e757ecf0b7cbf4cccc5475768c4e4ab78c3
diff --git a/libs/application_runner/priv/repo/migrations/20230915081255_action_to_listener.exs b/libs/application_runner/priv/repo/migrations/20230915081255_action_to_listener.exs
new file mode 100644
index 00000000..bd00ed22
--- /dev/null
+++ b/libs/application_runner/priv/repo/migrations/20230915081255_action_to_listener.exs
@@ -0,0 +1,8 @@
+defmodule ApplicationRunner.Repo.Migrations.ActionToListener do
+ use Ecto.Migration
+
+ def change do
+ rename(table("webhooks"), :action, to: :listener)
+ rename(table("crons"), :listener_name, to: :listener)
+ end
+end
diff --git a/libs/application_runner/test/controllers/resource_controller_test.exs b/libs/application_runner/test/controllers/resource_controller_test.exs
index 3d104fbf..7777dd00 100644
--- a/libs/application_runner/test/controllers/resource_controller_test.exs
+++ b/libs/application_runner/test/controllers/resource_controller_test.exs
@@ -22,7 +22,7 @@ defmodule LenraWeb.ResourcesControllerTest do
)
{:error, _} ->
- Plug.Conn.resp(conn, 200, Jason.encode!(%{manifest: @manifest}))
+ Plug.Conn.resp(conn, 200, Jason.encode!(@manifest))
end
end
diff --git a/libs/application_runner/test/crons/cron_test.exs b/libs/application_runner/test/crons/cron_test.exs
index ebc7ab69..11c76418 100644
--- a/libs/application_runner/test/crons/cron_test.exs
+++ b/libs/application_runner/test/crons/cron_test.exs
@@ -14,7 +14,7 @@ defmodule ApplicationRunner.Crons.CronTest do
Cron.new(env.id, "test", %{
"schedule" => "* * * * *",
- "listener_name" => "listener",
+ "listener" => "listener",
"props" => %{
"prop1" => "1",
"prop2" => "2"
@@ -25,7 +25,7 @@ defmodule ApplicationRunner.Crons.CronTest do
cron = Enum.at(Repo.all(Cron), 0)
assert cron.schedule == "* * * * *"
- assert cron.listener_name == "listener"
+ assert cron.listener == "listener"
assert cron.props == %{
"prop1" => "1",
@@ -42,7 +42,7 @@ defmodule ApplicationRunner.Crons.CronTest do
Cron.new(env.id, "test", %{
"schedule" => "* * * * *",
- "listener_name" => "listener",
+ "listener" => "listener",
"should_run_missed_steps" => true
})
|> Repo.insert!()
@@ -50,7 +50,7 @@ defmodule ApplicationRunner.Crons.CronTest do
cron = Enum.at(Repo.all(Cron), 0)
assert cron.schedule == "* * * * *"
- assert cron.listener_name == "listener"
+ assert cron.listener == "listener"
assert cron.should_run_missed_steps == true
end
@@ -63,7 +63,7 @@ defmodule ApplicationRunner.Crons.CronTest do
cron =
Cron.new(env.id, "test", %{
"schedule" => "This is not a valid schedule",
- "listener_name" => "listener",
+ "listener" => "listener",
"props" => %{
"prop1" => "1",
"prop2" => "2"
@@ -77,7 +77,7 @@ defmodule ApplicationRunner.Crons.CronTest do
cron =
Cron.new(1, "test", %{
"schedule" => "* * * * *",
- "listener_name" => "listener",
+ "listener" => "listener",
"props" => %{
"prop1" => "1",
"prop2" => "2"
@@ -97,7 +97,7 @@ defmodule ApplicationRunner.Crons.CronTest do
})
assert cron.valid? == false
- assert [{:listener_name, _err}, {:schedule, _error}] = cron.errors
+ assert [{:listener, _err}, {:schedule, _error}] = cron.errors
end
test "Insert Cron with no props into database successfully" do
@@ -107,14 +107,14 @@ defmodule ApplicationRunner.Crons.CronTest do
Cron.new(env.id, "test", %{
"schedule" => "* * * * *",
- "listener_name" => "listener"
+ "listener" => "listener"
})
|> Repo.insert!()
cron = Enum.at(Repo.all(Cron), 0)
assert cron.schedule == "* * * * *"
- assert cron.listener_name == "listener"
+ assert cron.listener == "listener"
end
test "Insert Cron with user into database successfully" do
@@ -128,7 +128,7 @@ defmodule ApplicationRunner.Crons.CronTest do
Cron.new(env.id, "test", %{
"schedule" => "* * * * *",
- "listener_name" => "listener",
+ "listener" => "listener",
"user_id" => user.id
})
|> Repo.insert!()
diff --git a/libs/application_runner/test/environment/dynamic_supervisor_test.exs b/libs/application_runner/test/environment/dynamic_supervisor_test.exs
index 4f28ad9d..b372a65b 100644
--- a/libs/application_runner/test/environment/dynamic_supervisor_test.exs
+++ b/libs/application_runner/test/environment/dynamic_supervisor_test.exs
@@ -19,7 +19,7 @@ defmodule ApplicationRunner.Environment.DynamixSupervisorTest do
)
{:error, _} ->
- Plug.Conn.resp(conn, 200, Jason.encode!(%{manifest: @manifest}))
+ Plug.Conn.resp(conn, 200, Jason.encode!(@manifest))
end
end
diff --git a/libs/application_runner/test/environment/view_dyn_sup_test.exs b/libs/application_runner/test/environment/view_dyn_sup_test.exs
index 036a81b7..9eb330df 100644
--- a/libs/application_runner/test/environment/view_dyn_sup_test.exs
+++ b/libs/application_runner/test/environment/view_dyn_sup_test.exs
@@ -11,8 +11,20 @@ defmodule ApplicationRunner.Environment.ViewDynSupTest do
alias ApplicationRunner.Guardian.AppGuardian
alias QueryParser.Parser
- @manifest %{"rootview" => "main"}
- @view %{"type" => "text", "value" => "test"}
+ @manifest %{
+ "lenra" => %{
+ "routes" => [
+ %{
+ "path" => "/",
+ "view" => %{
+ "_type" => "view",
+ "name" => "main"
+ }
+ }
+ ]
+ }
+ }
+ @view %{"_type" => "text", "value" => "test"}
@function_name Ecto.UUID.generate()
@session_id 1337
@@ -49,7 +61,7 @@ defmodule ApplicationRunner.Environment.ViewDynSupTest do
)
{:error, _} ->
- Plug.Conn.resp(conn, 200, Jason.encode!(%{manifest: @manifest}))
+ Plug.Conn.resp(conn, 200, Jason.encode!(@manifest))
end
end
diff --git a/libs/application_runner/test/integration_test.exs b/libs/application_runner/test/integration_test.exs
index 246870f4..31ce43a8 100644
--- a/libs/application_runner/test/integration_test.exs
+++ b/libs/application_runner/test/integration_test.exs
@@ -22,17 +22,19 @@ defmodule ApplicationRunner.IntegrationTest do
@query %{"foo" => "bar"}
@manifest %{
- "lenraRoutes" => [
- %{"path" => "/", "view" => %{"type" => "view", "name" => "main"}}
- ]
+ "lenra" => %{
+ "routes" => [
+ %{"path" => "/", "view" => %{"_type" => "view", "name" => "main"}}
+ ]
+ }
}
def view("main", _) do
- %{"type" => "view", "name" => "echo", "query" => @query, "coll" => @coll}
+ %{"_type" => "view", "name" => "echo", "find" => %{"query" => @query, "coll" => @coll}}
end
def view("echo", data) do
- %{"type" => "text", "value" => Jason.encode!(data)}
+ %{"_type" => "text", "value" => Jason.encode!(data)}
end
def get_name(module, identifier) do
@@ -130,8 +132,8 @@ defmodule ApplicationRunner.IntegrationTest do
Environment.TokenAgent.add_token(sm.env_id, uuid, token)
case Jason.decode(body) do
- {:ok, %{"action" => action, "props" => props}} ->
- resp_listener(logger_agent, conn, action, props, token)
+ {:ok, %{"listener" => name, "props" => props}} ->
+ resp_listener(logger_agent, conn, name, props, token)
{:ok, %{"view" => name, "data" => data}} ->
resp_view(logger_agent, conn, name, data)
@@ -157,7 +159,7 @@ defmodule ApplicationRunner.IntegrationTest do
def resp_manifest(logger_agent, conn) do
add_log_to_agent(logger_agent, {:manifest, @manifest})
- Plug.Conn.resp(conn, 200, Jason.encode!(%{manifest: @manifest}))
+ Plug.Conn.resp(conn, 200, Jason.encode!(@manifest))
end
def resp_view(logger_agent, conn, name, data) do
@@ -170,10 +172,10 @@ defmodule ApplicationRunner.IntegrationTest do
)
end
- def resp_listener(logger_agent, conn, action, props, token) do
- add_log_to_agent(logger_agent, {:listener, action, props})
+ def resp_listener(logger_agent, conn, name, props, token) do
+ add_log_to_agent(logger_agent, {:listener, name, props})
- case action do
+ case name do
"insert" ->
conn = Phoenix.ConnTest.build_conn()
@@ -250,7 +252,7 @@ defmodule ApplicationRunner.IntegrationTest do
assert MongoStorage.has_user_link?(em.env_id, sm.user_id)
# The first message should be a send ui message..
- assert_receive {:send, :ui, %{"root" => %{"type" => "text", "value" => "[]"}}}
+ assert_receive {:send, :ui, %{"root" => %{"_type" => "text", "value" => "[]"}}}
# Add one data by simulating an "insert" event.
ApplicationRunner.EventHandler.send_session_event(
@@ -339,9 +341,11 @@ defmodule ApplicationRunner.IntegrationTest do
# The manifest is fetched
{:manifest,
%{
- "lenraRoutes" => [
- %{"path" => "/", "view" => %{"type" => "view", "name" => "main"}}
- ]
+ "lenra" => %{
+ "routes" => [
+ %{"path" => "/", "view" => %{"_type" => "view", "name" => "main"}}
+ ]
+ }
}},
# The onEnvStart event is run.
{:listener, "onEnvStart", %{}},
diff --git a/libs/application_runner/test/json/components/button_validator_test.exs b/libs/application_runner/test/json/components/button_validator_test.exs
index e4d6b017..7b874287 100644
--- a/libs/application_runner/test/json/components/button_validator_test.exs
+++ b/libs/application_runner/test/json/components/button_validator_test.exs
@@ -16,7 +16,8 @@
# "type" => "button",
# "text" => "",
# "onPressed" => %{
-# "action" => "anyaction",
+# "_type" => "listener",
+# "name" => "anyaction",
# "props" => %{
# "number" => 10,
# "text" => "value"
@@ -65,12 +66,13 @@
# assert_error({:error, :invalid_ui, [{"Required property text was not present.", ""}]})
# end
-# test "invalid button with invalid action and props in listener", %{env_id: env_id} do
+# test "invalid button with invalid name and props in listener", %{env_id: env_id} do
# json = %{
# "type" => "button",
# "text" => "test",
# "onPressed" => %{
-# "action" => 10,
+# "_type" => "listener",
+# "name" => 10,
# "props" => ""
# }
# }
@@ -81,7 +83,7 @@
# assert_error(
# {:error, :invalid_ui,
# [
-# {"Type mismatch. Expected String but got Integer.", "/onPressed/action"},
+# {"Type mismatch. Expected String but got Integer.", "/onPressed/name"},
# {"Type mismatch. Expected Object but got String.", "/onPressed/props"}
# ]}
# )
@@ -92,7 +94,8 @@
# "type" => "button",
# "text" => "test",
# "onChange" => %{
-# "action" => 42,
+# "_type" => "listener",
+# "name" => 42,
# "props" => "machin"
# }
# }
diff --git a/libs/application_runner/test/json/components/textfield_validator_test.exs b/libs/application_runner/test/json/components/textfield_validator_test.exs
index 9cf113c4..a374a295 100644
--- a/libs/application_runner/test/json/components/textfield_validator_test.exs
+++ b/libs/application_runner/test/json/components/textfield_validator_test.exs
@@ -10,7 +10,8 @@
# "type" => "textfield",
# "value" => "",
# "onChanged" => %{
-# "action" => "anyaction",
+# "_type" => "listener",
+# "name" => "anyaction",
# "props" => %{
# "number" => 10,
# "value" => "value"
@@ -59,14 +60,15 @@
# assert_error({:error, :invalid_ui, [{"Required property value was not present.", ""}]})
# end
-# test "invalid textfield with invalid action and props in listener", %{
+# test "invalid textfield with invalid name and props in listener", %{
# env_id: env_id
# } do
# json = %{
# "type" => "textfield",
# "value" => "test",
# "onChanged" => %{
-# "action" => 10,
+# "_type" => "listener",
+# "name" => 10,
# "props" => ""
# }
# }
@@ -76,7 +78,7 @@
# assert_error(
# {:error, :invalid_ui,
# [
-# {"Type mismatch. Expected String but got Integer.", "/onChanged/action"},
+# {"Type mismatch. Expected String but got Integer.", "/onChanged/name"},
# {"Type mismatch. Expected Object but got String.", "/onChanged/props"}
# ]}
# )
@@ -87,7 +89,8 @@
# "type" => "textfield",
# "value" => "test",
# "onClick" => %{
-# "action" => 42,
+# "_type" => "listener",
+# "name" => 42,
# "props" => "machin"
# }
# }
diff --git a/libs/application_runner/test/perf.exs b/libs/application_runner/test/perf.exs
index 377c5e84..e705e56e 100644
--- a/libs/application_runner/test/perf.exs
+++ b/libs/application_runner/test/perf.exs
@@ -11,7 +11,7 @@ defmodule ApplicationRunner.MongoStorageTest do
test "should validate container under 20 ms" do
container = %{
- "type" => "container",
+ "_type" => "container",
"padding" => %{
"top" => 8,
"left" => 8,
@@ -26,7 +26,7 @@ defmodule ApplicationRunner.MongoStorageTest do
"maxHeight" => 100
},
"child" => %{
- "type" => "text",
+ "_type" => "text",
"value" => "Text inside a container with padding"
}
}
@@ -40,7 +40,7 @@ defmodule ApplicationRunner.MongoStorageTest do
test "should return error if mongo not started" do
container = %{
- "type" => "container",
+ "_type" => "container",
"padding" => %{
"top" => 8,
"left" => 8,
@@ -55,29 +55,29 @@ defmodule ApplicationRunner.MongoStorageTest do
"maxHeight" => 100
},
"child" => %{
- "type" => "container",
+ "_type" => "container",
"child" => %{
- "type" => "flex",
+ "_type" => "flex",
"children" => [
%{
- "type" => "flex",
+ "_type" => "flex",
"children" => [
- %{"type" => "text", "value" => "First child"},
- %{"type" => "text", "value" => "Second child"}
+ %{"_type" => "text", "value" => "First child"},
+ %{"_type" => "text", "value" => "Second child"}
]
},
%{
- "type" => "flex",
+ "_type" => "flex",
"children" => [
- %{"type" => "text", "value" => "First child"},
- %{"type" => "text", "value" => "Second child"}
+ %{"_type" => "text", "value" => "First child"},
+ %{"_type" => "text", "value" => "Second child"}
]
},
%{
- "type" => "flex",
+ "_type" => "flex",
"children" => [
- %{"type" => "text", "value" => "First child"},
- %{"type" => "text", "value" => "Second child"}
+ %{"_type" => "text", "value" => "First child"},
+ %{"_type" => "text", "value" => "Second child"}
]
}
]
diff --git a/libs/application_runner/test/session/listener_cache_test.exs b/libs/application_runner/test/session/listener_cache_test.exs
index cbf913c3..a3069399 100644
--- a/libs/application_runner/test/session/listener_cache_test.exs
+++ b/libs/application_runner/test/session/listener_cache_test.exs
@@ -63,9 +63,9 @@
# # Wait for OnSessionStart
# assert :ok = EventHandler.subscribe(handler_pid)
-# assert_receive({:event_finished, _action, _res})
+# assert_receive({:event_finished, _listener, _res})
-# assert_receive({:event_finished, _action, _res})
+# assert_receive({:event_finished, _listener, _res})
# assert_receive({:send, :ui, @ui})
@@ -87,8 +87,8 @@
# "" ->
# Plug.Conn.resp(conn, 200, Jason.encode!(%{"manifest" => @manifest}))
-# # Listeners "action" in body
-# %{"action" => _action} ->
+# # Listeners "listener" in body
+# %{"listener" => _listener} ->
# Plug.Conn.resp(conn, 200, "")
# # Widget data key
@@ -102,15 +102,15 @@
# end
# test "test save_listener and fetch_listener", %{session_state: session_state} do
-# action = "go"
+# listener = "go"
# props = %{"value" => "ok"}
# listener = %{
-# "action" => action,
+# "listener" => listener,
# "props" => props
# }
-# code = Crypto.hash({action, props})
+# code = Crypto.hash({listener, props})
# assert {:error, BusinessError.unknow_listener_code(code)} ==
# ListenersCache.fetch_listener(session_state, code)
diff --git a/libs/application_runner/test/session/session_manager_test.exs b/libs/application_runner/test/session/session_manager_test.exs
index c2cef1ce..3900fecb 100644
--- a/libs/application_runner/test/session/session_manager_test.exs
+++ b/libs/application_runner/test/session/session_manager_test.exs
@@ -52,8 +52,8 @@
# "" ->
# Plug.Conn.resp(conn, 200, Jason.encode!(%{"manifest" => @manifest}))
-# # Listeners "action" in body
-# %{"action" => _action} ->
+# # Listeners "listener" in body
+# %{"listener" => _listener} ->
# Plug.Conn.resp(conn, 200, "")
# # Widget data key
@@ -100,9 +100,9 @@
# # Wait for OnSessionStart
# assert :ok = EventHandler.subscribe(handler_pid)
-# assert_receive({:event_finished, _action, _res})
+# assert_receive({:event_finished, _listener, _res})
-# assert_receive({:event_finished, _action, _res})
+# assert_receive({:event_finished, _listener, _res})
# assert_receive({:send, :ui, @ui})
# end
@@ -146,7 +146,7 @@
# # Wait for OnSessionStart
# assert :ok = EventHandler.subscribe(handler_pid)
-# assert_receive({:event_finished, _action, _res})
+# assert_receive({:event_finished, _listener, _res})
# # Wait for Widget
# assert :ok = EventHandler.subscribe(handler_pid)
diff --git a/libs/application_runner/test/session/session_managers_test.exs b/libs/application_runner/test/session/session_managers_test.exs
index 4ea1cdcd..c4ed1b74 100644
--- a/libs/application_runner/test/session/session_managers_test.exs
+++ b/libs/application_runner/test/session/session_managers_test.exs
@@ -58,8 +58,8 @@
# "" ->
# Plug.Conn.resp(conn, 200, Jason.encode!(%{"manifest" => @manifest}))
-# # Listeners "action" in body
-# %{"action" => _action} ->
+# # Listeners "listener" in body
+# %{"listener" => _action} ->
# Plug.Conn.resp(conn, 200, "")
# # Widget data key
diff --git a/libs/application_runner/test/storage_test.exs b/libs/application_runner/test/storage_test.exs
index 86e9bb4c..b70a38e6 100644
--- a/libs/application_runner/test/storage_test.exs
+++ b/libs/application_runner/test/storage_test.exs
@@ -42,12 +42,12 @@ defmodule ApplicationRunner.StorageTest do
cron = Enum.at(Repo.all(Cron), 0)
- assert cron.listener_name == "listener"
+ assert cron.listener == "listener"
assert cron.schedule == "* * * * * *"
assert cron.environment_id == env_id
end
- test "without listener_name and schedule should not work" do
+ test "without listener and schedule should not work" do
assert {:error, %{reason: :invalid_params}} = Storage.add_job(1, Scheduler.new_job())
end
@@ -68,17 +68,17 @@ defmodule ApplicationRunner.StorageTest do
assert :ok = Storage.add_job(1, job)
assert [cron] = Crons.all()
- assert cron.listener_name == "listener"
+ assert cron.listener == "listener"
updated_cron =
- Cron.update(cron, %{"listener_name" => "changed"})
+ Cron.update(cron, %{"listener" => "changed"})
|> Ecto.Changeset.apply_changes()
|> Crons.to_job()
assert :ok = Storage.update_job(1, updated_cron)
assert [updated_cron] = Crons.all()
- assert updated_cron.listener_name == "changed"
+ assert updated_cron.listener == "changed"
end
test "not existing job", %{
@@ -91,7 +91,7 @@ defmodule ApplicationRunner.StorageTest do
job
|> Crons.to_changeset()
|> Ecto.Changeset.apply_changes()
- |> Cron.update(%{"listener_name" => "changed"})
+ |> Cron.update(%{"listener" => "changed"})
|> Ecto.Changeset.apply_changes()
|> Crons.to_job()
diff --git a/libs/application_runner/test/support/application_runner_adapter.ex b/libs/application_runner/test/support/application_runner_adapter.ex
index adbd01db..871c7663 100644
--- a/libs/application_runner/test/support/application_runner_adapter.ex
+++ b/libs/application_runner/test/support/application_runner_adapter.ex
@@ -38,11 +38,11 @@ defmodule ApplicationRunner.ApplicationRunnerAdapter do
end
def handle_call(
- {:run_listener, action, props, event, apiOptions},
+ {:run_listener, name, props, event, apiOptions},
_from,
%{listeners: listeners} = mock
) do
- case Map.get(listeners, action) do
+ case Map.get(listeners, name) do
nil ->
{:reply, {:error, :listener_not_found}, mock}
@@ -53,7 +53,7 @@ defmodule ApplicationRunner.ApplicationRunnerAdapter do
end
def handle_call(
- {:run_listener, _action, _props, _event},
+ {:run_listener, _listener, _props, _event},
_from,
mock
) do
diff --git a/libs/application_runner/test/support/component_case.ex b/libs/application_runner/test/support/component_case.ex
index 24809296..fb8c4051 100644
--- a/libs/application_runner/test/support/component_case.ex
+++ b/libs/application_runner/test/support/component_case.ex
@@ -22,7 +22,19 @@ defmodule ApplicationRunner.ComponentCase do
alias ApplicationRunner.Environments.{Manager, Managers}
- @manifest %{"rootView" => "root"}
+ @manifest %{
+ "lenra" => %{
+ "routes" => [
+ %{
+ "path" => "/",
+ "view" => %{
+ "_type" => "view",
+ "name" => "root"
+ }
+ }
+ ]
+ }
+ }
setup context do
start_supervised(EnvManagers)
@@ -88,10 +100,10 @@ defmodule ApplicationRunner.ComponentCase do
case body_decoded do
# Manifest no body
"" ->
- Plug.Conn.resp(conn, 200, Jason.encode!(%{"manifest" => @manifest}))
+ Plug.Conn.resp(conn, 200, Jason.encode!(@manifest))
- # Listeners "action" in body
- %{"action" => _action} ->
+ # Listeners "listener" in body
+ %{"listener" => _listener} ->
Plug.Conn.resp(conn, 200, "")
# view data key
diff --git a/libs/application_runner/test/support/cron_helper.ex b/libs/application_runner/test/support/cron_helper.ex
index 6265d3c5..ac8cb7d2 100644
--- a/libs/application_runner/test/support/cron_helper.ex
+++ b/libs/application_runner/test/support/cron_helper.ex
@@ -9,7 +9,7 @@ defmodule ApplicationRunner.CronHelper do
def basic_job(env_id, function_name) do
env_id
|> Cron.new(function_name, %{
- "listener_name" => "listener",
+ "listener" => "listener",
"schedule" => "* * * * * *"
})
|> Ecto.Changeset.apply_changes()
diff --git a/libs/application_runner/test/ui_validator_test.exs b/libs/application_runner/test/ui_validator_test.exs
index 45ca67af..6284e6df 100644
--- a/libs/application_runner/test/ui_validator_test.exs
+++ b/libs/application_runner/test/ui_validator_test.exs
@@ -9,10 +9,11 @@
# "$defs" => %{
# "listener" => %{
# "properties" => %{
-# "action" => %{"type" => "string"},
+# "_type" => %{"enum" => ["listener"]},
+# "name" => %{"type" => "string"},
# "props" => %{"type" => "object"}
# },
-# "required" => ["action"],
+# "required" => ["_type", "name"],
# "type" => "listener"
# }
# },
@@ -66,6 +67,7 @@
# "type" => "textfield",
# "value" => "",
# "onChanged" => %{
+# "_type" => "listener",
# "name" => "Category.setName"
# }
# },
@@ -73,6 +75,7 @@
# "type" => "button",
# "text" => "Save",
# "onPressed" => %{
+# "_type" => "listener",
# "name" => "Category.save"
# }
# }
@@ -85,6 +88,7 @@
# "type" => "button",
# "text" => "+",
# "onPressed" => %{
+# "_type" => "listener",
# "name" => "Category.addField"
# }
# }
@@ -100,11 +104,11 @@
# :invalid_ui,
# [
# {"Schema does not allow additional properties.", "/children/0/children/0/onChanged/name"},
-# {"Required property action was not present.", "/children/0/children/0/onChanged"},
+# {"Required property name was not present.", "/children/0/children/0/onChanged"},
# {"Schema does not allow additional properties.", "/children/0/children/1/onPressed/name"},
-# {"Required property action was not present.", "/children/0/children/1/onPressed"},
+# {"Required property name was not present.", "/children/0/children/1/onPressed"},
# {"Schema does not allow additional properties.", "/children/1/children/0/onPressed/name"},
-# {"Required property action was not present.", "/children/1/children/0/onPressed"}
+# {"Required property name was not present.", "/children/1/children/0/onPressed"}
# ]
# })
# end
diff --git a/libs/application_runner/test/webhooks/webhook_controller_test.exs b/libs/application_runner/test/webhooks/webhook_controller_test.exs
index 453d9756..2471a7a5 100644
--- a/libs/application_runner/test/webhooks/webhook_controller_test.exs
+++ b/libs/application_runner/test/webhooks/webhook_controller_test.exs
@@ -100,16 +100,16 @@ defmodule ApplicationRunner.Webhooks.ControllerTest do
conn
|> Plug.Conn.put_req_header("authorization", "Bearer " <> token)
|> post(Routes.webhooks_path(conn, :create), %{
- "action" => "test"
+ "listener" => "test"
})
response = json_response(conn, 200)
- assert %{"action" => "test", "props" => nil} = response
+ assert %{"listener" => "test", "props" => nil} = response
assert [webhook] = WebhookServices.get(response["environment_id"])
- assert webhook.action == "test"
+ assert webhook.listener == "test"
end
test "Create webhook in session should work properly",
@@ -122,16 +122,16 @@ defmodule ApplicationRunner.Webhooks.ControllerTest do
conn
|> Plug.Conn.put_req_header("authorization", "Bearer " <> token)
|> post(Routes.webhooks_path(conn, :create), %{
- "action" => "test"
+ "listener" => "test"
})
response = json_response(conn, 200)
- assert %{"action" => "test", "props" => nil} = response
+ assert %{"listener" => "test", "props" => nil} = response
assert [webhook] = WebhookServices.get(response["environment_id"])
- assert webhook.action == "test"
+ assert webhook.listener == "test"
end
defp handle_request(conn, callback) do
@@ -147,8 +147,8 @@ defmodule ApplicationRunner.Webhooks.ControllerTest do
callback.(body_decoded)
case body_decoded do
- # Listeners "action" in body
- %{"action" => _action} ->
+ # Listeners "listener" in body
+ %{"listener" => _listener} ->
Plug.Conn.resp(conn, 200, "")
end
end
diff --git a/libs/application_runner/test/webhooks/webhook_services_test.exs b/libs/application_runner/test/webhooks/webhook_services_test.exs
index 27a4b0b6..b4e07d3e 100644
--- a/libs/application_runner/test/webhooks/webhook_services_test.exs
+++ b/libs/application_runner/test/webhooks/webhook_services_test.exs
@@ -46,8 +46,8 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
callback.(body_decoded)
case body_decoded do
- # Listeners "action" in body
- %{"action" => _action} ->
+ # Listeners "listener" in body
+ %{"listener" => _listener} ->
Plug.Conn.resp(conn, 200, "")
end
end
@@ -58,7 +58,10 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
bypass: bypass
} do
assert {:ok, webhook} =
- Webhook.new(env_id, %{"action" => "listener", "props" => %{"propKey" => "propValue"}})
+ Webhook.new(env_id, %{
+ "listener" => "listener",
+ "props" => %{"propKey" => "propValue"}
+ })
|> Repo.insert()
Bypass.stub(
@@ -67,7 +70,7 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
"/function/test",
&handle_request(&1, fn body ->
assert body["props"] == %{"propKey" => "propValue"}
- assert body["action"] == "listener"
+ assert body["listener"] == "listener"
assert body["event"] == %{"eventPropKey" => "eventPropValue"}
end)
)
@@ -92,7 +95,7 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
assert {:ok, webhook} =
Webhook.new(env_id, %{
"user_id" => user_id,
- "action" => "listener",
+ "listener" => "listener",
"props" => %{"propKey" => "propValue"}
})
|> Repo.insert()
@@ -103,7 +106,7 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
"/function/test",
&handle_request(&1, fn body ->
assert body["props"] == %{"propKey" => "propValue"}
- assert body["action"] == "listener"
+ assert body["listener"] == "listener"
assert body["event"] == %{"eventPropKey" => "eventPropValue"}
end)
)
@@ -116,11 +119,11 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
user_id: _user_id,
bypass: _bypass
} do
- assert {:ok, _webhook} = WebhookServices.create(env_id, %{"action" => "listener"})
+ assert {:ok, _webhook} = WebhookServices.create(env_id, %{"listener" => "listener"})
webhook = Enum.at(Repo.all(Webhook), 0)
- assert webhook.action == "listener"
+ assert webhook.listener == "listener"
assert webhook.environment_id == env_id
end
@@ -130,14 +133,14 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
bypass: _bypass
} do
assert {:ok, webhook} =
- WebhookServices.create(env_id, %{"action" => "listener", "user_id" => user_id})
+ WebhookServices.create(env_id, %{"listener" => "listener", "user_id" => user_id})
webhook_preload = Repo.preload(webhook, :user)
assert webhook_preload.user.id == user_id
end
- test "Webhook create without action should not work", %{
+ test "Webhook create without listener should not work", %{
env_id: env_id,
user_id: _user_id,
bypass: _bypass
@@ -150,17 +153,17 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
user_id: _user_id,
bypass: _bypass
} do
- assert {:error, _reason} = WebhookServices.create(-1, %{"action" => "listener"})
+ assert {:error, _reason} = WebhookServices.create(-1, %{"listener" => "listener"})
end
test "Webhook get should work properly", %{env_id: env_id} do
assert {:ok, _webhook} =
- Webhook.new(env_id, %{"action" => "listener"})
+ Webhook.new(env_id, %{"listener" => "listener"})
|> Repo.insert()
webhooks = WebhookServices.get(env_id)
- assert Enum.at(webhooks, 0).action == "listener"
+ assert Enum.at(webhooks, 0).listener == "listener"
end
test "Webhook get with no webhook in db should return an empty array", %{env_id: env_id} do
@@ -169,17 +172,17 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
test "Webhook get should work properly with multiple webhooks", %{env_id: env_id} do
assert {:ok, _first} =
- Webhook.new(env_id, %{"action" => "first"})
+ Webhook.new(env_id, %{"listener" => "first"})
|> Repo.insert()
assert {:ok, _second} =
- Webhook.new(env_id, %{"action" => "second"})
+ Webhook.new(env_id, %{"listener" => "second"})
|> Repo.insert()
webhooks = WebhookServices.get(env_id)
- assert Enum.at(webhooks, 0).action == "first"
- assert Enum.at(webhooks, 1).action == "second"
+ assert Enum.at(webhooks, 0).listener == "first"
+ assert Enum.at(webhooks, 1).listener == "second"
end
test "Get webhooks linked to specific user should work properly", %{env_id: env_id} do
@@ -189,12 +192,12 @@ defmodule ApplicationRunner.Webhooks.ServicesTest do
|> Repo.insert!()
assert {:ok, _webhook} =
- Webhook.new(env_id, %{"action" => "user_specific_webhook", "user_id" => user.id})
+ Webhook.new(env_id, %{"listener" => "user_specific_webhook", "user_id" => user.id})
|> Repo.insert()
webhooks = WebhookServices.get(env_id, user.id)
- assert Enum.at(webhooks, 0).action == "user_specific_webhook"
+ assert Enum.at(webhooks, 0).listener == "user_specific_webhook"
end
test "Get webhooks linked to specific user but no webhook in db should return empty array", %{
diff --git a/libs/application_runner/test/webhooks/webhook_test.exs b/libs/application_runner/test/webhooks/webhook_test.exs
index 3a442c6a..cd50018a 100644
--- a/libs/application_runner/test/webhooks/webhook_test.exs
+++ b/libs/application_runner/test/webhooks/webhook_test.exs
@@ -13,7 +13,7 @@ defmodule ApplicationRunner.Webhooks.WebhookTest do
|> Repo.insert!()
Webhook.new(env.id, %{
- "action" => "test",
+ "listener" => "test",
"props" => %{
"prop1" => "1",
"prop2" => "2"
@@ -23,7 +23,7 @@ defmodule ApplicationRunner.Webhooks.WebhookTest do
webhook = Enum.at(Repo.all(Webhook), 0)
- assert webhook.action == "test"
+ assert webhook.listener == "test"
assert webhook.props == %{
"prop1" => "1",
@@ -34,7 +34,7 @@ defmodule ApplicationRunner.Webhooks.WebhookTest do
test "Webhook with invalid env_id should not work" do
webhook =
Webhook.new(1, %{
- "action" => "test",
+ "listener" => "test",
"props" => %{
"prop1" => "1",
"prop2" => "2"
@@ -44,7 +44,7 @@ defmodule ApplicationRunner.Webhooks.WebhookTest do
assert_raise Ecto.InvalidChangesetError, fn -> Repo.insert!(webhook) end
end
- test "Webhook without action should not work" do
+ test "Webhook without listener should not work" do
webhook =
Webhook.new(1, %{
"props" => %{
@@ -54,7 +54,7 @@ defmodule ApplicationRunner.Webhooks.WebhookTest do
})
assert webhook.valid? == false
- assert [action: _reason] = webhook.errors
+ assert [listener: _reason] = webhook.errors
end
test "Insert Webhook with no props into database successfully" do
@@ -63,13 +63,13 @@ defmodule ApplicationRunner.Webhooks.WebhookTest do
|> Repo.insert!()
Webhook.new(env.id, %{
- "action" => "test"
+ "listener" => "test"
})
|> Repo.insert!()
webhook = Enum.at(Repo.all(Webhook), 0)
- assert webhook.action == "test"
+ assert webhook.listener == "test"
end
test "Insert Webhook with user into database successfully" do
@@ -83,13 +83,13 @@ defmodule ApplicationRunner.Webhooks.WebhookTest do
Webhook.new(env.id, %{
"user_id" => user.id,
- "action" => "test"
+ "listener" => "test"
})
|> Repo.insert!()
webhook = Enum.at(Repo.all(Webhook), 0)
- assert webhook.action == "test"
+ assert webhook.listener == "test"
assert webhook.user_id == user.id
preload_user = Repo.preload(webhook, :user)
diff --git a/libs/lenra_common/LICENSE b/libs/lenra_common/LICENSE
deleted file mode 100644
index 4d2a95b9..00000000
--- a/libs/lenra_common/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2022 Lenra
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
\ No newline at end of file
diff --git a/mix.lock b/mix.lock
index d086c323..be8d853d 100644
--- a/mix.lock
+++ b/mix.lock
@@ -29,7 +29,7 @@
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"esbuild": {:hex, :esbuild, "0.7.1", "fa0947e8c3c3c2f86c9bf7e791a0a385007ccd42b86885e8e893bdb6631f5169", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "66661cdf70b1378ee4dc16573fcee67750b59761b2605a0207c267ab9d19f13c"},
"event_queue": {:git, "https://github.com/lenra-io/event-queue.git", "3278e1224b63f51cbb7f574894d67ced104e928f", [tag: "v1.0.0"]},
- "ex_component_schema": {:git, "https://github.com/lenra-io/ex_component_schema", "3b8d70d1f2ede5973c7875e6681fb9993f861826", [ref: "v1.0.0-beta.5"]},
+ "ex_component_schema": {:git, "https://github.com/lenra-io/ex_component_schema", "374b17c0aea3e88cce4f0c9bcf3f17184bd9da30", [ref: "v1.0.0-beta.6"]},
"ex_doc": {:hex, :ex_doc, "0.30.6", "5f8b54854b240a2b55c9734c4b1d0dd7bdd41f71a095d42a70445c03cf05a281", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bd48f2ddacf4e482c727f9293d9498e0881597eae6ddc3d9562bd7923375109f"},
"excoveralls": {:hex, :excoveralls, "0.15.3", "54bb54043e1cf5fe431eb3db36b25e8fd62cf3976666bafe491e3fa5e29eba47", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "f8eb5d8134d84c327685f7bb8f1db4147f1363c3c9533928234e496e3070114e"},
"expo": {:hex, :expo, "0.4.1", "1c61d18a5df197dfda38861673d392e642649a9cef7694d2f97a587b2cfb319b", [:mix], [], "hexpm", "2ff7ba7a798c8c543c12550fa0e2cbc81b95d4974c65855d8d15ba7b37a1ce47"},