@zapier/zapier-sdk 0.0.2 → 0.1.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.
Files changed (167) hide show
  1. package/dist/api/auth.d.ts +8 -0
  2. package/dist/api/auth.js +29 -0
  3. package/dist/api/client.d.ts +8 -0
  4. package/dist/api/client.js +102 -0
  5. package/dist/api/debug.d.ts +12 -0
  6. package/dist/api/debug.js +50 -0
  7. package/dist/api/index.d.ts +26 -0
  8. package/dist/api/index.js +51 -0
  9. package/dist/api/polling.d.ts +17 -0
  10. package/dist/api/polling.js +34 -0
  11. package/dist/{types.d.ts → api/types.d.ts} +37 -76
  12. package/dist/api/types.js +9 -0
  13. package/dist/functions/bundleCode/index.d.ts +11 -0
  14. package/dist/functions/bundleCode/index.js +91 -0
  15. package/dist/functions/bundleCode/info.d.ts +27 -0
  16. package/dist/functions/bundleCode/info.js +11 -0
  17. package/dist/functions/bundleCode/schemas.d.ts +27 -0
  18. package/dist/functions/bundleCode/schemas.js +22 -0
  19. package/dist/functions/generateTypes/index.d.ts +11 -0
  20. package/dist/functions/generateTypes/index.js +305 -0
  21. package/dist/functions/generateTypes/info.d.ts +21 -0
  22. package/dist/functions/generateTypes/info.js +11 -0
  23. package/dist/functions/generateTypes/schemas.d.ts +30 -0
  24. package/dist/functions/generateTypes/schemas.js +14 -0
  25. package/dist/functions/getAction/index.d.ts +12 -0
  26. package/dist/functions/getAction/index.js +26 -0
  27. package/dist/functions/getAction/info.d.ts +18 -0
  28. package/dist/functions/getAction/info.js +11 -0
  29. package/dist/functions/getAction/schemas.d.ts +30 -0
  30. package/dist/functions/getAction/schemas.js +13 -0
  31. package/dist/functions/getApp/index.d.ts +12 -0
  32. package/dist/functions/getApp/index.js +37 -0
  33. package/dist/functions/getApp/info.d.ts +12 -0
  34. package/dist/functions/getApp/info.js +11 -0
  35. package/dist/functions/getApp/schemas.d.ts +24 -0
  36. package/dist/functions/getApp/schemas.js +11 -0
  37. package/dist/functions/listActions/index.d.ts +12 -0
  38. package/dist/functions/listActions/index.js +128 -0
  39. package/dist/functions/listActions/info.d.ts +15 -0
  40. package/dist/functions/listActions/info.js +11 -0
  41. package/dist/functions/listActions/schemas.d.ts +27 -0
  42. package/dist/functions/listActions/schemas.js +14 -0
  43. package/dist/functions/listApps/index.d.ts +12 -0
  44. package/dist/functions/listApps/index.js +50 -0
  45. package/dist/functions/listApps/info.d.ts +18 -0
  46. package/dist/functions/listApps/info.js +11 -0
  47. package/dist/functions/listApps/schemas.d.ts +30 -0
  48. package/dist/functions/listApps/schemas.js +15 -0
  49. package/dist/functions/listAuths/index.d.ts +12 -0
  50. package/dist/functions/listAuths/index.js +118 -0
  51. package/dist/functions/listAuths/info.d.ts +24 -0
  52. package/dist/functions/listAuths/info.js +11 -0
  53. package/dist/functions/listAuths/schemas.d.ts +36 -0
  54. package/dist/functions/listAuths/schemas.js +17 -0
  55. package/dist/functions/listFields/index.d.ts +12 -0
  56. package/dist/functions/listFields/index.js +65 -0
  57. package/dist/functions/listFields/info.d.ts +24 -0
  58. package/dist/functions/listFields/info.js +11 -0
  59. package/dist/functions/listFields/schemas.d.ts +36 -0
  60. package/dist/functions/listFields/schemas.js +17 -0
  61. package/dist/functions/runAction/index.d.ts +12 -0
  62. package/dist/functions/runAction/index.js +157 -0
  63. package/dist/functions/runAction/info.d.ts +24 -0
  64. package/dist/functions/runAction/info.js +11 -0
  65. package/dist/functions/runAction/schemas.d.ts +36 -0
  66. package/dist/functions/runAction/schemas.js +15 -0
  67. package/dist/index.d.ts +15 -3
  68. package/dist/index.js +27 -4
  69. package/dist/plugins/apps/index.d.ts +8 -0
  70. package/dist/plugins/apps/index.js +77 -0
  71. package/dist/plugins/apps/info.d.ts +6 -0
  72. package/dist/plugins/apps/info.js +13 -0
  73. package/dist/plugins/apps/types.d.ts +21 -0
  74. package/dist/plugins/apps/types.js +2 -0
  75. package/dist/resolvers/actionKey.d.ts +8 -0
  76. package/dist/resolvers/actionKey.js +20 -0
  77. package/dist/resolvers/actionType.d.ts +8 -0
  78. package/dist/resolvers/actionType.js +21 -0
  79. package/dist/resolvers/appKey.d.ts +6 -0
  80. package/dist/resolvers/appKey.js +8 -0
  81. package/dist/resolvers/authenticationId.d.ts +8 -0
  82. package/dist/resolvers/authenticationId.js +29 -0
  83. package/dist/resolvers/index.d.ts +39 -0
  84. package/dist/resolvers/index.js +105 -0
  85. package/dist/resolvers/inputs.d.ts +7 -0
  86. package/dist/resolvers/inputs.js +15 -0
  87. package/dist/schema-utils.d.ts +39 -0
  88. package/dist/schema-utils.js +52 -0
  89. package/dist/schemas/Action.d.ts +21 -0
  90. package/dist/schemas/Action.js +31 -0
  91. package/dist/schemas/App.d.ts +19 -0
  92. package/dist/schemas/App.js +32 -0
  93. package/dist/schemas/Auth.d.ts +30 -0
  94. package/dist/schemas/Auth.js +49 -0
  95. package/dist/schemas/Field.d.ts +15 -0
  96. package/dist/schemas/Field.js +25 -0
  97. package/dist/sdk.d.ts +3 -4
  98. package/dist/sdk.js +96 -11
  99. package/dist/types/domain.d.ts +22 -0
  100. package/dist/types/domain.js +21 -0
  101. package/dist/types/properties.d.ts +21 -0
  102. package/dist/types/properties.js +45 -0
  103. package/dist/types/sdk.d.ts +21 -0
  104. package/dist/types/sdk.js +2 -0
  105. package/package.json +4 -2
  106. package/src/api/auth.ts +28 -0
  107. package/src/api/client.ts +148 -0
  108. package/src/api/debug.ts +58 -0
  109. package/src/api/index.ts +83 -0
  110. package/src/api/polling.ts +56 -0
  111. package/src/{types.ts → api/types.ts} +51 -118
  112. package/src/functions/bundleCode/index.ts +78 -0
  113. package/src/functions/bundleCode/info.ts +9 -0
  114. package/src/functions/bundleCode/schemas.ts +30 -0
  115. package/src/functions/generateTypes/index.ts +348 -0
  116. package/src/functions/generateTypes/info.ts +9 -0
  117. package/src/functions/generateTypes/schemas.ts +38 -0
  118. package/src/functions/getAction/index.ts +33 -0
  119. package/src/functions/getAction/info.ts +9 -0
  120. package/src/functions/getAction/schemas.ts +35 -0
  121. package/src/functions/getApp/index.ts +41 -0
  122. package/src/functions/getApp/info.ts +9 -0
  123. package/src/functions/getApp/schemas.ts +31 -0
  124. package/src/functions/listActions/index.ts +149 -0
  125. package/src/functions/listActions/info.ts +9 -0
  126. package/src/functions/listActions/schemas.ts +40 -0
  127. package/src/functions/listApps/index.ts +60 -0
  128. package/src/functions/listApps/info.ts +9 -0
  129. package/src/functions/listApps/schemas.ts +43 -0
  130. package/src/functions/listAuths/index.ts +153 -0
  131. package/src/functions/listAuths/info.ts +9 -0
  132. package/src/functions/listAuths/schemas.ts +48 -0
  133. package/src/functions/listFields/index.ts +86 -0
  134. package/src/functions/listFields/info.ts +9 -0
  135. package/src/functions/listFields/schemas.ts +46 -0
  136. package/src/functions/runAction/index.ts +258 -0
  137. package/src/functions/runAction/info.ts +9 -0
  138. package/src/functions/runAction/schemas.ts +41 -0
  139. package/src/index.ts +24 -4
  140. package/src/plugins/apps/index.ts +144 -0
  141. package/src/plugins/apps/info.ts +12 -0
  142. package/src/plugins/apps/types.ts +34 -0
  143. package/src/resolvers/actionKey.ts +33 -0
  144. package/src/resolvers/actionType.ts +30 -0
  145. package/src/resolvers/appKey.ts +11 -0
  146. package/src/resolvers/authenticationId.ts +38 -0
  147. package/src/resolvers/index.ts +117 -0
  148. package/src/resolvers/inputs.ts +23 -0
  149. package/src/schema-utils.ts +119 -0
  150. package/src/schemas/Action.ts +40 -0
  151. package/src/schemas/App.ts +43 -0
  152. package/src/schemas/Auth.ts +62 -0
  153. package/src/schemas/Field.ts +34 -0
  154. package/src/sdk.ts +153 -19
  155. package/src/types/domain.ts +54 -0
  156. package/src/types/properties.ts +67 -0
  157. package/src/types/sdk.ts +42 -0
  158. package/dist/actions-sdk.d.ts +0 -51
  159. package/dist/actions-sdk.js +0 -1194
  160. package/dist/output-schemas.d.ts +0 -95
  161. package/dist/output-schemas.js +0 -138
  162. package/dist/schemas.d.ts +0 -338
  163. package/dist/schemas.js +0 -336
  164. package/dist/types.js +0 -41
  165. package/src/actions-sdk.ts +0 -1685
  166. package/src/output-schemas.ts +0 -196
  167. package/src/schemas.ts +0 -467
@@ -0,0 +1,34 @@
1
+ import type {
2
+ ActionExecutionOptions,
3
+ ActionExecutionResult,
4
+ } from "../../types/domain";
5
+
6
+ interface AppFactoryOptions {
7
+ authenticationId: number;
8
+ }
9
+
10
+ interface ActionTypeProxy {
11
+ [action: string]: (
12
+ options?: ActionExecutionOptions,
13
+ ) => Promise<ActionExecutionResult>;
14
+ }
15
+
16
+ interface AppProxy {
17
+ [type: string]: ActionTypeProxy;
18
+ }
19
+
20
+ interface AppFactory {
21
+ (options: AppFactoryOptions): AppProxy;
22
+ }
23
+
24
+ // An app can be both a factory function and have properties for direct access
25
+ type AppProxyWithFactory = AppFactory & AppProxy;
26
+
27
+ export interface ActionProxy {
28
+ [app: string]: AppProxyWithFactory;
29
+ }
30
+
31
+ // Plugin interface - ready to be mixed into main SDK interface
32
+ export interface AppsPluginSdkExtension {
33
+ apps: ActionProxy;
34
+ }
@@ -0,0 +1,33 @@
1
+ import type { ZapierSdk } from "../types/sdk";
2
+
3
+ export interface ActionKeyResolver {
4
+ type: "dynamic";
5
+ depends: readonly string[];
6
+ fetch: (
7
+ sdk: ZapierSdk,
8
+ resolvedParams: Record<string, any>,
9
+ ) => Promise<any[]>;
10
+ prompt: (items: any[], params: Record<string, any>) => any;
11
+ }
12
+
13
+ export const actionKeyResolver: ActionKeyResolver = {
14
+ type: "dynamic",
15
+ depends: ["appKey", "actionType"] as const,
16
+ fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
17
+ const actions = await sdk.listActions({ appKey: resolvedParams.appKey });
18
+ return actions.filter(
19
+ (action: any) => action.type === resolvedParams.actionType,
20
+ );
21
+ },
22
+ prompt: (actions: any[]) => ({
23
+ type: "list",
24
+ name: "actionKey",
25
+ message: "Select action:",
26
+ choices: actions.map((action) => ({
27
+ name: `${action.name || action.key} - ${
28
+ action.description || "No description"
29
+ }`,
30
+ value: action.key,
31
+ })),
32
+ }),
33
+ };
@@ -0,0 +1,30 @@
1
+ import type { ZapierSdk } from "../types/sdk";
2
+
3
+ export interface ActionTypeResolver {
4
+ type: "dynamic";
5
+ depends: readonly string[];
6
+ fetch: (
7
+ sdk: ZapierSdk,
8
+ resolvedParams: Record<string, any>,
9
+ ) => Promise<any[]>;
10
+ prompt: (items: any[], params: Record<string, any>) => any;
11
+ }
12
+
13
+ export const actionTypeResolver: ActionTypeResolver = {
14
+ type: "dynamic",
15
+ depends: ["appKey"] as const,
16
+ fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
17
+ const actions = await sdk.listActions({ appKey: resolvedParams.appKey });
18
+ const types = [...new Set(actions.map((action: any) => action.type))];
19
+ return types.map((type) => ({ key: type, name: type }));
20
+ },
21
+ prompt: (types: any[]) => ({
22
+ type: "list",
23
+ name: "actionType",
24
+ message: "Select action type:",
25
+ choices: types.map((type) => ({
26
+ name: type.name,
27
+ value: type.key,
28
+ })),
29
+ }),
30
+ };
@@ -0,0 +1,11 @@
1
+ export interface AppKeyResolver {
2
+ type: "static";
3
+ inputType?: "text" | "password" | "email";
4
+ placeholder?: string;
5
+ }
6
+
7
+ export const appKeyResolver: AppKeyResolver = {
8
+ type: "static",
9
+ inputType: "text",
10
+ placeholder: "Enter app slug (e.g., 'slack', 'github')",
11
+ };
@@ -0,0 +1,38 @@
1
+ import type { ZapierSdk } from "../types/sdk";
2
+
3
+ export interface AuthenticationIdResolver {
4
+ type: "dynamic";
5
+ depends: readonly string[];
6
+ fetch: (
7
+ sdk: ZapierSdk,
8
+ resolvedParams: Record<string, any>,
9
+ ) => Promise<any[]>;
10
+ prompt: (items: any[], params: Record<string, any>) => any;
11
+ }
12
+
13
+ export const authenticationIdResolver: AuthenticationIdResolver = {
14
+ type: "dynamic",
15
+ depends: ["appKey"] as const,
16
+ fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
17
+ // Get auths for the specific app (owned auths will be prioritized automatically)
18
+ return await sdk.listAuths({
19
+ appKey: resolvedParams.appKey,
20
+ limit: 1000,
21
+ });
22
+ },
23
+ prompt: (auths: any[], params: Record<string, any>) => ({
24
+ type: "list",
25
+ name: "authenticationId",
26
+ message: `Select authentication for ${params.appKey}:`,
27
+ choices: [
28
+ ...auths.map((auth) => ({
29
+ name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
30
+ value: auth.id,
31
+ })),
32
+ {
33
+ name: "↗ Skip authentication (may fail)",
34
+ value: null,
35
+ },
36
+ ],
37
+ }),
38
+ };
@@ -0,0 +1,117 @@
1
+ import { appKeyResolver } from "./appKey";
2
+ import { actionTypeResolver } from "./actionType";
3
+ import { actionKeyResolver } from "./actionKey";
4
+ import { authenticationIdResolver } from "./authenticationId";
5
+ import { inputsResolver } from "./inputs";
6
+
7
+ // Centralized resolver registry
8
+ export const resolverRegistry = {
9
+ appKey: appKeyResolver,
10
+ actionType: actionTypeResolver,
11
+ actionKey: actionKeyResolver,
12
+ authenticationId: authenticationIdResolver,
13
+ inputs: inputsResolver,
14
+ } as const;
15
+
16
+ // Type definitions
17
+ export type ResolverName = keyof typeof resolverRegistry;
18
+ export type ResolverType = (typeof resolverRegistry)[ResolverName];
19
+
20
+ // Utility functions for working with resolvers
21
+
22
+ /**
23
+ * Get a resolver by name
24
+ */
25
+ export function getResolver(name: string): ResolverType | undefined {
26
+ return resolverRegistry[name as ResolverName];
27
+ }
28
+
29
+ /**
30
+ * Get all resolvers for a list of missing parameters
31
+ */
32
+ export function getResolversForMissingParams(
33
+ missingParams: string[],
34
+ ): Record<string, ResolverType> {
35
+ const resolvers: Record<string, ResolverType> = {};
36
+
37
+ for (const param of missingParams) {
38
+ const resolver = resolverRegistry[param as ResolverName];
39
+ if (resolver) {
40
+ resolvers[param] = resolver;
41
+ }
42
+ }
43
+
44
+ return resolvers;
45
+ }
46
+
47
+ /**
48
+ * Check if a parameter has a resolver
49
+ */
50
+ export function hasResolver(paramName: string): boolean {
51
+ return paramName in resolverRegistry;
52
+ }
53
+
54
+ /**
55
+ * Get all parameter names that have resolvers
56
+ */
57
+ export function getResolvableParams(): string[] {
58
+ return Object.keys(resolverRegistry);
59
+ }
60
+
61
+ /**
62
+ * Resolve dependency chain for a parameter
63
+ * Returns parameters in the order they need to be resolved
64
+ */
65
+ export function getResolutionOrder(
66
+ paramName: string,
67
+ resolved: Set<string> = new Set(),
68
+ ): string[] {
69
+ const resolver = getResolver(paramName);
70
+ if (!resolver || resolver.type === "static") {
71
+ return [paramName];
72
+ }
73
+
74
+ const order: string[] = [];
75
+
76
+ if ("depends" in resolver && resolver.depends) {
77
+ for (const dependency of resolver.depends) {
78
+ if (!resolved.has(dependency)) {
79
+ order.push(...getResolutionOrder(dependency, resolved));
80
+ resolved.add(dependency);
81
+ }
82
+ }
83
+ }
84
+
85
+ if (!resolved.has(paramName)) {
86
+ order.push(paramName);
87
+ resolved.add(paramName);
88
+ }
89
+
90
+ return order;
91
+ }
92
+
93
+ /**
94
+ * Get resolution order for multiple parameters
95
+ */
96
+ export function getResolutionOrderForParams(paramNames: string[]): string[] {
97
+ const resolved = new Set<string>();
98
+ const order: string[] = [];
99
+
100
+ for (const paramName of paramNames) {
101
+ const paramOrder = getResolutionOrder(paramName, resolved);
102
+ for (const param of paramOrder) {
103
+ if (!order.includes(param)) {
104
+ order.push(param);
105
+ }
106
+ }
107
+ }
108
+
109
+ return order;
110
+ }
111
+
112
+ // Re-export individual resolvers for direct access if needed
113
+ export { appKeyResolver } from "./appKey";
114
+ export { actionTypeResolver } from "./actionType";
115
+ export { actionKeyResolver } from "./actionKey";
116
+ export { authenticationIdResolver } from "./authenticationId";
117
+ export { inputsResolver } from "./inputs";
@@ -0,0 +1,23 @@
1
+ import type { ZapierSdk } from "../types/sdk";
2
+
3
+ export interface InputsResolver {
4
+ type: "fields";
5
+ depends: readonly string[];
6
+ fetch: (
7
+ sdk: ZapierSdk,
8
+ resolvedParams: Record<string, any>,
9
+ ) => Promise<any[]>;
10
+ }
11
+
12
+ export const inputsResolver: InputsResolver = {
13
+ type: "fields",
14
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"] as const,
15
+ fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
16
+ return await sdk.listFields({
17
+ appKey: resolvedParams.appKey,
18
+ actionKey: resolvedParams.actionKey,
19
+ actionType: resolvedParams.actionType,
20
+ authenticationId: resolvedParams.authenticationId,
21
+ });
22
+ },
23
+ };
@@ -0,0 +1,119 @@
1
+ import { z } from "zod";
2
+
3
+ // ============================================================================
4
+ // Format Metadata Types
5
+ // ============================================================================
6
+
7
+ export interface FormattedItem {
8
+ title: string;
9
+ subtitle?: string;
10
+ details: Array<{
11
+ text: string;
12
+ style: "normal" | "dim" | "accent" | "warning" | "success";
13
+ }>;
14
+ }
15
+
16
+ export interface FormatMetadata {
17
+ format: (item: any) => FormattedItem;
18
+ }
19
+
20
+ // Helper function to add format metadata to schemas
21
+ export function withFormatter<T extends z.ZodType>(
22
+ schema: T,
23
+ formatMeta: FormatMetadata,
24
+ ): T {
25
+ // Store format metadata on the schema definition
26
+ (schema._def as any).formatMeta = formatMeta;
27
+ return schema;
28
+ }
29
+
30
+ // Helper function to get format metadata from a schema
31
+ export function getFormatMetadata(
32
+ schema: z.ZodType,
33
+ ): FormatMetadata | undefined {
34
+ return (schema._def as any).formatMeta;
35
+ }
36
+
37
+ // Helper function to link input schemas to output schemas
38
+ export function withOutputSchema<T extends z.ZodType>(
39
+ inputSchema: T,
40
+ outputSchema: z.ZodType,
41
+ ): T {
42
+ // Store output schema reference on the input schema
43
+ (inputSchema._def as any).outputSchema = outputSchema;
44
+ return inputSchema;
45
+ }
46
+
47
+ // Helper function to get output schema from an input schema
48
+ export function getOutputSchema(inputSchema: z.ZodType): z.ZodType | undefined {
49
+ return (inputSchema._def as any).outputSchema;
50
+ }
51
+
52
+ // ============================================================================
53
+ // Resolution Metadata Types
54
+ // ============================================================================
55
+
56
+ export interface StaticResolver {
57
+ type: "static";
58
+ inputType?: "text" | "password" | "email";
59
+ placeholder?: string;
60
+ }
61
+
62
+ export interface DynamicResolver {
63
+ type: "dynamic";
64
+ fetch: (sdk: any, resolvedParams: any) => Promise<any[]>; // Function to fetch data using SDK
65
+ prompt: (items: any[], params: any) => any;
66
+ depends?: string[]; // Parameters this resolver depends on
67
+ }
68
+
69
+ export interface FieldsResolver {
70
+ type: "fields";
71
+ fetch: (sdk: any, resolvedParams: any) => Promise<any[]>; // Function to fetch fields using SDK
72
+ depends?: string[]; // Parameters this resolver depends on
73
+ }
74
+
75
+ export type ResolverMetadata =
76
+ | StaticResolver
77
+ | DynamicResolver
78
+ | FieldsResolver;
79
+
80
+ // Wrapper interface for resolver metadata to allow future extensibility
81
+ export interface ResolverConfig {
82
+ resolver: ResolverMetadata;
83
+ // Future metadata types can be added here:
84
+ // validation?: ValidationMetadata;
85
+ // display?: DisplayMetadata;
86
+ }
87
+
88
+ // Helper function to add resolver metadata to schemas
89
+ export function withResolver<T extends z.ZodType>(
90
+ schema: T,
91
+ config: ResolverConfig,
92
+ ): T {
93
+ // Store resolver metadata on the schema definition
94
+ (schema._def as any).resolverMeta = config;
95
+ return schema;
96
+ }
97
+
98
+ // ============================================================================
99
+ // Schema Description Utilities
100
+ // ============================================================================
101
+
102
+ export function getSchemaDescription(schema: z.ZodSchema): string | undefined {
103
+ return schema.description;
104
+ }
105
+
106
+ export function getFieldDescriptions(
107
+ schema: z.ZodObject<any>,
108
+ ): Record<string, string> {
109
+ const descriptions: Record<string, string> = {};
110
+ const shape = schema.shape;
111
+
112
+ for (const [key, fieldSchema] of Object.entries(shape)) {
113
+ if (fieldSchema instanceof z.ZodType && fieldSchema.description) {
114
+ descriptions[key] = fieldSchema.description;
115
+ }
116
+ }
117
+
118
+ return descriptions;
119
+ }
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ import { withFormatter } from "../schema-utils";
3
+
4
+ // ============================================================================
5
+ // Action Schemas
6
+ // ============================================================================
7
+
8
+ export const ActionItemSchema = withFormatter(
9
+ z.object({
10
+ key: z.string(),
11
+ name: z.string().optional(),
12
+ type: z.string(),
13
+ appKey: z.string().optional(),
14
+ description: z.string().optional(),
15
+ }),
16
+ {
17
+ format: (item) => {
18
+ const details = [];
19
+ details.push({ text: `Type: ${item.type}`, style: "accent" as const });
20
+ if (item.appKey) {
21
+ details.push({ text: `App: ${item.appKey}`, style: "normal" as const });
22
+ }
23
+ if (item.description) {
24
+ details.push({ text: item.description, style: "dim" as const });
25
+ }
26
+
27
+ return {
28
+ title: item.name || item.key,
29
+ subtitle: `(${item.key})`,
30
+ details,
31
+ };
32
+ },
33
+ },
34
+ );
35
+
36
+ // ============================================================================
37
+ // Type Exports
38
+ // ============================================================================
39
+
40
+ export type ActionItem = z.infer<typeof ActionItemSchema>;
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ import { withFormatter } from "../schema-utils";
3
+
4
+ export { FormattedItem, FormatMetadata } from "../schema-utils";
5
+
6
+ // ============================================================================
7
+ // App Schemas
8
+ // ============================================================================
9
+
10
+ export const AppItemSchema = withFormatter(
11
+ z.object({
12
+ key: z.string(),
13
+ name: z.string().optional(),
14
+ description: z.string().optional(),
15
+ category: z.string().optional(),
16
+ }),
17
+ {
18
+ format: (item) => {
19
+ const details = [];
20
+ if (item.description) {
21
+ details.push({ text: item.description, style: "dim" as const });
22
+ }
23
+ if (item.category) {
24
+ details.push({
25
+ text: `Category: ${item.category}`,
26
+ style: "accent" as const,
27
+ });
28
+ }
29
+
30
+ return {
31
+ title: item.name || item.key,
32
+ subtitle: `(${item.key})`,
33
+ details,
34
+ };
35
+ },
36
+ },
37
+ );
38
+
39
+ // ============================================================================
40
+ // Type Exports
41
+ // ============================================================================
42
+
43
+ export type AppItem = z.infer<typeof AppItemSchema>;
@@ -0,0 +1,62 @@
1
+ import { z } from "zod";
2
+ import { withFormatter } from "../schema-utils";
3
+
4
+ // ============================================================================
5
+ // Auth Schemas
6
+ // ============================================================================
7
+
8
+ export const AuthItemSchema = withFormatter(
9
+ z.object({
10
+ id: z.number(),
11
+ title: z.string().optional(),
12
+ label: z.string().optional(),
13
+ identifier: z.string().optional(),
14
+ account_id: z.string().optional(),
15
+ is_private: z.boolean().optional(),
16
+ shared_with_all: z.boolean().optional(),
17
+ marked_stale_at: z.string().optional(),
18
+ }),
19
+ {
20
+ format: (item) => {
21
+ const details = [];
22
+
23
+ if (item.identifier) {
24
+ details.push({
25
+ text: `Identifier: ${item.identifier}`,
26
+ style: "accent" as const,
27
+ });
28
+ }
29
+
30
+ if (item.label && item.title && item.label !== item.title) {
31
+ details.push({
32
+ text: `Label: ${item.label}`,
33
+ style: "normal" as const,
34
+ });
35
+ }
36
+
37
+ details.push({
38
+ text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
39
+ style: "dim" as const,
40
+ });
41
+
42
+ if (item.marked_stale_at) {
43
+ details.push({
44
+ text: `⚠️ Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
45
+ style: "warning" as const,
46
+ });
47
+ }
48
+
49
+ return {
50
+ title: item.title || item.label || `Authentication ${item.id}`,
51
+ subtitle: `(ID: ${item.id})`,
52
+ details,
53
+ };
54
+ },
55
+ },
56
+ );
57
+
58
+ // ============================================================================
59
+ // Type Exports
60
+ // ============================================================================
61
+
62
+ export type AuthItem = z.infer<typeof AuthItemSchema>;
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import { withFormatter } from "../schema-utils";
3
+
4
+ // ============================================================================
5
+ // Field Schemas
6
+ // ============================================================================
7
+
8
+ export const FieldItemSchema = withFormatter(
9
+ z.object({
10
+ key: z.string(),
11
+ name: z.string().optional(),
12
+ description: z.string().optional(),
13
+ }),
14
+ {
15
+ format: (item) => {
16
+ const details = [];
17
+ if (item.description) {
18
+ details.push({ text: item.description, style: "dim" as const });
19
+ }
20
+
21
+ return {
22
+ title: item.name || item.key,
23
+ subtitle: `(${item.key})`,
24
+ details,
25
+ };
26
+ },
27
+ },
28
+ );
29
+
30
+ // ============================================================================
31
+ // Type Exports
32
+ // ============================================================================
33
+
34
+ export type FieldItem = z.infer<typeof FieldItemSchema>;