codeapp-js 0.3.0 → 1.0.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/AI/codeapp.agent.md +105 -0
- package/AI/skills/connections/SKILL.md +47 -0
- package/AI/skills/dataverse/SKILL.md +99 -0
- package/AI/skills/environment-variables/SKILL.md +89 -0
- package/AI/skills/frontend-design/SKILL.md +34 -0
- package/AI/skills/jira/SKILL.md +81 -0
- package/AI/skills/office365-groups/SKILL.md +61 -0
- package/AI/skills/office365-outlook/SKILL.md +52 -0
- package/AI/skills/office365-users/SKILL.md +78 -0
- package/AI/skills/sharepoint/SKILL.md +77 -0
- package/AI/skills/sql/SKILL.md +85 -0
- package/AI/skills/start/SKILL.md +46 -0
- package/AI/skills/teams/SKILL.md +55 -0
- package/{examples/combined demo/.power/schemas/office365groups/office365groups.Schema.json → codeApp/.power/schemas/office365groups/office365groups.Schema.json} +2203 -2203
- package/codeApp/dist/codeapp.js +95 -1792
- package/codeApp/dist/connectors/azureKeyvault.js +459 -0
- package/codeApp/dist/connectors/jira.js +1247 -0
- package/codeApp/dist/connectors/office365groups.js +642 -0
- package/codeApp/dist/connectors/office365users.js +513 -0
- package/codeApp/dist/connectors/outlook.js +1393 -0
- package/codeApp/dist/connectors/sharepoint.js +466 -0
- package/codeApp/dist/connectors/sql.js +149 -0
- package/codeApp/dist/connectors/teams.js +280 -0
- package/codeApp/dist/power-apps-data.js +16 -2
- package/examples/{kanban → apps/kanban}/dist/dataverse.js +94 -94
- package/examples/{kanban → apps/kanban}/dist/environmentVar.js +55 -55
- package/examples/{kanban → apps/kanban}/dist/index.css +605 -605
- package/examples/{kanban → apps/kanban}/dist/index.html +21 -21
- package/examples/{kanban → apps/kanban}/dist/index.js +860 -860
- package/examples/{kanban → apps/kanban}/dist/office365groups.js +97 -97
- package/examples/apps/kanban/dist/office365users.js +451 -0
- package/examples/{kanban → apps/kanban}/dist/outlook.js +162 -162
- package/examples/{planning Poker/dist/power-apps-data.js → apps/kanban/dist/power-apps-data.js} +2953 -2953
- package/examples/{kanban → apps/kanban}/dist/sharepoint.js +435 -339
- package/examples/{kanban → apps/kanban}/power.config.json +35 -35
- package/examples/{planning Poker → apps/planning Poker}/additional files/customizations (tables).xml +6428 -6428
- package/examples/{planning Poker → apps/planning Poker}/additional files/dataverse-tables.json +165 -165
- package/examples/{planning Poker → apps/planning Poker}/additional files/readme.md +122 -122
- package/examples/{planning Poker → apps/planning Poker}/dist/dataverse.js +78 -78
- package/examples/{planning Poker → apps/planning Poker}/dist/index.html +198 -198
- package/examples/{planning Poker → apps/planning Poker}/dist/index.js +954 -954
- package/examples/{todo/dist/power-apps-data.js → apps/planning Poker/dist/power-apps-data.js } +2953 -2953
- package/examples/{planning Poker → apps/planning Poker}/dist/styles.css +815 -815
- package/examples/{planning Poker → apps/planning Poker}/power.config.json +50 -50
- package/examples/{outlook Demo2 → apps/solution explorer}/dist/codeapp.js +9 -245
- package/examples/apps/solution explorer/dist/index.html +80 -0
- package/examples/apps/solution explorer/dist/index.js +735 -0
- package/examples/apps/solution explorer/dist/styles.css +571 -0
- package/examples/apps/solution explorer/power.config.json +151 -0
- package/examples/{todo → apps/todo}/dist/dataverse.js +64 -64
- package/examples/{todo → apps/todo}/dist/index.html +75 -75
- package/examples/{todo → apps/todo}/dist/index.js +8 -8
- package/examples/{kanban → apps/todo}/dist/power-apps-data.js +2953 -2953
- package/examples/{todo → apps/todo}/dist/renderer.js +375 -375
- package/examples/{todo → apps/todo}/dist/styles.css +691 -691
- package/examples/{todo → apps/todo}/power.config.json +34 -34
- package/examples/combined demo/.power/schemas/appschemas/dataSourcesInfo.ts +6275 -7830
- package/examples/combined demo/.power/schemas/jira/jira.Schema.json +6903 -0
- package/examples/combined demo/.power/schemas/keyvault/keyvault.Schema.json +1600 -0
- package/examples/combined demo/.power/schemas/teams/teams.Schema.json +11112 -0
- package/examples/combined demo/dist/codeapp.js +394 -1098
- package/examples/{outlook Demo2/OutlookDemo_1_0_0_1.zip → combined demo/dist/icon-512.png} +0 -0
- package/examples/combined demo/dist/index.html +29 -511
- package/examples/combined demo/dist/index.js +490 -470
- package/examples/combined demo/dist/office365users.js +513 -0
- package/examples/combined demo/dist/outlook.js +1393 -0
- package/examples/combined demo/dist/power-apps-data.js +3079 -3006
- package/examples/combined demo/dist/styles.css +483 -0
- package/examples/combined demo/power.config.json +33 -42
- package/examples/combined demo/src/generated/index.ts +12 -14
- package/examples/combined demo/src/generated/models/AzureKeyVaultModel.ts +107 -0
- package/examples/combined demo/src/generated/models/JiraModel.ts +501 -0
- package/examples/combined demo/src/generated/services/AzureKeyVaultService.ts +257 -0
- package/examples/combined demo/src/generated/services/JiraService.ts +1124 -0
- package/examples/dataverse Demo/dist/codeapp.js +394 -1085
- package/examples/dataverse Demo/dist/icon-512.png +0 -0
- package/examples/dataverse Demo/dist/index.html +146 -54
- package/examples/dataverse Demo/dist/index.js +693 -83
- package/examples/dataverse Demo/dist/power-apps-data.js +3079 -2911
- package/examples/dataverse Demo/dist/styles.css +528 -0
- package/examples/dataverse Demo/power.config.json +41 -35
- package/examples/dataverse Demo/readme.md +79 -79
- package/examples/groups Demo/dist/codeapp.js +394 -1085
- package/examples/groups Demo/dist/icon-512.png +0 -0
- package/examples/groups Demo/dist/index.html +21 -25
- package/examples/groups Demo/dist/index.js +304 -113
- package/examples/groups Demo/dist/office365groups.js +642 -0
- package/examples/groups Demo/dist/power-apps-data.js +3079 -2911
- package/examples/groups Demo/dist/styles.css +509 -0
- package/examples/groups Demo/power.config.json +25 -25
- package/examples/myProfile/dist/codeapp.js +398 -0
- package/examples/myProfile/dist/index.html +21 -184
- package/examples/myProfile/dist/index.js +324 -141
- package/examples/myProfile/dist/office365users.js +517 -169
- package/examples/myProfile/dist/power-apps-data.js +3080 -2953
- package/examples/myProfile/dist/styles.css +458 -0
- package/examples/myProfile/power.config.json +24 -23
- package/examples/outlook Demo/dist/codeapp.js +394 -1085
- package/examples/outlook Demo/dist/index.html +150 -35
- package/examples/outlook Demo/dist/index.js +516 -170
- package/examples/outlook Demo/dist/outlook.js +1393 -121
- package/examples/outlook Demo/dist/power-apps-data.js +3079 -2911
- package/examples/outlook Demo/dist/styles.css +408 -84
- package/examples/outlook Demo/power.config.json +24 -23
- package/examples/outlook Demo/readme.md +92 -82
- package/examples/sharePoint Demo/dist/codeapp.js +394 -1085
- package/examples/sharePoint Demo/dist/icon-512.png +0 -0
- package/examples/sharePoint Demo/dist/index.html +22 -255
- package/examples/sharePoint Demo/dist/index.js +899 -262
- package/examples/sharePoint Demo/dist/power-apps-data.js +3079 -2911
- package/{dev files → examples/sharePoint Demo/dist}/sharepoint.js +239 -112
- package/examples/sharePoint Demo/dist/styles.css +587 -0
- package/examples/sharePoint Demo/power.config.json +23 -22
- package/package.json +1 -1
- package/readme.md +465 -76
- package/.vscode/settings.json +0 -6
- package/dev files/customConnector.js +0 -98
- package/dev files/dataverse.js +0 -120
- package/dev files/environmentVar.js +0 -55
- package/dev files/office365groups.js +0 -65
- package/dev files/office365users.js +0 -169
- package/dev files/outlook.js +0 -330
- package/dev files/power-apps-data.js +0 -2952
- package/examples/combined demo/.power/schemas/office365/office365.Schema.json +0 -21098
- package/examples/combined demo/.power/schemas/office365users/office365users.Schema.json +0 -2094
- package/examples/kanban/agent/decision-log.md +0 -9
- package/examples/kanban/agent/mockup-01-editorial-glass.html +0 -159
- package/examples/kanban/agent/mockup-02-dark-rail.html +0 -147
- package/examples/kanban/agent/mockup-03-paper-grid.html +0 -114
- package/examples/kanban/agent/mockup-04-neon-minimal.html +0 -141
- package/examples/kanban/agent/mockup-05-mono-architect.html +0 -119
- package/examples/kanban/dist/office365users.js +0 -169
- package/examples/kanban/src/generated/index.ts +0 -14
- package/examples/kanban/src/generated/models/Office365GroupsModel.ts +0 -363
- package/examples/kanban/src/generated/models/Office365OutlookModel.ts +0 -2046
- package/examples/kanban/src/generated/models/Office365UsersModel.ts +0 -254
- package/examples/kanban/src/generated/services/Office365GroupsService.ts +0 -326
- package/examples/kanban/src/generated/services/Office365OutlookService.ts +0 -2476
- package/examples/kanban/src/generated/services/Office365UsersService.ts +0 -358
- package/examples/outlook Demo2/agent/decision-log.md +0 -7
- package/examples/outlook Demo2/dist/index.html +0 -98
- package/examples/outlook Demo2/dist/index.js +0 -272
- package/examples/outlook Demo2/dist/styles.css +0 -639
- package/examples/outlook Demo2/power.config.json +0 -23
- package/examples/planning Poker/.vscode/settings.json +0 -5
- package/examples/sharePoint Demo/agent/decision-log.md +0 -17
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/index.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365GroupsModel.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365OutlookModel.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365UsersModel.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365GroupsService.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365OutlookService.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365UsersService.ts +0 -0
- /package/examples/{planning Poker → apps/planning Poker}/additional files/AgilePoker_1_0_0_1.zip +0 -0
- /package/examples/{planning Poker → apps/planning Poker}/additional files/PokerTables_1_0_0_1.zip +0 -0
- /package/examples/{outlook Demo2 → apps/solution explorer}/dist/icon-512.png +0 -0
- /package/examples/{outlook Demo2 → apps/solution explorer}/dist/power-apps-data.js +0 -0
- /package/examples/{todo → apps/todo}/dist/icon192.png +0 -0
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// Custom Connector Utility for Power Apps Code-First SDK
|
|
2
|
-
// This module provides generic functions to call any custom connector operation.
|
|
3
|
-
// Usage: import and use callCustomConnectorOperation or openCustomConnectorHttpRequest.
|
|
4
|
-
|
|
5
|
-
import { getClient } from "./power-apps-data.js";
|
|
6
|
-
|
|
7
|
-
// ── Data source name (set to your custom connector name) ──
|
|
8
|
-
const DATA_SOURCE_NAME = "<yourCustomConnectorName>"; // Replace with your connector name
|
|
9
|
-
const CUSTOM_CONNECTOR_APIS = {};
|
|
10
|
-
|
|
11
|
-
// ── Initialize SDK client for the custom connector ──
|
|
12
|
-
function initClient() {
|
|
13
|
-
const dataSourcesInfo = {
|
|
14
|
-
[DATA_SOURCE_NAME]: {
|
|
15
|
-
tableId: "",
|
|
16
|
-
version: "",
|
|
17
|
-
primaryKey: "",
|
|
18
|
-
dataSourceType: "Connector",
|
|
19
|
-
apis: CUSTOM_CONNECTOR_APIS,
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
return getClient(dataSourcesInfo);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function stringifyErrorDetails(oError) {
|
|
26
|
-
if (!oError) return "Operation failed";
|
|
27
|
-
if (typeof oError === "string") return oError;
|
|
28
|
-
if (oError instanceof Error) return oError.message || "Operation failed";
|
|
29
|
-
var aPropertyNames = Object.getOwnPropertyNames(oError);
|
|
30
|
-
var oSerializable = {};
|
|
31
|
-
aPropertyNames.forEach((sName) => {
|
|
32
|
-
oSerializable[sName] = oError[sName];
|
|
33
|
-
});
|
|
34
|
-
try {
|
|
35
|
-
return JSON.stringify(oSerializable);
|
|
36
|
-
} catch {
|
|
37
|
-
return String(oError);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function unwrapResult(oResult) {
|
|
42
|
-
if (oResult && oResult.success === false) {
|
|
43
|
-
var sMessage = stringifyErrorDetails(oResult.error);
|
|
44
|
-
if (oResult.data !== undefined) {
|
|
45
|
-
sMessage += " | data: " + stringifyErrorDetails(oResult.data);
|
|
46
|
-
}
|
|
47
|
-
throw new Error(sMessage);
|
|
48
|
-
}
|
|
49
|
-
if (oResult && Object.prototype.hasOwnProperty.call(oResult, "data")) {
|
|
50
|
-
return oResult.data;
|
|
51
|
-
}
|
|
52
|
-
return oResult;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ── Internal: execute a connector operation ────────────────────
|
|
56
|
-
async function execOp(operationName, parameters) {
|
|
57
|
-
const client = await initClient();
|
|
58
|
-
try {
|
|
59
|
-
const result = await client.executeAsync({
|
|
60
|
-
connectorOperation: {
|
|
61
|
-
tableName: DATA_SOURCE_NAME,
|
|
62
|
-
operationName,
|
|
63
|
-
parameters,
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
return unwrapResult(result);
|
|
67
|
-
} catch (oErr) {
|
|
68
|
-
throw new Error(DATA_SOURCE_NAME + ": " + stringifyErrorDetails(oErr));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// ── Call any custom connector operation by name ───────────────
|
|
73
|
-
export async function callCustomConnectorOperation(operationName, parameters = {}) {
|
|
74
|
-
return execOp(operationName, parameters);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// ── Open HTTP Request (for advanced scenarios) ────────────────
|
|
78
|
-
export async function openCustomConnectorHttpRequest({ method = "GET", uri, headers, body }) {
|
|
79
|
-
const client = await initClient();
|
|
80
|
-
try {
|
|
81
|
-
const result = await client.executeAsync({
|
|
82
|
-
httpRequest: {
|
|
83
|
-
tableName: DATA_SOURCE_NAME,
|
|
84
|
-
method,
|
|
85
|
-
uri,
|
|
86
|
-
headers,
|
|
87
|
-
body,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
return unwrapResult(result);
|
|
91
|
-
} catch (oErr) {
|
|
92
|
-
throw new Error(DATA_SOURCE_NAME + ": " + stringifyErrorDetails(oErr));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// ── Example Usage ─────────────────────────────────────────────
|
|
97
|
-
// callCustomConnectorOperation("MyAction", { param1: "value" })
|
|
98
|
-
// openCustomConnectorHttpRequest({ method: "POST", uri: "/myapi", body: { ... } })
|
package/dev files/dataverse.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { getClient, getContext } from "./power-apps-data.js";
|
|
2
|
-
|
|
3
|
-
// ── Table Registry (populated at runtime via registerTable) ────
|
|
4
|
-
let oDataSources = {};
|
|
5
|
-
|
|
6
|
-
// ── Register a Dataverse table for use by the library ──────────
|
|
7
|
-
export function registerTable(sTableName, sPrimaryKey) {
|
|
8
|
-
oDataSources[sTableName] = {
|
|
9
|
-
tableId: '',
|
|
10
|
-
version: '',
|
|
11
|
-
primaryKey: sPrimaryKey,
|
|
12
|
-
dataSourceType: 'Dataverse',
|
|
13
|
-
apis: {}
|
|
14
|
-
};
|
|
15
|
-
// reset client so it picks up the new table on next call
|
|
16
|
-
oSharedClient = null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// ── Initialize SDK & Client ────────────────────────────────────
|
|
20
|
-
let oSharedClient = null;
|
|
21
|
-
|
|
22
|
-
function getSharedClient() {
|
|
23
|
-
if (!oSharedClient) {
|
|
24
|
-
oSharedClient = getClient(oDataSources);
|
|
25
|
-
}
|
|
26
|
-
return oSharedClient;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// ── Ensure value is an array (accepts array or comma-separated string)
|
|
30
|
-
function ensureArray(value) {
|
|
31
|
-
if (!value) return value;
|
|
32
|
-
if (Array.isArray(value)) return value;
|
|
33
|
-
if (typeof value === 'string') return value.split(',').map(function (s) { return s.trim(); });
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ── Unwrap SDK response ────────────────────────────────────────
|
|
38
|
-
function unwrapResult(result) {
|
|
39
|
-
if (result && result.success === false) {
|
|
40
|
-
var sMsg = result.error ? (result.error.message || JSON.stringify(result.error)) : 'Operation failed';
|
|
41
|
-
throw new Error(sMsg);
|
|
42
|
-
}
|
|
43
|
-
return result && 'data' in result ? result.data : result;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// ── Create ─────────────────────────────────────────────────────
|
|
47
|
-
export async function createItem(tableName, primaryKey, record) {
|
|
48
|
-
const client = getSharedClient();
|
|
49
|
-
const result = await client.createRecordAsync(tableName, record);
|
|
50
|
-
return unwrapResult(result);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// ── Read (single) ──────────────────────────────────────────────
|
|
54
|
-
export async function getItem(tableName, primaryKey, id, select) {
|
|
55
|
-
const client = getSharedClient();
|
|
56
|
-
select = ensureArray(select);
|
|
57
|
-
const options = select ? { select } : undefined;
|
|
58
|
-
const result = await client.retrieveRecordAsync(tableName, id, options);
|
|
59
|
-
return unwrapResult(result);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// ── List (multiple) ────────────────────────────────────────────
|
|
63
|
-
export async function listItems(tableName, primaryKey, { filter, select, orderBy, top, skip } = {}) {
|
|
64
|
-
const client = getSharedClient();
|
|
65
|
-
select = ensureArray(select);
|
|
66
|
-
orderBy = ensureArray(orderBy);
|
|
67
|
-
const result = await client.retrieveMultipleRecordsAsync(tableName, {
|
|
68
|
-
filter,
|
|
69
|
-
select,
|
|
70
|
-
orderBy,
|
|
71
|
-
top,
|
|
72
|
-
skip,
|
|
73
|
-
});
|
|
74
|
-
var unwrapped = unwrapResult(result);
|
|
75
|
-
return { entities: Array.isArray(unwrapped) ? unwrapped : [] };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// ── Update ─────────────────────────────────────────────────────
|
|
79
|
-
export async function updateItem(tableName, primaryKey, id, changedFields) {
|
|
80
|
-
const client = getSharedClient();
|
|
81
|
-
const result = await client.updateRecordAsync(tableName, id, changedFields);
|
|
82
|
-
return unwrapResult(result);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ── Delete ─────────────────────────────────────────────────────
|
|
86
|
-
export async function deleteItem(tableName, primaryKey, id) {
|
|
87
|
-
const client = getSharedClient();
|
|
88
|
-
const result = await client.deleteRecordAsync(tableName, id);
|
|
89
|
-
return unwrapResult(result);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// ── Unbound Action ─────────────────────────────────────────────
|
|
93
|
-
// Calls an unbound Dataverse action by POSTing to the action endpoint.
|
|
94
|
-
// The actionName must be declared in power.config.json under
|
|
95
|
-
// databaseReferences.default.cds.dataSources, e.g.:
|
|
96
|
-
// "WhoAmI": { "entitySetName": "WhoAmI", "logicalName": "whoami", "isHidden": false }
|
|
97
|
-
export async function callUnboundAction(tableName, primaryKey, actionName, params) {
|
|
98
|
-
if (!oDataSources[actionName]) {
|
|
99
|
-
oDataSources[actionName] = {
|
|
100
|
-
tableId: '',
|
|
101
|
-
version: '',
|
|
102
|
-
primaryKey: '',
|
|
103
|
-
dataSourceType: 'Dataverse',
|
|
104
|
-
apis: {}
|
|
105
|
-
};
|
|
106
|
-
oSharedClient = null;
|
|
107
|
-
}
|
|
108
|
-
var client = getSharedClient();
|
|
109
|
-
var result = await client.createRecordAsync(actionName, params || {});
|
|
110
|
-
return unwrapResult(result);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// ── WhoAmI ─────────────────────────────────────────────────────
|
|
114
|
-
export async function whoAmI() {
|
|
115
|
-
var oCtx = await getContext();
|
|
116
|
-
var sId = oCtx.UserId || oCtx.userId || oCtx.systemuserid;
|
|
117
|
-
if (sId) return sId;
|
|
118
|
-
if (oCtx.userSettings && oCtx.userSettings.userId) return oCtx.userSettings.userId;
|
|
119
|
-
return oCtx;
|
|
120
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { getClient } from "./power-apps-data.js";
|
|
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,65 +0,0 @@
|
|
|
1
|
-
import { getClient } from "./power-apps-data.js";
|
|
2
|
-
|
|
3
|
-
// ── Data source name (must match connectionReferences in power.config.json) ──
|
|
4
|
-
const DATA_SOURCE = "Office365Groups";
|
|
5
|
-
|
|
6
|
-
// ── Initialize SDK client for the Office 365 Groups 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 Office 365 Groups operation by name ───────────────
|
|
37
|
-
export async function callGroupsOperation(operationName, parameters = {}) {
|
|
38
|
-
return execOp(operationName, parameters);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// ── Open HTTP Request ──────────────────────────────────────────
|
|
42
|
-
export async function openHttpRequest({ method = "GET", uri, headers, body }) {
|
|
43
|
-
return execOp("HttpRequest", {
|
|
44
|
-
method,
|
|
45
|
-
uri,
|
|
46
|
-
headers: headers || {},
|
|
47
|
-
body: body || "",
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// ═══════════════════════════════════════════════════════════════
|
|
52
|
-
// GROUPS
|
|
53
|
-
// ═══════════════════════════════════════════════════════════════
|
|
54
|
-
|
|
55
|
-
// ── List My Groups ─────────────────────────────────────────────
|
|
56
|
-
export async function listMyGroups() {
|
|
57
|
-
return execOp("ListOwnedGroups", {});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ── List Members of a Group ────────────────────────────────────
|
|
61
|
-
export async function listGroupMembers(groupId) {
|
|
62
|
-
return execOp("ListGroupMembers", {
|
|
63
|
-
groupId,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { getClient } from "./power-apps-data.js";
|
|
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
|
-
}
|