Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions ci/tests/typesCompile.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

// Compiles a TypeScript file that imports every package with types by its
// package name, as a caller does, with the type files themselves checked.
// The file exists only in memory, at the repository root, so the packages
// resolve through the workspace links in node_modules.

const path = require('path');
const ts = require('typescript');

const ROOT = path.resolve(__dirname, '..', '..');
const CHECK_FILE = path.join(ROOT, 'types-compile-check.ts');
const COMPILE_TIMEOUT_MS = 120000;

const OPTIONS = {
noEmit: true,
skipLibCheck: false,
esModuleInterop: true,
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES2020,
moduleResolution: ts.ModuleResolutionKind.Node10
};

const packagesWithTypes = () =>
require(path.join(ROOT, 'package.json')).workspaces
.map((folder) => require(path.join(ROOT, folder, 'package.json')))
.filter((manifest) => manifest.types || manifest.typings)
.map((manifest) => manifest.name);

const isCheckFile = (fileName) =>
path.resolve(fileName).toLowerCase() === CHECK_FILE.toLowerCase();

const compile = (source) => {
const host = ts.createCompilerHost(OPTIONS);
const { fileExists, readFile, getSourceFile } = host;
host.fileExists = (fileName) =>
isCheckFile(fileName) || fileExists.call(host, fileName);
host.readFile = (fileName) =>
isCheckFile(fileName) ? source : readFile.call(host, fileName);
host.getSourceFile = (fileName, language, ...rest) =>
isCheckFile(fileName)
? ts.createSourceFile(fileName, source, language)
: getSourceFile.call(host, fileName, language, ...rest);
const program = ts.createProgram([CHECK_FILE], OPTIONS, host);
const formatHost = {
getCanonicalFileName: (fileName) => fileName,
getCurrentDirectory: () => ROOT,
getNewLine: () => '\n'
};
return ts.getPreEmitDiagnostics(program)
.map((diagnostic) => ts.formatDiagnostic(diagnostic, formatHost).trim());
};

describe('published types', () => {
test('every package\'s types compile when a TypeScript caller imports ' +
'them', () => {
const names = packagesWithTypes();
expect(names.length).toBeGreaterThan(0);
const source = names
.map((name, i) => `import * as p${i} from '${name}';\nexport { p${i} };`)
.join('\n');
expect(compile(source)).toEqual([]);
}, COMPILE_TIMEOUT_MS);
});
2 changes: 1 addition & 1 deletion device-detection/fiftyone.devicedetection.cloud/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
module.exports = {
DeviceDetectionCloud: require('./deviceDetectionCloud'),
DeviceDetectionCloudPipelineBuilder: require('./deviceDetectionCloudPipelineBuilder'),
HardwareProfileCloudEngine: require('../fiftyone.devicedetection.cloud/hardwareProfileCloudEngine')
HardwareProfileCloudEngine: require('./hardwareProfileCloudEngine')

};
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ declare class DeviceDetectionCloudPipelineBuilder extends DeviceDetectionCloudPi
* @param {object} options the options for the pipeline builder
* @param {string} options.licenceKeys license key(s) used by the
* data file update service. A key can be obtained from the
* 51Degrees website: https://51degrees.com/pricing.
* 51Degrees website: https://51degrees.com/pricing?utm_source=code&utm_medium=comment&utm_campaign=51degrees-node&utm_content=fiftyone.devicedetection.cloud-devicedetectioncloudpipelinebuilder.js&utm_term=constructor.
* This parameter MUST be set when using a data file.
* If you do not wish to use a key then you can specify
* an empty string, but this will cause automatic updates
* to be disabled.
* @param {string} options.resourceKey resourceKey
* @param {Array<string>|string} options.requestedProperties the fully
* qualified names of the properties to ask the cloud service for, such
* as device.ismobile. Required with a license key and no resource key.
* @param {string} options.resourceKey resourceKey
* @param {number} options.cacheSize size of the default cache
* (includes cache if set).
* @param {string} options.cloudEndPoint Choose a non default endpoint
Expand All @@ -36,8 +36,8 @@ declare class DeviceDetectionCloudPipelineBuilder extends DeviceDetectionCloudPi
*/
constructor({ licenceKeys, resourceKey, requestedProperties, cacheSize, cloudEndPoint, cloudRequestOrigin }: {
licenceKeys: string;
resourceKey: string;
requestedProperties: Array<string> | string;
resourceKey: string;
cacheSize: number;
cloudEndPoint: string;
cloudRequestOrigin: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export let DeviceDetectionCloud: typeof import("./deviceDetectionCloud");
export let DeviceDetectionCloudPipelineBuilder: typeof import("./deviceDetectionCloudPipelineBuilder");
export let HardwareProfileCloudEngine: typeof import("../fiftyone.devicedetection.cloud/hardwareProfileCloudEngine");
export let HardwareProfileCloudEngine: typeof import("./hardwareProfileCloudEngine");
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ module.exports = {
DeviceDetectionOnPremise: require('./deviceDetectionOnPremise'),
DeviceDetectionOnPremisePipelineBuilder: require('./deviceDetectionOnPremisePipelineBuilder'),
SwigData: require('./swigData'),
swigHelpers: require('../fiftyone.devicedetection.onpremise/swigHelpers')
swigHelpers: require('./swigHelpers')
};
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ declare class DeviceDetectionOnPremise extends DeviceDetectionOnPremise_base {
* @param {string} options.tempDataDir The directory to use for the
* temporary data copy if 'createTempDataCopy' is set to true.
* @param {boolean} options.updateOnStart whether to download / update
* the datafile on initialisation
* the datafile on initialisation. If there is no file at dataFilePath it
* is downloaded, and processing fails if the download does not work.
*/
constructor({ dataFilePath, autoUpdate, cache, dataUpdateUrl, dataUpdateVerifyMd5, dataUpdateUseUrlFormatter, restrictedProperties, licenceKeys, download, performanceProfile, reuseTempFile, updateMatchedUserAgent, maxMatchedUserAgentLength, drift, difference, concurrency, allowUnmatched, fileSystemWatcher, pollingInterval, updateTimeMaximumRandomisation, createTempDataCopy, tempDataDir, updateOnStart }: {
dataFilePath: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,8 @@ export let testConstants: {
hardwareResourceKeyEnvVar: string;
browserResourceKeyEnvVar: string;
noSetHeaderResourceKeyEnvVar: string;
/**
* @deprecated No test reads a licence key under this name. The licence
* key is read from the _51DEGREES_LICENSE_KEY environment variable.
*/
licenseKeyEnvVar: string;
};
/**
* @deprecated The name each of envVars replaced. An old name is read only
* when the name that replaced it is unset or empty. Use envVars.
*/
legacyEnvVars: {
_51DEGREES_RESOURCE_KEY: string;
_51DEGREES_RESOURCE_KEY_SUPER: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@ export namespace envVars {
let hardwareResourceKeyEnvVar: string;
let browserResourceKeyEnvVar: string;
let noSetHeaderResourceKeyEnvVar: string;
/**
* @deprecated No test reads a licence key under this name. The licence
* key is read from the _51DEGREES_LICENSE_KEY environment variable.
*/
let licenseKeyEnvVar: string;
}
/**
* @deprecated The name each of envVars replaced. An old name is read only
* when the name that replaced it is unset or empty. Use envVars.
*/
export namespace legacyEnvVars {
let _51DEGREES_RESOURCE_KEY: string;
let _51DEGREES_RESOURCE_KEY_SUPER: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ declare class IpIntelligenceCloudPipelineBuilder extends IpIntelligenceCloudPipe
* @param {object} options the options for the pipeline builder
* @param {string} options.licenceKeys license key(s) used by the
* data file update service. A key can be obtained from the
* 51Degrees website: https://51degrees.com/pricing.
* 51Degrees website: https://51degrees.com/pricing?utm_source=code&utm_medium=comment&utm_campaign=51degrees-node&utm_content=fiftyone.ipintelligence.cloud-ipintelligencecloudpipelinebuilder.js&utm_term=constructor.
* This parameter MUST be set when using a data file.
* If you do not wish to use a key then you can specify
* an empty string, but this will cause automatic updates
* to be disabled.
* @param {string} options.resourceKey resourceKey
* @param {Array<string>|string} options.requestedProperties the fully
* qualified names of the properties to ask the cloud service for, such
* as ip.registeredcountry. Required with a license key and no resource key.
* @param {string} options.resourceKey resourceKey
* @param {number} options.cacheSize size of the default cache
* (includes cache if set).
* @param {string} options.cloudEndPoint Choose a non default endpoint
Expand All @@ -30,8 +30,8 @@ declare class IpIntelligenceCloudPipelineBuilder extends IpIntelligenceCloudPipe
*/
constructor({ licenceKeys, resourceKey, requestedProperties, cacheSize, cloudEndPoint, cloudRequestOrigin }: {
licenceKeys: string;
resourceKey: string;
requestedProperties: Array<string> | string;
resourceKey: string;
cacheSize: number;
cloudEndPoint: string;
cloudRequestOrigin: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare class IpIntelligenceOnPremise extends IpIntelligenceOnPremise_base {
* will be restricted to
* @param {string} options.licenceKeys license key(s) used by the
* data file update service. A key can be obtained from the
* 51Degrees website: https://51degrees.com/pricing.
* 51Degrees website: https://51degrees.com/pricing?utm_source=code&utm_medium=comment&utm_campaign=51degrees-node&utm_content=fiftyone.ipintelligence.onpremise-ipintelligenceonpremise.js&utm_term=constructor.
* If you do not wish to use a key then you can specify
* an empty string, but this will cause automatic updates to
* be disabled.
Expand All @@ -51,7 +51,8 @@ declare class IpIntelligenceOnPremise extends IpIntelligenceOnPremise_base {
* @param {string} options.tempDataDir The directory to use for the
* temporary data copy if 'createTempDataCopy' is set to true.
* @param {boolean} options.updateOnStart whether to download / update
* the datafile on initialisation
* the datafile on initialisation. If there is no file at dataFilePath it
* is downloaded, and processing fails if the download does not work.
*/
constructor({ dataFilePath, autoUpdate, cache, dataUpdateUrl, dataUpdateVerifyMd5, dataUpdateUseUrlFormatter, restrictedProperties, licenceKeys, download, performanceProfile, reuseTempFile, concurrency, fileSystemWatcher, pollingInterval, updateTimeMaximumRandomisation, createTempDataCopy, tempDataDir, updateOnStart }: {
dataFilePath: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare class IpIntelligenceOnPremisePipelineBuilder extends IpIntelligenceOnPre
* @param {object} options the options for the pipeline builder
* @param {string} [options.licenceKeys] license key(s) used by the
* data file update service. A key can be obtained from the
* 51Degrees website: https://51degrees.com/pricing.
* 51Degrees website: https://51degrees.com/pricing?utm_source=code&utm_medium=comment&utm_campaign=51degrees-node&utm_content=fiftyone.ipintelligence.onpremise-ipintelligenceonpremisepipelinebuilder.js&utm_term=constructor.
* This parameter MUST be set when using a data file.
* If you do not wish to use a key then you can specify
* an empty string, but this will cause automatic updates
Expand Down
13 changes: 0 additions & 13 deletions ip-intelligence/fiftyone.ipintelligence.shared/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,8 @@ export let errorMessages: {
export let testConstants: {
envVars: {
superResourceKeyVariable: string;
/**
* @deprecated The name the variable had before, which is read only
* when the variable superResourceKeyVariable names is unset or empty.
* Use superResourceKeyVariable.
*/
superResourceKeyEnvVar: string;
/**
* @deprecated No test reads a resource key under this name. Use
* superResourceKeyVariable.
*/
ipiResourceKeyEnvVar: string;
/**
* @deprecated No test reads a licence key under this name. The licence
* key is read from the _51DEGREES_LICENSE_KEY environment variable.
*/
licenseKeyEnvVar: string;
};
ipAddresses: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
export namespace envVars {
let superResourceKeyVariable: string;
/**
* @deprecated The name the variable had before, which is read only
* when the variable superResourceKeyVariable names is unset or empty.
* Use superResourceKeyVariable.
*/
let superResourceKeyEnvVar: string;
/**
* @deprecated No test reads a resource key under this name. Use
* superResourceKeyVariable.
*/
let ipiResourceKeyEnvVar: string;
/**
* @deprecated No test reads a licence key under this name. The licence
* key is read from the _51DEGREES_LICENSE_KEY environment variable.
*/
let licenseKeyEnvVar: string;
}
export namespace ipAddresses {
Expand Down
4 changes: 2 additions & 2 deletions location/types/geoLocationCloud.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export = GeoLocationCloud;
declare class GeoLocationCloud {
declare const GeoLocationCloud_base: typeof import("fiftyone.pipeline.cloudrequestengine/types/cloudEngine");
declare class GeoLocationCloud extends GeoLocationCloud_base {
/**
* Constructor for GeoLocationCloud
*
Expand All @@ -9,5 +10,4 @@ declare class GeoLocationCloud {
constructor({ locationProvider }: {
locationProvider: string;
}, ...args: any[]);
dataKey: string;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
export = CloudRequestEngine;
declare const CloudRequestEngine_base: typeof import("fiftyone.pipeline.engines/types/engine");
/**
* @typedef {import('fiftyone.pipeline.core').FlowData} FlowData
* @typedef {import('fiftyone.pipeline.core').Evidence} Evidence
*/
declare class CloudRequestEngine extends CloudRequestEngine_base {
/**
* Constructor for CloudRequestEngine
Expand Down Expand Up @@ -86,17 +82,7 @@ declare class CloudRequestEngine extends CloudRequestEngine_base {
* @returns {Promise} resolved once the FlowData is processed
*/
process(flowData: FlowData): Promise<any>;
discovery: Promise<any>;
/**
* A response with a top level `fodid` member, in any case, holds a 51Did
* created for the one request, so it is neither stored in the cache nor
* served from it. The answer is worked out once for each element data,
* so a cache hit does not parse the response again.
*
* @param {object} data the element data of a response
* @returns {boolean} false if the response has a top level fodid member
*/
isCacheable(data: object): boolean;
discovery: any;
/**
* Typically, cloud will return errors as JSON.
* However, transport level errors or other failures can result in
Expand Down Expand Up @@ -219,7 +205,8 @@ declare class CloudRequestEngine extends CloudRequestEngine_base {
*/
getSelectedEvidence(evidence: Evidence, type: string): Evidence;
/**
* Check that the key of a KeyValuePair has the given prefix.
* Check that the key of a KeyValuePair has the given prefix, ignoring
* letter case as evidence keys do.
*
* @param {string} itemKey Key to check
* @param {string} prefix The prefix to check for.
Expand Down
32 changes: 32 additions & 0 deletions pipeline/fiftyone.pipeline.core/types/callbackUrl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export = callbackUrl;
/**
* Builds the callback URL from its parts and checks it. One slash separates
* the host and the endpoint, being added when neither has one and removed
* when both do. The protocol and the host are written in lower case and the
* rest as given, apart from the percent-encoding. The host value holds no
* '?', '#' or '@'.
*
* @param {*} protocol the protocol, http or https in any case
* @param {*} host the host, which can end with a port and a path
* @param {*} endPoint the endpoint
* @returns {{valid: boolean, url: string}|null} null when the protocol,
* host or endpoint is not set. Otherwise whether the URL is valid, and the
* URL to write into the script when it is, or the URL as it was built, for
* the log, when it is not. The logged URL shows '***' in place of everything
* in the host before its last '@'.
*/
declare function callbackUrl(protocol: any, host: any, endPoint: any): {
valid: boolean;
url: string;
} | null;
declare namespace callbackUrl {
export { isScheme };
}
/**
* Whether the protocol is http or https, ignoring the case of its ASCII
* letters only.
*
* @param {string} protocol the protocol
* @returns {boolean} true if the protocol is http or https
*/
declare function isScheme(protocol: string): boolean;
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ declare class ElementDataDictionary extends ElementData {
* @returns {number} integer value
*/
getInternal(key: string): number;
/**
* Looks for a key in the dictionary ignoring its letter case. The contents
* can change after the data is made, so they are searched each time
* rather than indexed once.
*
* @param {string} key the property key to retrieve
* @returns {*} the value, or undefined if there is none
*/
getInternalIgnoringCase(key: string): any;
[Symbol.iterator](): Generator<string, void, unknown>;
}
declare namespace ElementDataDictionary {
Expand Down
2 changes: 1 addition & 1 deletion pipeline/fiftyone.pipeline.core/types/evidence.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ declare class Evidence {
constructor(flowData: FlowData);
flowData: import("./flowData");
evidenceStore: {};
keys: {};
keys: any;
unacceptedStore: {};
/**
* The web request as server.http-request holds it, being every value
Expand Down
Loading
Loading