@datadog/apps-frontend 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,146 @@
1
+ /* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0.
2
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ * Copyright 2019-Present Datadog, Inc.
4
+ */
5
+
6
+ import { EVERY_SURFACE } from '../embedding/types.js';
7
+ import type { AnyContract, AnyField, AnySchema, Contract, ContractVersion, FunctionField, InferOf, SurfaceId, ValidationOnlySchema, ValueField, ValueSchema } from '../embedding/types.js';
8
+ import type { AnyOlderContractVersion, AnyVersionedContract, VersionedContract } from '../embedding/versioning.js';
9
+ declare const publishedDefinitionBrand: unique symbol;
10
+ /**
11
+ * One published inputs definition: every version it serves, and the surfaces
12
+ * it is offered on.
13
+ *
14
+ * `surfaces` exists for development ergonomics only -- discovery while writing
15
+ * code, and type errors when a host forgets an input its surface offers.
16
+ * Nothing reads it at runtime, and inputs and surfaces are otherwise unrelated:
17
+ * an input is a complete thing without any surface, which is why declaring them
18
+ * is optional. Omitted resolves to every `SurfaceId`, so the hint reads as
19
+ * "available everywhere" rather than as an empty list.
20
+ */
21
+ export type DatadogAppInputsSchema<TLatest extends AnyContract, TSurfaces extends readonly SurfaceId[] = typeof EVERY_SURFACE, TOlderVersions extends readonly AnyOlderContractVersion<TLatest>[] = readonly []> = VersionedContract<TLatest, TOlderVersions> & Readonly<{
22
+ surfaces: TSurfaces;
23
+ }>;
24
+ export type AnyDatadogAppInputsSchema = AnyVersionedContract & Readonly<{
25
+ surfaces: readonly SurfaceId[];
26
+ }>;
27
+ export type PublishedDatadogAppInputsDefinition<TSchema extends AnyDatadogAppInputsSchema> = TSchema & Readonly<{
28
+ [publishedDefinitionBrand]: (fields: TSchema['latest']['fields']) => TSchema['latest']['fields'];
29
+ }>;
30
+ type PortableSchema<TSchema extends AnySchema> = ValueSchema<InferOf<TSchema>>;
31
+ interface PortableValueBuilder {
32
+ readOnly<TSchema extends AnySchema>(schema: ValidationOnlySchema<TSchema>): ValueField<PortableSchema<TSchema>>;
33
+ }
34
+ interface PortableFunctionBuilder {
35
+ readOnly<const TInputs extends Readonly<Record<string, AnySchema>>, TResult extends AnySchema>(definition: Readonly<{
36
+ inputs: {
37
+ readonly [TName in keyof TInputs]: ValidationOnlySchema<TInputs[TName]>;
38
+ };
39
+ result: ValidationOnlySchema<TResult>;
40
+ /**
41
+ * Optional per-function override of `FUNCTION_CALL_TIMEOUT_MS`.
42
+ * See `FunctionField.timeoutMs`.
43
+ */
44
+ timeoutMs?: number;
45
+ }>): FunctionField<{
46
+ readonly [TName in keyof TInputs]: PortableSchema<TInputs[TName]>;
47
+ }, PortableSchema<TResult>>;
48
+ }
49
+ /** Builds an input value field while hiding its concrete validator type. */
50
+ export declare const value: PortableValueBuilder;
51
+ /** Builds an input function field while hiding its concrete validator types. */
52
+ export declare const fn: PortableFunctionBuilder;
53
+ type ValidationOnlyFields<TFields extends Record<string, AnyField>> = {
54
+ readonly [TName in keyof TFields]: TFields[TName] extends ValueField<infer TSchema> ? ValueField<ValidationOnlySchema<TSchema>> : TFields[TName] extends FunctionField<infer TInputs, infer TResult> ? FunctionField<{
55
+ readonly [TInputName in keyof TInputs]: ValidationOnlySchema<TInputs[TInputName]>;
56
+ }, ValidationOnlySchema<TResult>> : never;
57
+ };
58
+ type PortableFields<TFields extends Record<string, AnyField>> = {
59
+ readonly [TName in keyof TFields]: TFields[TName] extends ValueField<infer TSchema> ? ValueField<PortableSchema<TSchema>> : TFields[TName] extends FunctionField<infer TInputs, infer TResult> ? FunctionField<{
60
+ readonly [TInputName in keyof TInputs]: PortableSchema<TInputs[TInputName]>;
61
+ }, PortableSchema<TResult>> : never;
62
+ };
63
+ export type PortableContract<TIdentifier extends string, TVersion extends ContractVersion, TFields extends Record<string, AnyField>> = Contract<PortableFields<TFields>> & Readonly<{
64
+ identifier: TIdentifier;
65
+ version: TVersion;
66
+ }>;
67
+ /**
68
+ * Defines one version of a package-owned input contract. Concrete validator
69
+ * types are deliberately erased at this boundary: schema authors keep full
70
+ * inference while public declarations expose only Standard Schema.
71
+ *
72
+ * A contract on its own cannot be provided to an app -- only
73
+ * `datadogAppInputsDefinition()`'s output can -- so declaring a version is
74
+ * never the same as offering to serve it.
75
+ */
76
+ export declare function datadogAppInputsVersion<const TIdentifier extends string, const TVersion extends ContractVersion, const TFields extends Record<string, AnyField>>(definition: Contract<TFields> & Readonly<{
77
+ identifier: TIdentifier;
78
+ version: TVersion;
79
+ fields: ValidationOnlyFields<TFields>;
80
+ }>): PortableContract<TIdentifier, TVersion, TFields>;
81
+ /**
82
+ * Publishes one package-owned inputs definition.
83
+ *
84
+ * The common case is one version, declared inline -- `identifier`, `version`,
85
+ * `fields`, and optionally the `surfaces` it is offered on. A schema that has
86
+ * to keep serving older versions instead passes `latest` plus `olderVersions`,
87
+ * so the extra step is paid only where extra versions exist.
88
+ *
89
+ * Either way the result is the single unit both sides deal in: an app claims it
90
+ * without naming a version, and a host provides it without learning that more
91
+ * than one exists. Dropping an `olderVersion()` is how support for that version
92
+ * ends, and simultaneously how the fields a host must supply get smaller.
93
+ */
94
+ export declare function datadogAppInputsDefinition<const TIdentifier extends string, const TVersion extends ContractVersion, const TFields extends Record<string, AnyField>, const TSurfaces extends readonly SurfaceId[] = typeof EVERY_SURFACE>(definition: Contract<TFields> & Readonly<{
95
+ identifier: TIdentifier;
96
+ version: TVersion;
97
+ fields: ValidationOnlyFields<TFields>;
98
+ /** Surfaces this input is offered on -- a development-time hint, read by nothing at runtime. */
99
+ surfaces?: TSurfaces;
100
+ }>): PublishedDatadogAppInputsDefinition<DatadogAppInputsSchema<PortableContract<TIdentifier, TVersion, TFields>, TSurfaces>>;
101
+ export declare function datadogAppInputsDefinition<TLatest extends AnyContract, const TSurfaces extends readonly SurfaceId[] = typeof EVERY_SURFACE, const TOlderVersions extends readonly AnyOlderContractVersion<TLatest>[] = readonly []>(definition: Readonly<{
102
+ latest: TLatest;
103
+ surfaces?: TSurfaces;
104
+ olderVersions?: TOlderVersions;
105
+ }>): PublishedDatadogAppInputsDefinition<DatadogAppInputsSchema<TLatest, TSurfaces, TOlderVersions>>;
106
+ /** Rejects copied or user-authored definitions at the public React boundary. */
107
+ export declare function assertPublishedDatadogAppInputsDefinition(definition: unknown): asserts definition is PublishedDatadogAppInputsDefinition<AnyDatadogAppInputsSchema>;
108
+ /**
109
+ * Turns one plain value into the field descriptor that carries it: a function
110
+ * becomes a callable field with validated inputs and result, anything else a
111
+ * read-only value field. This is the inverse of the erasure `value.readOnly()`
112
+ * and `fn.readOnly()` perform, which is what lets a schema be *declared* in the
113
+ * terms a consumer thinks in while being *built* from real validators.
114
+ */
115
+ type FieldFor<TValue> = [TValue] extends [
116
+ (inputs: infer TInputs) => infer TResult
117
+ ] ? FunctionField<{
118
+ readonly [TName in keyof TInputs]: ValueSchema<TInputs[TName]>;
119
+ }, ValueSchema<Awaited<TResult>>> : ValueField<ValueSchema<TValue>>;
120
+ type FieldsFor<TShape extends Readonly<Record<string, unknown>>> = {
121
+ readonly [TName in keyof TShape]: FieldFor<TShape[TName]>;
122
+ };
123
+ /**
124
+ * One Datadog App input, described the way it is used rather than the way it is
125
+ * built: its identifier, the values a claim hands you, and the surfaces it is
126
+ * offered on.
127
+ *
128
+ * This is the type a schema annotates itself with, so it is also what an editor
129
+ * shows on hover. Versions are deliberately absent -- how many exist, and which
130
+ * one a given peer gets, is settled by the package and is not a caller's
131
+ * concern.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * DatadogAppInput<
136
+ * 'datadog.idp.homepage',
137
+ * { position: number; move: (inputs: { delta: number }) => number },
138
+ * readonly ['datadog.idp.homepage']
139
+ * >
140
+ * ```
141
+ */
142
+ export type DatadogAppInput<TIdentifier extends string, TShape extends Readonly<Record<string, unknown>>, TSurfaces extends readonly SurfaceId[] = typeof EVERY_SURFACE> = PublishedDatadogAppInputsDefinition<DatadogAppInputsSchema<Contract<FieldsFor<TShape>> & Readonly<{
143
+ identifier: TIdentifier;
144
+ version: ContractVersion;
145
+ }>, TSurfaces>>;
146
+ export {};
@@ -0,0 +1,7 @@
1
+ /* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0.
2
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ * Copyright 2019-Present Datadog, Inc.
4
+ */
5
+
6
+ export { useDatadogAppInput } from './use-datadog-app-input.js';
7
+ export type { DatadogAppInputState } from './use-datadog-app-input.js';
@@ -0,0 +1,7 @@
1
+ /* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0.
2
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ * Copyright 2019-Present Datadog, Inc.
4
+ */
5
+
6
+ import{d as i}from"../../_chunks/chunk-2V2HASKF.js";import{c as n}from"../../_chunks/chunk-NCWC7QOQ.js";import"../../_chunks/chunk-X34MSTJH.js";import{useSyncExternalStore as p}from"react";function a(e){let o=i();n(e);let t=o.getClaim(e.latest);return p(t.subscribe,t.getSnapshot,t.getSnapshot)}export{a as useDatadogAppInput};
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/inputs/react/use-datadog-app-input.ts"],
4
+ "sourcesContent": ["import { useSyncExternalStore } from 'react';\n\nimport { useAppEmbedding } from '../../embedding/react/context';\nimport type { ClaimState } from '../../embedding/types';\nimport { assertPublishedDatadogAppInputsDefinition } from '../published-definition';\nimport type { DatadogAppInputDefinition } from '../schemas/index';\n\n/**\n * What {@link useDatadogAppInput} gives back for one input: `pending` while the\n * connection or claim is in flight, `ready` with validated `fields`, `unavailable`\n * when this host does not provide the input, or `failed` with an actionable\n * `error`. `fields` exists only on `ready`, so stale values can never be read as\n * live.\n *\n * Named in terms of the input rather than the contract behind it -- which\n * version is being served is not a caller's concern.\n */\nexport type DatadogAppInputState<\n TDefinition extends DatadogAppInputDefinition,\n> = ClaimState<TDefinition['latest']>;\n\n/**\n * A type that refuses to match while saying why.\n *\n * A compiler error is the one piece of documentation a caller cannot skip, so\n * rejections here resolve to a sentence rather than to a bare `never` -- the\n * message becomes the error text, at the call site, in the editor.\n */\ntype Rejected<TMessage extends string> = Readonly<{\n __datadogAppInputsError: TMessage;\n}>;\n\ntype PublishedDefinitionFor<TDefinition extends DatadogAppInputDefinition> =\n Extract<\n DatadogAppInputDefinition,\n Readonly<{ identifier: TDefinition['identifier'] }>\n >;\n\ntype NoExtraFields<TDefinition extends DatadogAppInputDefinition> =\n Exclude<\n keyof TDefinition['latest']['fields'],\n keyof PublishedDefinitionFor<TDefinition>['latest']['fields']\n > extends never\n ? unknown\n : Rejected<'This definition has fields the published one does not. Pass a definition exported from @datadog/apps-frontend/inputs/schema, unmodified.'>;\n\n/**\n * Claims one Datadog App input and tracks its state across renders. Call it\n * below {@link DatadogAppProvider}.\n *\n * Pass a definition exported from `@datadog/apps-frontend/inputs/schema` --\n * {@link datadogTheme} is one. Hovering a definition shows the surfaces it is\n * offered on; the returned {@link ClaimState} says whether its values are usable\n * yet, and carries `fields` only while they are.\n *\n * Versions are not a caller's concern: this claims whichever version the\n * installed copy of the package treats as latest. An older copy asks for an\n * older version and keeps working for as long as the host still converts to it.\n * Past that the claim fails with `APP_MAJOR_TOO_OLD` -- update this package and\n * re-upload the app -- rather than silently degrading.\n *\n * @param definition An input definition from `@datadog/apps-frontend/inputs/schema`.\n * @returns The claim's current state: `pending`, `ready` (with `fields`),\n * `unavailable` when this host does not provide the input, or `failed` with an\n * actionable `error`.\n */\nexport function useDatadogAppInput<\n const TDefinition extends DatadogAppInputDefinition,\n>(\n definition: TDefinition & NoExtraFields<TDefinition>,\n): DatadogAppInputState<TDefinition> {\n const embedding = useAppEmbedding();\n assertPublishedDatadogAppInputsDefinition(definition);\n const store = embedding.getClaim<TDefinition['latest']>(definition.latest);\n return useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n store.getSnapshot,\n );\n}\n"],
5
+ "mappings": "gJAAA,OAAS,wBAAAA,MAA4B,QAkE9B,SAASC,EAGZC,EACiC,CACjC,IAAMC,EAAYC,EAAgB,EAClCC,EAA0CH,CAAU,EACpD,IAAMI,EAAQH,EAAU,SAAgCD,EAAW,MAAM,EACzE,OAAOK,EACHD,EAAM,UACNA,EAAM,YACNA,EAAM,WACV,CACJ",
6
+ "names": ["useSyncExternalStore", "useDatadogAppInput", "definition", "embedding", "useAppEmbedding", "assertPublishedDatadogAppInputsDefinition", "store", "useSyncExternalStore"]
7
+ }
@@ -0,0 +1,54 @@
1
+ /* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0.
2
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ * Copyright 2019-Present Datadog, Inc.
4
+ */
5
+
6
+ import type { ClaimState } from '../../embedding/types.js';
7
+ import type { DatadogAppInputDefinition } from '../schemas/index.js';
8
+ /**
9
+ * What {@link useDatadogAppInput} gives back for one input: `pending` while the
10
+ * connection or claim is in flight, `ready` with validated `fields`, `unavailable`
11
+ * when this host does not provide the input, or `failed` with an actionable
12
+ * `error`. `fields` exists only on `ready`, so stale values can never be read as
13
+ * live.
14
+ *
15
+ * Named in terms of the input rather than the contract behind it -- which
16
+ * version is being served is not a caller's concern.
17
+ */
18
+ export type DatadogAppInputState<TDefinition extends DatadogAppInputDefinition> = ClaimState<TDefinition['latest']>;
19
+ /**
20
+ * A type that refuses to match while saying why.
21
+ *
22
+ * A compiler error is the one piece of documentation a caller cannot skip, so
23
+ * rejections here resolve to a sentence rather than to a bare `never` -- the
24
+ * message becomes the error text, at the call site, in the editor.
25
+ */
26
+ type Rejected<TMessage extends string> = Readonly<{
27
+ __datadogAppInputsError: TMessage;
28
+ }>;
29
+ type PublishedDefinitionFor<TDefinition extends DatadogAppInputDefinition> = Extract<DatadogAppInputDefinition, Readonly<{
30
+ identifier: TDefinition['identifier'];
31
+ }>>;
32
+ type NoExtraFields<TDefinition extends DatadogAppInputDefinition> = Exclude<keyof TDefinition['latest']['fields'], keyof PublishedDefinitionFor<TDefinition>['latest']['fields']> extends never ? unknown : Rejected<'This definition has fields the published one does not. Pass a definition exported from @datadog/apps-frontend/inputs/schema, unmodified.'>;
33
+ /**
34
+ * Claims one Datadog App input and tracks its state across renders. Call it
35
+ * below {@link DatadogAppProvider}.
36
+ *
37
+ * Pass a definition exported from `@datadog/apps-frontend/inputs/schema` --
38
+ * {@link datadogTheme} is one. Hovering a definition shows the surfaces it is
39
+ * offered on; the returned {@link ClaimState} says whether its values are usable
40
+ * yet, and carries `fields` only while they are.
41
+ *
42
+ * Versions are not a caller's concern: this claims whichever version the
43
+ * installed copy of the package treats as latest. An older copy asks for an
44
+ * older version and keeps working for as long as the host still converts to it.
45
+ * Past that the claim fails with `APP_MAJOR_TOO_OLD` -- update this package and
46
+ * re-upload the app -- rather than silently degrading.
47
+ *
48
+ * @param definition An input definition from `@datadog/apps-frontend/inputs/schema`.
49
+ * @returns The claim's current state: `pending`, `ready` (with `fields`),
50
+ * `unavailable` when this host does not provide the input, or `failed` with an
51
+ * actionable `error`.
52
+ */
53
+ export declare function useDatadogAppInput<const TDefinition extends DatadogAppInputDefinition>(definition: TDefinition & NoExtraFields<TDefinition>): DatadogAppInputState<TDefinition>;
54
+ export {};
@@ -0,0 +1,30 @@
1
+ /* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0.
2
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ * Copyright 2019-Present Datadog, Inc.
4
+ */
5
+
6
+ import type { DatadogAppInput } from '../published-definition.js';
7
+ import type { DatadogAppInputImplementations } from '../types.js';
8
+ /**
9
+ * One field, named `dashboard`, holding the same shape every dashboard mount
10
+ * site already passes as `inputs.dashboard` -- so that object can be forwarded
11
+ * to `datadogDashboard` unchanged, with no reshaping in between.
12
+ */
13
+ export declare const datadogDashboard: DatadogAppInput<'datadog.dashboard', {
14
+ dashboard: {
15
+ timeframe: {
16
+ start: number;
17
+ end: number;
18
+ isLive: boolean;
19
+ };
20
+ templateVariables: {
21
+ name: string;
22
+ value: string;
23
+ values?: string[];
24
+ prefix?: string;
25
+ default?: string;
26
+ }[];
27
+ };
28
+ }, readonly ['datadog.dashboard']>;
29
+ /** The dashboard state a host provides to `datadogDashboard`. */
30
+ export type DashboardInputs = DatadogAppInputImplementations<typeof datadogDashboard>;
@@ -0,0 +1,25 @@
1
+ /* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0.
2
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ * Copyright 2019-Present Datadog, Inc.
4
+ */
5
+
6
+ /**
7
+ * `@datadog/apps-frontend/inputs/schema`'s npm entry. Anything defined under
8
+ * this directory that should reach consumers of the published package must
9
+ * be exported from this file -- not from any individual schema module.
10
+ *
11
+ * Exporting a schema here is the whole of publishing it:
12
+ * `DatadogAppInputDefinition` is derived from what this file hands out, so the
13
+ * hook accepts exactly that and nothing else.
14
+ */
15
+ import type { AnyDatadogAppInputsSchema } from '../published-definition.js';
16
+ export { datadogTheme } from './theme.js';
17
+ export type { DatadogAppTheme } from './theme.js';
18
+ export { datadogDashboard } from './dashboard.js';
19
+ export type { DashboardInputs } from './dashboard.js';
20
+ /**
21
+ * Every published input an app may claim -- read off this module's own exports,
22
+ * so exporting a schema above is the whole of publishing it. There is no second
23
+ * list to keep in step, and `useDatadogAppInput` widens automatically.
24
+ */
25
+ export type DatadogAppInputDefinition = Extract<(typeof import('./index.js'))[keyof typeof import('./index.js')], AnyDatadogAppInputsSchema>;
@@ -0,0 +1,7 @@
1
+ /* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0.
2
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ * Copyright 2019-Present Datadog, Inc.
4
+ */
5
+
6
+ import{a as O,b as T}from"../../_chunks/chunk-NCWC7QOQ.js";import"../../_chunks/chunk-X34MSTJH.js";var Me=Object.freeze({status:"aborted"});function g(e,t,r){function n(u,m){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:m,constr:o,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,m);let p=o.prototype,f=Object.keys(p);for(let v=0;v<f.length;v++){let $=f[v];$ in u||(u[$]=p[$].bind(u))}}let i=r?.Parent??Object;class d extends i{}Object.defineProperty(d,"name",{value:e});function o(u){var m;let p=r?.Parent?new d:this;n(p,u),(m=p._zod).deferred??(m.deferred=[]);for(let f of p._zod.deferred)f();return p}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:u=>r?.Parent&&u instanceof r.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var _=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};var K={};function b(e){return e&&Object.assign(K,e),K}function B(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function ie(e,t){return typeof t=="bigint"?t.toString():t}function X(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function oe(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var ne=Symbol("evaluating");function z(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==ne)return n===void 0&&(n=ne,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}var q="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Le=X(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});var ue=new Set(["string","number","symbol"]);function E(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function A(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function y(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ce(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Re={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function j(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function M(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function N(e){return typeof e=="string"?e:e?.message}function I(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=N(e.inst?._zod.def?.error?.(e))??N(t?.error?.(e))??N(r.customError?.(e))??N(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}var le=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ie,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},se=g("$ZodError",le),U=g("$ZodError",le,{Parent:Error});var Fe=e=>(t,r,n,i)=>{let d=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:r,issues:[]},d);if(o instanceof Promise)throw new _;if(o.issues.length){let u=new(i?.Err??e)(o.issues.map(m=>I(m,d,b())));throw q(u,i?.callee),u}return o.value},L=Fe(U),Ve=e=>async(t,r,n,i)=>{let d=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},d);if(o instanceof Promise&&(o=await o),o.issues.length){let u=new(i?.Err??e)(o.issues.map(m=>I(m,d,b())));throw q(u,i?.callee),u}return o.value},R=Ve(U),Je=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},d=t._zod.run({value:r,issues:[]},i);if(d instanceof Promise)throw new _;return d.issues.length?{success:!1,error:new(e??se)(d.issues.map(o=>I(o,i,b())))}:{success:!0,data:d.value}},Z=Je(U),Ge=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},d=t._zod.run({value:r,issues:[]},i);return d instanceof Promise&&(d=await d),d.issues.length?{success:!1,error:new e(d.issues.map(o=>I(o,i,b())))}:{success:!0,data:d.value}},P=Ge(U);var Ke="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",We=new RegExp(`^${Ke}$`);var de=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var me=/^-?\d+(?:\.\d+)?$/,pe=/^(?:true|false)$/i;var ge={major:4,minor:3,patch:6};var h=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ge;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let d of i._zod.onattach)d(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(o,u,m)=>{let p=j(o),f;for(let v of u){if(v._zod.def.when){if(!v._zod.def.when(o))continue}else if(p)continue;let $=o.issues.length,x=v._zod.check(o);if(x instanceof Promise&&m?.async===!1)throw new _;if(f||x instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await x,o.issues.length!==$&&(p||(p=j(o,$)))});else{if(o.issues.length===$)continue;p||(p=j(o,$))}}return f?f.then(()=>o):o},d=(o,u,m)=>{if(j(o))return o.aborted=!0,o;let p=i(u,n,m);if(p instanceof Promise){if(m.async===!1)throw new _;return p.then(f=>e._zod.parse(f,m))}return e._zod.parse(p,m)};e._zod.run=(o,u)=>{if(u.skipChecks)return e._zod.parse(o,u);if(u.direction==="backward"){let p=e._zod.parse({value:o.value,issues:[]},{...u,skipChecks:!0});return p instanceof Promise?p.then(f=>d(f,o,u)):d(p,o,u)}let m=e._zod.parse(o,u);if(m instanceof Promise){if(u.async===!1)throw new _;return m.then(p=>i(p,n,u))}return i(m,n,u)}}z(e,"~standard",()=>({validate:i=>{try{let d=Z(e,i);return d.success?{value:d.data}:{issues:d.error?.issues}}catch{return P(e,i).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),Y=g("$ZodString",(e,t)=>{h.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??de(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var _e=g("$ZodNumber",(e,t)=>{h.init(e,t),e._zod.pattern=e._zod.bag.pattern??me,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let d=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...d?{received:d}:{}}),r}});var H=g("$ZodBoolean",(e,t)=>{h.init(e,t),e._zod.pattern=pe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}});function ve(e,t,r){e.issues.length&&t.issues.push(...M(r,e.issues)),t.value[r]=e.value}var xe=g("$ZodArray",(e,t)=>{h.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let d=[];for(let o=0;o<i.length;o++){let u=i[o],m=t.element._zod.run({value:u,issues:[]},n);m instanceof Promise?d.push(m.then(p=>ve(p,r,o))):ve(m,r,o)}return d.length?Promise.all(d).then(()=>r):r}});function C(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(...M(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Xe(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=ce(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function qe(e,t,r,n,i,d){let o=[],u=i.keySet,m=i.catchall._zod,p=m.def.type,f=m.optout==="optional";for(let v in t){if(u.has(v))continue;if(p==="never"){o.push(v);continue}let $=m.run({value:t[v],issues:[]},n);$ instanceof Promise?e.push($.then(x=>C(x,r,v,t,f))):C($,r,v,t,f)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:d}),e.length?Promise.all(e).then(()=>r):r}var ye=g("$ZodObject",(e,t)=>{if(h.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let u=t.shape;Object.defineProperty(t,"shape",{get:()=>{let m={...u};return Object.defineProperty(t,"shape",{value:m}),m}})}let n=X(()=>Xe(t));z(e._zod,"propValues",()=>{let u=t.shape,m={};for(let p in u){let f=u[p]._zod;if(f.values){m[p]??(m[p]=new Set);for(let v of f.values)m[p].add(v)}}return m});let i=ae,d=t.catchall,o;e._zod.parse=(u,m)=>{o??(o=n.value);let p=u.value;if(!i(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value={};let f=[],v=o.shape;for(let $ of o.keys){let x=v[$],w=x._zod.optout==="optional",G=x._zod.run({value:p[$],issues:[]},m);G instanceof Promise?f.push(G.then(Ae=>C(Ae,u,$,p,w))):C(G,u,$,p,w)}return d?qe(f,p,u,m,n.value,e):f.length?Promise.all(f).then(()=>u):u}});var be=g("$ZodEnum",(e,t)=>{h.init(e,t);let r=B(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(i=>ue.has(typeof i)).map(i=>typeof i=="string"?E(i):i.toString()).join("|")})$`),e._zod.parse=(i,d)=>{let o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:r,input:o,inst:e}),i}});function $e(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var ze=g("$ZodOptional",(e,t)=>{h.init(e,t),e._zod.optin="optional",e._zod.optout="optional",z(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),z(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${oe(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(d=>$e(d,r.value)):$e(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var Ie;var Q=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Se(){return new Q}(Ie=globalThis).__zod_globalRegistry??(Ie.__zod_globalRegistry=Se());var ee=globalThis.__zod_globalRegistry;function we(e,t){return new e({type:"string",...y(t)})}function je(e,t){return new e({type:"number",checks:[],...y(t)})}function Ue(e,t){return new e({type:"boolean",...y(t)})}var k=g("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");h.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>L(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Z(e,r,n),e.parseAsync=async(r,n)=>R(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>P(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>A(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Ze=g("ZodMiniString",(e,t)=>{Y.init(e,t),k.init(e,t)});function S(e){return we(Ze,e)}var Pe=g("ZodMiniNumber",(e,t)=>{_e.init(e,t),k.init(e,t)});function te(e){return je(Pe,e)}var De=g("ZodMiniBoolean",(e,t)=>{H.init(e,t),k.init(e,t)});function Oe(e){return Ue(De,e)}var lt=g("ZodMiniArray",(e,t)=>{xe.init(e,t),k.init(e,t)});function re(e,t){return new lt({type:"array",element:e,...y(t)})}var st=g("ZodMiniObject",(e,t)=>{ye.init(e,t),k.init(e,t),z(e,"shape",()=>t.shape)});function V(e,t){let r={type:"object",shape:e??{},...y(t)};return new st(r)}var dt=g("ZodMiniEnum",(e,t)=>{be.init(e,t),k.init(e,t),e.options=Object.values(t.entries)});function Te(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new dt({type:"enum",entries:r,...y(t)})}var mt=g("ZodMiniOptional",(e,t)=>{ze.init(e,t),k.init(e,t)});function J(e){return new mt({type:"optional",innerType:e})}var ht=T({identifier:"datadog.theme",version:1,fields:{theme:O.readOnly(Te(["light","dark"]))}});var _t=V({name:S(),value:S(),values:J(re(S())),prefix:J(S()),default:J(S())}),xt=V({start:te(),end:te(),isLive:Oe()}),yt=V({timeframe:xt,templateVariables:re(_t)}),bt=T({identifier:"datadog.dashboard",version:1,surfaces:["datadog.dashboard"],fields:{dashboard:O.readOnly(yt)}});export{bt as datadogDashboard,ht as datadogTheme};
7
+ //# sourceMappingURL=index.js.map