@qualtrics/plugin-client 1.8.19
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/create-npm-package.js +39 -0
- package/dist/package.json +33 -0
- package/dist/src/constants.d.ts +12 -0
- package/dist/src/constants.js +21 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/deferred.d.ts +6 -0
- package/dist/src/deferred.js +28 -0
- package/dist/src/deferred.js.map +1 -0
- package/dist/src/errors/encoder.d.ts +15 -0
- package/dist/src/errors/encoder.js +130 -0
- package/dist/src/errors/encoder.js.map +1 -0
- package/dist/src/errors/errorMessages.d.ts +4 -0
- package/dist/src/errors/errorMessages.js +14 -0
- package/dist/src/errors/errorMessages.js.map +1 -0
- package/dist/src/errors/errorTypes.d.ts +67 -0
- package/dist/src/errors/errorTypes.js +166 -0
- package/dist/src/errors/errorTypes.js.map +1 -0
- package/dist/src/errors/interfaceValidator.d.ts +30 -0
- package/dist/src/errors/interfaceValidator.js +54 -0
- package/dist/src/errors/interfaceValidator.js.map +1 -0
- package/dist/src/lib/messages/messageChannel.d.ts +126 -0
- package/dist/src/lib/messages/messageChannel.js +390 -0
- package/dist/src/lib/messages/messageChannel.js.map +1 -0
- package/dist/src/lib/plugin/buildConfig.d.ts +1 -0
- package/dist/src/lib/plugin/buildConfig.js +3 -0
- package/dist/src/lib/plugin/buildConfig.js.map +1 -0
- package/dist/src/lib/plugin/index.d.ts +3 -0
- package/dist/src/lib/plugin/index.js +4 -0
- package/dist/src/lib/plugin/index.js.map +1 -0
- package/dist/src/lib/plugin/models.d.ts +13 -0
- package/dist/src/lib/plugin/models.js +9 -0
- package/dist/src/lib/plugin/models.js.map +1 -0
- package/dist/src/lib/plugin/pluginClient.d.ts +155 -0
- package/dist/src/lib/plugin/pluginClient.js +436 -0
- package/dist/src/lib/plugin/pluginClient.js.map +1 -0
- package/dist/src/lib/plugin/translations.d.ts +15 -0
- package/dist/src/lib/plugin/translations.js +49 -0
- package/dist/src/lib/plugin/translations.js.map +1 -0
- package/dist/src/modelUtils.d.ts +6 -0
- package/dist/src/modelUtils.js +21 -0
- package/dist/src/modelUtils.js.map +1 -0
- package/dist/src/models.d.ts +125 -0
- package/dist/src/models.js +130 -0
- package/dist/src/models.js.map +1 -0
- package/dist/src/utils.d.ts +3 -0
- package/dist/src/utils.js +23 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +25 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { isTranslationFile } from "../../models";
|
|
3
|
+
var Translator = /** @class */ (function () {
|
|
4
|
+
function Translator(translationFile) {
|
|
5
|
+
this.translationFile = translationFile;
|
|
6
|
+
}
|
|
7
|
+
Translator.prototype.getText = function (key, params, defaultValue) {
|
|
8
|
+
var template = this.getTemplateOrDefault(key, defaultValue);
|
|
9
|
+
return Translator.replacePlaceholders(template, params);
|
|
10
|
+
};
|
|
11
|
+
Translator.prototype.getTemplateOrDefault = function (key, defaultValue) {
|
|
12
|
+
var template = this.getTemplate(key);
|
|
13
|
+
if (template !== undefined)
|
|
14
|
+
return template;
|
|
15
|
+
if (defaultValue !== undefined)
|
|
16
|
+
return defaultValue;
|
|
17
|
+
return "{Translation not found: ".concat(key, "}");
|
|
18
|
+
};
|
|
19
|
+
Translator.prototype.getTemplate = function (key) {
|
|
20
|
+
var _a;
|
|
21
|
+
if (isTranslationFile(this.translationFile)) {
|
|
22
|
+
return (_a = this.translationFile.strings[key]) === null || _a === void 0 ? void 0 : _a.text;
|
|
23
|
+
}
|
|
24
|
+
// get value from TranslationFileDeprecated
|
|
25
|
+
var template = _.get(this.translationFile, key);
|
|
26
|
+
if (typeof template !== 'string')
|
|
27
|
+
return undefined;
|
|
28
|
+
return template;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Replace placeholders like "{{foo}}" with the value specified in params['foo'].
|
|
32
|
+
*
|
|
33
|
+
* Placeholders without a value present in params are left untouched.
|
|
34
|
+
*/
|
|
35
|
+
Translator.replacePlaceholders = function (template, params) {
|
|
36
|
+
if (!params) {
|
|
37
|
+
return template;
|
|
38
|
+
}
|
|
39
|
+
var result = template;
|
|
40
|
+
Object.keys(params).forEach(function (key) {
|
|
41
|
+
var reg = new RegExp("{{".concat(key, "}}"), 'g');
|
|
42
|
+
result = result.replace(reg, params[key]);
|
|
43
|
+
});
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
return Translator;
|
|
47
|
+
}());
|
|
48
|
+
export default Translator;
|
|
49
|
+
//# sourceMappingURL=translations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translations.js","sourceRoot":"","sources":["../../../../../plugin-sdk/src/lib/plugin/translations.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAA;AAEtB,OAAO,EAAC,iBAAiB,EAA6C,qBAAmB;AAEzF;IACE,oBAAoB,eAA4D;QAA5D,oBAAe,GAAf,eAAe,CAA6C;IAAG,CAAC;IAEpF,4BAAO,GAAP,UAAQ,GAAW,EAAE,MAA+B,EAAE,YAAqB;QACzE,IAAM,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;QAC7D,OAAO,UAAU,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACzD,CAAC;IAEO,yCAAoB,GAA5B,UAA6B,GAAW,EAAE,YAAqB;QAC7D,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QACtC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAA;QAC3C,IAAI,YAAY,KAAK,SAAS;YAAE,OAAO,YAAY,CAAA;QACnD,OAAO,kCAA2B,GAAG,MAAG,CAAA;IAC1C,CAAC;IAEO,gCAAW,GAAnB,UAAoB,GAAW;;QAC7B,IAAI,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YAC5C,OAAO,MAAA,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,0CAAE,IAAI,CAAA;QAChD,CAAC;QACD,2CAA2C;QAC3C,IAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA;QACjD,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAA;QAClD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;;;OAIG;IACY,8BAAmB,GAAlC,UAAmC,QAAgB,EAAE,MAA+B;QAClF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,IAAI,MAAM,GAAG,QAAQ,CAAA;QACrB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAC,GAAG;YAC9B,IAAM,GAAG,GAAG,IAAI,MAAM,CAAC,YAAK,GAAG,OAAI,EAAE,GAAG,CAAC,CAAA;YACzC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;IACH,iBAAC;AAAD,CAAC,AAzCD,IAyCC;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as t from 'io-ts';
|
|
2
|
+
export declare function createCodec<T>(typeName: string, isTypeFunc: (value: unknown) => value is T): t.Type<T>;
|
|
3
|
+
export declare function isPresent(variable: unknown): boolean;
|
|
4
|
+
export declare function isSerializable(variable: unknown): boolean;
|
|
5
|
+
export declare function OptionalArg<T>(codec: t.Type<T>): t.Type<T | undefined>;
|
|
6
|
+
export declare const NonEmptyString: t.Type<string, string, unknown>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as t from 'io-ts';
|
|
2
|
+
export function createCodec(typeName, isTypeFunc) {
|
|
3
|
+
return new t.Type(typeName, isTypeFunc, function (value, context) { return (isTypeFunc(value) ? t.success(value) : t.failure(value, context)); }, t.identity);
|
|
4
|
+
}
|
|
5
|
+
export function isPresent(variable) {
|
|
6
|
+
return variable !== undefined && variable !== null && variable !== '';
|
|
7
|
+
}
|
|
8
|
+
export function isSerializable(variable) {
|
|
9
|
+
try {
|
|
10
|
+
JSON.stringify(variable);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
export function OptionalArg(codec) {
|
|
18
|
+
return t.union([codec, t.undefined]);
|
|
19
|
+
}
|
|
20
|
+
export var NonEmptyString = createCodec('NonEmptyString', function (s) { return t.string.is(s) && isPresent(s); });
|
|
21
|
+
//# sourceMappingURL=modelUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelUtils.js","sourceRoot":"","sources":["../../../plugin-sdk/src/modelUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAA;AAE1B,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,UAA0C;IAE1C,OAAO,IAAI,CAAC,CAAC,IAAI,CACf,QAAQ,EACR,UAAU,EACV,UAAC,KAAK,EAAE,OAAO,IAAK,OAAA,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAlE,CAAkE,EACtF,CAAC,CAAC,QAAQ,CACX,CAAA;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,QAAiB;IACzC,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,EAAE,CAAA;AACvE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAiB;IAC9C,IAAI,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IAC1B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,WAAW,CAAI,KAAgB;IAC7C,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;AACtC,CAAC;AAED,MAAM,CAAC,IAAM,cAAc,GAAG,WAAW,CACvC,gBAAgB,EAChB,UAAC,CAAU,IAAkB,OAAA,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,EAA9B,CAA8B,CAC5D,CAAA"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as t from 'io-ts';
|
|
2
|
+
/**
|
|
3
|
+
* Any object that can be serialized
|
|
4
|
+
*/
|
|
5
|
+
export type SerializableRecord = Record<string, unknown>;
|
|
6
|
+
export declare const SerializableRecord: t.Type<SerializableRecord, SerializableRecord, unknown>;
|
|
7
|
+
export type SerializableArray = Array<unknown>;
|
|
8
|
+
export declare const SerializableArray: t.Type<SerializableArray, SerializableArray, unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* A generic property bag that is a payload on messages passed to plugins and
|
|
11
|
+
* back. Will be serialized.
|
|
12
|
+
*/
|
|
13
|
+
export type MessageData = unknown;
|
|
14
|
+
export declare const MessageData: t.Type<unknown, unknown, unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* Handlers receive MessageData as a parameter and provide MessageData in
|
|
17
|
+
* return.
|
|
18
|
+
*/
|
|
19
|
+
export type BaseHandler = (m: MessageData) => MessageData;
|
|
20
|
+
export declare const BaseHandler: t.Type<BaseHandler, BaseHandler, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Fields that are required for egress connections, but not for internal
|
|
23
|
+
* connections.
|
|
24
|
+
*/
|
|
25
|
+
export declare const EgressConnectionFields: t.TypeC<{
|
|
26
|
+
paramFormat: t.Type<string, string, unknown>;
|
|
27
|
+
paramName: t.Type<string, string, unknown>;
|
|
28
|
+
paramTemplate: t.Type<string, string, unknown>;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Egress gateway credential provided by user making egress request
|
|
32
|
+
*/
|
|
33
|
+
export declare const EgressFetchConnectionSpecifier: t.IntersectionC<[t.TypeC<{
|
|
34
|
+
connectionName: t.Type<string, string, unknown>;
|
|
35
|
+
}>, t.TypeC<{
|
|
36
|
+
paramFormat: t.Type<string, string, unknown>;
|
|
37
|
+
paramName: t.Type<string, string, unknown>;
|
|
38
|
+
paramTemplate: t.Type<string, string, unknown>;
|
|
39
|
+
}>]>;
|
|
40
|
+
export type EgressFetchConnectionSpecifier = t.TypeOf<typeof EgressFetchConnectionSpecifier>;
|
|
41
|
+
/**
|
|
42
|
+
* Fetch config provided by developer
|
|
43
|
+
*/
|
|
44
|
+
export declare const UserProvidedFetchConfig: t.IntersectionC<[t.TypeC<{
|
|
45
|
+
method: t.Type<string, string, unknown>;
|
|
46
|
+
}>, t.PartialC<{
|
|
47
|
+
headers: t.RecordC<t.StringC, t.StringC>;
|
|
48
|
+
body: t.UnionC<[t.Type<SerializableRecord, SerializableRecord, unknown>, t.Type<SerializableArray, SerializableArray, unknown>, t.StringC]>;
|
|
49
|
+
params: t.RecordC<t.StringC, t.StringC>;
|
|
50
|
+
connection: t.IntersectionC<[t.TypeC<{
|
|
51
|
+
connectionName: t.Type<string, string, unknown>;
|
|
52
|
+
}>, t.PartialC<{
|
|
53
|
+
paramFormat: t.Type<string, string, unknown>;
|
|
54
|
+
paramName: t.Type<string, string, unknown>;
|
|
55
|
+
paramTemplate: t.Type<string, string, unknown>;
|
|
56
|
+
}>]>;
|
|
57
|
+
}>]>;
|
|
58
|
+
export type UserProvidedFetchConfig = t.TypeOf<typeof UserProvidedFetchConfig>;
|
|
59
|
+
/**
|
|
60
|
+
* fetchQualtricsApi config provided by Developer
|
|
61
|
+
*/
|
|
62
|
+
export declare const UserProvidedQualtricsApiFetchConfig: t.IntersectionC<[t.TypeC<{
|
|
63
|
+
method: t.Type<string, string, unknown>;
|
|
64
|
+
}>, t.PartialC<{
|
|
65
|
+
body: t.Type<unknown, unknown, unknown>;
|
|
66
|
+
params: t.RecordC<t.StringC, t.StringC>;
|
|
67
|
+
}>]>;
|
|
68
|
+
export type UserProvidedQualtricsApiFetchConfig = t.TypeOf<typeof UserProvidedQualtricsApiFetchConfig>;
|
|
69
|
+
/**
|
|
70
|
+
* Valid connection config
|
|
71
|
+
*/
|
|
72
|
+
export declare function isValidSimpleConnectionScheme(s: unknown): s is SimpleConnectionScheme;
|
|
73
|
+
export type SimpleConnectionScheme = 'apikey' | 'basic' | 'sftp' | 'oauth2' | 'adobe' | 'successfactors' | 'oauth2ClientJWT' | 'awsSigV4' | 'internal' | 'none';
|
|
74
|
+
type Connection = {
|
|
75
|
+
name: string;
|
|
76
|
+
scheme: SimpleConnectionScheme;
|
|
77
|
+
};
|
|
78
|
+
export type ProvidedContext = Record<string, unknown>;
|
|
79
|
+
export type Context = {
|
|
80
|
+
instanceID: string;
|
|
81
|
+
availableConnections: Array<string>;
|
|
82
|
+
connections?: Array<Connection>;
|
|
83
|
+
language: string;
|
|
84
|
+
translations?: TranslationFile;
|
|
85
|
+
translationsError?: unknown;
|
|
86
|
+
} & ProvidedContext;
|
|
87
|
+
export declare function isContext(c: unknown): c is Context;
|
|
88
|
+
/**
|
|
89
|
+
* Translation file format, as placed in a plugin under
|
|
90
|
+
* public/translations/${lang}.json.
|
|
91
|
+
*/
|
|
92
|
+
export interface TranslationFile {
|
|
93
|
+
meta?: {
|
|
94
|
+
summary: string;
|
|
95
|
+
};
|
|
96
|
+
strings: Record<string, {
|
|
97
|
+
text: string;
|
|
98
|
+
context?: string;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Old translation file format. It's a sort of recursive tree, where leaf nodes
|
|
103
|
+
* have to be strings.
|
|
104
|
+
*/
|
|
105
|
+
export interface TranslationFileDeprecated {
|
|
106
|
+
[label: string]: string | TranslationFileDeprecated;
|
|
107
|
+
}
|
|
108
|
+
export declare function isTranslationFile(t: TranslationFile | TranslationFileDeprecated): t is TranslationFile;
|
|
109
|
+
export interface FetchResponse {
|
|
110
|
+
status: number;
|
|
111
|
+
responseData: unknown;
|
|
112
|
+
responseHeaders?: Record<string, string>;
|
|
113
|
+
}
|
|
114
|
+
export declare const EgressResponse: t.IntersectionC<[t.TypeC<{
|
|
115
|
+
httpStatusCode: t.NumberC;
|
|
116
|
+
responseBody: t.StringC;
|
|
117
|
+
}>, t.PartialC<{
|
|
118
|
+
responseHeaders: t.RecordC<t.StringC, t.StringC>;
|
|
119
|
+
}>]>;
|
|
120
|
+
export type EgressResponse = t.TypeOf<typeof EgressResponse>;
|
|
121
|
+
export declare const InitMessage: t.UnionC<[t.UndefinedC, t.PartialC<{
|
|
122
|
+
clientVersion: t.StringC;
|
|
123
|
+
}>]>;
|
|
124
|
+
export type InitMessage = t.TypeOf<typeof InitMessage>;
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Common models across the plugin client and plugin manager. Every item
|
|
2
|
+
// exported by this module is a direct or indirect import of both the client
|
|
3
|
+
// and manager projects.
|
|
4
|
+
import * as t from 'io-ts';
|
|
5
|
+
import { CONNECTION_SCHEMES } from "./constants";
|
|
6
|
+
import { createCodec, isSerializable, NonEmptyString } from "./modelUtils";
|
|
7
|
+
export var SerializableRecord = createCodec('SerializableRecord', function (r) { return t.UnknownRecord.is(r) && isSerializable(r); });
|
|
8
|
+
export var SerializableArray = createCodec('SerializableArray', function (r) { return t.UnknownArray.is(r) && isSerializable(r); });
|
|
9
|
+
export var MessageData = createCodec('MessageData', function (m) {
|
|
10
|
+
return isSerializable(m);
|
|
11
|
+
});
|
|
12
|
+
export var BaseHandler = createCodec('handler', function (h) {
|
|
13
|
+
return t.Function.is(h);
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Fields that are required for all fetch connection specifiers.
|
|
17
|
+
*/
|
|
18
|
+
var CommonConnectionFields = t.type({
|
|
19
|
+
connectionName: NonEmptyString,
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Fields that are required for egress connections, but not for internal
|
|
23
|
+
* connections.
|
|
24
|
+
*/
|
|
25
|
+
export var EgressConnectionFields = t.type({
|
|
26
|
+
paramFormat: NonEmptyString,
|
|
27
|
+
paramName: NonEmptyString,
|
|
28
|
+
paramTemplate: NonEmptyString,
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* An object that specifies a connection to use. Note that it's not known in
|
|
32
|
+
* the plugin client whether the connection is internal or not, so several
|
|
33
|
+
* fields here are marked optional. They're enforced in the manager, after the
|
|
34
|
+
* connection name is resolved against the list of the extension's connections.
|
|
35
|
+
*/
|
|
36
|
+
var FetchConnectionSpecifier = t.intersection([CommonConnectionFields, t.partial(EgressConnectionFields.props)], 'Connection Configuration For Request');
|
|
37
|
+
/**
|
|
38
|
+
* Egress gateway credential provided by user making egress request
|
|
39
|
+
*/
|
|
40
|
+
export var EgressFetchConnectionSpecifier = t.intersection([CommonConnectionFields, EgressConnectionFields], 'Credential Configuration For Egress Request');
|
|
41
|
+
/**
|
|
42
|
+
* Fetch config provided by developer
|
|
43
|
+
*/
|
|
44
|
+
export var UserProvidedFetchConfig = t.intersection([
|
|
45
|
+
t.type({
|
|
46
|
+
// required parameters
|
|
47
|
+
method: NonEmptyString,
|
|
48
|
+
}),
|
|
49
|
+
t.partial({
|
|
50
|
+
// optional parameters
|
|
51
|
+
headers: t.record(t.string, t.string),
|
|
52
|
+
body: t.union([SerializableRecord, SerializableArray, t.string]),
|
|
53
|
+
params: t.record(t.string, t.string),
|
|
54
|
+
connection: FetchConnectionSpecifier,
|
|
55
|
+
}),
|
|
56
|
+
]);
|
|
57
|
+
/**
|
|
58
|
+
* fetchQualtricsApi config provided by Developer
|
|
59
|
+
*/
|
|
60
|
+
export var UserProvidedQualtricsApiFetchConfig = t.intersection([
|
|
61
|
+
t.type({
|
|
62
|
+
method: NonEmptyString,
|
|
63
|
+
}),
|
|
64
|
+
t.partial({
|
|
65
|
+
body: MessageData,
|
|
66
|
+
params: t.record(t.string, t.string),
|
|
67
|
+
}),
|
|
68
|
+
]);
|
|
69
|
+
/**
|
|
70
|
+
* Valid connection config
|
|
71
|
+
*/
|
|
72
|
+
export function isValidSimpleConnectionScheme(s) {
|
|
73
|
+
return (typeof s == 'string' && Object.values(CONNECTION_SCHEMES).includes(s));
|
|
74
|
+
}
|
|
75
|
+
var SimpleConnectionScheme = createCodec('scheme', function (s) {
|
|
76
|
+
return isValidSimpleConnectionScheme(s);
|
|
77
|
+
});
|
|
78
|
+
export function isContext(c) {
|
|
79
|
+
if (typeof c !== 'object')
|
|
80
|
+
return false;
|
|
81
|
+
var co = c;
|
|
82
|
+
if (!co)
|
|
83
|
+
return false;
|
|
84
|
+
if (!co.instanceID)
|
|
85
|
+
return false;
|
|
86
|
+
if (typeof co.instanceID !== 'string')
|
|
87
|
+
return false;
|
|
88
|
+
if (!co.language)
|
|
89
|
+
return false;
|
|
90
|
+
if (typeof co.language !== 'string')
|
|
91
|
+
return false;
|
|
92
|
+
if (!co.availableConnections)
|
|
93
|
+
return false;
|
|
94
|
+
if (!Array.isArray(co.availableConnections))
|
|
95
|
+
return false;
|
|
96
|
+
if (co.connections) {
|
|
97
|
+
if (!(co.connections instanceof Array))
|
|
98
|
+
return false;
|
|
99
|
+
return co.connections.every(function (c) { return c.name && c.scheme; });
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
export function isTranslationFile(t) {
|
|
104
|
+
if (!t.strings)
|
|
105
|
+
return false;
|
|
106
|
+
if (typeof t.strings !== 'object')
|
|
107
|
+
return false;
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
export var EgressResponse = t.intersection([
|
|
111
|
+
t.type({
|
|
112
|
+
httpStatusCode: t.number,
|
|
113
|
+
responseBody: t.string,
|
|
114
|
+
}),
|
|
115
|
+
t.partial({
|
|
116
|
+
responseHeaders: t.record(t.string, t.string),
|
|
117
|
+
}),
|
|
118
|
+
]);
|
|
119
|
+
// InitMessage contains information sent by the plugin client on
|
|
120
|
+
// initialization. For backward compatibility with earlier versions of the
|
|
121
|
+
// plugin client, which didn't send any contents at all, this can be undefined,
|
|
122
|
+
// and all fields are optional.
|
|
123
|
+
export var InitMessage = t.union([
|
|
124
|
+
t.undefined,
|
|
125
|
+
t.partial({
|
|
126
|
+
// optional parameters
|
|
127
|
+
clientVersion: t.string,
|
|
128
|
+
}),
|
|
129
|
+
]);
|
|
130
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../plugin-sdk/src/models.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,wBAAwB;AAExB,OAAO,KAAK,CAAC,MAAM,OAAO,CAAA;AAE1B,OAAO,EAAC,kBAAkB,EAAC,oBAAsB;AACjD,OAAO,EAAC,WAAW,EAAE,cAAc,EAAE,cAAc,EAAC,qBAAuB;AAO3E,MAAM,CAAC,IAAM,kBAAkB,GAAG,WAAW,CAC3C,oBAAoB,EACpB,UAAC,CAAU,IAA8B,OAAA,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,EAA1C,CAA0C,CACpF,CAAA;AAID,MAAM,CAAC,IAAM,iBAAiB,GAAG,WAAW,CAC1C,mBAAmB,EACnB,UAAC,CAAU,IAA6B,OAAA,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,EAAzC,CAAyC,CAClF,CAAA;AASD,M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sBAAsB;QACtB,aAAa,EAAE,CAAC,CAAC,MAAM;KACxB,CAAC;CACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function getUrlVars(url) {
|
|
2
|
+
var vars = {};
|
|
3
|
+
url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
|
|
4
|
+
vars[key] = value;
|
|
5
|
+
return m;
|
|
6
|
+
});
|
|
7
|
+
return vars;
|
|
8
|
+
}
|
|
9
|
+
export function addTimeout(timeout, callback, request) {
|
|
10
|
+
return window.setTimeout(function () {
|
|
11
|
+
callback(new Error("Request timed out after ".concat(timeout.toString(), " milliseconds. Request: ").concat(JSON.stringify(request))));
|
|
12
|
+
}, timeout);
|
|
13
|
+
}
|
|
14
|
+
// returns undefined if the feature key is not set on the window
|
|
15
|
+
// otherwise, returns the feature key value converted to a bool
|
|
16
|
+
export function getFeatureStatus(flipperName) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
var feature = (_c = (_b = (_a = window.Qualtrics) === null || _a === void 0 ? void 0 : _a.Environment) === null || _b === void 0 ? void 0 : _b.features) === null || _c === void 0 ? void 0 : _c[flipperName];
|
|
19
|
+
if (feature === undefined)
|
|
20
|
+
return undefined;
|
|
21
|
+
return !!feature;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../plugin-sdk/src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAM,IAAI,GAA2B,EAAE,CAAA;IACvC,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,UAAU,CAAS,EAAE,GAAW,EAAE,KAAa;QACpF,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACjB,OAAO,CAAC,CAAA;IACV,CAAC,CAAC,CAAA;IACF,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,OAAe,EACf,QAAkC,EAClC,OAAgB;IAEhB,OAAO,MAAM,CAAC,UAAU,CAAC;QACvB,QAAQ,CACN,IAAI,KAAK,CACP,kCAA2B,OAAO,CAAC,QAAQ,EAAE,qCAA2B,IAAI,CAAC,SAAS,CACpF,OAAO,CACR,CAAE,CACJ,CACF,CAAA;IACH,CAAC,EAAE,OAAO,CAAC,CAAA;AACb,CAAC;AAED,gEAAgE;AAChE,+DAA+D;AAC/D,MAAM,UAAU,gBAAgB,CAAC,WAAmB;;IAClD,IAAM,OAAO,GAAG,MAAA,MAAA,MAAA,MAAM,CAAC,SAAS,0CAAE,WAAW,0CAAE,QAAQ,0CAAG,WAAW,CAAC,CAAA;IACtE,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC3C,OAAO,CAAC,CAAC,OAAO,CAAA;AAClB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qualtrics/plugin-client",
|
|
3
|
+
"version": "1.8.19",
|
|
4
|
+
"description": "Interface for XM Plugins to communicate with the environment they're rendered in",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "ssh://git@gitlab-app.eng.qops.net:10022/developer-platform/app-framework/plugin-sdk.git"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"registry": "https://registry.npmjs.org/"
|
|
11
|
+
},
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"depcheck": "1.4.7",
|
|
16
|
+
"ts-patch": "3.1.2"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"fp-ts": "^2.10.5",
|
|
20
|
+
"io-ts": "^2.2.16",
|
|
21
|
+
"lodash": "^4.17.21"
|
|
22
|
+
},
|
|
23
|
+
"main": "dist/src/lib/plugin/index.js",
|
|
24
|
+
"types": "dist/src/lib/plugin/index.d.ts"
|
|
25
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../plugin-sdk/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": "../plugin-sdk",
|
|
5
|
+
"outDir": "./dist/src",
|
|
6
|
+
"plugins": [
|
|
7
|
+
{"transform": "typescript-transform-paths"},
|
|
8
|
+
{"transform": "typescript-transform-paths", "afterDeclarations": true},
|
|
9
|
+
{"transform": "../plugin-sdk/ts-transform-define.ts"}
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"../plugin-sdk/src/lib/plugin/index.ts",
|
|
14
|
+
"../plugin-sdk/src/global.d.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|