@microsoft/managed-apps 0.4.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/LICENSE +153 -0
- package/README.md +3 -0
- package/dist/app/App.Types.d.ts +28 -0
- package/dist/app/App.Types.d.ts.map +1 -0
- package/dist/app/App.Types.js +5 -0
- package/dist/app/App.Types.js.map +1 -0
- package/dist/app/Config.d.ts +6 -0
- package/dist/app/Config.d.ts.map +1 -0
- package/dist/app/Config.js +10 -0
- package/dist/app/Config.js.map +1 -0
- package/dist/app/ContextProvider.d.ts +6 -0
- package/dist/app/ContextProvider.d.ts.map +1 -0
- package/dist/app/ContextProvider.js +36 -0
- package/dist/app/ContextProvider.js.map +1 -0
- package/dist/app/index.d.ts +7 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +6 -0
- package/dist/app/index.js.map +1 -0
- package/dist/data/getClient.d.ts +6 -0
- package/dist/data/getClient.d.ts.map +1 -0
- package/dist/data/getClient.js +14 -0
- package/dist/data/getClient.js.map +1 -0
- package/dist/data/index.d.ts +7 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +6 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/metadata/dataverse/dataverseMetadata.d.ts +408 -0
- package/dist/data/metadata/dataverse/dataverseMetadata.d.ts.map +1 -0
- package/dist/data/metadata/dataverse/dataverseMetadata.js +118 -0
- package/dist/data/metadata/dataverse/dataverseMetadata.js.map +1 -0
- package/dist/data/metadata/dataverse/index.d.ts +6 -0
- package/dist/data/metadata/dataverse/index.d.ts.map +1 -0
- package/dist/data/metadata/dataverse/index.js +5 -0
- package/dist/data/metadata/dataverse/index.js.map +1 -0
- package/dist/data/multiSelectPicklistUtils.d.ts +34 -0
- package/dist/data/multiSelectPicklistUtils.d.ts.map +1 -0
- package/dist/data/multiSelectPicklistUtils.js +51 -0
- package/dist/data/multiSelectPicklistUtils.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/communication/getAppConnections.d.ts +11 -0
- package/dist/internal/communication/getAppConnections.d.ts.map +1 -0
- package/dist/internal/communication/getAppConnections.js +20 -0
- package/dist/internal/communication/getAppConnections.js.map +1 -0
- package/dist/internal/communication/index.d.ts +11 -0
- package/dist/internal/communication/index.d.ts.map +1 -0
- package/dist/internal/communication/index.js +11 -0
- package/dist/internal/communication/index.js.map +1 -0
- package/dist/internal/communication/sendHttpRequest.d.ts +17 -0
- package/dist/internal/communication/sendHttpRequest.d.ts.map +1 -0
- package/dist/internal/communication/sendHttpRequest.js +21 -0
- package/dist/internal/communication/sendHttpRequest.js.map +1 -0
- package/dist/internal/communication/trackEvent.d.ts +11 -0
- package/dist/internal/communication/trackEvent.d.ts.map +1 -0
- package/dist/internal/communication/trackEvent.js +21 -0
- package/dist/internal/communication/trackEvent.js.map +1 -0
- package/dist/internal/sdkChannel.d.ts +18 -0
- package/dist/internal/sdkChannel.d.ts.map +1 -0
- package/dist/internal/sdkChannel.js +42 -0
- package/dist/internal/sdkChannel.js.map +1 -0
- package/dist/internal/telemetry.d.ts +11 -0
- package/dist/internal/telemetry.d.ts.map +1 -0
- package/dist/internal/telemetry.js +17 -0
- package/dist/internal/telemetry.js.map +1 -0
- package/dist/telemetry/Logger.types.d.ts +16 -0
- package/dist/telemetry/Logger.types.d.ts.map +1 -0
- package/dist/telemetry/Logger.types.js +5 -0
- package/dist/telemetry/Logger.types.js.map +1 -0
- package/dist/telemetry/LoggerManager.d.ts +17 -0
- package/dist/telemetry/LoggerManager.d.ts.map +1 -0
- package/dist/telemetry/LoggerManager.js +40 -0
- package/dist/telemetry/LoggerManager.js.map +1 -0
- package/dist/telemetry/index.d.ts +7 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +5 -0
- package/dist/telemetry/index.js.map +1 -0
- package/package.json +47 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import * as app from './app/index';
|
|
5
|
+
import * as data from './data/index';
|
|
6
|
+
import * as telemetry from './telemetry/index';
|
|
7
|
+
export { app, data, telemetry };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import * as app from './app/index';
|
|
5
|
+
import * as data from './data/index';
|
|
6
|
+
import * as telemetry from './telemetry/index';
|
|
7
|
+
export { app, data, telemetry };
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { type AppDataSourceConfig } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
/**
|
|
6
|
+
* Fetch the app's resolved connection configs from the host, keyed by entity
|
|
7
|
+
* (data source) name. Keys are normalized to lowercase to match existing SDK
|
|
8
|
+
* lookup conventions.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getAppConnections(): Promise<Record<string, AppDataSourceConfig>>;
|
|
11
|
+
//# sourceMappingURL=getAppConnections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAppConnections.d.ts","sourceRoot":"","sources":["../../../src/internal/communication/getAppConnections.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,8CAA8C,CAAC;AAIjG;;;;GAIG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAStF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { Methods } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
import { getSdkChannel } from '../sdkChannel';
|
|
6
|
+
/**
|
|
7
|
+
* Fetch the app's resolved connection configs from the host, keyed by entity
|
|
8
|
+
* (data source) name. Keys are normalized to lowercase to match existing SDK
|
|
9
|
+
* lookup conventions.
|
|
10
|
+
*/
|
|
11
|
+
export async function getAppConnections() {
|
|
12
|
+
const channel = await getSdkChannel();
|
|
13
|
+
const result = await channel.send(Methods.Data.getAppConnections);
|
|
14
|
+
const lowercased = {};
|
|
15
|
+
for (const [key, value] of Object.entries(result)) {
|
|
16
|
+
lowercased[key.toLowerCase()] = value;
|
|
17
|
+
}
|
|
18
|
+
return lowercased;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=getAppConnections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAppConnections.js","sourceRoot":"","sources":["../../../src/internal/communication/getAppConnections.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAA4B,OAAO,EAAE,MAAM,8CAA8C,CAAC;AAEjG,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,OAAO,GAAG,MAAM,aAAa,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAElE,MAAM,UAAU,GAAwC,EAAE,CAAC;IAC3D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IACxC,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Centralized JSON-RPC channel helpers. All host-facing calls in this package
|
|
6
|
+
* should go through this folder so the channel surface stays auditable.
|
|
7
|
+
*/
|
|
8
|
+
export { getAppConnections } from './getAppConnections';
|
|
9
|
+
export { sendHttpRequest } from './sendHttpRequest';
|
|
10
|
+
export { trackEvent } from './trackEvent';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/communication/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Centralized JSON-RPC channel helpers. All host-facing calls in this package
|
|
6
|
+
* should go through this folder so the channel surface stays auditable.
|
|
7
|
+
*/
|
|
8
|
+
export { getAppConnections } from './getAppConnections';
|
|
9
|
+
export { sendHttpRequest } from './sendHttpRequest';
|
|
10
|
+
export { trackEvent } from './trackEvent';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/communication/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { type HttpSendParams, type HttpSendResult } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
/**
|
|
6
|
+
* Send an HTTP request through the host's JSON-RPC channel.
|
|
7
|
+
*
|
|
8
|
+
* The host validates the URL against resolved connection origins, injects
|
|
9
|
+
* the appropriate Authorization header via its auth middleware, and runs
|
|
10
|
+
* the request through retry/circuit-breaker/tracking middleware. Network
|
|
11
|
+
* metrics are reported automatically — the SDK does not need to track them.
|
|
12
|
+
*
|
|
13
|
+
* Binary request bodies should be passed as base64 with `bodyEncoding: 'base64'`.
|
|
14
|
+
* Binary response bodies arrive base64-encoded with `bodyEncoding: 'base64'`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function sendHttpRequest(params: HttpSendParams): Promise<HttpSendResult>;
|
|
17
|
+
//# sourceMappingURL=sendHttpRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendHttpRequest.d.ts","sourceRoot":"","sources":["../../../src/internal/communication/sendHttpRequest.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,8CAA8C,CAAC;AAItD;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAGrF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { Methods, } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
import { getSdkChannel } from '../sdkChannel';
|
|
6
|
+
/**
|
|
7
|
+
* Send an HTTP request through the host's JSON-RPC channel.
|
|
8
|
+
*
|
|
9
|
+
* The host validates the URL against resolved connection origins, injects
|
|
10
|
+
* the appropriate Authorization header via its auth middleware, and runs
|
|
11
|
+
* the request through retry/circuit-breaker/tracking middleware. Network
|
|
12
|
+
* metrics are reported automatically — the SDK does not need to track them.
|
|
13
|
+
*
|
|
14
|
+
* Binary request bodies should be passed as base64 with `bodyEncoding: 'base64'`.
|
|
15
|
+
* Binary response bodies arrive base64-encoded with `bodyEncoding: 'base64'`.
|
|
16
|
+
*/
|
|
17
|
+
export async function sendHttpRequest(params) {
|
|
18
|
+
const channel = await getSdkChannel();
|
|
19
|
+
return channel.send(Methods.Http.send, params);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=sendHttpRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendHttpRequest.js","sourceRoot":"","sources":["../../../src/internal/communication/sendHttpRequest.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAGL,OAAO,GACR,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAsB;IAC1D,MAAM,OAAO,GAAG,MAAM,aAAa,EAAE,CAAC;IACtC,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Send a structured telemetry event to the host.
|
|
6
|
+
*
|
|
7
|
+
* Fire-and-forget. Errors during the call (channel unavailable, etc.) are
|
|
8
|
+
* swallowed so logger failures never break the app.
|
|
9
|
+
*/
|
|
10
|
+
export declare function trackEvent(eventName: string, properties?: Record<string, unknown>): void;
|
|
11
|
+
//# sourceMappingURL=trackEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trackEvent.d.ts","sourceRoot":"","sources":["../../../src/internal/communication/trackEvent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAQxF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { Methods } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
import { getSdkChannel } from '../sdkChannel';
|
|
6
|
+
/**
|
|
7
|
+
* Send a structured telemetry event to the host.
|
|
8
|
+
*
|
|
9
|
+
* Fire-and-forget. Errors during the call (channel unavailable, etc.) are
|
|
10
|
+
* swallowed so logger failures never break the app.
|
|
11
|
+
*/
|
|
12
|
+
export function trackEvent(eventName, properties) {
|
|
13
|
+
getSdkChannel()
|
|
14
|
+
.then((channel) => {
|
|
15
|
+
channel.notify(Methods.Telemetry.trackEvent, { eventName, properties });
|
|
16
|
+
})
|
|
17
|
+
.catch(() => {
|
|
18
|
+
// Channel unavailable — silently degrade.
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=trackEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trackEvent.js","sourceRoot":"","sources":["../../../src/internal/communication/trackEvent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,8CAA8C,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,SAAiB,EAAE,UAAoC;IAChF,aAAa,EAAE;SACZ,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QAChB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1E,CAAC,CAAC;SACD,KAAK,CAAC,GAAG,EAAE;QACV,0CAA0C;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { type Channel } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
/**
|
|
6
|
+
* Get or create the App SDK's dedicated channel to the host.
|
|
7
|
+
*
|
|
8
|
+
* When `window.__platformBridge` is available (runtime — bridge script injected
|
|
9
|
+
* by the gateway), the bridge's `initialize()` method creates the channel.
|
|
10
|
+
*
|
|
11
|
+
* When the bridge is absent (authoring — no bridge script), the SDK falls back
|
|
12
|
+
* to creating a MessageChannel directly and transferring a port to the host
|
|
13
|
+
* via `window.parent.postMessage`.
|
|
14
|
+
*
|
|
15
|
+
* The channel is cached — subsequent calls return the same instance.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getSdkChannel(): Promise<Channel>;
|
|
18
|
+
//# sourceMappingURL=sdkChannel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkChannel.d.ts","sourceRoot":"","sources":["../../src/internal/sdkChannel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,OAAO,EAKb,MAAM,8CAA8C,CAAC;AAItD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAKhD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { createChannelReceiver, MessagePortChannel, PortTransferType, transferPort, } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
let sdkChannelPromise = null;
|
|
6
|
+
/**
|
|
7
|
+
* Get or create the App SDK's dedicated channel to the host.
|
|
8
|
+
*
|
|
9
|
+
* When `window.__platformBridge` is available (runtime — bridge script injected
|
|
10
|
+
* by the gateway), the bridge's `initialize()` method creates the channel.
|
|
11
|
+
*
|
|
12
|
+
* When the bridge is absent (authoring — no bridge script), the SDK falls back
|
|
13
|
+
* to creating a MessageChannel directly and transferring a port to the host
|
|
14
|
+
* via `window.parent.postMessage`.
|
|
15
|
+
*
|
|
16
|
+
* The channel is cached — subsequent calls return the same instance.
|
|
17
|
+
*/
|
|
18
|
+
export function getSdkChannel() {
|
|
19
|
+
if (!sdkChannelPromise) {
|
|
20
|
+
sdkChannelPromise = initSdkChannel();
|
|
21
|
+
}
|
|
22
|
+
return sdkChannelPromise;
|
|
23
|
+
}
|
|
24
|
+
async function initSdkChannel() {
|
|
25
|
+
// Create a receiver for host → SDK actions (subscriptions, push updates)
|
|
26
|
+
const sdkReceiver = createChannelReceiver();
|
|
27
|
+
if (window.__platformBridge) {
|
|
28
|
+
// Runtime: bridge script is injected, use it
|
|
29
|
+
return window.__platformBridge.connect(sdkReceiver);
|
|
30
|
+
}
|
|
31
|
+
// Authoring fallback: no bridge script, self-initialize via window.parent
|
|
32
|
+
const { port1, port2 } = new MessageChannel();
|
|
33
|
+
transferPort(window.parent, port2, PortTransferType.SdkPort, '*');
|
|
34
|
+
const channel = new MessagePortChannel(port1, {
|
|
35
|
+
receiver: sdkReceiver,
|
|
36
|
+
component: 'app-sdk',
|
|
37
|
+
componentVersion: '0.1.0',
|
|
38
|
+
});
|
|
39
|
+
await channel.connect();
|
|
40
|
+
return channel;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=sdkChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkChannel.js","sourceRoot":"","sources":["../../src/internal/sdkChannel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,GACb,MAAM,8CAA8C,CAAC;AAEtD,IAAI,iBAAiB,GAA4B,IAAI,CAAC;AAEtD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,cAAc,EAAE,CAAC;IACvC,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,KAAK,UAAU,cAAc;IAC3B,yEAAyE;IACzE,MAAM,WAAW,GAAG,qBAAqB,EAAE,CAAC;IAC5C,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC5B,6CAA6C;QAC7C,OAAO,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACtD,CAAC;IAED,0EAA0E;IAC1E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,cAAc,EAAE,CAAC;IAE9C,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,KAAK,EAAE;QAC5C,QAAQ,EAAE,WAAW;QACrB,SAAS,EAAE,SAAS;QACpB,gBAAgB,EAAE,OAAO;KAC1B,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IACxB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Send a telemetry event to the host.
|
|
6
|
+
*
|
|
7
|
+
* Fire-and-forget — does not await channel readiness synchronously.
|
|
8
|
+
* The event is queued if the channel isn't ready yet.
|
|
9
|
+
*/
|
|
10
|
+
export declare function trackEvent(eventName: string, properties?: Record<string, unknown>): void;
|
|
11
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/internal/telemetry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAIxF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { Methods } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
import { getSdkChannel } from './sdkChannel';
|
|
6
|
+
/**
|
|
7
|
+
* Send a telemetry event to the host.
|
|
8
|
+
*
|
|
9
|
+
* Fire-and-forget — does not await channel readiness synchronously.
|
|
10
|
+
* The event is queued if the channel isn't ready yet.
|
|
11
|
+
*/
|
|
12
|
+
export function trackEvent(eventName, properties) {
|
|
13
|
+
getSdkChannel().then((channel) => {
|
|
14
|
+
channel.notify(Methods.Telemetry.trackEvent, { eventName, properties });
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/internal/telemetry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,8CAA8C,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,SAAiB,EAAE,UAAoC;IAChF,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QAC/B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import type { Metric } from '@microsoft/managed-apps-common/metrics';
|
|
5
|
+
/**
|
|
6
|
+
* Developer-facing logger interface.
|
|
7
|
+
*
|
|
8
|
+
* App developers provide an implementation via initializeLogger() or setConfig().
|
|
9
|
+
* The logger receives structured metrics streamed from the host (session load,
|
|
10
|
+
* network requests, data request summaries).
|
|
11
|
+
*/
|
|
12
|
+
export interface ILogger {
|
|
13
|
+
/** Receive a structured metric from the host. */
|
|
14
|
+
logMetric?(value: Metric): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=Logger.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.types.d.ts","sourceRoot":"","sources":["../../src/telemetry/Logger.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,iDAAiD;IACjD,SAAS,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.types.js","sourceRoot":"","sources":["../../src/telemetry/Logger.types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import type { ILogger } from './Logger.types';
|
|
5
|
+
/**
|
|
6
|
+
* Initialize the developer logger and subscribe to host metric streaming.
|
|
7
|
+
*
|
|
8
|
+
* When called, the SDK subscribes to Telemetry.subscribeMetrics via the
|
|
9
|
+
* channel's stream() method. The host yields metrics as they're collected
|
|
10
|
+
* (network requests, session load, data request summaries). Each metric
|
|
11
|
+
* is forwarded to the developer's ILogger.logMetric().
|
|
12
|
+
*
|
|
13
|
+
* The subscription runs in the background — this function starts the
|
|
14
|
+
* stream consumer and returns immediately.
|
|
15
|
+
*/
|
|
16
|
+
export declare function initializeLogger(logger: ILogger): void;
|
|
17
|
+
//# sourceMappingURL=LoggerManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerManager.d.ts","sourceRoot":"","sources":["../../src/telemetry/LoggerManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAKtD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { Methods } from '@microsoft/managed-apps-common/communication';
|
|
5
|
+
import { getSdkChannel } from '../internal/sdkChannel';
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the developer logger and subscribe to host metric streaming.
|
|
8
|
+
*
|
|
9
|
+
* When called, the SDK subscribes to Telemetry.subscribeMetrics via the
|
|
10
|
+
* channel's stream() method. The host yields metrics as they're collected
|
|
11
|
+
* (network requests, session load, data request summaries). Each metric
|
|
12
|
+
* is forwarded to the developer's ILogger.logMetric().
|
|
13
|
+
*
|
|
14
|
+
* The subscription runs in the background — this function starts the
|
|
15
|
+
* stream consumer and returns immediately.
|
|
16
|
+
*/
|
|
17
|
+
export function initializeLogger(logger) {
|
|
18
|
+
if (!logger.logMetric)
|
|
19
|
+
return;
|
|
20
|
+
// Start the stream consumer in the background (fire-and-forget)
|
|
21
|
+
consumeMetricStream(logger);
|
|
22
|
+
}
|
|
23
|
+
async function consumeMetricStream(logger) {
|
|
24
|
+
try {
|
|
25
|
+
const channel = await getSdkChannel();
|
|
26
|
+
const stream = channel.stream(Methods.Telemetry.subscribeMetrics);
|
|
27
|
+
for await (const metric of stream) {
|
|
28
|
+
try {
|
|
29
|
+
logger.logMetric?.(metric);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Don't let logger errors break the stream
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Channel or stream unavailable — silently degrade
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=LoggerManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerManager.js","sourceRoot":"","sources":["../../src/telemetry/LoggerManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,8CAA8C,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,IAAI,CAAC,MAAM,CAAC,SAAS;QAAE,OAAO;IAE9B,gEAAgE;IAChE,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,MAAe;IAChD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,aAAa,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAElE,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;YAClC,IAAI,CAAC;gBACH,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;YAAC,MAAM,CAAC;gBACP,2CAA2C;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,mDAAmD;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
export type { ILogger } from './Logger.types';
|
|
5
|
+
export { initializeLogger } from './LoggerManager';
|
|
6
|
+
export type { DataRequestsSummaryMetric, Metric, NetworkRequestMetric, SessionLoadSummaryMetric, } from '@microsoft/managed-apps-common/metrics';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,YAAY,EACV,yBAAyB,EACzB,MAAM,EACN,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,wCAAwC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/managed-apps",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Power Apps SDK",
|
|
6
|
+
"license": "See license in LICENSE file",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./app": {
|
|
9
|
+
"types": "./dist/app/index.d.ts",
|
|
10
|
+
"default": "./dist/app/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./data": {
|
|
13
|
+
"types": "./dist/data/index.d.ts",
|
|
14
|
+
"default": "./dist/data/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./data/metadata/dataverse": {
|
|
17
|
+
"types": "./dist/data/metadata/dataverse/index.d.ts",
|
|
18
|
+
"default": "./dist/data/metadata/dataverse/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./telemetry": {
|
|
21
|
+
"types": "./dist/telemetry/index.d.ts",
|
|
22
|
+
"default": "./dist/telemetry/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc -p tsconfig.build.json",
|
|
32
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
33
|
+
"check-types": "tsc --noEmit",
|
|
34
|
+
"lint": "eslint src/",
|
|
35
|
+
"test": "bun test --isolate src/",
|
|
36
|
+
"clean": "bun ../../scripts/clean.ts dist .turbo tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@microsoft/managed-apps-cli": "0.5.0",
|
|
40
|
+
"@microsoft/managed-apps-common": "0.5.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@repo/repo-config": "0.0.0",
|
|
44
|
+
"@types/bun": "1.3.13",
|
|
45
|
+
"typescript": "5.9.3"
|
|
46
|
+
}
|
|
47
|
+
}
|