codeapp-js 0.1.0 → 0.2.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/codeApp/dist/codeapp.js +326 -72
- package/codeApp/dist/icon-512.png +0 -0
- package/codeApp/dist/index.html +1 -0
- package/codeApp/dist/index.js +1 -1
- package/codeApp/dist/power-apps-data.js +2952 -2531
- package/codeApp/power.config.json +1 -1
- package/dev files/customConnector.js +98 -0
- package/dev files/dataverse.js +33 -7
- package/dev files/environmentVar.js +1 -1
- package/dev files/office365groups.js +1 -1
- package/dev files/office365users.js +1 -1
- package/dev files/outlook.js +1 -1
- package/dev files/power-apps-data.js +2952 -0
- package/dev files/sharepoint.js +1 -1
- package/examples/combined demo/dist/codeapp.js +1098 -0
- package/examples/combined demo/dist/index.js +470 -515
- package/examples/combined demo/dist/power-apps-data.js +3007 -2531
- package/examples/dataverse Demo/dist/codeapp.js +1085 -0
- package/examples/dataverse Demo/dist/index.js +38 -26
- package/examples/dataverse Demo/dist/power-apps-data.js +2912 -2531
- package/examples/groups Demo/dist/codeapp.js +1085 -0
- package/examples/groups Demo/dist/index.js +113 -113
- package/examples/groups Demo/dist/power-apps-data.js +2912 -2531
- package/examples/groups Demo/power.config.json +3 -2
- package/examples/kanban/dist/power-apps-data.js +2953 -2531
- package/examples/myProfile/dist/power-apps-data.js +2953 -2531
- package/examples/outlook Demo/dist/codeapp.js +1085 -0
- package/examples/outlook Demo/dist/index.js +39 -35
- package/examples/outlook Demo/dist/power-apps-data.js +2912 -2531
- package/examples/planning Poker/dist/power-apps-data.js +2953 -2531
- package/examples/sharePoint Demo/dist/codeapp.js +1085 -0
- package/examples/sharePoint Demo/dist/index.js +262 -269
- package/examples/sharePoint Demo/dist/power-apps-data.js +2912 -2531
- package/examples/solution explorer/agent/decision-log.md +27 -0
- package/examples/solution explorer/agent/mockup-01-swiss-grid.html +452 -0
- package/examples/solution explorer/agent/mockup-02-dark-glass.html +496 -0
- package/examples/solution explorer/agent/mockup-03-paper-console.html +510 -0
- package/examples/solution explorer/agent/mockup-04-neon-noir.html +546 -0
- package/examples/solution explorer/agent/mockup-05-zen-garden.html +534 -0
- package/examples/solution explorer/dist/codeapp.js +1098 -0
- package/examples/solution explorer/dist/icon-512.png +0 -0
- package/examples/solution explorer/dist/index.html +80 -0
- package/examples/solution explorer/dist/index.js +735 -0
- package/examples/solution explorer/dist/power-apps-data.js +3007 -0
- package/examples/solution explorer/dist/styles.css +571 -0
- package/examples/solution explorer/power.config.json +151 -0
- package/examples/todo/dist/power-apps-data.js +2953 -2531
- package/package.json +1 -8
- package/.github/instructions/wyattdave.instructions.md +0 -39
- package/examples/combined demo/dist/dataverse.js +0 -86
- package/examples/combined demo/dist/environmentVar.js +0 -55
- package/examples/combined demo/dist/office365groups.js +0 -97
- package/examples/combined demo/dist/office365users.js +0 -169
- package/examples/combined demo/dist/outlook.js +0 -162
- package/examples/combined demo/dist/sharepoint.js +0 -339
- package/examples/dataverse Demo/dist/dataverse.js +0 -86
- package/examples/groups Demo/dist/dataverse.js +0 -86
- package/examples/groups Demo/dist/environmentVar.js +0 -55
- package/examples/groups Demo/dist/office365groups.js +0 -97
- package/examples/groups Demo/dist/office365users.js +0 -169
- package/examples/groups Demo/dist/outlook.js +0 -162
- package/examples/groups Demo/dist/sharepoint.js +0 -339
- package/examples/sharePoint Demo/dist/dataverse.js +0 -94
- package/examples/sharePoint Demo/dist/environmentVar.js +0 -55
- package/examples/sharePoint Demo/dist/office365groups.js +0 -97
- package/examples/sharePoint Demo/dist/office365users.js +0 -169
- package/examples/sharePoint Demo/dist/outlook.js +0 -162
- package/examples/sharePoint Demo/dist/sharepoint.js +0 -339
- package/scripts/build-power-sdk.mjs +0 -69
package/package.json
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeapp-js",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "JavaScript library with samples and starter app for Power Apps Code Apps.",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "npm run build:sdk",
|
|
8
|
-
"build:sdk": "node ./scripts/build-power-sdk.mjs",
|
|
9
|
-
"postinstall": "npm run build:sdk",
|
|
10
7
|
"start": "http-server . -p 4173 -c-1",
|
|
11
8
|
"start:codeapp": "http-server . -p 4173 -c-1 -o /codeApp/dist/"
|
|
12
9
|
},
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"@microsoft/power-apps": "1.0.4"
|
|
15
|
-
},
|
|
16
10
|
"devDependencies": {
|
|
17
|
-
"esbuild": "0.25.1",
|
|
18
11
|
"http-server": "14.1.1"
|
|
19
12
|
}
|
|
20
13
|
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# Copilot Instructions
|
|
2
|
-
|
|
3
|
-
These instructions guide AI coding agents working in this repository to be immediately productive and consistent with project conventions.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
- standard web technologies: HTML, CSS, JavaScript (ES6+).
|
|
7
|
-
- Core files:
|
|
8
|
-
- `index.html`: Structure, assets, and script/style inclusions.
|
|
9
|
-
- `styles.css`: responsive and built to light/dark themes using CSS custom properties.
|
|
10
|
-
- `script.js`: key functionality of the site
|
|
11
|
-
- `dom.js`: dom manipulation functions
|
|
12
|
-
- `imgs/`: image files for UI icons.
|
|
13
|
-
- `README.md`: Features, usage, and future enhancements.
|
|
14
|
-
- `Sitemap.xml`: for search engine indexing.
|
|
15
|
-
- No build step or backend;
|
|
16
|
-
- Create as a Progressive Web App (PWA) with service worker for offline support and caching, but with always fetching latest data when online.
|
|
17
|
-
- cloudflare hosting
|
|
18
|
-
|
|
19
|
-
- Follow `wyattdave.instructions.md` conventions:
|
|
20
|
-
- Use camelCase for variables and functions.
|
|
21
|
-
- Prefix variable names: `b` boolean, `i` number, `s` string, `a` array, `o` object, `e` element.
|
|
22
|
-
- Ensure variables are type consistent and avoid implicit type coercion by using naming conventions.
|
|
23
|
-
- CSS should be in a separate file, avoid inline styles unless for dynamic styling.
|
|
24
|
-
- JavaScript should be in a separate file, avoid inline event handlers and scripts in html.
|
|
25
|
-
- JavaScript files should follow: script.js for main logic, dom.js for dom manipulation functions, specific js files for large logic, and per html page for page-specific logic.
|
|
26
|
-
- Function-first approach; avoid classes unless necessary.
|
|
27
|
-
- Build functions for reusability and testability; avoid inline code blocks.
|
|
28
|
-
- Use descriptive names for variables and functions, avoiding abbreviations.
|
|
29
|
-
- Use let and const, avoid var.
|
|
30
|
-
- Use const for dom elements where possible.
|
|
31
|
-
- Use strict equality `===` and inequality `!==`.
|
|
32
|
-
- Use `//` for single-line comments and `/* */` for multi-line comments.
|
|
33
|
-
- Use forEach, map, filter, reduce for array operations instead of for loops where appropriate.
|
|
34
|
-
- Use arrow functions for anonymous functions and callbacks.
|
|
35
|
-
- Use " for html attributes and ' for js strings, ` for template literals.
|
|
36
|
-
- Use `new RegExp("pattern","flags")` (avoid literal `/.../flags`).
|
|
37
|
-
- Use `fetch` for API calls, with async/await syntax.
|
|
38
|
-
- Handle errors gracefully with try/catch and user-friendly messages.
|
|
39
|
-
- Prefer string concatenation `"a"+variable+"b"` over template literals.
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { getClient } from "@microsoft/power-apps/data";
|
|
2
|
-
|
|
3
|
-
// ── All Table Definitions ──────────────────────────────────────
|
|
4
|
-
const ALL_DATA_SOURCES = {
|
|
5
|
-
wd_pokersessions: { tableId: '', version: '', primaryKey: 'wd_pokersessionid', dataSourceType: 'Dataverse', apis: {} },
|
|
6
|
-
wd_pokerparticipants: { tableId: '', version: '', primaryKey: 'wd_pokerparticipantid', dataSourceType: 'Dataverse', apis: {} },
|
|
7
|
-
wd_pokerrounds: { tableId: '', version: '', primaryKey: 'wd_pokerroundid', dataSourceType: 'Dataverse', apis: {} },
|
|
8
|
-
wd_pokervotes: { tableId: '', version: '', primaryKey: 'wd_pokervoteid', dataSourceType: 'Dataverse', apis: {} },
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// ── Initialize SDK & Client ────────────────────────────────────
|
|
12
|
-
let oSharedClient = null;
|
|
13
|
-
|
|
14
|
-
function getSharedClient() {
|
|
15
|
-
if (!oSharedClient) {
|
|
16
|
-
oSharedClient = getClient(ALL_DATA_SOURCES);
|
|
17
|
-
}
|
|
18
|
-
return oSharedClient;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// ── Unwrap SDK response ────────────────────────────────────────
|
|
22
|
-
function unwrapResult(result) {
|
|
23
|
-
if (result && result.success === false) {
|
|
24
|
-
var sMsg = result.error ? (result.error.message || JSON.stringify(result.error)) : 'Operation failed';
|
|
25
|
-
throw new Error(sMsg);
|
|
26
|
-
}
|
|
27
|
-
return result && 'data' in result ? result.data : result;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// ── Create ─────────────────────────────────────────────────────
|
|
31
|
-
export async function createItem(tableName, primaryKey, record) {
|
|
32
|
-
const client = getSharedClient();
|
|
33
|
-
const result = await client.createRecordAsync(tableName, record);
|
|
34
|
-
return unwrapResult(result);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ── Read (single) ──────────────────────────────────────────────
|
|
38
|
-
export async function getItem(tableName, primaryKey, id, select) {
|
|
39
|
-
const client = getSharedClient();
|
|
40
|
-
const options = select ? { select } : undefined;
|
|
41
|
-
const result = await client.retrieveRecordAsync(tableName, id, options);
|
|
42
|
-
return unwrapResult(result);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ── List (multiple) ────────────────────────────────────────────
|
|
46
|
-
export async function listItems(tableName, primaryKey, { filter, select, orderBy, top, skip } = {}) {
|
|
47
|
-
const client = getSharedClient();
|
|
48
|
-
const result = await client.retrieveMultipleRecordsAsync(tableName, {
|
|
49
|
-
filter,
|
|
50
|
-
select,
|
|
51
|
-
orderBy,
|
|
52
|
-
top,
|
|
53
|
-
skip,
|
|
54
|
-
});
|
|
55
|
-
var unwrapped = unwrapResult(result);
|
|
56
|
-
return { entities: Array.isArray(unwrapped) ? unwrapped : [] };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ── Update ─────────────────────────────────────────────────────
|
|
60
|
-
export async function updateItem(tableName, primaryKey, id, changedFields) {
|
|
61
|
-
const client = getSharedClient();
|
|
62
|
-
const result = await client.updateRecordAsync(tableName, id, changedFields);
|
|
63
|
-
return unwrapResult(result);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ── Delete ─────────────────────────────────────────────────────
|
|
67
|
-
export async function deleteItem(tableName, primaryKey, id) {
|
|
68
|
-
const client = getSharedClient();
|
|
69
|
-
const result = await client.deleteRecordAsync(tableName, id);
|
|
70
|
-
return unwrapResult(result);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ── Unbound Action ─────────────────────────────────────────────
|
|
74
|
-
export async function callUnboundAction(tableName, primaryKey, actionName, params) {
|
|
75
|
-
const client = getSharedClient();
|
|
76
|
-
const result = await client.invokeActionAsync(tableName, actionName, params);
|
|
77
|
-
return unwrapResult(result);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// ── WhoAmI ─────────────────────────────────────────────────────
|
|
81
|
-
export async function whoAmI() {
|
|
82
|
-
const client = getSharedClient();
|
|
83
|
-
const result = await client.invokeActionAsync('', 'WhoAmI', {});
|
|
84
|
-
var data = unwrapResult(result);
|
|
85
|
-
return data.UserId || data.userid || data.systemuserid || data;
|
|
86
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { getClient } from "@microsoft/power-apps/data";
|
|
2
|
-
|
|
3
|
-
// ── All Table Definitions ──────────────────────────────────────
|
|
4
|
-
const ALL_DATA_SOURCES = {
|
|
5
|
-
environmentvariabledefinitions: { tableId: "", version: "", primaryKey: "environmentvariabledefinitionid", dataSourceType: "Dataverse", apis: {} },
|
|
6
|
-
environmentvariablevalues: { tableId: "", version: "", primaryKey: "environmentvariablevalueid", dataSourceType: "Dataverse", apis: {} },
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
// ── Initialize SDK & Client ────────────────────────────────────
|
|
10
|
-
let oSharedClient = null;
|
|
11
|
-
|
|
12
|
-
function getSharedClient() {
|
|
13
|
-
if (!oSharedClient) {
|
|
14
|
-
oSharedClient = getClient(ALL_DATA_SOURCES);
|
|
15
|
-
}
|
|
16
|
-
return oSharedClient;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// ── Unwrap SDK response ────────────────────────────────────────
|
|
20
|
-
function unwrapResult(result) {
|
|
21
|
-
if (result && result.success === false) {
|
|
22
|
-
let sMsg = result.error ? (result.error.message || JSON.stringify(result.error)) : "Operation failed";
|
|
23
|
-
throw new Error(sMsg);
|
|
24
|
-
}
|
|
25
|
-
return result && "data" in result ? result.data : result;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// ── Get Environment Variable (single query with expand) ────────
|
|
29
|
-
export async function getEnvironmentVariable(sSchemaName) {
|
|
30
|
-
let client = getSharedClient();
|
|
31
|
-
|
|
32
|
-
// Try single query: filter values by expanded definition schema name
|
|
33
|
-
let valResult = await client.retrieveMultipleRecordsAsync("environmentvariablevalues", {
|
|
34
|
-
filter: "EnvironmentVariableDefinitionId/schemaname eq '" + sSchemaName + "'",
|
|
35
|
-
select: ["value"],
|
|
36
|
-
expand: [{ name: "EnvironmentVariableDefinitionId", select: ["defaultvalue", "schemaname"] }],
|
|
37
|
-
});
|
|
38
|
-
let aVals = unwrapResult(valResult);
|
|
39
|
-
|
|
40
|
-
// If value record exists, return it
|
|
41
|
-
if (Array.isArray(aVals) && aVals.length > 0 && aVals[0].value) {
|
|
42
|
-
return aVals[0].value;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// No value record — fall back to definition default value
|
|
46
|
-
let defResult = await client.retrieveMultipleRecordsAsync("environmentvariabledefinitions", {
|
|
47
|
-
filter: "schemaname eq '" + sSchemaName + "'",
|
|
48
|
-
select: ["defaultvalue"],
|
|
49
|
-
});
|
|
50
|
-
let aDefs = unwrapResult(defResult);
|
|
51
|
-
if (!Array.isArray(aDefs) || aDefs.length === 0) {
|
|
52
|
-
throw new Error("Environment variable not found: " + sSchemaName);
|
|
53
|
-
}
|
|
54
|
-
return aDefs[0].defaultvalue || "";
|
|
55
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { getClient } from "@microsoft/power-apps/data";
|
|
2
|
-
|
|
3
|
-
// ── Data source name (must match the generated connector data source name) ──
|
|
4
|
-
const DATA_SOURCE = "office365groups";
|
|
5
|
-
|
|
6
|
-
const GROUPS_APIS = {
|
|
7
|
-
ListOwnedGroups: {
|
|
8
|
-
path: "/{connectionId}/v1.0/me/memberOf/$/microsoft.graph.group",
|
|
9
|
-
method: "GET",
|
|
10
|
-
parameters: [
|
|
11
|
-
{ name: "connectionId", in: "path", required: true },
|
|
12
|
-
],
|
|
13
|
-
},
|
|
14
|
-
ListGroupMembers: {
|
|
15
|
-
path: "/{connectionId}/v1.0/groups/{groupId}/members",
|
|
16
|
-
method: "GET",
|
|
17
|
-
parameters: [
|
|
18
|
-
{ name: "connectionId", in: "path", required: true },
|
|
19
|
-
{ name: "groupId", in: "path", required: true },
|
|
20
|
-
{ name: "$top", in: "query", required: false },
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
HttpRequest: {
|
|
24
|
-
path: "/{connectionId}/httprequest",
|
|
25
|
-
method: "POST",
|
|
26
|
-
parameters: [
|
|
27
|
-
{ name: "connectionId", in: "path", required: true },
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// ── Initialize SDK client for the Office 365 Groups connector ──
|
|
33
|
-
function initClient() {
|
|
34
|
-
const dataSourcesInfo = {
|
|
35
|
-
[DATA_SOURCE]: {
|
|
36
|
-
tableId: "",
|
|
37
|
-
version: "",
|
|
38
|
-
primaryKey: "",
|
|
39
|
-
dataSourceType: "Connector",
|
|
40
|
-
apis: GROUPS_APIS,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
return getClient(dataSourcesInfo);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// ── Internal: execute a connector operation ────────────────────
|
|
47
|
-
async function execOp(operationName, parameters) {
|
|
48
|
-
const client = await initClient();
|
|
49
|
-
const result = await client.executeAsync({
|
|
50
|
-
connectorOperation: {
|
|
51
|
-
tableName: DATA_SOURCE,
|
|
52
|
-
operationName,
|
|
53
|
-
parameters,
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (!result.success) {
|
|
58
|
-
throw new Error(result.error?.message || "Operation failed");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return Object.prototype.hasOwnProperty.call(result, "data") ? result.data : result;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// ═══════════════════════════════════════════════════════════════
|
|
65
|
-
// GENERIC
|
|
66
|
-
// ═══════════════════════════════════════════════════════════════
|
|
67
|
-
|
|
68
|
-
// ── Call any Office 365 Groups operation by name ───────────────
|
|
69
|
-
export async function callGroupsOperation(operationName, parameters = {}) {
|
|
70
|
-
return execOp(operationName, parameters);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ── Open HTTP Request ──────────────────────────────────────────
|
|
74
|
-
export async function openHttpRequest({ method = "GET", uri, headers, body }) {
|
|
75
|
-
return execOp("HttpRequest", {
|
|
76
|
-
method,
|
|
77
|
-
uri,
|
|
78
|
-
headers: headers || {},
|
|
79
|
-
body: body || "",
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// ═══════════════════════════════════════════════════════════════
|
|
84
|
-
// GROUPS
|
|
85
|
-
// ═══════════════════════════════════════════════════════════════
|
|
86
|
-
|
|
87
|
-
// ── List My Groups ─────────────────────────────────────────────
|
|
88
|
-
export async function listMyGroups() {
|
|
89
|
-
return execOp("ListOwnedGroups", {});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// ── List Members of a Group ────────────────────────────────────
|
|
93
|
-
export async function listGroupMembers(groupId) {
|
|
94
|
-
return execOp("ListGroupMembers", {
|
|
95
|
-
groupId,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { getClient } from "@microsoft/power-apps/data";
|
|
2
|
-
|
|
3
|
-
// ── Data source name (must match connectionReferences in power.config.json) ──
|
|
4
|
-
const DATA_SOURCE = "office365users";
|
|
5
|
-
|
|
6
|
-
// ── Initialize SDK client for the Office 365 Users connector ───
|
|
7
|
-
function initClient() {
|
|
8
|
-
const dataSourcesInfo = {
|
|
9
|
-
[DATA_SOURCE]: {
|
|
10
|
-
tableId: "",
|
|
11
|
-
version: "",
|
|
12
|
-
primaryKey: "",
|
|
13
|
-
dataSourceType: "Connector",
|
|
14
|
-
apis: {
|
|
15
|
-
MyProfile_V2: {
|
|
16
|
-
path: "/{connectionId}/codeless/v1.0/me",
|
|
17
|
-
method: "GET",
|
|
18
|
-
parameters: [
|
|
19
|
-
{ name: "connectionId", in: "path", required: true },
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
UserProfile_V2: {
|
|
23
|
-
path: "/{connectionId}/codeless/v1.0/users/{id}",
|
|
24
|
-
method: "GET",
|
|
25
|
-
parameters: [
|
|
26
|
-
{ name: "connectionId", in: "path", required: true },
|
|
27
|
-
{ name: "id", in: "path", required: true },
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
Manager_V2: {
|
|
31
|
-
path: "/{connectionId}/codeless/v1.0/users/{id}/manager",
|
|
32
|
-
method: "GET",
|
|
33
|
-
parameters: [
|
|
34
|
-
{ name: "connectionId", in: "path", required: true },
|
|
35
|
-
{ name: "id", in: "path", required: true },
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
DirectReports_V2: {
|
|
39
|
-
path: "/{connectionId}/codeless/v1.0/users/{id}/directReports",
|
|
40
|
-
method: "GET",
|
|
41
|
-
parameters: [
|
|
42
|
-
{ name: "connectionId", in: "path", required: true },
|
|
43
|
-
{ name: "id", in: "path", required: true },
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
UserPhoto_V2: {
|
|
47
|
-
path: "/{connectionId}/codeless/v1.0/users/{id}/photo/$value",
|
|
48
|
-
method: "GET",
|
|
49
|
-
parameters: [
|
|
50
|
-
{ name: "connectionId", in: "path", required: true },
|
|
51
|
-
{ name: "id", in: "path", required: true },
|
|
52
|
-
],
|
|
53
|
-
responseInfo: { "200": "image/jpeg" },
|
|
54
|
-
},
|
|
55
|
-
SearchUser_V2: {
|
|
56
|
-
path: "/{connectionId}/codeless/v1.0/users",
|
|
57
|
-
method: "GET",
|
|
58
|
-
parameters: [
|
|
59
|
-
{ name: "connectionId", in: "path", required: true },
|
|
60
|
-
{ name: "searchTerm", in: "query", required: false },
|
|
61
|
-
{ name: "$top", in: "query", required: false },
|
|
62
|
-
{ name: "$skip", in: "query", required: false },
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
HttpRequest: {
|
|
66
|
-
path: "/{connectionId}/codeless/v1.0/httprequest",
|
|
67
|
-
method: "POST",
|
|
68
|
-
parameters: [
|
|
69
|
-
{ name: "connectionId", in: "path", required: true },
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
return getClient(dataSourcesInfo);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// ── Internal: execute a connector operation ────────────────────
|
|
79
|
-
async function execOp(operationName, parameters) {
|
|
80
|
-
const client = await initClient();
|
|
81
|
-
const result = await client.executeAsync({
|
|
82
|
-
connectorOperation: {
|
|
83
|
-
tableName: DATA_SOURCE,
|
|
84
|
-
operationName,
|
|
85
|
-
parameters,
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
if (!result.success) {
|
|
89
|
-
throw new Error(result.error?.message || "Operation failed");
|
|
90
|
-
}
|
|
91
|
-
return result.data;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// ═══════════════════════════════════════════════════════════════
|
|
95
|
-
// GENERIC
|
|
96
|
-
// ═══════════════════════════════════════════════════════════════
|
|
97
|
-
|
|
98
|
-
// ── Call any Office 365 Users operation by name ────────────────
|
|
99
|
-
export async function callUsersOperation(operationName, parameters = {}) {
|
|
100
|
-
return execOp(operationName, parameters);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// ── Open HTTP Request ──────────────────────────────────────────
|
|
104
|
-
export async function openHttpRequest({ method = "GET", uri, headers, body }) {
|
|
105
|
-
return execOp("HttpRequest", {
|
|
106
|
-
method,
|
|
107
|
-
uri,
|
|
108
|
-
headers: headers || {},
|
|
109
|
-
body: body || "",
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// ═══════════════════════════════════════════════════════════════
|
|
114
|
-
// PROFILE
|
|
115
|
-
// ═══════════════════════════════════════════════════════════════
|
|
116
|
-
|
|
117
|
-
// ── Get My Profile ─────────────────────────────────────────────
|
|
118
|
-
export async function getMyProfile() {
|
|
119
|
-
return execOp("MyProfile_V2", {});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// ── Get User Profile ───────────────────────────────────────────
|
|
123
|
-
export async function getUserProfile(userId) {
|
|
124
|
-
return execOp("UserProfile_V2", {
|
|
125
|
-
id: userId,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// ═══════════════════════════════════════════════════════════════
|
|
130
|
-
// MANAGER & REPORTS
|
|
131
|
-
// ═══════════════════════════════════════════════════════════════
|
|
132
|
-
|
|
133
|
-
// ── Get Manager ────────────────────────────────────────────────
|
|
134
|
-
export async function getManager(userId) {
|
|
135
|
-
return execOp("Manager_V2", {
|
|
136
|
-
id: userId,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// ── Get Direct Reports ─────────────────────────────────────────
|
|
141
|
-
export async function getDirectReports(userId) {
|
|
142
|
-
return execOp("DirectReports_V2", {
|
|
143
|
-
id: userId,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// ═══════════════════════════════════════════════════════════════
|
|
148
|
-
// PHOTO
|
|
149
|
-
// ═══════════════════════════════════════════════════════════════
|
|
150
|
-
|
|
151
|
-
// ── Get User Photo ─────────────────────────────────────────────
|
|
152
|
-
export async function getUserPhoto(userId) {
|
|
153
|
-
return execOp("UserPhoto_V2", {
|
|
154
|
-
id: userId,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// ═══════════════════════════════════════════════════════════════
|
|
159
|
-
// SEARCH
|
|
160
|
-
// ═══════════════════════════════════════════════════════════════
|
|
161
|
-
|
|
162
|
-
// ── Search for Users ───────────────────────────────────────────
|
|
163
|
-
export async function searchForUsers({ searchTerm, top, skip } = {}) {
|
|
164
|
-
const params = {};
|
|
165
|
-
if (searchTerm) params.searchTerm = searchTerm;
|
|
166
|
-
if (top != null) params.$top = top;
|
|
167
|
-
if (skip != null) params.$skip = skip;
|
|
168
|
-
return execOp("SearchUser_V2", params);
|
|
169
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { getClient } from "@microsoft/power-apps/data";
|
|
2
|
-
|
|
3
|
-
// ── Data source name (must match connectionReferences in power.config.json) ──
|
|
4
|
-
const DATA_SOURCE = "Office365Outlook";
|
|
5
|
-
|
|
6
|
-
// ── Initialize SDK client for the Office 365 Outlook connector ──
|
|
7
|
-
function initClient() {
|
|
8
|
-
const dataSourcesInfo = {
|
|
9
|
-
[DATA_SOURCE]: {
|
|
10
|
-
tableId: "",
|
|
11
|
-
version: "",
|
|
12
|
-
primaryKey: "",
|
|
13
|
-
dataSourceType: "Connector",
|
|
14
|
-
apis: {},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
return getClient(dataSourcesInfo);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// ── Internal: execute a connector operation ────────────────────
|
|
21
|
-
async function execOp(operationName, parameters) {
|
|
22
|
-
const client = await initClient();
|
|
23
|
-
return client.executeAsync({
|
|
24
|
-
connectorOperation: {
|
|
25
|
-
tableName: DATA_SOURCE,
|
|
26
|
-
operationName,
|
|
27
|
-
parameters,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// ═══════════════════════════════════════════════════════════════
|
|
33
|
-
// GENERIC
|
|
34
|
-
// ═══════════════════════════════════════════════════════════════
|
|
35
|
-
|
|
36
|
-
// ── Call any Outlook connector operation by name ───────────────
|
|
37
|
-
export async function callOutlookOperation(operationName, parameters = {}) {
|
|
38
|
-
return execOp(operationName, parameters);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// ═══════════════════════════════════════════════════════════════
|
|
42
|
-
// MAIL
|
|
43
|
-
// ═══════════════════════════════════════════════════════════════
|
|
44
|
-
|
|
45
|
-
// ── Send Email ─────────────────────────────────────────────────
|
|
46
|
-
export async function sendEmail({ to, cc, bcc, subject, body, isHtml = true, importance = "Normal", attachments }) {
|
|
47
|
-
return execOp("SendEmailV2", {
|
|
48
|
-
"emailMessage/To": to,
|
|
49
|
-
"emailMessage/Subject": subject,
|
|
50
|
-
"emailMessage/Body": body,
|
|
51
|
-
"emailMessage/Cc": cc || "",
|
|
52
|
-
"emailMessage/Bcc": bcc || "",
|
|
53
|
-
"emailMessage/Importance": importance,
|
|
54
|
-
"emailMessage/IsHtml": isHtml,
|
|
55
|
-
"emailMessage/Attachments": attachments || [],
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ── Forward Email ──────────────────────────────────────────────
|
|
60
|
-
export async function forwardEmail(messageId, { to, comment = "" }) {
|
|
61
|
-
return execOp("ForwardEmailV2", {
|
|
62
|
-
message_id: messageId,
|
|
63
|
-
"emailMessage/To": to,
|
|
64
|
-
"emailMessage/Comment": comment,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ── Reply to Email ─────────────────────────────────────────────
|
|
69
|
-
export async function replyToEmail(messageId, { comment, replyAll = false }) {
|
|
70
|
-
return execOp(replyAll ? "ReplyAllToV3" : "ReplyToV3", {
|
|
71
|
-
message_id: messageId,
|
|
72
|
-
comment,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ── List Emails ────────────────────────────────────────────────
|
|
77
|
-
export async function listEmails({ folderId = "Inbox", fetchOnlyUnread, searchQuery, top, skip } = {}) {
|
|
78
|
-
const params = { folderPath: folderId };
|
|
79
|
-
if (fetchOnlyUnread != null) params.fetchOnlyUnread = fetchOnlyUnread;
|
|
80
|
-
if (searchQuery) params.searchQuery = searchQuery;
|
|
81
|
-
if (top != null) params.top = top;
|
|
82
|
-
if (skip != null) params.skip = skip;
|
|
83
|
-
return execOp("GetEmailsV3", params);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// ── Send from Shared Mailbox ───────────────────────────────────
|
|
87
|
-
export async function sendFromSharedMailbox(sharedMailbox, { to, cc, bcc, subject, body, isHtml = true, importance = "Normal", attachments }) {
|
|
88
|
-
return execOp("SharedMailboxSendEmailV2", {
|
|
89
|
-
"emailMessage/To": to,
|
|
90
|
-
"emailMessage/Subject": subject,
|
|
91
|
-
"emailMessage/Body": body,
|
|
92
|
-
"emailMessage/Cc": cc || "",
|
|
93
|
-
"emailMessage/Bcc": bcc || "",
|
|
94
|
-
"emailMessage/Importance": importance,
|
|
95
|
-
"emailMessage/IsHtml": isHtml,
|
|
96
|
-
"emailMessage/Attachments": attachments || [],
|
|
97
|
-
mailboxAddress: sharedMailbox,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// ── Move Email ─────────────────────────────────────────────────
|
|
102
|
-
export async function moveEmail(messageId, destinationFolderId) {
|
|
103
|
-
return execOp("MoveEmailV2", {
|
|
104
|
-
message_id: messageId,
|
|
105
|
-
folderPath: destinationFolderId,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// ── Delete Email ───────────────────────────────────────────────
|
|
110
|
-
export async function deleteEmail(messageId) {
|
|
111
|
-
return execOp("DeleteEmailV2", {
|
|
112
|
-
message_id: messageId,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// ═══════════════════════════════════════════════════════════════
|
|
117
|
-
// CALENDAR
|
|
118
|
-
// ═══════════════════════════════════════════════════════════════
|
|
119
|
-
|
|
120
|
-
// ── Create Event ───────────────────────────────────────────────
|
|
121
|
-
export async function createEvent({ calendarId = "Calendar", subject, body, start, end, location, attendees, isAllDay = false, importance = "Normal", isHtml = true, timeZone = "UTC" }) {
|
|
122
|
-
return execOp("V4CalendarPostItem", {
|
|
123
|
-
table: calendarId,
|
|
124
|
-
"item/subject": subject,
|
|
125
|
-
"item/body": body || "",
|
|
126
|
-
"item/start": start,
|
|
127
|
-
"item/end": end,
|
|
128
|
-
"item/timeZone": timeZone,
|
|
129
|
-
"item/location": location || "",
|
|
130
|
-
"item/requiredAttendees": Array.isArray(attendees) ? attendees.join(";") : (attendees || ""),
|
|
131
|
-
"item/isAllDay": isAllDay,
|
|
132
|
-
"item/importance": importance,
|
|
133
|
-
"item/isHtml": isHtml,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// ── List Events ────────────────────────────────────────────────
|
|
138
|
-
export async function listEvents({ calendarId = "Calendar", filter, orderBy, top, skip } = {}) {
|
|
139
|
-
const params = { table: calendarId };
|
|
140
|
-
if (filter) params.$filter = filter;
|
|
141
|
-
if (orderBy) params.$orderby = orderBy;
|
|
142
|
-
if (top != null) params.$top = top;
|
|
143
|
-
if (skip != null) params.$skip = skip;
|
|
144
|
-
return execOp("V2CalendarGetItems", params);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// ── Edit Event ─────────────────────────────────────────────────
|
|
148
|
-
export async function editEvent(eventId, changedFields, calendarId = "Calendar") {
|
|
149
|
-
return execOp("V4CalendarPatchItem", {
|
|
150
|
-
table: calendarId,
|
|
151
|
-
id: eventId,
|
|
152
|
-
...changedFields,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// ── Delete Event ───────────────────────────────────────────────
|
|
157
|
-
export async function deleteEvent(eventId, calendarId = "Calendar") {
|
|
158
|
-
return execOp("V2CalendarDeleteItem", {
|
|
159
|
-
table: calendarId,
|
|
160
|
-
id: eventId,
|
|
161
|
-
});
|
|
162
|
-
}
|