backlex 0.1.1 → 0.1.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as ListQuery, k as ListResponse, C as Condition, f as DurationParts, R as RelativeNow, A as AggregateQuery, a as AggregateRow, S as SearchQuery, m as SearchResponse, I as ImportSummary, h as ItemQuery, i as ItemResponse, d as BatchResponse, c as BatchOperation, g as ItemEvent, l as ResumableUploadResult, D as DeviceToken, P as PhoneNumber, j as JobStatus, J as Job, F as FlagState } from './types-DMWee2em.js';
2
- export { B as BacklexError, U as Upload, n as UploadStatus } from './types-DMWee2em.js';
1
+ import { L as ListQuery, m as ListResponse, C as Condition, h as DurationParts, R as RelativeNow, A as AggregateQuery, a as AggregateRow, S as SearchQuery, o as SearchResponse, I as ImportSummary, j as ItemQuery, k as ItemResponse, d as BatchResponse, f as BulkUpdateResponse, c as BatchOperation, i as ItemEvent, n as ResumableUploadResult, D as DeviceToken, P as PhoneNumber, l as JobStatus, J as Job, F as FlagState } from './types-DiJCXOy-.js';
2
+ export { B as BacklexError, U as Upload, p as UploadStatus } from './types-DiJCXOy-.js';
3
3
  export { VerifyWebhookOptions, verifyWebhook } from './webhook.js';
4
4
 
5
5
  /**
@@ -330,6 +330,7 @@ interface CollectionClient<T extends Record<string, unknown>> {
330
330
  deleteMany(ids: string[], opts?: {
331
331
  atomic?: boolean;
332
332
  }): Promise<BatchResponse<T>>;
333
+ bulkUpdate(keys: string[], data: Partial<T>): Promise<BulkUpdateResponse>;
333
334
  batch(operations: BatchOperation<T>[], opts?: {
334
335
  atomic?: boolean;
335
336
  }): Promise<BatchResponse<T>>;
@@ -571,6 +572,57 @@ interface FlagsClient {
571
572
  refresh?: boolean;
572
573
  }): Promise<boolean>;
573
574
  }
575
+ /** A visual workflow (flow) row. `operations` is the serialized op DSL the
576
+ * builder compiles; `layout` is a purely-presentational graph snapshot. */
577
+ interface Flow {
578
+ id: string;
579
+ tenantId?: string | null;
580
+ name: string;
581
+ trigger: string;
582
+ operations: unknown[];
583
+ layout?: unknown;
584
+ active: boolean;
585
+ }
586
+ /** Create/update payload for a flow. `operations` must be non-empty on create;
587
+ * `update` accepts any subset. */
588
+ interface FlowInput {
589
+ name: string;
590
+ trigger: string;
591
+ operations: unknown[];
592
+ layout?: unknown;
593
+ active?: boolean;
594
+ }
595
+ /** Outcome of a manual flow run. `ok: false` means the run halted on an
596
+ * unhandled op error; `error` carries the first failure message. */
597
+ interface FlowRunResult {
598
+ ok: boolean;
599
+ error?: string;
600
+ }
601
+ /** Visual workflows (admin-scoped). Mirrors `/api/flows`. See `createClient`. */
602
+ interface FlowsClient {
603
+ /** List every flow in the active workspace. */
604
+ list(): Promise<{
605
+ data: Flow[];
606
+ }>;
607
+ /** Fetch a single flow's full definition by id. */
608
+ get(id: string): Promise<{
609
+ data: Flow;
610
+ }>;
611
+ /** Create a flow scoped to the active workspace. */
612
+ create(input: FlowInput): Promise<{
613
+ data: Flow;
614
+ }>;
615
+ /** Partial update of a flow by id. */
616
+ update(id: string, patch: Partial<FlowInput>): Promise<{
617
+ ok: boolean;
618
+ }>;
619
+ /** Delete a flow by id. */
620
+ delete(id: string): Promise<{
621
+ ok: boolean;
622
+ }>;
623
+ /** Synchronously run a flow with an arbitrary `input` trigger payload. */
624
+ run(id: string, input?: Record<string, unknown>): Promise<FlowRunResult>;
625
+ }
574
626
  /** The backlex client returned by `createClient` — data, auth, storage, realtime, and more. */
575
627
  interface BacklexClient {
576
628
  /** Typed data API for one collection by slug. */
@@ -585,6 +637,8 @@ interface BacklexClient {
585
637
  messaging: MessagingClient;
586
638
  /** Durable background job queue. */
587
639
  jobs: JobsClient;
640
+ /** Visual workflows (flows). */
641
+ flows: FlowsClient;
588
642
  /** Feature flags / remote config. */
589
643
  flags: FlagsClient;
590
644
  /** Offline-first sync controller for one collection. */
@@ -619,4 +673,4 @@ type TypedClient<R extends CollectionsMap> = BacklexClient & {
619
673
  */
620
674
  declare const typedCollections: <R extends CollectionsMap>(client: BacklexClient) => TypedClient<R>;
621
675
 
622
- export { AggregateQuery, AggregateRow, type AuthClient, type AuthResult, type AuthSession, type AuthSurface, type AuthUser, type BacklexClient, BatchOperation, BatchResponse, type ClientOptions, type CollectionClient, type CollectionsMap, DeviceToken, type FieldKey, type FilterBuilder, FlagState, type FlagsClient, ImportSummary, ItemEvent, ItemQuery, ItemResponse, Job, JobStatus, type JobsClient, ListQuery, ListResponse, type MessagingClient, PhoneNumber, type PublicProvider, QueryBuilder, type QueuedOp, ResumableUploadResult, SearchQuery, SearchResponse, type SortKey, type StorageClient, type SyncOptions, type SyncStore, type TypedClient, type TypedCollections, createClient, createSync, indexedDbStore, memoryStore, typedCollections };
676
+ export { AggregateQuery, AggregateRow, type AuthClient, type AuthResult, type AuthSession, type AuthSurface, type AuthUser, type BacklexClient, BatchOperation, BatchResponse, BulkUpdateResponse, type ClientOptions, type CollectionClient, type CollectionsMap, DeviceToken, type FieldKey, type FilterBuilder, FlagState, type FlagsClient, type Flow, type FlowInput, type FlowRunResult, type FlowsClient, ImportSummary, ItemEvent, ItemQuery, ItemResponse, Job, JobStatus, type JobsClient, ListQuery, ListResponse, type MessagingClient, PhoneNumber, type PublicProvider, QueryBuilder, type QueuedOp, ResumableUploadResult, SearchQuery, SearchResponse, type SortKey, type StorageClient, type SyncOptions, type SyncStore, type TypedClient, type TypedCollections, createClient, createSync, indexedDbStore, memoryStore, typedCollections };
package/dist/index.js CHANGED
@@ -456,7 +456,11 @@ var createClient = (opts) => {
456
456
  const tenantHeader = () => opts.tenant ? { "x-backlex-tenant": opts.tenant } : {};
457
457
  const request = async (method, path, body, extraHeaders) => {
458
458
  const headers = {
459
- "content-type": "application/json",
459
+ // Only advertise a JSON body when we actually send one. A bodyless POST
460
+ // (publish, unpublish, restore, fts-reindex, …) that still carried
461
+ // `content-type: application/json` made the server's body validator try to
462
+ // parse an empty body and fail with "Malformed JSON in request body".
463
+ ...body !== void 0 ? { "content-type": "application/json" } : {},
460
464
  ...authHeader(),
461
465
  ...tenantHeader(),
462
466
  ...extraHeaders ?? {}
@@ -539,6 +543,14 @@ var createClient = (opts) => {
539
543
  operations: ids.map((id) => ({ op: "delete", id })),
540
544
  atomic: opts2?.atomic
541
545
  }),
546
+ /** Set the SAME fields on many ids at once (one shared patch). Only the
547
+ * named fields change per row; partial-success (a key the caller can't
548
+ * write is reported `NOT_FOUND`). Differs from `updateMany`, which sends
549
+ * a distinct patch per id. */
550
+ bulkUpdate: (keys, data) => request("POST", `/api/items/${slug}/bulk-update`, {
551
+ keys,
552
+ data
553
+ }),
542
554
  /** Mixed create/update/delete in one request. `atomic` = all-or-nothing. */
543
555
  batch: (operations, opts2) => request("POST", `/api/items/${slug}/batch`, {
544
556
  operations,
@@ -818,6 +830,20 @@ var createClient = (opts) => {
818
830
  /** Delete a job row. */
819
831
  remove: (id) => request("DELETE", `/api/jobs/${encodeURIComponent(id)}`)
820
832
  };
833
+ const flows = {
834
+ /** List every flow in the active workspace. */
835
+ list: () => request("GET", "/api/flows"),
836
+ /** Fetch a single flow's full definition by id. */
837
+ get: (id) => request("GET", `/api/flows/${encodeURIComponent(id)}`),
838
+ /** Create a flow scoped to the active workspace. */
839
+ create: (input) => request("POST", "/api/flows", input),
840
+ /** Partial update of a flow by id. */
841
+ update: (id, patch) => request("PATCH", `/api/flows/${encodeURIComponent(id)}`, patch),
842
+ /** Delete a flow by id. */
843
+ delete: (id) => request("DELETE", `/api/flows/${encodeURIComponent(id)}`),
844
+ /** Run a flow synchronously with an arbitrary `input` trigger payload. */
845
+ run: (id, input) => request("POST", `/api/flows/${encodeURIComponent(id)}/run`, input ?? {})
846
+ };
821
847
  let flagsCache = null;
822
848
  const fetchFlags = async () => {
823
849
  const res = await request("GET", "/api/flags");
@@ -848,6 +874,7 @@ var createClient = (opts) => {
848
874
  storage,
849
875
  messaging,
850
876
  jobs,
877
+ flows,
851
878
  flags,
852
879
  sync,
853
880
  /** Raw escape hatch — issues a request with auth headers applied. */
@@ -187,6 +187,25 @@ interface BatchResponse<T = Record<string, unknown>> {
187
187
  results: BatchRowResult<T>[];
188
188
  };
189
189
  }
190
+ /** Per-key outcome inside a {@link BulkUpdateResponse}. */
191
+ interface BulkUpdateRowResult {
192
+ id: string;
193
+ ok: boolean;
194
+ error?: {
195
+ code: string;
196
+ message: string;
197
+ };
198
+ }
199
+ /** Response from a `bulkUpdate(keys, data)` call — one shared patch over many
200
+ * ids, partial-success (a key the caller can't write is `NOT_FOUND`). */
201
+ interface BulkUpdateResponse {
202
+ data: {
203
+ total: number;
204
+ updated: number;
205
+ failed: number;
206
+ results: BulkUpdateRowResult[];
207
+ };
208
+ }
190
209
  /** A registered push device (from `messaging.listDevices()`). */
191
210
  interface DeviceToken {
192
211
  id: string;
@@ -267,4 +286,4 @@ declare class BacklexError extends Error {
267
286
  } | undefined);
268
287
  }
269
288
 
270
- export { type AggregateQuery as A, BacklexError as B, type Condition as C, type DeviceToken as D, type FlagState as F, type ImportSummary as I, type Job as J, type ListQuery as L, type PhoneNumber as P, type RelativeNow as R, type SearchQuery as S, type Upload as U, type AggregateRow as a, type ApiError as b, type BatchOperation as c, type BatchResponse as d, type BatchRowResult as e, type DurationParts as f, type ItemEvent as g, type ItemQuery as h, type ItemResponse as i, type JobStatus as j, type ListResponse as k, type ResumableUploadResult as l, type SearchResponse as m, type UploadStatus as n };
289
+ export { type AggregateQuery as A, BacklexError as B, type Condition as C, type DeviceToken as D, type FlagState as F, type ImportSummary as I, type Job as J, type ListQuery as L, type PhoneNumber as P, type RelativeNow as R, type SearchQuery as S, type Upload as U, type AggregateRow as a, type ApiError as b, type BatchOperation as c, type BatchResponse as d, type BatchRowResult as e, type BulkUpdateResponse as f, type BulkUpdateRowResult as g, type DurationParts as h, type ItemEvent as i, type ItemQuery as j, type ItemResponse as k, type JobStatus as l, type ListResponse as m, type ResumableUploadResult as n, type SearchResponse as o, type UploadStatus as p };
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
1
- export { A as AggregateQuery, a as AggregateRow, b as ApiError, B as BacklexError, c as BatchOperation, d as BatchResponse, e as BatchRowResult, D as DeviceToken, F as FlagState, I as ImportSummary, g as ItemEvent, h as ItemQuery, i as ItemResponse, J as Job, j as JobStatus, L as ListQuery, k as ListResponse, P as PhoneNumber, l as ResumableUploadResult, S as SearchQuery, m as SearchResponse, U as Upload, n as UploadStatus } from './types-DMWee2em.js';
1
+ export { A as AggregateQuery, a as AggregateRow, b as ApiError, B as BacklexError, c as BatchOperation, d as BatchResponse, e as BatchRowResult, f as BulkUpdateResponse, g as BulkUpdateRowResult, D as DeviceToken, F as FlagState, I as ImportSummary, i as ItemEvent, j as ItemQuery, k as ItemResponse, J as Job, l as JobStatus, L as ListQuery, m as ListResponse, P as PhoneNumber, n as ResumableUploadResult, S as SearchQuery, o as SearchResponse, U as Upload, p as UploadStatus } from './types-DiJCXOy-.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backlex",
3
- "version": "0.1.1",
4
- "description": "Typed TypeScript client for the backlex API — auth, collection CRUD, query builder, realtime, storage, jobs, flags, and offline sync. Zero dependencies. On npm as compiled ESM + types; on JSR (@backlex/backlex) as TypeScript source.",
3
+ "version": "0.1.2",
4
+ "description": "Typed TypeScript client for the backlex API — auth, collection CRUD, query builder, realtime, storage, jobs, flows, flags, and offline sync. Zero dependencies. On npm as compiled ESM + types; on JSR (@backlex/backlex) as TypeScript source.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "homepage": "https://backlex.com",