zenstack 1.0.0 → 1.0.16
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/LICENSE +1 -1
- package/README.md +126 -1
- package/bin/cli +3 -0
- package/bin/post-install.js +24 -0
- package/cli/cli-error.d.ts +5 -0
- package/cli/cli-error.js +10 -0
- package/cli/cli-error.js.map +1 -0
- package/cli/cli-util.d.ts +18 -0
- package/cli/cli-util.js +143 -0
- package/cli/cli-util.js.map +1 -0
- package/cli/index.d.ts +15 -0
- package/cli/index.js +121 -0
- package/cli/index.js.map +1 -0
- package/cli/plugin-runner.d.ts +14 -0
- package/cli/plugin-runner.js +145 -0
- package/cli/plugin-runner.js.map +1 -0
- package/constants.d.ts +1 -0
- package/constants.js +6 -0
- package/constants.js.map +1 -0
- package/language-server/constants.d.ts +15 -0
- package/language-server/constants.js +20 -0
- package/language-server/constants.js.map +1 -0
- package/language-server/main.d.ts +1 -0
- package/language-server/main.js +13 -0
- package/language-server/main.js.map +1 -0
- package/language-server/types.d.ts +10 -0
- package/language-server/types.js +3 -0
- package/language-server/types.js.map +1 -0
- package/language-server/utils.d.ts +18 -0
- package/language-server/utils.js +58 -0
- package/language-server/utils.js.map +1 -0
- package/language-server/validator/attribute-validator.d.ts +9 -0
- package/language-server/validator/attribute-validator.js +11 -0
- package/language-server/validator/attribute-validator.js.map +1 -0
- package/language-server/validator/datamodel-validator.d.ts +15 -0
- package/language-server/validator/datamodel-validator.js +278 -0
- package/language-server/validator/datamodel-validator.js.map +1 -0
- package/language-server/validator/datasource-validator.d.ts +12 -0
- package/language-server/validator/datasource-validator.js +66 -0
- package/language-server/validator/datasource-validator.js.map +1 -0
- package/language-server/validator/enum-validator.d.ts +11 -0
- package/language-server/validator/enum-validator.js +28 -0
- package/language-server/validator/enum-validator.js.map +1 -0
- package/language-server/validator/expression-validator.d.ts +10 -0
- package/language-server/validator/expression-validator.js +30 -0
- package/language-server/validator/expression-validator.js.map +1 -0
- package/language-server/validator/schema-validator.d.ts +10 -0
- package/language-server/validator/schema-validator.js +28 -0
- package/language-server/validator/schema-validator.js.map +1 -0
- package/language-server/validator/utils.d.ts +25 -0
- package/language-server/validator/utils.js +257 -0
- package/language-server/validator/utils.js.map +1 -0
- package/language-server/validator/zmodel-validator.d.ts +21 -0
- package/language-server/validator/zmodel-validator.js +69 -0
- package/language-server/validator/zmodel-validator.js.map +1 -0
- package/language-server/zmodel-code-action.d.ts +14 -0
- package/language-server/zmodel-code-action.js +93 -0
- package/language-server/zmodel-code-action.js.map +1 -0
- package/language-server/zmodel-formatter.d.ts +9 -0
- package/language-server/zmodel-formatter.js +76 -0
- package/language-server/zmodel-formatter.js.map +1 -0
- package/language-server/zmodel-linker.d.ts +29 -0
- package/language-server/zmodel-linker.js +366 -0
- package/language-server/zmodel-linker.js.map +1 -0
- package/language-server/zmodel-module.d.ts +41 -0
- package/language-server/zmodel-module.js +80 -0
- package/language-server/zmodel-module.js.map +1 -0
- package/language-server/zmodel-scope.d.ts +10 -0
- package/language-server/zmodel-scope.js +44 -0
- package/language-server/zmodel-scope.js.map +1 -0
- package/language-server/zmodel-workspace-manager.d.ts +8 -0
- package/language-server/zmodel-workspace-manager.js +37 -0
- package/language-server/zmodel-workspace-manager.js.map +1 -0
- package/package.json +133 -8
- package/plugins/access-policy/expression-writer.d.ts +39 -0
- package/plugins/access-policy/expression-writer.js +361 -0
- package/plugins/access-policy/expression-writer.js.map +1 -0
- package/plugins/access-policy/index.d.ts +4 -0
- package/plugins/access-policy/index.js +24 -0
- package/plugins/access-policy/index.js.map +1 -0
- package/plugins/access-policy/policy-guard-generator.d.ts +15 -0
- package/plugins/access-policy/policy-guard-generator.js +349 -0
- package/plugins/access-policy/policy-guard-generator.js.map +1 -0
- package/plugins/access-policy/typescript-expression-transformer.d.ts +26 -0
- package/plugins/access-policy/typescript-expression-transformer.js +111 -0
- package/plugins/access-policy/typescript-expression-transformer.js.map +1 -0
- package/plugins/access-policy/utils.d.ts +5 -0
- package/plugins/access-policy/utils.js +14 -0
- package/plugins/access-policy/utils.js.map +1 -0
- package/plugins/access-policy/zod-schema-generator.d.ts +12 -0
- package/plugins/access-policy/zod-schema-generator.js +158 -0
- package/plugins/access-policy/zod-schema-generator.js.map +1 -0
- package/plugins/model-meta/index.d.ts +4 -0
- package/plugins/model-meta/index.js +168 -0
- package/plugins/model-meta/index.js.map +1 -0
- package/plugins/plugin-utils.d.ts +16 -0
- package/plugins/plugin-utils.js +54 -0
- package/plugins/plugin-utils.js.map +1 -0
- package/plugins/prisma/indent-string.d.ts +4 -0
- package/plugins/prisma/indent-string.js +12 -0
- package/plugins/prisma/indent-string.js.map +1 -0
- package/plugins/prisma/index.d.ts +4 -0
- package/plugins/prisma/index.js +24 -0
- package/plugins/prisma/index.js.map +1 -0
- package/plugins/prisma/prisma-builder.d.ts +152 -0
- package/plugins/prisma/prisma-builder.js +363 -0
- package/plugins/prisma/prisma-builder.js.map +1 -0
- package/plugins/prisma/schema-generator.d.ts +25 -0
- package/plugins/prisma/schema-generator.js +292 -0
- package/plugins/prisma/schema-generator.js.map +1 -0
- package/plugins/prisma/zmodel-code-generator.d.ts +28 -0
- package/plugins/prisma/zmodel-code-generator.js +114 -0
- package/plugins/prisma/zmodel-code-generator.js.map +1 -0
- package/res/prism-zmodel.js +20 -0
- package/res/starter.zmodel +51 -0
- package/res/stdlib.zmodel +346 -0
- package/telemetry.d.ts +20 -0
- package/telemetry.js +119 -0
- package/telemetry.js.map +1 -0
- package/types.d.ts +12 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
- package/utils/ast-utils.d.ts +16 -0
- package/utils/ast-utils.js +85 -0
- package/utils/ast-utils.js.map +1 -0
- package/utils/exec-utils.d.ts +6 -0
- package/utils/exec-utils.js +13 -0
- package/utils/exec-utils.js.map +1 -0
- package/utils/pkg-utils.d.ts +3 -0
- package/utils/pkg-utils.js +46 -0
- package/utils/pkg-utils.js.map +1 -0
- package/utils/version-utils.d.ts +1 -0
- package/utils/version-utils.js +14 -0
- package/utils/version-utils.js.map +1 -0
- package/.vscode/extensions.json +0 -7
- package/.vscode/launch.json +0 -49
- package/.vscode/settings.json +0 -4
- package/packages/internal/jest.config.ts +0 -32
- package/packages/internal/package.json +0 -42
- package/packages/internal/src/constants.ts +0 -1
- package/packages/internal/src/handler/data/guard-utils.ts +0 -7
- package/packages/internal/src/handler/data/handler.ts +0 -415
- package/packages/internal/src/handler/data/query-processor.ts +0 -504
- package/packages/internal/src/handler/index.ts +0 -1
- package/packages/internal/src/handler/types.ts +0 -20
- package/packages/internal/src/index.ts +0 -3
- package/packages/internal/src/request-handler.ts +0 -27
- package/packages/internal/src/request.ts +0 -101
- package/packages/internal/src/types.ts +0 -40
- package/packages/internal/tests/query-processor.test.ts +0 -172
- package/packages/internal/tsconfig.json +0 -21
- package/packages/runtime/auth.d.ts +0 -1
- package/packages/runtime/auth.js +0 -3
- package/packages/runtime/hooks.d.ts +0 -10
- package/packages/runtime/hooks.js +0 -3
- package/packages/runtime/index.d.ts +0 -3
- package/packages/runtime/index.js +0 -1
- package/packages/runtime/package-lock.json +0 -512
- package/packages/runtime/package.json +0 -16
- package/packages/runtime/server.d.ts +0 -1
- package/packages/runtime/server.js +0 -3
- package/packages/runtime/types.d.ts +0 -1
- package/packages/runtime/types.js +0 -3
- package/packages/schema/.eslintrc.json +0 -13
- package/packages/schema/.vscodeignore +0 -4
- package/packages/schema/asset/logo-dark.png +0 -0
- package/packages/schema/asset/logo-light.png +0 -0
- package/packages/schema/bin/cli +0 -3
- package/packages/schema/jest.config.ts +0 -32
- package/packages/schema/langium-config.json +0 -14
- package/packages/schema/langium-quickstart.md +0 -41
- package/packages/schema/language-configuration.json +0 -30
- package/packages/schema/package.json +0 -96
- package/packages/schema/src/cli/cli-util.ts +0 -80
- package/packages/schema/src/cli/index.ts +0 -64
- package/packages/schema/src/extension.ts +0 -76
- package/packages/schema/src/generator/constants.ts +0 -5
- package/packages/schema/src/generator/index.ts +0 -92
- package/packages/schema/src/generator/next-auth/index.ts +0 -197
- package/packages/schema/src/generator/package.template.json +0 -9
- package/packages/schema/src/generator/prisma/expression-writer.ts +0 -352
- package/packages/schema/src/generator/prisma/index.ts +0 -32
- package/packages/schema/src/generator/prisma/plain-expression-builder.ts +0 -91
- package/packages/schema/src/generator/prisma/prisma-builder.ts +0 -366
- package/packages/schema/src/generator/prisma/query-gard-generator.ts +0 -208
- package/packages/schema/src/generator/prisma/schema-generator.ts +0 -300
- package/packages/schema/src/generator/react-hooks/index.ts +0 -181
- package/packages/schema/src/generator/service/index.ts +0 -107
- package/packages/schema/src/generator/tsconfig.template.json +0 -17
- package/packages/schema/src/generator/types.ts +0 -17
- package/packages/schema/src/generator/utils.ts +0 -9
- package/packages/schema/src/language-server/generated/ast.ts +0 -603
- package/packages/schema/src/language-server/generated/grammar.ts +0 -2190
- package/packages/schema/src/language-server/generated/module.ts +0 -24
- package/packages/schema/src/language-server/main.ts +0 -12
- package/packages/schema/src/language-server/stdlib.zmodel +0 -22
- package/packages/schema/src/language-server/types.ts +0 -9
- package/packages/schema/src/language-server/zmodel-index.ts +0 -33
- package/packages/schema/src/language-server/zmodel-linker.ts +0 -409
- package/packages/schema/src/language-server/zmodel-module.ts +0 -90
- package/packages/schema/src/language-server/zmodel-scope.ts +0 -21
- package/packages/schema/src/language-server/zmodel-validator.ts +0 -35
- package/packages/schema/src/language-server/zmodel.langium +0 -186
- package/packages/schema/src/utils/exec-utils.ts +0 -5
- package/packages/schema/src/utils/indent-string.ts +0 -6
- package/packages/schema/syntaxes/zmodel.json +0 -57
- package/packages/schema/syntaxes/zmodel.tmLanguage.json +0 -57
- package/packages/schema/tests/generator/expression-writer.test.ts +0 -676
- package/packages/schema/tests/generator/prisma-builder.test.ts +0 -138
- package/packages/schema/tests/schema/parser.test.ts +0 -423
- package/packages/schema/tests/schema/sample-todo.test.ts +0 -14
- package/packages/schema/tests/utils.ts +0 -38
- package/packages/schema/tsconfig.json +0 -23
- package/pnpm-workspace.yaml +0 -3
- package/samples/todo/.env +0 -2
- package/samples/todo/.eslintrc.json +0 -3
- package/samples/todo/.vscode/launch.json +0 -11
- package/samples/todo/README.md +0 -34
- package/samples/todo/components/AuthGuard.tsx +0 -17
- package/samples/todo/components/Avatar.tsx +0 -22
- package/samples/todo/components/BreadCrumb.tsx +0 -44
- package/samples/todo/components/ManageMembers.tsx +0 -134
- package/samples/todo/components/NavBar.tsx +0 -57
- package/samples/todo/components/SpaceMembers.tsx +0 -76
- package/samples/todo/components/Spaces.tsx +0 -28
- package/samples/todo/components/TimeInfo.tsx +0 -17
- package/samples/todo/components/Todo.tsx +0 -72
- package/samples/todo/components/TodoList.tsx +0 -77
- package/samples/todo/lib/context.ts +0 -31
- package/samples/todo/next.config.js +0 -10
- package/samples/todo/package-lock.json +0 -7527
- package/samples/todo/package.json +0 -45
- package/samples/todo/pages/_app.tsx +0 -50
- package/samples/todo/pages/api/auth/[...nextauth].ts +0 -83
- package/samples/todo/pages/api/zenstack/[...path].ts +0 -16
- package/samples/todo/pages/create-space.tsx +0 -114
- package/samples/todo/pages/index.tsx +0 -32
- package/samples/todo/pages/space/[slug]/[listId]/index.tsx +0 -88
- package/samples/todo/pages/space/[slug]/index.tsx +0 -169
- package/samples/todo/postcss.config.js +0 -6
- package/samples/todo/public/avatar.jpg +0 -0
- package/samples/todo/public/favicon.ico +0 -0
- package/samples/todo/public/logo.png +0 -0
- package/samples/todo/public/vercel.svg +0 -4
- package/samples/todo/styles/globals.css +0 -7
- package/samples/todo/tailwind.config.js +0 -11
- package/samples/todo/tsconfig.json +0 -28
- package/samples/todo/types/next-auth.d.ts +0 -14
- package/samples/todo/types/next.d.ts +0 -16
- package/samples/todo/zenstack/migrations/20221014084317_init/migration.sql +0 -153
- package/samples/todo/zenstack/migrations/20221020094651_upate_cli/migration.sql +0 -23
- package/samples/todo/zenstack/migrations/migration_lock.toml +0 -3
- package/samples/todo/zenstack/schema.prisma +0 -126
- package/samples/todo/zenstack/schema.zmodel +0 -161
- package/tests/integration/jest.config.ts +0 -16
- package/tests/integration/package-lock.json +0 -1081
- package/tests/integration/package.json +0 -27
- package/tests/integration/tests/operation-coverate.test.ts +0 -563
- package/tests/integration/tests/operations.zmodel +0 -69
- package/tests/integration/tests/todo-e2e.test.ts +0 -577
- package/tests/integration/tests/todo.zmodel +0 -123
- package/tests/integration/tests/tsconfig.template.json +0 -10
- package/tests/integration/tests/utils.ts +0 -133
- package/tests/integration/tsconfig.json +0 -10
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Welcome to your Langium VS Code Extension
|
|
2
|
-
|
|
3
|
-
## What's in the folder
|
|
4
|
-
|
|
5
|
-
This folder contains all necessary files for your language extension.
|
|
6
|
-
|
|
7
|
-
- `package.json` - the manifest file in which you declare your language support.
|
|
8
|
-
- `language-configuration.json` - the language configuration used in the VS Code editor, defining the tokens that are used for comments and brackets.
|
|
9
|
-
- `src/extension.ts` - the main code of the extension, which is responsible for launching a language server and client.
|
|
10
|
-
- `src/language-server/zmodel.langium` - the grammar definition of your language.
|
|
11
|
-
- `src/language-server/main.ts` - the entry point of the language server process.
|
|
12
|
-
- `src/language-server/zmodel-module.ts` - the dependency injection module of your language implementation. Use this to register overridden and added services.
|
|
13
|
-
- `src/language-server/zmodel-validator.ts` - an example validator. You should change it to reflect the semantics of your language.
|
|
14
|
-
- `src/cli/index.ts` - the entry point of the command line interface (CLI) of your language.
|
|
15
|
-
- `src/cli/generator.ts` - the code generator used by the CLI to write output files from DSL documents.
|
|
16
|
-
- `src/cli/cli-util.ts` - utility code for the CLI.
|
|
17
|
-
|
|
18
|
-
## Get up and running straight away
|
|
19
|
-
|
|
20
|
-
- Run `npm run langium:generate` to generate TypeScript code from the grammar definition.
|
|
21
|
-
- Run `npm run build` to compile all TypeScript code.
|
|
22
|
-
- Press `F5` to open a new window with your extension loaded.
|
|
23
|
-
- Create a new file with a file name suffix matching your language.
|
|
24
|
-
- Verify that syntax highlighting, validation, completion etc. are working as expected.
|
|
25
|
-
- Run `./bin/cli` to see options for the CLI; `./bin/cli generate <file>` generates code for a given DSL file.
|
|
26
|
-
|
|
27
|
-
## Make changes
|
|
28
|
-
|
|
29
|
-
- Run `npm run watch` to have the TypeScript compiler run automatically after every change of the source files.
|
|
30
|
-
- Run `npm run langium:watch` to have the Langium generator run automatically afer every change of the grammar declaration.
|
|
31
|
-
- You can relaunch the extension from the debug toolbar after making changes to the files listed above.
|
|
32
|
-
- You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
|
|
33
|
-
|
|
34
|
-
## Install your extension
|
|
35
|
-
|
|
36
|
-
- To start using your extension with VS Code, copy it into the `<user home>/.vscode/extensions` folder and restart Code.
|
|
37
|
-
- To share your extension with the world, read the [VS Code documentation](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) about publishing an extension.
|
|
38
|
-
|
|
39
|
-
## To Go Further
|
|
40
|
-
|
|
41
|
-
Documentation about the Langium framework is available at https://langium.org
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"comments": {
|
|
3
|
-
// symbol used for single line comment. Remove this entry if your language does not support line comments
|
|
4
|
-
"lineComment": "//",
|
|
5
|
-
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
|
|
6
|
-
"blockComment": [ "/*", "*/" ]
|
|
7
|
-
},
|
|
8
|
-
// symbols used as brackets
|
|
9
|
-
"brackets": [
|
|
10
|
-
["{", "}"],
|
|
11
|
-
["[", "]"],
|
|
12
|
-
["(", ")"]
|
|
13
|
-
],
|
|
14
|
-
// symbols that are auto closed when typing
|
|
15
|
-
"autoClosingPairs": [
|
|
16
|
-
["{", "}"],
|
|
17
|
-
["[", "]"],
|
|
18
|
-
["(", ")"],
|
|
19
|
-
["\"", "\""],
|
|
20
|
-
["'", "'"]
|
|
21
|
-
],
|
|
22
|
-
// symbols that can be used to surround a selection
|
|
23
|
-
"surroundingPairs": [
|
|
24
|
-
["{", "}"],
|
|
25
|
-
["[", "]"],
|
|
26
|
-
["(", ")"],
|
|
27
|
-
["\"", "\""],
|
|
28
|
-
["'", "'"]
|
|
29
|
-
]
|
|
30
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "zenstack",
|
|
3
|
-
"displayName": "ZenStack CLI and Language Tools",
|
|
4
|
-
"description": "ZenStack CLI and Language Tools",
|
|
5
|
-
"version": "0.1.43",
|
|
6
|
-
"engines": {
|
|
7
|
-
"vscode": "^1.56.0"
|
|
8
|
-
},
|
|
9
|
-
"categories": [
|
|
10
|
-
"Programming Languages"
|
|
11
|
-
],
|
|
12
|
-
"contributes": {
|
|
13
|
-
"languages": [
|
|
14
|
-
{
|
|
15
|
-
"id": "zmodel",
|
|
16
|
-
"aliases": [
|
|
17
|
-
"ZenStack Model",
|
|
18
|
-
"zmodel"
|
|
19
|
-
],
|
|
20
|
-
"extensions": [
|
|
21
|
-
".zmodel"
|
|
22
|
-
],
|
|
23
|
-
"configuration": "./language-configuration.json",
|
|
24
|
-
"icon": {
|
|
25
|
-
"light": "./asset/logo-light.png",
|
|
26
|
-
"dark": "./asset/logo-dark.png"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
"grammars": [
|
|
31
|
-
{
|
|
32
|
-
"language": "zmodel",
|
|
33
|
-
"scopeName": "source.zmodel",
|
|
34
|
-
"path": "./syntaxes/zmodel.tmLanguage.json"
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
},
|
|
38
|
-
"activationEvents": [
|
|
39
|
-
"onLanguage:zmodel"
|
|
40
|
-
],
|
|
41
|
-
"files": [
|
|
42
|
-
"bin",
|
|
43
|
-
"out"
|
|
44
|
-
],
|
|
45
|
-
"bin": {
|
|
46
|
-
"zenstack": "./bin/cli"
|
|
47
|
-
},
|
|
48
|
-
"main": "./out/extension.js",
|
|
49
|
-
"scripts": {
|
|
50
|
-
"vscode:prepublish": "npm run build && npm run lint",
|
|
51
|
-
"build": "tsc && tsc-alias && cp src/language-server/stdlib.zmodel ./out/language-server/ && cp src/generator/*.template.json ./out/generator/",
|
|
52
|
-
"ts:watch": "tsc --watch",
|
|
53
|
-
"tsc-alias:watch": "tsc-alias --watch",
|
|
54
|
-
"lint": "eslint src --ext ts",
|
|
55
|
-
"langium:generate": "langium generate",
|
|
56
|
-
"langium:watch": "langium generate --watch",
|
|
57
|
-
"watch": "concurrently --kill-others \"npm:langium:watch\" \"npm:ts:watch\" \"npm:tsc-alias:watch\"",
|
|
58
|
-
"test": "jest",
|
|
59
|
-
"prepublishOnly": "pnpm build"
|
|
60
|
-
},
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"@zenstackhq/internal": "workspace:*",
|
|
63
|
-
"change-case": "^4.1.2",
|
|
64
|
-
"chevrotain": "^9.1.0",
|
|
65
|
-
"colors": "^1.4.0",
|
|
66
|
-
"commander": "^8.0.0",
|
|
67
|
-
"langium": "^0.4.0",
|
|
68
|
-
"prisma": "^4.4.0",
|
|
69
|
-
"promisify": "^0.0.3",
|
|
70
|
-
"ts-morph": "^16.0.0",
|
|
71
|
-
"vscode-jsonrpc": "^8.0.2",
|
|
72
|
-
"vscode-languageclient": "^7.0.0",
|
|
73
|
-
"vscode-languageserver": "^7.0.0",
|
|
74
|
-
"vscode-uri": "^3.0.2"
|
|
75
|
-
},
|
|
76
|
-
"devDependencies": {
|
|
77
|
-
"@prisma/internals": "^4.4.0",
|
|
78
|
-
"@types/jest": "^29.0.3",
|
|
79
|
-
"@types/node": "^14.18.29",
|
|
80
|
-
"@types/tmp": "^0.2.3",
|
|
81
|
-
"@types/uuid": "^8.3.4",
|
|
82
|
-
"@types/vscode": "^1.56.0",
|
|
83
|
-
"@typescript-eslint/eslint-plugin": "^4.14.1",
|
|
84
|
-
"@typescript-eslint/parser": "^4.14.1",
|
|
85
|
-
"concurrently": "^7.4.0",
|
|
86
|
-
"eslint": "^7.19.0",
|
|
87
|
-
"jest": "^29.0.3",
|
|
88
|
-
"langium-cli": "^0.4.0",
|
|
89
|
-
"tmp": "^0.2.1",
|
|
90
|
-
"ts-jest": "^29.0.1",
|
|
91
|
-
"ts-node": "^10.9.1",
|
|
92
|
-
"tsc-alias": "^1.7.0",
|
|
93
|
-
"tsconfig-paths-jest": "^0.0.1",
|
|
94
|
-
"typescript": "^4.6.2"
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import colors from 'colors';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import { AstNode, LangiumDocument, LangiumServices } from 'langium';
|
|
5
|
-
import { URI } from 'vscode-uri';
|
|
6
|
-
|
|
7
|
-
export async function extractDocument(
|
|
8
|
-
fileName: string,
|
|
9
|
-
services: LangiumServices
|
|
10
|
-
): Promise<LangiumDocument> {
|
|
11
|
-
const extensions = services.LanguageMetaData.fileExtensions;
|
|
12
|
-
if (!extensions.includes(path.extname(fileName))) {
|
|
13
|
-
console.error(
|
|
14
|
-
colors.yellow(
|
|
15
|
-
`Please choose a file with one of these extensions: ${extensions}.`
|
|
16
|
-
)
|
|
17
|
-
);
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!fs.existsSync(fileName)) {
|
|
22
|
-
console.error(colors.red(`File ${fileName} does not exist.`));
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const stdLib =
|
|
27
|
-
services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
28
|
-
URI.file(path.join(__dirname, '../language-server/stdlib.zmodel'))
|
|
29
|
-
);
|
|
30
|
-
const document =
|
|
31
|
-
services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
32
|
-
URI.file(path.resolve(fileName))
|
|
33
|
-
);
|
|
34
|
-
await services.shared.workspace.DocumentBuilder.build([stdLib, document], {
|
|
35
|
-
validationChecks: 'all',
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const validationErrors = (document.diagnostics ?? []).filter(
|
|
39
|
-
(e) => e.severity === 1
|
|
40
|
-
);
|
|
41
|
-
if (validationErrors.length > 0) {
|
|
42
|
-
console.error(colors.red('There are validation errors:'));
|
|
43
|
-
for (const validationError of validationErrors) {
|
|
44
|
-
console.error(
|
|
45
|
-
colors.red(
|
|
46
|
-
`line ${validationError.range.start.line + 1}: ${
|
|
47
|
-
validationError.message
|
|
48
|
-
} [${document.textDocument.getText(validationError.range)}]`
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return document;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export async function extractAstNode<T extends AstNode>(
|
|
59
|
-
fileName: string,
|
|
60
|
-
services: LangiumServices
|
|
61
|
-
): Promise<T> {
|
|
62
|
-
return (await extractDocument(fileName, services)).parseResult?.value as T;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface FilePathData {
|
|
66
|
-
destination: string;
|
|
67
|
-
name: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function extractDestinationAndName(
|
|
71
|
-
filePath: string,
|
|
72
|
-
destination: string | undefined
|
|
73
|
-
): FilePathData {
|
|
74
|
-
filePath = filePath.replace(/\..*$/, '').replace(/[.-]/g, '');
|
|
75
|
-
return {
|
|
76
|
-
destination:
|
|
77
|
-
destination ?? path.join(path.dirname(filePath), 'generated'),
|
|
78
|
-
name: path.basename(filePath),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { Model } from '../language-server/generated/ast';
|
|
3
|
-
import { ZModelLanguageMetaData } from '../language-server/generated/module';
|
|
4
|
-
import { createZModelServices } from '../language-server/zmodel-module';
|
|
5
|
-
import { extractAstNode } from './cli-util';
|
|
6
|
-
import { Context, GeneratorError } from '../generator/types';
|
|
7
|
-
import { ZenStackGenerator } from '../generator';
|
|
8
|
-
import { GENERATED_CODE_PATH } from '../generator/constants';
|
|
9
|
-
import colors from 'colors';
|
|
10
|
-
|
|
11
|
-
export const generateAction = async (
|
|
12
|
-
fileName: string,
|
|
13
|
-
opts: GenerateOptions
|
|
14
|
-
): Promise<void> => {
|
|
15
|
-
const services = createZModelServices().ZModel;
|
|
16
|
-
const model = await extractAstNode<Model>(fileName, services);
|
|
17
|
-
|
|
18
|
-
const context: Context = {
|
|
19
|
-
schema: model,
|
|
20
|
-
outDir: opts.destination || './zenstack',
|
|
21
|
-
// TODO: make this configurable
|
|
22
|
-
generatedCodeDir: GENERATED_CODE_PATH,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
await new ZenStackGenerator().generate(context);
|
|
27
|
-
} catch (err) {
|
|
28
|
-
if (err instanceof GeneratorError) {
|
|
29
|
-
console.error(colors.red(err.message));
|
|
30
|
-
process.exit(-1);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type GenerateOptions = {
|
|
36
|
-
destination?: string;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default function (): void {
|
|
40
|
-
const program = new Command('zenstack');
|
|
41
|
-
|
|
42
|
-
program.version(
|
|
43
|
-
require('../../package.json').version,
|
|
44
|
-
'-v --version',
|
|
45
|
-
'display CLI version'
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
program.description(
|
|
49
|
-
`${colors.bold.blue(
|
|
50
|
-
'ζ'
|
|
51
|
-
)} ZenStack simplifies fullstack development by generating backend services and Typescript clients from a data model.\n\nDocumentation: https://zenstack.dev/doc.`
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const fileExtensions = ZModelLanguageMetaData.fileExtensions.join(', ');
|
|
55
|
-
program
|
|
56
|
-
.command('generate')
|
|
57
|
-
.argument('<file>', `source file (with extension ${fileExtensions})`)
|
|
58
|
-
.description(
|
|
59
|
-
'generates RESTful API and Typescript client for your data model'
|
|
60
|
-
)
|
|
61
|
-
.action(generateAction);
|
|
62
|
-
|
|
63
|
-
program.parse(process.argv);
|
|
64
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import * as vscode from 'vscode';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
LanguageClient,
|
|
5
|
-
LanguageClientOptions,
|
|
6
|
-
ServerOptions,
|
|
7
|
-
TransportKind,
|
|
8
|
-
} from 'vscode-languageclient/node';
|
|
9
|
-
|
|
10
|
-
let client: LanguageClient;
|
|
11
|
-
|
|
12
|
-
// This function is called when the extension is activated.
|
|
13
|
-
export function activate(context: vscode.ExtensionContext): void {
|
|
14
|
-
client = startLanguageClient(context);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// This function is called when the extension is deactivated.
|
|
18
|
-
export function deactivate(): Thenable<void> | undefined {
|
|
19
|
-
if (client) {
|
|
20
|
-
return client.stop();
|
|
21
|
-
}
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function startLanguageClient(context: vscode.ExtensionContext): LanguageClient {
|
|
26
|
-
const serverModule = context.asAbsolutePath(
|
|
27
|
-
path.join('out', 'language-server', 'main')
|
|
28
|
-
);
|
|
29
|
-
// The debug options for the server
|
|
30
|
-
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging.
|
|
31
|
-
// By setting `process.env.DEBUG_BREAK` to a truthy value, the language server will wait until a debugger is attached.
|
|
32
|
-
const debugOptions = {
|
|
33
|
-
execArgv: [
|
|
34
|
-
'--nolazy',
|
|
35
|
-
`--inspect${process.env.DEBUG_BREAK ? '-brk' : ''}=${
|
|
36
|
-
process.env.DEBUG_SOCKET || '6009'
|
|
37
|
-
}`,
|
|
38
|
-
],
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// If the extension is launched in debug mode then the debug server options are used
|
|
42
|
-
// Otherwise the run options are used
|
|
43
|
-
const serverOptions: ServerOptions = {
|
|
44
|
-
run: { module: serverModule, transport: TransportKind.ipc },
|
|
45
|
-
debug: {
|
|
46
|
-
module: serverModule,
|
|
47
|
-
transport: TransportKind.ipc,
|
|
48
|
-
options: debugOptions,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const fileSystemWatcher =
|
|
53
|
-
vscode.workspace.createFileSystemWatcher('**/*.zmodel');
|
|
54
|
-
context.subscriptions.push(fileSystemWatcher);
|
|
55
|
-
|
|
56
|
-
// Options to control the language client
|
|
57
|
-
const clientOptions: LanguageClientOptions = {
|
|
58
|
-
documentSelector: [{ scheme: 'file', language: 'zmodel' }],
|
|
59
|
-
synchronize: {
|
|
60
|
-
// Notify the server about file changes to files contained in the workspace
|
|
61
|
-
fileEvents: fileSystemWatcher,
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// Create the language client and start the client.
|
|
66
|
-
const client = new LanguageClient(
|
|
67
|
-
'zmodel',
|
|
68
|
-
'ZenStack Model',
|
|
69
|
-
serverOptions,
|
|
70
|
-
clientOptions
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
// Start the client. This will also launch the server
|
|
74
|
-
client.start();
|
|
75
|
-
return client;
|
|
76
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export const INTERNAL_PACKAGE = '@zenstackhq/internal';
|
|
2
|
-
export const GUARD_FIELD_NAME = 'zenstack_guard';
|
|
3
|
-
export const TRANSACTION_FIELD_NAME = 'zenstack_transaction';
|
|
4
|
-
export const API_ROUTE_NAME = 'zenstack';
|
|
5
|
-
export const GENERATED_CODE_PATH = 'node_modules/.zenstack';
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Context, GeneratorError } from './types';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import colors from 'colors';
|
|
4
|
-
import PrismaGenerator from './prisma';
|
|
5
|
-
import ServiceGenerator from './service';
|
|
6
|
-
import ReactHooksGenerator from './react-hooks';
|
|
7
|
-
import NextAuthGenerator from './next-auth';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { execSync } from '../utils/exec-utils';
|
|
10
|
-
|
|
11
|
-
export class ZenStackGenerator {
|
|
12
|
-
async generate(context: Context) {
|
|
13
|
-
// folder that stores generated prisma schema and migrations
|
|
14
|
-
if (!fs.existsSync(context.outDir)) {
|
|
15
|
-
fs.mkdirSync(context.outDir);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// folder that stores generated zenstack code
|
|
19
|
-
if (fs.existsSync(context.generatedCodeDir)) {
|
|
20
|
-
fs.rmSync(context.generatedCodeDir, {
|
|
21
|
-
force: true,
|
|
22
|
-
recursive: true,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
fs.mkdirSync(context.generatedCodeDir);
|
|
26
|
-
|
|
27
|
-
const version = require('../../package.json').version;
|
|
28
|
-
console.log(colors.bold(`⌛️ Running ZenStack generator v${version}`));
|
|
29
|
-
|
|
30
|
-
const generators = [
|
|
31
|
-
new PrismaGenerator(),
|
|
32
|
-
new ServiceGenerator(),
|
|
33
|
-
new ReactHooksGenerator(),
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
require('next-auth');
|
|
38
|
-
generators.push(new NextAuthGenerator());
|
|
39
|
-
} catch {
|
|
40
|
-
console.warn(
|
|
41
|
-
colors.yellow(
|
|
42
|
-
'Next-auth module is not installed, skipping generating adapter.'
|
|
43
|
-
)
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
for (const generator of generators) {
|
|
48
|
-
await generator.generate(context);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// generate package.json
|
|
52
|
-
const packageJson = require(path.join(
|
|
53
|
-
__dirname,
|
|
54
|
-
'package.template.json'
|
|
55
|
-
));
|
|
56
|
-
fs.writeFileSync(
|
|
57
|
-
path.join(context.generatedCodeDir, 'package.json'),
|
|
58
|
-
JSON.stringify(packageJson, undefined, 4)
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
// compile ts sources
|
|
62
|
-
const tsConfig = require(path.join(
|
|
63
|
-
__dirname,
|
|
64
|
-
'tsconfig.template.json'
|
|
65
|
-
));
|
|
66
|
-
fs.writeFileSync(
|
|
67
|
-
path.join(context.generatedCodeDir, 'tsconfig.json'),
|
|
68
|
-
JSON.stringify(tsConfig, undefined, 4)
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
execSync(
|
|
73
|
-
`npx tsc -p "${path.join(
|
|
74
|
-
context.generatedCodeDir,
|
|
75
|
-
'tsconfig.json'
|
|
76
|
-
)}"`
|
|
77
|
-
);
|
|
78
|
-
} catch {
|
|
79
|
-
throw new GeneratorError(
|
|
80
|
-
'Something went wrong, generated runtime code failed to compile...\nPlease check errors above.'
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
console.log(colors.blue(' ✔️ Typescript source files transpiled'));
|
|
85
|
-
|
|
86
|
-
console.log(
|
|
87
|
-
colors.green(
|
|
88
|
-
colors.bold('👻 All generators completed successfully!')
|
|
89
|
-
)
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { Context, Generator } from '../types';
|
|
2
|
-
import { Project } from 'ts-morph';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import colors from 'colors';
|
|
5
|
-
|
|
6
|
-
export default class NextAuthGenerator implements Generator {
|
|
7
|
-
async generate(context: Context) {
|
|
8
|
-
const project = new Project();
|
|
9
|
-
|
|
10
|
-
this.generateIndex(project, context);
|
|
11
|
-
this.generateAdapter(project, context);
|
|
12
|
-
this.generateAuthorize(project, context);
|
|
13
|
-
|
|
14
|
-
await project.save();
|
|
15
|
-
|
|
16
|
-
console.log(colors.blue(` ✔️ Next-auth adapter generated`));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
generateIndex(project: Project, context: Context) {
|
|
20
|
-
const sf = project.createSourceFile(
|
|
21
|
-
path.join(context.generatedCodeDir, 'src/auth/index.ts'),
|
|
22
|
-
undefined,
|
|
23
|
-
{ overwrite: true }
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
sf.addStatements([
|
|
27
|
-
`export * from './next-auth-adapter';`,
|
|
28
|
-
`export * from './authorize';`,
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
sf.formatText();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
generateAdapter(project: Project, context: Context) {
|
|
35
|
-
const content = `
|
|
36
|
-
import { ZenStackService } from '..';
|
|
37
|
-
import { Adapter } from 'next-auth/adapters';
|
|
38
|
-
import { Prisma } from '../../.prisma';
|
|
39
|
-
|
|
40
|
-
export function NextAuthAdapter(service: ZenStackService): Adapter {
|
|
41
|
-
const db = service.db;
|
|
42
|
-
return {
|
|
43
|
-
createUser: (data) => db.user.create({ data: data as Prisma.UserCreateInput }),
|
|
44
|
-
getUser: (id) => db.user.findUnique({ where: { id } }),
|
|
45
|
-
getUserByEmail: (email) => db.user.findUnique({ where: { email } }),
|
|
46
|
-
async getUserByAccount(provider_providerAccountId) {
|
|
47
|
-
const account = await db.account.findUnique({
|
|
48
|
-
where: { provider_providerAccountId },
|
|
49
|
-
select: { user: true },
|
|
50
|
-
});
|
|
51
|
-
return account?.user ?? null;
|
|
52
|
-
},
|
|
53
|
-
updateUser: (data) => db.user.update({ where: { id: data.id }, data: data as Prisma.UserUpdateInput }),
|
|
54
|
-
deleteUser: (id) => db.user.delete({ where: { id } }),
|
|
55
|
-
linkAccount: (data) => db.account.create({ data }) as any,
|
|
56
|
-
unlinkAccount: (provider_providerAccountId) =>
|
|
57
|
-
db.account.delete({ where: { provider_providerAccountId } }) as any,
|
|
58
|
-
async getSessionAndUser(sessionToken) {
|
|
59
|
-
const userAndSession = await db.session.findUnique({
|
|
60
|
-
where: { sessionToken },
|
|
61
|
-
include: { user: true },
|
|
62
|
-
});
|
|
63
|
-
if (!userAndSession) return null;
|
|
64
|
-
const { user, ...session } = userAndSession;
|
|
65
|
-
return { user, session };
|
|
66
|
-
},
|
|
67
|
-
createSession: (data) => db.session.create({ data }),
|
|
68
|
-
updateSession: (data) =>
|
|
69
|
-
db.session.update({
|
|
70
|
-
data,
|
|
71
|
-
where: { sessionToken: data.sessionToken },
|
|
72
|
-
}),
|
|
73
|
-
deleteSession: (sessionToken) =>
|
|
74
|
-
db.session.delete({ where: { sessionToken } }),
|
|
75
|
-
createVerificationToken: (data) => db.verificationToken.create({ data }),
|
|
76
|
-
async useVerificationToken(identifier_token) {
|
|
77
|
-
try {
|
|
78
|
-
return await db.verificationToken.delete({
|
|
79
|
-
where: { identifier_token },
|
|
80
|
-
});
|
|
81
|
-
} catch (error) {
|
|
82
|
-
// If token already used/deleted, just return null
|
|
83
|
-
// https://www.prisma.io/docs/reference/api-reference/error-reference#p2025
|
|
84
|
-
if (
|
|
85
|
-
(error as Prisma.PrismaClientKnownRequestError).code ===
|
|
86
|
-
'P2025'
|
|
87
|
-
)
|
|
88
|
-
return null;
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
`;
|
|
95
|
-
|
|
96
|
-
const sf = project.createSourceFile(
|
|
97
|
-
path.join(
|
|
98
|
-
context.generatedCodeDir,
|
|
99
|
-
'src/auth/next-auth-adapter.ts'
|
|
100
|
-
),
|
|
101
|
-
content,
|
|
102
|
-
{ overwrite: true }
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
sf.formatText();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
generateAuthorize(project: Project, context: Context) {
|
|
109
|
-
const content = `
|
|
110
|
-
import { ZenStackService } from '..';
|
|
111
|
-
import { hash, compare } from 'bcryptjs';
|
|
112
|
-
|
|
113
|
-
async function hashPassword(password: string) {
|
|
114
|
-
const hashedPassword = await hash(password, 12);
|
|
115
|
-
return hashedPassword;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function verifyPassword(password: string, hashedPassword: string) {
|
|
119
|
-
const isValid = await compare(password, hashedPassword);
|
|
120
|
-
return isValid;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export function authorize(service: ZenStackService) {
|
|
124
|
-
return async (
|
|
125
|
-
credentials: Record<'email' | 'password', string> | undefined
|
|
126
|
-
) => {
|
|
127
|
-
if (!credentials) {
|
|
128
|
-
throw new Error('Missing credentials');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
let maybeUser = await service.db.user.findFirst({
|
|
133
|
-
where: {
|
|
134
|
-
email: credentials!.email,
|
|
135
|
-
},
|
|
136
|
-
select: {
|
|
137
|
-
id: true,
|
|
138
|
-
email: true,
|
|
139
|
-
password: true,
|
|
140
|
-
name: true,
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
if (!maybeUser) {
|
|
145
|
-
if (!credentials.password || !credentials.email) {
|
|
146
|
-
throw new Error('Invalid Credentials');
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
maybeUser = await service.db.user.create({
|
|
150
|
-
data: {
|
|
151
|
-
email: credentials.email,
|
|
152
|
-
password: await hashPassword(credentials.password),
|
|
153
|
-
},
|
|
154
|
-
select: {
|
|
155
|
-
id: true,
|
|
156
|
-
email: true,
|
|
157
|
-
password: true,
|
|
158
|
-
name: true,
|
|
159
|
-
},
|
|
160
|
-
});
|
|
161
|
-
} else {
|
|
162
|
-
if (!maybeUser.password) {
|
|
163
|
-
throw new Error('Invalid User Record');
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const isValid = await verifyPassword(
|
|
167
|
-
credentials.password,
|
|
168
|
-
maybeUser.password
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
if (!isValid) {
|
|
172
|
-
throw new Error('Invalid Credentials');
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
id: maybeUser.id,
|
|
178
|
-
email: maybeUser.email,
|
|
179
|
-
name: maybeUser.name,
|
|
180
|
-
};
|
|
181
|
-
} catch (error) {
|
|
182
|
-
console.log(error);
|
|
183
|
-
throw error;
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
`;
|
|
188
|
-
|
|
189
|
-
const sf = project.createSourceFile(
|
|
190
|
-
path.join(context.generatedCodeDir, 'src/auth/authorize.ts'),
|
|
191
|
-
content,
|
|
192
|
-
{ overwrite: true }
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
sf.formatText();
|
|
196
|
-
}
|
|
197
|
-
}
|