import * as HttpClient from "effect/unstable/http/HttpClient";
import * as redacted from "effect/Redacted";
import * as S from "effect/Schema";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import * as C from "../category.js";
import { SensitiveString } from "../sensitive.js";
const svc = T.AwsApiService({
    sdkId: "Personalize Events",
    serviceShapeName: "AmazonPersonalizeEvents",
});
const auth = T.AwsAuthSigv4({ name: "personalize" });
const ver = T.ServiceVersion("2018-03-22");
const proto = T.AwsProtocolsRestJson1();
const rules = T.EndpointResolver((p, _) => {
    const { Region, UseDualStack = false, UseFIPS = false, Endpoint } = p;
    const e = (u, p = {}, h = {}) => ({
        type: "endpoint",
        endpoint: { url: u, properties: p, headers: h },
    });
    const err = (m) => ({
        type: "error",
        message: m,
    });
    if (Endpoint != null) {
        if (UseFIPS === true) {
            return err("Invalid Configuration: FIPS and custom endpoint are not supported");
        }
        if (UseDualStack === true) {
            return err("Invalid Configuration: Dualstack and custom endpoint are not supported");
        }
        return e(Endpoint);
    }
    if (Region != null) {
        {
            const PartitionResult = _.partition(Region);
            if (PartitionResult != null && PartitionResult !== false) {
                if (UseFIPS === true && UseDualStack === true) {
                    if (true === _.getAttr(PartitionResult, "supportsFIPS") &&
                        true === _.getAttr(PartitionResult, "supportsDualStack")) {
                        return e(`https://personalize-events-fips.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("FIPS and DualStack are enabled, but this partition does not support one or both");
                }
                if (UseFIPS === true) {
                    if (_.getAttr(PartitionResult, "supportsFIPS") === true) {
                        return e(`https://personalize-events-fips.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
                    }
                    return err("FIPS is enabled but this partition does not support FIPS");
                }
                if (UseDualStack === true) {
                    if (true === _.getAttr(PartitionResult, "supportsDualStack")) {
                        return e(`https://personalize-events.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://personalize-events.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const ActionImpression = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(SensitiveString);
export const ActionInteraction = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    actionId: SensitiveString,
    userId: S.optional(SensitiveString),
    sessionId: S.String,
    timestamp: S.Date.pipe(T.TimestampFormat("epoch-seconds")),
    eventType: S.String,
    eventId: S.optional(S.String),
    recommendationId: S.optional(S.String),
    impression: S.optional(ActionImpression),
    properties: S.optional(SensitiveString),
})).annotate({
    identifier: "ActionInteraction",
});
export const ActionInteractionsList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(ActionInteraction);
export const PutActionInteractionsRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    trackingId: S.String,
    actionInteractions: ActionInteractionsList,
}).pipe(T.all(T.Http({ method: "POST", uri: "/action-interactions" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "PutActionInteractionsRequest",
});
export const PutActionInteractionsResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "PutActionInteractionsResponse",
});
export const Action = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ actionId: S.String, properties: S.optional(SensitiveString) })).annotate({ identifier: "Action" });
export const ActionList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Action);
export const PutActionsRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ datasetArn: S.String, actions: ActionList }).pipe(T.all(T.Http({ method: "POST", uri: "/actions" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "PutActionsRequest",
});
export const PutActionsResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "PutActionsResponse",
});
export const Impression = /*@__PURE__*/ /*#__PURE__*/ S.Array(SensitiveString);
export const MetricAttribution = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ eventAttributionSource: S.String })).annotate({
    identifier: "MetricAttribution",
});
export const Event = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    eventId: S.optional(S.String),
    eventType: S.String,
    eventValue: S.optional(S.Number),
    itemId: S.optional(SensitiveString),
    properties: S.optional(SensitiveString),
    sentAt: S.Date.pipe(T.TimestampFormat("epoch-seconds")),
    recommendationId: S.optional(S.String),
    impression: S.optional(Impression),
    metricAttribution: S.optional(MetricAttribution),
})).annotate({ identifier: "Event" });
export const EventList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Event);
export const PutEventsRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    trackingId: S.String,
    userId: S.optional(SensitiveString),
    sessionId: S.String,
    eventList: EventList,
}).pipe(T.all(T.Http({ method: "POST", uri: "/events" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "PutEventsRequest",
});
export const PutEventsResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "PutEventsResponse",
});
export const Item = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ itemId: S.String, properties: S.optional(SensitiveString) })).annotate({ identifier: "Item" });
export const ItemList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Item);
export const PutItemsRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ datasetArn: S.String, items: ItemList }).pipe(T.all(T.Http({ method: "POST", uri: "/items" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "PutItemsRequest",
});
export const PutItemsResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "PutItemsResponse",
});
export const User = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ userId: S.String, properties: S.optional(SensitiveString) })).annotate({ identifier: "User" });
export const UserList = /*@__PURE__*/ /*#__PURE__*/ S.Array(User);
export const PutUsersRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ datasetArn: S.String, users: UserList }).pipe(T.all(T.Http({ method: "POST", uri: "/users" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "PutUsersRequest",
});
export const PutUsersResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "PutUsersResponse",
});
//# Errors
export class InvalidInputException extends S.TaggedErrorClass()("InvalidInputException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class ResourceInUseException extends S.TaggedErrorClass()("ResourceInUseException", { message: S.optional(S.String) }).pipe(C.withConflictError) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
/**
 * Records action interaction event data. An *action interaction* event is an interaction between a user and an *action*.
 * For example, a user taking an action, such a enrolling in a membership program or downloading your app.
 *
 * For more information about recording action interactions, see Recording action interaction events.
 * For more information about actions in an Actions dataset, see Actions dataset.
 */
export const putActionInteractions = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PutActionInteractionsRequest,
    output: PutActionInteractionsResponse,
    errors: [
        InvalidInputException,
        ResourceInUseException,
        ResourceNotFoundException,
    ],
}));
/**
 * Adds one or more actions to an Actions dataset. For more information see
 * Importing actions individually.
 */
export const putActions = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PutActionsRequest,
    output: PutActionsResponse,
    errors: [
        InvalidInputException,
        ResourceInUseException,
        ResourceNotFoundException,
    ],
}));
/**
 * Records item interaction event data. For more information see
 * Recording item interaction events.
 */
export const putEvents = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PutEventsRequest,
    output: PutEventsResponse,
    errors: [InvalidInputException],
}));
/**
 * Adds one or more items to an Items dataset. For more information see
 * Importing items individually.
 */
export const putItems = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PutItemsRequest,
    output: PutItemsResponse,
    errors: [
        InvalidInputException,
        ResourceInUseException,
        ResourceNotFoundException,
    ],
}));
/**
 * Adds one or more users to a Users dataset. For more information see
 * Importing users individually.
 */
export const putUsers = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PutUsersRequest,
    output: PutUsersResponse,
    errors: [
        InvalidInputException,
        ResourceInUseException,
        ResourceNotFoundException,
    ],
}));
//# sourceMappingURL=personalize-events.js.map