@truecodeio/sdk-core 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @boko/sdk-core
2
+
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - change package name
8
+
9
+ ## 0.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Override access property
14
+
15
+ ## 0.2.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Init packages
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@truecodeio/sdk-core",
3
+ "version": "0.2.2",
4
+ "type": "module",
5
+ "access": "public",
6
+ "scripts": {
7
+ "format:prettier:fix:all": "prettier --cache --write ./src",
8
+ "lint:eslint:fix:all": "eslint --cache --fix ./src"
9
+ },
10
+ "dependencies": {
11
+ "@boko/client-shared": "workspace:^",
12
+ "@boko/server": "workspace:^",
13
+ "@trpc/client": "^11.4.0",
14
+ "superjson": "^2.2.2",
15
+ "zod": "^3.25.63"
16
+ },
17
+ "devDependencies": {
18
+ "@boko/tsconfig": "workspace:^"
19
+ }
20
+ }
package/src/client.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { AppRouter } from "@boko/server";
2
+ import { createTRPCClient, httpBatchLink } from "@trpc/client";
3
+ import superjson from "superjson";
4
+
5
+ type ClientConfig = {
6
+ apiKey: string;
7
+ };
8
+
9
+ export const createClient = ({ apiKey }: ClientConfig) => {
10
+ return createTRPCClient<AppRouter>({
11
+ links: [
12
+ httpBatchLink({
13
+ transformer: superjson,
14
+ // TODO: during build time, this SHOULD be replaced with the actual server URL
15
+ url: "http://localhost:3000",
16
+ headers: () => {
17
+ return {
18
+ Authorization: `ApiKey ${apiKey}`,
19
+ };
20
+ },
21
+ }),
22
+ ],
23
+ });
24
+ };
package/src/index.ts ADDED
@@ -0,0 +1,37 @@
1
+ import { createClient } from "./client.ts";
2
+ import { rootNodeSchema } from "@boko/client-shared/schemas/tree-nodes.ts";
3
+
4
+ type ClientOptions = {
5
+ apiKey: string;
6
+ };
7
+
8
+ export const createBokoClient = (options: ClientOptions) => {
9
+ const client = createClient({
10
+ apiKey: options.apiKey,
11
+ });
12
+
13
+ return {
14
+ getEligibleCampaign: async () => {
15
+ const eligibleCampaign = await client.getEligibleCampaign.query();
16
+
17
+ if (!eligibleCampaign) {
18
+ return null;
19
+ }
20
+
21
+ return {
22
+ ...eligibleCampaign,
23
+ template: {
24
+ ...eligibleCampaign.template,
25
+ // TODO: Do we need to parse the content here or on procedure level?
26
+ content: rootNodeSchema.parse(eligibleCampaign.template.content),
27
+ },
28
+ };
29
+ },
30
+ };
31
+ };
32
+
33
+ export type EligibleCampaign = NonNullable<
34
+ Awaited<
35
+ ReturnType<ReturnType<typeof createBokoClient>["getEligibleCampaign"]>
36
+ >
37
+ >;
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "@boko/tsconfig",
3
+ "compilerOptions": {
4
+ "allowImportingTsExtensions": true,
5
+ "moduleResolution": "bundler",
6
+ "module": "ES2022",
7
+ "paths": {
8
+ "@boko/sdk-core/*": ["./src/*"],
9
+ "@boko/server": ["../../apps/server/src"],
10
+ "@boko/server/*": ["../../apps/server/src/*"],
11
+ "@boko/client-shared/*": ["../client-shared/src/*"]
12
+ }
13
+ },
14
+ "include": ["src"]
15
+ }