@oneblink/sdk-core 0.3.1 → 0.3.2-beta.4

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.
@@ -0,0 +1,5 @@
1
+ import { ABNRecord } from '@oneblink/types/typescript/misc';
2
+ export declare const getBusinessNameFromABNRecord: (abnRecord: ABNRecord) => string | undefined;
3
+ export declare const displayBusinessNameFromABNRecord: (abnRecord: ABNRecord) => string;
4
+ export declare const getABNNumberFromABNRecord: (abnRecord: ABNRecord) => string | undefined;
5
+ export declare const displayABNNumberFromABNRecord: (abnRecord: ABNRecord) => string;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.displayABNNumberFromABNRecord = exports.getABNNumberFromABNRecord = exports.displayBusinessNameFromABNRecord = exports.getBusinessNameFromABNRecord = void 0;
4
+ const getBusinessNameFromABNRecord = (abnRecord) => {
5
+ var _a, _b;
6
+ if ((_a = abnRecord.mainName) === null || _a === void 0 ? void 0 : _a.organisationName) {
7
+ return abnRecord.mainName.organisationName;
8
+ }
9
+ if ((_b = abnRecord.mainTradingName) === null || _b === void 0 ? void 0 : _b.organisationName) {
10
+ return abnRecord.mainTradingName.organisationName;
11
+ }
12
+ if (abnRecord.legalName) {
13
+ const { givenName, otherGivenName, familyName } = abnRecord.legalName;
14
+ let legalName = '';
15
+ if (givenName)
16
+ legalName += `${givenName} `;
17
+ // Concat middle name
18
+ if (otherGivenName)
19
+ legalName += `${otherGivenName} `;
20
+ // Concat last name
21
+ if (familyName)
22
+ legalName += `${familyName}`;
23
+ if (legalName)
24
+ return legalName.trim();
25
+ }
26
+ };
27
+ exports.getBusinessNameFromABNRecord = getBusinessNameFromABNRecord;
28
+ const displayBusinessNameFromABNRecord = (abnRecord) => {
29
+ const businessName = (0, exports.getBusinessNameFromABNRecord)(abnRecord);
30
+ return businessName || 'Unknown Business Name';
31
+ };
32
+ exports.displayBusinessNameFromABNRecord = displayBusinessNameFromABNRecord;
33
+ const getABNNumberFromABNRecord = (abnRecord) => {
34
+ if (!abnRecord.ABN)
35
+ return;
36
+ if (Array.isArray(abnRecord.ABN)) {
37
+ const relevantABN = abnRecord.ABN.find((abn) => abn.isCurrentIndicator);
38
+ return relevantABN === null || relevantABN === void 0 ? void 0 : relevantABN.identifierValue;
39
+ }
40
+ return abnRecord.ABN.identifierValue;
41
+ };
42
+ exports.getABNNumberFromABNRecord = getABNNumberFromABNRecord;
43
+ const displayABNNumberFromABNRecord = (abnRecord) => {
44
+ const abnNumber = (0, exports.getABNNumberFromABNRecord)(abnRecord);
45
+ return abnNumber || 'Unknown ABN Number';
46
+ };
47
+ exports.displayABNNumberFromABNRecord = displayABNNumberFromABNRecord;
48
+ //# sourceMappingURL=abnService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abnService.js","sourceRoot":"","sources":["../src/abnService.ts"],"names":[],"mappings":";;;AAEO,MAAM,4BAA4B,GAAG,CAC1C,SAAoB,EACA,EAAE;;IACtB,IAAI,MAAA,SAAS,CAAC,QAAQ,0CAAE,gBAAgB,EAAE;QACxC,OAAO,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAA;KAC3C;IACD,IAAI,MAAA,SAAS,CAAC,eAAe,0CAAE,gBAAgB,EAAE;QAC/C,OAAO,SAAS,CAAC,eAAe,CAAC,gBAAgB,CAAA;KAClD;IACD,IAAI,SAAS,CAAC,SAAS,EAAE;QACvB,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC,SAAS,CAAA;QAErE,IAAI,SAAS,GAAG,EAAE,CAAA;QAClB,IAAI,SAAS;YAAE,SAAS,IAAI,GAAG,SAAS,GAAG,CAAA;QAC3C,qBAAqB;QACrB,IAAI,cAAc;YAAE,SAAS,IAAI,GAAG,cAAc,GAAG,CAAA;QACrD,mBAAmB;QACnB,IAAI,UAAU;YAAE,SAAS,IAAI,GAAG,UAAU,EAAE,CAAA;QAE5C,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC,IAAI,EAAE,CAAA;KACvC;AACH,CAAC,CAAA;AArBY,QAAA,4BAA4B,gCAqBxC;AACM,MAAM,gCAAgC,GAAG,CAC9C,SAAoB,EACZ,EAAE;IACV,MAAM,YAAY,GAAG,IAAA,oCAA4B,EAAC,SAAS,CAAC,CAAA;IAC5D,OAAO,YAAY,IAAI,uBAAuB,CAAA;AAChD,CAAC,CAAA;AALY,QAAA,gCAAgC,oCAK5C;AAEM,MAAM,yBAAyB,GAAG,CACvC,SAAoB,EACA,EAAE;IACtB,IAAI,CAAC,SAAS,CAAC,GAAG;QAAE,OAAM;IAC1B,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QAChC,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;QACvE,OAAO,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,CAAA;KACpC;IACD,OAAO,SAAS,CAAC,GAAG,CAAC,eAAe,CAAA;AACtC,CAAC,CAAA;AATY,QAAA,yBAAyB,6BASrC;AACM,MAAM,6BAA6B,GAAG,CAAC,SAAoB,EAAU,EAAE;IAC5E,MAAM,SAAS,GAAG,IAAA,iCAAyB,EAAC,SAAS,CAAC,CAAA;IACtD,OAAO,SAAS,IAAI,oBAAoB,CAAA;AAC1C,CAAC,CAAA;AAHY,QAAA,6BAA6B,iCAGzC","sourcesContent":["import { ABNRecord } from '@oneblink/types/typescript/misc'\n\nexport const getBusinessNameFromABNRecord = (\n abnRecord: ABNRecord,\n): string | undefined => {\n if (abnRecord.mainName?.organisationName) {\n return abnRecord.mainName.organisationName\n }\n if (abnRecord.mainTradingName?.organisationName) {\n return abnRecord.mainTradingName.organisationName\n }\n if (abnRecord.legalName) {\n const { givenName, otherGivenName, familyName } = abnRecord.legalName\n\n let legalName = ''\n if (givenName) legalName += `${givenName} `\n // Concat middle name\n if (otherGivenName) legalName += `${otherGivenName} `\n // Concat last name\n if (familyName) legalName += `${familyName}`\n\n if (legalName) return legalName.trim()\n }\n}\nexport const displayBusinessNameFromABNRecord = (\n abnRecord: ABNRecord,\n): string => {\n const businessName = getBusinessNameFromABNRecord(abnRecord)\n return businessName || 'Unknown Business Name'\n}\n\nexport const getABNNumberFromABNRecord = (\n abnRecord: ABNRecord,\n): string | undefined => {\n if (!abnRecord.ABN) return\n if (Array.isArray(abnRecord.ABN)) {\n const relevantABN = abnRecord.ABN.find((abn) => abn.isCurrentIndicator)\n return relevantABN?.identifierValue\n }\n return abnRecord.ABN.identifierValue\n}\nexport const displayABNNumberFromABNRecord = (abnRecord: ABNRecord): string => {\n const abnNumber = getABNNumberFromABNRecord(abnRecord)\n return abnNumber || 'Unknown ABN Number'\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * as conditionalLogicService from './conditionalLogicService';
3
3
  import replaceCustomValues, { getElementSubmissionValue } from './replaceCustomValues';
4
4
  export * as typeCastService from './typeCastService';
5
5
  export * as userService from './userService';
6
+ export * as abnService from './abnService';
6
7
  export { replaceCustomValues, getElementSubmissionValue };
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.getElementSubmissionValue = exports.replaceCustomValues = exports.userService = exports.typeCastService = exports.conditionalLogicService = exports.formElementsService = void 0;
22
+ exports.getElementSubmissionValue = exports.replaceCustomValues = exports.abnService = exports.userService = exports.typeCastService = exports.conditionalLogicService = exports.formElementsService = void 0;
23
23
  exports.formElementsService = __importStar(require("./formElementsService"));
24
24
  exports.conditionalLogicService = __importStar(require("./conditionalLogicService"));
25
25
  const replaceCustomValues_1 = __importStar(require("./replaceCustomValues"));
@@ -27,4 +27,5 @@ exports.replaceCustomValues = replaceCustomValues_1.default;
27
27
  Object.defineProperty(exports, "getElementSubmissionValue", { enumerable: true, get: function () { return replaceCustomValues_1.getElementSubmissionValue; } });
28
28
  exports.typeCastService = __importStar(require("./typeCastService"));
29
29
  exports.userService = __importStar(require("./userService"));
30
+ exports.abnService = __importStar(require("./abnService"));
30
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6EAA4D;AAC5D,qFAAoE;AACpE,6EAE8B;AAIrB,8BANF,6BAAmB,CAME;AAAE,0GAL5B,+CAAyB,OAK4B;AAHvD,qEAAoD;AACpD,6DAA4C","sourcesContent":["export * as formElementsService from './formElementsService'\nexport * as conditionalLogicService from './conditionalLogicService'\nimport replaceCustomValues, {\n getElementSubmissionValue,\n} from './replaceCustomValues'\nexport * as typeCastService from './typeCastService'\nexport * as userService from './userService'\n\nexport { replaceCustomValues, getElementSubmissionValue }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6EAA4D;AAC5D,qFAAoE;AACpE,6EAE8B;AAKrB,8BAPF,6BAAmB,CAOE;AAAE,0GAN5B,+CAAyB,OAM4B;AAJvD,qEAAoD;AACpD,6DAA4C;AAC5C,2DAA0C","sourcesContent":["export * as formElementsService from './formElementsService'\nexport * as conditionalLogicService from './conditionalLogicService'\nimport replaceCustomValues, {\n getElementSubmissionValue,\n} from './replaceCustomValues'\nexport * as typeCastService from './typeCastService'\nexport * as userService from './userService'\nexport * as abnService from './abnService'\n\nexport { replaceCustomValues, getElementSubmissionValue }\n"]}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getElementSubmissionValue = void 0;
4
4
  const formElementsService_1 = require("./formElementsService");
5
+ const abnService_1 = require("./abnService");
5
6
  const CUSTOM_VALUES = [
6
7
  {
7
8
  string: '{INFO_PAGE_ID}',
@@ -131,7 +132,7 @@ function getElementSubmissionValue({ propertyName, submission, formElements, for
131
132
  .join(' ') || (value === null || value === void 0 ? void 0 : value.emailAddress));
132
133
  }
133
134
  case 'abn': {
134
- return value === null || value === void 0 ? void 0 : value.ABN.identifierValue;
135
+ return value ? (0, abnService_1.getABNNumberFromABNRecord)(value) : undefined;
135
136
  }
136
137
  default: {
137
138
  return value;
@@ -1 +1 @@
1
- {"version":3,"file":"replaceCustomValues.js","sourceRoot":"","sources":["../src/replaceCustomValues.ts"],"names":[],"mappings":";;;AACA,+DAAuD;AAcvD,MAAM,aAAa,GAAG;IACpB;QACE,MAAM,EAAE,gBAAgB;QACxB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE;KAC7D;IACD;QACE,MAAM,EAAE,kBAAkB;QAC1B,KAAK,EAAE,CAAC,EAAE,IAAI,EAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI;KACpD;IACD;QACE,MAAM,EAAE,WAAW;QACnB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE;KAC7D;IACD;QACE,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI;KACpD;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,CAAC,EACN,mBAAmB,EACnB,UAAU,EACV,UAAU,GACU,EAAE,EAAE;YACxB,IAAI,CAAC,mBAAmB,EAAE;gBACxB,OAAO,EAAE,CAAA;aACV;YACD,OAAO,GAAG,UAAU,CAAC,mBAAmB,CAAC,IAAI,UAAU,CACrD,mBAAmB,CACpB,EAAE,CAAA;QACL,CAAC;KACF;IACD;QACE,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,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AAG,yBAAyB,CAAC;YACtC,YAAY;YACZ,YAAY,EAAE,IAAI,CAAC,QAAQ;YAC3B,UAAU;YACV,UAAU;YACV,UAAU;YACV,YAAY;YACZ,cAAc;SACf,CAAC,CAAA;QAEF,OAAO,SAAS,CAAC,OAAO,CACtB,KAAK,EACL,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,KAAgB,CAC7C,CAAA;IACH,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC;AAED,SAAwB,mBAAmB,CACzC,IAAY,EACZ,EACE,IAAI,EACJ,UAAU,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,cAAc,EACd,kBAAkB,GAGnB;IAED,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,EAAE;QACxC,IAAI;QACJ,UAAU;QACV,UAAU;QACV,UAAU;QACV,YAAY;QACZ,cAAc;KACf,CAAC,CAAA;IACF,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE;QACrD,OAAO,SAAS,CAAC,OAAO,CACtB,WAAW,CAAC,MAAM,EAClB,WAAW,CAAC,KAAK,CAAC;YAChB,IAAI;YACJ,mBAAmB;YACnB,UAAU;YACV,YAAY;YACZ,UAAU;YACV,UAAU;YACV,YAAY;YACZ,cAAc;YACd,kBAAkB;SACnB,CAAC,CACH,CAAA;IACH,CAAC,EAAE,MAAM,CAAC,CAAA;AACZ,CAAC;AAzCD,sCAyCC","sourcesContent":["import { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { findFormElement } from './formElementsService'\n\ntype CustomValuesOptions = {\n form: FormTypes.Form\n externalId?: string\n submissionId: string\n submissionTimestamp: string\n formatDate: (value: string) => string\n formatTime: (value: string) => string\n formatNumber: (value: number) => string\n formatCurrency: (value: number) => string\n previousApprovalId?: string\n}\n\nconst CUSTOM_VALUES = [\n {\n string: '{INFO_PAGE_ID}',\n value: ({ form }: CustomValuesOptions) => form.id.toString(),\n },\n {\n string: '{INFO_PAGE_NAME}',\n value: ({ form }: CustomValuesOptions) => form.name,\n },\n {\n string: '{FORM_ID}',\n value: ({ form }: CustomValuesOptions) => form.id.toString(),\n },\n {\n string: '{FORM_NAME}',\n value: ({ form }: CustomValuesOptions) => form.name,\n },\n {\n string: '{DATE}',\n value: ({\n submissionTimestamp,\n formatDate,\n formatTime,\n }: CustomValuesOptions) => {\n if (!submissionTimestamp) {\n return ''\n }\n return `${formatDate(submissionTimestamp)} ${formatTime(\n submissionTimestamp,\n )}`\n },\n },\n {\n string: '{TIMESTAMP}',\n value: ({ submissionTimestamp }: CustomValuesOptions) =>\n submissionTimestamp || '',\n },\n {\n string: '{SUBMISSION_ID}',\n value: ({ submissionId }: CustomValuesOptions) => submissionId || '',\n },\n {\n string: '{EXTERNAL_ID}',\n value: ({ externalId }: CustomValuesOptions) => externalId || '',\n },\n {\n string: '{PREVIOUS_APPROVAL_ID}',\n value: ({ previousApprovalId }: CustomValuesOptions) =>\n previousApprovalId || '',\n },\n]\n\nexport function getElementSubmissionValue({\n propertyName,\n submission,\n formElements,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n}: {\n propertyName: string\n formElements: FormTypes.FormElement[]\n submission: SubmissionTypes.S3SubmissionData['submission']\n formatDate: (value: string) => string\n formatTime: (value: string) => string\n formatNumber: (value: number) => string\n formatCurrency: (value: number) => string\n}): unknown {\n const formElement = findFormElement(\n formElements,\n (element) =>\n element.type !== 'page' &&\n element.type !== 'section' &&\n element.name === propertyName,\n )\n\n const value = submission[propertyName]\n if (value === undefined || value === null) {\n return undefined\n }\n\n switch (formElement?.type) {\n case 'datetime': {\n return `${formatDate(value)} ${formatTime(value)}`\n }\n case 'date': {\n return formatDate(value)\n }\n case 'time': {\n return formatTime(value)\n }\n case 'radio':\n case 'autocomplete': {\n const option = formElement.options?.find((opt) => opt.value === value)\n return option?.label || value\n }\n\n case 'checkboxes': {\n const selectedOptionLabels: string[] = value.reduce(\n (labels: string[], selectedOption: string) => {\n const foundOption = formElement.options?.find(\n (o) => o.value === selectedOption,\n )\n if (foundOption) labels.push(foundOption.label)\n return labels\n },\n [],\n )\n return selectedOptionLabels.length ? selectedOptionLabels : undefined\n }\n case 'compliance': {\n const option = (formElement.options || []).find(\n (option: FormTypes.ChoiceElementOption) => option.value === value.value,\n )\n return {\n ...value,\n value: option?.label || value.value,\n }\n }\n case 'select': {\n if (formElement.multi) {\n const selectedOptionLabels: string[] = value.reduce(\n (labels: string[], selectedOption: string) => {\n const foundOption = formElement.options?.find(\n (o) => o.value === selectedOption,\n )\n if (foundOption) labels.push(foundOption.label)\n return labels\n },\n [],\n )\n return selectedOptionLabels.length ? selectedOptionLabels : undefined\n } else {\n const option = formElement.options?.find((opt) => opt.value === value)\n return option?.label || ''\n }\n }\n case 'boolean': {\n return value ? 'Yes' : 'No'\n }\n case 'calculation': {\n if (!Number.isNaN(value) && Number.isFinite(value)) {\n let text\n if (formElement.displayAsCurrency) {\n text = formatCurrency(value)\n } else {\n text = formatNumber(value)\n }\n return text\n }\n return undefined\n }\n case 'pointAddress':\n case 'geoscapeAddress': {\n return value?.addressDetails?.formattedAddress || value?.addressId\n }\n case 'civicaStreetName': {\n return value?.formattedStreet\n }\n case 'civicaNameRecord': {\n return (\n [value?.title, value?.givenName1, value?.familyName]\n .filter((t) => t)\n .join(' ') || value?.emailAddress\n )\n }\n case 'abn': {\n return value?.ABN.identifierValue\n }\n default: {\n return value\n }\n }\n}\n\nfunction replaceElementValues(\n text: string,\n {\n form,\n submission,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n }: {\n form: FormTypes.Form\n submission: SubmissionTypes.S3SubmissionData['submission']\n formatDate: (value: string) => string\n formatTime: (value: string) => string\n formatNumber: (value: number) => string\n formatCurrency: (value: number) => string\n },\n): string {\n const matches = text.match(/({ELEMENT:)([^}]+)(})/g)\n if (!matches) {\n return text\n }\n\n return matches.reduce((newString, match) => {\n const propertyName = match.substring(\n match.indexOf(':') + 1,\n match.lastIndexOf('}'),\n )\n\n const value = getElementSubmissionValue({\n propertyName,\n formElements: form.elements,\n submission,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n })\n\n return newString.replace(\n match,\n value === undefined ? '' : (value as string),\n )\n }, text)\n}\n\nexport default function replaceCustomValues(\n text: string,\n {\n form,\n submission,\n externalId,\n submissionId,\n submissionTimestamp,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n previousApprovalId,\n }: CustomValuesOptions & {\n submission: SubmissionTypes.S3SubmissionData['submission']\n },\n): string {\n const string = replaceElementValues(text, {\n form,\n submission,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n })\n return CUSTOM_VALUES.reduce((newString, customValue) => {\n return newString.replace(\n customValue.string,\n customValue.value({\n form,\n submissionTimestamp,\n externalId,\n submissionId,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n previousApprovalId,\n }),\n )\n }, string)\n}\n"]}
1
+ {"version":3,"file":"replaceCustomValues.js","sourceRoot":"","sources":["../src/replaceCustomValues.ts"],"names":[],"mappings":";;;AACA,+DAAuD;AACvD,6CAAwD;AAcxD,MAAM,aAAa,GAAG;IACpB;QACE,MAAM,EAAE,gBAAgB;QACxB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE;KAC7D;IACD;QACE,MAAM,EAAE,kBAAkB;QAC1B,KAAK,EAAE,CAAC,EAAE,IAAI,EAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI;KACpD;IACD;QACE,MAAM,EAAE,WAAW;QACnB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE;KAC7D;IACD;QACE,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAuB,EAAE,EAAE,CAAC,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;YACd,kBAAkB;SACnB,CAAC,CACH,CAAA;IACH,CAAC,EAAE,MAAM,CAAC,CAAA;AACZ,CAAC;AAzCD,sCAyCC","sourcesContent":["import { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { findFormElement } from './formElementsService'\nimport { getABNNumberFromABNRecord } from './abnService'\n\ntype CustomValuesOptions = {\n form: FormTypes.Form\n externalId?: string\n submissionId: string\n submissionTimestamp: string\n formatDate: (value: string) => string\n formatTime: (value: string) => string\n formatNumber: (value: number) => string\n formatCurrency: (value: number) => string\n previousApprovalId?: string\n}\n\nconst CUSTOM_VALUES = [\n {\n string: '{INFO_PAGE_ID}',\n value: ({ form }: CustomValuesOptions) => form.id.toString(),\n },\n {\n string: '{INFO_PAGE_NAME}',\n value: ({ form }: CustomValuesOptions) => form.name,\n },\n {\n string: '{FORM_ID}',\n value: ({ form }: CustomValuesOptions) => form.id.toString(),\n },\n {\n string: '{FORM_NAME}',\n value: ({ form }: CustomValuesOptions) => form.name,\n },\n {\n string: '{DATE}',\n value: ({\n submissionTimestamp,\n formatDate,\n formatTime,\n }: CustomValuesOptions) => {\n if (!submissionTimestamp) {\n return ''\n }\n return `${formatDate(submissionTimestamp)} ${formatTime(\n submissionTimestamp,\n )}`\n },\n },\n {\n string: '{TIMESTAMP}',\n value: ({ submissionTimestamp }: CustomValuesOptions) =>\n submissionTimestamp || '',\n },\n {\n string: '{SUBMISSION_ID}',\n value: ({ submissionId }: CustomValuesOptions) => submissionId || '',\n },\n {\n string: '{EXTERNAL_ID}',\n value: ({ externalId }: CustomValuesOptions) => externalId || '',\n },\n {\n string: '{PREVIOUS_APPROVAL_ID}',\n value: ({ previousApprovalId }: CustomValuesOptions) =>\n previousApprovalId || '',\n },\n]\n\nexport function getElementSubmissionValue({\n propertyName,\n submission,\n formElements,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n}: {\n propertyName: string\n formElements: FormTypes.FormElement[]\n submission: SubmissionTypes.S3SubmissionData['submission']\n formatDate: (value: string) => string\n formatTime: (value: string) => string\n formatNumber: (value: number) => string\n formatCurrency: (value: number) => string\n}): unknown {\n const formElement = findFormElement(\n formElements,\n (element) =>\n element.type !== 'page' &&\n element.type !== 'section' &&\n element.name === propertyName,\n )\n\n const value = submission[propertyName]\n if (value === undefined || value === null) {\n return undefined\n }\n\n switch (formElement?.type) {\n case 'datetime': {\n return `${formatDate(value)} ${formatTime(value)}`\n }\n case 'date': {\n return formatDate(value)\n }\n case 'time': {\n return formatTime(value)\n }\n case 'radio':\n case 'autocomplete': {\n const option = formElement.options?.find((opt) => opt.value === value)\n return option?.label || value\n }\n\n case 'checkboxes': {\n const selectedOptionLabels: string[] = value.reduce(\n (labels: string[], selectedOption: string) => {\n const foundOption = formElement.options?.find(\n (o) => o.value === selectedOption,\n )\n if (foundOption) labels.push(foundOption.label)\n return labels\n },\n [],\n )\n return selectedOptionLabels.length ? selectedOptionLabels : undefined\n }\n case 'compliance': {\n const option = (formElement.options || []).find(\n (option: FormTypes.ChoiceElementOption) => option.value === value.value,\n )\n return {\n ...value,\n value: option?.label || value.value,\n }\n }\n case 'select': {\n if (formElement.multi) {\n const selectedOptionLabels: string[] = value.reduce(\n (labels: string[], selectedOption: string) => {\n const foundOption = formElement.options?.find(\n (o) => o.value === selectedOption,\n )\n if (foundOption) labels.push(foundOption.label)\n return labels\n },\n [],\n )\n return selectedOptionLabels.length ? selectedOptionLabels : undefined\n } else {\n const option = formElement.options?.find((opt) => opt.value === value)\n return option?.label || ''\n }\n }\n case 'boolean': {\n return value ? 'Yes' : 'No'\n }\n case 'calculation': {\n if (!Number.isNaN(value) && Number.isFinite(value)) {\n let text\n if (formElement.displayAsCurrency) {\n text = formatCurrency(value)\n } else {\n text = formatNumber(value)\n }\n return text\n }\n return undefined\n }\n case 'pointAddress':\n case 'geoscapeAddress': {\n return value?.addressDetails?.formattedAddress || value?.addressId\n }\n case 'civicaStreetName': {\n return value?.formattedStreet\n }\n case 'civicaNameRecord': {\n return (\n [value?.title, value?.givenName1, value?.familyName]\n .filter((t) => t)\n .join(' ') || value?.emailAddress\n )\n }\n case 'abn': {\n return value ? getABNNumberFromABNRecord(value) : undefined\n }\n default: {\n return value\n }\n }\n}\n\nfunction replaceElementValues(\n text: string,\n {\n form,\n submission,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n }: {\n form: FormTypes.Form\n submission: SubmissionTypes.S3SubmissionData['submission']\n formatDate: (value: string) => string\n formatTime: (value: string) => string\n formatNumber: (value: number) => string\n formatCurrency: (value: number) => string\n },\n): string {\n const matches = text.match(/({ELEMENT:)([^}]+)(})/g)\n if (!matches) {\n return text\n }\n\n return matches.reduce((newString, match) => {\n const propertyName = match.substring(\n match.indexOf(':') + 1,\n match.lastIndexOf('}'),\n )\n\n const value = getElementSubmissionValue({\n propertyName,\n formElements: form.elements,\n submission,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n })\n\n return newString.replace(\n match,\n value === undefined ? '' : (value as string),\n )\n }, text)\n}\n\nexport default function replaceCustomValues(\n text: string,\n {\n form,\n submission,\n externalId,\n submissionId,\n submissionTimestamp,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n previousApprovalId,\n }: CustomValuesOptions & {\n submission: SubmissionTypes.S3SubmissionData['submission']\n },\n): string {\n const string = replaceElementValues(text, {\n form,\n submission,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n })\n return CUSTOM_VALUES.reduce((newString, customValue) => {\n return newString.replace(\n customValue.string,\n customValue.value({\n form,\n submissionTimestamp,\n externalId,\n submissionId,\n formatDate,\n formatTime,\n formatNumber,\n formatCurrency,\n previousApprovalId,\n }),\n )\n }, string)\n}\n"]}
@@ -13,6 +13,6 @@ declare const formElements: {
13
13
  toRepeatableSetElement: (e: FormTypes.FormElement) => FormTypes.RepeatableSetElement | undefined;
14
14
  };
15
15
  declare const submissionEvents: {
16
- toPaymentSubmissionEvent: (e: SubmissionEventTypes.FormSubmissionEvent) => SubmissionEventTypes.PaymentSubmissionEvent | undefined;
16
+ toPaymentSubmissionEvent: (e: SubmissionEventTypes.FormEvent) => SubmissionEventTypes.PaymentSubmissionEvent | undefined;
17
17
  };
18
18
  export { formElements, submissionEvents };
@@ -1 +1 @@
1
- {"version":3,"file":"typeCastService.js","sourceRoot":"","sources":["../src/typeCastService.ts"],"names":[],"mappings":";;;AAEA,MAAM,gBAAgB,GAAG,CACvB,CAAwB,EACsB,EAAE;IAChD,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,YAAY,CAAC;QAClB,KAAK,OAAO,CAAC;QACb,KAAK,cAAc,CAAC;QACpB,KAAK,YAAY,CAAC,CAAC;YACjB,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAC5B,CAAwB,EACmB,EAAE;IAC7C,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,MAAM,CAAC;QACZ,KAAK,UAAU,CAAC,CAAC;YACf,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,wBAAwB,GAAG,CAC/B,CAAwB,EACsB,EAAE;IAChD,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,MAAM,CAAC;QACZ,KAAK,UAAU,CAAC,CAAC;YACf,OAAM;SACP;QACD,OAAO,CAAC,CAAC;YACP,OAAO,CAAC,CAAA;SACT;KACF;AACH,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CACtB,CAAwB,EACiB,EAAE;IAC3C,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,SAAS,CAAC;QACf,KAAK,YAAY,CAAC;QAClB,KAAK,MAAM,CAAC;QACZ,KAAK,UAAU,CAAC;QAChB,KAAK,OAAO,CAAC;QACb,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ,CAAC;QACd,KA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;IACrC,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,MAAM,CAAC,CAAC;YACX,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,sBAAsB,GAAG,CAC7B,CAAwB,EACoB,EAAE;IAC9C,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,eAAe,CAAC,CAAC;YACpB,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,YAAY,GAAG;IACnB,gBAAgB;IAChB,qBAAqB;IACrB,wBAAwB;IACxB,eAAe;IACf,uBAAuB;IACvB,iBAAiB;IACjB,0BAA0B;IAC1B,aAAa;IACb,sBAAsB;CACvB,CAAA;AAqBQ,oCAAY;AAnBrB,MAAM,wBAAwB,GAAG,CAC/B,CAA2C,EACc,EAAE;IAC3D,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,mBAAmB,CAAC,CAAC;YACxB,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG;IACvB,wBAAwB;CACzB,CAAA;AAEsB,4CAAgB","sourcesContent":["import { FormTypes, SubmissionEventTypes } from '@oneblink/types'\n\nconst toOptionsElement = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithOptions | undefined => {\n switch (e.type) {\n case 'select':\n case 'compliance':\n case 'radio':\n case 'autocomplete':\n case 'checkboxes': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toFormElementWithForm = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithForm | undefined => {\n switch (e.type) {\n case 'form':\n case 'infoPage': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toFormElementWithoutForm = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithoutForm | undefined => {\n switch (e.type) {\n case 'form':\n case 'infoPage': {\n return\n }\n default: {\n return e\n }\n }\n}\n\nconst toLookupElement = (\n e: FormTypes.FormElement,\n): FormTypes.LookupFormElement | undefined => {\n switch (e.type) {\n case 'boolean':\n case 'checkboxes':\n case 'date':\n case 'datetime':\n case 'files':\n case 'location':\n case 'number':\n case 'compliance':\n case 'radio':\n case 'select':\n case 'text':\n case 'textarea':\n case 'time':\n case 'barcodeScanner':\n case 'email':\n case 'telephone':\n case 'pointAddress':\n case 'geoscapeAddress':\n case 'civicaStreetName':\n case 'bsb':\n case 'autocomplete':\n case 'abn': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toNestedElementsElement = (\n e: FormTypes.FormElement,\n): FormTypes.NestedElementsElement | undefined => {\n switch (e.type) {\n case 'repeatableSet':\n case 'section':\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\ntype NamelessElement = FormTypes.PageElement | FormTypes.SectionElement\nconst toNamelessElement = (\n e: FormTypes.FormElement,\n): NamelessElement | undefined => {\n switch (e.type) {\n case 'section':\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\ntype NonNestedElementsFormElement =\n | FormTypes.NonNestedElementsElement\n | FormTypes.FormElementWithForm\nconst toNonNestedElementsElement = (\n e: FormTypes.FormElement,\n): NonNestedElementsFormElement | undefined => {\n switch (e.type) {\n case 'repeatableSet':\n case 'section':\n case 'page': {\n return\n }\n default: {\n return e\n }\n }\n}\n\nconst toPageElement = (\n e: FormTypes.FormElement,\n): FormTypes.PageElement | undefined => {\n switch (e.type) {\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toRepeatableSetElement = (\n e: FormTypes.FormElement,\n): FormTypes.RepeatableSetElement | undefined => {\n switch (e.type) {\n case 'repeatableSet': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst formElements = {\n toOptionsElement,\n toFormElementWithForm,\n toFormElementWithoutForm,\n toLookupElement,\n toNestedElementsElement,\n toNamelessElement,\n toNonNestedElementsElement,\n toPageElement,\n toRepeatableSetElement,\n}\n\nconst toPaymentSubmissionEvent = (\n e: SubmissionEventTypes.FormSubmissionEvent,\n): SubmissionEventTypes.PaymentSubmissionEvent | undefined => {\n switch (e.type) {\n case 'BPOINT':\n case 'CP_PAY':\n case 'WESTPAC_QUICK_WEB': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst submissionEvents = {\n toPaymentSubmissionEvent,\n}\n\nexport { formElements, submissionEvents }\n"]}
1
+ {"version":3,"file":"typeCastService.js","sourceRoot":"","sources":["../src/typeCastService.ts"],"names":[],"mappings":";;;AAEA,MAAM,gBAAgB,GAAG,CACvB,CAAwB,EACsB,EAAE;IAChD,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,YAAY,CAAC;QAClB,KAAK,OAAO,CAAC;QACb,KAAK,cAAc,CAAC;QACpB,KAAK,YAAY,CAAC,CAAC;YACjB,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAC5B,CAAwB,EACmB,EAAE;IAC7C,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,MAAM,CAAC;QACZ,KAAK,UAAU,CAAC,CAAC;YACf,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,wBAAwB,GAAG,CAC/B,CAAwB,EACsB,EAAE;IAChD,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,MAAM,CAAC;QACZ,KAAK,UAAU,CAAC,CAAC;YACf,OAAM;SACP;QACD,OAAO,CAAC,CAAC;YACP,OAAO,CAAC,CAAA;SACT;KACF;AACH,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CACtB,CAAwB,EACiB,EAAE;IAC3C,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KAAK,eAAe,CAAC;QACrB,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC,CAAC;YACX,OAAM;SACP;QACD,OAAO,CAAC,CAAC;YACP,OAAO,CAAC,CAAA;SACT;KACF;AACH,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,CACpB,CAAwB,EACW,EAAE;IACrC,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,MAAM,CAAC,CAAC;YACX,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,sBAAsB,GAAG,CAC7B,CAAwB,EACoB,EAAE;IAC9C,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,eAAe,CAAC,CAAC;YACpB,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,YAAY,GAAG;IACnB,gBAAgB;IAChB,qBAAqB;IACrB,wBAAwB;IACxB,eAAe;IACf,uBAAuB;IACvB,iBAAiB;IACjB,0BAA0B;IAC1B,aAAa;IACb,sBAAsB;CACvB,CAAA;AAqBQ,oCAAY;AAnBrB,MAAM,wBAAwB,GAAG,CAC/B,CAAiC,EACwB,EAAE;IAC3D,QAAQ,CAAC,CAAC,IAAI,EAAE;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,mBAAmB,CAAC,CAAC;YACxB,OAAO,CAAC,CAAA;SACT;QACD,OAAO,CAAC,CAAC;YACP,OAAM;SACP;KACF;AACH,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG;IACvB,wBAAwB;CACzB,CAAA;AAEsB,4CAAgB","sourcesContent":["import { FormTypes, SubmissionEventTypes } from '@oneblink/types'\n\nconst toOptionsElement = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithOptions | undefined => {\n switch (e.type) {\n case 'select':\n case 'compliance':\n case 'radio':\n case 'autocomplete':\n case 'checkboxes': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toFormElementWithForm = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithForm | undefined => {\n switch (e.type) {\n case 'form':\n case 'infoPage': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toFormElementWithoutForm = (\n e: FormTypes.FormElement,\n): FormTypes.FormElementWithoutForm | undefined => {\n switch (e.type) {\n case 'form':\n case 'infoPage': {\n return\n }\n default: {\n return e\n }\n }\n}\n\nconst toLookupElement = (\n e: FormTypes.FormElement,\n): FormTypes.LookupFormElement | undefined => {\n switch (e.type) {\n case 'boolean':\n case 'checkboxes':\n case 'date':\n case 'datetime':\n case 'files':\n case 'location':\n case 'number':\n case 'compliance':\n case 'radio':\n case 'select':\n case 'text':\n case 'textarea':\n case 'time':\n case 'barcodeScanner':\n case 'email':\n case 'telephone':\n case 'pointAddress':\n case 'geoscapeAddress':\n case 'civicaStreetName':\n case 'bsb':\n case 'autocomplete':\n case 'abn': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toNestedElementsElement = (\n e: FormTypes.FormElement,\n): FormTypes.NestedElementsElement | undefined => {\n switch (e.type) {\n case 'repeatableSet':\n case 'section':\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\ntype NamelessElement = FormTypes.PageElement | FormTypes.SectionElement\nconst toNamelessElement = (\n e: FormTypes.FormElement,\n): NamelessElement | undefined => {\n switch (e.type) {\n case 'section':\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\ntype NonNestedElementsFormElement =\n | FormTypes.NonNestedElementsElement\n | FormTypes.FormElementWithForm\nconst toNonNestedElementsElement = (\n e: FormTypes.FormElement,\n): NonNestedElementsFormElement | undefined => {\n switch (e.type) {\n case 'repeatableSet':\n case 'section':\n case 'page': {\n return\n }\n default: {\n return e\n }\n }\n}\n\nconst toPageElement = (\n e: FormTypes.FormElement,\n): FormTypes.PageElement | undefined => {\n switch (e.type) {\n case 'page': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst toRepeatableSetElement = (\n e: FormTypes.FormElement,\n): FormTypes.RepeatableSetElement | undefined => {\n switch (e.type) {\n case 'repeatableSet': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst formElements = {\n toOptionsElement,\n toFormElementWithForm,\n toFormElementWithoutForm,\n toLookupElement,\n toNestedElementsElement,\n toNamelessElement,\n toNonNestedElementsElement,\n toPageElement,\n toRepeatableSetElement,\n}\n\nconst toPaymentSubmissionEvent = (\n e: SubmissionEventTypes.FormEvent,\n): SubmissionEventTypes.PaymentSubmissionEvent | undefined => {\n switch (e.type) {\n case 'BPOINT':\n case 'CP_PAY':\n case 'WESTPAC_QUICK_WEB': {\n return e\n }\n default: {\n return\n }\n }\n}\n\nconst submissionEvents = {\n toPaymentSubmissionEvent,\n}\n\nexport { formElements, submissionEvents }\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oneblink/sdk-core",
3
3
  "description": "OneBlink SDK for JavaScript (works in Browsers and NodeJS)",
4
- "version": "0.3.1",
4
+ "version": "0.3.2-beta.4",
5
5
  "author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/oneblink/sdk-core-js/issues"