@dereekb/nestjs 12.3.9 → 12.3.10

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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [12.3.10](https://github.com/dereekb/dbx-components/compare/v12.3.9-dev...v12.3.10) (2025-08-15)
6
+
7
+
8
+
5
9
  ## [12.3.9](https://github.com/dereekb/dbx-components/compare/v12.3.8-dev...v12.3.9) (2025-08-15)
6
10
 
7
11
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/mailgun",
3
- "version": "12.3.9",
3
+ "version": "12.3.10",
4
4
  "type": "commonjs",
5
5
  "types": "./src/index.d.ts",
6
6
  "main": "./src/index.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/openai",
3
- "version": "12.3.9",
3
+ "version": "12.3.10",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {},
6
6
  "dependencies": {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs",
3
- "version": "12.3.9",
3
+ "version": "12.3.10",
4
4
  "type": "commonjs",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/stripe",
3
- "version": "12.3.9",
3
+ "version": "12.3.10",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {},
6
6
  "dependencies": {},
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/nestjs/typeform",
3
- "version": "12.3.9",
3
+ "version": "12.3.10",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {},
6
6
  "dependencies": {},
@@ -4,3 +4,4 @@ export * from './typeform.api';
4
4
  export * from './typeform.module';
5
5
  export * from './typeform.config';
6
6
  export * from './typeform.type';
7
+ export * from './typeform.util';
@@ -7,4 +7,5 @@ tslib_1.__exportStar(require("./typeform.api"), exports);
7
7
  tslib_1.__exportStar(require("./typeform.module"), exports);
8
8
  tslib_1.__exportStar(require("./typeform.config"), exports);
9
9
  tslib_1.__exportStar(require("./typeform.type"), exports);
10
+ tslib_1.__exportStar(require("./typeform.util"), exports);
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/typeform/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,4DAAkC;AAClC,yDAA+B;AAC/B,4DAAkC;AAClC,4DAAkC;AAClC,0DAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/typeform/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,4DAAkC;AAClC,yDAA+B;AAC/B,4DAAkC;AAClC,4DAAkC;AAClC,0DAAgC;AAChC,0DAAgC"}
@@ -46,6 +46,8 @@ export interface TypeformFormHiddenMetadata extends Partial<Record<string, any>>
46
46
  readonly utm_medium?: string;
47
47
  readonly utm_source?: string;
48
48
  }
49
+ export type TypeformFormResponseDefinitionFieldId = string;
50
+ export type TypeformFormResponseDefinitionField = MaybeSo<TypeformFormResponseDefinition['fields']>[0];
49
51
  export interface TypeformFormResponseDefinition extends MaybeSo<TypeformResponse['definition']> {
50
52
  readonly id: TypeformFormId;
51
53
  readonly title: TypeformFormName;
@@ -0,0 +1,20 @@
1
+ export type TypeformTemplateRefType = 'field';
2
+ export interface TypeformTemplateRef {
3
+ /**
4
+ * The type of ref
5
+ */
6
+ readonly type: TypeformTemplateRefType;
7
+ /**
8
+ * The full match
9
+ *
10
+ * I.E. {{field:123456789}}
11
+ */
12
+ readonly match: string;
13
+ /**
14
+ * The field ref value
15
+ *
16
+ * I.E. 123456789
17
+ */
18
+ readonly ref: string;
19
+ }
20
+ export declare function findTypeformTemplateRefsInString(input: string): TypeformTemplateRef[];
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findTypeformTemplateRefsInString = findTypeformTemplateRefsInString;
4
+ function findTypeformTemplateRefsInString(input) {
5
+ /**
6
+ * Used to search the input string to find field refs like the following:
7
+ *
8
+ * {{field:8f7adc1e-c3b8-44bd-b00c-1b6c8de65797}}
9
+ * {{field:01H7G3DCZ1FZV4KYZGM755MXZZ}}
10
+ */
11
+ const regex = /\{\{\s*(field)\s*:\s*([A-Za-z0-9-]+)\s*\}\}/g;
12
+ const matches = input.matchAll(regex);
13
+ const result = [];
14
+ for (const regexMatch of matches) {
15
+ const match = regexMatch[0]; // {{field:8f7adc1e-c3b8-44bd-b00c-1b6c8de65797}}
16
+ const type = regexMatch[1]; // field
17
+ const ref = regexMatch[2]; // 8f7adc1e-c3b8-44bd-b00c-1b6c8de65797
18
+ result.push({
19
+ type,
20
+ match,
21
+ ref
22
+ });
23
+ }
24
+ return result;
25
+ }
26
+ //# sourceMappingURL=typeform.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeform.util.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/typeform/src/lib/typeform.util.ts"],"names":[],"mappings":";;AAqBA,4EAwBC;AAxBD,SAAgB,gCAAgC,CAAC,KAAa;IAC5D;;;;;OAKG;IACH,MAAM,KAAK,GAAG,8CAA8C,CAAC;IAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,MAAM,GAA0B,EAAE,CAAC;IAEzC,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,iDAAiD;QAC9E,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAA4B,CAAC,CAAC,QAAQ;QAC/D,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,uCAAuC;QAElE,MAAM,CAAC,IAAI,CAAC;YACV,IAAI;YACJ,KAAK;YACL,GAAG;SACJ,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -3,5 +3,6 @@ export * from './webhook.typeform.type';
3
3
  export * from './webhook.typeform.config';
4
4
  export * from './webhook.typeform.controller';
5
5
  export * from './webhook.typeform.module';
6
+ export * from './webhook.typeform.form';
6
7
  export * from './webhook.typeform.service';
7
8
  export * from './webhook.typeform.verify';
@@ -6,6 +6,7 @@ tslib_1.__exportStar(require("./webhook.typeform.type"), exports);
6
6
  tslib_1.__exportStar(require("./webhook.typeform.config"), exports);
7
7
  tslib_1.__exportStar(require("./webhook.typeform.controller"), exports);
8
8
  tslib_1.__exportStar(require("./webhook.typeform.module"), exports);
9
+ tslib_1.__exportStar(require("./webhook.typeform.form"), exports);
9
10
  tslib_1.__exportStar(require("./webhook.typeform.service"), exports);
10
11
  tslib_1.__exportStar(require("./webhook.typeform.verify"), exports);
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/nestjs/typeform/src/lib/webhook/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,kEAAwC;AACxC,oEAA0C;AAC1C,wEAA8C;AAC9C,oEAA0C;AAC1C,qEAA2C;AAC3C,oEAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/nestjs/typeform/src/lib/webhook/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,kEAAwC;AACxC,oEAA0C;AAC1C,wEAA8C;AAC9C,oEAA0C;AAC1C,kEAAwC;AACxC,qEAA2C;AAC3C,oEAA0C"}
@@ -0,0 +1,48 @@
1
+ import { Maybe } from '@dereekb/util';
2
+ import { TypeformFormResponseAnswer, TypeformFormResponseDefinitionField } from '../typeform.type';
3
+ import { TypeformWebhookFormResponse } from './webhook.typeform.type';
4
+ export interface TypeformFormResponseAnswerValuePair<T = unknown> {
5
+ /**
6
+ * The answer as retrieved from the form response.
7
+ */
8
+ readonly answer: TypeformFormResponseAnswer;
9
+ /**
10
+ * Answer value as was retrieved
11
+ */
12
+ readonly value: T;
13
+ /**
14
+ * Answer value as a string
15
+ */
16
+ readonly valueString: string;
17
+ }
18
+ export interface TypeformFormQuestionAnswerPair<T = unknown> extends TypeformFormResponseAnswerValuePair<T> {
19
+ /**
20
+ * The expanded question title, which replaces all field references with the field's value.
21
+ *
22
+ * Provided only if the definition field exists.
23
+ */
24
+ readonly questionTitle?: Maybe<string>;
25
+ /**
26
+ * True if the original title had a field reference.
27
+ */
28
+ readonly hadReferenceInTitle: boolean;
29
+ /**
30
+ * Definition field, if it exists.
31
+ */
32
+ readonly definitionField?: TypeformFormResponseDefinitionField;
33
+ }
34
+ /**
35
+ * An expanded TypeformWebhookFormResponse, containing the original form response and a list of TypeformFormQuestionAnswerPair.
36
+ */
37
+ export interface ExpandedTypeformWebhookFormResponse {
38
+ readonly formResponse: TypeformWebhookFormResponse;
39
+ readonly pairs: TypeformFormQuestionAnswerPair[];
40
+ }
41
+ /**
42
+ * Creates an ExpandedTypeformWebhookFormResponse from a TypeformWebhookFormResponse.
43
+ */
44
+ export declare function expandTypeformWebhookFormResponse(formResponse: TypeformWebhookFormResponse): ExpandedTypeformWebhookFormResponse;
45
+ /**
46
+ * Creates a TypeformFormQuestionAnswerPair from a TypeformFormResponseAnswer.
47
+ */
48
+ export declare function makeTypeformFormResponseAnswerValuePair(answer: TypeformFormResponseAnswer): TypeformFormResponseAnswerValuePair;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expandTypeformWebhookFormResponse = expandTypeformWebhookFormResponse;
4
+ exports.makeTypeformFormResponseAnswerValuePair = makeTypeformFormResponseAnswerValuePair;
5
+ const util_1 = require("@dereekb/util");
6
+ const typeform_util_1 = require("../typeform.util");
7
+ /**
8
+ * Creates an ExpandedTypeformWebhookFormResponse from a TypeformWebhookFormResponse.
9
+ */
10
+ function expandTypeformWebhookFormResponse(formResponse) {
11
+ const { answers, definition } = formResponse;
12
+ const { fields = [] } = definition;
13
+ const questionFieldMap = new Map((0, util_1.filterMaybeArrayValues)(fields.map((x) => (x.id ? [x.id, x] : null))));
14
+ const answerValuePairs = answers.map((answer) => makeTypeformFormResponseAnswerValuePair(answer));
15
+ const answerValueFieldRefMap = new Map((0, util_1.filterMaybeArrayValues)(answerValuePairs.map((x) => (x.answer.field.ref ? [x.answer.field.ref, x] : null))));
16
+ function expandQuestionTitle(title) {
17
+ let result = title;
18
+ let hadReferenceInTitle = false;
19
+ if (result) {
20
+ const refsInTitle = (0, typeform_util_1.findTypeformTemplateRefsInString)(result);
21
+ if (refsInTitle.length > 0) {
22
+ hadReferenceInTitle = true;
23
+ refsInTitle.forEach((refInTitle) => {
24
+ const { match, ref } = refInTitle;
25
+ const fullMatch = match;
26
+ const answer = answerValueFieldRefMap.get(ref);
27
+ const answerValue = answer?.valueString;
28
+ const replacedTitle = result.replaceAll(fullMatch, answerValue || '');
29
+ result = replacedTitle;
30
+ });
31
+ }
32
+ }
33
+ return {
34
+ questionTitle: result,
35
+ hadReferenceInTitle
36
+ };
37
+ }
38
+ const pairs = answerValuePairs.map((answerValue) => {
39
+ const definitionField = questionFieldMap.get(answerValue.answer.field.id);
40
+ const { questionTitle, hadReferenceInTitle } = expandQuestionTitle(definitionField?.title);
41
+ const result = {
42
+ ...answerValue,
43
+ definitionField,
44
+ questionTitle,
45
+ hadReferenceInTitle
46
+ };
47
+ return result;
48
+ });
49
+ return {
50
+ formResponse,
51
+ pairs
52
+ };
53
+ }
54
+ /**
55
+ * Creates a TypeformFormQuestionAnswerPair from a TypeformFormResponseAnswer.
56
+ */
57
+ function makeTypeformFormResponseAnswerValuePair(answer) {
58
+ let value;
59
+ let valueString;
60
+ switch (answer.type) {
61
+ case 'number':
62
+ value = answer.number;
63
+ valueString = answer.number.toString();
64
+ break;
65
+ case 'boolean':
66
+ value = answer.boolean;
67
+ valueString = answer.boolean.toString();
68
+ break;
69
+ case 'email':
70
+ value = answer.email;
71
+ valueString = answer.email;
72
+ break;
73
+ case 'phone_number':
74
+ value = answer.phone_number;
75
+ valueString = answer.phone_number;
76
+ break;
77
+ case 'date':
78
+ value = answer.date;
79
+ valueString = answer.date;
80
+ break;
81
+ case 'payment':
82
+ value = answer.payment;
83
+ valueString = answer.payment.amount.toString();
84
+ break;
85
+ case 'text':
86
+ value = answer.text;
87
+ valueString = answer.text;
88
+ break;
89
+ case 'choices':
90
+ value = answer.choices;
91
+ valueString = answer.choices.other || (0, util_1.joinStringsWithCommas)(answer.choices.labels);
92
+ break;
93
+ case 'choice':
94
+ value = answer.choice;
95
+ valueString = answer.choice.other || answer.choice.label || '';
96
+ break;
97
+ case 'url':
98
+ value = answer.url;
99
+ valueString = answer.url;
100
+ break;
101
+ case 'file_url':
102
+ value = answer.file_url;
103
+ valueString = answer.file_url;
104
+ break;
105
+ }
106
+ const result = {
107
+ answer,
108
+ value,
109
+ valueString
110
+ };
111
+ return result;
112
+ }
113
+ //# sourceMappingURL=webhook.typeform.form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.typeform.form.js","sourceRoot":"","sources":["../../../../../../../packages/nestjs/typeform/src/lib/webhook/webhook.typeform.form.ts"],"names":[],"mappings":";;AAgDA,8EAuDC;AAKD,0FA0DC;AAtKD,wCAAqF;AAGrF,oDAAoE;AA0CpE;;GAEG;AACH,SAAgB,iCAAiC,CAAC,YAAyC;IACzF,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,YAAY,CAAC;IAC7C,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,UAAU,CAAC;IAEnC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAA6E,IAAA,6BAAsB,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,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