@form-engine-ts/storage-azure-table 8.0.2 → 8.1.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/dist/index.cjs +3 -6
- package/dist/index.js +3 -4
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -116,7 +116,7 @@ function textAnswerQuery(fieldIdOrOptions, options) {
|
|
|
116
116
|
function submissionTextAnswers(submission, fieldIds) {
|
|
117
117
|
const entries = fieldIds === void 0 ? Object.entries(submission.values) : fieldIds.map((id) => [id, submission.values[id]]);
|
|
118
118
|
return entries.flatMap(
|
|
119
|
-
([fieldId, value]) => typeof value === "string" && value.length > 0 ? [{ fieldId, text: value }] : []
|
|
119
|
+
([fieldId, value]) => typeof value === "string" && value.length > 0 ? [{ fieldId, text: value }] : (0, import_core.isRadioTextAnswer)(value) && value.text.length > 0 ? [{ fieldId, text: value.text }] : []
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
function cloneJson(value) {
|
|
@@ -125,9 +125,6 @@ function cloneJson(value) {
|
|
|
125
125
|
function isRecord(value) {
|
|
126
126
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
127
127
|
}
|
|
128
|
-
function isFormValue(value) {
|
|
129
|
-
return value === void 0 || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
130
|
-
}
|
|
131
128
|
function parseJson(value, location) {
|
|
132
129
|
if (typeof value !== "string") throw new Error(`Azure Table ${location} payload is invalid.`);
|
|
133
130
|
try {
|
|
@@ -138,7 +135,7 @@ function parseJson(value, location) {
|
|
|
138
135
|
}
|
|
139
136
|
function parseSubmission(value, location) {
|
|
140
137
|
const parsed = typeof value === "string" ? parseJson(value, location) : value;
|
|
141
|
-
if (!isRecord(parsed) || typeof parsed.id !== "string" || typeof parsed.formId !== "string" || !Number.isInteger(parsed.formVersion) || typeof parsed.locale !== "string" || typeof parsed.submittedAt !== "string" || !isRecord(parsed.values) || !Object.values(parsed.values).every(isFormValue)) {
|
|
138
|
+
if (!isRecord(parsed) || typeof parsed.id !== "string" || typeof parsed.formId !== "string" || !Number.isInteger(parsed.formVersion) || typeof parsed.locale !== "string" || typeof parsed.submittedAt !== "string" || !isRecord(parsed.values) || !Object.values(parsed.values).every(import_core.isFormValue)) {
|
|
142
139
|
throw new Error(`Azure Table ${location} submission is invalid.`);
|
|
143
140
|
}
|
|
144
141
|
return cloneJson(parsed);
|
|
@@ -180,7 +177,7 @@ function mappedSubmissionFromEntity(entity, mapping, valueCodec) {
|
|
|
180
177
|
if (typeof id !== "string" || typeof formId !== "string" || typeof formVersion !== "number" || typeof submittedAt !== "string" || typeof rawValues !== "string")
|
|
181
178
|
return void 0;
|
|
182
179
|
const values = valueCodec?.decodeValues?.(rawValues) ?? parseJson(rawValues, "submission values");
|
|
183
|
-
if (!isRecord(values) || !Object.values(values).every(isFormValue))
|
|
180
|
+
if (!isRecord(values) || !Object.values(values).every(import_core.isFormValue))
|
|
184
181
|
throw new Error("Azure Table values are invalid.");
|
|
185
182
|
const rawMetadata = entity[propertyName(mapping, "metadata", "metadata")];
|
|
186
183
|
const metadata = rawMetadata === void 0 ? void 0 : parseJson(rawMetadata, "submission metadata");
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
createFormLifecycleAdapter,
|
|
8
8
|
exportResponsesToCsv,
|
|
9
9
|
hashFormSubmissionPayload,
|
|
10
|
+
isFormValue,
|
|
11
|
+
isRadioTextAnswer,
|
|
10
12
|
matchesSubmissionPageFilters,
|
|
11
13
|
normalizeSubmissionPageSize
|
|
12
14
|
} from "@form-engine-ts/core";
|
|
@@ -98,7 +100,7 @@ function textAnswerQuery(fieldIdOrOptions, options) {
|
|
|
98
100
|
function submissionTextAnswers(submission, fieldIds) {
|
|
99
101
|
const entries = fieldIds === void 0 ? Object.entries(submission.values) : fieldIds.map((id) => [id, submission.values[id]]);
|
|
100
102
|
return entries.flatMap(
|
|
101
|
-
([fieldId, value]) => typeof value === "string" && value.length > 0 ? [{ fieldId, text: value }] : []
|
|
103
|
+
([fieldId, value]) => typeof value === "string" && value.length > 0 ? [{ fieldId, text: value }] : isRadioTextAnswer(value) && value.text.length > 0 ? [{ fieldId, text: value.text }] : []
|
|
102
104
|
);
|
|
103
105
|
}
|
|
104
106
|
function cloneJson(value) {
|
|
@@ -107,9 +109,6 @@ function cloneJson(value) {
|
|
|
107
109
|
function isRecord(value) {
|
|
108
110
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
109
111
|
}
|
|
110
|
-
function isFormValue(value) {
|
|
111
|
-
return value === void 0 || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
112
|
-
}
|
|
113
112
|
function parseJson(value, location) {
|
|
114
113
|
if (typeof value !== "string") throw new Error(`Azure Table ${location} payload is invalid.`);
|
|
115
114
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@form-engine-ts/storage-azure-table",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"typescript"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@form-engine-ts/core": "8.0
|
|
42
|
+
"@form-engine-ts/core": "8.1.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@azure/data-tables": "^13.3.2"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@azure/data-tables": "^13.3.2",
|
|
54
|
-
"@form-engine-ts/storage": "8.0
|
|
54
|
+
"@form-engine-ts/storage": "8.1.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --external @form-engine-ts/core",
|