@tailor-platform/create-sdk 1.8.0 → 1.9.0
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 +2 -0
- package/package.json +1 -1
- package/templates/hello-world/.oxfmtrc.json +1 -1
- package/templates/hello-world/package.json +6 -1
- package/templates/hello-world/src/db/user.ts +18 -0
- package/templates/hello-world/src/generated/kysely-tailordb.ts +66 -0
- package/templates/hello-world/tailor.config.ts +7 -1
- package/templates/hello-world/tsconfig.json +1 -1
- package/templates/inventory-management/package.json +1 -1
- package/templates/multi-application/package.json +1 -1
- package/templates/testing/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -4,15 +4,20 @@
|
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"deploy": "tailor-sdk apply",
|
|
7
|
+
"generate": "tailor-sdk generate",
|
|
7
8
|
"format": "oxfmt --write .",
|
|
8
9
|
"format:check": "oxfmt --check .",
|
|
9
10
|
"lint": "oxlint --type-aware . && eslint --cache .",
|
|
10
11
|
"lint:fix": "oxlint --type-aware --fix . && eslint --cache --fix .",
|
|
11
12
|
"typecheck": "tsc --noEmit"
|
|
12
13
|
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@tailor-platform/function-kysely-tailordb": "0.1.3",
|
|
16
|
+
"kysely": "0.28.10"
|
|
17
|
+
},
|
|
13
18
|
"devDependencies": {
|
|
14
19
|
"@eslint/js": "9.39.2",
|
|
15
|
-
"@tailor-platform/sdk": "1.
|
|
20
|
+
"@tailor-platform/sdk": "1.9.0",
|
|
16
21
|
"@types/node": "24.10.9",
|
|
17
22
|
"eslint": "9.39.2",
|
|
18
23
|
"eslint-plugin-oxlint": "1.39.0",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
db,
|
|
3
|
+
unsafeAllowAllGqlPermission,
|
|
4
|
+
unsafeAllowAllTypePermission,
|
|
5
|
+
} from "@tailor-platform/sdk";
|
|
6
|
+
|
|
7
|
+
export const user = db
|
|
8
|
+
.type("User", {
|
|
9
|
+
name: db.string().description("Name of the user"),
|
|
10
|
+
email: db.string().unique().description("Email address of the user"),
|
|
11
|
+
role: db.enum(["MANAGER", "STAFF"]),
|
|
12
|
+
...db.fields.timestamps(),
|
|
13
|
+
})
|
|
14
|
+
.features({
|
|
15
|
+
gqlOperations: "query",
|
|
16
|
+
})
|
|
17
|
+
.permission(unsafeAllowAllTypePermission)
|
|
18
|
+
.gqlPermission(unsafeAllowAllGqlPermission);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ColumnType,
|
|
3
|
+
Kysely,
|
|
4
|
+
type KyselyConfig,
|
|
5
|
+
type Transaction as KyselyTransaction,
|
|
6
|
+
type Insertable as KyselyInsertable,
|
|
7
|
+
type Selectable as KyselySelectable,
|
|
8
|
+
type Updateable as KyselyUpdateable,
|
|
9
|
+
} from "kysely";
|
|
10
|
+
import { TailordbDialect } from "@tailor-platform/function-kysely-tailordb";
|
|
11
|
+
|
|
12
|
+
type Timestamp = ColumnType<Date, Date | string, Date | string>;
|
|
13
|
+
type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
|
|
14
|
+
? ColumnType<S, I | undefined, U>
|
|
15
|
+
: ColumnType<T, T | undefined, T>;
|
|
16
|
+
|
|
17
|
+
export interface Namespace {
|
|
18
|
+
"main-db": {
|
|
19
|
+
User: {
|
|
20
|
+
id: Generated<string>;
|
|
21
|
+
name: string;
|
|
22
|
+
email: string;
|
|
23
|
+
role: "MANAGER" | "STAFF";
|
|
24
|
+
createdAt: Generated<Timestamp>;
|
|
25
|
+
updatedAt: Timestamp | null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getDB<const N extends keyof Namespace>(
|
|
31
|
+
namespace: N,
|
|
32
|
+
kyselyConfig?: Omit<KyselyConfig, "dialect">,
|
|
33
|
+
): Kysely<Namespace[N]> {
|
|
34
|
+
const client = new tailordb.Client({ namespace });
|
|
35
|
+
return new Kysely<Namespace[N]>({
|
|
36
|
+
dialect: new TailordbDialect(client),
|
|
37
|
+
...kyselyConfig,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type DB<N extends keyof Namespace = keyof Namespace> = ReturnType<typeof getDB<N>>;
|
|
42
|
+
|
|
43
|
+
export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =
|
|
44
|
+
K extends DB<infer N>
|
|
45
|
+
? KyselyTransaction<Namespace[N]>
|
|
46
|
+
: K extends keyof Namespace
|
|
47
|
+
? KyselyTransaction<Namespace[K]>
|
|
48
|
+
: never;
|
|
49
|
+
|
|
50
|
+
type TableName = {
|
|
51
|
+
[N in keyof Namespace]: keyof Namespace[N];
|
|
52
|
+
}[keyof Namespace];
|
|
53
|
+
export type Table<T extends TableName> = {
|
|
54
|
+
[N in keyof Namespace]: T extends keyof Namespace[N] ? Namespace[N][T]
|
|
55
|
+
: never;
|
|
56
|
+
}[keyof Namespace];
|
|
57
|
+
|
|
58
|
+
export type Insertable<T extends keyof Namespace[keyof Namespace]> = KyselyInsertable<
|
|
59
|
+
Table<T>
|
|
60
|
+
>;
|
|
61
|
+
export type Selectable<T extends keyof Namespace[keyof Namespace]> = KyselySelectable<
|
|
62
|
+
Table<T>
|
|
63
|
+
>;
|
|
64
|
+
export type Updateable<T extends keyof Namespace[keyof Namespace]> = KyselyUpdateable<
|
|
65
|
+
Table<T>
|
|
66
|
+
>;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { defineConfig } from "@tailor-platform/sdk";
|
|
1
|
+
import { defineConfig, defineGenerators } from "@tailor-platform/sdk";
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
4
|
name: "hello-world",
|
|
5
|
+
db: { "main-db": { files: [`./src/db/*.ts`] } },
|
|
5
6
|
resolver: { "main-resolver": { files: [`./src/resolvers/**/*.ts`] } },
|
|
6
7
|
});
|
|
8
|
+
|
|
9
|
+
export const generators = defineGenerators([
|
|
10
|
+
"@tailor-platform/kysely-type",
|
|
11
|
+
{ distPath: `./src/generated/kysely-tailordb.ts` },
|
|
12
|
+
]);
|