react-native-persona 1.2.8 → 1.3.0
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/CHANGELOG.md +29 -0
- package/RNPersonaInquiry.podspec +1 -1
- package/android/README.md +14 -0
- package/android/build.gradle +21 -100
- package/lib/commonjs/index.js +477 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/util.js +36 -0
- package/lib/commonjs/util.js.map +1 -0
- package/lib/commonjs/util.spec.js +31 -0
- package/lib/commonjs/util.spec.js.map +1 -0
- package/lib/module/index.js +452 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/util.js +29 -0
- package/lib/module/util.js.map +1 -0
- package/lib/module/util.spec.js +28 -0
- package/lib/module/util.spec.js.map +1 -0
- package/lib/typescript/persona-tools/Config.d.ts +15 -0
- package/lib/typescript/persona-tools/Theme.d.ts +124 -0
- package/lib/typescript/persona-tools/index.d.ts +1 -0
- package/lib/typescript/persona-tools/lib/AndroidResourcePrinter.d.ts +40 -0
- package/lib/typescript/persona-tools/lib/AndroidResourcePrinter.spec.d.ts +1 -0
- package/lib/typescript/persona-tools/lib/prompts.d.ts +8 -0
- package/lib/typescript/persona-tools/tools/AndroidThemeGenerator.d.ts +5 -0
- package/lib/typescript/persona-tools/tools/IosThemeInstructions.d.ts +5 -0
- package/{generatedTypes → lib/typescript/src}/index.d.ts +67 -3
- package/lib/typescript/src/util.d.ts +3 -0
- package/lib/typescript/src/util.spec.d.ts +1 -0
- package/package.json +79 -21
- package/persona-tools/{config.ts → Config.ts} +7 -7
- package/persona-tools/Theme.ts +140 -138
- package/persona-tools/index.ts +9 -9
- package/persona-tools/lib/AndroidResourcePrinter.spec.ts +100 -101
- package/persona-tools/lib/AndroidResourcePrinter.ts +314 -278
- package/persona-tools/lib/prompts.ts +11 -11
- package/persona-tools/tools/AndroidThemeGenerator.ts +31 -32
- package/persona-tools/tools/IosThemeInstructions.ts +8 -8
- package/src/index.ts +17 -18
- package/src/util.spec.ts +14 -8
- package/src/util.ts +3 -3
- package/jest.config.js +0 -10
- package/persona-tools/Theme.js +0 -213
- package/persona-tools/config.js +0 -72
- package/persona-tools/index.js +0 -30
- package/persona-tools/lib/AndroidResourcePrinter.js +0 -832
- package/persona-tools/lib/AndroidResourcePrinter.spec.js +0 -1135
- package/persona-tools/lib/prompts.js +0 -39
- package/persona-tools/tools/AndroidThemeGenerator.js +0 -59
- package/persona-tools/tools/IosThemeInstructions.js +0 -34
- package/src/index.js +0 -307
- package/src/util.js +0 -29
- package/src/util.spec.js +0 -15
- package/tsconfig.json +0 -29
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.confirmResourceFiles = exports.confirmThemeValues = exports.whatWouldYouLikePrompt = exports.TOOL_CHOICE = void 0;
|
|
7
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
-
exports.TOOL_CHOICE = {
|
|
9
|
-
AndroidTheme: "Update Android theme",
|
|
10
|
-
iosTheme: "Update iOS theme",
|
|
11
|
-
};
|
|
12
|
-
async function whatWouldYouLikePrompt() {
|
|
13
|
-
const questions = {
|
|
14
|
-
name: "choice",
|
|
15
|
-
type: "list",
|
|
16
|
-
choices: [exports.TOOL_CHOICE.AndroidTheme, exports.TOOL_CHOICE.iosTheme],
|
|
17
|
-
message: "What would you like to do?",
|
|
18
|
-
};
|
|
19
|
-
return inquirer_1.default.prompt(questions);
|
|
20
|
-
}
|
|
21
|
-
exports.whatWouldYouLikePrompt = whatWouldYouLikePrompt;
|
|
22
|
-
async function confirmThemeValues() {
|
|
23
|
-
const questions = {
|
|
24
|
-
name: "isConfirmed",
|
|
25
|
-
type: "confirm",
|
|
26
|
-
message: "Do these values look right?",
|
|
27
|
-
};
|
|
28
|
-
return inquirer_1.default.prompt(questions);
|
|
29
|
-
}
|
|
30
|
-
exports.confirmThemeValues = confirmThemeValues;
|
|
31
|
-
async function confirmResourceFiles() {
|
|
32
|
-
const questions = {
|
|
33
|
-
name: "isConfirmed",
|
|
34
|
-
type: "confirm",
|
|
35
|
-
message: `Continue?`,
|
|
36
|
-
};
|
|
37
|
-
return inquirer_1.default.prompt(questions);
|
|
38
|
-
}
|
|
39
|
-
exports.confirmResourceFiles = confirmResourceFiles;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const Theme_1 = __importDefault(require("../Theme"));
|
|
10
|
-
const prompts_1 = require("../lib/prompts");
|
|
11
|
-
const AndroidResourcePrinter_1 = __importDefault(require("../lib/AndroidResourcePrinter"));
|
|
12
|
-
const config_1 = __importDefault(require("../config"));
|
|
13
|
-
const ANDROID_STYLES_RESOURCE_PATH = "./android/app/src/main/res/values/styles_persona.xml";
|
|
14
|
-
const ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH = "./android/app/src/main/res/drawable/rn_persona_button.xml";
|
|
15
|
-
const ANDROID_BUTTON_SECONDARY_DRAWABLE_RESOURCE_PATH = "./android/app/src/main/res/drawable/rn_persona_button_secondary.xml";
|
|
16
|
-
const ANDROID_BUTTON_COLOR_RESOURCE_PATH = "./android/app/src/main/res/color/rn_persona_button.xml";
|
|
17
|
-
class ThemeGenerator {
|
|
18
|
-
async run() {
|
|
19
|
-
await Theme_1.default.print();
|
|
20
|
-
const { isConfirmed: themeValuesConfirmed } = await prompts_1.confirmThemeValues();
|
|
21
|
-
if (!themeValuesConfirmed) {
|
|
22
|
-
console.log(chalk_1.default.yellow("\nPlease adjust the values in package.json.\n"));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
console.log(`\n${chalk_1.default.yellow("Creating an Android Resource files for your project at:")}\n
|
|
26
|
-
- ${ANDROID_STYLES_RESOURCE_PATH}
|
|
27
|
-
- ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}
|
|
28
|
-
- ${ANDROID_BUTTON_SECONDARY_DRAWABLE_RESOURCE_PATH}
|
|
29
|
-
- ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}\n`);
|
|
30
|
-
console.log("Building your application with this resource file themes your Persona Inquiry flow.\n");
|
|
31
|
-
const config = await config_1.default.get();
|
|
32
|
-
const theme = config["androidTheme"];
|
|
33
|
-
const { style, buttonDrawable, buttonSecondaryDrawable, buttonColor } = new AndroidResourcePrinter_1.default(theme).process();
|
|
34
|
-
let { isConfirmed: confirmed } = await prompts_1.confirmResourceFiles();
|
|
35
|
-
if (!confirmed) {
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
// Add a line after confirmation
|
|
39
|
-
console.log("");
|
|
40
|
-
fs_1.default.mkdirSync(path_1.default.dirname(ANDROID_STYLES_RESOURCE_PATH), {
|
|
41
|
-
recursive: true
|
|
42
|
-
});
|
|
43
|
-
fs_1.default.writeFileSync(ANDROID_STYLES_RESOURCE_PATH, style.end({ prettyPrint: true }));
|
|
44
|
-
console.log(`${chalk_1.default.green("Saved an Android style file at path:")} ${ANDROID_STYLES_RESOURCE_PATH}.`);
|
|
45
|
-
fs_1.default.mkdirSync(path_1.default.dirname(ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH), {
|
|
46
|
-
recursive: true
|
|
47
|
-
});
|
|
48
|
-
fs_1.default.writeFileSync(ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH, buttonDrawable.end({ prettyPrint: true }));
|
|
49
|
-
console.log(`${chalk_1.default.green("Saved an Android drawable file at path:")} ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}.`);
|
|
50
|
-
fs_1.default.writeFileSync(ANDROID_BUTTON_SECONDARY_DRAWABLE_RESOURCE_PATH, buttonSecondaryDrawable.end({ prettyPrint: true }));
|
|
51
|
-
console.log(`${chalk_1.default.green("Saved an Android drawable file at path:")} ${ANDROID_BUTTON_SECONDARY_DRAWABLE_RESOURCE_PATH}.`);
|
|
52
|
-
fs_1.default.mkdirSync(path_1.default.dirname(ANDROID_BUTTON_COLOR_RESOURCE_PATH), {
|
|
53
|
-
recursive: true
|
|
54
|
-
});
|
|
55
|
-
fs_1.default.writeFileSync(ANDROID_BUTTON_COLOR_RESOURCE_PATH, buttonColor.end({ prettyPrint: true }));
|
|
56
|
-
console.log(`${chalk_1.default.green("Saved an Android color file at path:")} ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}.`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.default = new ThemeGenerator();
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const Theme_1 = __importDefault(require("../Theme"));
|
|
7
|
-
const prompts_1 = require("../lib/prompts");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
class IosThemeInstructions {
|
|
10
|
-
async run() {
|
|
11
|
-
await Theme_1.default.print("ios");
|
|
12
|
-
const { isConfirmed: themeValuesConfirmed } = await prompts_1.confirmThemeValues();
|
|
13
|
-
if (!themeValuesConfirmed) {
|
|
14
|
-
console.log(chalk_1.default.yellow("\nPlease adjust the values in package.json.\n"));
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
console.log(`\n${chalk_1.default.yellow("To theme the Persona Inquiry flow for iOS:")}`);
|
|
18
|
-
console.log("Add the theme values to the Persona Inquiry SDK client by using the `.iosTheme` builder function");
|
|
19
|
-
console.log(`
|
|
20
|
-
${chalk_1.default.green(`+ import { persona } from '../package.json'`)}
|
|
21
|
-
...
|
|
22
|
-
Inquiry.fromTemplate(selectedTemplateId)
|
|
23
|
-
.onSuccess(handleSuccess)
|
|
24
|
-
.onCancelled(handleCancelled)
|
|
25
|
-
.onFailed(handleFailed)
|
|
26
|
-
.onError(handleError)
|
|
27
|
-
${chalk_1.default.green("+ .iosTheme(persona.iosTheme)")}
|
|
28
|
-
.build()
|
|
29
|
-
.start();
|
|
30
|
-
...
|
|
31
|
-
`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.default = new IosThemeInstructions();
|
package/src/index.js
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Inquiry = exports.Environment = exports.Fields = exports.InvalidAccountId = exports.InvalidInquiryId = exports.InvalidTemplateId = void 0;
|
|
4
|
-
const react_native_1 = require("react-native");
|
|
5
|
-
const util_1 = require("./util");
|
|
6
|
-
const { PersonaInquiry } = react_native_1.NativeModules;
|
|
7
|
-
class InvalidTemplateId extends Error {
|
|
8
|
-
}
|
|
9
|
-
exports.InvalidTemplateId = InvalidTemplateId;
|
|
10
|
-
class InvalidInquiryId extends Error {
|
|
11
|
-
}
|
|
12
|
-
exports.InvalidInquiryId = InvalidInquiryId;
|
|
13
|
-
class InvalidAccountId extends Error {
|
|
14
|
-
}
|
|
15
|
-
exports.InvalidAccountId = InvalidAccountId;
|
|
16
|
-
/**
|
|
17
|
-
* Run validations that the string is in proper Inquiry token format
|
|
18
|
-
* and do a type conversion to InquiryId.
|
|
19
|
-
*
|
|
20
|
-
* @param candidate
|
|
21
|
-
*/
|
|
22
|
-
function makeInquiryId(candidate) {
|
|
23
|
-
if (candidate.startsWith("inq_"))
|
|
24
|
-
return candidate;
|
|
25
|
-
throw new InvalidInquiryId(`Valid template IDs start with "inq_". Received: ${candidate} `);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Run validations that the string is in proper Template token format
|
|
29
|
-
* and do a type conversion to TemplateId.
|
|
30
|
-
*
|
|
31
|
-
* @param candidate
|
|
32
|
-
*/
|
|
33
|
-
function makeTemplateId(candidate) {
|
|
34
|
-
if (candidate.startsWith("tmpl_") || candidate.startsWith("blu_")) {
|
|
35
|
-
return candidate;
|
|
36
|
-
}
|
|
37
|
-
throw new InvalidTemplateId(`Valid template IDs start with "tmpl_". Received: ${candidate} `);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Run validations that the string is in proper Template token format
|
|
41
|
-
* and do a type conversion to AccountId.
|
|
42
|
-
*
|
|
43
|
-
* @param candidate
|
|
44
|
-
*/
|
|
45
|
-
function makeAccountId(candidate) {
|
|
46
|
-
if (candidate.startsWith("act_")) {
|
|
47
|
-
return candidate;
|
|
48
|
-
}
|
|
49
|
-
throw new InvalidAccountId(`Valid account IDs start with "act_". Received: ${candidate} `);
|
|
50
|
-
}
|
|
51
|
-
var Fields;
|
|
52
|
-
(function (Fields) {
|
|
53
|
-
class Builder {
|
|
54
|
-
constructor() {
|
|
55
|
-
this._name = null;
|
|
56
|
-
this._address = null;
|
|
57
|
-
this._birthdate = null;
|
|
58
|
-
this._emailAddress = null;
|
|
59
|
-
this._phoneNumber = null;
|
|
60
|
-
this._fields = {};
|
|
61
|
-
}
|
|
62
|
-
name(name) {
|
|
63
|
-
this._name = name;
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Returns the Field.Builder instance
|
|
68
|
-
*
|
|
69
|
-
* @param address - The address object
|
|
70
|
-
*/
|
|
71
|
-
address(address) {
|
|
72
|
-
this._address = address;
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* @param date {Date}
|
|
77
|
-
*/
|
|
78
|
-
birthdate(date) {
|
|
79
|
-
this._birthdate = date;
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* @param date {string}
|
|
84
|
-
*/
|
|
85
|
-
emailAddress(email) {
|
|
86
|
-
this._emailAddress = email;
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
phoneNumber(phoneNumber) {
|
|
90
|
-
this._phoneNumber = phoneNumber;
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
field(fieldKey, value) {
|
|
94
|
-
this._fields = {
|
|
95
|
-
...this._fields,
|
|
96
|
-
[fieldKey]: value,
|
|
97
|
-
};
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
build() {
|
|
101
|
-
var _a;
|
|
102
|
-
return {
|
|
103
|
-
name: this._name,
|
|
104
|
-
address: this._address,
|
|
105
|
-
emailAddress: this._emailAddress,
|
|
106
|
-
phoneNumber: this._phoneNumber,
|
|
107
|
-
birthdate: (_a = this._birthdate) === null || _a === void 0 ? void 0 : _a.toISOString(),
|
|
108
|
-
additionalFields: this._fields,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function builder() {
|
|
113
|
-
return new Builder();
|
|
114
|
-
}
|
|
115
|
-
Fields.builder = builder;
|
|
116
|
-
})(Fields = exports.Fields || (exports.Fields = {}));
|
|
117
|
-
/**
|
|
118
|
-
* String enum for environments. These strings will be parsed
|
|
119
|
-
* on the native side bridge into Kotlin / Swift enums.
|
|
120
|
-
*/
|
|
121
|
-
var Environment;
|
|
122
|
-
(function (Environment) {
|
|
123
|
-
Environment["SANDBOX"] = "sandbox";
|
|
124
|
-
Environment["PRODUCTION"] = "production";
|
|
125
|
-
})(Environment = exports.Environment || (exports.Environment = {}));
|
|
126
|
-
const eventEmitter = new react_native_1.NativeEventEmitter(PersonaInquiry);
|
|
127
|
-
class Inquiry {
|
|
128
|
-
constructor(options) {
|
|
129
|
-
this.templateId = options.templateId;
|
|
130
|
-
this.inquiryId = options.inquiryId;
|
|
131
|
-
this.referenceId = options.referenceId;
|
|
132
|
-
this.accountId = options.accountId;
|
|
133
|
-
this.environment = options.environment;
|
|
134
|
-
this.accessToken = options.accessToken;
|
|
135
|
-
this.fields = options.fields;
|
|
136
|
-
// Callbacks
|
|
137
|
-
this.onSuccess = options.onSuccess;
|
|
138
|
-
this.onCancelled = options.onCancelled;
|
|
139
|
-
this.onFailed = options.onFailed;
|
|
140
|
-
this.onError = options.onError;
|
|
141
|
-
// Theme object
|
|
142
|
-
this.iosThemeObject = options.iosThemeObject;
|
|
143
|
-
}
|
|
144
|
-
clearListeners() {
|
|
145
|
-
if (this.onSuccessListener)
|
|
146
|
-
this.onSuccessListener.remove();
|
|
147
|
-
if (this.onCancelledListener)
|
|
148
|
-
this.onCancelledListener.remove();
|
|
149
|
-
if (this.onFailedListener)
|
|
150
|
-
this.onFailedListener.remove();
|
|
151
|
-
if (this.onErrorListener)
|
|
152
|
-
this.onErrorListener.remove();
|
|
153
|
-
}
|
|
154
|
-
start() {
|
|
155
|
-
this.onSuccessListener = eventEmitter.addListener("onSuccess", ({ inquiryId: inquiryId, attributes: attributes, }) => {
|
|
156
|
-
// Native Brige sends an ISO 8601 Date. Convert this to a JS Date
|
|
157
|
-
if (typeof attributes.birthdate === "string") {
|
|
158
|
-
attributes.birthdate = new Date(attributes.birthdate);
|
|
159
|
-
}
|
|
160
|
-
if (this.onSuccess)
|
|
161
|
-
this.onSuccess(inquiryId, attributes);
|
|
162
|
-
this.clearListeners();
|
|
163
|
-
});
|
|
164
|
-
this.onCancelledListener = eventEmitter.addListener("onCancelled", () => {
|
|
165
|
-
if (this.onCancelled)
|
|
166
|
-
this.onCancelled();
|
|
167
|
-
this.clearListeners();
|
|
168
|
-
});
|
|
169
|
-
this.onFailedListener = eventEmitter.addListener("onFailed", ({ inquiryId: inquiryId }) => {
|
|
170
|
-
if (this.onFailed)
|
|
171
|
-
this.onFailed(inquiryId);
|
|
172
|
-
this.clearListeners();
|
|
173
|
-
});
|
|
174
|
-
this.onErrorListener = eventEmitter.addListener("onError", ({ error: errorMessage }) => {
|
|
175
|
-
if (this.onError)
|
|
176
|
-
this.onError(new Error(errorMessage));
|
|
177
|
-
this.clearListeners();
|
|
178
|
-
});
|
|
179
|
-
PersonaInquiry.startInquiry({
|
|
180
|
-
templateId: this.templateId,
|
|
181
|
-
inquiryId: this.inquiryId,
|
|
182
|
-
referenceId: this.referenceId,
|
|
183
|
-
accountId: this.accountId,
|
|
184
|
-
environment: this.environment,
|
|
185
|
-
accessToken: this.accessToken,
|
|
186
|
-
fields: this.fields,
|
|
187
|
-
iosTheme: util_1.processThemeValues(this.iosThemeObject || {}),
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
exports.Inquiry = Inquiry;
|
|
192
|
-
class InquiryBuilder {
|
|
193
|
-
constructor(inquiryId) {
|
|
194
|
-
this._inquiryId = inquiryId;
|
|
195
|
-
}
|
|
196
|
-
accessToken(accessToken) {
|
|
197
|
-
this._accessToken = accessToken;
|
|
198
|
-
return this;
|
|
199
|
-
}
|
|
200
|
-
onSuccess(callback) {
|
|
201
|
-
this._onSuccess = callback;
|
|
202
|
-
return this;
|
|
203
|
-
}
|
|
204
|
-
onCancelled(callback) {
|
|
205
|
-
this._onCancelled = callback;
|
|
206
|
-
return this;
|
|
207
|
-
}
|
|
208
|
-
onFailed(callback) {
|
|
209
|
-
this._onFailed = callback;
|
|
210
|
-
return this;
|
|
211
|
-
}
|
|
212
|
-
onError(callback) {
|
|
213
|
-
this._onError = callback;
|
|
214
|
-
return this;
|
|
215
|
-
}
|
|
216
|
-
iosTheme(themeObject) {
|
|
217
|
-
this._iosThemeObject = themeObject;
|
|
218
|
-
return this;
|
|
219
|
-
}
|
|
220
|
-
build() {
|
|
221
|
-
return new Inquiry({
|
|
222
|
-
inquiryId: this._inquiryId,
|
|
223
|
-
accessToken: this._accessToken,
|
|
224
|
-
onSuccess: this._onSuccess,
|
|
225
|
-
onCancelled: this._onCancelled,
|
|
226
|
-
onFailed: this._onFailed,
|
|
227
|
-
onError: this._onError,
|
|
228
|
-
iosThemeObject: this._iosThemeObject,
|
|
229
|
-
fields: this._fields,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
class TemplateBuilder {
|
|
234
|
-
constructor(templateId) {
|
|
235
|
-
this._templateId = templateId;
|
|
236
|
-
return this;
|
|
237
|
-
}
|
|
238
|
-
referenceId(referenceId) {
|
|
239
|
-
this._accountId = undefined;
|
|
240
|
-
this._referenceId = referenceId;
|
|
241
|
-
return this;
|
|
242
|
-
}
|
|
243
|
-
accountId(accountId) {
|
|
244
|
-
this._referenceId = undefined;
|
|
245
|
-
this._accountId = makeAccountId(accountId);
|
|
246
|
-
return this;
|
|
247
|
-
}
|
|
248
|
-
environment(environment) {
|
|
249
|
-
this._environment = environment;
|
|
250
|
-
return this;
|
|
251
|
-
}
|
|
252
|
-
accessToken(accessToken) {
|
|
253
|
-
this._accessToken = accessToken;
|
|
254
|
-
return this;
|
|
255
|
-
}
|
|
256
|
-
fields(fields) {
|
|
257
|
-
this._fields = fields;
|
|
258
|
-
return this;
|
|
259
|
-
}
|
|
260
|
-
onSuccess(callback) {
|
|
261
|
-
this._onSuccess = callback;
|
|
262
|
-
return this;
|
|
263
|
-
}
|
|
264
|
-
onCancelled(callback) {
|
|
265
|
-
this._onCancelled = callback;
|
|
266
|
-
return this;
|
|
267
|
-
}
|
|
268
|
-
onFailed(callback) {
|
|
269
|
-
this._onFailed = callback;
|
|
270
|
-
return this;
|
|
271
|
-
}
|
|
272
|
-
onError(callback) {
|
|
273
|
-
this._onError = callback;
|
|
274
|
-
return this;
|
|
275
|
-
}
|
|
276
|
-
iosTheme(themeObject) {
|
|
277
|
-
this._iosThemeObject = themeObject;
|
|
278
|
-
return this;
|
|
279
|
-
}
|
|
280
|
-
build() {
|
|
281
|
-
return new Inquiry({
|
|
282
|
-
templateId: this._templateId,
|
|
283
|
-
accountId: this._accountId,
|
|
284
|
-
referenceId: this._referenceId,
|
|
285
|
-
environment: this._environment,
|
|
286
|
-
accessToken: this._accessToken,
|
|
287
|
-
fields: this._fields,
|
|
288
|
-
onSuccess: this._onSuccess,
|
|
289
|
-
onCancelled: this._onCancelled,
|
|
290
|
-
onFailed: this._onFailed,
|
|
291
|
-
onError: this._onError,
|
|
292
|
-
iosThemeObject: this._iosThemeObject,
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
var InquiryBuilders;
|
|
297
|
-
(function (InquiryBuilders) {
|
|
298
|
-
function fromInquiry(inquiryId) {
|
|
299
|
-
return new InquiryBuilder(makeInquiryId(inquiryId));
|
|
300
|
-
}
|
|
301
|
-
InquiryBuilders.fromInquiry = fromInquiry;
|
|
302
|
-
function fromTemplate(templateId) {
|
|
303
|
-
return new TemplateBuilder(makeTemplateId(templateId));
|
|
304
|
-
}
|
|
305
|
-
InquiryBuilders.fromTemplate = fromTemplate;
|
|
306
|
-
})(InquiryBuilders || (InquiryBuilders = {}));
|
|
307
|
-
exports.default = InquiryBuilders;
|
package/src/util.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processThemeValues = void 0;
|
|
4
|
-
const HEX_REGEX = /^[a-fA-F0-9]{6}$/;
|
|
5
|
-
function processThemeValues(themeObject) {
|
|
6
|
-
const result = {};
|
|
7
|
-
for (const [key, value] of Object.entries(themeObject)) {
|
|
8
|
-
if (value === null) {
|
|
9
|
-
continue;
|
|
10
|
-
}
|
|
11
|
-
if (key.includes("Color")) {
|
|
12
|
-
let colorValue = value;
|
|
13
|
-
if (value[0] === "#") {
|
|
14
|
-
colorValue = value.slice(1);
|
|
15
|
-
}
|
|
16
|
-
if (HEX_REGEX.test(colorValue)) {
|
|
17
|
-
result[key] = `#${colorValue}`;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
result[key] = value.toString();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
exports.processThemeValues = processThemeValues;
|
package/src/util.spec.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const util_1 = require("./util");
|
|
4
|
-
describe('processThemeValues', () => {
|
|
5
|
-
it('works', () => {
|
|
6
|
-
expect(util_1.processThemeValues({ testColorA: "#FFFFFF", testColorB: "#zzzzzz" })).toEqual({ testColorA: "#FFFFFF" });
|
|
7
|
-
});
|
|
8
|
-
it('filters out non 6 character codes', () => {
|
|
9
|
-
expect(util_1.processThemeValues({ testColorA: "#FFFFFF", testColorB: "#FFF" })).toEqual({ testColorA: "#FFFFFF" });
|
|
10
|
-
});
|
|
11
|
-
it('does not do anything with non colors', () => {
|
|
12
|
-
// Values are expected to be strings on the iOS side of the bridge.
|
|
13
|
-
expect(util_1.processThemeValues({ buttonCornerRadius: "20" })).toEqual({ buttonCornerRadius: "20" });
|
|
14
|
-
});
|
|
15
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": [
|
|
4
|
-
"ES2019"
|
|
5
|
-
],
|
|
6
|
-
"target": "ES2019",
|
|
7
|
-
"module": "commonjs",
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"jsx": "react-native",
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"strict": true,
|
|
13
|
-
"noUnusedLocals": true,
|
|
14
|
-
"noUnusedParameters": true,
|
|
15
|
-
"allowJs": true,
|
|
16
|
-
"allowSyntheticDefaultImports": true,
|
|
17
|
-
"isolatedModules": true,
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"declarationDir": "./generatedTypes"
|
|
20
|
-
},
|
|
21
|
-
"include": [
|
|
22
|
-
"src/**/*",
|
|
23
|
-
"persona-tools/**/*"
|
|
24
|
-
],
|
|
25
|
-
"exclude": [
|
|
26
|
-
"node_modules",
|
|
27
|
-
"example/"
|
|
28
|
-
]
|
|
29
|
-
}
|