@jini-ai/cms-forms 0.2.2 → 0.6.12

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,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @jini-ai/cms@0.6.12
9
+ - @jini-ai/core@0.6.12
10
+
11
+ ## 0.6.11
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [8fe4cb0]
16
+ - Updated dependencies
17
+ - Updated dependencies
18
+ - @jini-ai/cms@0.6.11
19
+ - @jini-ai/core@0.6.11
20
+
21
+ ## 0.6.10
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [0ca4d2a]
26
+ - Updated dependencies [b2f0fa8]
27
+ - Updated dependencies [22f0619]
28
+ - Updated dependencies [82ed2d3]
29
+ - Updated dependencies [ea8d883]
30
+ - Updated dependencies [9098d22]
31
+ - Updated dependencies [5a3de86]
32
+ - @jini-ai/cms@0.6.10
33
+ - @jini-ai/core@0.6.10
34
+
35
+ ## 0.2.3 — 2026-10-05
36
+
37
+ - `submitForm` takes an optional `transaction` port (`SubmissionTransactionPort`): the submission row and its `form.submission.received` event are written inside it, so a failed enqueue rolls the row back instead of leaving a stored submission that never notifies. Dispatch starts only after it commits. Without the port the two writes run back to back, as before.
38
+ - Requires `@jini-ai/cms` ^0.5.0 and `@jini-ai/core` ^0.4.1 (the versions released alongside it).
39
+
3
40
  ## 0.2.2 — 2026-10-04
4
41
 
5
42
  - Authored checkbox values (`checkboxValue`).
@@ -18,6 +55,8 @@
18
55
 
19
56
  ## Unreleased
20
57
 
58
+ - Deprecated in favour of `@jini-ai/cms/forms`; retain the current version and workspace links until the consumer forms switch.
59
+
21
60
  ### Compilation
22
61
 
23
62
  - Align the in-memory event-bus fixture and subscriber test calls with the current CMS argument objects.
@@ -29,7 +68,6 @@
29
68
  - Use core runtime/JSON/ID/time types and `Pick<Logger, 'warn'>`; structured warning error data is passed in argument two.
30
69
  - Pass notification subscriptions as `{ eventName, handler }` and change-set insertion as `{ record, items }, { event }`.
31
70
 
32
-
33
71
  - Restore independent empty `fieldErrors` defaults for message-only field and
34
72
  submission validation errors.
35
73
  - Validate name updates against the host's reserved-slug policy using the stored,
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
- # @jini-ai/cms-forms
1
+ Deprecated: use `@jini-ai/cms/forms` (same API; adapters at `/html`, `/sql`, `/express`).
2
2
 
3
- Configurable forms in the CMS family, kept as a private workspace package at `packages/cms/forms`. Do not publish this package to npm. The root export includes field and submission validation, honeypot handling, domain errors and records, audited definition writes, anonymous submissions, rate-limit key construction, and notification subscribers. Version 0.1.0 uses Apache-2.0 licensing.
3
+ Deprecated package: use `@jini-ai/cms/forms` for new consumers. This package is marked for npm deprecation in the owner's publish. Keep `packages/cms/forms` until the consumer forms switch is complete: existing workspace links still resolve to this folder. No npm deprecation has been issued by this metadata change.
4
4
 
5
- Runtime code has no framework, Node, database, mail-provider, or CMS implementation imports. CMS contracts are type-only dependencies from `@jini-ai/cms/core`. There is no `@jini-ai/cms/forms` compatibility alias.
5
+ Configurable forms in the CMS family. The root export includes field and submission validation, honeypot handling, domain errors and records, audited definition writes, anonymous submissions, rate-limit key construction, and notification subscribers. The package uses Apache-2.0 licensing.
6
+
7
+ Runtime code has no framework, Node, database, mail-provider, or CMS implementation imports. CMS contracts are type-only dependencies from `@jini-ai/cms/core`. The successor lives in the CMS package at `@jini-ai/cms/forms`, with separate `/html`, `/sql` and `/express` adapters.
6
8
 
7
9
  Every public function accepts a required object and, where applicable, a second optional object. Consumers bind repositories, clock, IDs, authorization, reserved slugs, permission names, rate limits, outbox, background dispatcher, logger, mailer, sender and audited command execution.
8
10
 
package/dist/ports.d.ts CHANGED
@@ -65,6 +65,12 @@ export interface RateLimiterPort {
65
65
  export interface FormOutboxPort {
66
66
  enqueue(event: import("@jini-ai/cms/core").DomainEvent): Promise<void>;
67
67
  }
68
+ /**
69
+ * Runs `work` as one unit of persistence: commit when it resolves, roll back when it throws. A host
70
+ * binds its database transaction here so an accepted submission's row and its outbox event are
71
+ * written together; a submission stored without its event would never notify anyone.
72
+ */
73
+ export type SubmissionTransactionPort = <T>(work: () => Promise<T>) => Promise<T>;
68
74
  /** Bound to the host's outbox/bus/clock; dispatch is kicked off without awaiting delivery. */
69
75
  export interface OutboxDispatcherPort {
70
76
  dispatch(required: Record<string, never>): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { Logger } from "@jini-ai/core/primitives";
2
- import type { RateLimiterPort, FormOutboxPort, OutboxDispatcherPort } from "./ports.js";
2
+ import type { RateLimiterPort, FormOutboxPort, OutboxDispatcherPort, SubmissionTransactionPort } from "./ports.js";
3
3
  import type { Clock, IdGenerator, UUID } from "@jini-ai/core/primitives";
4
4
  import type { FormDefinitionRepoPort, FormSubmissionRepoPort } from "./ports.js";
5
5
  export interface SubmitFormDeps {
@@ -11,6 +11,8 @@ export interface SubmitFormDeps {
11
11
  clock: Clock;
12
12
  idGen: IdGenerator;
13
13
  rateLimiter: RateLimiterPort;
14
+ /** Omitted: the two writes run back to back with no rollback between them. */
15
+ transaction?: SubmissionTransactionPort;
14
16
  }
15
17
  export interface SubmitFormInput {
16
18
  workspaceId: UUID;
@@ -1,5 +1,5 @@
1
1
  import { nowIso as kernelNowIso } from "@jini-ai/core/primitives";
2
- /** Anonymous submission path: active lookup, honeypot, validation, rate check, persistence, event enqueue, then background dispatch. Persistence and enqueue remain separate awaited effects, matching the source contract. */
2
+ /** Anonymous submission path: active lookup, honeypot, validation, rate check, persistence + event enqueue in one host transaction, then background dispatch. */
3
3
  import { buildFormsRateLimitKey } from "./rate-limit-key.js";
4
4
  import { FormDefinitionNotFoundError, FormRateLimitExceededError, FormSubmissionValidationError, } from "./errors.js";
5
5
  import { isHoneypotTripped, validateSubmissionPayload } from "./forms.js";
@@ -38,15 +38,20 @@ export async function submitForm(required) {
38
38
  sourceIp: input.sourceIp,
39
39
  submittedAt: now,
40
40
  };
41
- await deps.submissionRepo.create(submission);
42
- // Only a persisted accepted submission gets this event; honeypot discards emit nothing.
43
- await deps.outbox.enqueue({
41
+ const event = {
44
42
  id: deps.idGen.newId(),
45
43
  name: "form.submission.received",
46
44
  occurredAt: now,
47
45
  workspaceId: input.workspaceId,
48
46
  aggregateId: submissionId,
49
47
  payload: { workspaceId: input.workspaceId, formDefinitionId: definition.id, submissionId },
48
+ };
49
+ // Only a persisted accepted submission gets this event; honeypot discards emit nothing. Row and
50
+ // event commit together: a failed enqueue must not leave a stored submission nobody is told about.
51
+ const transaction = deps.transaction ?? ((work) => work());
52
+ await transaction(async () => {
53
+ await deps.submissionRepo.create(submission);
54
+ await deps.outbox.enqueue(event);
50
55
  });
51
56
  // Dispatch failures cannot affect an accepted submission or create an unhandled rejection.
52
57
  // Never await delivery here: a subscriber sends mail, so awaiting it would reintroduce the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/cms-forms",
3
- "version": "0.2.2",
3
+ "version": "0.6.12",
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/cms": "^0.4.2",
41
- "@jini-ai/core": "^0.4.0"
40
+ "@jini-ai/cms": "^0.6.12",
41
+ "@jini-ai/core": "^0.6.12"
42
42
  },
43
43
  "devDependencies": {
44
44
  "vitest": "^2.1.0",
@@ -49,6 +49,7 @@
49
49
  "access": "public",
50
50
  "registry": "https://registry.npmjs.org"
51
51
  },
52
+ "deprecated": "Use @jini-ai/cms/forms. Scheduled for npm deprecation in the owner publish; retained for existing workspace links until the consumer forms switch.",
52
53
  "scripts": {
53
54
  "build": "tsc -p tsconfig.json",
54
55
  "typecheck": "tsc -p tsconfig.json --noEmit",