@jini-ai/cms-forms 0.2.1 → 0.2.2

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
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.2 — 2026-10-04
4
+
5
+ - Authored checkbox values (`checkboxValue`).
6
+ - `sweepExpiredSubmissionIps` clears form-submitter IP addresses after 90 days.
7
+
3
8
  ## 0.2.1 — 2026-10-04
4
9
 
5
10
  - `@jini-ai/cms` and `@jini-ai/core` are caret ranges (`^0.4.1`, `^0.4.0`) instead of exact pins, so a host on a newer patch of either resolves a single copy without an override.
package/dist/forms.js CHANGED
@@ -59,6 +59,14 @@ function maxLengthErrors(descriptor, label) {
59
59
  }
60
60
  return [];
61
61
  }
62
+ function checkboxValueErrors(descriptor, label) {
63
+ if (descriptor.checkboxValue === undefined)
64
+ return [];
65
+ if (descriptor.type !== "checkbox" || typeof descriptor.checkboxValue !== "string") {
66
+ return [{ field: label, reason: "checkboxValue must be a string on a checkbox field" }];
67
+ }
68
+ return [];
69
+ }
62
70
  // HTML-escaped class names are inert; only their length is bounded. Check type defensively
63
71
  // because real inputs include parsed request bodies, regardless of the descriptor's static type.
64
72
  function classNameErrors(descriptor, label) {
@@ -120,7 +128,7 @@ export function validateFieldDescriptors({ fields }) {
120
128
  const claimedIds = new Set();
121
129
  for (const descriptor of fields) {
122
130
  const label = descriptor.id || "(unknown)";
123
- fieldErrors.push(...fieldIdErrors(descriptor, label, claimedIds), ...fieldTypeErrors(descriptor, label), ...labelLengthErrors(descriptor, label), ...maxLengthErrors(descriptor, label), ...classNameErrors(descriptor, label), ...attributeErrors(descriptor, label));
131
+ fieldErrors.push(...fieldIdErrors(descriptor, label, claimedIds), ...fieldTypeErrors(descriptor, label), ...labelLengthErrors(descriptor, label), ...maxLengthErrors(descriptor, label), ...checkboxValueErrors(descriptor, label), ...classNameErrors(descriptor, label), ...attributeErrors(descriptor, label));
124
132
  }
125
133
  if (fieldErrors.length > 0)
126
134
  return { valid: false, fieldErrors };
@@ -153,7 +161,9 @@ function resolveTextValue(field, value) {
153
161
  // only JSON booleans would reject every checked checkbox when client JavaScript is disabled.
154
162
  // An unticked native checkbox omits its key; submission resolution treats that as absence.
155
163
  const HTML_CHECKBOX_ON_VALUE = "on";
156
- function resolveCheckboxValue(value) {
164
+ function resolveCheckboxValue(field, value) {
165
+ if (field.checkboxValue !== undefined && typeof value === "string")
166
+ return { kind: "accepted", value };
157
167
  if (typeof value === "boolean")
158
168
  return { kind: "accepted", value };
159
169
  if (value === HTML_CHECKBOX_ON_VALUE)
@@ -167,7 +177,7 @@ function resolveSubmittedValue(field, value) {
167
177
  return field.required ? { kind: "rejected", reason: "required" } : { kind: "absent" };
168
178
  }
169
179
  if (field.type === "checkbox")
170
- return resolveCheckboxValue(value);
180
+ return resolveCheckboxValue(field, value);
171
181
  return resolveTextValue(field, value);
172
182
  }
173
183
  /**
package/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@ export * from "./rate-limit-key.js";
6
6
  export * from "./write-service.js";
7
7
  export * from "./submit-service.js";
8
8
  export * from "./notify-subscriber.js";
9
+ export * from "./submission-ip-retention.js";
9
10
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -6,4 +6,5 @@ export * from "./rate-limit-key.js";
6
6
  export * from "./write-service.js";
7
7
  export * from "./submit-service.js";
8
8
  export * from "./notify-subscriber.js";
9
+ export * from "./submission-ip-retention.js";
9
10
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Submission metadata retention, independent of databases and host scheduling.
3
+ * Answers and submission identity are never deleted by this maintenance operation.
4
+ */
5
+ /**
6
+ * Owner decision 2026-10-04: retain form submitter IPs for 90 days for abuse investigation,
7
+ * then remove them automatically. Matches the privacy wording: "IP addresses on form
8
+ * submissions are deleted after 90 days"; this is not expiry of the submission itself.
9
+ */
10
+ export declare const SUBMISSION_IP_RETENTION_DAYS = 90;
11
+ export interface SubmissionIpRetentionPort {
12
+ /**
13
+ * Clear only sourceIp to NULL for at most limit rows submitted at/before the ISO UTC cutoff.
14
+ * Include all workspaces and Trash rows. Perform one atomic guarded update; return actual
15
+ * affected rows, excluding already-NULL values. Concurrent passes must be idempotent.
16
+ */
17
+ clearExpiredIps(required: {
18
+ submittedBeforeOrAt: string;
19
+ }, optional?: {
20
+ limit?: number;
21
+ }): Promise<number>;
22
+ }
23
+ /** A complete pass, using bounded updates and one fixed cutoff even across multiple batches. */
24
+ export declare function sweepExpiredSubmissionIps({ now, repo }: {
25
+ now: number;
26
+ repo: SubmissionIpRetentionPort;
27
+ }, { batchSize }?: {
28
+ batchSize?: number;
29
+ }): Promise<number>;
30
+ //# sourceMappingURL=submission-ip-retention.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Submission metadata retention, independent of databases and host scheduling.
3
+ * Answers and submission identity are never deleted by this maintenance operation.
4
+ */
5
+ /**
6
+ * Owner decision 2026-10-04: retain form submitter IPs for 90 days for abuse investigation,
7
+ * then remove them automatically. Matches the privacy wording: "IP addresses on form
8
+ * submissions are deleted after 90 days"; this is not expiry of the submission itself.
9
+ */
10
+ export const SUBMISSION_IP_RETENTION_DAYS = 90;
11
+ /** A complete pass, using bounded updates and one fixed cutoff even across multiple batches. */
12
+ export async function sweepExpiredSubmissionIps({ now, repo }, { batchSize = 500 } = {}) {
13
+ const cutoff = now - SUBMISSION_IP_RETENTION_DAYS * 24 * 60 * 60 * 1000;
14
+ if (!Number.isFinite(now) || !Number.isFinite(new Date(cutoff).getTime()))
15
+ throw new RangeError("submission IP sweep needs a valid timestamp");
16
+ if (!Number.isSafeInteger(batchSize) || batchSize <= 0)
17
+ throw new RangeError("submission IP sweep batchSize must be a positive integer");
18
+ const submittedBeforeOrAt = new Date(cutoff).toISOString();
19
+ let total = 0;
20
+ let cleared;
21
+ do {
22
+ cleared = await repo.clearExpiredIps({ submittedBeforeOrAt }, { limit: batchSize });
23
+ total += cleared;
24
+ } while (cleared === batchSize);
25
+ return total;
26
+ }
27
+ //# sourceMappingURL=submission-ip-retention.js.map
package/dist/types.d.ts CHANGED
@@ -7,6 +7,8 @@ export interface FieldDescriptor {
7
7
  type: FieldType;
8
8
  required: boolean;
9
9
  maxLength?: number | null;
10
+ /** Presence distinguishes an authored checkbox value (even "") from the native boolean default. */
11
+ checkboxValue?: string;
10
12
  /** Length-bounded and HTML-escaped at rendering; class names are inert after escaping. */
11
13
  className?: string;
12
14
  /** Attribute names require a closed allowlist: escaping a name cannot make it safe.
@@ -36,7 +38,8 @@ export interface FormSubmissionRecord {
36
38
  workspaceId: UUID;
37
39
  formDefinitionId: UUID;
38
40
  data: Record<string, string | boolean>;
39
- sourceIp: string;
41
+ /** Cleared by metadata retention; answers and the submission itself remain. */
42
+ sourceIp: string | null;
40
43
  submittedAt: string;
41
44
  }
42
45
  export interface FormSubmissionPage {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/cms-forms",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Framework-free configurable form validation, audited definitions, anonymous submissions and notification services with injected host ports.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -37,8 +37,8 @@
37
37
  "!dist/**/*.map"
38
38
  ],
39
39
  "dependencies": {
40
- "@jini-ai/core": "^0.4.0",
41
- "@jini-ai/cms": "^0.4.1"
40
+ "@jini-ai/cms": "^0.4.2",
41
+ "@jini-ai/core": "^0.4.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "vitest": "^2.1.0",