@form-engine-ts/storage-localstorage 7.18.1 → 8.0.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 CHANGED
@@ -132,6 +132,14 @@ function createLocalStorageAdapter(storagePrefix = "pf_", injectedStorage, optio
132
132
  (submission) => submission.formId === formId && (formVersion === void 0 || submission.formVersion === formVersion) && (options2?.since === void 0 || submission.submittedAt >= options2.since) && (options2?.until === void 0 || submission.submittedAt <= options2.until)
133
133
  ).sort((left, right) => left.submittedAt.localeCompare(right.submittedAt) || left.id.localeCompare(right.id)).map(cloneJson);
134
134
  },
135
+ async countSubmissions(formId, formVersion, options2) {
136
+ return prefixedKeys(submissionPrefix).reduce((count, key) => {
137
+ const value = storage.getItem(key);
138
+ if (value === null) throw new Error(`Stored submission at "${key}" disappeared during reading.`);
139
+ const submission = parseSubmission(value, key);
140
+ return count + (submission.formId === formId && (formVersion === void 0 || submission.formVersion === formVersion) && (options2?.since === void 0 || submission.submittedAt >= options2.since) && (options2?.until === void 0 || submission.submittedAt <= options2.until) ? 1 : 0);
141
+ }, 0);
142
+ },
135
143
  async deleteSubmission(submissionId) {
136
144
  storage.removeItem(submissionKey(submissionId));
137
145
  },
package/dist/index.js CHANGED
@@ -111,6 +111,14 @@ function createLocalStorageAdapter(storagePrefix = "pf_", injectedStorage, optio
111
111
  (submission) => submission.formId === formId && (formVersion === void 0 || submission.formVersion === formVersion) && (options2?.since === void 0 || submission.submittedAt >= options2.since) && (options2?.until === void 0 || submission.submittedAt <= options2.until)
112
112
  ).sort((left, right) => left.submittedAt.localeCompare(right.submittedAt) || left.id.localeCompare(right.id)).map(cloneJson);
113
113
  },
114
+ async countSubmissions(formId, formVersion, options2) {
115
+ return prefixedKeys(submissionPrefix).reduce((count, key) => {
116
+ const value = storage.getItem(key);
117
+ if (value === null) throw new Error(`Stored submission at "${key}" disappeared during reading.`);
118
+ const submission = parseSubmission(value, key);
119
+ return count + (submission.formId === formId && (formVersion === void 0 || submission.formVersion === formVersion) && (options2?.since === void 0 || submission.submittedAt >= options2.since) && (options2?.until === void 0 || submission.submittedAt <= options2.until) ? 1 : 0);
120
+ }, 0);
121
+ },
114
122
  async deleteSubmission(submissionId) {
115
123
  storage.removeItem(submissionKey(submissionId));
116
124
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@form-engine-ts/storage-localstorage",
3
- "version": "7.18.1",
3
+ "version": "8.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,10 +39,10 @@
39
39
  "typescript"
40
40
  ],
41
41
  "dependencies": {
42
- "@form-engine-ts/core": "7.18.1"
42
+ "@form-engine-ts/core": "8.0.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@form-engine-ts/storage": "7.18.1"
45
+ "@form-engine-ts/storage": "8.0.0"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsup src/index.ts --format esm,cjs --dts --clean --external @form-engine-ts/core",