@fabriktor/client 0.0.20 → 0.0.22

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,15 @@
1
+ export type QueryValue = string | number | boolean | undefined | null;
2
+ export type QueryOptions = Record<string, QueryValue | QueryValue[]>;
3
+ export type CollectionPathOptions = {
4
+ svc: string;
5
+ col: string;
6
+ };
7
+ export type IDPathOptions = CollectionPathOptions & {
8
+ id: string;
9
+ };
10
+ export type BuildQueryOptions = {
11
+ query?: QueryOptions;
12
+ };
13
+ export declare function collectionPath(opts: CollectionPathOptions): string;
14
+ export declare function idPath(opts: IDPathOptions): string;
15
+ export declare function withQuery(path: string, opts?: BuildQueryOptions): string;
@@ -0,0 +1,46 @@
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 { buildPath } from "./path.js";
7
+ export function collectionPath(opts) {
8
+ return buildPath({
9
+ svc: opts.svc,
10
+ col: opts.col,
11
+ });
12
+ }
13
+ export function idPath(opts) {
14
+ return buildPath({
15
+ svc: opts.svc,
16
+ col: opts.col,
17
+ id: opts.id,
18
+ });
19
+ }
20
+ export function withQuery(path, opts) {
21
+ const query = opts?.query;
22
+ if (!query) {
23
+ return path;
24
+ }
25
+ const params = new URLSearchParams();
26
+ for (const [key, value] of Object.entries(query)) {
27
+ if (value === undefined || value === null) {
28
+ continue;
29
+ }
30
+ if (Array.isArray(value)) {
31
+ for (const item of value) {
32
+ if (item === undefined || item === null) {
33
+ continue;
34
+ }
35
+ params.append(key, String(item));
36
+ }
37
+ continue;
38
+ }
39
+ params.set(key, String(value));
40
+ }
41
+ const raw = params.toString();
42
+ if (raw === "") {
43
+ return path;
44
+ }
45
+ return `${path}?${raw}`;
46
+ }
@@ -0,0 +1,70 @@
1
+ import { OperationResultValueKey, SearchResultResultsKey, type OperationResult, type SearchResult, type UpsertResult } from "@fabriktor/schema";
2
+ import type { TokenProvider } from "./auth.js";
3
+ import type { HTTPDoer } from "./http.js";
4
+ import { type QueryOptions } from "./col.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
+ };
11
+ export type CRUDClientOptions = {
12
+ http: HTTPDoer;
13
+ base_url: string;
14
+ svc: string;
15
+ col: string;
16
+ get_token?: TokenProvider;
17
+ };
18
+ export type QueryOptionsCRUD = {
19
+ query?: QueryOptions;
20
+ };
21
+ export type InsertOneOptionsCRUD<In> = {
22
+ in: In;
23
+ };
24
+ export type UpsertOneOptionsCRUD<In> = {
25
+ in: In;
26
+ query?: QueryOptions;
27
+ };
28
+ export type FindOneOptionsCRUD = {
29
+ id: string;
30
+ };
31
+ export type ReplaceOneOptionsCRUD<In> = {
32
+ id: string;
33
+ in: In;
34
+ };
35
+ export type DeleteOneOptionsCRUD = {
36
+ id: string;
37
+ };
38
+ export type DeleteManyOptionsCRUD = {
39
+ query?: QueryOptions;
40
+ };
41
+ export type SearchManyOptionsCRUD = {
42
+ query?: QueryOptions;
43
+ };
44
+ export interface CRUDOperator<In, Out> {
45
+ query(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Out[]>>;
46
+ insertOne(opts: InsertOneOptionsCRUD<In>): Promise<OperationResult>;
47
+ upsertOne(opts: UpsertOneOptionsCRUD<In>): Promise<OperationResultOf<UpsertResult>>;
48
+ findOne(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Out>>;
49
+ replaceOne(opts: ReplaceOneOptionsCRUD<In>): Promise<OperationResult>;
50
+ deleteOne(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
51
+ deleteMany(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
52
+ searchMany(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<Out>>>;
53
+ }
54
+ export declare class CRUDClient<In, Out> implements CRUDOperator<In, Out> {
55
+ private http;
56
+ private base_url;
57
+ private svc;
58
+ private col;
59
+ private get_token?;
60
+ constructor(opts: CRUDClientOptions);
61
+ query(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Out[]>>;
62
+ insertOne(opts: InsertOneOptionsCRUD<In>): Promise<OperationResult>;
63
+ upsertOne(opts: UpsertOneOptionsCRUD<In>): Promise<OperationResultOf<UpsertResult>>;
64
+ findOne(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Out>>;
65
+ replaceOne(opts: ReplaceOneOptionsCRUD<In>): Promise<OperationResult>;
66
+ deleteOne(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
67
+ deleteMany(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
68
+ searchMany(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<Out>>>;
69
+ }
70
+ export declare function newCRUDClient<In, Out>(opts: CRUDClientOptions): CRUDClient<In, Out>;
@@ -0,0 +1,137 @@
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 { HTTPMethodDelete, HTTPMethodGet, HTTPMethodPatch, HTTPMethodPost, PathSearch, OperationResultValueKey, SearchResultResultsKey, } from "@fabriktor/schema";
7
+ import { requiredToken } from "./auth.js";
8
+ import { collectionPath, idPath, withQuery } from "./col.js";
9
+ import { buildPath } from "./path.js";
10
+ export class CRUDClient {
11
+ http;
12
+ base_url;
13
+ svc;
14
+ col;
15
+ get_token;
16
+ constructor(opts) {
17
+ this.http = opts.http;
18
+ this.base_url = opts.base_url;
19
+ this.svc = opts.svc;
20
+ this.col = opts.col;
21
+ this.get_token = opts.get_token;
22
+ }
23
+ async query(opts) {
24
+ const token = await requiredToken(this.get_token);
25
+ return await this.http.do({
26
+ base_url: this.base_url,
27
+ path: withQuery(collectionPath({
28
+ svc: this.svc,
29
+ col: this.col,
30
+ }), {
31
+ query: opts?.query,
32
+ }),
33
+ method: HTTPMethodGet,
34
+ token,
35
+ });
36
+ }
37
+ async insertOne(opts) {
38
+ const token = await requiredToken(this.get_token);
39
+ return await this.http.do({
40
+ base_url: this.base_url,
41
+ path: collectionPath({
42
+ svc: this.svc,
43
+ col: this.col,
44
+ }),
45
+ method: HTTPMethodPost,
46
+ token,
47
+ body: opts.in,
48
+ });
49
+ }
50
+ async upsertOne(opts) {
51
+ const token = await requiredToken(this.get_token);
52
+ return await this.http.do({
53
+ base_url: this.base_url,
54
+ path: withQuery(collectionPath({
55
+ svc: this.svc,
56
+ col: this.col,
57
+ }), {
58
+ query: opts.query,
59
+ }),
60
+ method: HTTPMethodPost,
61
+ token,
62
+ body: opts.in,
63
+ });
64
+ }
65
+ async findOne(opts) {
66
+ const token = await requiredToken(this.get_token);
67
+ return await this.http.do({
68
+ base_url: this.base_url,
69
+ path: idPath({
70
+ svc: this.svc,
71
+ col: this.col,
72
+ id: opts.id,
73
+ }),
74
+ method: HTTPMethodGet,
75
+ token,
76
+ });
77
+ }
78
+ async replaceOne(opts) {
79
+ const token = await requiredToken(this.get_token);
80
+ return await this.http.do({
81
+ base_url: this.base_url,
82
+ path: idPath({
83
+ svc: this.svc,
84
+ col: this.col,
85
+ id: opts.id,
86
+ }),
87
+ method: HTTPMethodPatch,
88
+ token,
89
+ body: opts.in,
90
+ });
91
+ }
92
+ async deleteOne(opts) {
93
+ const token = await requiredToken(this.get_token);
94
+ return await this.http.do({
95
+ base_url: this.base_url,
96
+ path: idPath({
97
+ svc: this.svc,
98
+ col: this.col,
99
+ id: opts.id,
100
+ }),
101
+ method: HTTPMethodDelete,
102
+ token,
103
+ });
104
+ }
105
+ async deleteMany(opts) {
106
+ const token = await requiredToken(this.get_token);
107
+ return await this.http.do({
108
+ base_url: this.base_url,
109
+ path: withQuery(collectionPath({
110
+ svc: this.svc,
111
+ col: this.col,
112
+ }), {
113
+ query: opts?.query,
114
+ }),
115
+ method: HTTPMethodDelete,
116
+ token,
117
+ });
118
+ }
119
+ async searchMany(opts) {
120
+ const token = await requiredToken(this.get_token);
121
+ return await this.http.do({
122
+ base_url: this.base_url,
123
+ path: withQuery(buildPath({
124
+ svc: this.svc,
125
+ col: this.col,
126
+ action: PathSearch,
127
+ }), {
128
+ query: opts?.query,
129
+ }),
130
+ method: HTTPMethodGet,
131
+ token,
132
+ });
133
+ }
134
+ }
135
+ export function newCRUDClient(opts) {
136
+ return new CRUDClient(opts);
137
+ }
@@ -2,6 +2,7 @@ export type PathOptions = {
2
2
  svc: string;
3
3
  col: string;
4
4
  id?: string;
5
+ id_key?: string;
5
6
  action?: string;
6
7
  };
7
8
  export declare function buildPath(opts: PathOptions): 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 { PathActions } from "@fabriktor/schema";
6
+ import { IDKey, PathActions } from "@fabriktor/schema";
7
7
  const pathSep = "/";
8
8
  function clean(v) {
9
9
  return v.replace(/^\/+|\/+$/g, "");
@@ -11,7 +11,7 @@ function clean(v) {
11
11
  export function buildPath(opts) {
12
12
  const out = [opts.svc, opts.col].map(clean);
13
13
  if (opts.id !== undefined) {
14
- out.push(encodeURIComponent(opts.id));
14
+ out.push(clean(opts.id_key ?? IDKey), encodeURIComponent(opts.id));
15
15
  }
16
16
  if (opts.action !== undefined) {
17
17
  out.push(PathActions, clean(opts.action));
@@ -1,7 +1,10 @@
1
1
  export * from "./core/auth.js";
2
+ export * from "./core/col.js";
3
+ export * from "./core/crud.js";
2
4
  export * from "./core/err.js";
3
5
  export * from "./core/http.js";
4
6
  export * from "./core/path.js";
7
+ export * from "./preferences/preferences.js";
5
8
  export * from "./users/tmp_phones.js";
6
9
  export * from "./users/tmp_usernames.js";
7
10
  export * from "./users/users.js";
package/dist/src/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  export * from "./core/auth.js";
2
+ export * from "./core/col.js";
3
+ export * from "./core/crud.js";
2
4
  export * from "./core/err.js";
3
5
  export * from "./core/http.js";
4
6
  export * from "./core/path.js";
7
+ export * from "./preferences/preferences.js";
5
8
  export * from "./users/tmp_phones.js";
6
9
  export * from "./users/tmp_usernames.js";
7
10
  export * from "./users/users.js";
@@ -0,0 +1,132 @@
1
+ import { type InPrefClient, type InPrefCompany, type InPrefEmail, type InPrefEmployee, type InPrefLanguage, type InPrefNotif, type InPrefPayment, type InPrefTutorial, type InPrefVisibility, type OperationResult, type PrefClient, type PrefCompany, type PrefEmail, type PrefEmployee, type PrefLanguage, type PrefNotif, type PrefPayment, type PrefTutorial, type PrefVisibility } from "@fabriktor/schema";
2
+ import type { TokenProvider } from "../core/auth.js";
3
+ import type { DeleteManyOptionsCRUD, DeleteOneOptionsCRUD, FindOneOptionsCRUD, InsertOneOptionsCRUD, OperationResultOf, QueryOptionsCRUD, ReplaceOneOptionsCRUD } from "../core/crud.js";
4
+ import type { HTTPDoer } from "../core/http.js";
5
+ export type PreferencesClientOptions = {
6
+ http: HTTPDoer;
7
+ base_url: string;
8
+ get_token?: TokenProvider;
9
+ };
10
+ export interface PreferencesOperator {
11
+ queryPrefPayments(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefPayment[]>>;
12
+ insertOnePrefPayment(opts: InsertOneOptionsCRUD<InPrefPayment>): Promise<OperationResult>;
13
+ findOnePrefPayment(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefPayment>>;
14
+ replaceOnePrefPayment(opts: ReplaceOneOptionsCRUD<InPrefPayment>): Promise<OperationResult>;
15
+ deleteOnePrefPayment(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
16
+ deleteManyPrefPayments(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
17
+ queryPrefClients(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefClient[]>>;
18
+ insertOnePrefClient(opts: InsertOneOptionsCRUD<InPrefClient>): Promise<OperationResult>;
19
+ findOnePrefClient(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefClient>>;
20
+ replaceOnePrefClient(opts: ReplaceOneOptionsCRUD<InPrefClient>): Promise<OperationResult>;
21
+ deleteOnePrefClient(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
22
+ deleteManyPrefClients(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
23
+ queryPrefEmployees(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefEmployee[]>>;
24
+ insertOnePrefEmployee(opts: InsertOneOptionsCRUD<InPrefEmployee>): Promise<OperationResult>;
25
+ findOnePrefEmployee(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefEmployee>>;
26
+ replaceOnePrefEmployee(opts: ReplaceOneOptionsCRUD<InPrefEmployee>): Promise<OperationResult>;
27
+ deleteOnePrefEmployee(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
28
+ deleteManyPrefEmployees(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
29
+ queryPrefCompanies(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefCompany[]>>;
30
+ insertOnePrefCompany(opts: InsertOneOptionsCRUD<InPrefCompany>): Promise<OperationResult>;
31
+ findOnePrefCompany(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefCompany>>;
32
+ replaceOnePrefCompany(opts: ReplaceOneOptionsCRUD<InPrefCompany>): Promise<OperationResult>;
33
+ deleteOnePrefCompany(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
34
+ deleteManyPrefCompanies(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
35
+ queryPrefVisibilities(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefVisibility[]>>;
36
+ insertOnePrefVisibility(opts: InsertOneOptionsCRUD<InPrefVisibility>): Promise<OperationResult>;
37
+ findOnePrefVisibility(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefVisibility>>;
38
+ replaceOnePrefVisibility(opts: ReplaceOneOptionsCRUD<InPrefVisibility>): Promise<OperationResult>;
39
+ deleteOnePrefVisibility(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
40
+ deleteManyPrefVisibilities(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
41
+ queryPrefLanguages(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefLanguage[]>>;
42
+ insertOnePrefLanguage(opts: InsertOneOptionsCRUD<InPrefLanguage>): Promise<OperationResult>;
43
+ findOnePrefLanguage(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefLanguage>>;
44
+ replaceOnePrefLanguage(opts: ReplaceOneOptionsCRUD<InPrefLanguage>): Promise<OperationResult>;
45
+ deleteOnePrefLanguage(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
46
+ deleteManyPrefLanguages(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
47
+ queryPrefNotif(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefNotif[]>>;
48
+ insertOnePrefNotif(opts: InsertOneOptionsCRUD<InPrefNotif>): Promise<OperationResult>;
49
+ findOnePrefNotif(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefNotif>>;
50
+ replaceOnePrefNotif(opts: ReplaceOneOptionsCRUD<InPrefNotif>): Promise<OperationResult>;
51
+ deleteOnePrefNotif(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
52
+ deleteManyPrefNotif(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
53
+ queryPrefEmails(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefEmail[]>>;
54
+ insertOnePrefEmail(opts: InsertOneOptionsCRUD<InPrefEmail>): Promise<OperationResult>;
55
+ findOnePrefEmail(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefEmail>>;
56
+ replaceOnePrefEmail(opts: ReplaceOneOptionsCRUD<InPrefEmail>): Promise<OperationResult>;
57
+ deleteOnePrefEmail(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
58
+ deleteManyPrefEmails(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
59
+ queryPrefTutorials(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefTutorial[]>>;
60
+ insertOnePrefTutorial(opts: InsertOneOptionsCRUD<InPrefTutorial>): Promise<OperationResult>;
61
+ findOnePrefTutorial(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefTutorial>>;
62
+ replaceOnePrefTutorial(opts: ReplaceOneOptionsCRUD<InPrefTutorial>): Promise<OperationResult>;
63
+ deleteOnePrefTutorial(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
64
+ deleteManyPrefTutorials(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
65
+ }
66
+ export declare class PreferencesClient implements PreferencesOperator {
67
+ private pref_payments;
68
+ private pref_clients;
69
+ private pref_employees;
70
+ private pref_companies;
71
+ private pref_visibilities;
72
+ private pref_languages;
73
+ private pref_notif;
74
+ private pref_emails;
75
+ private pref_tutorials;
76
+ constructor(opts: PreferencesClientOptions);
77
+ queryPrefPayments(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefPayment[]>>;
78
+ insertOnePrefPayment(opts: InsertOneOptionsCRUD<InPrefPayment>): Promise<OperationResult>;
79
+ findOnePrefPayment(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefPayment>>;
80
+ replaceOnePrefPayment(opts: ReplaceOneOptionsCRUD<InPrefPayment>): Promise<OperationResult>;
81
+ deleteOnePrefPayment(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
82
+ deleteManyPrefPayments(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
83
+ queryPrefClients(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefClient[]>>;
84
+ insertOnePrefClient(opts: InsertOneOptionsCRUD<InPrefClient>): Promise<OperationResult>;
85
+ findOnePrefClient(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefClient>>;
86
+ replaceOnePrefClient(opts: ReplaceOneOptionsCRUD<InPrefClient>): Promise<OperationResult>;
87
+ deleteOnePrefClient(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
88
+ deleteManyPrefClients(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
89
+ queryPrefEmployees(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefEmployee[]>>;
90
+ insertOnePrefEmployee(opts: InsertOneOptionsCRUD<InPrefEmployee>): Promise<OperationResult>;
91
+ findOnePrefEmployee(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefEmployee>>;
92
+ replaceOnePrefEmployee(opts: ReplaceOneOptionsCRUD<InPrefEmployee>): Promise<OperationResult>;
93
+ deleteOnePrefEmployee(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
94
+ deleteManyPrefEmployees(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
95
+ queryPrefCompanies(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefCompany[]>>;
96
+ insertOnePrefCompany(opts: InsertOneOptionsCRUD<InPrefCompany>): Promise<OperationResult>;
97
+ findOnePrefCompany(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefCompany>>;
98
+ replaceOnePrefCompany(opts: ReplaceOneOptionsCRUD<InPrefCompany>): Promise<OperationResult>;
99
+ deleteOnePrefCompany(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
100
+ deleteManyPrefCompanies(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
101
+ queryPrefVisibilities(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefVisibility[]>>;
102
+ insertOnePrefVisibility(opts: InsertOneOptionsCRUD<InPrefVisibility>): Promise<OperationResult>;
103
+ findOnePrefVisibility(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefVisibility>>;
104
+ replaceOnePrefVisibility(opts: ReplaceOneOptionsCRUD<InPrefVisibility>): Promise<OperationResult>;
105
+ deleteOnePrefVisibility(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
106
+ deleteManyPrefVisibilities(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
107
+ queryPrefLanguages(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefLanguage[]>>;
108
+ insertOnePrefLanguage(opts: InsertOneOptionsCRUD<InPrefLanguage>): Promise<OperationResult>;
109
+ findOnePrefLanguage(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefLanguage>>;
110
+ replaceOnePrefLanguage(opts: ReplaceOneOptionsCRUD<InPrefLanguage>): Promise<OperationResult>;
111
+ deleteOnePrefLanguage(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
112
+ deleteManyPrefLanguages(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
113
+ queryPrefNotif(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefNotif[]>>;
114
+ insertOnePrefNotif(opts: InsertOneOptionsCRUD<InPrefNotif>): Promise<OperationResult>;
115
+ findOnePrefNotif(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefNotif>>;
116
+ replaceOnePrefNotif(opts: ReplaceOneOptionsCRUD<InPrefNotif>): Promise<OperationResult>;
117
+ deleteOnePrefNotif(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
118
+ deleteManyPrefNotif(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
119
+ queryPrefEmails(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefEmail[]>>;
120
+ insertOnePrefEmail(opts: InsertOneOptionsCRUD<InPrefEmail>): Promise<OperationResult>;
121
+ findOnePrefEmail(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefEmail>>;
122
+ replaceOnePrefEmail(opts: ReplaceOneOptionsCRUD<InPrefEmail>): Promise<OperationResult>;
123
+ deleteOnePrefEmail(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
124
+ deleteManyPrefEmails(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
125
+ queryPrefTutorials(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PrefTutorial[]>>;
126
+ insertOnePrefTutorial(opts: InsertOneOptionsCRUD<InPrefTutorial>): Promise<OperationResult>;
127
+ findOnePrefTutorial(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PrefTutorial>>;
128
+ replaceOnePrefTutorial(opts: ReplaceOneOptionsCRUD<InPrefTutorial>): Promise<OperationResult>;
129
+ deleteOnePrefTutorial(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
130
+ deleteManyPrefTutorials(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
131
+ }
132
+ export declare function newPreferencesClient(opts: PreferencesClientOptions): PreferencesClient;
@@ -0,0 +1,248 @@
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 { ColPreferencesClients, ColPreferencesCompanies, ColPreferencesEmails, ColPreferencesEmployees, ColPreferencesLanguages, ColPreferencesNotif, ColPreferencesPayments, ColPreferencesTutorials, ColPreferencesVisibilities, SvcPreferences, } from "@fabriktor/schema";
7
+ import { newCRUDClient } from "../core/crud.js";
8
+ export class PreferencesClient {
9
+ pref_payments;
10
+ pref_clients;
11
+ pref_employees;
12
+ pref_companies;
13
+ pref_visibilities;
14
+ pref_languages;
15
+ pref_notif;
16
+ pref_emails;
17
+ pref_tutorials;
18
+ constructor(opts) {
19
+ this.pref_payments = newCRUDClient({
20
+ http: opts.http,
21
+ base_url: opts.base_url,
22
+ svc: SvcPreferences,
23
+ col: ColPreferencesPayments,
24
+ get_token: opts.get_token,
25
+ });
26
+ this.pref_clients = newCRUDClient({
27
+ http: opts.http,
28
+ base_url: opts.base_url,
29
+ svc: SvcPreferences,
30
+ col: ColPreferencesClients,
31
+ get_token: opts.get_token,
32
+ });
33
+ this.pref_employees = newCRUDClient({
34
+ http: opts.http,
35
+ base_url: opts.base_url,
36
+ svc: SvcPreferences,
37
+ col: ColPreferencesEmployees,
38
+ get_token: opts.get_token,
39
+ });
40
+ this.pref_companies = newCRUDClient({
41
+ http: opts.http,
42
+ base_url: opts.base_url,
43
+ svc: SvcPreferences,
44
+ col: ColPreferencesCompanies,
45
+ get_token: opts.get_token,
46
+ });
47
+ this.pref_visibilities = newCRUDClient({
48
+ http: opts.http,
49
+ base_url: opts.base_url,
50
+ svc: SvcPreferences,
51
+ col: ColPreferencesVisibilities,
52
+ get_token: opts.get_token,
53
+ });
54
+ this.pref_languages = newCRUDClient({
55
+ http: opts.http,
56
+ base_url: opts.base_url,
57
+ svc: SvcPreferences,
58
+ col: ColPreferencesLanguages,
59
+ get_token: opts.get_token,
60
+ });
61
+ this.pref_notif = newCRUDClient({
62
+ http: opts.http,
63
+ base_url: opts.base_url,
64
+ svc: SvcPreferences,
65
+ col: ColPreferencesNotif,
66
+ get_token: opts.get_token,
67
+ });
68
+ this.pref_emails = newCRUDClient({
69
+ http: opts.http,
70
+ base_url: opts.base_url,
71
+ svc: SvcPreferences,
72
+ col: ColPreferencesEmails,
73
+ get_token: opts.get_token,
74
+ });
75
+ this.pref_tutorials = newCRUDClient({
76
+ http: opts.http,
77
+ base_url: opts.base_url,
78
+ svc: SvcPreferences,
79
+ col: ColPreferencesTutorials,
80
+ get_token: opts.get_token,
81
+ });
82
+ }
83
+ async queryPrefPayments(opts) {
84
+ return await this.pref_payments.query(opts);
85
+ }
86
+ async insertOnePrefPayment(opts) {
87
+ return await this.pref_payments.insertOne(opts);
88
+ }
89
+ async findOnePrefPayment(opts) {
90
+ return await this.pref_payments.findOne(opts);
91
+ }
92
+ async replaceOnePrefPayment(opts) {
93
+ return await this.pref_payments.replaceOne(opts);
94
+ }
95
+ async deleteOnePrefPayment(opts) {
96
+ return await this.pref_payments.deleteOne(opts);
97
+ }
98
+ async deleteManyPrefPayments(opts) {
99
+ return await this.pref_payments.deleteMany(opts);
100
+ }
101
+ async queryPrefClients(opts) {
102
+ return await this.pref_clients.query(opts);
103
+ }
104
+ async insertOnePrefClient(opts) {
105
+ return await this.pref_clients.insertOne(opts);
106
+ }
107
+ async findOnePrefClient(opts) {
108
+ return await this.pref_clients.findOne(opts);
109
+ }
110
+ async replaceOnePrefClient(opts) {
111
+ return await this.pref_clients.replaceOne(opts);
112
+ }
113
+ async deleteOnePrefClient(opts) {
114
+ return await this.pref_clients.deleteOne(opts);
115
+ }
116
+ async deleteManyPrefClients(opts) {
117
+ return await this.pref_clients.deleteMany(opts);
118
+ }
119
+ async queryPrefEmployees(opts) {
120
+ return await this.pref_employees.query(opts);
121
+ }
122
+ async insertOnePrefEmployee(opts) {
123
+ return await this.pref_employees.insertOne(opts);
124
+ }
125
+ async findOnePrefEmployee(opts) {
126
+ return await this.pref_employees.findOne(opts);
127
+ }
128
+ async replaceOnePrefEmployee(opts) {
129
+ return await this.pref_employees.replaceOne(opts);
130
+ }
131
+ async deleteOnePrefEmployee(opts) {
132
+ return await this.pref_employees.deleteOne(opts);
133
+ }
134
+ async deleteManyPrefEmployees(opts) {
135
+ return await this.pref_employees.deleteMany(opts);
136
+ }
137
+ async queryPrefCompanies(opts) {
138
+ return await this.pref_companies.query(opts);
139
+ }
140
+ async insertOnePrefCompany(opts) {
141
+ return await this.pref_companies.insertOne(opts);
142
+ }
143
+ async findOnePrefCompany(opts) {
144
+ return await this.pref_companies.findOne(opts);
145
+ }
146
+ async replaceOnePrefCompany(opts) {
147
+ return await this.pref_companies.replaceOne(opts);
148
+ }
149
+ async deleteOnePrefCompany(opts) {
150
+ return await this.pref_companies.deleteOne(opts);
151
+ }
152
+ async deleteManyPrefCompanies(opts) {
153
+ return await this.pref_companies.deleteMany(opts);
154
+ }
155
+ async queryPrefVisibilities(opts) {
156
+ return await this.pref_visibilities.query(opts);
157
+ }
158
+ async insertOnePrefVisibility(opts) {
159
+ return await this.pref_visibilities.insertOne(opts);
160
+ }
161
+ async findOnePrefVisibility(opts) {
162
+ return await this.pref_visibilities.findOne(opts);
163
+ }
164
+ async replaceOnePrefVisibility(opts) {
165
+ return await this.pref_visibilities.replaceOne(opts);
166
+ }
167
+ async deleteOnePrefVisibility(opts) {
168
+ return await this.pref_visibilities.deleteOne(opts);
169
+ }
170
+ async deleteManyPrefVisibilities(opts) {
171
+ return await this.pref_visibilities.deleteMany(opts);
172
+ }
173
+ async queryPrefLanguages(opts) {
174
+ return await this.pref_languages.query(opts);
175
+ }
176
+ async insertOnePrefLanguage(opts) {
177
+ return await this.pref_languages.insertOne(opts);
178
+ }
179
+ async findOnePrefLanguage(opts) {
180
+ return await this.pref_languages.findOne(opts);
181
+ }
182
+ async replaceOnePrefLanguage(opts) {
183
+ return await this.pref_languages.replaceOne(opts);
184
+ }
185
+ async deleteOnePrefLanguage(opts) {
186
+ return await this.pref_languages.deleteOne(opts);
187
+ }
188
+ async deleteManyPrefLanguages(opts) {
189
+ return await this.pref_languages.deleteMany(opts);
190
+ }
191
+ async queryPrefNotif(opts) {
192
+ return await this.pref_notif.query(opts);
193
+ }
194
+ async insertOnePrefNotif(opts) {
195
+ return await this.pref_notif.insertOne(opts);
196
+ }
197
+ async findOnePrefNotif(opts) {
198
+ return await this.pref_notif.findOne(opts);
199
+ }
200
+ async replaceOnePrefNotif(opts) {
201
+ return await this.pref_notif.replaceOne(opts);
202
+ }
203
+ async deleteOnePrefNotif(opts) {
204
+ return await this.pref_notif.deleteOne(opts);
205
+ }
206
+ async deleteManyPrefNotif(opts) {
207
+ return await this.pref_notif.deleteMany(opts);
208
+ }
209
+ async queryPrefEmails(opts) {
210
+ return await this.pref_emails.query(opts);
211
+ }
212
+ async insertOnePrefEmail(opts) {
213
+ return await this.pref_emails.insertOne(opts);
214
+ }
215
+ async findOnePrefEmail(opts) {
216
+ return await this.pref_emails.findOne(opts);
217
+ }
218
+ async replaceOnePrefEmail(opts) {
219
+ return await this.pref_emails.replaceOne(opts);
220
+ }
221
+ async deleteOnePrefEmail(opts) {
222
+ return await this.pref_emails.deleteOne(opts);
223
+ }
224
+ async deleteManyPrefEmails(opts) {
225
+ return await this.pref_emails.deleteMany(opts);
226
+ }
227
+ async queryPrefTutorials(opts) {
228
+ return await this.pref_tutorials.query(opts);
229
+ }
230
+ async insertOnePrefTutorial(opts) {
231
+ return await this.pref_tutorials.insertOne(opts);
232
+ }
233
+ async findOnePrefTutorial(opts) {
234
+ return await this.pref_tutorials.findOne(opts);
235
+ }
236
+ async replaceOnePrefTutorial(opts) {
237
+ return await this.pref_tutorials.replaceOne(opts);
238
+ }
239
+ async deleteOnePrefTutorial(opts) {
240
+ return await this.pref_tutorials.deleteOne(opts);
241
+ }
242
+ async deleteManyPrefTutorials(opts) {
243
+ return await this.pref_tutorials.deleteMany(opts);
244
+ }
245
+ }
246
+ export function newPreferencesClient(opts) {
247
+ return new PreferencesClient(opts);
248
+ }
@@ -63,15 +63,34 @@ export class UsersClient {
63
63
  },
64
64
  });
65
65
  }
66
+ // public async resolveUsername(
67
+ // opts: ResolveUsernameOptions,
68
+ // ): Promise<Op<string>> {
69
+ // return await this.http.do<PLUsersResolveUsername, Op<string>>({
70
+ // base_url: this.base_url,
71
+ // path: userPath(PathUsersResolveUsername),
72
+ // method: HTTPMethodPost,
73
+ // body: {
74
+ // username: opts.username,
75
+ // },
76
+ // });
77
+ // }
66
78
  async resolveUsername(opts) {
67
- return await this.http.do({
79
+ const body = {
80
+ username: opts.username,
81
+ };
82
+ console.log("[client/users.resolveUsername] request", {
83
+ path: userPath(PathUsersResolveUsername),
84
+ body,
85
+ });
86
+ const out = await this.http.do({
68
87
  base_url: this.base_url,
69
88
  path: userPath(PathUsersResolveUsername),
70
89
  method: HTTPMethodPost,
71
- body: {
72
- username: opts.username,
73
- },
90
+ body,
74
91
  });
92
+ console.log("[client/users.resolveUsername] response", out);
93
+ return out;
75
94
  }
76
95
  async match(opts) {
77
96
  const token = await requiredToken(this.get_token);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/client",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
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.14"
20
+ "@fabriktor/schema": "^0.0.15"
21
21
  }
22
22
  }