@diagonal-hq/cli 0.0.0-stage → 0.2.0

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,10 @@
1
+ declare global {
2
+ interface Console {
3
+ log(...values: unknown[]): void;
4
+ info(...values: unknown[]): void;
5
+ warn(...values: unknown[]): void;
6
+ error(...values: unknown[]): void;
7
+ }
8
+ var console: Console;
9
+ }
10
+ export {};
@@ -0,0 +1,124 @@
1
+ import { type DataCountInput, type DataCreateInput, type DataCreateManyInput, type DataDeleteInput, type DataDeleteManyInput, type DataDeleteManyOutput, type DataFindInput, type DataFindOrCreateInput, type DataRestoreInput, type DataSearchInput, type DataSearchOutput, type DataUpdateInput, type DataUpdateOrCreateInput } from './generated/capabilities';
2
+ import type { WorkspaceResources } from './index';
3
+ type Entry = WorkspaceResources[keyof WorkspaceResources];
4
+ export type ResourceKey = [keyof WorkspaceResources] extends [never] ? string : Entry extends {
5
+ id: infer I;
6
+ } ? I : never;
7
+ /** The id of each entry of `E` that has every capability in `C`. */
8
+ type IdWithCapabilities<E, C extends string> = E extends {
9
+ id: infer I;
10
+ capabilities: infer Declared;
11
+ } ? [C] extends [Declared] ? I : never : never;
12
+ /**
13
+ * The ids of the resources that have every capability in `C`. Any string while the workspace
14
+ * declares no resources.
15
+ */
16
+ export type ResourceKeyWith<C extends string> = [keyof WorkspaceResources] extends [never] ? string : IdWithCapabilities<Entry, C>;
17
+ type EntryFor<R> = Extract<Entry, {
18
+ id: R;
19
+ }>;
20
+ export type InputOf<R> = [EntryFor<R>] extends [never] ? Record<string, unknown> : EntryFor<R> extends {
21
+ input: infer I;
22
+ } ? I : never;
23
+ export type RecordOf<R> = [EntryFor<R>] extends [never] ? {
24
+ id: string;
25
+ } & Record<string, unknown> : EntryFor<R> extends {
26
+ record: infer T;
27
+ } ? T : never;
28
+ /** The declared keys of `T`. `keyof` on a type with an index signature returns only `string | number`. */
29
+ type DeclaredKey<T> = keyof {
30
+ [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
31
+ };
32
+ /**
33
+ * `DataSearchOutput` with `data` narrowed to the resource's record shape and `cursor` narrowed to
34
+ * the cursor text. `pagination` stays as generated.
35
+ */
36
+ type SearchOutput<R> = Pick<DataSearchOutput, Exclude<DeclaredKey<DataSearchOutput>, 'data' | 'cursor'>> & {
37
+ data?: Array<RecordOf<R>>;
38
+ /** With `paging: 'cursor'`, the `after` value for the next page. Null when no records are left. */
39
+ cursor?: string | null;
40
+ [key: string]: unknown;
41
+ };
42
+ type EachInput<R> = Omit<DataSearchInput, 'resource' | 'page' | 'pageSize' | 'paging' | 'after'> & {
43
+ resource: R;
44
+ /** Stop after this many records. Leave it out to visit every match. */
45
+ maxRecords?: number;
46
+ };
47
+ /**
48
+ * Visit every record that the search matches, one record at a time, with cursor paging. The
49
+ * query is copied when `each` is called, so a change to the input object during the walk does
50
+ * not change the pages.
51
+ *
52
+ * Each page continues after the last record of the page before it. A record that the loop body
53
+ * updates so that it no longer matches, or deletes, does not move a later page. A body that
54
+ * changes the value of a `sort` field can move a visited record after the cursor, and the walk
55
+ * then visits it again. Sort on a field that the body does not change, or leave `sort` empty.
56
+ */
57
+ declare function each<R extends ResourceKey>(input: EachInput<R>): AsyncGenerator<RecordOf<R>, void, undefined>;
58
+ export declare const data: {
59
+ create: <R extends ResourceKey>(input: Omit<DataCreateInput, "resource" | "data"> & {
60
+ resource: R;
61
+ data: InputOf<R>;
62
+ }) => Promise<{
63
+ id: string;
64
+ } & Record<string, unknown>>;
65
+ find: <R extends ResourceKey>(input: Omit<DataFindInput, "resource"> & {
66
+ resource: R;
67
+ }) => Promise<{
68
+ id: string;
69
+ } & Record<string, unknown>>;
70
+ update: <R extends ResourceKey>(input: Omit<DataUpdateInput, "resource" | "data"> & {
71
+ resource: R;
72
+ data: InputOf<R>;
73
+ }) => Promise<{
74
+ id: string;
75
+ } & Record<string, unknown>>;
76
+ search: <R extends ResourceKey>(input: Omit<DataSearchInput, "resource"> & {
77
+ resource: R;
78
+ }) => Promise<SearchOutput<R>>;
79
+ each: typeof each;
80
+ delete: <R extends ResourceKey>(input: Omit<DataDeleteInput, "resource"> & {
81
+ resource: R;
82
+ }) => Promise<{
83
+ id: string;
84
+ } & Record<string, unknown>>;
85
+ restore: <R extends ResourceKey>(input: Omit<DataRestoreInput, "resource"> & {
86
+ resource: R;
87
+ }) => Promise<{
88
+ id: string;
89
+ } & Record<string, unknown>>;
90
+ count: <R extends ResourceKey>(input: Omit<DataCountInput, "resource"> & {
91
+ resource: R;
92
+ }) => Promise<number>;
93
+ findOrCreate: <R extends ResourceKey>(input: Omit<DataFindOrCreateInput, "resource"> & {
94
+ resource: R;
95
+ }) => Promise<{
96
+ id: string;
97
+ } & Record<string, unknown>>;
98
+ updateOrCreate: <R extends ResourceKey>(input: Omit<DataUpdateOrCreateInput, "resource"> & {
99
+ resource: R;
100
+ }) => Promise<{
101
+ id: string;
102
+ } & Record<string, unknown>>;
103
+ createMany: <R extends ResourceKey>(input: Omit<DataCreateManyInput, "resource" | "records"> & {
104
+ resource: R;
105
+ records: Array<InputOf<R>>;
106
+ }) => Promise<({
107
+ id: string;
108
+ } & Record<string, unknown>)[]>;
109
+ deleteMany: <R extends ResourceKey>(input: Omit<DataDeleteManyInput, "resource"> & {
110
+ resource: R;
111
+ }) => Promise<DataDeleteManyOutput>;
112
+ aggregateMetrics: (input: import("./index").DataAggregateMetricsInput) => Promise<import("./index").DataAggregateMetricsOutput>;
113
+ relation: {
114
+ attach: (input: import("./index").DataRelationAttachInput) => Promise<import("./index").DataRelationAttachOutput>;
115
+ attachMany: (input: import("./index").DataRelationAttachManyInput) => Promise<import("./index").DataRelationAttachManyOutput>;
116
+ detach: (input: import("./index").DataRelationDetachInput) => Promise<import("./index").DataRelationDetachOutput>;
117
+ detachMany: (input: import("./index").DataRelationDetachManyInput) => Promise<import("./index").DataRelationDetachManyOutput>;
118
+ sync: (input: import("./index").DataRelationSyncInput) => Promise<import("./index").DataRelationSyncOutput>;
119
+ };
120
+ semanticSearch: (input: import("./index").DataSemanticSearchInput) => Promise<import("./index").DataSemanticSearchOutput>;
121
+ sum: (input: import("./index").DataSumInput) => Promise<import("./index").DataSumOutput>;
122
+ validate: (input: import("./index").DataValidateInput) => Promise<import("./index").DataValidateOutput>;
123
+ };
124
+ export {};
@@ -0,0 +1,23 @@
1
+ export declare class HostError extends Error {
2
+ readonly code: string;
3
+ readonly status: number;
4
+ readonly details: unknown;
5
+ readonly failureId: number | null;
6
+ /**
7
+ * @param failureId The host's ID for the failure of the call. When the error ends the run, the
8
+ * host records that failure, so a run records the failure of the call that it rethrows.
9
+ */
10
+ constructor(message: string, code: string, status: number, details: unknown, failureId?: number | null);
11
+ }
12
+ export declare class WorkflowFailure extends Error {
13
+ readonly status: number;
14
+ readonly details: unknown;
15
+ constructor(message: string, status: number, details?: unknown);
16
+ }
17
+ export declare function fail(message: string, options?: {
18
+ status?: number;
19
+ details?: unknown;
20
+ }): never;
21
+ export declare function validationError(errors: Record<string, string[]>, options?: {
22
+ message?: string;
23
+ }): never;