@form-engine-ts/storage-localstorage 1.0.0 → 2.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/README.md CHANGED
@@ -17,7 +17,10 @@ const storage = createLocalStorageAdapter("my-app:");
17
17
  await storage.saveSchema(schema);
18
18
  await storage.saveSubmission(submission);
19
19
 
20
- const responses = await storage.listSubmissions(schema.id, schema.version);
20
+ const responses = await storage.listSubmissions(schema.id, schema.version, {
21
+ since: "2026-01-01T00:00:00.000Z",
22
+ until: "2026-01-31T23:59:59.999Z"
23
+ });
21
24
  ```
22
25
 
23
- Outside a browser, pass a compatible `StorageLike` object as the second argument.
26
+ Date boundaries are inclusive, and results are ordered by submission time and then ID. Outside a browser, pass a compatible `StorageLike` object as the second argument.
package/dist/index.cjs CHANGED
@@ -98,14 +98,14 @@ function createLocalStorageAdapter(storagePrefix = "pf_", injectedStorage) {
98
98
  if (storage.getItem(key) !== null) throw new Error(`A submission with ID "${submission.id}" already exists.`);
99
99
  storage.setItem(key, JSON.stringify(submission));
100
100
  },
101
- async listSubmissions(formId, formVersion) {
101
+ async listSubmissions(formId, formVersion, options) {
102
102
  return prefixedKeys(submissionPrefix).map((key) => {
103
103
  const value = storage.getItem(key);
104
104
  if (value === null) throw new Error(`Stored submission at "${key}" disappeared during reading.`);
105
105
  return parseSubmission(value, key);
106
106
  }).filter(
107
- (submission) => submission.formId === formId && (formVersion === void 0 || submission.formVersion === formVersion)
108
- ).sort((left, right) => left.submittedAt.localeCompare(right.submittedAt)).map(cloneJson);
107
+ (submission) => submission.formId === formId && (formVersion === void 0 || submission.formVersion === formVersion) && (options?.since === void 0 || submission.submittedAt >= options.since) && (options?.until === void 0 || submission.submittedAt <= options.until)
108
+ ).sort((left, right) => left.submittedAt.localeCompare(right.submittedAt) || left.id.localeCompare(right.id)).map(cloneJson);
109
109
  },
110
110
  async deleteSubmission(submissionId) {
111
111
  storage.removeItem(submissionKey(submissionId));
package/dist/index.js CHANGED
@@ -74,14 +74,14 @@ function createLocalStorageAdapter(storagePrefix = "pf_", injectedStorage) {
74
74
  if (storage.getItem(key) !== null) throw new Error(`A submission with ID "${submission.id}" already exists.`);
75
75
  storage.setItem(key, JSON.stringify(submission));
76
76
  },
77
- async listSubmissions(formId, formVersion) {
77
+ async listSubmissions(formId, formVersion, options) {
78
78
  return prefixedKeys(submissionPrefix).map((key) => {
79
79
  const value = storage.getItem(key);
80
80
  if (value === null) throw new Error(`Stored submission at "${key}" disappeared during reading.`);
81
81
  return parseSubmission(value, key);
82
82
  }).filter(
83
- (submission) => submission.formId === formId && (formVersion === void 0 || submission.formVersion === formVersion)
84
- ).sort((left, right) => left.submittedAt.localeCompare(right.submittedAt)).map(cloneJson);
83
+ (submission) => submission.formId === formId && (formVersion === void 0 || submission.formVersion === formVersion) && (options?.since === void 0 || submission.submittedAt >= options.since) && (options?.until === void 0 || submission.submittedAt <= options.until)
84
+ ).sort((left, right) => left.submittedAt.localeCompare(right.submittedAt) || left.id.localeCompare(right.id)).map(cloneJson);
85
85
  },
86
86
  async deleteSubmission(submissionId) {
87
87
  storage.removeItem(submissionKey(submissionId));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@form-engine-ts/storage-localstorage",
3
- "version": "1.0.0",
3
+ "version": "2.0.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": "1.0.0"
42
+ "@form-engine-ts/core": "2.0.0"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsup src/index.ts --format esm,cjs --dts --clean --external @form-engine-ts/core",