diff --git a/e2e/react-bed/src/sdk/modules/abac/UserInvitations.ts b/e2e/react-bed/src/sdk/modules/abac/UserInvitations.ts new file mode 100644 index 000000000..e5bf16e08 --- /dev/null +++ b/e2e/react-bed/src/sdk/modules/abac/UserInvitations.ts @@ -0,0 +1,562 @@ +import { GResponse } from "../../sdk/envelopes/index"; +import { buildUrl } from "../../sdk/common/buildUrl"; +import { + fetchx, + handleFetchResponse, + type FetchxContext, + type PartialDeep, + type TypedRequestInit, + type TypedResponse, +} from "../../sdk/common/fetchx"; +import { + type UseMutationOptions, + type UseQueryOptions, + useMutation, + useQuery, +} from "react-query"; +import { useFetchxContext } from "../../sdk/react/useFetchx"; +import { useState } from "react"; +/** + * Action to communicate with the action UserInvitations + */ +export type UserInvitationsActionOptions = { + queryKey?: unknown[]; + qs?: URLSearchParams; +}; +export type UserInvitationsActionQueryOptions = Omit< + UseQueryOptions< + unknown, + unknown, + GResponse, + unknown[] + >, + "queryKey" +> & + UserInvitationsActionOptions & + Partial<{ + creatorFn: (item: unknown) => UserInvitationsActionRes; + }> & { + onMessage?: (ev: MessageEvent) => void; + overrideUrl?: string; + headers?: Headers; + ctx?: FetchxContext; + }; +export const useUserInvitationsActionQuery = ( + options: UserInvitationsActionQueryOptions, +) => { + const globalCtx = useFetchxContext(); + const ctx = options?.ctx ?? globalCtx ?? undefined; + const [isCompleted, setCompleteState] = useState(false); + const [response, setResponse] = useState>(); + const fn = () => { + setCompleteState(false); + return UserInvitationsAction.Fetch( + { + headers: options?.headers, + }, + { + creatorFn: options?.creatorFn, + qs: options?.qs, + ctx, + onMessage: options?.onMessage, + overrideUrl: options?.overrideUrl, + }, + ).then((x) => { + x.done.then(() => { + setCompleteState(true); + }); + setResponse(x.response); + return x.response.result; + }); + }; + const result = useQuery({ + queryKey: [UserInvitationsAction.NewUrl(options?.qs)], + queryFn: fn, + ...(options || {}), + }); + return { + ...result, + isCompleted, + response, + }; +}; +export type UserInvitationsActionMutationOptions = Omit< + UseMutationOptions, + "mutationFn" +> & + UserInvitationsActionOptions & { + ctx?: FetchxContext; + onMessage?: (ev: MessageEvent) => void; + overrideUrl?: string; + headers?: Headers; + } & Partial<{ + creatorFn: (item: unknown) => UserInvitationsActionRes; + }>; +export const useUserInvitationsAction = ( + options?: UserInvitationsActionMutationOptions, +) => { + const globalCtx = useFetchxContext(); + const ctx = options?.ctx ?? globalCtx ?? undefined; + const [isCompleted, setCompleteState] = useState(false); + const [response, setResponse] = useState>(); + const fn = (body: unknown) => { + setCompleteState(false); + return UserInvitationsAction.Fetch( + { + body, + headers: options?.headers, + }, + { + creatorFn: options?.creatorFn, + qs: options?.qs, + ctx, + onMessage: options?.onMessage, + overrideUrl: options?.overrideUrl, + }, + ).then((x) => { + x.done.then(() => { + setCompleteState(true); + }); + setResponse(x.response); + return x.response.result; + }); + }; + const result = useMutation({ + mutationFn: fn, + ...(options || {}), + }); + return { + ...result, + isCompleted, + response, + }; +}; +/** + * UserInvitationsAction + */ +export class UserInvitationsAction { + // + static URL = "/users/invitations"; + static NewUrl = (qs?: URLSearchParams) => + buildUrl(UserInvitationsAction.URL, undefined, qs); + static Method = "get"; + static Fetch$ = async ( + qs?: URLSearchParams, + ctx?: FetchxContext, + init?: TypedRequestInit, + overrideUrl?: string, + ) => { + return fetchx, unknown, unknown>( + overrideUrl ?? UserInvitationsAction.NewUrl(qs), + { + method: UserInvitationsAction.Method, + ...(init || {}), + }, + ctx, + ); + }; + static Fetch = async ( + init?: TypedRequestInit, + { + creatorFn, + qs, + ctx, + onMessage, + overrideUrl, + }: { + creatorFn?: ((item: unknown) => UserInvitationsActionRes) | undefined; + qs?: URLSearchParams; + ctx?: FetchxContext; + onMessage?: (ev: MessageEvent) => void; + overrideUrl?: string; + } = { + creatorFn: (item) => new UserInvitationsActionRes(item), + }, + ) => { + creatorFn = creatorFn || ((item) => new UserInvitationsActionRes(item)); + const res = await UserInvitationsAction.Fetch$(qs, ctx, init, overrideUrl); + return handleFetchResponse( + res, + (data) => { + const resp = new GResponse(); + if (creatorFn) { + resp.setCreator(creatorFn); + } + resp.inject(data); + return resp; + }, + onMessage, + init?.signal, + ); + }; + static Definition = { + name: "UserInvitations", + url: "/users/invitations", + method: "get", + description: + "Shows the invitations for an specific user, if the invited member already has a account. It's based on the passports, so if the passport is authenticated we will show them.", + out: { + envelope: "GResponse", + fields: [ + { + name: "userId", + description: "UserUniqueId", + type: "string", + }, + { + name: "uniqueId", + description: "Invitation unique id", + type: "string", + }, + { + name: "value", + description: "The value of the passport (email/phone)", + type: "string", + }, + { + name: "roleName", + description: "Name of the role that user will get", + type: "string", + }, + { + name: "workspaceName", + description: "Name of the workspace which user is invited to.", + type: "string", + }, + { + name: "type", + description: "The method of the invitation, such as email.", + type: "string", + }, + { + name: "coverLetter", + description: + "The content that user will receive to understand the reason of the letter.", + type: "string", + }, + ], + }, + }; +} +/** + * The base class definition for userInvitationsActionRes + **/ +export class UserInvitationsActionRes { + /** + * UserUniqueId + * @type {string} + **/ + #userId: string = ""; + /** + * UserUniqueId + * @returns {string} + **/ + get userId() { + return this.#userId; + } + /** + * UserUniqueId + * @type {string} + **/ + set userId(value: string) { + this.#userId = String(value); + } + setUserId(value: string) { + this.userId = value; + return this; + } + /** + * Invitation unique id + * @type {string} + **/ + #uniqueId: string = ""; + /** + * Invitation unique id + * @returns {string} + **/ + get uniqueId() { + return this.#uniqueId; + } + /** + * Invitation unique id + * @type {string} + **/ + set uniqueId(value: string) { + this.#uniqueId = String(value); + } + setUniqueId(value: string) { + this.uniqueId = value; + return this; + } + /** + * The value of the passport (email/phone) + * @type {string} + **/ + #value: string = ""; + /** + * The value of the passport (email/phone) + * @returns {string} + **/ + get value() { + return this.#value; + } + /** + * The value of the passport (email/phone) + * @type {string} + **/ + set value(value: string) { + this.#value = String(value); + } + setValue(value: string) { + this.value = value; + return this; + } + /** + * Name of the role that user will get + * @type {string} + **/ + #roleName: string = ""; + /** + * Name of the role that user will get + * @returns {string} + **/ + get roleName() { + return this.#roleName; + } + /** + * Name of the role that user will get + * @type {string} + **/ + set roleName(value: string) { + this.#roleName = String(value); + } + setRoleName(value: string) { + this.roleName = value; + return this; + } + /** + * Name of the workspace which user is invited to. + * @type {string} + **/ + #workspaceName: string = ""; + /** + * Name of the workspace which user is invited to. + * @returns {string} + **/ + get workspaceName() { + return this.#workspaceName; + } + /** + * Name of the workspace which user is invited to. + * @type {string} + **/ + set workspaceName(value: string) { + this.#workspaceName = String(value); + } + setWorkspaceName(value: string) { + this.workspaceName = value; + return this; + } + /** + * The method of the invitation, such as email. + * @type {string} + **/ + #type: string = ""; + /** + * The method of the invitation, such as email. + * @returns {string} + **/ + get type() { + return this.#type; + } + /** + * The method of the invitation, such as email. + * @type {string} + **/ + set type(value: string) { + this.#type = String(value); + } + setType(value: string) { + this.type = value; + return this; + } + /** + * The content that user will receive to understand the reason of the letter. + * @type {string} + **/ + #coverLetter: string = ""; + /** + * The content that user will receive to understand the reason of the letter. + * @returns {string} + **/ + get coverLetter() { + return this.#coverLetter; + } + /** + * The content that user will receive to understand the reason of the letter. + * @type {string} + **/ + set coverLetter(value: string) { + this.#coverLetter = String(value); + } + setCoverLetter(value: string) { + this.coverLetter = value; + return this; + } + constructor(data: unknown = undefined) { + if (data === null || data === undefined) { + return; + } + if (typeof data === "string") { + this.applyFromObject(JSON.parse(data)); + } else if (this.#isJsonAppliable(data)) { + this.applyFromObject(data); + } else { + throw new Error( + "Instance cannot be created on an unknown value, check the content being passed. got: " + + typeof data, + ); + } + } + #isJsonAppliable(obj: unknown) { + const g = globalThis as unknown as { Buffer: any; Blob: any }; + const isBuffer = + typeof g.Buffer !== "undefined" && + typeof g.Buffer.isBuffer === "function" && + g.Buffer.isBuffer(obj); + const isBlob = typeof g.Blob !== "undefined" && obj instanceof g.Blob; + return ( + obj && + typeof obj === "object" && + !Array.isArray(obj) && + !isBuffer && + !(obj instanceof ArrayBuffer) && + !isBlob + ); + } + /** + * casts the fields of a javascript object into the class properties one by one + **/ + applyFromObject(data = {}) { + const d = data as Partial; + if (d.userId !== undefined) { + this.userId = d.userId; + } + if (d.uniqueId !== undefined) { + this.uniqueId = d.uniqueId; + } + if (d.value !== undefined) { + this.value = d.value; + } + if (d.roleName !== undefined) { + this.roleName = d.roleName; + } + if (d.workspaceName !== undefined) { + this.workspaceName = d.workspaceName; + } + if (d.type !== undefined) { + this.type = d.type; + } + if (d.coverLetter !== undefined) { + this.coverLetter = d.coverLetter; + } + } + /** + * Special toJSON override, since the field are private, + * Json stringify won't see them unless we mention it explicitly. + **/ + toJSON() { + return { + userId: this.#userId, + uniqueId: this.#uniqueId, + value: this.#value, + roleName: this.#roleName, + workspaceName: this.#workspaceName, + type: this.#type, + coverLetter: this.#coverLetter, + }; + } + toString() { + return JSON.stringify(this); + } + static get Fields() { + return { + userId: "userId", + uniqueId: "uniqueId", + value: "value", + roleName: "roleName", + workspaceName: "workspaceName", + type: "type", + coverLetter: "coverLetter", + }; + } + /** + * Creates an instance of UserInvitationsActionRes, and possibleDtoObject + * needs to satisfy the type requirement fully, otherwise typescript compile would + * be complaining. + **/ + static from(possibleDtoObject: UserInvitationsActionResType) { + return new UserInvitationsActionRes(possibleDtoObject); + } + /** + * Creates an instance of UserInvitationsActionRes, and partialDtoObject + * needs to satisfy the type, but partially, and rest of the content would + * be constructed according to data types and nullability. + **/ + static with(partialDtoObject: PartialDeep) { + return new UserInvitationsActionRes(partialDtoObject); + } + copyWith( + partial: PartialDeep, + ): InstanceType { + return new UserInvitationsActionRes({ ...this.toJSON(), ...partial }); + } + clone(): InstanceType { + return new UserInvitationsActionRes(this.toJSON()); + } +} +export abstract class UserInvitationsActionResFactory { + abstract create(data: unknown): UserInvitationsActionRes; +} +/** + * The base type definition for userInvitationsActionRes + **/ +export type UserInvitationsActionResType = { + /** + * UserUniqueId + * @type {string} + **/ + userId: string; + /** + * Invitation unique id + * @type {string} + **/ + uniqueId: string; + /** + * The value of the passport (email/phone) + * @type {string} + **/ + value: string; + /** + * Name of the role that user will get + * @type {string} + **/ + roleName: string; + /** + * Name of the workspace which user is invited to. + * @type {string} + **/ + workspaceName: string; + /** + * The method of the invitation, such as email. + * @type {string} + **/ + type: string; + /** + * The content that user will receive to understand the reason of the letter. + * @type {string} + **/ + coverLetter: string; +}; +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace UserInvitationsActionResType {} diff --git a/e2e/react-bed/src/sdk/modules/abac/useGetUsersInvitations.ts b/e2e/react-bed/src/sdk/modules/abac/useGetUsersInvitations.ts deleted file mode 100644 index f7f6b01ff..000000000 --- a/e2e/react-bed/src/sdk/modules/abac/useGetUsersInvitations.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* -* Generated by fireback 1.2.5 -* Written by Ali Torabi. -* The code is generated for react-query@v3.39.3 -* Checkout the repository for licenses and contribution: https://github.com/torabian/fireback -*/ -import { useContext } from "react"; -import { useQuery } from "react-query"; -import { - RemoteQueryContext, - type UseRemoteQuery, - queryBeforeSend, -} from "../../core/react-tools"; -import { stringify } from "qs"; -import { execApiFn, type IResponseList } from "../../core/http-tools"; - import { - UserInvitationsQueryColumns, - } from "../abac/UserInvitationsQueryColumns" -// Fireback gives the option to have typesafe query string -export type GetUsersInvitationsQs = { -} -export type GetUsersInvitationsUrlParams = { -} -export type GetUsersInvitationsHeaders = { -} -export function useGetUsersInvitations({ - queryOptions, - query, - queryClient, - execFnOverride, - unauthorized, - optionFn -}: UseRemoteQuery & {query?: GetUsersInvitationsQs}) { - const { options, execFn } = useContext(RemoteQueryContext); - const computedOptions = optionFn ? optionFn(options) : options; - // Calculare the function which will do the remote calls. - // We consider to use global override, this specific override, or default which - // comes with the sdk. - const rpcFn = execFnOverride - ? execFnOverride(computedOptions) - : execFn - ? execFn(computedOptions) - : execApiFn(computedOptions); - // Url of the remote affix. - const url = "/users/invitations".substr(1); - let computedUrl = `${url}?${stringify(query)}`; - let completeRouteUrls = true; - // Attach the details of the request to the fn - const fn = () => rpcFn("GET", computedUrl); - const auth = computedOptions?.headers?.authorization - const hasKey = auth != "undefined" && auth != undefined && auth !=null && auth != "null" && !!auth - let enabled = true; - if (!completeRouteUrls) { - enabled = false; - } else if (!hasKey && !unauthorized) { - enabled = false; - } - const query$ = useQuery, any>(["*abac.UserInvitationsQueryColumns", computedOptions, query], fn, { - cacheTime: 1000, - retry: false, - keepPreviousData: true, - enabled, - ...((queryOptions as any) || {}) - } as any); - const items: Array = query$.data?.data?.items || []; - return { - query: query$, - items, - keyExtractor: (item: UserInvitationsQueryColumns) => item.uniqueId, - }; -} -useGetUsersInvitations.UKEY = "*abac.UserInvitationsQueryColumns" \ No newline at end of file diff --git a/modules/abac/AbacCustomActions.dyno.go b/modules/abac/AbacCustomActions.dyno.go index 19b9e451c..3bb5a086d 100644 --- a/modules/abac/AbacCustomActions.dyno.go +++ b/modules/abac/AbacCustomActions.dyno.go @@ -22,45 +22,6 @@ type QueryUserRoleWorkspacesResDtoRoles struct { Capabilities []string `json:"capabilities" xml:"capabilities" yaml:"capabilities" ` } -var UserInvitationsSecurityModel = &fireback.SecurityModel{ - ActionRequires: []fireback.PermissionInfo{}, - ResolveStrategy: "user", -} - -type userInvitationsActionImpSig func( - q fireback.QueryDSL) ([]*UserInvitationsQueryColumns, - *fireback.QueryResultMeta, - *fireback.IError, -) - -var UserInvitationsActionImp userInvitationsActionImpSig - -func UserInvitationsActionFn( - q fireback.QueryDSL, -) ( - []*UserInvitationsQueryColumns, - *fireback.QueryResultMeta, - *fireback.IError, -) { - if UserInvitationsActionImp == nil { - return nil, nil, nil - } - return UserInvitationsActionImp(q) -} - -var UserInvitationsActionCmd cli.Command = cli.Command{ - Name: "user-invitations", - Usage: `Shows the invitations for an specific user, if the invited member already has a account. It's based on the passports, so if the passport is authenticated we will show them.`, - Flags: fireback.CommonQueryFlags, - Action: func(c *cli.Context) { - fireback.CommonCliQueryCmd3IError( - c, - UserInvitationsActionFn, - UserInvitationsSecurityModel, - nil, - ) - }, -} var QueryUserRoleWorkspacesSecurityModel = &fireback.SecurityModel{ ActionRequires: []fireback.PermissionInfo{}, ResolveStrategy: "user", @@ -525,6 +486,44 @@ var GsmSendSmsWithProviderActionCmd cli.Command = cli.Command{ /// For emi, we also need to print the handlers, and also print security model, which is a part of Fireback /// and not available in Emi (won't be) +var UserInvitationsImpl func(c UserInvitationsActionRequest, query fireback.QueryDSL) (*UserInvitationsActionResponse, error) = nil +var UserInvitationsSecurityModel = &fireback.SecurityModel{ + ActionRequires: []fireback.PermissionInfo{}, + ResolveStrategy: "user", +} + +// This can be both used as cli and http +var UserInvitationsActionDef fireback.Module3Action = fireback.Module3Action{ + // Temporary until fireback code gen is deleted. + Skip: true, + CliName: UserInvitationsActionMeta().CliName, + Description: UserInvitationsActionMeta().Description, + Name: UserInvitationsActionMeta().Name, + Method: UserInvitationsActionMeta().Method, + Url: UserInvitationsActionMeta().URL, + SecurityModel: UserInvitationsSecurityModel, + // get + Handlers: []gin.HandlerFunc{ + func(m *gin.Context) { + req := UserInvitationsActionRequest{ + QueryParams: m.Request.URL.Query(), + Headers: m.Request.Header, + GinCtx: m, + } + query := fireback.ExtractQueryDslFromGinContext(m) + fireback.ReadGinRequestBodyAndCastToGoStruct(m, &req.Body, query) + resp, err := UserInvitationsImpl(req, query) + fireback.WriteActionResponseToGin(m, resp, err) + }, + }, + CliAction: func(c *cli.Context, security *fireback.SecurityModel) error { + query := fireback.CommonCliQueryDSLBuilderAuthorize(c, UserInvitationsSecurityModel) + req := UserInvitationsActionRequest{} + resp, err := UserInvitationsImpl(req, query) + fireback.HandleActionInCli2(c, resp, err, map[string]map[string]string{}) + return nil + }, +} var SignoutImpl func(c SignoutActionRequest, query fireback.QueryDSL) (*SignoutActionResponse, error) = nil var SignoutSecurityModel *fireback.SecurityModel = nil @@ -1063,6 +1062,7 @@ var OsLoginAuthenticateActionDef fireback.Module3Action = fireback.Module3Action func AbacCustomActions() []fireback.Module3Action { routes := []fireback.Module3Action{ //// Let's add actions for emi acts + UserInvitationsActionDef, SignoutActionDef, OauthAuthenticateActionDef, AcceptInviteActionDef, @@ -1079,29 +1079,6 @@ func AbacCustomActions() []fireback.Module3Action { CheckPassportMethodsActionDef, OsLoginAuthenticateActionDef, /// End for emi actions - { - Method: "GET", - Url: "/users/invitations", - SecurityModel: UserInvitationsSecurityModel, - Name: "userInvitations", - Description: "Shows the invitations for an specific user, if the invited member already has a account. It's based on the passports, so if the passport is authenticated we will show them.", - Handlers: []gin.HandlerFunc{ - func(c *gin.Context) { - // QUERY - get - fireback.HttpQueryEntity( - c, - UserInvitationsActionFn, - nil, - ) - }, - }, - Format: "QUERY", - Action: UserInvitationsActionFn, - ResponseEntity: &UserInvitationsQueryColumns{}, - Out: &fireback.Module3ActionBody{ - Entity: "UserInvitationsQueryColumns", - }, - }, { Method: "GET", Url: "/urw/query", @@ -1245,7 +1222,6 @@ func AbacCustomActions() []fireback.Module3Action { } var AbacCustomActionsCli = []cli.Command{ - UserInvitationsActionCmd, QueryUserRoleWorkspacesActionCmd, SendEmailActionCmd, SendEmailWithProviderActionCmd, @@ -1267,6 +1243,7 @@ var AbacCliActionsBundle = &fireback.CliActionsBundle{ Usage: `Fireback ABAC module provides user authentication, basic support for most projects, including advanced role, permission module on top of fireback core module. Using this module is not essential to create fireback projects, but provides a great possibility to avoid building most user management flow. Some other helpers, such as timezone are added here.`, // Here we will include entities actions, as well as module level actions Subcommands: cli.Commands{ + UserInvitationsActionDef.ToCli(), SignoutActionDef.ToCli(), OauthAuthenticateActionDef.ToCli(), AcceptInviteActionDef.ToCli(), @@ -1282,7 +1259,6 @@ var AbacCliActionsBundle = &fireback.CliActionsBundle{ QueryWorkspaceTypesPubliclyActionDef.ToCli(), CheckPassportMethodsActionDef.ToCli(), OsLoginAuthenticateActionDef.ToCli(), - UserInvitationsActionCmd, QueryUserRoleWorkspacesActionCmd, SendEmailActionCmd, SendEmailWithProviderActionCmd, diff --git a/modules/abac/AbacModule3.yml b/modules/abac/AbacModule3.yml index 0b4321f60..fe27bede0 100644 --- a/modules/abac/AbacModule3.yml +++ b/modules/abac/AbacModule3.yml @@ -156,6 +156,39 @@ dtom: type: string? acts: + - name: UserInvitations + description: + Shows the invitations for an specific user, if the invited member already has a account. + It's based on the passports, so if the passport is authenticated we will show them. + url: /users/invitations + method: get + security: + resolveStrategy: user + out: + envelope: GResponse + fields: + - name: userId + type: string + description: UserUniqueId + - name: uniqueId + type: string + description: Invitation unique id + - name: value + type: string + description: The value of the passport (email/phone) + - name: roleName + type: string + description: Name of the role that user will get + - name: workspaceName + type: string + description: Name of the workspace which user is invited to. + - name: type + type: string + description: The method of the invitation, such as email. + - name: coverLetter + type: string + description: The content that user will receive to understand the reason of the letter. + - name: Signout url: /passport/signout description: Signout the user, clears cookies or does anything else if needed. @@ -601,18 +634,6 @@ acts: out: dto: UserSessionDto actions: - - name: userInvitations - description: - Shows the invitations for an specific user, if the invited member already has a account. - It's based on the passports, so if the passport is authenticated we will show them. - format: query - url: /users/invitations - method: get - security: - resolveStrategy: user - out: - dto: UserInvitationsQueryColumns - - name: queryUserRoleWorkspaces format: query method: get diff --git a/modules/abac/UserEntity.go b/modules/abac/UserEntity.go index fe315f021..05fedbf1c 100644 --- a/modules/abac/UserEntity.go +++ b/modules/abac/UserEntity.go @@ -104,7 +104,7 @@ func init() { UserCliCommands, TokenCliFn(), AcceptInviteActionDef.ToCli(), - UserInvitationsActionCmd, + UserInvitationsActionDef.ToCli(), ) } diff --git a/modules/abac/UserInvitationsAction.dyno.go b/modules/abac/UserInvitationsAction.dyno.go new file mode 100644 index 000000000..1609438ad --- /dev/null +++ b/modules/abac/UserInvitationsAction.dyno.go @@ -0,0 +1,327 @@ +package abac + +import ( + "encoding/json" + "fmt" + "github.com/gin-gonic/gin" + "github.com/torabian/emi/emigo" + "github.com/urfave/cli" + "io" + "net/http" + "net/url" +) + +/** +* Action to communicate with the action UserInvitationsAction + */ +func UserInvitationsActionMeta() struct { + Name string + CliName string + URL string + Method string + Description string +} { + return struct { + Name string + CliName string + URL string + Method string + Description string + }{ + Name: "UserInvitationsAction", + CliName: "user-invitations-action", + URL: "/users/invitations", + Method: "GET", + Description: `Shows the invitations for an specific user, if the invited member already has a account. It's based on the passports, so if the passport is authenticated we will show them.`, + } +} +func GetUserInvitationsActionResCliFlags(prefix string) []emigo.CliFlag { + return []emigo.CliFlag{ + { + Name: prefix + "user-id", + Type: "string", + }, + { + Name: prefix + "unique-id", + Type: "string", + }, + { + Name: prefix + "value", + Type: "string", + }, + { + Name: prefix + "role-name", + Type: "string", + }, + { + Name: prefix + "workspace-name", + Type: "string", + }, + { + Name: prefix + "type", + Type: "string", + }, + { + Name: prefix + "cover-letter", + Type: "string", + }, + } +} +func CastUserInvitationsActionResFromCli(c emigo.CliCastable) UserInvitationsActionRes { + data := UserInvitationsActionRes{} + if c.IsSet("user-id") { + data.UserId = c.String("user-id") + } + if c.IsSet("unique-id") { + data.UniqueId = c.String("unique-id") + } + if c.IsSet("value") { + data.Value = c.String("value") + } + if c.IsSet("role-name") { + data.RoleName = c.String("role-name") + } + if c.IsSet("workspace-name") { + data.WorkspaceName = c.String("workspace-name") + } + if c.IsSet("type") { + data.Type = c.String("type") + } + if c.IsSet("cover-letter") { + data.CoverLetter = c.String("cover-letter") + } + return data +} + +// The base class definition for userInvitationsActionRes +type UserInvitationsActionRes struct { + // UserUniqueId + UserId string `json:"userId" yaml:"userId"` + // Invitation unique id + UniqueId string `json:"uniqueId" yaml:"uniqueId"` + // The value of the passport (email/phone) + Value string `json:"value" yaml:"value"` + // Name of the role that user will get + RoleName string `json:"roleName" yaml:"roleName"` + // Name of the workspace which user is invited to. + WorkspaceName string `json:"workspaceName" yaml:"workspaceName"` + // The method of the invitation, such as email. + Type string `json:"type" yaml:"type"` + // The content that user will receive to understand the reason of the letter. + CoverLetter string `json:"coverLetter" yaml:"coverLetter"` +} + +func (x *UserInvitationsActionRes) Json() string { + if x != nil { + str, _ := json.MarshalIndent(x, "", " ") + return string(str) + } + return "" +} + +type UserInvitationsActionResponse struct { + StatusCode int + Headers map[string]string + Payload interface{} +} + +func (x *UserInvitationsActionResponse) SetContentType(contentType string) *UserInvitationsActionResponse { + if x.Headers == nil { + x.Headers = make(map[string]string) + } + x.Headers["Content-Type"] = contentType + return x +} +func (x *UserInvitationsActionResponse) AsStream(r io.Reader, contentType string) *UserInvitationsActionResponse { + x.Payload = r + x.SetContentType(contentType) + return x +} +func (x *UserInvitationsActionResponse) AsJSON(payload any) *UserInvitationsActionResponse { + x.Payload = payload + x.SetContentType("application/json") + return x +} +func (x *UserInvitationsActionResponse) AsHTML(payload string) *UserInvitationsActionResponse { + x.Payload = payload + x.SetContentType("text/html; charset=utf-8") + return x +} +func (x *UserInvitationsActionResponse) AsBytes(payload []byte) *UserInvitationsActionResponse { + x.Payload = payload + x.SetContentType("application/octet-stream") + return x +} +func (x UserInvitationsActionResponse) GetStatusCode() int { + return x.StatusCode +} +func (x UserInvitationsActionResponse) GetRespHeaders() map[string]string { + return x.Headers +} +func (x UserInvitationsActionResponse) GetPayload() interface{} { + return x.Payload +} + +// UserInvitationsActionRaw registers a raw Gin route for the UserInvitationsAction action. +// This gives the developer full control over middleware, handlers, and response handling. +func UserInvitationsActionRaw(r *gin.Engine, handlers ...gin.HandlerFunc) { + meta := UserInvitationsActionMeta() + r.Handle(meta.Method, meta.URL, handlers...) +} + +type UserInvitationsActionRequestSig = func(c UserInvitationsActionRequest) (*UserInvitationsActionResponse, error) + +// UserInvitationsActionHandler returns the HTTP method, route URL, and a typed Gin handler for the UserInvitationsAction action. +// Developers implement their business logic as a function that receives a typed request object +// and returns either an *ActionResponse or nil. JSON marshalling, headers, and errors are handled automatically. +func UserInvitationsActionHandler( + handler UserInvitationsActionRequestSig, +) (method, url string, h gin.HandlerFunc) { + meta := UserInvitationsActionMeta() + return meta.Method, meta.URL, func(m *gin.Context) { + // Build typed request wrapper + req := UserInvitationsActionRequest{ + Body: nil, + QueryParams: m.Request.URL.Query(), + Headers: m.Request.Header, + GinCtx: m, + } + resp, err := handler(req) + if err != nil { + m.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + // If the handler returned nil (and no error), it means the response was handled manually. + if resp == nil { + return + } + // Apply headers + for k, v := range resp.Headers { + m.Header(k, v) + } + // Apply status and payload + status := resp.StatusCode + if status == 0 { + status = http.StatusOK + } + if resp.Payload != nil { + m.JSON(status, resp.Payload) + } else { + m.Status(status) + } + } +} + +// UserInvitationsAction is a high-level convenience wrapper around UserInvitationsActionHandler. +// It automatically constructs and registers the typed route on the Gin engine. +// Use this when you don't need custom middleware or route grouping. +func UserInvitationsActionGin(r gin.IRoutes, handler UserInvitationsActionRequestSig) { + method, url, h := UserInvitationsActionHandler(handler) + r.Handle(method, url, h) +} + +/** + * Query parameters for UserInvitationsAction + */ +// Query wrapper with private fields +type UserInvitationsActionQuery struct { + values url.Values + mapped map[string]interface{} + // Typesafe fields +} + +func UserInvitationsActionQueryFromString(rawQuery string) UserInvitationsActionQuery { + v := UserInvitationsActionQuery{} + values, _ := url.ParseQuery(rawQuery) + mapped := map[string]interface{}{} + if result, err := emigo.UnmarshalQs(rawQuery); err == nil { + mapped = result + } + decoder, err := emigo.NewDecoder(&emigo.DecoderConfig{ + TagName: "json", // reuse json tags + WeaklyTypedInput: true, // "1" -> int, "true" -> bool + Result: &v, + }) + if err == nil { + _ = decoder.Decode(mapped) + } + v.values = values + v.mapped = mapped + return v +} +func UserInvitationsActionQueryFromGin(c *gin.Context) UserInvitationsActionQuery { + return UserInvitationsActionQueryFromString(c.Request.URL.RawQuery) +} +func UserInvitationsActionQueryFromHttp(r *http.Request) UserInvitationsActionQuery { + return UserInvitationsActionQueryFromString(r.URL.RawQuery) +} +func (q UserInvitationsActionQuery) Values() url.Values { + return q.values +} +func (q UserInvitationsActionQuery) Mapped() map[string]interface{} { + return q.mapped +} +func (q *UserInvitationsActionQuery) SetValues(v url.Values) { + q.values = v +} +func (q *UserInvitationsActionQuery) SetMapped(m map[string]interface{}) { + q.mapped = m +} + +type UserInvitationsActionRequest struct { + Body interface{} + QueryParams url.Values + Headers http.Header + GinCtx *gin.Context + CliCtx *cli.Context +} +type UserInvitationsActionResult struct { + resp *http.Response // embed original response + Payload interface{} +} + +func UserInvitationsActionCall( + req UserInvitationsActionRequest, + config *emigo.APIClient, // optional pre-built request +) (*UserInvitationsActionResult, error) { + var httpReq *http.Request + if config == nil || config.Httpr == nil { + meta := UserInvitationsActionMeta() + baseURL := meta.URL + // Build final URL with query string + u, err := url.Parse(baseURL) + if err != nil { + return nil, err + } + // if UrlValues present, encode and append + if len(req.QueryParams) > 0 { + u.RawQuery = req.QueryParams.Encode() + } + req0, err := http.NewRequest(meta.Method, u.String(), nil) + if err != nil { + return nil, err + } + httpReq = req0 + } else { + httpReq = config.Httpr + } + httpReq.Header = req.Headers + resp, err := http.DefaultClient.Do(httpReq) + if err != nil { + return nil, err + } + var result UserInvitationsActionResult + result.resp = resp + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return &result, err + } + if resp.StatusCode >= 400 { + return &result, fmt.Errorf("request failed: %s", respBody) + } + if err := json.Unmarshal(respBody, &result.Payload); err != nil { + return &result, err + } + return &result, nil +} diff --git a/modules/abac/UserInvitationsAction.go b/modules/abac/UserInvitationsAction.go index e0d3f5d05..5d4b24ca8 100644 --- a/modules/abac/UserInvitationsAction.go +++ b/modules/abac/UserInvitationsAction.go @@ -4,19 +4,18 @@ import "github.com/torabian/fireback/modules/fireback" func init() { // Override the implementation with our actual code. - UserInvitationsActionImp = UserInvitationsAction + UserInvitationsImpl = UserInvitationsAction } -func UserInvitationsAction( - q fireback.QueryDSL) ([]*UserInvitationsQueryColumns, - *fireback.QueryResultMeta, - *fireback.IError, -) { - invitations, _, err3 := UserInvitationsQuery(q) +func UserInvitationsAction(c UserInvitationsActionRequest, q fireback.QueryDSL) (*UserInvitationsActionResponse, error) { + + invitations, qrm, err3 := UserInvitationsQuery(q) if err3 != nil { - return nil, nil, fireback.CastToIError(err3) + return nil, fireback.CastToIError(err3) } - return invitations, nil, nil + return &UserInvitationsActionResponse{ + Payload: fireback.GResponseQuery(invitations, qrm, &q), + }, nil } diff --git a/modules/fireback/codegen/react-new/src/modules/fireback/components/entity-manager/CommonListManager.tsx b/modules/fireback/codegen/react-new/src/modules/fireback/components/entity-manager/CommonListManager.tsx index 0fae6cd83..bc5a9fab1 100644 --- a/modules/fireback/codegen/react-new/src/modules/fireback/components/entity-manager/CommonListManager.tsx +++ b/modules/fireback/codegen/react-new/src/modules/fireback/components/entity-manager/CommonListManager.tsx @@ -169,7 +169,7 @@ export const CommonListManager = ({ const jsonQuery = useMemo(() => filtersToJsonQuery(f as any), [f]); - const q = queryHook({ + const source = queryHook({ query: { deep: deep === undefined ? true : deep, ...udf.debouncedFilters, @@ -178,6 +178,8 @@ export const CommonListManager = ({ queryClient: queryClient, }); + const q = source.query ? source : { query: source }; + q.jsonQuery = jsonQuery; const rows: any = q.query.data?.data?.items || []; diff --git a/modules/fireback/codegen/react-new/src/modules/fireback/modules/selfservice/user-invitations/UserInvitationList.tsx b/modules/fireback/codegen/react-new/src/modules/fireback/modules/selfservice/user-invitations/UserInvitationList.tsx index fc8256847..092fb660c 100644 --- a/modules/fireback/codegen/react-new/src/modules/fireback/modules/selfservice/user-invitations/UserInvitationList.tsx +++ b/modules/fireback/codegen/react-new/src/modules/fireback/modules/selfservice/user-invitations/UserInvitationList.tsx @@ -1,5 +1,4 @@ import { useS } from "@/modules/fireback/hooks/useS"; -import { useGetUsersInvitations } from "@/modules/fireback/sdk/modules/abac/useGetUsersInvitations"; import { CommonListManager } from "../../../components/entity-manager/CommonListManager"; import { strings } from "./strings/translations"; import { userInvitationColumns } from "./UserInvitationColumns"; @@ -8,6 +7,7 @@ import { ModalContext } from "@/modules/fireback/components/modal/Modal"; import { useContext } from "react"; import { UserInvitationsQueryColumns } from "@/modules/fireback/sdk/modules/abac/UserInvitationsQueryColumns"; import { useAcceptInviteAction, AcceptInviteActionReq } from "@/modules/fireback/sdk/modules/abac/AcceptInvite"; +import { useUserInvitationsActionQuery } from "@/modules/fireback/sdk/modules/abac/UserInvitations"; export const UserInvitationList = () => { const s = useS(strings); @@ -47,7 +47,7 @@ export const UserInvitationList = () => { ); diff --git a/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/UserInvitations.ts b/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/UserInvitations.ts new file mode 100644 index 000000000..e5bf16e08 --- /dev/null +++ b/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/UserInvitations.ts @@ -0,0 +1,562 @@ +import { GResponse } from "../../sdk/envelopes/index"; +import { buildUrl } from "../../sdk/common/buildUrl"; +import { + fetchx, + handleFetchResponse, + type FetchxContext, + type PartialDeep, + type TypedRequestInit, + type TypedResponse, +} from "../../sdk/common/fetchx"; +import { + type UseMutationOptions, + type UseQueryOptions, + useMutation, + useQuery, +} from "react-query"; +import { useFetchxContext } from "../../sdk/react/useFetchx"; +import { useState } from "react"; +/** + * Action to communicate with the action UserInvitations + */ +export type UserInvitationsActionOptions = { + queryKey?: unknown[]; + qs?: URLSearchParams; +}; +export type UserInvitationsActionQueryOptions = Omit< + UseQueryOptions< + unknown, + unknown, + GResponse, + unknown[] + >, + "queryKey" +> & + UserInvitationsActionOptions & + Partial<{ + creatorFn: (item: unknown) => UserInvitationsActionRes; + }> & { + onMessage?: (ev: MessageEvent) => void; + overrideUrl?: string; + headers?: Headers; + ctx?: FetchxContext; + }; +export const useUserInvitationsActionQuery = ( + options: UserInvitationsActionQueryOptions, +) => { + const globalCtx = useFetchxContext(); + const ctx = options?.ctx ?? globalCtx ?? undefined; + const [isCompleted, setCompleteState] = useState(false); + const [response, setResponse] = useState>(); + const fn = () => { + setCompleteState(false); + return UserInvitationsAction.Fetch( + { + headers: options?.headers, + }, + { + creatorFn: options?.creatorFn, + qs: options?.qs, + ctx, + onMessage: options?.onMessage, + overrideUrl: options?.overrideUrl, + }, + ).then((x) => { + x.done.then(() => { + setCompleteState(true); + }); + setResponse(x.response); + return x.response.result; + }); + }; + const result = useQuery({ + queryKey: [UserInvitationsAction.NewUrl(options?.qs)], + queryFn: fn, + ...(options || {}), + }); + return { + ...result, + isCompleted, + response, + }; +}; +export type UserInvitationsActionMutationOptions = Omit< + UseMutationOptions, + "mutationFn" +> & + UserInvitationsActionOptions & { + ctx?: FetchxContext; + onMessage?: (ev: MessageEvent) => void; + overrideUrl?: string; + headers?: Headers; + } & Partial<{ + creatorFn: (item: unknown) => UserInvitationsActionRes; + }>; +export const useUserInvitationsAction = ( + options?: UserInvitationsActionMutationOptions, +) => { + const globalCtx = useFetchxContext(); + const ctx = options?.ctx ?? globalCtx ?? undefined; + const [isCompleted, setCompleteState] = useState(false); + const [response, setResponse] = useState>(); + const fn = (body: unknown) => { + setCompleteState(false); + return UserInvitationsAction.Fetch( + { + body, + headers: options?.headers, + }, + { + creatorFn: options?.creatorFn, + qs: options?.qs, + ctx, + onMessage: options?.onMessage, + overrideUrl: options?.overrideUrl, + }, + ).then((x) => { + x.done.then(() => { + setCompleteState(true); + }); + setResponse(x.response); + return x.response.result; + }); + }; + const result = useMutation({ + mutationFn: fn, + ...(options || {}), + }); + return { + ...result, + isCompleted, + response, + }; +}; +/** + * UserInvitationsAction + */ +export class UserInvitationsAction { + // + static URL = "/users/invitations"; + static NewUrl = (qs?: URLSearchParams) => + buildUrl(UserInvitationsAction.URL, undefined, qs); + static Method = "get"; + static Fetch$ = async ( + qs?: URLSearchParams, + ctx?: FetchxContext, + init?: TypedRequestInit, + overrideUrl?: string, + ) => { + return fetchx, unknown, unknown>( + overrideUrl ?? UserInvitationsAction.NewUrl(qs), + { + method: UserInvitationsAction.Method, + ...(init || {}), + }, + ctx, + ); + }; + static Fetch = async ( + init?: TypedRequestInit, + { + creatorFn, + qs, + ctx, + onMessage, + overrideUrl, + }: { + creatorFn?: ((item: unknown) => UserInvitationsActionRes) | undefined; + qs?: URLSearchParams; + ctx?: FetchxContext; + onMessage?: (ev: MessageEvent) => void; + overrideUrl?: string; + } = { + creatorFn: (item) => new UserInvitationsActionRes(item), + }, + ) => { + creatorFn = creatorFn || ((item) => new UserInvitationsActionRes(item)); + const res = await UserInvitationsAction.Fetch$(qs, ctx, init, overrideUrl); + return handleFetchResponse( + res, + (data) => { + const resp = new GResponse(); + if (creatorFn) { + resp.setCreator(creatorFn); + } + resp.inject(data); + return resp; + }, + onMessage, + init?.signal, + ); + }; + static Definition = { + name: "UserInvitations", + url: "/users/invitations", + method: "get", + description: + "Shows the invitations for an specific user, if the invited member already has a account. It's based on the passports, so if the passport is authenticated we will show them.", + out: { + envelope: "GResponse", + fields: [ + { + name: "userId", + description: "UserUniqueId", + type: "string", + }, + { + name: "uniqueId", + description: "Invitation unique id", + type: "string", + }, + { + name: "value", + description: "The value of the passport (email/phone)", + type: "string", + }, + { + name: "roleName", + description: "Name of the role that user will get", + type: "string", + }, + { + name: "workspaceName", + description: "Name of the workspace which user is invited to.", + type: "string", + }, + { + name: "type", + description: "The method of the invitation, such as email.", + type: "string", + }, + { + name: "coverLetter", + description: + "The content that user will receive to understand the reason of the letter.", + type: "string", + }, + ], + }, + }; +} +/** + * The base class definition for userInvitationsActionRes + **/ +export class UserInvitationsActionRes { + /** + * UserUniqueId + * @type {string} + **/ + #userId: string = ""; + /** + * UserUniqueId + * @returns {string} + **/ + get userId() { + return this.#userId; + } + /** + * UserUniqueId + * @type {string} + **/ + set userId(value: string) { + this.#userId = String(value); + } + setUserId(value: string) { + this.userId = value; + return this; + } + /** + * Invitation unique id + * @type {string} + **/ + #uniqueId: string = ""; + /** + * Invitation unique id + * @returns {string} + **/ + get uniqueId() { + return this.#uniqueId; + } + /** + * Invitation unique id + * @type {string} + **/ + set uniqueId(value: string) { + this.#uniqueId = String(value); + } + setUniqueId(value: string) { + this.uniqueId = value; + return this; + } + /** + * The value of the passport (email/phone) + * @type {string} + **/ + #value: string = ""; + /** + * The value of the passport (email/phone) + * @returns {string} + **/ + get value() { + return this.#value; + } + /** + * The value of the passport (email/phone) + * @type {string} + **/ + set value(value: string) { + this.#value = String(value); + } + setValue(value: string) { + this.value = value; + return this; + } + /** + * Name of the role that user will get + * @type {string} + **/ + #roleName: string = ""; + /** + * Name of the role that user will get + * @returns {string} + **/ + get roleName() { + return this.#roleName; + } + /** + * Name of the role that user will get + * @type {string} + **/ + set roleName(value: string) { + this.#roleName = String(value); + } + setRoleName(value: string) { + this.roleName = value; + return this; + } + /** + * Name of the workspace which user is invited to. + * @type {string} + **/ + #workspaceName: string = ""; + /** + * Name of the workspace which user is invited to. + * @returns {string} + **/ + get workspaceName() { + return this.#workspaceName; + } + /** + * Name of the workspace which user is invited to. + * @type {string} + **/ + set workspaceName(value: string) { + this.#workspaceName = String(value); + } + setWorkspaceName(value: string) { + this.workspaceName = value; + return this; + } + /** + * The method of the invitation, such as email. + * @type {string} + **/ + #type: string = ""; + /** + * The method of the invitation, such as email. + * @returns {string} + **/ + get type() { + return this.#type; + } + /** + * The method of the invitation, such as email. + * @type {string} + **/ + set type(value: string) { + this.#type = String(value); + } + setType(value: string) { + this.type = value; + return this; + } + /** + * The content that user will receive to understand the reason of the letter. + * @type {string} + **/ + #coverLetter: string = ""; + /** + * The content that user will receive to understand the reason of the letter. + * @returns {string} + **/ + get coverLetter() { + return this.#coverLetter; + } + /** + * The content that user will receive to understand the reason of the letter. + * @type {string} + **/ + set coverLetter(value: string) { + this.#coverLetter = String(value); + } + setCoverLetter(value: string) { + this.coverLetter = value; + return this; + } + constructor(data: unknown = undefined) { + if (data === null || data === undefined) { + return; + } + if (typeof data === "string") { + this.applyFromObject(JSON.parse(data)); + } else if (this.#isJsonAppliable(data)) { + this.applyFromObject(data); + } else { + throw new Error( + "Instance cannot be created on an unknown value, check the content being passed. got: " + + typeof data, + ); + } + } + #isJsonAppliable(obj: unknown) { + const g = globalThis as unknown as { Buffer: any; Blob: any }; + const isBuffer = + typeof g.Buffer !== "undefined" && + typeof g.Buffer.isBuffer === "function" && + g.Buffer.isBuffer(obj); + const isBlob = typeof g.Blob !== "undefined" && obj instanceof g.Blob; + return ( + obj && + typeof obj === "object" && + !Array.isArray(obj) && + !isBuffer && + !(obj instanceof ArrayBuffer) && + !isBlob + ); + } + /** + * casts the fields of a javascript object into the class properties one by one + **/ + applyFromObject(data = {}) { + const d = data as Partial; + if (d.userId !== undefined) { + this.userId = d.userId; + } + if (d.uniqueId !== undefined) { + this.uniqueId = d.uniqueId; + } + if (d.value !== undefined) { + this.value = d.value; + } + if (d.roleName !== undefined) { + this.roleName = d.roleName; + } + if (d.workspaceName !== undefined) { + this.workspaceName = d.workspaceName; + } + if (d.type !== undefined) { + this.type = d.type; + } + if (d.coverLetter !== undefined) { + this.coverLetter = d.coverLetter; + } + } + /** + * Special toJSON override, since the field are private, + * Json stringify won't see them unless we mention it explicitly. + **/ + toJSON() { + return { + userId: this.#userId, + uniqueId: this.#uniqueId, + value: this.#value, + roleName: this.#roleName, + workspaceName: this.#workspaceName, + type: this.#type, + coverLetter: this.#coverLetter, + }; + } + toString() { + return JSON.stringify(this); + } + static get Fields() { + return { + userId: "userId", + uniqueId: "uniqueId", + value: "value", + roleName: "roleName", + workspaceName: "workspaceName", + type: "type", + coverLetter: "coverLetter", + }; + } + /** + * Creates an instance of UserInvitationsActionRes, and possibleDtoObject + * needs to satisfy the type requirement fully, otherwise typescript compile would + * be complaining. + **/ + static from(possibleDtoObject: UserInvitationsActionResType) { + return new UserInvitationsActionRes(possibleDtoObject); + } + /** + * Creates an instance of UserInvitationsActionRes, and partialDtoObject + * needs to satisfy the type, but partially, and rest of the content would + * be constructed according to data types and nullability. + **/ + static with(partialDtoObject: PartialDeep) { + return new UserInvitationsActionRes(partialDtoObject); + } + copyWith( + partial: PartialDeep, + ): InstanceType { + return new UserInvitationsActionRes({ ...this.toJSON(), ...partial }); + } + clone(): InstanceType { + return new UserInvitationsActionRes(this.toJSON()); + } +} +export abstract class UserInvitationsActionResFactory { + abstract create(data: unknown): UserInvitationsActionRes; +} +/** + * The base type definition for userInvitationsActionRes + **/ +export type UserInvitationsActionResType = { + /** + * UserUniqueId + * @type {string} + **/ + userId: string; + /** + * Invitation unique id + * @type {string} + **/ + uniqueId: string; + /** + * The value of the passport (email/phone) + * @type {string} + **/ + value: string; + /** + * Name of the role that user will get + * @type {string} + **/ + roleName: string; + /** + * Name of the workspace which user is invited to. + * @type {string} + **/ + workspaceName: string; + /** + * The method of the invitation, such as email. + * @type {string} + **/ + type: string; + /** + * The content that user will receive to understand the reason of the letter. + * @type {string} + **/ + coverLetter: string; +}; +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace UserInvitationsActionResType {} diff --git a/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/useGetUsersInvitations.ts b/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/useGetUsersInvitations.ts deleted file mode 100644 index f7f6b01ff..000000000 --- a/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/useGetUsersInvitations.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* -* Generated by fireback 1.2.5 -* Written by Ali Torabi. -* The code is generated for react-query@v3.39.3 -* Checkout the repository for licenses and contribution: https://github.com/torabian/fireback -*/ -import { useContext } from "react"; -import { useQuery } from "react-query"; -import { - RemoteQueryContext, - type UseRemoteQuery, - queryBeforeSend, -} from "../../core/react-tools"; -import { stringify } from "qs"; -import { execApiFn, type IResponseList } from "../../core/http-tools"; - import { - UserInvitationsQueryColumns, - } from "../abac/UserInvitationsQueryColumns" -// Fireback gives the option to have typesafe query string -export type GetUsersInvitationsQs = { -} -export type GetUsersInvitationsUrlParams = { -} -export type GetUsersInvitationsHeaders = { -} -export function useGetUsersInvitations({ - queryOptions, - query, - queryClient, - execFnOverride, - unauthorized, - optionFn -}: UseRemoteQuery & {query?: GetUsersInvitationsQs}) { - const { options, execFn } = useContext(RemoteQueryContext); - const computedOptions = optionFn ? optionFn(options) : options; - // Calculare the function which will do the remote calls. - // We consider to use global override, this specific override, or default which - // comes with the sdk. - const rpcFn = execFnOverride - ? execFnOverride(computedOptions) - : execFn - ? execFn(computedOptions) - : execApiFn(computedOptions); - // Url of the remote affix. - const url = "/users/invitations".substr(1); - let computedUrl = `${url}?${stringify(query)}`; - let completeRouteUrls = true; - // Attach the details of the request to the fn - const fn = () => rpcFn("GET", computedUrl); - const auth = computedOptions?.headers?.authorization - const hasKey = auth != "undefined" && auth != undefined && auth !=null && auth != "null" && !!auth - let enabled = true; - if (!completeRouteUrls) { - enabled = false; - } else if (!hasKey && !unauthorized) { - enabled = false; - } - const query$ = useQuery, any>(["*abac.UserInvitationsQueryColumns", computedOptions, query], fn, { - cacheTime: 1000, - retry: false, - keepPreviousData: true, - enabled, - ...((queryOptions as any) || {}) - } as any); - const items: Array = query$.data?.data?.items || []; - return { - query: query$, - items, - keyExtractor: (item: UserInvitationsQueryColumns) => item.uniqueId, - }; -} -useGetUsersInvitations.UKEY = "*abac.UserInvitationsQueryColumns" \ No newline at end of file