UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

270 lines 10.6 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../lib/schemas.js"; import * as types from "../types/primitives.js"; import { smartUnion } from "../types/smartUnion.js"; export const SegmentOutcomeDataRulesType = { Entity: "entity", }; export const SegmentRhsDataType = { Regex: "regex", }; export const SegmentRhsType = { List: "list", ListInline: "list/inline", }; export const SegmentCmp = { NotContains: "!contains", NotEndsWith: "!endsWith", NotEq: "!eq", NotEx: "!ex", NotOneOf: "!oneOf", NotRegex: "!regex", NotStartsWith: "!startsWith", After: "after", Before: "before", Contains: "contains", ContainsAllOf: "containsAllOf", ContainsAnyOf: "containsAnyOf", ContainsNoneOf: "containsNoneOf", EndsWith: "endsWith", Eq: "eq", Ex: "ex", Gt: "gt", Gte: "gte", Lt: "lt", Lte: "lte", OneOf: "oneOf", Regex: "regex", StartsWith: "startsWith", }; export const SegmentTypeName = { Segment: "segment", }; /** @internal */ export const SegmentOutcomeDataRulesType$inboundSchema = z.nativeEnum(SegmentOutcomeDataRulesType); /** @internal */ export const SegmentOutcomeBase$inboundSchema = z.object({ type: SegmentOutcomeDataRulesType$inboundSchema, kind: types.string(), attribute: types.string(), }); export function segmentOutcomeBaseFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentOutcomeBase$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentOutcomeBase' from JSON`); } /** @internal */ export const SegmentOutcome2$inboundSchema = z.object({ type: types.literal("split"), base: z.lazy(() => SegmentOutcomeBase$inboundSchema), passPromille: types.number(), }); export function segmentOutcome2FromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentOutcome2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentOutcome2' from JSON`); } /** @internal */ export const SegmentOutcome1$inboundSchema = z.object({ type: types.literal("all"), }); export function segmentOutcome1FromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentOutcome1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentOutcome1' from JSON`); } /** @internal */ export const SegmentOutcome$inboundSchema = z.union([ z.lazy(() => SegmentOutcome1$inboundSchema), z.lazy(() => SegmentOutcome2$inboundSchema), ]); export function segmentOutcomeFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentOutcome$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentOutcome' from JSON`); } /** @internal */ export const SegmentRhsDataType$inboundSchema = z.nativeEnum(SegmentRhsDataType); /** @internal */ export const SegmentRhs4$inboundSchema = z.object({ type: SegmentRhsDataType$inboundSchema, pattern: types.string(), flags: types.string(), }); export function segmentRhs4FromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentRhs4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentRhs4' from JSON`); } /** @internal */ export const SegmentRhsType$inboundSchema = z.nativeEnum(SegmentRhsType); /** @internal */ export const SegmentItems2$inboundSchema = z.object({ label: types.optional(types.string()), note: types.optional(types.string()), value: types.string(), }); export function segmentItems2FromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentItems2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentItems2' from JSON`); } /** @internal */ export const SegmentItems1$inboundSchema = z.object({ label: types.optional(types.string()), note: types.optional(types.string()), value: types.number(), }); export function segmentItems1FromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentItems1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentItems1' from JSON`); } /** @internal */ export const SegmentRhsItems$inboundSchema = smartUnion([ z.lazy(() => SegmentItems1$inboundSchema), z.lazy(() => SegmentItems2$inboundSchema), ]); export function segmentRhsItemsFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentRhsItems$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentRhsItems' from JSON`); } /** @internal */ export const SegmentRhs3$inboundSchema = z.object({ type: SegmentRhsType$inboundSchema, items: z.array(smartUnion([ z.lazy(() => SegmentItems1$inboundSchema), z.lazy(() => SegmentItems2$inboundSchema), ])), }); export function segmentRhs3FromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentRhs3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentRhs3' from JSON`); } /** @internal */ export const SegmentRhs$inboundSchema = smartUnion([ z.lazy(() => SegmentRhs4$inboundSchema), z.lazy(() => SegmentRhs3$inboundSchema), types.string(), types.number(), types.boolean(), ]); export function segmentRhsFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentRhs$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentRhs' from JSON`); } /** @internal */ export const SegmentCmpOptions$inboundSchema = z.object({ ignoreCase: types.optional(types.boolean()), }); export function segmentCmpOptionsFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentCmpOptions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentCmpOptions' from JSON`); } /** @internal */ export const SegmentLhs2$inboundSchema = z.object({ type: types.literal("entity"), kind: types.string(), attribute: types.string(), }); export function segmentLhs2FromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentLhs2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentLhs2' from JSON`); } /** @internal */ export const SegmentLhs1$inboundSchema = z.object({ type: types.literal("segment"), }); export function segmentLhs1FromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentLhs1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentLhs1' from JSON`); } /** @internal */ export const SegmentLhs$inboundSchema = z.union([ z.lazy(() => SegmentLhs1$inboundSchema), z.lazy(() => SegmentLhs2$inboundSchema), ]); export function segmentLhsFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentLhs$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentLhs' from JSON`); } /** @internal */ export const SegmentCmp$inboundSchema = z .nativeEnum(SegmentCmp); /** @internal */ export const SegmentConditions$inboundSchema = z.object({ rhs: types.optional(smartUnion([ z.lazy(() => SegmentRhs4$inboundSchema), z.lazy(() => SegmentRhs3$inboundSchema), types.string(), types.number(), types.boolean(), ])), cmpOptions: types.optional(z.lazy(() => SegmentCmpOptions$inboundSchema)), lhs: z.union([ z.lazy(() => SegmentLhs1$inboundSchema), z.lazy(() => SegmentLhs2$inboundSchema), ]), cmp: SegmentCmp$inboundSchema, }); export function segmentConditionsFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentConditions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentConditions' from JSON`); } /** @internal */ export const SegmentRules$inboundSchema = z.object({ id: types.string(), outcome: z.union([ z.lazy(() => SegmentOutcome1$inboundSchema), z.lazy(() => SegmentOutcome2$inboundSchema), ]), conditions: z.array(z.lazy(() => SegmentConditions$inboundSchema)), }); export function segmentRulesFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentRules$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentRules' from JSON`); } /** @internal */ export const Include$inboundSchema = z.object({ note: types.optional(types.string()), value: types.string(), }); export function includeFromJSON(jsonString) { return safeParse(jsonString, (x) => Include$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Include' from JSON`); } /** @internal */ export const ExcludeT$inboundSchema = z.object({ note: types.optional(types.string()), value: types.string(), }); export function excludeFromJSON(jsonString) { return safeParse(jsonString, (x) => ExcludeT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExcludeT' from JSON`); } /** @internal */ export const Data$inboundSchema = z .object({ rules: types.optional(z.array(z.lazy(() => SegmentRules$inboundSchema))), include: types.optional(z.record(z.record(z.array(z.lazy(() => Include$inboundSchema))))), exclude: types.optional(z.record(z.record(z.array(z.lazy(() => ExcludeT$inboundSchema))))), }); export function dataFromJSON(jsonString) { return safeParse(jsonString, (x) => Data$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Data' from JSON`); } /** @internal */ export const SegmentTypeName$inboundSchema = z.nativeEnum(SegmentTypeName); /** @internal */ export const SegmentCreator$inboundSchema = z.object({ id: types.string(), name: types.string(), }); export function segmentCreatorFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentCreator$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentCreator' from JSON`); } /** @internal */ export const SegmentMetadata$inboundSchema = z.object({ creator: types.optional(z.lazy(() => SegmentCreator$inboundSchema)), }); export function segmentMetadataFromJSON(jsonString) { return safeParse(jsonString, (x) => SegmentMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SegmentMetadata' from JSON`); } /** @internal */ export const Segment$inboundSchema = z.object({ description: types.optional(types.string()), createdBy: types.optional(types.string()), usedByFlags: types.optional(z.array(types.string())), usedBySegments: types.optional(z.array(types.string())), data: z.lazy(() => Data$inboundSchema), id: types.string(), label: types.string(), slug: types.string(), createdAt: types.number(), updatedAt: types.number(), projectId: types.string(), typeName: SegmentTypeName$inboundSchema, hint: types.string(), metadata: types.optional(z.lazy(() => SegmentMetadata$inboundSchema)), }); export function segmentFromJSON(jsonString) { return safeParse(jsonString, (x) => Segment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Segment' from JSON`); } //# sourceMappingURL=segment.js.map