@fabriktor/client 0.0.24 → 0.0.26

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.
@@ -0,0 +1,18 @@
1
+ import { type InConnection, type OperationResult } from "@fabriktor/schema";
2
+ import type { TokenProvider } from "../core/auth.js";
3
+ import type { InsertOneOptionsCRUD } from "../core/crud.js";
4
+ import type { HTTPDoer } from "../core/http.js";
5
+ export type ConnectionsClientOptions = {
6
+ http: HTTPDoer;
7
+ base_url: string;
8
+ get_token?: TokenProvider;
9
+ };
10
+ export interface ConnectionsOperator {
11
+ insertOneConnection(opts: InsertOneOptionsCRUD<InConnection>): Promise<OperationResult>;
12
+ }
13
+ export declare class ConnectionsClient implements ConnectionsOperator {
14
+ private connections;
15
+ constructor(opts: ConnectionsClientOptions);
16
+ insertOneConnection(opts: InsertOneOptionsCRUD<InConnection>): Promise<OperationResult>;
17
+ }
18
+ export declare function newConnectionsClient(opts: ConnectionsClientOptions): ConnectionsClient;
@@ -0,0 +1,25 @@
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
+ import { ColConnectionsConnections, SvcConnections, } from "@fabriktor/schema";
7
+ import { newCRUDClient } from "../core/crud.js";
8
+ export class ConnectionsClient {
9
+ connections;
10
+ constructor(opts) {
11
+ this.connections = newCRUDClient({
12
+ http: opts.http,
13
+ base_url: opts.base_url,
14
+ svc: SvcConnections,
15
+ col: ColConnectionsConnections,
16
+ get_token: opts.get_token,
17
+ });
18
+ }
19
+ async insertOneConnection(opts) {
20
+ return await this.connections.insertOne(opts);
21
+ }
22
+ }
23
+ export function newConnectionsClient(opts) {
24
+ return new ConnectionsClient(opts);
25
+ }
@@ -43,7 +43,7 @@ export class HTTPClient {
43
43
  catch (err) {
44
44
  throw errHTTPRequestFailed(err);
45
45
  }
46
- if (res.ok && idempotencyToken !== undefined) {
46
+ if (idempotencyToken !== undefined) {
47
47
  this.idempotency.reset(opts.method, opts.path);
48
48
  }
49
49
  if (!res.ok) {
@@ -1,3 +1,4 @@
1
+ export * from "./connections/connections.js";
1
2
  export * from "./core/auth.js";
2
3
  export * from "./core/col.js";
3
4
  export * from "./core/crud.js";
@@ -5,6 +6,8 @@ export * from "./core/err.js";
5
6
  export * from "./core/http.js";
6
7
  export * from "./core/idempotency.js";
7
8
  export * from "./core/path.js";
9
+ export * from "./memos/memos.js";
10
+ export * from "./notifications/notifications.js";
8
11
  export * from "./preferences/preferences.js";
9
12
  export * from "./users/tmp_phones.js";
10
13
  export * from "./users/tmp_usernames.js";
package/dist/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./connections/connections.js";
1
2
  export * from "./core/auth.js";
2
3
  export * from "./core/col.js";
3
4
  export * from "./core/crud.js";
@@ -5,6 +6,8 @@ export * from "./core/err.js";
5
6
  export * from "./core/http.js";
6
7
  export * from "./core/idempotency.js";
7
8
  export * from "./core/path.js";
9
+ export * from "./memos/memos.js";
10
+ export * from "./notifications/notifications.js";
8
11
  export * from "./preferences/preferences.js";
9
12
  export * from "./users/tmp_phones.js";
10
13
  export * from "./users/tmp_usernames.js";
@@ -0,0 +1,45 @@
1
+ import { type InMemo, type InMemoFolder, type Memo, type MemoFolder, type OperationResult } from "@fabriktor/schema";
2
+ import type { TokenProvider } from "../core/auth.js";
3
+ import type { DeleteManyOptionsCRUD, DeleteOneOptionsCRUD, FindOneOptionsCRUD, InsertOneOptionsCRUD, OperationResultOf, QueryOptionsCRUD, ReplaceOneOptionsCRUD, SearchManyOptionsCRUD, SearchResultOf } from "../core/crud.js";
4
+ import type { HTTPDoer } from "../core/http.js";
5
+ export type MemosClientOptions = {
6
+ http: HTTPDoer;
7
+ base_url: string;
8
+ get_token?: TokenProvider;
9
+ };
10
+ export interface MemosOperator {
11
+ queryMemos(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Memo[]>>;
12
+ insertOneMemo(opts: InsertOneOptionsCRUD<InMemo>): Promise<OperationResult>;
13
+ findOneMemo(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Memo>>;
14
+ replaceOneMemo(opts: ReplaceOneOptionsCRUD<InMemo>): Promise<OperationResult>;
15
+ deleteOneMemo(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
16
+ deleteManyMemos(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
17
+ searchManyMemos(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<Memo>>>;
18
+ queryMemoFolders(opts?: QueryOptionsCRUD): Promise<OperationResultOf<MemoFolder[]>>;
19
+ insertOneMemoFolder(opts: InsertOneOptionsCRUD<InMemoFolder>): Promise<OperationResult>;
20
+ findOneMemoFolder(opts: FindOneOptionsCRUD): Promise<OperationResultOf<MemoFolder>>;
21
+ replaceOneMemoFolder(opts: ReplaceOneOptionsCRUD<InMemoFolder>): Promise<OperationResult>;
22
+ deleteOneMemoFolder(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
23
+ deleteManyMemoFolders(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
24
+ searchManyMemoFolders(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<MemoFolder>>>;
25
+ }
26
+ export declare class MemosClient implements MemosOperator {
27
+ private memos;
28
+ private memo_folders;
29
+ constructor(opts: MemosClientOptions);
30
+ queryMemos(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Memo[]>>;
31
+ insertOneMemo(opts: InsertOneOptionsCRUD<InMemo>): Promise<OperationResult>;
32
+ findOneMemo(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Memo>>;
33
+ replaceOneMemo(opts: ReplaceOneOptionsCRUD<InMemo>): Promise<OperationResult>;
34
+ deleteOneMemo(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
35
+ deleteManyMemos(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
36
+ searchManyMemos(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<Memo>>>;
37
+ queryMemoFolders(opts?: QueryOptionsCRUD): Promise<OperationResultOf<MemoFolder[]>>;
38
+ insertOneMemoFolder(opts: InsertOneOptionsCRUD<InMemoFolder>): Promise<OperationResult>;
39
+ findOneMemoFolder(opts: FindOneOptionsCRUD): Promise<OperationResultOf<MemoFolder>>;
40
+ replaceOneMemoFolder(opts: ReplaceOneOptionsCRUD<InMemoFolder>): Promise<OperationResult>;
41
+ deleteOneMemoFolder(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
42
+ deleteManyMemoFolders(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
43
+ searchManyMemoFolders(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<MemoFolder>>>;
44
+ }
45
+ export declare function newMemosClient(opts: MemosClientOptions): MemosClient;
@@ -0,0 +1,72 @@
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
+ import { ColMemosMemoFolders, ColMemosMemos, SvcMemos, } from "@fabriktor/schema";
7
+ import { newCRUDClient } from "../core/crud.js";
8
+ export class MemosClient {
9
+ memos;
10
+ memo_folders;
11
+ constructor(opts) {
12
+ this.memos = newCRUDClient({
13
+ http: opts.http,
14
+ base_url: opts.base_url,
15
+ svc: SvcMemos,
16
+ col: ColMemosMemos,
17
+ get_token: opts.get_token,
18
+ });
19
+ this.memo_folders = newCRUDClient({
20
+ http: opts.http,
21
+ base_url: opts.base_url,
22
+ svc: SvcMemos,
23
+ col: ColMemosMemoFolders,
24
+ get_token: opts.get_token,
25
+ });
26
+ }
27
+ async queryMemos(opts) {
28
+ return await this.memos.query(opts);
29
+ }
30
+ async insertOneMemo(opts) {
31
+ return await this.memos.insertOne(opts);
32
+ }
33
+ async findOneMemo(opts) {
34
+ return await this.memos.findOne(opts);
35
+ }
36
+ async replaceOneMemo(opts) {
37
+ return await this.memos.replaceOne(opts);
38
+ }
39
+ async deleteOneMemo(opts) {
40
+ return await this.memos.deleteOne(opts);
41
+ }
42
+ async deleteManyMemos(opts) {
43
+ return await this.memos.deleteMany(opts);
44
+ }
45
+ async searchManyMemos(opts) {
46
+ return await this.memos.searchMany(opts);
47
+ }
48
+ async queryMemoFolders(opts) {
49
+ return await this.memo_folders.query(opts);
50
+ }
51
+ async insertOneMemoFolder(opts) {
52
+ return await this.memo_folders.insertOne(opts);
53
+ }
54
+ async findOneMemoFolder(opts) {
55
+ return await this.memo_folders.findOne(opts);
56
+ }
57
+ async replaceOneMemoFolder(opts) {
58
+ return await this.memo_folders.replaceOne(opts);
59
+ }
60
+ async deleteOneMemoFolder(opts) {
61
+ return await this.memo_folders.deleteOne(opts);
62
+ }
63
+ async deleteManyMemoFolders(opts) {
64
+ return await this.memo_folders.deleteMany(opts);
65
+ }
66
+ async searchManyMemoFolders(opts) {
67
+ return await this.memo_folders.searchMany(opts);
68
+ }
69
+ }
70
+ export function newMemosClient(opts) {
71
+ return new MemosClient(opts);
72
+ }
@@ -0,0 +1,24 @@
1
+ import { type InDTok, type PLNotificationsRelay, type UpsertResult } from "@fabriktor/schema";
2
+ import type { TokenProvider } from "../core/auth.js";
3
+ import type { OperationResultOf, UpsertOneOptionsCRUD } from "../core/crud.js";
4
+ import type { HTTPDoer } from "../core/http.js";
5
+ export type RelayNotificationOptions = PLNotificationsRelay;
6
+ export type NotificationsClientOptions = {
7
+ http: HTTPDoer;
8
+ base_url: string;
9
+ get_token?: TokenProvider;
10
+ };
11
+ export interface NotificationsOperator {
12
+ upsertOneDTok(opts: UpsertOneOptionsCRUD<InDTok>): Promise<OperationResultOf<UpsertResult>>;
13
+ relayNotification(opts: RelayNotificationOptions): Promise<void>;
14
+ }
15
+ export declare class NotificationsClient implements NotificationsOperator {
16
+ private dtoks;
17
+ private http;
18
+ private base_url;
19
+ private get_token?;
20
+ constructor(opts: NotificationsClientOptions);
21
+ upsertOneDTok(opts: UpsertOneOptionsCRUD<InDTok>): Promise<OperationResultOf<UpsertResult>>;
22
+ relayNotification(opts: RelayNotificationOptions): Promise<void>;
23
+ }
24
+ export declare function newNotificationsClient(opts: NotificationsClientOptions): NotificationsClient;
@@ -0,0 +1,50 @@
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
+ import { ColNotificationsDToks, HTTPMethodPost, PathNotificationsRelay, SvcNotifications, } from "@fabriktor/schema";
7
+ import { requiredToken } from "../core/auth.js";
8
+ import { newCRUDClient } from "../core/crud.js";
9
+ import { buildPath } from "../core/path.js";
10
+ export class NotificationsClient {
11
+ dtoks;
12
+ http;
13
+ base_url;
14
+ get_token;
15
+ constructor(opts) {
16
+ this.dtoks = newCRUDClient({
17
+ http: opts.http,
18
+ base_url: opts.base_url,
19
+ svc: SvcNotifications,
20
+ col: ColNotificationsDToks,
21
+ get_token: opts.get_token,
22
+ });
23
+ this.http = opts.http;
24
+ this.base_url = opts.base_url;
25
+ this.get_token = opts.get_token;
26
+ }
27
+ async upsertOneDTok(opts) {
28
+ return await this.dtoks.upsertOne(opts);
29
+ }
30
+ async relayNotification(opts) {
31
+ const token = await requiredToken(this.get_token);
32
+ return await this.http.do({
33
+ base_url: this.base_url,
34
+ path: notificationPath(PathNotificationsRelay),
35
+ method: HTTPMethodPost,
36
+ token,
37
+ body: opts,
38
+ });
39
+ }
40
+ }
41
+ export function newNotificationsClient(opts) {
42
+ return new NotificationsClient(opts);
43
+ }
44
+ function notificationPath(action) {
45
+ return buildPath({
46
+ svc: SvcNotifications,
47
+ col: SvcNotifications,
48
+ action,
49
+ });
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/client",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,6 +17,6 @@
17
17
  "typescript": "^6.0.3"
18
18
  },
19
19
  "dependencies": {
20
- "@fabriktor/schema": "^0.0.18"
20
+ "@fabriktor/schema": "^0.0.19"
21
21
  }
22
22
  }