@base44-preview/cli 0.0.1-pr.10.3ef6431
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/README.md +49 -0
- package/dist/cli/commands/auth/login.d.ts +3 -0
- package/dist/cli/commands/auth/login.d.ts.map +1 -0
- package/dist/cli/commands/auth/login.js +71 -0
- package/dist/cli/commands/auth/login.js.map +1 -0
- package/dist/cli/commands/auth/logout.d.ts +3 -0
- package/dist/cli/commands/auth/logout.d.ts.map +1 -0
- package/dist/cli/commands/auth/logout.js +14 -0
- package/dist/cli/commands/auth/logout.js.map +1 -0
- package/dist/cli/commands/auth/whoami.d.ts +3 -0
- package/dist/cli/commands/auth/whoami.d.ts.map +1 -0
- package/dist/cli/commands/auth/whoami.js +14 -0
- package/dist/cli/commands/auth/whoami.js.map +1 -0
- package/dist/cli/commands/project/show-project.d.ts +3 -0
- package/dist/cli/commands/project/show-project.d.ts.map +1 -0
- package/dist/cli/commands/project/show-project.js +20 -0
- package/dist/cli/commands/project/show-project.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +21 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/index.d.ts +4 -0
- package/dist/cli/utils/index.d.ts.map +1 -0
- package/dist/cli/utils/index.js +4 -0
- package/dist/cli/utils/index.js.map +1 -0
- package/dist/cli/utils/packageVersion.d.ts +2 -0
- package/dist/cli/utils/packageVersion.d.ts.map +1 -0
- package/dist/cli/utils/packageVersion.js +12 -0
- package/dist/cli/utils/packageVersion.js.map +1 -0
- package/dist/cli/utils/runCommand.d.ts +8 -0
- package/dist/cli/utils/runCommand.d.ts.map +1 -0
- package/dist/cli/utils/runCommand.js +25 -0
- package/dist/cli/utils/runCommand.js.map +1 -0
- package/dist/cli/utils/runTask.d.ts +14 -0
- package/dist/cli/utils/runTask.d.ts.map +1 -0
- package/dist/cli/utils/runTask.js +24 -0
- package/dist/cli/utils/runTask.js.map +1 -0
- package/dist/core/auth/api.d.ts +5 -0
- package/dist/core/auth/api.d.ts.map +1 -0
- package/dist/core/auth/api.js +81 -0
- package/dist/core/auth/api.js.map +1 -0
- package/dist/core/auth/authClient.d.ts +7 -0
- package/dist/core/auth/authClient.d.ts.map +1 -0
- package/dist/core/auth/authClient.js +14 -0
- package/dist/core/auth/authClient.js.map +1 -0
- package/dist/core/auth/config.d.ts +15 -0
- package/dist/core/auth/config.d.ts.map +1 -0
- package/dist/core/auth/config.js +91 -0
- package/dist/core/auth/config.js.map +1 -0
- package/dist/core/auth/index.d.ts +4 -0
- package/dist/core/auth/index.d.ts.map +1 -0
- package/dist/core/auth/index.js +4 -0
- package/dist/core/auth/index.js.map +1 -0
- package/dist/core/auth/schema.d.ts +58 -0
- package/dist/core/auth/schema.d.ts.map +1 -0
- package/dist/core/auth/schema.js +57 -0
- package/dist/core/auth/schema.js.map +1 -0
- package/dist/core/config/app.d.ts +22 -0
- package/dist/core/config/app.d.ts.map +1 -0
- package/dist/core/config/app.js +14 -0
- package/dist/core/config/app.js.map +1 -0
- package/dist/core/config/index.d.ts +4 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/index.js +3 -0
- package/dist/core/config/index.js.map +1 -0
- package/dist/core/config/project.d.ts +25 -0
- package/dist/core/config/project.d.ts.map +1 -0
- package/dist/core/config/project.js +62 -0
- package/dist/core/config/project.js.map +1 -0
- package/dist/core/config/resource.d.ts +4 -0
- package/dist/core/config/resource.d.ts.map +1 -0
- package/dist/core/config/resource.js +2 -0
- package/dist/core/config/resource.js.map +1 -0
- package/dist/core/consts.d.ts +8 -0
- package/dist/core/consts.d.ts.map +1 -0
- package/dist/core/consts.js +24 -0
- package/dist/core/consts.js.map +1 -0
- package/dist/core/errors.d.ts +8 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +15 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/resources/entity/config.d.ts +3 -0
- package/dist/core/resources/entity/config.d.ts.map +1 -0
- package/dist/core/resources/entity/config.js +25 -0
- package/dist/core/resources/entity/config.js.map +1 -0
- package/dist/core/resources/entity/index.d.ts +4 -0
- package/dist/core/resources/entity/index.d.ts.map +1 -0
- package/dist/core/resources/entity/index.js +4 -0
- package/dist/core/resources/entity/index.js.map +1 -0
- package/dist/core/resources/entity/resource.d.ts +4 -0
- package/dist/core/resources/entity/resource.d.ts.map +1 -0
- package/dist/core/resources/entity/resource.js +5 -0
- package/dist/core/resources/entity/resource.js.map +1 -0
- package/dist/core/resources/entity/schema.d.ts +47 -0
- package/dist/core/resources/entity/schema.d.ts.map +1 -0
- package/dist/core/resources/entity/schema.js +29 -0
- package/dist/core/resources/entity/schema.js.map +1 -0
- package/dist/core/resources/function/config.d.ts +4 -0
- package/dist/core/resources/function/config.d.ts.map +1 -0
- package/dist/core/resources/function/config.js +26 -0
- package/dist/core/resources/function/config.js.map +1 -0
- package/dist/core/resources/function/index.d.ts +4 -0
- package/dist/core/resources/function/index.d.ts.map +1 -0
- package/dist/core/resources/function/index.js +4 -0
- package/dist/core/resources/function/index.js.map +1 -0
- package/dist/core/resources/function/resource.d.ts +4 -0
- package/dist/core/resources/function/resource.d.ts.map +1 -0
- package/dist/core/resources/function/resource.js +5 -0
- package/dist/core/resources/function/resource.js.map +1 -0
- package/dist/core/resources/function/schema.d.ts +91 -0
- package/dist/core/resources/function/schema.d.ts.map +1 -0
- package/dist/core/resources/function/schema.js +36 -0
- package/dist/core/resources/function/schema.js.map +1 -0
- package/dist/core/resources/index.d.ts +3 -0
- package/dist/core/resources/index.d.ts.map +1 -0
- package/dist/core/resources/index.js +3 -0
- package/dist/core/resources/index.js.map +1 -0
- package/dist/core/utils/fs.d.ts +5 -0
- package/dist/core/utils/fs.d.ts.map +1 -0
- package/dist/core/utils/fs.js +56 -0
- package/dist/core/utils/fs.js.map +1 -0
- package/dist/core/utils/httpClient.d.ts +3 -0
- package/dist/core/utils/httpClient.d.ts.map +1 -0
- package/dist/core/utils/httpClient.js +57 -0
- package/dist/core/utils/httpClient.js.map +1 -0
- package/dist/core/utils/index.d.ts +3 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/index.js +3 -0
- package/dist/core/utils/index.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const EntityPropertySchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodString;
|
|
4
|
+
description: z.ZodOptional<z.ZodString>;
|
|
5
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
7
|
+
format: z.ZodOptional<z.ZodString>;
|
|
8
|
+
items: z.ZodOptional<z.ZodAny>;
|
|
9
|
+
relation: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
entity: z.ZodString;
|
|
11
|
+
type: z.ZodString;
|
|
12
|
+
}, z.core.$strip>>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
declare const EntityPoliciesSchema: z.ZodObject<{
|
|
15
|
+
read: z.ZodOptional<z.ZodString>;
|
|
16
|
+
create: z.ZodOptional<z.ZodString>;
|
|
17
|
+
update: z.ZodOptional<z.ZodString>;
|
|
18
|
+
delete: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const EntitySchema: z.ZodObject<{
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
type: z.ZodLiteral<"object">;
|
|
23
|
+
properties: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
24
|
+
type: z.ZodString;
|
|
25
|
+
description: z.ZodOptional<z.ZodString>;
|
|
26
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
28
|
+
format: z.ZodOptional<z.ZodString>;
|
|
29
|
+
items: z.ZodOptional<z.ZodAny>;
|
|
30
|
+
relation: z.ZodOptional<z.ZodObject<{
|
|
31
|
+
entity: z.ZodString;
|
|
32
|
+
type: z.ZodString;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
required: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
policies: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
read: z.ZodOptional<z.ZodString>;
|
|
38
|
+
create: z.ZodOptional<z.ZodString>;
|
|
39
|
+
update: z.ZodOptional<z.ZodString>;
|
|
40
|
+
delete: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type EntityProperty = z.infer<typeof EntityPropertySchema>;
|
|
44
|
+
export type EntityPolicies = z.infer<typeof EntityPoliciesSchema>;
|
|
45
|
+
export type Entity = z.infer<typeof EntitySchema>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/entity/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,oBAAoB;;;;;;;;;;;iBAaxB,CAAC;AAEH,QAAA,MAAM,oBAAoB;;;;;iBAKxB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;iBAMvB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const EntityPropertySchema = z.object({
|
|
3
|
+
type: z.string(),
|
|
4
|
+
description: z.string().optional(),
|
|
5
|
+
enum: z.array(z.string()).optional(),
|
|
6
|
+
default: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
7
|
+
format: z.string().optional(),
|
|
8
|
+
items: z.any().optional(),
|
|
9
|
+
relation: z
|
|
10
|
+
.object({
|
|
11
|
+
entity: z.string(),
|
|
12
|
+
type: z.string(),
|
|
13
|
+
})
|
|
14
|
+
.optional(),
|
|
15
|
+
});
|
|
16
|
+
const EntityPoliciesSchema = z.object({
|
|
17
|
+
read: z.string().optional(),
|
|
18
|
+
create: z.string().optional(),
|
|
19
|
+
update: z.string().optional(),
|
|
20
|
+
delete: z.string().optional(),
|
|
21
|
+
});
|
|
22
|
+
export const EntitySchema = z.object({
|
|
23
|
+
name: z.string().min(1, "Entity name cannot be empty"),
|
|
24
|
+
type: z.literal("object"),
|
|
25
|
+
properties: z.record(z.string(), EntityPropertySchema),
|
|
26
|
+
required: z.array(z.string()).optional(),
|
|
27
|
+
policies: EntityPoliciesSchema.optional(),
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/core/resources/entity/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC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AAoB,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/function/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CAazB;AAED,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,cAAc,EAAE,CAAC,CAe3B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { globby } from "globby";
|
|
2
|
+
import { FUNCTION_CONFIG_FILE } from "../../consts.js";
|
|
3
|
+
import { readJsonFile, pathExists } from "../../utils/fs.js";
|
|
4
|
+
import { FunctionConfigSchema } from "./schema.js";
|
|
5
|
+
export async function readFunctionConfig(configPath) {
|
|
6
|
+
const parsed = await readJsonFile(configPath);
|
|
7
|
+
const result = FunctionConfigSchema.safeParse(parsed);
|
|
8
|
+
if (!result.success) {
|
|
9
|
+
throw new Error(`Invalid function configuration in ${configPath}: ${result.error.issues
|
|
10
|
+
.map((e) => e.message)
|
|
11
|
+
.join(", ")}`);
|
|
12
|
+
}
|
|
13
|
+
return result.data;
|
|
14
|
+
}
|
|
15
|
+
export async function readAllFunctions(functionsDir) {
|
|
16
|
+
if (!(await pathExists(functionsDir))) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
const configFiles = await globby(`*/${FUNCTION_CONFIG_FILE}`, {
|
|
20
|
+
cwd: functionsDir,
|
|
21
|
+
absolute: true,
|
|
22
|
+
});
|
|
23
|
+
const functionConfigs = await Promise.all(configFiles.map((configPath) => readFunctionConfig(configPath)));
|
|
24
|
+
return functionConfigs;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/function/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/resources/function/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/function/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,cAAc,CAErD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../../src/core/resources/function/resource.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAA6B;IACxD,OAAO,EAAE,gBAAgB;CAC1B,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const HttpTriggerSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodOptional<z.ZodString>;
|
|
4
|
+
name: z.ZodOptional<z.ZodString>;
|
|
5
|
+
description: z.ZodOptional<z.ZodString>;
|
|
6
|
+
type: z.ZodLiteral<"http">;
|
|
7
|
+
path: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
declare const ScheduleTriggerSchema: z.ZodObject<{
|
|
10
|
+
id: z.ZodOptional<z.ZodString>;
|
|
11
|
+
name: z.ZodOptional<z.ZodString>;
|
|
12
|
+
description: z.ZodOptional<z.ZodString>;
|
|
13
|
+
type: z.ZodLiteral<"schedule">;
|
|
14
|
+
scheduleMode: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
recurring: "recurring";
|
|
16
|
+
once: "once";
|
|
17
|
+
}>>;
|
|
18
|
+
cron: z.ZodString;
|
|
19
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
declare const EventTriggerSchema: z.ZodObject<{
|
|
23
|
+
id: z.ZodOptional<z.ZodString>;
|
|
24
|
+
name: z.ZodOptional<z.ZodString>;
|
|
25
|
+
description: z.ZodOptional<z.ZodString>;
|
|
26
|
+
type: z.ZodLiteral<"event">;
|
|
27
|
+
entity: z.ZodString;
|
|
28
|
+
event: z.ZodString;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
declare const TriggerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
31
|
+
id: z.ZodOptional<z.ZodString>;
|
|
32
|
+
name: z.ZodOptional<z.ZodString>;
|
|
33
|
+
description: z.ZodOptional<z.ZodString>;
|
|
34
|
+
type: z.ZodLiteral<"http">;
|
|
35
|
+
path: z.ZodString;
|
|
36
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
37
|
+
id: z.ZodOptional<z.ZodString>;
|
|
38
|
+
name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
description: z.ZodOptional<z.ZodString>;
|
|
40
|
+
type: z.ZodLiteral<"schedule">;
|
|
41
|
+
scheduleMode: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
recurring: "recurring";
|
|
43
|
+
once: "once";
|
|
44
|
+
}>>;
|
|
45
|
+
cron: z.ZodString;
|
|
46
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
49
|
+
id: z.ZodOptional<z.ZodString>;
|
|
50
|
+
name: z.ZodOptional<z.ZodString>;
|
|
51
|
+
description: z.ZodOptional<z.ZodString>;
|
|
52
|
+
type: z.ZodLiteral<"event">;
|
|
53
|
+
entity: z.ZodString;
|
|
54
|
+
event: z.ZodString;
|
|
55
|
+
}, z.core.$strip>], "type">;
|
|
56
|
+
export declare const FunctionConfigSchema: z.ZodObject<{
|
|
57
|
+
entry: z.ZodString;
|
|
58
|
+
triggers: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
59
|
+
id: z.ZodOptional<z.ZodString>;
|
|
60
|
+
name: z.ZodOptional<z.ZodString>;
|
|
61
|
+
description: z.ZodOptional<z.ZodString>;
|
|
62
|
+
type: z.ZodLiteral<"http">;
|
|
63
|
+
path: z.ZodString;
|
|
64
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
65
|
+
id: z.ZodOptional<z.ZodString>;
|
|
66
|
+
name: z.ZodOptional<z.ZodString>;
|
|
67
|
+
description: z.ZodOptional<z.ZodString>;
|
|
68
|
+
type: z.ZodLiteral<"schedule">;
|
|
69
|
+
scheduleMode: z.ZodOptional<z.ZodEnum<{
|
|
70
|
+
recurring: "recurring";
|
|
71
|
+
once: "once";
|
|
72
|
+
}>>;
|
|
73
|
+
cron: z.ZodString;
|
|
74
|
+
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
+
id: z.ZodOptional<z.ZodString>;
|
|
78
|
+
name: z.ZodOptional<z.ZodString>;
|
|
79
|
+
description: z.ZodOptional<z.ZodString>;
|
|
80
|
+
type: z.ZodLiteral<"event">;
|
|
81
|
+
entity: z.ZodString;
|
|
82
|
+
event: z.ZodString;
|
|
83
|
+
}, z.core.$strip>], "type">>>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export type HttpTrigger = z.infer<typeof HttpTriggerSchema>;
|
|
86
|
+
export type ScheduleTrigger = z.infer<typeof ScheduleTriggerSchema>;
|
|
87
|
+
export type EventTrigger = z.infer<typeof EventTriggerSchema>;
|
|
88
|
+
export type Trigger = z.infer<typeof TriggerSchema>;
|
|
89
|
+
export type FunctionConfig = z.infer<typeof FunctionConfigSchema>;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/core/resources/function/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,iBAAiB;;;;;;iBAMrB,CAAC;AAEH,QAAA,MAAM,qBAAqB;;;;;;;;;;;;iBASzB,CAAC;AAEH,QAAA,MAAM,kBAAkB;;;;;;;iBAOtB,CAAC;AAEH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;2BAIjB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAG/B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const HttpTriggerSchema = z.object({
|
|
3
|
+
id: z.string().optional(),
|
|
4
|
+
name: z.string().optional(),
|
|
5
|
+
description: z.string().optional(),
|
|
6
|
+
type: z.literal("http"),
|
|
7
|
+
path: z.string().min(1, "Path cannot be empty"),
|
|
8
|
+
});
|
|
9
|
+
const ScheduleTriggerSchema = z.object({
|
|
10
|
+
id: z.string().optional(),
|
|
11
|
+
name: z.string().optional(),
|
|
12
|
+
description: z.string().optional(),
|
|
13
|
+
type: z.literal("schedule"),
|
|
14
|
+
scheduleMode: z.enum(["recurring", "once"]).optional(),
|
|
15
|
+
cron: z.string().min(1, "Cron expression cannot be empty"),
|
|
16
|
+
isActive: z.boolean().optional(),
|
|
17
|
+
timezone: z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
const EventTriggerSchema = z.object({
|
|
20
|
+
id: z.string().optional(),
|
|
21
|
+
name: z.string().optional(),
|
|
22
|
+
description: z.string().optional(),
|
|
23
|
+
type: z.literal("event"),
|
|
24
|
+
entity: z.string().min(1, "Entity name cannot be empty"),
|
|
25
|
+
event: z.string().min(1, "Event type cannot be empty"),
|
|
26
|
+
});
|
|
27
|
+
const TriggerSchema = z.discriminatedUnion("type", [
|
|
28
|
+
HttpTriggerSchema,
|
|
29
|
+
ScheduleTriggerSchema,
|
|
30
|
+
EventTriggerSchema,
|
|
31
|
+
]);
|
|
32
|
+
export const FunctionConfigSchema = z.object({
|
|
33
|
+
entry: z.string().min(1, "Entry point cannot be empty"),
|
|
34
|
+
triggers: z.array(TriggerSchema).optional(),
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/core/resources/function/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;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AO,CAAC,OAAO,CAAC;IACxB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;IACxD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,4BAA4B,CAAC;CACvD,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACjD,iBAAiB;IACjB,qBAAqB;IACrB,kBAAkB;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;IACvD,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function pathExists(path: string): Promise<boolean>;
|
|
2
|
+
export declare function readJsonFile(filePath: string): Promise<unknown>;
|
|
3
|
+
export declare function writeJsonFile(filePath: string, data: unknown): Promise<void>;
|
|
4
|
+
export declare function deleteFile(filePath: string): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/core/utils/fs.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,oBAItC;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8BrE;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAchE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir, unlink, access } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { parse, printParseErrorCode } from "jsonc-parser";
|
|
4
|
+
export function pathExists(path) {
|
|
5
|
+
return access(path)
|
|
6
|
+
.then(() => true)
|
|
7
|
+
.catch(() => false);
|
|
8
|
+
}
|
|
9
|
+
export async function readJsonFile(filePath) {
|
|
10
|
+
if (!(await pathExists(filePath))) {
|
|
11
|
+
throw new Error(`File not found: ${filePath}`);
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const fileContent = await readFile(filePath, "utf-8");
|
|
15
|
+
const errors = [];
|
|
16
|
+
const result = parse(fileContent, errors, { allowTrailingComma: true });
|
|
17
|
+
if (errors.length > 0) {
|
|
18
|
+
const errorMessages = errors
|
|
19
|
+
.map((e) => `${printParseErrorCode(e.error)} at offset ${e.offset}`)
|
|
20
|
+
.join(", ");
|
|
21
|
+
throw new Error(`File contains invalid JSONC: ${filePath} (${errorMessages})`);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error instanceof Error && error.message.includes("invalid JSONC")) {
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Failed to read file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function writeJsonFile(filePath, data) {
|
|
33
|
+
try {
|
|
34
|
+
const dir = dirname(filePath);
|
|
35
|
+
if (!(await pathExists(dir))) {
|
|
36
|
+
await mkdir(dir, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
const jsonContent = JSON.stringify(data, null, 2);
|
|
39
|
+
await writeFile(filePath, jsonContent, "utf-8");
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new Error(`Failed to write file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export async function deleteFile(filePath) {
|
|
46
|
+
if (!(await pathExists(filePath))) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
await unlink(filePath);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error(`Failed to delete file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/core/utils/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC;SAChB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;SAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB;IACj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,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC7B,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAClD,MAAM,SAAS,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,wBAAwB,QAAQ,KAC9B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAC3C,EAAE,CACH,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAgB;IAC/C,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QAClC,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,yBAAyB,QAAQ,KAC/B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAC3C,EAAE,CACH,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpClient.d.ts","sourceRoot":"","sources":["../../../src/core/utils/httpClient.ts"],"names":[],"mappings":"AA2CA,QAAA,MAAM,UAAU,yBA4Bd,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import ky from "ky";
|
|
2
|
+
import { getBase44ApiUrl } from "../consts.js";
|
|
3
|
+
import { readAuth, refreshAndSaveTokens, isTokenExpired, } from "../auth/config.js";
|
|
4
|
+
// Track requests that have already been retried to prevent infinite loops
|
|
5
|
+
const retriedRequests = new WeakSet();
|
|
6
|
+
/**
|
|
7
|
+
* Handles 401 responses by refreshing the token and retrying the request.
|
|
8
|
+
* Only retries once per request to prevent infinite loops.
|
|
9
|
+
*/
|
|
10
|
+
async function handleUnauthorized(request, _options, response) {
|
|
11
|
+
if (response.status !== 401) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// Prevent infinite retry loop - only retry once per request
|
|
15
|
+
if (retriedRequests.has(request)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const newAccessToken = await refreshAndSaveTokens();
|
|
19
|
+
if (!newAccessToken) {
|
|
20
|
+
// Refresh failed, let the 401 propagate
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Mark this request as retried and retry with new token
|
|
24
|
+
retriedRequests.add(request);
|
|
25
|
+
request.headers.set("Authorization", `Bearer ${newAccessToken}`);
|
|
26
|
+
return ky(request);
|
|
27
|
+
}
|
|
28
|
+
const httpClient = ky.create({
|
|
29
|
+
prefixUrl: getBase44ApiUrl(),
|
|
30
|
+
headers: {
|
|
31
|
+
"User-Agent": "Base44 CLI",
|
|
32
|
+
},
|
|
33
|
+
hooks: {
|
|
34
|
+
beforeRequest: [
|
|
35
|
+
async (request) => {
|
|
36
|
+
try {
|
|
37
|
+
const auth = await readAuth();
|
|
38
|
+
// Proactively refresh if token is expired or about to expire
|
|
39
|
+
if (isTokenExpired(auth)) {
|
|
40
|
+
const newAccessToken = await refreshAndSaveTokens();
|
|
41
|
+
if (newAccessToken) {
|
|
42
|
+
request.headers.set("Authorization", `Bearer ${newAccessToken}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
request.headers.set("Authorization", `Bearer ${auth.accessToken}`);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// No auth available, continue without header
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
afterResponse: [handleUnauthorized],
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
export default httpClient;
|
|
57
|
+
//# sourceMappingURL=httpClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpClient.js","sourceRoot":"","sources":["../../../src/core/utils/httpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,0EAA0E;AAC1E,MAAM,eAAe,GAAG,IAAI,OAAO,EAAa,CAAC;AAEjD;;;GAGG;AACH,KAAK,UAAU,kBAAkB,CAC/B,OAAkB,EAClB,QAA2B,EAC3B,QAAoB;IAEpB,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,OAAO;IACT,CAAC;IAED,4DAA4D;IAC5D,IAAI,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,oBAAoB,EAAE,CAAC;IAEpD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,wCAAwC;QACxC,OAAO;IACT,CAAC;IAED,wDAAwD;IACxD,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,cAAc,EAAE,CAAC,CAAC;IACjE,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,GAAG,EAAE,CAAC,MAAM,CAAC;IAC3B,SAAS,EAAE,eAAe,EAAE;IAC5B,OAAO,EAAE;QACP,YAAY,EAAE,YAAY;KAC3B;IACD,KAAK,EAAE;QACL,aAAa,EAAE;YACb,KAAK,EAAE,OAAO,EAAE,EAAE;gBAChB,IAAI,CAAC;oBACH,MAAM,IAAI,GAAG,MAAM,QAAQ,EAAE,CAAC;oBAE9B,6DAA6D;oBAC7D,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;wBACzB,MAAM,cAAc,GAAG,MAAM,oBAAoB,EAAE,CAAC;wBACpD,IAAI,cAAc,EAAE,CAAC;4BACnB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,cAAc,EAAE,CAAC,CAAC;4BACjE,OAAO;wBACT,CAAC;oBACH,CAAC;oBAED,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;gBACrE,CAAC;gBAAC,MAAM,CAAC;oBACP,6CAA6C;gBAC/C,CAAC;YACH,CAAC;SACF;QACD,aAAa,EAAE,CAAC,kBAAkB,CAAC;KACpC;CACF,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@base44-preview/cli",
|
|
3
|
+
"version": "0.0.1-pr.10.3ef6431",
|
|
4
|
+
"description": "Base44 CLI - Unified interface for managing Base44 applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/cli/index.js",
|
|
7
|
+
"types": "./dist/cli/index.d.ts",
|
|
8
|
+
"bin": "./dist/cli/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/cli/index.d.ts",
|
|
12
|
+
"default": "./dist/cli/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc && tsc-alias",
|
|
20
|
+
"dev": "tsx src/cli/index.ts",
|
|
21
|
+
"start": "node dist/cli/index.js",
|
|
22
|
+
"clean": "rm -rf dist",
|
|
23
|
+
"lint": "eslint src",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:watch": "vitest"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"base44",
|
|
29
|
+
"cli",
|
|
30
|
+
"command-line"
|
|
31
|
+
],
|
|
32
|
+
"author": "",
|
|
33
|
+
"license": "ISC",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/base44/cli"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@clack/prompts": "^0.11.0",
|
|
40
|
+
"chalk": "^5.6.2",
|
|
41
|
+
"commander": "^12.1.0",
|
|
42
|
+
"globby": "^16.1.0",
|
|
43
|
+
"jsonc-parser": "^3.3.1",
|
|
44
|
+
"ky": "^1.14.2",
|
|
45
|
+
"p-wait-for": "^6.0.0",
|
|
46
|
+
"zod": "^4.3.5"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@stylistic/eslint-plugin": "^5.6.1",
|
|
50
|
+
"@types/node": "^22.10.5",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^8.51.0",
|
|
52
|
+
"@typescript-eslint/parser": "^8.51.0",
|
|
53
|
+
"eslint": "^9.39.2",
|
|
54
|
+
"eslint-plugin-import": "^2.32.0",
|
|
55
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
56
|
+
"tsc-alias": "^1.8.16",
|
|
57
|
+
"tsx": "^4.19.2",
|
|
58
|
+
"typescript": "^5.7.2",
|
|
59
|
+
"typescript-eslint": "^8.52.0",
|
|
60
|
+
"vitest": "^4.0.16"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=20.19.0"
|
|
64
|
+
}
|
|
65
|
+
}
|