@zapier/kitcore 0.5.1 → 0.6.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.
- package/CHANGELOG.md +6 -0
- package/README.md +7 -2
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +20 -5
- package/dist/index.d.ts +20 -5
- package/dist/index.mjs +1 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -897,6 +897,21 @@ type StrictPage$1<TResponse> = SdkPage<unknown> & {
|
|
|
897
897
|
type ItemOf$1<TResponse> = TResponse extends SdkPage<infer TItem> ? TItem : TResponse extends {
|
|
898
898
|
data: readonly (infer TItem)[];
|
|
899
899
|
} ? TItem : never;
|
|
900
|
+
/**
|
|
901
|
+
* A response whose only own key is `data`. Gates the item overload of
|
|
902
|
+
* `defineMethod` the way `StrictPage` gates list-standard: `run` returns the
|
|
903
|
+
* `{ data }` envelope itself, and an envelope with extra keys is rejected (a
|
|
904
|
+
* future variant may accept metadata alongside `data`).
|
|
905
|
+
*/
|
|
906
|
+
type StrictItem<TResponse> = {
|
|
907
|
+
data: unknown;
|
|
908
|
+
} & {
|
|
909
|
+
[K in Exclude<keyof TResponse, "data">]?: never;
|
|
910
|
+
};
|
|
911
|
+
/** Data type sourced from an item envelope. */
|
|
912
|
+
type DataOf<TResponse> = TResponse extends {
|
|
913
|
+
data: infer TData;
|
|
914
|
+
} ? TData : never;
|
|
900
915
|
/**
|
|
901
916
|
* A leaf plugin that is a single value (not a function). `value` is a static
|
|
902
917
|
* constant; `get({ imports })` computes the value from imports. Like a
|
|
@@ -1928,8 +1943,8 @@ declare function createPluginStack<TRequires = object>(): PluginStack<TRequires,
|
|
|
1928
1943
|
*
|
|
1929
1944
|
* The `output` mode shapes `run`'s result into the public surface and drives
|
|
1930
1945
|
* the overload that types the call: raw (default, passthrough), `item`
|
|
1931
|
-
* (`run` returns `T`, surfaced as `Promise<{ data: T }>`), or `list`
|
|
1932
|
-
* returns one `SdkPage`, surfaced as `PaginatedSdkResult`). See Output.
|
|
1946
|
+
* (`run` returns `{ data: T }`, surfaced as `Promise<{ data: T }>`), or `list`
|
|
1947
|
+
* (`run` returns one `SdkPage`, surfaced as `PaginatedSdkResult`). See Output.
|
|
1933
1948
|
*/
|
|
1934
1949
|
declare function defineMethod<const TName extends string, TInput, TOutput, const TPositional extends readonly (keyof TInput & string)[] = readonly [], const TImports extends ImportsInput = readonly [], const TNamespace extends string = "", TState = undefined>(config: {
|
|
1935
1950
|
name: TName;
|
|
@@ -1958,7 +1973,7 @@ declare function defineMethod<const TName extends string, TInput, TOutput, const
|
|
|
1958
1973
|
}) => void | Promise<void>;
|
|
1959
1974
|
run: (bag: MethodRunBag<ImportsOf<TImports>, TInput, TState>) => TOutput;
|
|
1960
1975
|
} & LeafMetaFields): MethodPlugin<TName, TInput, TOutput, TPositional> & LeafSummary<TNamespace, TName, TImports>;
|
|
1961
|
-
declare function defineMethod<const TName extends string, TInput, TData
|
|
1976
|
+
declare function defineMethod<const TName extends string, TInput, TResponse extends StrictItem<TResponse>, TData = DataOf<TResponse>, const TImports extends ImportsInput = readonly [], const TNamespace extends string = "", TState = undefined>(config: {
|
|
1962
1977
|
name: TName;
|
|
1963
1978
|
namespace?: TNamespace;
|
|
1964
1979
|
imports?: TImports & StaticList<TImports>;
|
|
@@ -1976,9 +1991,9 @@ declare function defineMethod<const TName extends string, TInput, TData, const T
|
|
|
1976
1991
|
state: TState;
|
|
1977
1992
|
input?: unknown;
|
|
1978
1993
|
}) => void | Promise<void>;
|
|
1979
|
-
run: (bag: MethodRunBag<ImportsOf<TImports>, TInput, TState>) =>
|
|
1994
|
+
run: (bag: MethodRunBag<ImportsOf<TImports>, TInput, TState>) => TResponse | Promise<TResponse>;
|
|
1980
1995
|
} & LeafMetaFields): MethodPlugin<TName, TInput, Promise<{
|
|
1981
|
-
data:
|
|
1996
|
+
data: TData;
|
|
1982
1997
|
}>> & LeafSummary<TNamespace, TName, TImports>;
|
|
1983
1998
|
declare function defineMethod<const TName extends string, TInput, TResponse extends StrictPage$1<TResponse>, TItem = ItemOf$1<TResponse>, const TImports extends ImportsInput = readonly [], const TNamespace extends string = "", TState = undefined>(config: {
|
|
1984
1999
|
name: TName;
|
package/dist/index.d.ts
CHANGED
|
@@ -897,6 +897,21 @@ type StrictPage$1<TResponse> = SdkPage<unknown> & {
|
|
|
897
897
|
type ItemOf$1<TResponse> = TResponse extends SdkPage<infer TItem> ? TItem : TResponse extends {
|
|
898
898
|
data: readonly (infer TItem)[];
|
|
899
899
|
} ? TItem : never;
|
|
900
|
+
/**
|
|
901
|
+
* A response whose only own key is `data`. Gates the item overload of
|
|
902
|
+
* `defineMethod` the way `StrictPage` gates list-standard: `run` returns the
|
|
903
|
+
* `{ data }` envelope itself, and an envelope with extra keys is rejected (a
|
|
904
|
+
* future variant may accept metadata alongside `data`).
|
|
905
|
+
*/
|
|
906
|
+
type StrictItem<TResponse> = {
|
|
907
|
+
data: unknown;
|
|
908
|
+
} & {
|
|
909
|
+
[K in Exclude<keyof TResponse, "data">]?: never;
|
|
910
|
+
};
|
|
911
|
+
/** Data type sourced from an item envelope. */
|
|
912
|
+
type DataOf<TResponse> = TResponse extends {
|
|
913
|
+
data: infer TData;
|
|
914
|
+
} ? TData : never;
|
|
900
915
|
/**
|
|
901
916
|
* A leaf plugin that is a single value (not a function). `value` is a static
|
|
902
917
|
* constant; `get({ imports })` computes the value from imports. Like a
|
|
@@ -1928,8 +1943,8 @@ declare function createPluginStack<TRequires = object>(): PluginStack<TRequires,
|
|
|
1928
1943
|
*
|
|
1929
1944
|
* The `output` mode shapes `run`'s result into the public surface and drives
|
|
1930
1945
|
* the overload that types the call: raw (default, passthrough), `item`
|
|
1931
|
-
* (`run` returns `T`, surfaced as `Promise<{ data: T }>`), or `list`
|
|
1932
|
-
* returns one `SdkPage`, surfaced as `PaginatedSdkResult`). See Output.
|
|
1946
|
+
* (`run` returns `{ data: T }`, surfaced as `Promise<{ data: T }>`), or `list`
|
|
1947
|
+
* (`run` returns one `SdkPage`, surfaced as `PaginatedSdkResult`). See Output.
|
|
1933
1948
|
*/
|
|
1934
1949
|
declare function defineMethod<const TName extends string, TInput, TOutput, const TPositional extends readonly (keyof TInput & string)[] = readonly [], const TImports extends ImportsInput = readonly [], const TNamespace extends string = "", TState = undefined>(config: {
|
|
1935
1950
|
name: TName;
|
|
@@ -1958,7 +1973,7 @@ declare function defineMethod<const TName extends string, TInput, TOutput, const
|
|
|
1958
1973
|
}) => void | Promise<void>;
|
|
1959
1974
|
run: (bag: MethodRunBag<ImportsOf<TImports>, TInput, TState>) => TOutput;
|
|
1960
1975
|
} & LeafMetaFields): MethodPlugin<TName, TInput, TOutput, TPositional> & LeafSummary<TNamespace, TName, TImports>;
|
|
1961
|
-
declare function defineMethod<const TName extends string, TInput, TData
|
|
1976
|
+
declare function defineMethod<const TName extends string, TInput, TResponse extends StrictItem<TResponse>, TData = DataOf<TResponse>, const TImports extends ImportsInput = readonly [], const TNamespace extends string = "", TState = undefined>(config: {
|
|
1962
1977
|
name: TName;
|
|
1963
1978
|
namespace?: TNamespace;
|
|
1964
1979
|
imports?: TImports & StaticList<TImports>;
|
|
@@ -1976,9 +1991,9 @@ declare function defineMethod<const TName extends string, TInput, TData, const T
|
|
|
1976
1991
|
state: TState;
|
|
1977
1992
|
input?: unknown;
|
|
1978
1993
|
}) => void | Promise<void>;
|
|
1979
|
-
run: (bag: MethodRunBag<ImportsOf<TImports>, TInput, TState>) =>
|
|
1994
|
+
run: (bag: MethodRunBag<ImportsOf<TImports>, TInput, TState>) => TResponse | Promise<TResponse>;
|
|
1980
1995
|
} & LeafMetaFields): MethodPlugin<TName, TInput, Promise<{
|
|
1981
|
-
data:
|
|
1996
|
+
data: TData;
|
|
1982
1997
|
}>> & LeafSummary<TNamespace, TName, TImports>;
|
|
1983
1998
|
declare function defineMethod<const TName extends string, TInput, TResponse extends StrictPage$1<TResponse>, TItem = ItemOf$1<TResponse>, const TImports extends ImportsInput = readonly [], const TNamespace extends string = "", TState = undefined>(config: {
|
|
1984
1999
|
name: TName;
|
package/dist/index.mjs
CHANGED
|
@@ -2177,9 +2177,7 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2177
2177
|
}
|
|
2178
2178
|
);
|
|
2179
2179
|
} else if (out.type === "item") {
|
|
2180
|
-
const itemCore = async (input) => (
|
|
2181
|
-
data: await callRun(input)
|
|
2182
|
-
});
|
|
2180
|
+
const itemCore = async (input) => callRun(input);
|
|
2183
2181
|
entry.value = createFunction(
|
|
2184
2182
|
fold(itemCore),
|
|
2185
2183
|
{
|