@transcend-io/airgap.js-types 6.5.0 → 6.8.2
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/.yarn/sdks/eslint/package.json +6 -0
- package/.yarn/sdks/prettier/package.json +6 -0
- package/.yarn/sdks/typescript/package.json +6 -0
- package/LICENSE +21 -0
- package/build/core.d.ts +375 -0
- package/build/core.d.ts.map +1 -0
- package/build/core.js +133 -0
- package/build/core.js.map +1 -0
- package/{src/enums/index.ts → build/enums/index.d.ts} +1 -0
- package/build/enums/index.d.ts.map +1 -0
- package/build/enums/index.js +16 -0
- package/build/enums/index.js.map +1 -0
- package/build/enums/privacyRegime.d.ts +16 -0
- package/build/enums/privacyRegime.d.ts.map +1 -0
- package/build/enums/privacyRegime.js +20 -0
- package/build/enums/privacyRegime.js.map +1 -0
- package/build/enums/purpose.d.ts +60 -0
- package/build/enums/purpose.d.ts.map +1 -0
- package/build/enums/purpose.js +47 -0
- package/build/enums/purpose.js.map +1 -0
- package/build/enums/viewState.d.ts +53 -0
- package/build/enums/viewState.d.ts.map +1 -0
- package/build/enums/viewState.js +45 -0
- package/build/enums/viewState.js.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +16 -0
- package/build/index.js.map +1 -0
- package/build/tsbuildinfo +1 -0
- package/build/ui.d.ts +109 -0
- package/build/ui.d.ts.map +1 -0
- package/build/ui.js +63 -0
- package/build/ui.js.map +1 -0
- package/package.json +35 -11
- package/.depcheckrc +0 -1
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -34
- package/.vscode/settings.json +0 -6
- package/src/core.ts +0 -351
- package/src/enums/privacyRegime.ts +0 -15
- package/src/enums/purpose.ts +0 -62
- package/src/enums/viewState.ts +0 -67
- package/src/index.ts +0 -1
- package/src/type-utils.ts +0 -110
- package/src/ui.ts +0 -92
- package/tsconfig.json +0 -40
package/src/type-utils.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
// external
|
|
2
|
-
import * as t from 'io-ts';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* To make the inspected type more tractable than a bunch of intersections
|
|
6
|
-
*/
|
|
7
|
-
export type Identity<T> = {
|
|
8
|
-
[K in keyof T]: T[K];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Make selected object keys defined by K optional in type T
|
|
13
|
-
*/
|
|
14
|
-
export type Optionalize<T, K extends keyof T> = Identity<
|
|
15
|
-
Omit<T, K> & Partial<T>
|
|
16
|
-
>;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* An arbitrary object keyed by strings for naming consistency
|
|
20
|
-
*/
|
|
21
|
-
export type ObjByString = { [key in string]: any }; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Object.entries that actually preserves entries as types.
|
|
25
|
-
*
|
|
26
|
-
* @param o - The object to get the entries from
|
|
27
|
-
* @returns The entries of the object preserving type
|
|
28
|
-
*/
|
|
29
|
-
export default function getEntries<
|
|
30
|
-
TKey extends keyof TObj,
|
|
31
|
-
TObj extends ObjByString,
|
|
32
|
-
>(o: TObj): [TKey, TObj[TKey]][] {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
return Object.entries(o) as any;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Invert an object so that the values look up the keys.
|
|
40
|
-
* If the object has an array as the value, each item in the array will be inverted.
|
|
41
|
-
*
|
|
42
|
-
* @param obj - The object to invert
|
|
43
|
-
* @param throwOnDuplicate - When true, throw error if duplicate key detected
|
|
44
|
-
* @returns The inverted object
|
|
45
|
-
*/
|
|
46
|
-
export function invert<TKey extends string, TValue extends string | string[]>(
|
|
47
|
-
obj: { [key in TKey]?: TValue },
|
|
48
|
-
throwOnDuplicate = true,
|
|
49
|
-
): {
|
|
50
|
-
[key in TValue extends (infer TK)[] ? TK : TValue]: TValue extends any[]
|
|
51
|
-
? TKey[]
|
|
52
|
-
: TKey;
|
|
53
|
-
} {
|
|
54
|
-
const result: any = {} as any;
|
|
55
|
-
|
|
56
|
-
// Invert
|
|
57
|
-
getEntries(obj).forEach(([key, instance]: [TKey, TValue | undefined]) => {
|
|
58
|
-
// Ensure no undefined values
|
|
59
|
-
if (instance === undefined) {
|
|
60
|
-
throw new Error('inverse found undefined value, this is not supported');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Handle array case
|
|
64
|
-
if (Array.isArray(instance)) {
|
|
65
|
-
instance.forEach((listKey) => {
|
|
66
|
-
// Create a new entry
|
|
67
|
-
if (!result[listKey]) {
|
|
68
|
-
result[listKey] = [key];
|
|
69
|
-
} else {
|
|
70
|
-
// Add to existing
|
|
71
|
-
result[listKey].push(key);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
} else {
|
|
75
|
-
// Ensure we do not overwrite duplicates
|
|
76
|
-
if (result[instance] && throwOnDuplicate) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
`Encountered duplicate value inverting object: "${instance}: ${key} and ${result[instance]}"`,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
result[instance] = key;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* We care about the values of an enum. This does not come out of the box with io-ts so we have to invert the enum first.
|
|
89
|
-
*
|
|
90
|
-
* @param enm - The enum to invert
|
|
91
|
-
* @returns The io-ts keyof
|
|
92
|
-
*/
|
|
93
|
-
export function valuesOf<TEnum extends string>(
|
|
94
|
-
enm: { [k in string]: TEnum },
|
|
95
|
-
): t.KeyofC<{ [k in TEnum]: unknown }> {
|
|
96
|
-
return t.keyof(invert(enm) as any);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Make an enum compatible with types -- in separate file because Logger/enums and Enum/index circular dependency
|
|
101
|
-
*
|
|
102
|
-
* @param x - The enum
|
|
103
|
-
* @returns The object proxy with error logger when a value is accessed outside of enum
|
|
104
|
-
*/
|
|
105
|
-
export function makeEnum<
|
|
106
|
-
T extends { [index: string]: U | U[] },
|
|
107
|
-
U extends string,
|
|
108
|
-
>(x: T): T {
|
|
109
|
-
return x;
|
|
110
|
-
}
|
package/src/ui.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// external
|
|
2
|
-
import * as t from 'io-ts';
|
|
3
|
-
|
|
4
|
-
// main
|
|
5
|
-
import { valuesOf } from './type-utils';
|
|
6
|
-
|
|
7
|
-
// local
|
|
8
|
-
import {
|
|
9
|
-
DismissedViewState,
|
|
10
|
-
InitialViewState,
|
|
11
|
-
PrivacyRegimeEnum,
|
|
12
|
-
} from './enums';
|
|
13
|
-
|
|
14
|
-
/** Transcend Smart Quarantine API (window.transcend) */
|
|
15
|
-
export type PreInitTranscendAPI = {
|
|
16
|
-
/** Ready event subscriber */
|
|
17
|
-
ready(callback: (transcend: TranscendAPI) => void): void;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Transcend Consent Manager external methods
|
|
22
|
-
*/
|
|
23
|
-
export type ConsentManagerAPI = {
|
|
24
|
-
/** Show consent manager unless recently dismissed */
|
|
25
|
-
autoShowConsentManager(): Promise<void>;
|
|
26
|
-
/** Show consent manager */
|
|
27
|
-
showConsentManager(): Promise<void>;
|
|
28
|
-
/** Hide consent manager */
|
|
29
|
-
hideConsentManager(): Promise<void>;
|
|
30
|
-
/** Toggle consent manager */
|
|
31
|
-
toggleConsentManager(): Promise<void>;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** Transcend Smart Quarantine API (window.transcend) */
|
|
35
|
-
export type TranscendAPI = PreInitTranscendAPI & ConsentManagerAPI;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Customer theming
|
|
39
|
-
*/
|
|
40
|
-
const Theme = t.type({
|
|
41
|
-
/** Primary color */
|
|
42
|
-
primaryColor: t.string,
|
|
43
|
-
/** Font color */
|
|
44
|
-
fontColor: t.string,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Mobile-first responsive breakpoints
|
|
49
|
-
* No media query for mobile, which is the default
|
|
50
|
-
*/
|
|
51
|
-
const Breakpoints = t.type({
|
|
52
|
-
/** In px, at or above this width is tablet */
|
|
53
|
-
tablet: t.string,
|
|
54
|
-
/** In px, at or above this width is desktop */
|
|
55
|
-
desktop: t.string,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
/** Consent manager UI configuration */
|
|
59
|
-
export const ConsentManagerConfig = t.type({
|
|
60
|
-
/** Customer theming */
|
|
61
|
-
theme: Theme,
|
|
62
|
-
/** A set of responsive breakpoints */
|
|
63
|
-
breakpoints: Breakpoints,
|
|
64
|
-
/** The privacy policy URL to redirect to */
|
|
65
|
-
privacyPolicy: t.string,
|
|
66
|
-
/** What state the consent manager should launch in */
|
|
67
|
-
initialViewStateByPrivacyRegime: t.record(
|
|
68
|
-
valuesOf(PrivacyRegimeEnum),
|
|
69
|
-
valuesOf(InitialViewState),
|
|
70
|
-
),
|
|
71
|
-
/** What state the consent manager should go to when dismissed */
|
|
72
|
-
dismissedViewState: valuesOf(DismissedViewState),
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
/** Type override */
|
|
76
|
-
export type ConsentManagerConfig = t.TypeOf<typeof ConsentManagerConfig>;
|
|
77
|
-
|
|
78
|
-
/** Input for Consent manager UI configuration */
|
|
79
|
-
export const ConsentManagerConfigInput = t.partial(ConsentManagerConfig.props);
|
|
80
|
-
|
|
81
|
-
/** Type override */
|
|
82
|
-
export type ConsentManagerConfigInput = t.TypeOf<
|
|
83
|
-
typeof ConsentManagerConfigInput
|
|
84
|
-
>;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Properties exposed on `self` by the Transcend Smart Quarantine
|
|
88
|
-
*/
|
|
89
|
-
export type TranscendView = Window & {
|
|
90
|
-
/** Transcend Smart Quarantine API */
|
|
91
|
-
transcend: TranscendAPI;
|
|
92
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Basic Options */
|
|
4
|
-
"incremental": true,
|
|
5
|
-
"target": "es2020",
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
"lib": ["esnext", "dom"],
|
|
8
|
-
"allowJs": false,
|
|
9
|
-
"checkJs": false, // speeds up tsc
|
|
10
|
-
"jsx": "react",
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"composite": true,
|
|
13
|
-
"declarationMap": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
|
|
16
|
-
/* Strict Type-Checking Options */
|
|
17
|
-
"strict": true,
|
|
18
|
-
|
|
19
|
-
/* Additional Checks */
|
|
20
|
-
"noUnusedLocals": true,
|
|
21
|
-
"noImplicitReturns": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true,
|
|
23
|
-
|
|
24
|
-
/* Module Resolution Options */
|
|
25
|
-
"moduleResolution": "node",
|
|
26
|
-
"baseUrl": ".",
|
|
27
|
-
"typeRoots": ["@types", "node_modules/@types"],
|
|
28
|
-
"esModuleInterop": true,
|
|
29
|
-
"resolveJsonModule": true,
|
|
30
|
-
"forceConsistentCasingInFileNames": true,
|
|
31
|
-
|
|
32
|
-
"outDir": "./build/airgap.js-types",
|
|
33
|
-
"rootDir": "src",
|
|
34
|
-
"tsBuildInfoFile": "../../build/airgap.js-types.tsbuildinfo",
|
|
35
|
-
"types": []
|
|
36
|
-
},
|
|
37
|
-
"include": ["src"],
|
|
38
|
-
"exclude": ["node_modules", "build"],
|
|
39
|
-
"references": []
|
|
40
|
-
}
|