diff --git a/config/build.ts b/config/build.ts index 9b5dc353c..a9dc8047d 100644 --- a/config/build.ts +++ b/config/build.ts @@ -42,7 +42,7 @@ const defaultApiSets = { /* any other hosts is allowed to have no API sets specified*/ }; - +const outlookEndpoints = ['messageread', 'messagecompose', 'appointmentread', 'appointmentcompose']; (async () => { let processedSnippets = new Dictionary(); @@ -154,7 +154,8 @@ async function processSnippets(processedSnippets: Dictionary { + const creatingStatusText = `Creating ${host}-${endpoint}.yaml`; + status.add(creatingStatusText); + let endpointItems = modifiedItems.filter((item) => item.endpoints.indexOf(endpoint) !== -1); + contents = jsyaml.safeDump(endpointItems, { + skipInvalid: true + }); + fileName = `playlists/${host}-${endpoint}.yaml`; + await writeFile(path.resolve(fileName), contents); + status.complete(true /*success*/, creatingStatusText); + }); + } + }); /* Creating view directory */ diff --git a/config/helpers.ts b/config/helpers.ts index 0df238a89..ece15950d 100644 --- a/config/helpers.ts +++ b/config/helpers.ts @@ -40,6 +40,7 @@ export interface SnippetProcessedData { [index: string]: number }; isPublic: boolean; + endpoints?: string[]; } /** diff --git a/config/snippet.d.ts b/config/snippet.d.ts index f0a4e31a9..16f2ba062 100644 --- a/config/snippet.d.ts +++ b/config/snippet.d.ts @@ -8,6 +8,7 @@ interface ITemplate { name?: string; description?: string; author?: string; + endpoints?: string[]; host: string; api_set: { [index: string]: number diff --git a/config/snippet.helpers.ts b/config/snippet.helpers.ts index f2574957d..9365ed64f 100644 --- a/config/snippet.helpers.ts +++ b/config/snippet.helpers.ts @@ -31,6 +31,7 @@ const snippetFields: { [key: string]: SnippetFieldType } = { origin: SnippetFieldType.TRANSIENT, created_at: SnippetFieldType.INTERNAL, modified_at: SnippetFieldType.INTERNAL, + endpoints: SnippetFieldType.PUBLIC, /* ISnippet */ script: SnippetFieldType.PUBLIC, diff --git a/playlists/outlook-appointmentcompose.yaml b/playlists/outlook-appointmentcompose.yaml new file mode 100644 index 000000000..9d64e78e7 --- /dev/null +++ b/playlists/outlook-appointmentcompose.yaml @@ -0,0 +1,22 @@ +- id: outlook-body-get-set-selected-text + name: Get/Set Selected Text + fileName: set-selected-text.yaml + description: Gets and Changes the value of selected text in body or subject. + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/01-body/set-selected-text.yaml + group: Body + api_set: {} + endpoints: + - messagecompose + - appointmentcompose +- id: outlook-subject-get-set-item-subject + name: Get/Set Item Subject + fileName: get-set-item-subject.yaml + description: Gets and Sets the subject of a compose item + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/02-subject/get-set-item-subject.yaml + group: Subject + api_set: {} + endpoints: + - messagecompose + - appointmentcompose diff --git a/playlists/outlook-appointmentread.yaml b/playlists/outlook-appointmentread.yaml new file mode 100644 index 000000000..8cfd9db6e --- /dev/null +++ b/playlists/outlook-appointmentread.yaml @@ -0,0 +1,22 @@ +- id: outlook-body-get-selected-text + name: Get Selected Text + fileName: get-selected-text.yaml + description: Outputs the text selected from either the body or subject. + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/01-body/get-selected-text.yaml + group: Body + api_set: {} + endpoints: + - messageread + - appointmentread +- id: outlook-subject-get-item-subject + name: Get Item Subject + fileName: get-item-subject.yaml + description: Gets the subject of a compose item + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/02-subject/get-item-subject.yaml + group: Subject + api_set: {} + endpoints: + - messageread + - appointmentread diff --git a/playlists/outlook-messagecompose.yaml b/playlists/outlook-messagecompose.yaml new file mode 100644 index 000000000..9d64e78e7 --- /dev/null +++ b/playlists/outlook-messagecompose.yaml @@ -0,0 +1,22 @@ +- id: outlook-body-get-set-selected-text + name: Get/Set Selected Text + fileName: set-selected-text.yaml + description: Gets and Changes the value of selected text in body or subject. + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/01-body/set-selected-text.yaml + group: Body + api_set: {} + endpoints: + - messagecompose + - appointmentcompose +- id: outlook-subject-get-set-item-subject + name: Get/Set Item Subject + fileName: get-set-item-subject.yaml + description: Gets and Sets the subject of a compose item + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/02-subject/get-set-item-subject.yaml + group: Subject + api_set: {} + endpoints: + - messagecompose + - appointmentcompose diff --git a/playlists/outlook-messageread.yaml b/playlists/outlook-messageread.yaml new file mode 100644 index 000000000..8cfd9db6e --- /dev/null +++ b/playlists/outlook-messageread.yaml @@ -0,0 +1,22 @@ +- id: outlook-body-get-selected-text + name: Get Selected Text + fileName: get-selected-text.yaml + description: Outputs the text selected from either the body or subject. + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/01-body/get-selected-text.yaml + group: Body + api_set: {} + endpoints: + - messageread + - appointmentread +- id: outlook-subject-get-item-subject + name: Get Item Subject + fileName: get-item-subject.yaml + description: Gets the subject of a compose item + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/02-subject/get-item-subject.yaml + group: Subject + api_set: {} + endpoints: + - messageread + - appointmentread diff --git a/playlists/outlook.yaml b/playlists/outlook.yaml index 8c6436a54..31ad76913 100644 --- a/playlists/outlook.yaml +++ b/playlists/outlook.yaml @@ -1,24 +1,44 @@ -- id: outlook-compose-basics-get-item-subject - name: Get Item Subject - fileName: get-item-subject.yaml - description: Gets the subject of a compose item - rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/01-compose-basics/get-item-subject.yaml - group: Compose Basics - api_set: {} -- id: outlook-compose-basics-get-selected-text +- id: outlook-body-get-selected-text name: Get Selected Text fileName: get-selected-text.yaml description: Outputs the text selected from either the body or subject. rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/01-compose-basics/get-selected-text.yaml - group: Compose Basics + https://raw.githubusercontent.com////samples/outlook/01-body/get-selected-text.yaml + group: Body api_set: {} -- id: outlook-compose-basics-set-selected-text - name: Set Selected Text + endpoints: + - messageread + - appointmentread +- id: outlook-body-get-set-selected-text + name: Get/Set Selected Text fileName: set-selected-text.yaml - description: Changes the value of selected text in body or subject. + description: Gets and Changes the value of selected text in body or subject. + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/01-body/set-selected-text.yaml + group: Body + api_set: {} + endpoints: + - messagecompose + - appointmentcompose +- id: outlook-subject-get-item-subject + name: Get Item Subject + fileName: get-item-subject.yaml + description: Gets the subject of a compose item + rawUrl: >- + https://raw.githubusercontent.com////samples/outlook/02-subject/get-item-subject.yaml + group: Subject + api_set: {} + endpoints: + - messageread + - appointmentread +- id: outlook-subject-get-set-item-subject + name: Get/Set Item Subject + fileName: get-set-item-subject.yaml + description: Gets and Sets the subject of a compose item rawUrl: >- - https://raw.githubusercontent.com////samples/outlook/01-compose-basics/set-selected-text.yaml - group: Compose Basics + https://raw.githubusercontent.com////samples/outlook/02-subject/get-set-item-subject.yaml + group: Subject api_set: {} + endpoints: + - messagecompose + - appointmentcompose diff --git a/samples/outlook/01-compose-basics/get-selected-text.yaml b/samples/outlook/01-body/get-selected-text.yaml similarity index 86% rename from samples/outlook/01-compose-basics/get-selected-text.yaml rename to samples/outlook/01-body/get-selected-text.yaml index eadb9e467..50b6b5e75 100644 --- a/samples/outlook/01-compose-basics/get-selected-text.yaml +++ b/samples/outlook/01-body/get-selected-text.yaml @@ -1,6 +1,10 @@ -id: outlook-compose-basics-get-selected-text +id: outlook-body-get-selected-text name: Get Selected Text description: Outputs the text selected from either the body or subject. +endpoints: + - messageread + - appointmentread +author: OfficeDev host: OUTLOOK api_set: {} script: @@ -30,8 +34,8 @@ style: /* Your style goes here */ language: css libraries: | - https://unpkg.com/@microsoft/office-js@1.1.1-private.1/dist/office.js - https://unpkg.com/@microsoft/office-js@1.1.1-private.1/dist/office.d.ts + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://appsforoffice.microsoft.com/lib/1/hosted/office.d.ts office-ui-fabric-js@1.4.0/dist/css/fabric.min.css office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/01-body/set-selected-text.yaml b/samples/outlook/01-body/set-selected-text.yaml new file mode 100644 index 000000000..4787272c7 --- /dev/null +++ b/samples/outlook/01-body/set-selected-text.yaml @@ -0,0 +1,72 @@ +id: outlook-body-get-set-selected-text +name: Get/Set Selected Text +description: Gets and Changes the value of selected text in body or subject. +endpoints: + - messagecompose + - appointmentcompose +author: OfficeDev +host: OUTLOOK +api_set: {} +script: + content: | + $("#get").click(get); + $("#set").click(set); + + function get() { + let item = Office.context.mailbox.item as Office.ItemCompose; + item.getSelectedDataAsync(Office.CoercionType.Text, (result: Office.AsyncResult) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + OfficeHelpers.UI.notify(`Action failed with message ${result.error.message}`); + return; + } + $("#text").val(result.value.data) + OfficeHelpers.UI.notify(`Get completed!`); + }) + } + + function set() { + let item = Office.context.mailbox.item as Office.ItemCompose; + item.setSelectedDataAsync($("#text").val(), (result: Office.AsyncResult) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + OfficeHelpers.UI.notify(`Action failed with message ${result.error.message}`); + return; + } + OfficeHelpers.UI.notify(`Set completed!`); + }) + } + language: typescript +template: + content: | +
+ + +
+
+ + + language: html +style: + content: | + /* Your style goes here */ + language: css +libraries: | + # Office.js + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://appsforoffice.microsoft.com/lib/1/hosted/office.d.ts + + # CSS Libraries + office-ui-fabric-js@1.4.0/dist/css/fabric.min.css + office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css + + # NPM libraries + @microsoft/office-js-helpers@0.7.4/dist/office.helpers.min.js + jquery@3.1.1 + + # IntelliSense: @types/library or node_modules paths or URL to d.ts files + @types/core-js + @microsoft/office-js-helpers@0.7.4/dist/office.helpers.d.ts + @types/jquery \ No newline at end of file diff --git a/samples/outlook/01-compose-basics/set-selected-text.yaml b/samples/outlook/01-compose-basics/set-selected-text.yaml deleted file mode 100644 index 1c3480df3..000000000 --- a/samples/outlook/01-compose-basics/set-selected-text.yaml +++ /dev/null @@ -1,44 +0,0 @@ -id: outlook-compose-basics-set-selected-text -name: Set Selected Text -description: Changes the value of selected text in body or subject. -host: OUTLOOK -api_set: {} -script: - content: | - $("#run").click(run); - - function run() { - let item = Office.context.mailbox.item as Office.ItemCompose; - item.setSelectedDataAsync("Hello World!", (result: Office.AsyncResult) => { - if (result.status === Office.AsyncResultStatus.Failed) { - OfficeHelpers.UI.notify(`Action failed with error: ${result.error.message}`) - } - }) - } - language: typescript -template: - content: | - - - language: html -style: - content: | - /* Your style goes here */ - language: css -libraries: | - https://unpkg.com/@microsoft/office-js@1.1.1-private.1/dist/office.js - https://unpkg.com/@microsoft/office-js@1.1.1-private.1/dist/office.d.ts - - office-ui-fabric-js@1.4.0/dist/css/fabric.min.css - office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css - - core-js@2.4.1/client/core.min.js - @types/core-js - - @microsoft/office-js-helpers@0.7.4/dist/office.helpers.min.js - @microsoft/office-js-helpers@0.7.4/dist/office.helpers.d.ts - - jquery@3.1.1 - @types/jquery \ No newline at end of file diff --git a/samples/outlook/01-compose-basics/get-item-subject.yaml b/samples/outlook/02-subject/get-item-subject.yaml similarity index 56% rename from samples/outlook/01-compose-basics/get-item-subject.yaml rename to samples/outlook/02-subject/get-item-subject.yaml index f460bac55..077253ef5 100644 --- a/samples/outlook/01-compose-basics/get-item-subject.yaml +++ b/samples/outlook/02-subject/get-item-subject.yaml @@ -1,6 +1,10 @@ -id: outlook-compose-basics-get-item-subject +id: outlook-subject-get-item-subject name: Get Item Subject description: Gets the subject of a compose item +endpoints: + - messageread + - appointmentread +author: OfficeDev host: OUTLOOK api_set: {} script: @@ -8,21 +12,15 @@ script: $("#run").click(run); function run() { - let item = Office.context.mailbox.item as Office.ItemCompose; - item.subject.getAsync((result: Office.AsyncResult) => { - if (result.status !== Office.AsyncResultStatus.Succeeded) { - OfficeHelpers.UI.notify(`Action failed with message ${result.error.message}`); - return; - } - OfficeHelpers.UI.notify(`Subject is ${result.value}`); - }) + let item = Office.context.mailbox.item as Office.ItemRead; + OfficeHelpers.UI.notify(`Subject is ${item.subject}`); } language: typescript template: content: | language: html style: @@ -30,8 +28,8 @@ style: /* Your style goes here */ language: css libraries: | - https://unpkg.com/@microsoft/office-js@1.1.1-private.1/dist/office.js - https://unpkg.com/@microsoft/office-js@1.1.1-private.1/dist/office.d.ts + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://appsforoffice.microsoft.com/lib/1/hosted/office.d.ts office-ui-fabric-js@1.4.0/dist/css/fabric.min.css office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css diff --git a/samples/outlook/02-subject/get-set-item-subject.yaml b/samples/outlook/02-subject/get-set-item-subject.yaml new file mode 100644 index 000000000..979d59ba0 --- /dev/null +++ b/samples/outlook/02-subject/get-set-item-subject.yaml @@ -0,0 +1,72 @@ +id: outlook-subject-get-set-item-subject +name: Get/Set Item Subject +description: Gets and Sets the subject of a compose item +endpoints: + - messagecompose + - appointmentcompose +author: OfficeDev +host: OUTLOOK +api_set: {} +script: + content: | + $("#get").click(get); + $("#set").click(set); + + function get() { + let item = Office.context.mailbox.item as Office.ItemCompose; + item.subject.getAsync((result: Office.AsyncResult) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + OfficeHelpers.UI.notify(`Action failed with message ${result.error.message}`); + return; + } + $("#text").val(result.value) + OfficeHelpers.UI.notify(`Get completed!`); + }) + } + + function set() { + let item = Office.context.mailbox.item as Office.ItemCompose; + item.subject.setAsync($("#text").val(), (result: Office.AsyncResult) => { + if (result.status !== Office.AsyncResultStatus.Succeeded) { + OfficeHelpers.UI.notify(`Action failed with message ${result.error.message}`); + return; + } + OfficeHelpers.UI.notify(`Set completed!`); + }) + } + language: typescript +template: + content: | +
+ + +
+
+ + + language: html +style: + content: | + /* Your style goes here */ + language: css +libraries: | + # Office.js + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://appsforoffice.microsoft.com/lib/1/hosted/office.d.ts + + # CSS Libraries + office-ui-fabric-js@1.4.0/dist/css/fabric.min.css + office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css + + # NPM libraries + @microsoft/office-js-helpers@0.7.4/dist/office.helpers.min.js + jquery@3.1.1 + + # IntelliSense: @types/library or node_modules paths or URL to d.ts files + @types/core-js + @microsoft/office-js-helpers@0.7.4/dist/office.helpers.d.ts + @types/jquery \ No newline at end of file diff --git a/samples/outlook/default.yaml b/samples/outlook/default.yaml index 87bd34444..c1708f9ae 100644 --- a/samples/outlook/default.yaml +++ b/samples/outlook/default.yaml @@ -24,7 +24,8 @@ style: language: css libraries: | # Office.js - https://unpkg.com/@microsoft/office-js@1.1.1-private.1/dist/office.js + https://appsforoffice.microsoft.com/lib/1/hosted/Office.js + https://appsforoffice.microsoft.com/lib/1/hosted/office.d.ts # CSS Libraries office-ui-fabric-js@1.4.0/dist/css/fabric.min.css @@ -36,7 +37,6 @@ libraries: | jquery@3.1.1 # IntelliSense: @types/library or node_modules paths or URL to d.ts files - @types/office-js @types/core-js @microsoft/office-js-helpers@0.7.4/dist/office.helpers.d.ts @types/jquery \ No newline at end of file diff --git a/view/outlook.json b/view/outlook.json index 77011f3b3..572f28d88 100644 --- a/view/outlook.json +++ b/view/outlook.json @@ -1,5 +1,6 @@ { - "outlook-compose-basics-get-item-subject": "https://raw.githubusercontent.com////samples/outlook/01-compose-basics/get-item-subject.yaml", - "outlook-compose-basics-get-selected-text": "https://raw.githubusercontent.com////samples/outlook/01-compose-basics/get-selected-text.yaml", - "outlook-compose-basics-set-selected-text": "https://raw.githubusercontent.com////samples/outlook/01-compose-basics/set-selected-text.yaml" + "outlook-body-get-selected-text": "https://raw.githubusercontent.com////samples/outlook/01-body/get-selected-text.yaml", + "outlook-body-get-set-selected-text": "https://raw.githubusercontent.com////samples/outlook/01-body/set-selected-text.yaml", + "outlook-subject-get-item-subject": "https://raw.githubusercontent.com////samples/outlook/02-subject/get-item-subject.yaml", + "outlook-subject-get-set-item-subject": "https://raw.githubusercontent.com////samples/outlook/02-subject/get-set-item-subject.yaml" } \ No newline at end of file