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
|
@@ -0,0 +1,98 @@
|
|
|
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getClient } from "
|
|
1
|
+
import { getClient, getContext } from "./power-apps-data.js";
|
|
2
2
|
|
|
3
3
|
// ── Table Registry (populated at runtime via registerTable) ────
|
|
4
4
|
let oDataSources = {};
|
|
@@ -26,6 +26,14 @@ function getSharedClient() {
|
|
|
26
26
|
return oSharedClient;
|
|
27
27
|
}
|
|
28
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
|
+
|
|
29
37
|
// ── Unwrap SDK response ────────────────────────────────────────
|
|
30
38
|
function unwrapResult(result) {
|
|
31
39
|
if (result && result.success === false) {
|
|
@@ -45,6 +53,7 @@ export async function createItem(tableName, primaryKey, record) {
|
|
|
45
53
|
// ── Read (single) ──────────────────────────────────────────────
|
|
46
54
|
export async function getItem(tableName, primaryKey, id, select) {
|
|
47
55
|
const client = getSharedClient();
|
|
56
|
+
select = ensureArray(select);
|
|
48
57
|
const options = select ? { select } : undefined;
|
|
49
58
|
const result = await client.retrieveRecordAsync(tableName, id, options);
|
|
50
59
|
return unwrapResult(result);
|
|
@@ -53,6 +62,8 @@ export async function getItem(tableName, primaryKey, id, select) {
|
|
|
53
62
|
// ── List (multiple) ────────────────────────────────────────────
|
|
54
63
|
export async function listItems(tableName, primaryKey, { filter, select, orderBy, top, skip } = {}) {
|
|
55
64
|
const client = getSharedClient();
|
|
65
|
+
select = ensureArray(select);
|
|
66
|
+
orderBy = ensureArray(orderBy);
|
|
56
67
|
const result = await client.retrieveMultipleRecordsAsync(tableName, {
|
|
57
68
|
filter,
|
|
58
69
|
select,
|
|
@@ -79,16 +90,31 @@ export async function deleteItem(tableName, primaryKey, id) {
|
|
|
79
90
|
}
|
|
80
91
|
|
|
81
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 }
|
|
82
97
|
export async function callUnboundAction(tableName, primaryKey, actionName, params) {
|
|
83
|
-
|
|
84
|
-
|
|
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 || {});
|
|
85
110
|
return unwrapResult(result);
|
|
86
111
|
}
|
|
87
112
|
|
|
88
113
|
// ── WhoAmI ─────────────────────────────────────────────────────
|
|
89
114
|
export async function whoAmI() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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;
|
|
94
120
|
}
|
package/dev files/outlook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getClient } from "
|
|
1
|
+
import { getClient } from "./power-apps-data.js";
|
|
2
2
|
|
|
3
3
|
// ── Data source name (must match connectionReferences in power.config.json) ──
|
|
4
4
|
const DATA_SOURCE_CANDIDATES = ["office365outlook", "Office365Outlook", "office365"];
|