@jini-ai/cms-forms 0.7.2 → 0.7.3-next.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/dist/forms.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare const MAX_LABEL_LENGTH = 200;
5
5
  export declare const MIN_MAX_LENGTH = 1;
6
6
  export declare const MAX_MAX_LENGTH = 5000;
7
7
  export declare const FIELD_ID_PATTERN: RegExp;
8
- export declare const FIELD_TYPES: Set<string>;
8
+ export declare const FIELD_TYPES: ReadonlySet<string>;
9
9
  export declare const MAX_CLASS_NAME_LENGTH = 300;
10
10
  export declare const MAX_ATTRIBUTES_PER_FIELD = 12;
11
11
  export declare const MAX_ATTRIBUTE_VALUE_LENGTH = 300;
@@ -1,6 +1,6 @@
1
1
  import type { Logger } from "@jini-ai/core/primitives";
2
2
  /** Notification subscriber with host sender, mail and logging ports. Each recipient receives a stable per-submission dedup key; delivery and repository failures never block sibling subscribers. */
3
- import type { EventBusPort } from "@jini-ai/cms/core";
3
+ import type { EventBusPort } from "@jini-ai/core/contracts/events";
4
4
  import type { MailerPort, EmailAddress } from "./ports.js";
5
5
  import type { FormDefinitionRepoPort, FormSubmissionRepoPort } from "./ports.js";
6
6
  export interface RegisterFormNotifySubscriberDeps {
package/dist/ports.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /** Forms persistence and outbound effect contracts. Concrete repositories, HTTP routing, tool wiring and transport implementations belong to consumers. */
2
2
  import type { UUID } from "@jini-ai/core/primitives";
3
+ import type { ExecuteCommandFn } from "@jini-ai/core/contracts/events";
3
4
  import type { FormDefinitionRecord, FormSubmissionPage, FormSubmissionRecord } from "./types.js";
4
5
  /** Definitions and submissions have distinct lifecycles and therefore separate ports.
5
6
  * Deletion belongs to the host's Trash/purge workflow, so neither persistence port exposes delete.
@@ -63,7 +64,7 @@ export interface RateLimiterPort {
63
64
  }>;
64
65
  }
65
66
  export interface FormOutboxPort {
66
- enqueue(event: import("@jini-ai/cms/core").DomainEvent): Promise<void>;
67
+ enqueue(event: import("@jini-ai/core/contracts/events").DomainEvent): Promise<void>;
67
68
  }
68
69
  /**
69
70
  * Runs `work` as one unit of persistence: commit when it resolves, roll back when it throws. A host
@@ -113,5 +114,5 @@ export interface MailerPort {
113
114
  }): Promise<MailerSendResult>;
114
115
  }
115
116
  /** Generic audited mutation contract supplied by the host composition root. */
116
- export type FormCommandExecutorPort = typeof import("@jini-ai/cms/core").executeCommand;
117
+ export type FormCommandExecutorPort = ExecuteCommandFn;
117
118
  //# sourceMappingURL=ports.d.ts.map
@@ -1,7 +1,6 @@
1
1
  /** Audited definition writes through the CMS command gateway. Host permissions and reserved slugs are explicit policies; notify, idempotency and optional outbox wiring live in the second argument. */
2
- import type { ChangeSetRepoPort } from "@jini-ai/cms/core";
2
+ import type { ChangeSetRepoPort, AuthorizeFn, CommandActor } from "@jini-ai/core/contracts/events";
3
3
  import type { Clock, IdGenerator, UUID } from "@jini-ai/core/primitives";
4
- import type { AuthorizeFn, CommandActor } from "@jini-ai/cms/core";
5
4
  import type { FormCommandExecutorPort, FormDefinitionRepoPort } from "./ports.js";
6
5
  import type { FieldDescriptor, FormDefinitionRecord, FormDefinitionStatus, NotifyConfig } from "./types.js";
7
6
  export interface FormWriteServiceDeps {
@@ -70,7 +69,7 @@ export declare function setFormDefinitionStatus(required: SetFormDefinitionStatu
70
69
  }>;
71
70
  export interface FormWriteOptional {
72
71
  idempotencyKey?: string;
73
- outbox?: import("@jini-ai/cms/core").OutboxPort;
72
+ outbox?: import("@jini-ai/core/contracts/events").OutboxPort;
74
73
  }
75
74
  export interface CreateFormDefinitionOptional extends FormWriteOptional {
76
75
  notify?: NotifyConfig;
@@ -125,16 +125,33 @@ export async function createFormDefinition(required, optional = {}) {
125
125
  });
126
126
  return result;
127
127
  }
128
+ function formCommandDeps(deps, optional) {
129
+ return {
130
+ clock: deps.clock,
131
+ idGen: deps.idGen,
132
+ changeSets: deps.changeSets,
133
+ outbox: optional.outbox,
134
+ authorize: deps.authorize,
135
+ };
136
+ }
137
+ function updatedFormFields(existing, patch) {
138
+ let fields = existing.fields;
139
+ if (patch.fields !== undefined) {
140
+ assertValidFields(patch.fields);
141
+ const existingIds = new Set(existing.fields.map((f) => f.id));
142
+ const newIds = new Set(patch.fields.map((f) => f.id));
143
+ const missing = [...existingIds].filter((id) => !newIds.has(id));
144
+ if (missing.length > 0) {
145
+ throw new FormFieldValidationError({ message: `patch omits existing field id(s): ${missing.join(", ")} (behavior.spec.md §1.2)`, fieldErrors: missing.map((id) => ({ field: id, reason: "existing field ids cannot be removed" })) });
146
+ }
147
+ fields = patch.fields;
148
+ }
149
+ return fields;
150
+ }
128
151
  export async function updateFormDefinition(required, optional = {}) {
129
152
  const { deps, input } = required;
130
153
  const { result } = await deps.executeCommand({
131
- deps: {
132
- clock: deps.clock,
133
- idGen: deps.idGen,
134
- changeSets: deps.changeSets,
135
- outbox: optional.outbox,
136
- authorize: deps.authorize,
137
- },
154
+ deps: formCommandDeps(deps, optional),
138
155
  command: {
139
156
  workspaceId: input.workspaceId,
140
157
  actor: input.actor,
@@ -156,17 +173,7 @@ export async function updateFormDefinition(required, optional = {}) {
156
173
  if (input.patch.name !== undefined) {
157
174
  validateNameAndSlug(name, existing.slug, deps.reservedSlugs);
158
175
  }
159
- let fields = existing.fields;
160
- if (input.patch.fields !== undefined) {
161
- assertValidFields(input.patch.fields);
162
- const existingIds = new Set(existing.fields.map((f) => f.id));
163
- const newIds = new Set(input.patch.fields.map((f) => f.id));
164
- const missing = [...existingIds].filter((id) => !newIds.has(id));
165
- if (missing.length > 0) {
166
- throw new FormFieldValidationError({ message: `patch omits existing field id(s): ${missing.join(", ")} (behavior.spec.md §1.2)`, fieldErrors: missing.map((id) => ({ field: id, reason: "existing field ids cannot be removed" })) });
167
- }
168
- fields = input.patch.fields;
169
- }
176
+ const fields = updatedFormFields(existing, input.patch);
170
177
  const notify = input.patch.notify !== undefined ? validateNotify(input.patch.notify) : existing.notify;
171
178
  const definition = {
172
179
  ...existing,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/cms-forms",
3
- "version": "0.7.2",
3
+ "version": "0.7.3-next.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,13 +37,13 @@
37
37
  "!dist/**/*.map"
38
38
  ],
39
39
  "dependencies": {
40
- "@jini-ai/cms": "^0.7.2",
41
- "@jini-ai/core": "^0.7.2"
40
+ "@jini-ai/core": "^0.7.3-next.2"
42
41
  },
43
42
  "devDependencies": {
44
- "vitest": "^2.1.0",
43
+ "vitest": "^3.2.6",
45
44
  "typescript": "^5.6.0",
46
- "@types/node": "^24.0.0"
45
+ "@types/node": "^24.0.0",
46
+ "@jini-ai/cms": "^0.7.3-next.2"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public",