Skip to content

Commit 2a8aedc

Browse files
committed
backend-id: bootstrap
1 parent f57bffd commit 2a8aedc

File tree

30 files changed

+921
-343
lines changed

30 files changed

+921
-343
lines changed

lib/_tau/src/impl.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ export const lte = (max: number) => (val: number) => eq(max)(val) || lt(max)(val
7070
export const noop = (): void => {}
7171
export const undef = (): undefined => {}
7272

73-
export const is_port = (x: string) => {
74-
const n = Number.parseInt(x, 10)
75-
const gt_0 = gt(0)
76-
const lt_65535 = lt(65535)
77-
78-
return !x.startsWith("0") && !is_nan(n) && gt_0(n) && lt_65535(n)
79-
}
80-
8173
export const keys_of: <T extends object>(o: T) => (keyof T)[] = o => {
8274
return Object.keys(o) as any
8375
}

lib/b-email-strategy-rusender/src/b-email-strategy-rusender.constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
export const URL = "https://api.beta.rusender.ru/api/v1/external-mails/send"
2323
export const METHOD = "POST"
2424

25-
export const X_API_KEY_HEADER_KEY = "x-api-key"
25+
export const X_API_KEY_HEADER_KEY = "X-Api-Key"
2626

2727
// TODO Move out
28-
export const CONTENT_TYPE_HEADER = ["content-type", "application/json"] as const
28+
export const CONTENT_TYPE_HEADER = ["Content-Type", "application/json"] as const

lib/b-email-strategy-rusender/src/b-email-strategy-rusender.impl.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import { type Oath, oath } from "@ordo-pink/oss-oath"
2323
import { core } from "@ordo-pink/sdk-core"
2424

25-
import * as CONST from "./b-email-strategy-rusender.constants"
26-
import type * as Types from "./b-email-strategy-rusender.types"
25+
import * as LIB from "./b-email-strategy-rusender.constants"
26+
import type * as Lib from "./b-email-strategy-rusender.types"
2727

28-
export const create: Types.Create = (k, s) => ({
28+
export const create: Lib.Create = (k, s) => ({
2929
send: (idempotencyKey, subject, html, to, from = s, previewTitle, headers, cc, bcc) =>
3030
oath
3131
.all([to_json({ idempotencyKey, mail: { bcc, cc, from, headers, html, previewTitle, subject, to } }), create_headers(k)])
@@ -42,12 +42,12 @@ const ignore_response = core.fns.v
4242

4343
type SendRequest = (args: [string, Headers]) => Oath.Instance<Response, Error>
4444
const send_request: SendRequest = ([body, headers]) =>
45-
oath.from_promise(() => fetch(CONST.URL, { method: CONST.METHOD, body, headers }))
45+
oath.from_promise(() => fetch(LIB.URL, { method: LIB.METHOD, body, headers }))
4646

47-
const create_headers = (k: Types.ApiKey) =>
47+
const create_headers = (k: Lib.ApiKey) =>
4848
oath
4949
.of(new Headers())
50-
.pipe(oath.ops.tap(h => h.set(...CONST.CONTENT_TYPE_HEADER)))
50+
.pipe(oath.ops.tap(h => h.set(...LIB.CONTENT_TYPE_HEADER)))
5151
.pipe(oath.ops.tap(h => h.set(...create_api_key_header(k))))
5252

53-
const create_api_key_header = (k: Types.ApiKey) => [CONST.X_API_KEY_HEADER_KEY, k] as const
53+
const create_api_key_header = (k: Lib.ApiKey) => [LIB.X_API_KEY_HEADER_KEY, k] as const

lib/b-email-strategy-rusender/src/b-email-strategy-rusender.types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2020
*/
2121

22-
import type * as EMAIL_STRATEGY_RUSENDER from "./b-email-strategy-rusender.constants"
2322
import type { Server } from "@ordo-pink/sdk-server"
2423

24+
import type * as LIB from "./b-email-strategy-rusender.constants"
25+
2526
export type ApiKey = string
2627
export type From = Server.Email.EmailGuy
2728
export type Args = [api_key: ApiKey, sender: From]
2829
export type Instance = Server.Email.Strategy
2930

3031
export type Create = (...args: Args) => Instance
3132

32-
export type CreateApiKeyHeader = (key: ApiKey) => [typeof EMAIL_STRATEGY_RUSENDER.X_API_KEY_HEADER_KEY, ApiKey]
33+
export type CreateApiKeyHeader = (key: ApiKey) => [typeof LIB.X_API_KEY_HEADER_KEY, ApiKey]

lib/b-repository-data-fs/src/b-repository-data-fs.impl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import { resolve } from "path"
3030
import { type Core, core } from "@ordo-pink/sdk-core"
3131
import { oath } from "@ordo-pink/oss-oath"
3232

33-
import * as Types from "./b-repository-data-fs.types"
33+
import type * as Lib from "./b-repository-data-fs.types"
3434

35-
export const create: Types.Create = root => {
35+
export const create: Lib.Create = root => {
3636
const get_path = get_path_from_root(root)
3737

3838
return {
@@ -65,8 +65,8 @@ export const create: Types.Create = root => {
6565

6666
// --- Internal ---
6767

68-
const to_already_exists_rrr = () => core.rrr.eexist("File already exists")
69-
const to_not_found_rrr = () => core.rrr.enoent("File not found")
68+
const to_already_exists_rrr = () => core.rrr.eexist("File already exists", null)
69+
const to_not_found_rrr = () => core.rrr.enoent("File not found", null)
7070
const to_io_rrr = (e: unknown) => core.rrr.eio("Failed to store local data", e)
7171

7272
const get_file = (path: string) => oath.try(() => Bun.file(path)).pipe(oath.ops.rmap(to_io_rrr))

lib/b-repository-data-s3/src/b-repository-data-s3.impl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import { S3Client, S3File } from "bun"
2424
import { type Core, core } from "@ordo-pink/sdk-core"
2525
import { oath } from "@ordo-pink/oss-oath"
2626

27-
import type * as Types from "./b-repository-data-s3.types"
27+
import type * as Lib from "./b-repository-data-s3.types"
2828

29-
export const create: Types.Create = (accessKeyId, secretAccessKey, region, bucket, endpoint) => {
29+
export const create: Lib.Create = (accessKeyId, secretAccessKey, region, bucket, endpoint) => {
3030
const s3 = new Bun.S3Client({ accessKeyId, bucket, endpoint, region, secretAccessKey })
3131

3232
return {
@@ -60,8 +60,8 @@ export const create: Types.Create = (accessKeyId, secretAccessKey, region, bucke
6060

6161
// --- Internal ---
6262

63-
const already_exists_rrr = () => core.rrr.eexist("File already exists")
64-
const not_found_rrr = () => core.rrr.enoent("File not found")
63+
const already_exists_rrr = () => core.rrr.eexist("File already exists", null)
64+
const not_found_rrr = () => core.rrr.enoent("File not found", null)
6565
const io_rrr = (e: unknown) => core.rrr.eio("Failed to connect to S3", e)
6666

6767
const get_file = (s3: S3Client) => (path: string) =>

lib/b-repository-user-repository-data/src/b-repository-user-repository-data.impl.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ import { type Core, core } from "@ordo-pink/sdk-core"
2323
import { type Server, server } from "@ordo-pink/sdk-server"
2424
import { oath } from "@ordo-pink/oss-oath"
2525

26-
import * as Types from "./b-repository-user-repository-data.types"
26+
import type * as Lib from "./b-repository-user-repository-data.types"
2727

28-
export const create: Types.Create = (repository, uid, fid, ufid) => {
28+
export const create: Lib.Create = (repository, uid, fid, ufid) => {
2929
let cache = get_cache_promise(repository, uid, fid)
30-
const cache0 = oath.from_promise<Types.Cache, never>(() => cache)
30+
const cache0 = oath.from_promise<Lib.Cache, never>(() => cache)
3131

32-
const read: Types.Instance["read"] = id =>
33-
repository.read(id, ufid).pipe(oath.ops.chain(from_stream0(() => core.rrr.eio("Cound not read user"))))
32+
const read: Lib.Instance["read"] = id =>
33+
repository.read(id, ufid).pipe(oath.ops.chain(from_stream0(() => core.rrr.eio("Cound not read user", id))))
3434

35-
const update_cache0 = (current_cache: Types.Cache) =>
35+
const update_cache0 = (current_cache: Lib.Cache) =>
3636
oath
3737
.try(() => JSON.stringify(current_cache))
3838
.pipe(oath.ops.chain(to_stream0()))
@@ -70,7 +70,7 @@ export const create: Types.Create = (repository, uid, fid, ufid) => {
7070

7171
read,
7272

73-
delete: id => repository.delete(id),
73+
delete: repository.delete,
7474

7575
update: (id, new_user) =>
7676
read(id).pipe(
@@ -135,8 +135,8 @@ const to_rrr = (message: string) => (error: unknown) => core.rrr.eio(message, er
135135
const get_cache_promise = (repository: Server.Data.Repository, uid: Core.User.Id, fid: Core.Data.Id) =>
136136
repository
137137
.read(uid, fid)
138-
.pipe(oath.ops.chain(stream => oath.from_promise(() => Bun.readableStreamToJSON(stream) as Promise<Types.Cache>)))
139-
.cata(oath.catas.or_else(() => ({ email: {}, ref: {} }) as Types.Cache))
138+
.pipe(oath.ops.chain(stream => oath.from_promise(() => Bun.readableStreamToJSON(stream) as Promise<Lib.Cache>)))
139+
.cata(oath.catas.or_else(() => ({ email: {}, ref: {} }) as Lib.Cache))
140140

141141
const to_stream0 =
142142
<$F>(on_error: (e: unknown) => $F = e => e as any) =>

lib/b-repository-user-repository-data/src/b-repository-user-repository-data.test.ts

Lines changed: 0 additions & 151 deletions
This file was deleted.

lib/b-repository-user-repository-data/src/b-repository-user-repository-data.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import type { Core } from "@ordo-pink/sdk-core"
2323
import type { Server } from "@ordo-pink/sdk-server"
2424

2525
export type Args = [
26-
repository_data: Server.Data.Repository,
26+
data_repository: Server.Data.Repository,
2727
cache_user_id: Core.User.Id,
2828
cache_file_id: Core.Data.Id,
2929
user_file_id: Core.Data.Id,

lib/b-server-id/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright 2025, 谢尔盖 ||↓ and the Ordo.pink contributors
3+
* SPDX-License-Identifier: AGPL-3.0-only
4+
*
5+
* Ordo.pink is an all-in-one team workspace.
6+
* Copyright (C) 2025 谢尔盖 ||↓ and the Ordo.pink contributors
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as published
10+
* by the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
export * as server_id from "./src/b-server-id.impl"
23+
export * as ServerId from "./src/b-server-id.types"

0 commit comments

Comments
 (0)