From 1d5f848363ae4d0278f3ec480b72eae1d41723f9 Mon Sep 17 00:00:00 2001 From: Adam Naji <110662505+Bashamega@users.noreply.github.com> Date: Sat, 18 Jul 2026 21:51:28 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#75279=20Move?= =?UTF-8?q?=20isAvailableOffline=20method=20to=20WebAPIOffline=20and=20upd?= =?UTF-8?q?ate=20documentation=20by=20@Bashamega?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bashamega --- types/xrm/index.d.ts | 15 ++++++++------- types/xrm/xrm-tests.ts | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/types/xrm/index.d.ts b/types/xrm/index.d.ts index 16eddee53d9e2e..0e6a58a3f4136d 100644 --- a/types/xrm/index.d.ts +++ b/types/xrm/index.d.ts @@ -6016,13 +6016,6 @@ declare namespace Xrm { * @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-webapi External Link: Xrm.WebApi (Client API reference)} */ interface WebApi extends WebApiOffline { - /** - * Returns a boolean value indicating whether an entity is offline enabled. - * @param entityLogicalName Logical name of the entity. For example: "account". - * @returns true if the entity is offline enabled; otherwise false. - */ - isAvailableOffline(entityLogicalName: string): boolean; - /** * Provides methods to use Web API to create and manage records and execute Web API actions and functions in Customer Engagement when connected to the Customer Engagement server (online mode). * @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-webapi/online External Link: Xrm.WebApi.online (Client API reference)} @@ -6159,6 +6152,14 @@ declare namespace Xrm { * @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-webapi/updaterecord External Link: updateRecord (Client API reference)} */ updateRecord(entityLogicalName: string, id: string, data: any): Async.PromiseLike; + + /** + * Returns a boolean value indicating whether an entity is offline enabled. + * @param entityLogicalName Logical name of the entity. For example: "account". + * @returns true if the entity is offline enabled; otherwise false. + * @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-webapi/isavailableoffline External Link: isAvailableOffline (Client API reference)} + */ + isAvailableOffline(entityLogicalName: string): boolean; } /** diff --git a/types/xrm/xrm-tests.ts b/types/xrm/xrm-tests.ts index c396ec2644b043..8fc1d20092c6bf 100644 --- a/types/xrm/xrm-tests.ts +++ b/types/xrm/xrm-tests.ts @@ -844,3 +844,24 @@ function testItemCollectionGet(formContext: Xrm.FormContext) { // $ExpectType Tab formContext.ui.tabs.get("tabName"); } +// Demonstrate Xrm.WebApi.offline.isAvailableOffline + +// Test with a typical entity logical name +// $ExpectType boolean +const isAccountAvailableOffline = Xrm.WebApi.offline.isAvailableOffline("account"); + +// Test with a custom entity logical name +// $ExpectType boolean +const isCustomEntityAvailableOffline = Xrm.WebApi.offline.isAvailableOffline("new_customentity"); + +// Should error with missing parameter +// @ts-expect-error +Xrm.WebApi.offline.isAvailableOffline(); + +// Should error with a non-string parameter +// @ts-expect-error +Xrm.WebApi.offline.isAvailableOffline(12345); + +// Should error with extra parameters +// @ts-expect-error +Xrm.WebApi.offline.isAvailableOffline("account", "extra"); From 780fe0f985e45cf474cb9e7d0e77e7eb2984b268 Mon Sep 17 00:00:00 2001 From: Trim21 Date: Sun, 19 Jul 2026 04:11:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#75280=20Update?= =?UTF-8?q?=20@types/bencode=20to=20v4=20by=20@trim21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/bencode/bencode-tests.ts | 22 ++++++++---- types/bencode/index.d.ts | 65 +++++++++++++++++++++++++++------- types/bencode/package.json | 15 +++++--- 3 files changed, 78 insertions(+), 24 deletions(-) diff --git a/types/bencode/bencode-tests.ts b/types/bencode/bencode-tests.ts index 0f213cc46b6ab7..a374fa678fc48c 100644 --- a/types/bencode/bencode-tests.ts +++ b/types/bencode/bencode-tests.ts @@ -1,9 +1,19 @@ -import * as bencode from "bencode"; +import bencode from "bencode"; bencode.byteLength("abcde"); // $ExpectType number bencode.encodingLength("abcde"); // $ExpectType number -bencode.encode([1, 2, 3, 4], new Buffer([]), 1); // $ExpectType Buffer || Buffer -bencode.decode(new Buffer("abcde"), 1, 3); // $ExpectType any -bencode.decode(new Buffer("abcde"), 1, 3, "utf-8"); // $ExpectType any -bencode.decode(new Buffer("abcde"), 1, "utf-8"); // $ExpectType any -bencode.decode(new Buffer("abcde"), "utf-8"); // $ExpectType any + +bencode.encode([1, 2, 3, 4]); // $ExpectType Uint8Array || Uint8Array +bencode.encode([1, 2, 3, 4], new Uint8Array(100)); // $ExpectType Uint8Array || Uint8Array +bencode.encode([1, 2, 3, 4], new Uint8Array(100), 0); // $ExpectType Uint8Array || Uint8Array + +bencode.encode.bytes; // $ExpectType number +bencode.encode._floatConversionDetected; // $ExpectType boolean + +bencode.decode(new Uint8Array([100, 51, 58, 97, 98, 99, 101])); // $ExpectType any +bencode.decode(new Uint8Array([100, 51, 58, 97, 98, 99, 101]), "utf-8"); // $ExpectType any +bencode.decode(new Uint8Array([100, 51, 58, 97, 98, 99, 101]), 1, 3); // $ExpectType any +bencode.decode(new Uint8Array([100, 51, 58, 97, 98, 99, 101]), 1, 3, "utf-8"); // $ExpectType any +bencode.decode(new Uint8Array([100, 51, 58, 97, 98, 99, 101]), 1, "utf-8"); // $ExpectType any + +bencode.decode.bytes; // $ExpectType number diff --git a/types/bencode/index.d.ts b/types/bencode/index.d.ts index 2584ac72c7570e..d2226f75c5731a 100644 --- a/types/bencode/index.d.ts +++ b/types/bencode/index.d.ts @@ -1,13 +1,52 @@ -/// - -export function byteLength(value: any): number; -export function encodingLength(value: any): number; -export function encode(data: any, buffer?: Buffer, offset?: number): Buffer; -export function decode(data: Buffer, encoding?: string): any; -export function decode(data: Buffer, start?: number, encoding?: string): any; -export function decode( - data: Buffer, - start?: number, - end?: number, - encoding?: string, -): any; +/** + * Determines the amount of bytes needed to encode the given value. + */ +declare function byteLength(value: any): number; + +/** + * Determines the amount of bytes needed to encode the given value. + * Alias for {@link byteLength}. + */ +declare function encodingLength(value: any): number; + +/** + * Encodes data in bencode. + * + * @param data Data to encode. Supports Uint8Array, Array, String, Object, Number, Boolean, Map, Set. + * @param buffer If provided, the encoded data will be written into this buffer at the given offset. + * @param offset Offset into the buffer to start writing. + * @returns The encoded data as a Uint8Array, or the provided buffer. + */ +declare function encode(data: any, buffer?: Uint8Array, offset?: number): Uint8Array; +declare namespace encode { + /** The number of bytes written in the last encode call. */ + let bytes: number; + /** Set to true if a float value was coerced to an integer during encoding. */ + let _floatConversionDetected: boolean; +} + +/** + * Decodes bencoded data. + * + * @param data The bencoded data to decode. + * @param start Optional start position in the data buffer. + * @param end Optional end position in the data buffer. + * @param encoding If provided, byte strings will be automatically converted to strings using this encoding. + * @returns The decoded data. + */ +declare function decode(data: Uint8Array | string, encoding?: string): any; +declare function decode(data: Uint8Array | string, start?: number, encoding?: string): any; +declare function decode(data: Uint8Array | string, start?: number, end?: number, encoding?: string): any; +declare namespace decode { + /** The number of bytes consumed in the last decode call. */ + let bytes: number; +} + +declare const bencode: { + byteLength: typeof byteLength; + encodingLength: typeof encodingLength; + encode: typeof encode; + decode: typeof decode; +}; + +export default bencode; diff --git a/types/bencode/package.json b/types/bencode/package.json index 21eab690372509..bdfc3618e183fb 100644 --- a/types/bencode/package.json +++ b/types/bencode/package.json @@ -1,13 +1,18 @@ { "private": true, "name": "@types/bencode", - "version": "2.0.9999", + "version": "4.0.9999", + "type": "module", + "exports": { + ".": { + "types": { + "default": "./index.d.ts" + } + } + }, "projects": [ - "https://github.com/themasch/node-bencode#readme" + "https://github.com/webtorrent/node-bencode#readme" ], - "dependencies": { - "@types/node": "*" - }, "devDependencies": { "@types/bencode": "workspace:." },