create-disposabl-app 0.3.2 → 0.3.4

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.
Files changed (45) hide show
  1. package/dist/index.js +31 -6
  2. package/dist/templates/default/apps/web/src/routeTree.gen.ts +49 -5
  3. package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.api-keys.tsx +154 -0
  4. package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.tsx +23 -5
  5. package/dist/templates/default/bun.lock +237 -39
  6. package/dist/templates/default/disposabl.json +3 -1
  7. package/dist/templates/default/package.json +4 -2
  8. package/dist/templates/default/packages/backend/generate.ts +123 -0
  9. package/dist/templates/default/packages/backend/generated/openapi.json +190 -0
  10. package/dist/templates/default/packages/backend/generated/platforms.ts +3 -0
  11. package/dist/templates/default/packages/backend/package.json +3 -1
  12. package/dist/templates/default/packages/cli/README.md +17 -0
  13. package/dist/templates/default/packages/cli/auth.ts +301 -0
  14. package/dist/templates/default/packages/cli/build.ts +9 -0
  15. package/dist/templates/default/packages/cli/index.ts +146 -0
  16. package/dist/templates/default/packages/cli/package.json +35 -0
  17. package/dist/templates/default/packages/cli/tsconfig.json +15 -0
  18. package/dist/templates/default/packages/disposabl-kit/platforms.ts +4 -4
  19. package/dist/templates/default/packages/disposabl-kit/server/http.ts +44 -8
  20. package/dist/templates/default/packages/disposabl-kit/server/lib/platform-spec.ts +94 -5
  21. package/dist/templates/default/packages/sdk/README.md +20 -0
  22. package/dist/templates/default/packages/sdk/openapi-ts.config.ts +10 -0
  23. package/dist/templates/default/packages/sdk/package.json +31 -0
  24. package/dist/templates/default/packages/sdk/src/config.ts +11 -0
  25. package/dist/templates/default/packages/sdk/src/generated/client/client.gen.ts +300 -0
  26. package/dist/templates/default/packages/sdk/src/generated/client/index.ts +27 -0
  27. package/dist/templates/default/packages/sdk/src/generated/client/types.gen.ts +238 -0
  28. package/dist/templates/default/packages/sdk/src/generated/client/utils.gen.ts +337 -0
  29. package/dist/templates/default/packages/sdk/src/generated/client.gen.ts +28 -0
  30. package/dist/templates/default/packages/sdk/src/generated/core/auth.gen.ts +49 -0
  31. package/dist/templates/default/packages/sdk/src/generated/core/bodySerializer.gen.ts +96 -0
  32. package/dist/templates/default/packages/sdk/src/generated/core/params.gen.ts +188 -0
  33. package/dist/templates/default/packages/sdk/src/generated/core/pathSerializer.gen.ts +186 -0
  34. package/dist/templates/default/packages/sdk/src/generated/core/queryKeySerializer.gen.ts +134 -0
  35. package/dist/templates/default/packages/sdk/src/generated/core/serverSentEvents.gen.ts +265 -0
  36. package/dist/templates/default/packages/sdk/src/generated/core/types.gen.ts +126 -0
  37. package/dist/templates/default/packages/sdk/src/generated/core/utils.gen.ts +146 -0
  38. package/dist/templates/default/packages/sdk/src/generated/index.ts +18 -0
  39. package/dist/templates/default/packages/sdk/src/generated/sdk.gen.ts +82 -0
  40. package/dist/templates/default/packages/sdk/src/generated/types.gen.ts +134 -0
  41. package/dist/templates/default/packages/sdk/src/index.ts +3 -0
  42. package/dist/templates/default/packages/sdk/tsconfig.build.json +10 -0
  43. package/dist/templates/default/packages/sdk/tsconfig.json +12 -0
  44. package/dist/templates/default/turbo.json +9 -0
  45. package/package.json +1 -1
@@ -0,0 +1,146 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ import type { BodySerializer, QuerySerializer } from "./bodySerializer.gen.js";
4
+ import {
5
+ type ArraySeparatorStyle,
6
+ serializeArrayParam,
7
+ serializeObjectParam,
8
+ serializePrimitiveParam,
9
+ } from "./pathSerializer.gen.js";
10
+
11
+ export interface PathSerializer {
12
+ path: Record<string, unknown>;
13
+ url: string;
14
+ }
15
+
16
+ export const PATH_PARAM_RE: RegExp = /\{[^{}]+\}/g;
17
+
18
+ export const defaultPathSerializer = ({
19
+ path,
20
+ url: _url,
21
+ }: PathSerializer): string => {
22
+ let url = _url;
23
+ const matches = _url.match(PATH_PARAM_RE);
24
+ if (matches) {
25
+ for (const match of matches) {
26
+ let explode = false;
27
+ let name = match.substring(1, match.length - 1);
28
+ let style: ArraySeparatorStyle = "simple";
29
+
30
+ if (name.endsWith("*")) {
31
+ explode = true;
32
+ name = name.substring(0, name.length - 1);
33
+ }
34
+
35
+ if (name.startsWith(".")) {
36
+ name = name.substring(1);
37
+ style = "label";
38
+ } else if (name.startsWith(";")) {
39
+ name = name.substring(1);
40
+ style = "matrix";
41
+ }
42
+
43
+ const value = path[name];
44
+
45
+ if (value === undefined || value === null) {
46
+ continue;
47
+ }
48
+
49
+ if (Array.isArray(value)) {
50
+ url = url.replace(
51
+ match,
52
+ serializeArrayParam({ explode, name, style, value }),
53
+ );
54
+ continue;
55
+ }
56
+
57
+ if (typeof value === "object") {
58
+ url = url.replace(
59
+ match,
60
+ serializeObjectParam({
61
+ explode,
62
+ name,
63
+ style,
64
+ value: value as Record<string, unknown>,
65
+ valueOnly: true,
66
+ }),
67
+ );
68
+ continue;
69
+ }
70
+
71
+ if (style === "matrix") {
72
+ url = url.replace(
73
+ match,
74
+ `;${serializePrimitiveParam({
75
+ name,
76
+ value: value as string,
77
+ })}`,
78
+ );
79
+ continue;
80
+ }
81
+
82
+ const replaceValue = encodeURIComponent(
83
+ style === "label" ? `.${value as string}` : (value as string),
84
+ );
85
+ url = url.replace(match, replaceValue);
86
+ }
87
+ }
88
+ return url;
89
+ };
90
+
91
+ export const getUrl = ({
92
+ baseUrl,
93
+ path,
94
+ query,
95
+ querySerializer,
96
+ url: _url,
97
+ }: {
98
+ baseUrl?: string;
99
+ path?: Record<string, unknown>;
100
+ query?: Record<string, unknown>;
101
+ querySerializer: QuerySerializer;
102
+ url: string;
103
+ }): string => {
104
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
105
+ let url = (baseUrl ?? "") + pathUrl;
106
+ if (path) {
107
+ url = defaultPathSerializer({ path, url });
108
+ }
109
+ let search = query ? querySerializer(query) : "";
110
+ if (search.startsWith("?")) {
111
+ search = search.substring(1);
112
+ }
113
+ if (search) {
114
+ url += `?${search}`;
115
+ }
116
+ return url;
117
+ };
118
+
119
+ export function getValidRequestBody(options: {
120
+ body?: unknown;
121
+ bodySerializer?: BodySerializer | null;
122
+ serializedBody?: unknown;
123
+ }): unknown {
124
+ const hasBody = options.body !== undefined;
125
+ const isSerializedBody = hasBody && options.bodySerializer;
126
+
127
+ if (isSerializedBody) {
128
+ if ("serializedBody" in options) {
129
+ const hasSerializedBody =
130
+ options.serializedBody !== undefined && options.serializedBody !== "";
131
+
132
+ return hasSerializedBody ? options.serializedBody : null;
133
+ }
134
+
135
+ // not all clients implement a serializedBody property (i.e., client-axios)
136
+ return options.body !== "" ? options.body : null;
137
+ }
138
+
139
+ // plain/text body
140
+ if (hasBody) {
141
+ return options.body;
142
+ }
143
+
144
+ // no body was provided
145
+ return undefined;
146
+ }
@@ -0,0 +1,18 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ export { type Options, todosCreate, todosGet, todosList } from "./sdk.gen.js";
4
+ export type {
5
+ ClientOptions,
6
+ TodosCreateData,
7
+ TodosCreateErrors,
8
+ TodosCreateResponse,
9
+ TodosCreateResponses,
10
+ TodosGetData,
11
+ TodosGetErrors,
12
+ TodosGetResponse,
13
+ TodosGetResponses,
14
+ TodosListData,
15
+ TodosListErrors,
16
+ TodosListResponse,
17
+ TodosListResponses,
18
+ } from "./types.gen.js";
@@ -0,0 +1,82 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ import { client } from "./client.gen.js";
4
+ import type {
5
+ Client,
6
+ ClientMeta,
7
+ Options as Options2,
8
+ RequestResult,
9
+ TDataShape,
10
+ } from "./client/index.js";
11
+ import type {
12
+ TodosCreateData,
13
+ TodosCreateErrors,
14
+ TodosCreateResponses,
15
+ TodosGetData,
16
+ TodosGetErrors,
17
+ TodosGetResponses,
18
+ TodosListData,
19
+ TodosListErrors,
20
+ TodosListResponses,
21
+ } from "./types.gen.js";
22
+
23
+ export type Options<
24
+ TData extends TDataShape = TDataShape,
25
+ ThrowOnError extends boolean = boolean,
26
+ TResponse = unknown,
27
+ > = Options2<TData, ThrowOnError, TResponse> & {
28
+ /**
29
+ * You can provide a client instance returned by `createClient()` instead of
30
+ * individual options. This might be also useful if you want to implement a
31
+ * custom client.
32
+ */
33
+ client?: Client;
34
+ /**
35
+ * You can pass arbitrary values through the `meta` object. This can be
36
+ * used to access values that aren't defined as part of the SDK function.
37
+ */
38
+ meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
39
+ };
40
+
41
+ export const todosCreate = <ThrowOnError extends boolean = false>(
42
+ options: Options<TodosCreateData, ThrowOnError>,
43
+ ): RequestResult<TodosCreateResponses, TodosCreateErrors, ThrowOnError> =>
44
+ (options.client ?? client).post<
45
+ TodosCreateResponses,
46
+ TodosCreateErrors,
47
+ ThrowOnError
48
+ >({
49
+ security: [{ scheme: "bearer", type: "http" }],
50
+ url: "/api/todos/create",
51
+ ...options,
52
+ headers: {
53
+ "Content-Type": "application/json",
54
+ ...options.headers,
55
+ },
56
+ });
57
+
58
+ export const todosGet = <ThrowOnError extends boolean = false>(
59
+ options: Options<TodosGetData, ThrowOnError>,
60
+ ): RequestResult<TodosGetResponses, TodosGetErrors, ThrowOnError> =>
61
+ (options.client ?? client).get<
62
+ TodosGetResponses,
63
+ TodosGetErrors,
64
+ ThrowOnError
65
+ >({
66
+ security: [{ scheme: "bearer", type: "http" }],
67
+ url: "/api/todos/get",
68
+ ...options,
69
+ });
70
+
71
+ export const todosList = <ThrowOnError extends boolean = false>(
72
+ options?: Options<TodosListData, ThrowOnError>,
73
+ ): RequestResult<TodosListResponses, TodosListErrors, ThrowOnError> =>
74
+ (options?.client ?? client).get<
75
+ TodosListResponses,
76
+ TodosListErrors,
77
+ ThrowOnError
78
+ >({
79
+ security: [{ scheme: "bearer", type: "http" }],
80
+ url: "/api/todos/list",
81
+ ...options,
82
+ });
@@ -0,0 +1,134 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ export type ClientOptions = {
4
+ baseUrl: `${string}://${string}` | (string & {});
5
+ };
6
+
7
+ export type TodosCreateData = {
8
+ body: {
9
+ title: string;
10
+ };
11
+ path?: never;
12
+ query?: never;
13
+ url: "/api/todos/create";
14
+ };
15
+
16
+ export type TodosCreateErrors = {
17
+ /**
18
+ * Invalid arguments
19
+ */
20
+ 400: unknown;
21
+ /**
22
+ * Authentication required
23
+ */
24
+ 401: unknown;
25
+ /**
26
+ * Insufficient scope
27
+ */
28
+ 403: unknown;
29
+ /**
30
+ * Internal error
31
+ */
32
+ 500: unknown;
33
+ };
34
+
35
+ export type TodosCreateResponses = {
36
+ /**
37
+ * ID of a document in "todos"
38
+ */
39
+ 200: string;
40
+ };
41
+
42
+ export type TodosCreateResponse =
43
+ TodosCreateResponses[keyof TodosCreateResponses];
44
+
45
+ export type TodosGetData = {
46
+ body?: never;
47
+ path?: never;
48
+ query: {
49
+ /**
50
+ * ID of a document in "todos"
51
+ */
52
+ id: string;
53
+ };
54
+ url: "/api/todos/get";
55
+ };
56
+
57
+ export type TodosGetErrors = {
58
+ /**
59
+ * Invalid arguments
60
+ */
61
+ 400: unknown;
62
+ /**
63
+ * Authentication required
64
+ */
65
+ 401: unknown;
66
+ /**
67
+ * Insufficient scope
68
+ */
69
+ 403: unknown;
70
+ /**
71
+ * Internal error
72
+ */
73
+ 500: unknown;
74
+ };
75
+
76
+ export type TodosGetResponses = {
77
+ /**
78
+ * Success
79
+ */
80
+ 200: {
81
+ userId: string;
82
+ title: string;
83
+ /**
84
+ * ID of a document in "todos"
85
+ */
86
+ _id: string;
87
+ _creationTime: number;
88
+ } | null;
89
+ };
90
+
91
+ export type TodosGetResponse = TodosGetResponses[keyof TodosGetResponses];
92
+
93
+ export type TodosListData = {
94
+ body?: never;
95
+ path?: never;
96
+ query?: never;
97
+ url: "/api/todos/list";
98
+ };
99
+
100
+ export type TodosListErrors = {
101
+ /**
102
+ * Invalid arguments
103
+ */
104
+ 400: unknown;
105
+ /**
106
+ * Authentication required
107
+ */
108
+ 401: unknown;
109
+ /**
110
+ * Insufficient scope
111
+ */
112
+ 403: unknown;
113
+ /**
114
+ * Internal error
115
+ */
116
+ 500: unknown;
117
+ };
118
+
119
+ export type TodosListResponses = {
120
+ /**
121
+ * Success
122
+ */
123
+ 200: Array<{
124
+ userId: string;
125
+ title: string;
126
+ /**
127
+ * ID of a document in "todos"
128
+ */
129
+ _id: string;
130
+ _creationTime: number;
131
+ }>;
132
+ };
133
+
134
+ export type TodosListResponse = TodosListResponses[keyof TodosListResponses];
@@ -0,0 +1,3 @@
1
+ export * from "./generated/sdk.gen.js";
2
+ export * from "./generated/types.gen.js";
3
+ export { client } from "./generated/client.gen.js";
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": false,
5
+ "declaration": true,
6
+ "outDir": "dist",
7
+ "rootDir": "src"
8
+ },
9
+ "include": ["src/**/*.ts"]
10
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
9
+ "noEmit": true
10
+ },
11
+ "include": ["src/**/*.ts", "openapi-ts.config.ts"]
12
+ }
@@ -43,6 +43,15 @@
43
43
  "cache": false,
44
44
  "persistent": true,
45
45
  "passThroughEnv": ["VITE_*"]
46
+ },
47
+ "@disposabl/backend#dev": {
48
+ "cache": false,
49
+ "persistent": true,
50
+ "with": ["@disposabl/backend#generate:watch"]
51
+ },
52
+ "generate:watch": {
53
+ "cache": false,
54
+ "persistent": true
46
55
  }
47
56
  },
48
57
  "globalDependencies": ["disposabl.json"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-disposabl-app",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Create a Disposabl app",
5
5
  "type": "module",
6
6
  "license": "MIT",