phibelle-kit 1.0.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/.vscode/settings.json +22 -0
- package/README.md +27 -0
- package/convex/_generated/api.d.ts +53 -0
- package/convex/_generated/api.js +23 -0
- package/convex/_generated/dataModel.d.ts +60 -0
- package/convex/_generated/server.d.ts +143 -0
- package/convex/_generated/server.js +93 -0
- package/dist/clone-scene.d.ts +5 -0
- package/dist/clone-scene.js +39 -0
- package/dist/commands/clone-scene.d.ts +5 -0
- package/dist/commands/clone-scene.js +39 -0
- package/dist/commands/hello.d.ts +1 -0
- package/dist/commands/hello.js +10 -0
- package/dist/commands/login.d.ts +1 -0
- package/dist/commands/login.js +75 -0
- package/dist/commands/logout.d.ts +1 -0
- package/dist/commands/logout.js +16 -0
- package/dist/commands/watch-scene.d.ts +1 -0
- package/dist/commands/watch-scene.js +103 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +6 -0
- package/dist/convex/_generated/api.d.ts +11 -0
- package/dist/convex/_generated/api.js +21 -0
- package/dist/convex/_generated/server.d.ts +67 -0
- package/dist/convex/_generated/server.js +77 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +32 -0
- package/dist/lib/conf.d.ts +5 -0
- package/dist/lib/conf.js +23 -0
- package/dist/lib/constants.d.ts +4 -0
- package/dist/lib/constants.js +6 -0
- package/dist/lib/convex-client.d.ts +47 -0
- package/dist/lib/convex-client.js +80 -0
- package/dist/lib/file-system.d.ts +6 -0
- package/dist/lib/file-system.js +54 -0
- package/dist/lib/first-run-setup.d.ts +12 -0
- package/dist/lib/first-run-setup.js +45 -0
- package/dist/lib/folder.d.ts +3 -0
- package/dist/lib/folder.js +33 -0
- package/dist/lib/public-env.d.ts +3 -0
- package/dist/lib/public-env.js +3 -0
- package/dist/lib/scene-packaging.d.ts +6 -0
- package/dist/lib/scene-packaging.js +196 -0
- package/dist/lib/script-watcher.d.ts +9 -0
- package/dist/lib/script-watcher.js +90 -0
- package/dist/lib/types.d.ts +62 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +3 -0
- package/dist/lib/wait-for-token.d.ts +1 -0
- package/dist/lib/wait-for-token.js +30 -0
- package/dist/package/global-module.d.ts +1 -0
- package/dist/package/global-module.js +117 -0
- package/dist/package/npm-package.d.ts +1 -0
- package/dist/package/npm-package.js +16 -0
- package/dist/package/phibelle-module.d.ts +1 -0
- package/dist/package/phibelle-module.js +122 -0
- package/dist/package/setup.d.ts +4 -0
- package/dist/package/setup.js +41 -0
- package/dist/scene-setup/global-module.d.ts +1 -0
- package/dist/scene-setup/global-module.js +117 -0
- package/dist/scene-setup/npm-package.d.ts +1 -0
- package/dist/scene-setup/npm-package.js +13 -0
- package/dist/scene-setup/setup.d.ts +15 -0
- package/dist/scene-setup/setup.js +51 -0
- package/dist/watch-scene.d.ts +1 -0
- package/dist/watch-scene.js +103 -0
- package/package.json +44 -0
- package/src/commands/clone-scene.ts +46 -0
- package/src/commands/watch-scene.ts +117 -0
- package/src/convex/_generated/README.md +0 -0
- package/src/convex/_generated/api.d.ts +53 -0
- package/src/convex/_generated/api.js +23 -0
- package/src/convex/_generated/dataModel.d.ts +60 -0
- package/src/convex/_generated/server.d.ts +143 -0
- package/src/convex/_generated/server.js +93 -0
- package/src/index.ts +37 -0
- package/src/lib/conf.ts +28 -0
- package/src/lib/convex-client.ts +101 -0
- package/src/lib/file-system.ts +53 -0
- package/src/lib/first-run-setup.ts +73 -0
- package/src/lib/public-env.ts +3 -0
- package/src/lib/scene-packaging.ts +238 -0
- package/src/lib/script-watcher.ts +103 -0
- package/src/lib/types.ts +63 -0
- package/src/lib/utils.ts +3 -0
- package/src/lib/wait-for-token.ts +34 -0
- package/src/package/global-module.ts +117 -0
- package/src/package/npm-package.ts +16 -0
- package/src/package/setup.ts +47 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"workbench.colorCustomizations": {
|
|
3
|
+
"activityBar.activeBackground": "#422810",
|
|
4
|
+
"activityBar.background": "#422810",
|
|
5
|
+
"activityBar.foreground": "#e7e7e7",
|
|
6
|
+
"activityBar.inactiveForeground": "#e7e7e799",
|
|
7
|
+
"activityBarBadge.background": "#1f804e",
|
|
8
|
+
"activityBarBadge.foreground": "#e7e7e7",
|
|
9
|
+
"commandCenter.border": "#e7e7e799",
|
|
10
|
+
"sash.hoverBorder": "#422810",
|
|
11
|
+
"statusBar.background": "#190f06",
|
|
12
|
+
"statusBar.foreground": "#e7e7e7",
|
|
13
|
+
"statusBarItem.hoverBackground": "#422810",
|
|
14
|
+
"statusBarItem.remoteBackground": "#190f06",
|
|
15
|
+
"statusBarItem.remoteForeground": "#e7e7e7",
|
|
16
|
+
"titleBar.activeBackground": "#190f06",
|
|
17
|
+
"titleBar.activeForeground": "#e7e7e7",
|
|
18
|
+
"titleBar.inactiveBackground": "#190f0699",
|
|
19
|
+
"titleBar.inactiveForeground": "#e7e7e799"
|
|
20
|
+
},
|
|
21
|
+
"peacock.color": "#190f06"
|
|
22
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# phibelle-kit
|
|
2
|
+
|
|
3
|
+
CLI for working with [Phibelle](https://phibelle.studio/) scenes.
|
|
4
|
+
|
|
5
|
+
**Requirements:** Node.js 20 or later.
|
|
6
|
+
|
|
7
|
+
## Commands
|
|
8
|
+
|
|
9
|
+
**clone**: One-time download of a scene.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx phibelle-kit clone <sceneId>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**watch**: Subscribe to scene updates and sync scripts.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx phibelle-kit watch <sceneId>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## After cloning
|
|
23
|
+
|
|
24
|
+
1. `cd <scene-folder>` to enter the scene directory.
|
|
25
|
+
2. `npm install` to install dependencies (for types and intellisense).
|
|
26
|
+
3. `npm run watch` in the scene folder to push edits, or run `npx phibelle-kit watch <sceneId>` from the parent directory.
|
|
27
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type * as assets from "../assets.js";
|
|
12
|
+
import type * as scenes from "../scenes.js";
|
|
13
|
+
import type * as storage from "../storage.js";
|
|
14
|
+
|
|
15
|
+
import type {
|
|
16
|
+
ApiFromModules,
|
|
17
|
+
FilterApi,
|
|
18
|
+
FunctionReference,
|
|
19
|
+
} from "convex/server";
|
|
20
|
+
|
|
21
|
+
declare const fullApi: ApiFromModules<{
|
|
22
|
+
assets: typeof assets;
|
|
23
|
+
scenes: typeof scenes;
|
|
24
|
+
storage: typeof storage;
|
|
25
|
+
}>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
29
|
+
*
|
|
30
|
+
* Usage:
|
|
31
|
+
* ```js
|
|
32
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const api: FilterApi<
|
|
36
|
+
typeof fullApi,
|
|
37
|
+
FunctionReference<any, "public">
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
42
|
+
*
|
|
43
|
+
* Usage:
|
|
44
|
+
* ```js
|
|
45
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const internal: FilterApi<
|
|
49
|
+
typeof fullApi,
|
|
50
|
+
FunctionReference<any, "internal">
|
|
51
|
+
>;
|
|
52
|
+
|
|
53
|
+
export declare const components: {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A utility for referencing Convex functions in your app's API.
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* ```js
|
|
18
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export const api = anyApi;
|
|
22
|
+
export const internal = anyApi;
|
|
23
|
+
export const components = componentsGeneric();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated data model types.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
DataModelFromSchemaDefinition,
|
|
13
|
+
DocumentByName,
|
|
14
|
+
TableNamesInDataModel,
|
|
15
|
+
SystemTableNames,
|
|
16
|
+
} from "convex/server";
|
|
17
|
+
import type { GenericId } from "convex/values";
|
|
18
|
+
import schema from "../schema.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The names of all of your Convex tables.
|
|
22
|
+
*/
|
|
23
|
+
export type TableNames = TableNamesInDataModel<DataModel>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The type of a document stored in Convex.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
29
|
+
*/
|
|
30
|
+
export type Doc<TableName extends TableNames> = DocumentByName<
|
|
31
|
+
DataModel,
|
|
32
|
+
TableName
|
|
33
|
+
>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* An identifier for a document in Convex.
|
|
37
|
+
*
|
|
38
|
+
* Convex documents are uniquely identified by their `Id`, which is accessible
|
|
39
|
+
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
|
|
40
|
+
*
|
|
41
|
+
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
|
|
42
|
+
*
|
|
43
|
+
* IDs are just strings at runtime, but this type can be used to distinguish them from other
|
|
44
|
+
* strings when type checking.
|
|
45
|
+
*
|
|
46
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
47
|
+
*/
|
|
48
|
+
export type Id<TableName extends TableNames | SystemTableNames> =
|
|
49
|
+
GenericId<TableName>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A type describing your Convex data model.
|
|
53
|
+
*
|
|
54
|
+
* This type includes information about what tables you have, the type of
|
|
55
|
+
* documents stored in those tables, and the indexes defined on them.
|
|
56
|
+
*
|
|
57
|
+
* This type is used to parameterize methods like `queryGeneric` and
|
|
58
|
+
* `mutationGeneric` to make them type-safe.
|
|
59
|
+
*/
|
|
60
|
+
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
ActionBuilder,
|
|
13
|
+
HttpActionBuilder,
|
|
14
|
+
MutationBuilder,
|
|
15
|
+
QueryBuilder,
|
|
16
|
+
GenericActionCtx,
|
|
17
|
+
GenericMutationCtx,
|
|
18
|
+
GenericQueryCtx,
|
|
19
|
+
GenericDatabaseReader,
|
|
20
|
+
GenericDatabaseWriter,
|
|
21
|
+
} from "convex/server";
|
|
22
|
+
import type { DataModel } from "./dataModel.js";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Define a query in this Convex app's public API.
|
|
26
|
+
*
|
|
27
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
28
|
+
*
|
|
29
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
30
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
31
|
+
*/
|
|
32
|
+
export declare const query: QueryBuilder<DataModel, "public">;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
36
|
+
*
|
|
37
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
38
|
+
*
|
|
39
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
40
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
41
|
+
*/
|
|
42
|
+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Define a mutation in this Convex app's public API.
|
|
46
|
+
*
|
|
47
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
48
|
+
*
|
|
49
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
50
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
51
|
+
*/
|
|
52
|
+
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
56
|
+
*
|
|
57
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
58
|
+
*
|
|
59
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
60
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
61
|
+
*/
|
|
62
|
+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Define an action in this Convex app's public API.
|
|
66
|
+
*
|
|
67
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
68
|
+
* code and code with side-effects, like calling third-party services.
|
|
69
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
70
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
71
|
+
*
|
|
72
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
73
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
74
|
+
*/
|
|
75
|
+
export declare const action: ActionBuilder<DataModel, "public">;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
79
|
+
*
|
|
80
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
81
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
82
|
+
*/
|
|
83
|
+
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Define an HTTP action.
|
|
87
|
+
*
|
|
88
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
89
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
90
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
91
|
+
*
|
|
92
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
93
|
+
* and a Fetch API `Request` object as its second.
|
|
94
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
95
|
+
*/
|
|
96
|
+
export declare const httpAction: HttpActionBuilder;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A set of services for use within Convex query functions.
|
|
100
|
+
*
|
|
101
|
+
* The query context is passed as the first argument to any Convex query
|
|
102
|
+
* function run on the server.
|
|
103
|
+
*
|
|
104
|
+
* This differs from the {@link MutationCtx} because all of the services are
|
|
105
|
+
* read-only.
|
|
106
|
+
*/
|
|
107
|
+
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A set of services for use within Convex mutation functions.
|
|
111
|
+
*
|
|
112
|
+
* The mutation context is passed as the first argument to any Convex mutation
|
|
113
|
+
* function run on the server.
|
|
114
|
+
*/
|
|
115
|
+
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A set of services for use within Convex action functions.
|
|
119
|
+
*
|
|
120
|
+
* The action context is passed as the first argument to any Convex action
|
|
121
|
+
* function run on the server.
|
|
122
|
+
*/
|
|
123
|
+
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* An interface to read from the database within Convex query functions.
|
|
127
|
+
*
|
|
128
|
+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
129
|
+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
130
|
+
* building a query.
|
|
131
|
+
*/
|
|
132
|
+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* An interface to read from and write to the database within Convex mutation
|
|
136
|
+
* functions.
|
|
137
|
+
*
|
|
138
|
+
* Convex guarantees that all writes within a single mutation are
|
|
139
|
+
* executed atomically, so you never have to worry about partial writes leaving
|
|
140
|
+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
141
|
+
* for the guarantees Convex provides your functions.
|
|
142
|
+
*/
|
|
143
|
+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
actionGeneric,
|
|
13
|
+
httpActionGeneric,
|
|
14
|
+
queryGeneric,
|
|
15
|
+
mutationGeneric,
|
|
16
|
+
internalActionGeneric,
|
|
17
|
+
internalMutationGeneric,
|
|
18
|
+
internalQueryGeneric,
|
|
19
|
+
} from "convex/server";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Define a query in this Convex app's public API.
|
|
23
|
+
*
|
|
24
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
25
|
+
*
|
|
26
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
27
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
28
|
+
*/
|
|
29
|
+
export const query = queryGeneric;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
33
|
+
*
|
|
34
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
35
|
+
*
|
|
36
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
37
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
38
|
+
*/
|
|
39
|
+
export const internalQuery = internalQueryGeneric;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Define a mutation in this Convex app's public API.
|
|
43
|
+
*
|
|
44
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
45
|
+
*
|
|
46
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
47
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
48
|
+
*/
|
|
49
|
+
export const mutation = mutationGeneric;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
53
|
+
*
|
|
54
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
55
|
+
*
|
|
56
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
57
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
58
|
+
*/
|
|
59
|
+
export const internalMutation = internalMutationGeneric;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Define an action in this Convex app's public API.
|
|
63
|
+
*
|
|
64
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
65
|
+
* code and code with side-effects, like calling third-party services.
|
|
66
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
67
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
68
|
+
*
|
|
69
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
70
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
71
|
+
*/
|
|
72
|
+
export const action = actionGeneric;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
76
|
+
*
|
|
77
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
78
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
79
|
+
*/
|
|
80
|
+
export const internalAction = internalActionGeneric;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Define an HTTP action.
|
|
84
|
+
*
|
|
85
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
86
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
87
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
88
|
+
*
|
|
89
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
90
|
+
* and a Fetch API `Request` object as its second.
|
|
91
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
92
|
+
*/
|
|
93
|
+
export const httpAction = httpActionGeneric;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { queryOnce } from "./lib/convex-client.js";
|
|
4
|
+
import { api } from "./convex/_generated/api.js";
|
|
5
|
+
import { BASE_URL } from "./lib/public-env.js";
|
|
6
|
+
import { sceneNameToFolder } from "./lib/file-system.js";
|
|
7
|
+
import { setupSceneFiles, unpackageWithLogging } from "./lib/first-run-setup.js";
|
|
8
|
+
/**
|
|
9
|
+
* Clone: one-time fetch of scene data. Creates scene dir, writes scene.json,
|
|
10
|
+
* sets up package.json/global.d.ts, unpacks scripts. No watcher, no opening folder.
|
|
11
|
+
*/
|
|
12
|
+
export async function cloneSceneCommand(sceneId) {
|
|
13
|
+
console.log();
|
|
14
|
+
console.log(chalk.bold.cyan(" 📥 Cloning scene..."));
|
|
15
|
+
console.log(chalk.gray(` Scene ID: ${sceneId}`));
|
|
16
|
+
console.log();
|
|
17
|
+
const scene = await queryOnce(api.scenes.getById, {
|
|
18
|
+
id: sceneId,
|
|
19
|
+
});
|
|
20
|
+
if (scene === null) {
|
|
21
|
+
console.log(chalk.red(" ✖ Scene not found"));
|
|
22
|
+
console.log();
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
const sceneFolderName = sceneNameToFolder(scene.name);
|
|
26
|
+
const sceneDir = path.join(process.cwd(), sceneFolderName);
|
|
27
|
+
setupSceneFiles(scene, sceneDir, true);
|
|
28
|
+
await unpackageWithLogging(scene._id, sceneDir, "Edit the scene in the app once to create a scene file, then run clone again.");
|
|
29
|
+
console.log(chalk.green(" ✓ Cloned scene"));
|
|
30
|
+
console.log(chalk.white(` Name: ${scene.name}`));
|
|
31
|
+
console.log(chalk.white(` Path: ${sceneDir}`));
|
|
32
|
+
console.log(chalk.white(" Scene link: ") + chalk.cyan(`${BASE_URL}/editor?sceneId=${scene._id}`));
|
|
33
|
+
console.log();
|
|
34
|
+
console.log(chalk.gray(" Next steps:"));
|
|
35
|
+
console.log(chalk.gray(" 1. ") + chalk.blueBright("cd ") + chalk.cyan(sceneFolderName) + chalk.gray(" to open the scene directory."));
|
|
36
|
+
console.log(chalk.gray(" 2. ") + chalk.blueBright("npm install") + chalk.gray(" to install the dependencies."));
|
|
37
|
+
console.log(chalk.gray(" 3. ") + chalk.blueBright("phibelle watch ") + chalk.cyan(sceneId) + chalk.gray(" to watch for changes and push edits."));
|
|
38
|
+
console.log();
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { queryOnce } from "../lib/convex-client.js";
|
|
4
|
+
import { api } from "../convex/_generated/api.js";
|
|
5
|
+
import { BASE_URL } from "../lib/public-env.js";
|
|
6
|
+
import { sceneNameToFolder } from "../lib/file-system.js";
|
|
7
|
+
import { setupSceneFiles, unpackageWithLogging } from "../lib/first-run-setup.js";
|
|
8
|
+
/**
|
|
9
|
+
* Clone: one-time fetch of scene data. Creates scene dir, writes scene.json,
|
|
10
|
+
* sets up package.json/global.d.ts, unpacks scripts. No watcher, no opening folder.
|
|
11
|
+
*/
|
|
12
|
+
export async function cloneSceneCommand(sceneId) {
|
|
13
|
+
console.log();
|
|
14
|
+
console.log(chalk.bold.cyan(" 📥 Cloning scene..."));
|
|
15
|
+
console.log(chalk.gray(` Scene ID: ${sceneId}`));
|
|
16
|
+
console.log();
|
|
17
|
+
const scene = await queryOnce(api.scenes.getById, {
|
|
18
|
+
id: sceneId,
|
|
19
|
+
});
|
|
20
|
+
if (scene === null) {
|
|
21
|
+
console.log(chalk.red(" ✖ Scene not found"));
|
|
22
|
+
console.log();
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
const sceneFolderName = sceneNameToFolder(scene.name);
|
|
26
|
+
const sceneDir = path.join(process.cwd(), sceneFolderName);
|
|
27
|
+
setupSceneFiles(scene, sceneDir, true);
|
|
28
|
+
await unpackageWithLogging(scene._id, sceneDir, "Edit the scene in the app once to create a scene file, then run clone again.");
|
|
29
|
+
console.log(chalk.green(" ✓ Cloned scene"));
|
|
30
|
+
console.log(chalk.white(` Name: ${scene.name}`));
|
|
31
|
+
console.log(chalk.white(` Path: ${sceneDir}`));
|
|
32
|
+
console.log(chalk.white(" Scene link: ") + chalk.cyan(`${BASE_URL}/editor?sceneId=${scene._id}`));
|
|
33
|
+
console.log();
|
|
34
|
+
console.log(chalk.gray(" Next steps:"));
|
|
35
|
+
console.log(chalk.gray(" 1. ") + chalk.blueBright("cd ") + chalk.cyan(sceneFolderName) + chalk.gray(" to open the scene directory."));
|
|
36
|
+
console.log(chalk.gray(" 2. ") + chalk.blueBright("npm install") + chalk.gray(" to install the dependencies."));
|
|
37
|
+
console.log(chalk.gray(" 3. ") + chalk.blueBright("npm run watch ") + chalk.gray(" to watch for changes and push edits."));
|
|
38
|
+
console.log();
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function helloCommand(): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { getStoredUsername } from "../lib/conf.js";
|
|
3
|
+
export async function helloCommand() {
|
|
4
|
+
const username = getStoredUsername();
|
|
5
|
+
const greeting = username ? `Hello ${username}! 👋` : "Hello World! 👋";
|
|
6
|
+
console.log();
|
|
7
|
+
console.log(chalk.bold.magenta(` ${greeting}`));
|
|
8
|
+
console.log(chalk.gray(" Phibelle CLI is working correctly."));
|
|
9
|
+
console.log();
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loginCommand(): Promise<void>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import * as readline from "readline/promises";
|
|
3
|
+
import { BASE_URL } from "../lib/constants.js";
|
|
4
|
+
import { CONFIG, getStoredToken } from "../lib/conf.js";
|
|
5
|
+
async function fetchUsernameFromAPI(token) {
|
|
6
|
+
try {
|
|
7
|
+
const response = await fetch(`${BASE_URL}/api/cli/user-info`, {
|
|
8
|
+
method: "GET",
|
|
9
|
+
headers: {
|
|
10
|
+
Authorization: `Bearer ${token}`,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const data = await response.json();
|
|
17
|
+
return data.username || null;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export async function loginCommand() {
|
|
24
|
+
const rl = readline.createInterface({
|
|
25
|
+
input: process.stdin,
|
|
26
|
+
output: process.stdout,
|
|
27
|
+
});
|
|
28
|
+
if (getStoredToken() !== undefined) {
|
|
29
|
+
console.log();
|
|
30
|
+
console.log(chalk.yellow(" You are already logged in. Please logout first."));
|
|
31
|
+
console.log();
|
|
32
|
+
rl.close();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
console.log();
|
|
36
|
+
console.log(chalk.bold.cyan(" 🔐 Phibelle CLI Login"));
|
|
37
|
+
console.log();
|
|
38
|
+
console.log(chalk.gray(" To authenticate, follow these steps:"));
|
|
39
|
+
console.log();
|
|
40
|
+
console.log(chalk.white(" 1. Open this URL in your browser:"));
|
|
41
|
+
console.log();
|
|
42
|
+
console.log(chalk.cyan(` ${BASE_URL}/cli-token`));
|
|
43
|
+
console.log();
|
|
44
|
+
console.log(chalk.white(" 2. Sign in if prompted"));
|
|
45
|
+
console.log(chalk.white(" 3. Copy the token displayed on the page"));
|
|
46
|
+
console.log(chalk.white(" 4. Paste it below"));
|
|
47
|
+
console.log();
|
|
48
|
+
const token = await rl.question(chalk.yellow(" Enter your token: "));
|
|
49
|
+
if (!token || token.trim() === "") {
|
|
50
|
+
console.log();
|
|
51
|
+
console.log(chalk.red(" ✖ No token provided. Login cancelled."));
|
|
52
|
+
console.log();
|
|
53
|
+
rl.close();
|
|
54
|
+
throw new Error("No token provided");
|
|
55
|
+
}
|
|
56
|
+
const trimmedToken = token.trim();
|
|
57
|
+
console.log(chalk.gray(" Fetching user information..."));
|
|
58
|
+
const username = await fetchUsernameFromAPI(trimmedToken);
|
|
59
|
+
if (username) {
|
|
60
|
+
CONFIG.set("username", username);
|
|
61
|
+
}
|
|
62
|
+
if (!username) {
|
|
63
|
+
console.log();
|
|
64
|
+
console.log(chalk.red(" ✖ Failed to fetch user information. Login cancelled."));
|
|
65
|
+
console.log();
|
|
66
|
+
rl.close();
|
|
67
|
+
throw new Error("Failed to fetch user information");
|
|
68
|
+
}
|
|
69
|
+
CONFIG.set("authToken", trimmedToken);
|
|
70
|
+
console.log();
|
|
71
|
+
console.log(chalk.green(" ✔ Successfully logged in!"));
|
|
72
|
+
console.log(chalk.gray(" Your token has been saved."));
|
|
73
|
+
console.log();
|
|
74
|
+
rl.close();
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function logoutCommand(): Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { clearToken, getStoredToken } from "../lib/conf.js";
|
|
3
|
+
export async function logoutCommand() {
|
|
4
|
+
const token = getStoredToken();
|
|
5
|
+
if (!token) {
|
|
6
|
+
console.log();
|
|
7
|
+
console.log(chalk.yellow(" ℹ You are not currently logged in."));
|
|
8
|
+
console.log();
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
clearToken();
|
|
12
|
+
console.log();
|
|
13
|
+
console.log(chalk.green(" ✔ Successfully logged out!"));
|
|
14
|
+
console.log(chalk.gray(" Your token has been cleared."));
|
|
15
|
+
console.log();
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function watchSceneCommand(sceneId: string): Promise<void>;
|