shortcutkit 0.6.1 → 0.8.1

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/dist/index.d.ts CHANGED
@@ -1,18 +1,47 @@
1
1
  import { type PlistValue } from "./plist.js";
2
+ import { type ActionDefinition } from "./definitions.js";
3
+ import { ACTIONS } from "./generated/actions.js";
2
4
  import type { ActionId, MetaParams, ParamTypes } from "./generated/actions.js";
3
- import type { Attachment, Picker, TokenString, Value } from "./values.js";
4
- export { actions, ACTIONS, PARAM_KINDS, type ActionId, type ActionKey, type ParamKey, type ParamTypes, type MetaParams } from "./generated/actions.js";
5
+ import type { AskAttachment, Attachment, ConditionSubject, TokenString, Value } from "./values.js";
6
+ export { actions, ACTIONS, PARAM_KINDS, PARAM_CHOICES, PARAM_VARIABLE_TYPES, type ActionId, type ActionKey, type ParamKey, type ParamTypes, type MetaParams } from "./generated/actions.js";
5
7
  export type { PlistValue } from "./plist.js";
6
8
  export type * from "./values.js";
7
9
  export { getDefinition, allDefinitions, type ActionDefinition, type ParameterDefinition, type Localized } from "./definitions.js";
8
10
  export { provenance, type Provenance } from "./provenance.js";
11
+ export type * from "./generated/params.js";
9
12
  /** Parameters accepted for an identifier: typed per key for built-in actions, open for anything else. */
10
13
  export type ParamsFor<I extends string> = I extends ActionId ? Partial<ParamTypes[I] & MetaParams> : Record<string, Value>;
11
14
  export type Action = {
12
15
  WFWorkflowActionIdentifier: string;
13
16
  WFWorkflowActionParameters: Record<string, Value>;
14
17
  outputName?: string;
18
+ outputTypes?: readonly string[];
15
19
  };
20
+ /** Content types an action's output can be (`WFStringContentItem`, `NSURL`, an App Intents entity, …). Shortcuts coerces between many of them at run time, so this describes, it does not restrict. */
21
+ export type OutputTypes<I extends ActionId> = (typeof ACTIONS)[I]["outputTypes"];
22
+ /** What the catalogue knows about an identifier: built-in or App Intent, engine definition or not. */
23
+ export type CatalogEntry = {
24
+ identifier: string;
25
+ /** Display name, as the editor shows it. */
26
+ name: string;
27
+ /** Parameter keys the action accepts, in the editor's order. */
28
+ params: readonly string[];
29
+ /** Value kind per key: bool, number, string, text, picker, subject, plainString, plainNumber, dictionary, quantity, filter, any. */
30
+ kinds: Record<string, string>;
31
+ /** Output name, or null when the action produces nothing. */
32
+ output: string | null;
33
+ /** Content types the output can be; empty when the action produces nothing. */
34
+ outputTypes: readonly string[];
35
+ /** Present for App Intents actions; written as the AppIntentDescriptor parameter. */
36
+ descriptor?: AppIntentDescriptor;
37
+ /** The engine's definition, for built-ins only. */
38
+ definition?: ActionDefinition;
39
+ };
40
+ /**
41
+ * Look up any catalogue identifier, built-in or App Intent. getDefinition() only knows built-ins
42
+ * (App Intents have no engine definition); this covers both with the same shape.
43
+ */
44
+ export declare function getAction(identifier: string): CatalogEntry | undefined;
16
45
  /** Names the app that provides an App Intents action; written as the AppIntentDescriptor parameter. */
17
46
  export type AppIntentDescriptor = {
18
47
  BundleIdentifier: string;
@@ -58,20 +87,35 @@ export declare const CONDITION: {
58
87
  };
59
88
  export type Condition = keyof typeof CONDITION;
60
89
  /** Reference another action's output. */
61
- export declare const ref: (action: Action, outputName?: string) => Attachment;
62
- export declare const variable: (name: string) => Attachment;
63
- export declare const shortcutInput: () => Attachment;
64
- export declare const clipboard: () => Attachment;
65
- export declare const currentDate: () => Attachment;
66
- export declare const ask: (prompt?: string) => Attachment;
67
- /** Wrap an attachment for WFVariablePickerParameter keys (Repeat with Each, If). */
68
- export declare const picker: (a: Attachment) => Picker;
90
+ export declare const ref: (action: Action, outputName?: string) => Attachment<"ActionOutput">;
91
+ export declare const variable: (name: string) => Attachment<"Variable">;
92
+ export declare const shortcutInput: () => Attachment<"ExtensionInput">;
93
+ export declare const clipboard: () => Attachment<"Clipboard">;
94
+ export declare const currentDate: () => Attachment<"CurrentDate">;
95
+ export declare const ask: (prompt?: string) => AskAttachment;
96
+ /** Device Details (name, model, OS version, …); the app usually adds a property aggrandizement. */
97
+ export declare const deviceDetails: () => Attachment<"DeviceDetails">;
98
+ /** The app the shortcut was run from. */
99
+ export declare const currentApp: () => Attachment<"CurrentApp">;
100
+ /** Wrap an attachment as the subject of an If condition, the form the app writes for `WFInput` on `is.workflow.actions.conditional`. Variable-picker parameters (Repeat with Each, Filter, Quick Look, …) take the bare attachment instead. */
101
+ export declare const subject: (a: Attachment) => ConditionSubject;
102
+ /** @deprecated Misnamed: this produces the If-subject form. Pass a bare `ref()` to variable-picker parameters; use `subject()` for If. */
103
+ export declare const picker: (a: Attachment) => ConditionSubject;
104
+ /** The current item inside a Repeat with Each block. */
105
+ export declare const repeatItem: () => Attachment<"Variable">;
106
+ /** The current index (1-based) inside a Repeat block. */
107
+ export declare const repeatIndex: () => Attachment<"Variable">;
69
108
  /** A WFTextTokenString: strings and attachments interleaved; each attachment becomes U+FFFC. */
70
109
  export declare function text(...parts: Array<string | number | Attachment>): TokenString;
110
+ /** Where a shortcut is offered beyond the app: `ActionExtension` is the share sheet, `QuickActions` the Finder and Services menus, `MenuBar`, `NCWidget`, `WatchKit`, `Sleep`, `ReceivesOnScreenContent`. */
111
+ export type WorkflowType = "ActionExtension" | "QuickActions" | "MenuBar" | "NCWidget" | "WatchKit" | "Sleep" | "ReceivesOnScreenContent";
71
112
  export interface ShortcutOptions {
72
113
  color?: IconColor | number;
73
114
  glyph?: number;
115
+ /** Content item classes accepted as input (`WFSafariWebPageContentItem`, `WFURLContentItem`, …); what the share sheet offers this shortcut for. */
74
116
  inputClasses?: string[];
117
+ /** Surfaces the shortcut appears in (`WFWorkflowTypes`); `["ActionExtension"]` puts it in the share sheet. Default none. */
118
+ types?: WorkflowType[];
75
119
  }
76
120
  export declare class Shortcut {
77
121
  readonly name: string;
@@ -79,20 +123,23 @@ export declare class Shortcut {
79
123
  private readonly color;
80
124
  private readonly glyph;
81
125
  private readonly inputClasses;
126
+ private readonly types;
82
127
  constructor(name: string, options?: ShortcutOptions);
83
128
  /**
84
129
  * Append an action. With an identifier from `actions`, parameter keys are checked at compile
85
130
  * time; any identifier is also validated at run time against the bundled definitions.
86
131
  */
87
132
  action<I extends string>(identifier: I, params?: ParamsFor<I>): Action;
88
- if(subject: Attachment, condition: Condition | number, value?: string | number): string;
133
+ if(subject_: Attachment, condition: Condition | number, value?: string | number): string;
89
134
  otherwise(gid: string): void;
90
135
  endIf(gid: string): void;
91
- repeatEach(items: Attachment): string;
92
- endRepeatEach(gid: string): void;
136
+ repeatEach(items: ParamTypes["is.workflow.actions.repeat.each"]["WFInput"]): string;
137
+ /** Close a Repeat with Each block. The returned action is the block's output: `ref()` it for the collected "Repeat Results". */
138
+ endRepeatEach(gid: string): Action;
93
139
  /** Open a Repeat block that runs `count` times; returns the grouping identifier for endRepeatCount(). */
94
- repeatCount(count: number | Attachment): string;
95
- endRepeatCount(gid: string): void;
140
+ repeatCount(count: ParamTypes["is.workflow.actions.repeat.count"]["WFRepeatCount"]): string;
141
+ /** Close a Repeat block. The returned action is the block's output: `ref()` it for the collected "Repeat Results". */
142
+ endRepeatCount(gid: string): Action;
96
143
  /**
97
144
  * Open a Choose from Menu block. Follow with one menuItem() per title, in order, each with the
98
145
  * actions of that branch, then endMenu(). Returns the grouping identifier.