|
1 | | -use std::default::Default; |
2 | | - |
3 | 1 | use serde::{Deserialize, Serialize}; |
4 | | -use thiserror::Error; |
5 | | - |
6 | | -use si_data_nats::NatsError; |
7 | | -use si_data_pg::PgError; |
8 | | -use telemetry::prelude::*; |
9 | | - |
10 | | -use crate::{ |
11 | | - pk, ComponentId, FuncId, HistoryEventError, SchemaVariantId, StandardModelError, |
12 | | - TransactionsError, WsEventError, |
13 | | -}; |
14 | | - |
15 | | -#[remain::sorted] |
16 | | -#[derive(Error, Debug)] |
17 | | -pub enum AuthenticationPrototypeError { |
18 | | - #[error("this schema variant({0}) already has an authentication function")] |
19 | | - AuthAlreadySet(SchemaVariantId), |
20 | | - #[error("component error: {0}")] |
21 | | - Component(String), |
22 | | - #[error("component not found: {0}")] |
23 | | - ComponentNotFound(ComponentId), |
24 | | - #[error("action Func {0} not found for ActionPrototype {1}")] |
25 | | - FuncNotFound(FuncId, AuthenticationPrototypeId), |
26 | | - #[error("history event error: {0}")] |
27 | | - HistoryEvent(#[from] HistoryEventError), |
28 | | - #[error("nats txn error: {0}")] |
29 | | - Nats(#[from] NatsError), |
30 | | - #[error("pg error: {0}")] |
31 | | - Pg(#[from] PgError), |
32 | | - #[error("schema not found")] |
33 | | - SchemaNotFound, |
34 | | - #[error("schema variant not found")] |
35 | | - SchemaVariantNotFound, |
36 | | - #[error("error serializing/deserializing json: {0}")] |
37 | | - SerdeJson(#[from] serde_json::Error), |
38 | | - #[error("standard model error: {0}")] |
39 | | - StandardModelError(#[from] StandardModelError), |
40 | | - #[error("transactions error: {0}")] |
41 | | - Transactions(#[from] TransactionsError), |
42 | | - #[error(transparent)] |
43 | | - WsEvent(#[from] WsEventError), |
44 | | -} |
45 | | - |
46 | | -pub type AuthenticationPrototypeResult<T> = Result<T, AuthenticationPrototypeError>; |
47 | | - |
48 | | -#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Copy)] |
49 | | -pub struct AuthenticationPrototypeContext { |
50 | | - pub schema_variant_id: SchemaVariantId, |
51 | | -} |
52 | | - |
53 | | -// Hrm - is this a universal resolver context? -- Adam |
54 | | -impl Default for AuthenticationPrototypeContext { |
55 | | - fn default() -> Self { |
56 | | - Self::new(SchemaVariantId::NONE) |
57 | | - } |
58 | | -} |
59 | 2 |
|
60 | | -impl AuthenticationPrototypeContext { |
61 | | - pub fn new(schema_variant_id: SchemaVariantId) -> Self { |
62 | | - Self { schema_variant_id } |
63 | | - } |
64 | | - |
65 | | - pub fn schema_variant_id(&self) -> SchemaVariantId { |
66 | | - self.schema_variant_id |
67 | | - } |
68 | | - |
69 | | - pub fn set_schema_variant_id(&mut self, schema_variant_id: SchemaVariantId) { |
70 | | - self.schema_variant_id = schema_variant_id; |
71 | | - } |
72 | | -} |
| 3 | +use crate::{pk, FuncId, SchemaVariantId}; |
73 | 4 |
|
74 | 5 | pk!(AuthenticationPrototypeId); |
75 | 6 |
|
76 | | -// An ActionPrototype joins a `FuncId` to a `SchemaVariantId` with a `ActionKind` and `name` |
77 | | -// This only exists for deserialization of the import data |
| 7 | +// TODO(nick): remove this once import can just create the edge. |
78 | 8 | #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] |
79 | 9 | pub struct AuthenticationPrototype { |
80 | 10 | pub id: AuthenticationPrototypeId, |
|
0 commit comments