Skip to content

Commit d994538

Browse files
committed
refactor(tools-forecast-codegen): Redesigned Forecast plugin architecture
1 parent b4c89d3 commit d994538

81 files changed

Lines changed: 3986 additions & 618 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libs/contact/typescript/server/attachment/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
}
4646
},
4747
"generate": {
48-
"executor": "@stormstack/tools-executors-typescript:storm-generate",
48+
"executor": "@stormstack/tools-nx-forecast:generate",
4949
"options": {
5050
"outputPath": "libs/contact/typescript/server/attachment/src/__generated__",
51-
"schema": "schema.storm",
51+
"schema": "schema.4cast",
5252
"packageManager": "pnpm",
5353
"dependencyCheck": true
5454
}

libs/contact/typescript/server/attachment/schema.storm renamed to libs/contact/typescript/server/attachment/schema.4cast

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,9 @@ generator js {
99
output = "../../../../../../node_modules/@prisma/client/contact-attachment"
1010
}
1111

12-
plugin prisma {
13-
provider = "@core/prisma"
14-
}
15-
16-
plugin meta {
17-
provider = "@core/model-meta"
18-
output = "src/__generated__/model-meta"
19-
compile = false
20-
}
21-
22-
plugin access {
23-
provider = "@core/access-policy"
24-
output = "src/__generated__/access-policy"
25-
compile = false
26-
}
27-
28-
plugin zod {
29-
provider = "@plugins/zod"
30-
output = "src/__generated__/zod"
31-
compile = false
32-
}
33-
34-
plugin drizzle {
35-
provider = "@plugins/drizzle"
36-
output = "src/__generated__/drizzle"
37-
compile = false
38-
}
39-
40-
plugin graphql {
41-
provider = "@plugins/graphql"
42-
output = "src/__generated__/graphql"
12+
plugin crud {
13+
provider = "@stormstack/tools-forecast-plugins-crud"
14+
output = "src/__generated__/crud"
4315
compile = false
4416
}
4517

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { MissingContextError } from "@stormstack/core-shared-utilities";
2+
import { AsyncLocalStorage } from "node:async_hooks";
3+
4+
const asyncLocalStorage = new AsyncLocalStorage<AsyncScope>();
5+
6+
export class AsyncScope {
7+
static get() {
8+
const scope = asyncLocalStorage.getStore();
9+
if (!scope) {
10+
throw new MissingContextError("GlobalContextStore");
11+
}
12+
13+
return scope;
14+
}
15+
16+
constructor(callback: () => void) {
17+
const parentScope = asyncLocalStorage.getStore();
18+
if (parentScope) {
19+
Object.setPrototypeOf(this, parentScope);
20+
}
21+
22+
asyncLocalStorage.run(this, callback);
23+
}
24+
}

libs/core/typescript/server/utilities/src/exists.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { existsSync } from "fs";
1+
import { existsSync } from "node:fs";
22

33
export const exists = (filePath: string): boolean => {
44
return existsSync(filePath);
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Path from "path";
1+
import Path, { dirname, isAbsolute, join } from "path";
22

3-
export const findFileName = (filePath: string): string => {
3+
export function findFileName(filePath: string): string {
44
return (
55
filePath
66
?.split(
@@ -12,8 +12,16 @@ export const findFileName = (filePath: string): string => {
1212
)
1313
?.pop() ?? ""
1414
);
15-
};
15+
}
1616

17-
export const findFilePath = (filePath: string): string => {
17+
export function findFilePath(filePath: string): string {
1818
return filePath.replace(findFileName(filePath), "");
19-
};
19+
}
20+
21+
export function resolvePath(filePath: string, basePath?: string) {
22+
if (isAbsolute(filePath)) {
23+
return filePath;
24+
} else {
25+
return join(dirname(basePath), filePath);
26+
}
27+
}

libs/core/typescript/shared/logging/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "@stormstack/core-shared-logging",
33
"version": "0.0.1",
4+
"type": "module",
45
"dependencies": {
5-
"chalk": "4.1.0",
6-
"ora": "^7.0.1"
6+
"chalk": "4.1.0"
77
},
88
"devDependencies": {
99
"@types/jest": "29.5.3"

libs/core/typescript/shared/logging/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"bundle": true,
1717
"metafile": true,
1818
"minify": true,
19-
"format": ["esm", "cjs"]
19+
"format": ["esm", "cjs"],
20+
"thirdParty": true
2021
}
2122
},
2223
"lint": {

libs/core/typescript/shared/logging/src/console/console-logger.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
/* eslint-disable @typescript-eslint/no-empty-function */
33
import { Provider } from "@stormstack/core-shared-injection/decorators";
4-
import ora from "ora";
54
import { formatLog } from "../format";
65
import { Logger } from "../logger";
76
import {
@@ -13,7 +12,6 @@ import {
1312
printWarning,
1413
startGroup
1514
} from "./print";
16-
import { ConsoleSpinner } from "./types";
1715

1816
@Provider(Logger)
1917
export class ConsoleLogger extends Logger {
@@ -109,39 +107,6 @@ export class ConsoleLogger extends Logger {
109107
endGroup();
110108
}
111109

112-
/**
113-
* The function returns a ConsoleSpinner object, which is created using the ora library and takes an
114-
* optional text parameter.
115-
* @param {string} [text] - The `text` parameter is an optional string that represents the text to be
116-
* displayed alongside the spinner.
117-
* @returns an instance of the `ConsoleSpinner` class.
118-
*/
119-
static spinner(text?: string): ConsoleSpinner {
120-
return ora(text);
121-
}
122-
123-
/**
124-
* The function `spinnerStart` returns a ConsoleSpinner object that starts a spinner animation with an
125-
* optional text.
126-
* @param {string} [text] - The `text` parameter is an optional string that represents the text to be
127-
* displayed alongside the spinner. It is used to provide additional context or information to the user
128-
* while the spinner is running. If no `text` is provided, the spinner will be displayed without any
129-
* accompanying text.
130-
* @returns a ConsoleSpinner object.
131-
*/
132-
static spinnerStart(text?: string): ConsoleSpinner {
133-
return ConsoleLogger.spinner(text).start();
134-
}
135-
136-
/**
137-
* The function stops a console spinner and returns the stopped spinner.
138-
* @param {ConsoleSpinner} spinner - The parameter "spinner" is of type "ConsoleSpinner".
139-
* @returns the stopped spinner object.
140-
*/
141-
static spinnerStop(spinner: ConsoleSpinner): ConsoleSpinner {
142-
return spinner.stop();
143-
}
144-
145110
public constructor(_name = "root") {
146111
super(_name);
147112
}

nx.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"tools/devops/*",
4949
"tools/executors/*",
5050
"tools/generators/*",
51-
"tools/storm/*",
51+
"tools/nx/*",
52+
"tools/forecast/*",
5253
"design-system/*",
5354
"libs/core/*",
5455
"libs/common/*",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "stormstack",
2+
"name": "@stormstack/root",
33
"namespace": "@stormstack",
44
"version": "0.0.0",
55
"private": true,

0 commit comments

Comments
 (0)