@form-engine-ts/storage-sqlite 7.18.0 → 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
@@ -237,6 +237,28 @@ function createSqliteStorage(options) {
237
237
  );
238
238
  return rows.map(parseSubmissionRow);
239
239
  },
240
+ async countSubmissions(formId, formVersion, queryOptions) {
241
+ await ensureReady();
242
+ const conditions = ["form_id = ?"];
243
+ const params = [formId];
244
+ if (formVersion !== void 0) {
245
+ conditions.push("form_version = ?");
246
+ params.push(formVersion);
247
+ }
248
+ if (queryOptions?.since !== void 0) {
249
+ conditions.push("submitted_at >= ?");
250
+ params.push(queryOptions.since);
251
+ }
252
+ if (queryOptions?.until !== void 0) {
253
+ conditions.push("submitted_at <= ?");
254
+ params.push(queryOptions.until);
255
+ }
256
+ const row = await options.db.get(
257
+ `SELECT COUNT(*) AS count FROM ${responsesTable} WHERE ${conditions.join(" AND ")}`,
258
+ params
259
+ );
260
+ return Number(row?.count ?? 0);
261
+ },
240
262
  async deleteSubmission(submissionId) {
241
263
  await ensureReady();
242
264
  await options.db.run(`DELETE FROM ${responsesTable} WHERE response_id = ?`, [submissionId]);
package/dist/index.js CHANGED
@@ -216,6 +216,28 @@ function createSqliteStorage(options) {
216
216
  );
217
217
  return rows.map(parseSubmissionRow);
218
218
  },
219
+ async countSubmissions(formId, formVersion, queryOptions) {
220
+ await ensureReady();
221
+ const conditions = ["form_id = ?"];
222
+ const params = [formId];
223
+ if (formVersion !== void 0) {
224
+ conditions.push("form_version = ?");
225
+ params.push(formVersion);
226
+ }
227
+ if (queryOptions?.since !== void 0) {
228
+ conditions.push("submitted_at >= ?");
229
+ params.push(queryOptions.since);
230
+ }
231
+ if (queryOptions?.until !== void 0) {
232
+ conditions.push("submitted_at <= ?");
233
+ params.push(queryOptions.until);
234
+ }
235
+ const row = await options.db.get(
236
+ `SELECT COUNT(*) AS count FROM ${responsesTable} WHERE ${conditions.join(" AND ")}`,
237
+ params
238
+ );
239
+ return Number(row?.count ?? 0);
240
+ },
219
241
  async deleteSubmission(submissionId) {
220
242
  await ensureReady();
221
243
  await options.db.run(`DELETE FROM ${responsesTable} WHERE response_id = ?`, [submissionId]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@form-engine-ts/storage-sqlite",
3
- "version": "7.18.0",
3
+ "version": "8.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -40,10 +40,10 @@
40
40
  "typescript"
41
41
  ],
42
42
  "dependencies": {
43
- "@form-engine-ts/core": "7.18.0"
43
+ "@form-engine-ts/core": "8.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@form-engine-ts/storage": "7.18.0"
46
+ "@form-engine-ts/storage": "8.0.0"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "tsup src/index.ts --format esm,cjs --dts --clean --external @form-engine-ts/core",