@oblax/forms 2.0.0 → 2.2.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/entries.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { OblaxContext } from '@oblax/core';
2
- import type { CreateEntryParams, EntryIdParams, FormEntry, ListEntriesParams } from './types.js';
2
+ import type { CreateEntryParams, EntryIdParams, FormEntry, FormEntryList, ListEntriesParams } from './types.js';
3
3
  /**
4
4
  * Manages entries (submissions) for a form.
5
5
  *
@@ -11,8 +11,12 @@ import type { CreateEntryParams, EntryIdParams, FormEntry, ListEntriesParams } f
11
11
  * payload: { first_name: 'John', last_name: 'Doe', age: 30 },
12
12
  * })
13
13
  *
14
- * // List all submissions
15
- * const entries = await oblax.forms.entries.list({ formId: 'form-id' })
14
+ * // A page of submissions, newest first, and how many there are
15
+ * const { data, count } = await oblax.forms.entries.list({
16
+ * formId: 'form-id',
17
+ * order: { field: '_created', direction: 'desc' },
18
+ * limit: 50,
19
+ * })
16
20
  *
17
21
  * // Fetch one by ID
18
22
  * const one = await oblax.forms.entries.get({ formId: 'form-id', entryId: entry.id })
@@ -25,12 +29,16 @@ export declare class EntriesSubmodule {
25
29
  private readonly ctx;
26
30
  constructor(ctx: OblaxContext);
27
31
  /**
28
- * Submits a new entry for the given form.
29
- * `payload` must contain keys that match the form's field names.
32
+ * Submits a new entry for the given form. `payload` holds the answers by field name; keys no
33
+ * field names are dropped. A 400 VALIDATION_FAILED names the first field that failed as
34
+ * `payload.<name>`.
30
35
  */
31
36
  create(params: CreateEntryParams): Promise<FormEntry>;
32
- /** Returns all submitted entries for a form. */
33
- list(params: ListEntriesParams): Promise<FormEntry[]>;
37
+ /**
38
+ * A page of a form's entries (20 by default, oldest first) and how many match. Filter, order
39
+ * and page on the server; see `ListEntriesParams`.
40
+ */
41
+ list(params: ListEntriesParams): Promise<FormEntryList>;
34
42
  /** Fetches a single entry by its ID. */
35
43
  get(params: EntryIdParams): Promise<FormEntry>;
36
44
  /** Deletes an entry. */
@@ -1 +1 @@
1
- {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../src/entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,iBAAiB,EAClB,MAAM,YAAY,CAAA;AAoBnB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC;IAQ3D,gDAAgD;IAC1C,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAO3D,wCAAwC;IAClC,GAAG,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC;IAOpD,wBAAwB;IAClB,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAKnD"}
1
+ {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../src/entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,aAAa,EACb,iBAAiB,EAClB,MAAM,YAAY,CAAA;AAkBnB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC;IAQ3D;;;OAGG;IACG,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ7D,wCAAwC;IAClC,GAAG,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC;IAOpD,wBAAwB;IAClB,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAKnD"}
package/dist/entries.js CHANGED
@@ -1,18 +1,10 @@
1
- /**
2
- * Collapses a flat API entry object into a typed `FormEntry`.
3
- *
4
- * The API returns entries as a flat object where `id` and `form_id` are
5
- * metadata and every other key is a field value, e.g.:
6
- * ```json
7
- * { "id": "abc", "form_id": "xyz", "first_name": "John", "age": 30 }
8
- * ```
9
- */
1
+ import { buildQuery, listPairs, pathSegment } from '@oblax/core';
2
+ /** Turns the API's `{ id, form_id, payload }` into a `FormEntry`, the payload as `values`. */
10
3
  function normalizeEntry(raw) {
11
- const { id, form_id, ...values } = raw;
12
4
  return {
13
- id: id,
14
- formId: form_id,
15
- values,
5
+ id: raw.id,
6
+ formId: raw.form_id,
7
+ values: raw.payload ?? {},
16
8
  };
17
9
  }
18
10
  /**
@@ -26,8 +18,12 @@ function normalizeEntry(raw) {
26
18
  * payload: { first_name: 'John', last_name: 'Doe', age: 30 },
27
19
  * })
28
20
  *
29
- * // List all submissions
30
- * const entries = await oblax.forms.entries.list({ formId: 'form-id' })
21
+ * // A page of submissions, newest first, and how many there are
22
+ * const { data, count } = await oblax.forms.entries.list({
23
+ * formId: 'form-id',
24
+ * order: { field: '_created', direction: 'desc' },
25
+ * limit: 50,
26
+ * })
31
27
  *
32
28
  * // Fetch one by ID
33
29
  * const one = await oblax.forms.entries.get({ formId: 'form-id', entryId: entry.id })
@@ -41,26 +37,31 @@ export class EntriesSubmodule {
41
37
  this.ctx = ctx;
42
38
  }
43
39
  /**
44
- * Submits a new entry for the given form.
45
- * `payload` must contain keys that match the form's field names.
40
+ * Submits a new entry for the given form. `payload` holds the answers by field name; keys no
41
+ * field names are dropped. A 400 VALIDATION_FAILED names the first field that failed as
42
+ * `payload.<name>`.
46
43
  */
47
44
  async create(params) {
48
- const raw = await this.ctx.http.post(`/forms/${params.formId}/entries`, { payload: params.payload });
45
+ const raw = await this.ctx.http.post(`/forms/${pathSegment(params.formId)}/entries`, { payload: params.payload });
49
46
  return normalizeEntry(raw);
50
47
  }
51
- /** Returns all submitted entries for a form. */
48
+ /**
49
+ * A page of a form's entries (20 by default, oldest first) and how many match. Filter, order
50
+ * and page on the server; see `ListEntriesParams`.
51
+ */
52
52
  async list(params) {
53
- const raw = await this.ctx.http.get(`/forms/${params.formId}/entries`);
54
- return raw.map(normalizeEntry);
53
+ const { formId, ...query } = params;
54
+ const raw = await this.ctx.http.get(`/forms/${pathSegment(formId)}/entries${buildQuery({}, listPairs(query))}`);
55
+ return { data: (raw.data ?? []).map(normalizeEntry), count: raw.count };
55
56
  }
56
57
  /** Fetches a single entry by its ID. */
57
58
  async get(params) {
58
- const raw = await this.ctx.http.get(`/forms/${params.formId}/entries/${params.entryId}`);
59
+ const raw = await this.ctx.http.get(`/forms/${pathSegment(params.formId)}/entries/${pathSegment(params.entryId)}`);
59
60
  return normalizeEntry(raw);
60
61
  }
61
62
  /** Deletes an entry. */
62
63
  async delete(params) {
63
- return this.ctx.http.delete(`/forms/${params.formId}/entries/${params.entryId}`);
64
+ return this.ctx.http.delete(`/forms/${pathSegment(params.formId)}/entries/${pathSegment(params.entryId)}`);
64
65
  }
65
66
  }
66
67
  //# sourceMappingURL=entries.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entries.js","sourceRoot":"","sources":["../src/entries.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAC,GAA4B;IAClD,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,GAAG,CAAA;IACtC,OAAO;QACL,EAAE,EAAM,EAAY;QACpB,MAAM,EAAE,OAAiB;QACzB,MAAM;KACP,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;G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AC,MAAM,CAAC,OAAO,CAAC,EAAE,CAC9E,CAAA;QACD,OAAO,cAAc,CAAC,GAAG,CAAC,CAAA;IAC5B,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,MAAM,CAAC,MAAqB;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CACzB,UAAU,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAC9E,CAAA;IACH,CAAC;CACF"}
package/dist/fields.d.ts CHANGED
@@ -1,18 +1,8 @@
1
1
  import type { OblaxContext } from '@oblax/core';
2
2
  /**
3
- * Manages fields within a specific form.
4
- *
5
- * @example
6
- * ```typescript
7
- * // Add a field to an existing form
8
- * const field = await oblax.forms.fields.create({
9
- * formId: 'form-id',
10
- * field: { name: 'phone', dataType: 'string', required: false },
11
- * })
12
- *
13
- * // Remove a field
14
- * await oblax.forms.fields.delete({ formId: 'form-id', fieldId: field.id })
15
- * ```
3
+ * A form's fields. It has no calls: a form's fields are set when it's created
4
+ * (`forms.create`) and the API has no route to add, change or remove one, as a form can't be
5
+ * updated. Read them from `forms.get()`; a field marked `_deleted` is gone.
16
6
  */
17
7
  export declare class FieldsSubmodule {
18
8
  private readonly ctx;
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAe/C;;;;;;;;;;;;;;GAcG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;CAoB/C"}
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;GAIG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;CAC/C"}
package/dist/fields.js CHANGED
@@ -1,28 +1,7 @@
1
- /** Maps a `FormFieldDraft` (camelCase input) to the API's snake_case body shape. */
2
- function draftToApiField(draft) {
3
- return {
4
- name: draft.name,
5
- data_type: draft.dataType,
6
- required: draft.required,
7
- options: draft.options ?? null,
8
- depends_field: draft.dependsField ?? '',
9
- depends_field_value: draft.dependsFieldValue ?? '',
10
- };
11
- }
12
1
  /**
13
- * Manages fields within a specific form.
14
- *
15
- * @example
16
- * ```typescript
17
- * // Add a field to an existing form
18
- * const field = await oblax.forms.fields.create({
19
- * formId: 'form-id',
20
- * field: { name: 'phone', dataType: 'string', required: false },
21
- * })
22
- *
23
- * // Remove a field
24
- * await oblax.forms.fields.delete({ formId: 'form-id', fieldId: field.id })
25
- * ```
2
+ * A form's fields. It has no calls: a form's fields are set when it's created
3
+ * (`forms.create`) and the API has no route to add, change or remove one, as a form can't be
4
+ * updated. Read them from `forms.get()`; a field marked `_deleted` is gone.
26
5
  */
27
6
  export class FieldsSubmodule {
28
7
  constructor(ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAGA,oFAAoF;AACpF,SAAS,eAAe,CAAC,KAAqB;IAC5C,OAAO;QACL,IAAI,EAAiB,KAAK,CAAC,IAAI;QAC/B,SAAS,EAAY,KAAK,CAAC,QAAQ;QACnC,QAAQ,EAAa,KAAK,CAAC,QAAQ;QACnC,OAAO,EAAc,KAAK,CAAC,OAAO,IAAI,IAAI;QAC1C,aAAa,EAAQ,KAAK,CAAC,YAAY,IAAI,EAAE;QAC7C,mBAAmB,EAAE,KAAK,CAAC,iBAAiB,IAAI,EAAE;KACnD,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,eAAe;IAC1B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;CAoBnD"}
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAC1B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;CACnD"}
@@ -1,17 +1,17 @@
1
1
  import type { OblaxContext } from '@oblax/core';
2
- import type { CreateFormParams, Form, FormIdParams, FormsConfig } from './types.js';
2
+ import type { CreateFormParams, Form, FormIdParams, FormList, FormsConfig, ListFormsParams } from './types.js';
3
3
  import { FieldsSubmodule } from './fields.js';
4
4
  import { EntriesSubmodule } from './entries.js';
5
5
  /**
6
6
  * The Forms module.
7
7
  *
8
- * Provides CRUD for form definitions directly on the module, with
9
- * `fields` and `entries` exposed as sub-modules for their nested resources.
8
+ * Form definitions on the module (list, get, create; a form can't be updated or deleted
9
+ * through the API), and its submissions on `entries`.
10
10
  *
11
11
  * @example
12
12
  * ```typescript
13
13
  * const oblax = new Oblax({
14
- * endpoint: 'https://api.my-app.oblax.io',
14
+ * endpoint: '<api-endpoint>', // the client's endpoint: `obx project clients list`
15
15
  * clientId: 'my-web-app',
16
16
  * modules: [PlatformBrowser(), Forms()],
17
17
  * })
@@ -25,17 +25,15 @@ import { EntriesSubmodule } from './entries.js';
25
25
  * ],
26
26
  * })
27
27
  *
28
+ * // A page of forms, by name
29
+ * const { data, count } = await oblax.forms.list({ order: { field: 'name', direction: 'asc' } })
30
+ *
28
31
  * // Submit an entry
29
32
  * await oblax.forms.entries.create({
30
33
  * formId: form.id,
31
34
  * payload: { email: 'alice@example.com', message: 'Hello!' },
32
35
  * })
33
- *
34
- * // Add a field after creation
35
- * await oblax.forms.fields.create({
36
- * formId: form.id,
37
- * field: { name: 'phone', dataType: 'string', required: false },
38
- * })
36
+
39
37
  * ```
40
38
  */
41
39
  export declare class FormsModule {
@@ -45,8 +43,12 @@ export declare class FormsModule {
45
43
  /** Manages entries (submissions) for a form. */
46
44
  readonly entries: EntriesSubmodule;
47
45
  constructor(ctx: OblaxContext, _config: FormsConfig);
48
- /** Returns all form definitions. */
49
- list(): Promise<Form[]>;
46
+ /**
47
+ * A page of the forms (20 by default, oldest first) with their fields, and how many match.
48
+ * Filter, order and page on the server; see `ListFormsParams`. Listing forms is for the
49
+ * admin role by default.
50
+ */
51
+ list(params?: ListFormsParams): Promise<FormList>;
50
52
  /** Fetches a single form definition by ID. */
51
53
  get(params: FormIdParams): Promise<Form>;
52
54
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"forms-module.d.ts","sourceRoot":"","sources":["../src/forms-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EAEJ,YAAY,EACZ,WAAW,EAEZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAc/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,WAAW;IAMV,OAAO,CAAC,QAAQ,CAAC,GAAG;IALhC,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;IAChC,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;gBAEL,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW;IAOpE,oCAAoC;IAC9B,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAI7B,8CAA8C;IACxC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAyBtD"}
1
+ {"version":3,"file":"forms-module.d.ts","sourceRoot":"","sources":["../src/forms-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EAEJ,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,eAAe,EAChB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAc/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,WAAW;IAMV,OAAO,CAAC,QAAQ,CAAC,GAAG;IALhC,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;IAChC,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;gBAEL,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW;IAOpE;;;;OAIG;IACG,IAAI,CAAC,MAAM,GAAE,eAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI3D,8CAA8C;IACxC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAMtD"}
@@ -1,3 +1,4 @@
1
+ import { buildQuery, listPairs, pathSegment } from '@oblax/core';
1
2
  import { FieldsSubmodule } from './fields.js';
2
3
  import { EntriesSubmodule } from './entries.js';
3
4
  /** Maps a `FormFieldDraft` to the API's snake_case body shape. */
@@ -14,13 +15,13 @@ function draftToApiField(draft) {
14
15
  /**
15
16
  * The Forms module.
16
17
  *
17
- * Provides CRUD for form definitions directly on the module, with
18
- * `fields` and `entries` exposed as sub-modules for their nested resources.
18
+ * Form definitions on the module (list, get, create; a form can't be updated or deleted
19
+ * through the API), and its submissions on `entries`.
19
20
  *
20
21
  * @example
21
22
  * ```typescript
22
23
  * const oblax = new Oblax({
23
- * endpoint: 'https://api.my-app.oblax.io',
24
+ * endpoint: '<api-endpoint>', // the client's endpoint: `obx project clients list`
24
25
  * clientId: 'my-web-app',
25
26
  * modules: [PlatformBrowser(), Forms()],
26
27
  * })
@@ -34,17 +35,15 @@ function draftToApiField(draft) {
34
35
  * ],
35
36
  * })
36
37
  *
38
+ * // A page of forms, by name
39
+ * const { data, count } = await oblax.forms.list({ order: { field: 'name', direction: 'asc' } })
40
+ *
37
41
  * // Submit an entry
38
42
  * await oblax.forms.entries.create({
39
43
  * formId: form.id,
40
44
  * payload: { email: 'alice@example.com', message: 'Hello!' },
41
45
  * })
42
- *
43
- * // Add a field after creation
44
- * await oblax.forms.fields.create({
45
- * formId: form.id,
46
- * field: { name: 'phone', dataType: 'string', required: false },
47
- * })
46
+
48
47
  * ```
49
48
  */
50
49
  export class FormsModule {
@@ -54,13 +53,17 @@ export class FormsModule {
54
53
  this.entries = new EntriesSubmodule(ctx);
55
54
  }
56
55
  // ─── Form CRUD ─────────────────────────────────────────────────────────────
57
- /** Returns all form definitions. */
58
- async list() {
59
- return this.ctx.http.get('/forms');
56
+ /**
57
+ * A page of the forms (20 by default, oldest first) with their fields, and how many match.
58
+ * Filter, order and page on the server; see `ListFormsParams`. Listing forms is for the
59
+ * admin role by default.
60
+ */
61
+ async list(params = {}) {
62
+ return this.ctx.http.get(`/forms${buildQuery({}, listPairs(params))}`);
60
63
  }
61
64
  /** Fetches a single form definition by ID. */
62
65
  async get(params) {
63
- return this.ctx.http.get(`/forms/${params.id}`);
66
+ return this.ctx.http.get(`/forms/${pathSegment(params.id)}`);
64
67
  }
65
68
  /**
66
69
  * Creates a new form with the given name and initial field definitions.
@@ -1 +1 @@
1
- {"version":3,"file":"forms-module.js","sourceRoot":"","sources":["../src/forms-module.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,kEAAkE;AAClE,SAAS,eAAe,CAA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C;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,MAAwB;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAO,QAAQ,EAAE;YACxC,IAAI,EAAI,MAAM,CAAC,IAAI;YACnB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC;SAC3C,CAAC,CAAA;IACJ,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -4,13 +4,12 @@ import type { FormsConfig } from './types.js';
4
4
  export { FormsModule } from './forms-module.js';
5
5
  export { FieldsSubmodule } from './fields.js';
6
6
  export { EntriesSubmodule } from './entries.js';
7
- export type { FormsConfig, Form, CreateFormParams, UpdateFormParams, FormIdParams, FormField, FormFieldDraft, AddFieldParams, DeleteFieldParams, FormEntry, CreateEntryParams, ListEntriesParams, EntryIdParams, } from './types.js';
7
+ export type { FormsConfig, Form, FormList, ListFormsParams, CreateFormParams, UpdateFormParams, FormIdParams, FormField, FormFieldDraft, AddFieldParams, DeleteFieldParams, FormEntry, FormEntryList, CreateEntryParams, ListEntriesParams, EntryIdParams, } from './types.js';
8
8
  /**
9
9
  * Forms module factory.
10
10
  *
11
- * Registers the forms module with the Oblax SDK. Form CRUD operations are
12
- * available directly on `oblax.forms`; field and entry operations are exposed
13
- * via `oblax.forms.fields` and `oblax.forms.entries`.
11
+ * Registers the forms module with the Oblax SDK. Form definitions are on
12
+ * `oblax.forms` (list, get, create) and submissions on `oblax.forms.entries`.
14
13
  *
15
14
  * @example
16
15
  * ```typescript
@@ -19,7 +18,7 @@ export type { FormsConfig, Form, CreateFormParams, UpdateFormParams, FormIdParam
19
18
  * import { Forms } from '@oblax/forms'
20
19
  *
21
20
  * const oblax = new Oblax({
22
- * endpoint: 'https://api.my-app.oblax.io',
21
+ * endpoint: '<api-endpoint>', // the client's endpoint: `obx project clients list`
23
22
  * clientId: 'my-web-app',
24
23
  * modules: [PlatformBrowser(), Forms()],
25
24
  * })
@@ -29,7 +28,7 @@ export type { FormsConfig, Form, CreateFormParams, UpdateFormParams, FormIdParam
29
28
  * name: 'Feedback',
30
29
  * fields: [
31
30
  * { name: 'email', dataType: 'string', required: true },
32
- * { name: 'rating', dataType: 'int', required: true },
31
+ * { name: 'rating', dataType: 'number', required: true },
33
32
  * { name: 'comment', dataType: 'string', required: false },
34
33
  * ],
35
34
  * })
@@ -40,14 +39,8 @@ export type { FormsConfig, Form, CreateFormParams, UpdateFormParams, FormIdParam
40
39
  * payload: { email: 'alice@example.com', rating: 5, comment: 'Great!' },
41
40
  * })
42
41
  *
43
- * // List submissions
44
- * const all = await oblax.forms.entries.list({ formId: form.id })
45
- *
46
- * // Add a field after the fact
47
- * await oblax.forms.fields.create({
48
- * formId: form.id,
49
- * field: { name: 'phone', dataType: 'string', required: false },
50
- * })
42
+ * // A page of submissions and how many there are
43
+ * const { data, count } = await oblax.forms.entries.list({ formId: form.id, limit: 50 })
51
44
  * ```
52
45
  */
53
46
  export declare function Forms(config?: FormsConfig): OblaxModulePlugin<'forms', FormsModule>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,YAAY,EACV,WAAW,EAEX,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EAEZ,SAAS,EACT,cAAc,EACd,cAAc,EACd,iBAAiB,EAEjB,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,KAAK,CAAC,MAAM,GAAE,WAAgB,GAAG,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC,CAOvF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,YAAY,EACV,WAAW,EAEX,IAAI,EACJ,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EAEZ,SAAS,EACT,cAAc,EACd,cAAc,EACd,iBAAiB,EAEjB,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,KAAK,CAAC,MAAM,GAAE,WAAgB,GAAG,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC,CAOvF"}
package/dist/index.js CHANGED
@@ -5,9 +5,8 @@ export { EntriesSubmodule } from './entries.js';
5
5
  /**
6
6
  * Forms module factory.
7
7
  *
8
- * Registers the forms module with the Oblax SDK. Form CRUD operations are
9
- * available directly on `oblax.forms`; field and entry operations are exposed
10
- * via `oblax.forms.fields` and `oblax.forms.entries`.
8
+ * Registers the forms module with the Oblax SDK. Form definitions are on
9
+ * `oblax.forms` (list, get, create) and submissions on `oblax.forms.entries`.
11
10
  *
12
11
  * @example
13
12
  * ```typescript
@@ -16,7 +15,7 @@ export { EntriesSubmodule } from './entries.js';
16
15
  * import { Forms } from '@oblax/forms'
17
16
  *
18
17
  * const oblax = new Oblax({
19
- * endpoint: 'https://api.my-app.oblax.io',
18
+ * endpoint: '<api-endpoint>', // the client's endpoint: `obx project clients list`
20
19
  * clientId: 'my-web-app',
21
20
  * modules: [PlatformBrowser(), Forms()],
22
21
  * })
@@ -26,7 +25,7 @@ export { EntriesSubmodule } from './entries.js';
26
25
  * name: 'Feedback',
27
26
  * fields: [
28
27
  * { name: 'email', dataType: 'string', required: true },
29
- * { name: 'rating', dataType: 'int', required: true },
28
+ * { name: 'rating', dataType: 'number', required: true },
30
29
  * { name: 'comment', dataType: 'string', required: false },
31
30
  * ],
32
31
  * })
@@ -37,14 +36,8 @@ export { EntriesSubmodule } from './entries.js';
37
36
  * payload: { email: 'alice@example.com', rating: 5, comment: 'Great!' },
38
37
  * })
39
38
  *
40
- * // List submissions
41
- * const all = await oblax.forms.entries.list({ formId: form.id })
42
- *
43
- * // Add a field after the fact
44
- * await oblax.forms.fields.create({
45
- * formId: form.id,
46
- * field: { name: 'phone', dataType: 'string', required: false },
47
- * })
39
+ * // A page of submissions and how many there are
40
+ * const { data, count } = await oblax.forms.entries.list({ formId: form.id, limit: 50 })
48
41
  * ```
49
42
  */
50
43
  export function Forms(config = {}) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAqB/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,UAAU,KAAK,CAAC,SAAsB,EAAE;IAC5C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,MAAM,CAAC,GAAiB;YACtB,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAwB/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,KAAK,CAAC,SAAsB,EAAE;IAC5C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,MAAM,CAAC,GAAiB;YACtB,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ListQuery } from '@oblax/core';
1
2
  /**
2
3
  * A form field as returned by the API.
3
4
  * Field names are snake_case to match the wire format exactly.
@@ -8,7 +9,10 @@ export interface FormField {
8
9
  /** `true` when the field has been soft-deleted. */
9
10
  _deleted: boolean;
10
11
  name: string;
11
- /** Scalar data type, e.g. `'string'`, `'int'`, `'float'`, `'bool'`. */
12
+ /**
13
+ * The answer's type. The API checks `string`, `email`, `number` (a number or a numeric
14
+ * string) and `boolean` (true or false); any other value is stored but not checked.
15
+ */
12
16
  data_type: string;
13
17
  required: boolean;
14
18
  /** Allowed values for enum-style fields. `null` when unconstrained. */
@@ -24,7 +28,7 @@ export interface FormField {
24
28
  */
25
29
  export interface FormFieldDraft {
26
30
  name: string;
27
- /** Scalar data type, e.g. `'string'`, `'int'`, `'float'`, `'bool'`. */
31
+ /** `string`, `email`, `number` or `boolean`: the types the API checks (see `FormField.data_type`). */
28
32
  dataType: string;
29
33
  required: boolean;
30
34
  /** Allowed values. Pass `null` or omit for free-form fields. */
@@ -37,12 +41,26 @@ export interface FormFieldDraft {
37
41
  export interface Form {
38
42
  id: string;
39
43
  name: string;
44
+ /** The form's slug, made from its name; `list()` can filter on it. */
45
+ slug: string;
40
46
  fields: FormField[];
41
47
  }
48
+ /**
49
+ * `forms.list()`'s filters, order and page. Filters: `id`, `name`, `slug`. Order by `id` (the
50
+ * default, oldest first), `name`, `slug` or `_created`. Pages of 20 (`limit` up to 100; more is
51
+ * a 400), `offset`.
52
+ */
53
+ export type ListFormsParams = ListQuery;
54
+ /** A page of forms and the number of forms that match. */
55
+ export interface FormList {
56
+ data: Form[];
57
+ count: number;
58
+ }
42
59
  export interface CreateFormParams {
43
60
  name: string;
44
61
  fields: FormFieldDraft[];
45
62
  }
63
+ /** @deprecated No call takes it: the API can't update a form or its fields. */
46
64
  export interface UpdateFormParams {
47
65
  /** ID of the form to update. */
48
66
  id: string;
@@ -56,11 +74,13 @@ export interface UpdateFormParams {
56
74
  export interface FormIdParams {
57
75
  id: string;
58
76
  }
77
+ /** @deprecated No call takes it: the API can't update a form or its fields. */
59
78
  export interface AddFieldParams {
60
79
  /** ID of the form to add the field to. */
61
80
  formId: string;
62
81
  field: FormFieldDraft;
63
82
  }
83
+ /** @deprecated No call takes it: the API can't update a form or its fields. */
64
84
  export interface DeleteFieldParams {
65
85
  /** ID of the form. */
66
86
  formId: string;
@@ -68,14 +88,13 @@ export interface DeleteFieldParams {
68
88
  fieldId: string;
69
89
  }
70
90
  /**
71
- * A normalised form entry.
72
- * The raw API response is a flat object whose keys are field names plus `id`
73
- * and `form_id`. The SDK separates metadata from field values.
91
+ * A form entry. The API answers `{ id, form_id, payload }`; the SDK gives the payload as
92
+ * `values`.
74
93
  */
75
94
  export interface FormEntry {
76
95
  id: string;
77
96
  formId: string;
78
- /** Field-name → value pairs (all keys except `id` and `form_id`). */
97
+ /** The answers, by field name: the entry's `payload` as it was submitted. */
79
98
  values: Record<string, unknown>;
80
99
  }
81
100
  export interface CreateEntryParams {
@@ -88,9 +107,19 @@ export interface CreateEntryParams {
88
107
  */
89
108
  payload: Record<string, unknown>;
90
109
  }
91
- export interface ListEntriesParams {
110
+ /**
111
+ * `forms.entries.list()`'s form, filters, order and page. Filters: `id`, `_created`. Order by
112
+ * `id` (the default, oldest first) or `_created`. Pages of 20 (`limit` up to 100; more is a
113
+ * 400), `offset`.
114
+ */
115
+ export interface ListEntriesParams extends ListQuery {
92
116
  formId: string;
93
117
  }
118
+ /** A page of a form's entries and the number of entries that match. */
119
+ export interface FormEntryList {
120
+ data: FormEntry[];
121
+ count: number;
122
+ }
94
123
  export interface EntryIdParams {
95
124
  formId: string;
96
125
  entryId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,uEAAuE;IACvE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IACxB,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAA;IACrB,kEAAkE;IAClE,mBAAmB,EAAE,MAAM,CAAA;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,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;CAChB;AAID,+DAA+D;AAC/D,MAAM,WAAW,WAAW;CAE3B"}
package/dist/types.js CHANGED
@@ -1,3 +1,2 @@
1
- // ─── Form fields ─────────────────────────────────────────────────────────────
2
1
  export {};
3
2
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,gFAAgF"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@oblax/forms",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Oblax SDK — forms module (form definitions, fields, entries)",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Oblax SDK for JavaScript Team",
8
- "url": "https://docs.oblax.io/docs/getting-started/your-first-sdk-call"
8
+ "url": "https://docs.oblax.io/docs/getting-started/first-call/"
9
9
  },
10
10
  "homepage": "https://github.com/oblaxio/oblax-sdk-js#readme",
11
11
  "repository": {
@@ -37,11 +37,11 @@
37
37
  "access": "public"
38
38
  },
39
39
  "peerDependencies": {
40
- "@oblax/core": "^2.0.0"
40
+ "@oblax/core": "^2.2.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "typescript": "^5.5.0",
44
- "@oblax/core": "2.0.0"
44
+ "@oblax/core": "2.2.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsc --build tsconfig.json",