@fabriktor/client 0.0.35 → 0.0.37

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.
@@ -1,9 +1,8 @@
1
- import { type Contact, type ID, type InContact, type OperationResult, type PLContactsGenerateQR, type Signal } from "@fabriktor/schema";
1
+ import { type Contact, type ID, type InContact, type OperationResult, type PLContactsGenerateQR } from "@fabriktor/schema";
2
2
  import type { TokenProvider } from "../core/auth.js";
3
3
  import type { DeleteOneOptionsCRUD, FindOneOptionsCRUD, InsertOneOptionsCRUD, OperationResultOf, ReplaceOneOptionsCRUD } from "../core/crud.js";
4
4
  import type { HTTPDoer } from "../core/http.js";
5
5
  export type GenerateQROptions = PLContactsGenerateQR;
6
- export type SignalOptions = Signal;
7
6
  export type ContactsClientOptions = {
8
7
  http: HTTPDoer;
9
8
  base_url: string;
@@ -14,7 +13,7 @@ export interface ContactsOperator {
14
13
  findOneContact(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Contact>>;
15
14
  replaceOneContact(opts: ReplaceOneOptionsCRUD<InContact>): Promise<OperationResult>;
16
15
  deleteOneContact(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
17
- signal(opts: SignalOptions): Promise<OperationResultOf<ID[]>>;
16
+ signal(): Promise<OperationResultOf<ID[]>>;
18
17
  suggest(): Promise<OperationResultOf<ID[]>>;
19
18
  generateQR(opts: GenerateQROptions): Promise<void>;
20
19
  findContacts(): Promise<OperationResultOf<Contact[]>>;
@@ -29,7 +28,7 @@ export declare class ContactsClient implements ContactsOperator {
29
28
  findOneContact(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Contact>>;
30
29
  replaceOneContact(opts: ReplaceOneOptionsCRUD<InContact>): Promise<OperationResult>;
31
30
  deleteOneContact(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
32
- signal(opts: SignalOptions): Promise<OperationResultOf<ID[]>>;
31
+ signal(): Promise<OperationResultOf<ID[]>>;
33
32
  suggest(): Promise<OperationResultOf<ID[]>>;
34
33
  generateQR(opts: GenerateQROptions): Promise<void>;
35
34
  findContacts(): Promise<OperationResultOf<Contact[]>>;
@@ -36,14 +36,13 @@ export class ContactsClient {
36
36
  async deleteOneContact(opts) {
37
37
  return await this.contacts.deleteOne(opts);
38
38
  }
39
- async signal(opts) {
39
+ async signal() {
40
40
  const token = await requiredToken(this.get_token);
41
41
  return await this.http.do({
42
42
  base_url: this.base_url,
43
43
  path: signalPath(PathContactsSignal),
44
44
  method: HTTPMethodPost,
45
45
  token,
46
- body: opts,
47
46
  });
48
47
  }
49
48
  async suggest() {
@@ -1,13 +1,10 @@
1
1
  import { OperationResultValueKey, SearchResultResultsKey, type OperationResult, type SearchResult, type UpsertResult } from "@fabriktor/schema";
2
+ import { type ReplaceOptionalField } from "./type.js";
2
3
  import type { TokenProvider } from "./auth.js";
3
4
  import { type QueryOptions } from "./col.js";
4
5
  import type { HTTPDoer } from "./http.js";
5
- export type OperationResultOf<T> = Omit<OperationResult, typeof OperationResultValueKey> & {
6
- [OperationResultValueKey]?: T;
7
- };
8
- export type SearchResultOf<T> = Omit<SearchResult, typeof SearchResultResultsKey> & {
9
- [SearchResultResultsKey]?: T[];
10
- };
6
+ export type OperationResultOf<T> = ReplaceOptionalField<OperationResult, typeof OperationResultValueKey, T>;
7
+ export type SearchResultOf<T> = ReplaceOptionalField<SearchResult, typeof SearchResultResultsKey, T[]>;
11
8
  export type CRUDClientOptions = {
12
9
  http: HTTPDoer;
13
10
  base_url: string;
@@ -3,7 +3,7 @@
3
3
  // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
4
  // not use this file except in compliance with the License. You may obtain
5
5
  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- import { HTTPMethodDelete, HTTPMethodGet, HTTPMethodPatch, HTTPMethodPost, OperationResultValueKey, PathSearch, SearchResultResultsKey, } from "@fabriktor/schema";
6
+ import { HTTPMethodDelete, HTTPMethodGet, HTTPMethodPatch, HTTPMethodPost, PathSearch, } from "@fabriktor/schema";
7
7
  import { requiredToken } from "./auth.js";
8
8
  import { collectionPath, idPath, withQuery } from "./col.js";
9
9
  import { buildPath } from "./path.js";
@@ -0,0 +1,7 @@
1
+ export type ReplaceField<T extends object, K extends keyof T, V> = Omit<T, K> & {
2
+ [P in K]: V;
3
+ };
4
+ export type ReplaceOptionalField<T extends object, K extends keyof T, V> = Omit<T, K> & {
5
+ [P in K]?: V;
6
+ };
7
+ export type OptionalField<T extends object, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
@@ -0,0 +1,6 @@
1
+ // Copyright (C) Fabriktor, Inc. 2025-present.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+ // not use this file except in compliance with the License. You may obtain
5
+ // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ export {};
@@ -11,6 +11,7 @@ export * from "./core/http.js";
11
11
  export * from "./core/idempotency.js";
12
12
  export * from "./core/multipart.js";
13
13
  export * from "./core/path.js";
14
+ export * from "./core/type.js";
14
15
  export * from "./core/ws.js";
15
16
  export * from "./feed/feed.js";
16
17
  export * from "./fulfillments/fulfillments.js";
package/dist/src/index.js CHANGED
@@ -11,6 +11,7 @@ export * from "./core/http.js";
11
11
  export * from "./core/idempotency.js";
12
12
  export * from "./core/multipart.js";
13
13
  export * from "./core/path.js";
14
+ export * from "./core/type.js";
14
15
  export * from "./core/ws.js";
15
16
  export * from "./feed/feed.js";
16
17
  export * from "./fulfillments/fulfillments.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/client",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {