shortcutkit 0.7.0 → 1.0.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/README.md +88 -183
- package/dist/generated/actions.d.ts +17230 -1567
- package/dist/generated/params.d.ts +99 -83
- package/dist/index.d.ts +65 -29
- package/dist/index.js +3164 -248
- package/dist/values.d.ts +16 -5
- package/package.json +8 -4
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { type PlistValue } from "./plist.js";
|
|
|
2
2
|
import { type ActionDefinition } from "./definitions.js";
|
|
3
3
|
import { ACTIONS } from "./generated/actions.js";
|
|
4
4
|
import type { ActionId, MetaParams, ParamTypes } from "./generated/actions.js";
|
|
5
|
-
import type { Attachment,
|
|
6
|
-
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";
|
|
7
7
|
export type { PlistValue } from "./plist.js";
|
|
8
8
|
export type * from "./values.js";
|
|
9
9
|
export { getDefinition, allDefinitions, type ActionDefinition, type ParameterDefinition, type Localized } from "./definitions.js";
|
|
@@ -11,22 +11,23 @@ export { provenance, type Provenance } from "./provenance.js";
|
|
|
11
11
|
export type * from "./generated/params.js";
|
|
12
12
|
/** Parameters accepted for an identifier: typed per key for built-in actions, open for anything else. */
|
|
13
13
|
export type ParamsFor<I extends string> = I extends ActionId ? Partial<ParamTypes[I] & MetaParams> : Record<string, Value>;
|
|
14
|
+
/** An action as `action()` returns it; pass it to `ref()` to use its output. */
|
|
14
15
|
export type Action = {
|
|
15
16
|
WFWorkflowActionIdentifier: string;
|
|
16
17
|
WFWorkflowActionParameters: Record<string, Value>;
|
|
17
18
|
outputName?: string;
|
|
18
19
|
outputTypes?: readonly string[];
|
|
19
20
|
};
|
|
20
|
-
/** Content types an action's output can be (`WFStringContentItem`, `NSURL`, an App Intents entity, …). Shortcuts
|
|
21
|
+
/** Content types an action's output can be (`WFStringContentItem`, `NSURL`, an App Intents entity, …). Shortcuts converts between many of them at run time, so this is a description, not a restriction. */
|
|
21
22
|
export type OutputTypes<I extends ActionId> = (typeof ACTIONS)[I]["outputTypes"];
|
|
22
|
-
/** What the
|
|
23
|
+
/** What the catalog knows about an identifier, built-in or App Intent. */
|
|
23
24
|
export type CatalogEntry = {
|
|
24
25
|
identifier: string;
|
|
25
26
|
/** Display name, as the editor shows it. */
|
|
26
27
|
name: string;
|
|
27
28
|
/** Parameter keys the action accepts, in the editor's order. */
|
|
28
29
|
params: readonly string[];
|
|
29
|
-
/** Value kind per key: bool, number, string, text, picker, plainString, plainNumber, dictionary, quantity, filter, any. */
|
|
30
|
+
/** Value kind per key: bool, number, string, text, picker, subject, plainString, plainNumber, dictionary, quantity, filter, any. */
|
|
30
31
|
kinds: Record<string, string>;
|
|
31
32
|
/** Output name, or null when the action produces nothing. */
|
|
32
33
|
output: string | null;
|
|
@@ -38,8 +39,8 @@ export type CatalogEntry = {
|
|
|
38
39
|
definition?: ActionDefinition;
|
|
39
40
|
};
|
|
40
41
|
/**
|
|
41
|
-
* Look up any
|
|
42
|
-
*
|
|
42
|
+
* Look up any catalog identifier, built-in or App Intent. Unlike getDefinition(), which knows
|
|
43
|
+
* only built-ins, this covers both in one shape.
|
|
43
44
|
*/
|
|
44
45
|
export declare function getAction(identifier: string): CatalogEntry | undefined;
|
|
45
46
|
/** Names the app that provides an App Intents action; written as the AppIntentDescriptor parameter. */
|
|
@@ -49,7 +50,7 @@ export type AppIntentDescriptor = {
|
|
|
49
50
|
TeamIdentifier: string;
|
|
50
51
|
AppIntentIdentifier: string;
|
|
51
52
|
};
|
|
52
|
-
/**
|
|
53
|
+
/** The icon palette, in picker order, as the file stores each color. */
|
|
53
54
|
export declare const ICON_COLORS: {
|
|
54
55
|
readonly Red: 4282601983;
|
|
55
56
|
readonly DarkOrange: 4251333119;
|
|
@@ -69,7 +70,7 @@ export declare const ICON_COLORS: {
|
|
|
69
70
|
};
|
|
70
71
|
export type IconColor = keyof typeof ICON_COLORS;
|
|
71
72
|
export declare const DEFAULT_GLYPH = 61440;
|
|
72
|
-
/**
|
|
73
|
+
/** If condition codes. less_than, greater_than, contains, has_any_value, and has_no_value are verified against the engine or Apple's files; the rest follow community documentation. */
|
|
73
74
|
export declare const CONDITION: {
|
|
74
75
|
readonly less_than: 0;
|
|
75
76
|
readonly less_or_equal: 1;
|
|
@@ -87,52 +88,87 @@ export declare const CONDITION: {
|
|
|
87
88
|
};
|
|
88
89
|
export type Condition = keyof typeof CONDITION;
|
|
89
90
|
/** Reference another action's output. */
|
|
90
|
-
export declare const ref: (action: Action, outputName?: string) => Attachment
|
|
91
|
-
|
|
92
|
-
export declare const
|
|
93
|
-
|
|
94
|
-
export declare const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
export declare const ref: (action: Action, outputName?: string) => Attachment<"ActionOutput">;
|
|
92
|
+
/** A named variable, as set by Set Variable or Add to Variable. */
|
|
93
|
+
export declare const variable: (name: string) => Attachment<"Variable">;
|
|
94
|
+
/** The shortcut's input, from the share sheet, Quick Actions, or Run Shortcut. */
|
|
95
|
+
export declare const shortcutInput: () => Attachment<"ExtensionInput">;
|
|
96
|
+
/** The clipboard's contents. */
|
|
97
|
+
export declare const clipboard: () => Attachment<"Clipboard">;
|
|
98
|
+
/** The date and time the shortcut runs. */
|
|
99
|
+
export declare const currentDate: () => Attachment<"CurrentDate">;
|
|
100
|
+
/** A value the user is asked for each time the shortcut runs. */
|
|
101
|
+
export declare const ask: (prompt?: string) => AskAttachment;
|
|
102
|
+
/** Device Details (name, model, OS version, …); the app usually adds a property aggrandizement. */
|
|
103
|
+
export declare const deviceDetails: () => Attachment<"DeviceDetails">;
|
|
104
|
+
/** The app the shortcut was run from. */
|
|
105
|
+
export declare const currentApp: () => Attachment<"CurrentApp">;
|
|
106
|
+
/** The If-subject form of a reference. `if()` and `action()` apply it for you. */
|
|
107
|
+
export declare const subject: (a: Attachment) => ConditionSubject;
|
|
108
|
+
/** @deprecated Misnamed: this produces the If-subject form. Pass a bare `ref()` to variable-picker parameters; use `subject()` for If. */
|
|
109
|
+
export declare const picker: (a: Attachment) => ConditionSubject;
|
|
110
|
+
/** The current item inside a Repeat with Each block. */
|
|
111
|
+
export declare const repeatItem: () => Attachment<"Variable">;
|
|
112
|
+
/** The current index (1-based) inside a Repeat block. */
|
|
113
|
+
export declare const repeatIndex: () => Attachment<"Variable">;
|
|
114
|
+
/** Text with references in it: `text("Hello, ", ref(name), "!")`. */
|
|
99
115
|
export declare function text(...parts: Array<string | number | Attachment>): TokenString;
|
|
116
|
+
/** Where a shortcut is offered beyond the app: `ActionExtension` is the share sheet, `QuickActions` the Finder and Services menus, `MenuBar`, `NCWidget`, `WatchKit`, `Sleep`, `ReceivesOnScreenContent`. */
|
|
117
|
+
export type WorkflowType = "ActionExtension" | "QuickActions" | "MenuBar" | "NCWidget" | "WatchKit" | "Sleep" | "ReceivesOnScreenContent";
|
|
100
118
|
export interface ShortcutOptions {
|
|
119
|
+
/** Icon color: a palette name (`"Teal"`) or a raw value. Default `"Blue"`. */
|
|
101
120
|
color?: IconColor | number;
|
|
121
|
+
/** Icon glyph, a codepoint from Shortcuts' icon font. Default 61440. */
|
|
102
122
|
glyph?: number;
|
|
123
|
+
/** Content item classes accepted as input (`WFSafariWebPageContentItem`, `WFURLContentItem`, …); what the share sheet offers this shortcut for. */
|
|
103
124
|
inputClasses?: string[];
|
|
125
|
+
/** Surfaces the shortcut appears in (`WFWorkflowTypes`); `["ActionExtension"]` puts it in the share sheet. Default none. */
|
|
126
|
+
types?: WorkflowType[];
|
|
104
127
|
}
|
|
128
|
+
/** A shortcut. Add actions, then `write()` and `sign()`; Shortcuts names the import after the file, which defaults to `<name>.shortcut`. */
|
|
105
129
|
export declare class Shortcut {
|
|
106
130
|
readonly name: string;
|
|
107
131
|
readonly actions: Action[];
|
|
108
132
|
private readonly color;
|
|
109
133
|
private readonly glyph;
|
|
110
134
|
private readonly inputClasses;
|
|
135
|
+
private readonly types;
|
|
111
136
|
constructor(name: string, options?: ShortcutOptions);
|
|
112
137
|
/**
|
|
113
|
-
* Append an action
|
|
114
|
-
*
|
|
138
|
+
* Append an action and return it; `ref()` it to use its output. Catalog identifiers are checked:
|
|
139
|
+
* wrong keys and values don't compile, and unknown keys or unreadable references throw. Other
|
|
140
|
+
* identifiers pass through unchecked.
|
|
115
141
|
*/
|
|
116
142
|
action<I extends string>(identifier: I, params?: ParamsFor<I>): Action;
|
|
143
|
+
/** Open an If block on `subject`. `condition` is a `CONDITION` name or code; `value` is what it compares with, if anything. Returns the id for `otherwise()` and `endIf()`. */
|
|
117
144
|
if(subject: Attachment, condition: Condition | number, value?: string | number): string;
|
|
145
|
+
/** Start the Otherwise branch of If block `gid`. */
|
|
118
146
|
otherwise(gid: string): void;
|
|
147
|
+
/** Close If block `gid`. */
|
|
119
148
|
endIf(gid: string): void;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
|
|
124
|
-
endRepeatCount(
|
|
149
|
+
/** Open a Repeat with Each block over `items`; returns the id for `endRepeatEach()`. Inside, use `repeatItem()` and `repeatIndex()`. */
|
|
150
|
+
repeatEach(items: ParamTypes["is.workflow.actions.repeat.each"]["WFInput"]): string;
|
|
151
|
+
/** Close a Repeat with Each block and return it; `ref()` it for the Repeat Results. */
|
|
152
|
+
endRepeatEach(gid: string): Action;
|
|
153
|
+
/** Open a Repeat block that runs `count` times; returns the id for `endRepeatCount()`. */
|
|
154
|
+
repeatCount(count: ParamTypes["is.workflow.actions.repeat.count"]["WFRepeatCount"]): string;
|
|
155
|
+
/** Close a Repeat block and return it; `ref()` it for the Repeat Results. */
|
|
156
|
+
endRepeatCount(gid: string): Action;
|
|
125
157
|
/**
|
|
126
|
-
* Open a Choose from Menu block
|
|
127
|
-
*
|
|
158
|
+
* Open a Choose from Menu block; returns the id for `menuItem()` and `endMenu()`. Follow with one
|
|
159
|
+
* `menuItem()` per title, in order, each followed by that branch's actions.
|
|
128
160
|
*/
|
|
129
161
|
chooseFromMenu(prompt: string | TokenString, items: string[]): string;
|
|
162
|
+
/** Start the branch for `title` in menu `gid`. */
|
|
130
163
|
menuItem(gid: string, title: string): void;
|
|
164
|
+
/** Close menu `gid`. */
|
|
131
165
|
endMenu(gid: string): void;
|
|
166
|
+
/** The shortcut as a plist object. */
|
|
132
167
|
toPlist(): Record<string, PlistValue>;
|
|
168
|
+
/** The shortcut as an XML plist. */
|
|
133
169
|
toXml(): string;
|
|
134
|
-
/** Write the unsigned file
|
|
170
|
+
/** Write the unsigned file, `<name>.shortcut` by default, and return its path. Binary if `plutil` is installed, XML otherwise. */
|
|
135
171
|
write(path?: string): Promise<string>;
|
|
136
|
-
/** Sign
|
|
172
|
+
/** Sign `input` into `output`, which Shortcuts will import, and return `output`. Needs a Mac with an iCloud login. */
|
|
137
173
|
static sign(input: string, output: string, mode?: "anyone" | "people-who-know-me"): string;
|
|
138
174
|
}
|