@slingr/cli 0.0.2 â 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +202 -0
- package/README.md +490 -319
- package/bin/dev.cmd +2 -2
- package/bin/dev.js +5 -5
- package/bin/run.cmd +2 -2
- package/bin/run.js +4 -4
- package/bin/slingr +1 -0
- package/dist/commands/build.d.ts +20 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +206 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/create-app.d.ts +0 -1
- package/dist/commands/create-app.d.ts.map +1 -1
- package/dist/commands/create-app.js +38 -57
- package/dist/commands/create-app.js.map +1 -1
- package/dist/commands/debug.d.ts +28 -0
- package/dist/commands/debug.d.ts.map +1 -0
- package/dist/commands/debug.js +474 -0
- package/dist/commands/debug.js.map +1 -0
- package/dist/commands/ds.d.ts +14 -1
- package/dist/commands/ds.d.ts.map +1 -1
- package/dist/commands/ds.js +450 -121
- package/dist/commands/ds.js.map +1 -1
- package/dist/commands/gql.d.ts +1 -1
- package/dist/commands/gql.d.ts.map +1 -1
- package/dist/commands/gql.js +190 -184
- package/dist/commands/gql.js.map +1 -1
- package/dist/commands/infra/down.d.ts.map +1 -1
- package/dist/commands/infra/down.js +8 -7
- package/dist/commands/infra/down.js.map +1 -1
- package/dist/commands/infra/up.d.ts.map +1 -1
- package/dist/commands/infra/up.js +8 -7
- package/dist/commands/infra/up.js.map +1 -1
- package/dist/commands/infra/update.d.ts +1 -0
- package/dist/commands/infra/update.d.ts.map +1 -1
- package/dist/commands/infra/update.js +33 -69
- package/dist/commands/infra/update.js.map +1 -1
- package/dist/commands/run.d.ts +29 -2
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +628 -130
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/setup.d.ts +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +34 -71
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/sync-metadata.d.ts +15 -0
- package/dist/commands/sync-metadata.d.ts.map +1 -0
- package/dist/commands/sync-metadata.js +225 -0
- package/dist/commands/sync-metadata.js.map +1 -0
- package/dist/commands/users.d.ts +30 -0
- package/dist/commands/users.d.ts.map +1 -0
- package/dist/commands/users.js +472 -0
- package/dist/commands/users.js.map +1 -0
- package/dist/commands/views.d.ts +11 -0
- package/dist/commands/views.d.ts.map +1 -0
- package/dist/commands/views.js +73 -0
- package/dist/commands/views.js.map +1 -0
- package/dist/projectStructure.d.ts +2 -2
- package/dist/projectStructure.d.ts.map +1 -1
- package/dist/projectStructure.js +281 -69
- package/dist/projectStructure.js.map +1 -1
- package/dist/scripts/generate-metadata.d.ts +13 -0
- package/dist/scripts/generate-metadata.d.ts.map +1 -0
- package/dist/scripts/generate-metadata.js +412 -0
- package/dist/scripts/generate-metadata.js.map +1 -0
- package/dist/scripts/generate-metadata.ts +498 -0
- package/dist/scripts/generate-schema.d.ts +1 -1
- package/dist/scripts/generate-schema.js +168 -74
- package/dist/scripts/generate-schema.js.map +1 -1
- package/dist/scripts/generate-schema.ts +258 -143
- package/dist/templates/.env.template +23 -0
- package/dist/templates/.firebaserc.template +5 -0
- package/dist/templates/.github/copilot-instructions.md.template +652 -17
- package/dist/templates/backend/Dockerfile.template +30 -0
- package/dist/templates/config/datasource.ts.template +12 -9
- package/dist/templates/config/jest.config.ts +30 -30
- package/dist/templates/config/jest.setup.ts +1 -1
- package/dist/templates/config/tsconfig.json.template +50 -29
- package/dist/templates/dataSources/mysql.ts.template +16 -13
- package/dist/templates/dataSources/postgres.ts.template +15 -13
- package/dist/templates/dataset-generator-script.ts.template +139 -139
- package/dist/templates/datasets/mysql-default/.slingr-schema.json.template +5 -0
- package/dist/templates/datasets/mysql-default/Address.jsonl.template +3 -3
- package/dist/templates/datasets/mysql-default/App.jsonl.template +4 -4
- package/dist/templates/datasets/mysql-default/Company.jsonl.template +3 -3
- package/dist/templates/datasets/mysql-default/Person.jsonl.template +2 -2
- package/dist/templates/datasets/mysql-default/User.jsonl.template +1 -0
- package/dist/templates/datasets/mysql-default/instructions.md.template +1 -0
- package/dist/templates/datasets/postgres-default/.slingr-schema.json.template +5 -0
- package/dist/templates/datasets/postgres-default/Address.jsonl.template +3 -3
- package/dist/templates/datasets/postgres-default/App.jsonl.template +4 -4
- package/dist/templates/datasets/postgres-default/Company.jsonl.template +3 -3
- package/dist/templates/datasets/postgres-default/Person.jsonl.template +2 -2
- package/dist/templates/datasets/postgres-default/User.jsonl.template +1 -0
- package/dist/templates/datasets/postgres-default/instructions.md.template +1 -0
- package/dist/templates/docker-compose.prod-test.yml.template +32 -0
- package/dist/templates/docker-compose.yml.template +24 -0
- package/dist/templates/docs/app-description.md.template +33 -33
- package/dist/templates/firebase.json.template +68 -0
- package/dist/templates/frontend/.umirc.ts.template +23 -0
- package/dist/templates/frontend/package.json.template +45 -0
- package/dist/templates/frontend/public/config.json +6 -0
- package/dist/templates/frontend/public/logo.svg +6 -0
- package/dist/templates/frontend/src/app.tsx.template +44 -0
- package/dist/templates/frontend/src/global.less.template +117 -0
- package/dist/templates/frontend/src/layouts/MainLayout.tsx.template +75 -0
- package/dist/templates/frontend/src/types/graphql-augmentation.d.ts.template +44 -0
- package/dist/templates/frontend/src/views/customViews/user/UserCreateView.tsx.template +18 -0
- package/dist/templates/frontend/src/views/customViews/user/UserEditView.tsx.template +29 -0
- package/dist/templates/frontend/src/views/customViews/user/UserReadView.tsx.template +24 -0
- package/dist/templates/frontend/src/views/customViews/user/UserTableView.tsx.template +38 -0
- package/dist/templates/frontend/src/views/customViews/welcome.tsx.template +34 -0
- package/dist/templates/frontend/tsconfig.json.template +50 -0
- package/dist/templates/gql/codegen.yml.template +25 -25
- package/dist/templates/gql/index.ts.template +17 -24
- package/dist/templates/gql/operations.graphql.template +30 -30
- package/dist/templates/ops/README.md.template +1045 -0
- package/dist/templates/ops/cloudbuild.yaml.template +161 -0
- package/dist/templates/ops/scripts/_utils.js.template +217 -0
- package/dist/templates/ops/scripts/deploy.js.template +145 -0
- package/dist/templates/ops/scripts/setup-gcp.js.template +330 -0
- package/dist/templates/ops/scripts/setup-secrets.js.template +76 -0
- package/dist/templates/ops/scripts/test-prod-local.js.template +49 -0
- package/dist/templates/package.json.template +50 -38
- package/dist/templates/pnpm-workspace.yaml.template +3 -0
- package/dist/templates/prompt-analysis.md.template +110 -110
- package/dist/templates/prompt-script-generation.md.template +258 -258
- package/dist/templates/src/Address.ts.template +28 -31
- package/dist/templates/src/App.ts.template +17 -61
- package/dist/templates/src/Company.ts.template +41 -47
- package/dist/templates/src/Models.test.ts.template +654 -654
- package/dist/templates/src/Person.test.ts.template +289 -289
- package/dist/templates/src/Person.ts.template +90 -105
- package/dist/templates/src/actions/index.ts.template +11 -11
- package/dist/templates/src/auth/permissions.ts.template +34 -0
- package/dist/templates/src/data/App.ts.template +48 -0
- package/dist/templates/src/data/User.ts.template +35 -0
- package/dist/templates/src/types/gql.d.ts.template +17 -17
- package/dist/templates/vscode/extensions.json +4 -3
- package/dist/templates/vscode/settings.json +17 -11
- package/dist/templates/workspace-package.json.template +21 -0
- package/dist/utils/buildCache.d.ts +12 -0
- package/dist/utils/buildCache.d.ts.map +1 -0
- package/dist/utils/buildCache.js +102 -0
- package/dist/utils/buildCache.js.map +1 -0
- package/dist/utils/checkFramework.d.ts +27 -0
- package/dist/utils/checkFramework.d.ts.map +1 -0
- package/dist/utils/checkFramework.js +104 -0
- package/dist/utils/checkFramework.js.map +1 -0
- package/dist/utils/datasourceParser.d.ts +11 -0
- package/dist/utils/datasourceParser.d.ts.map +1 -1
- package/dist/utils/datasourceParser.js +154 -56
- package/dist/utils/datasourceParser.js.map +1 -1
- package/dist/utils/dockerManager.d.ts +25 -0
- package/dist/utils/dockerManager.d.ts.map +1 -0
- package/dist/utils/dockerManager.js +281 -0
- package/dist/utils/dockerManager.js.map +1 -0
- package/dist/utils/infraFileParser.d.ts +26 -0
- package/dist/utils/infraFileParser.d.ts.map +1 -0
- package/dist/utils/infraFileParser.js +75 -0
- package/dist/utils/infraFileParser.js.map +1 -0
- package/dist/utils/jsonlLoader.d.ts +91 -12
- package/dist/utils/jsonlLoader.d.ts.map +1 -1
- package/dist/utils/jsonlLoader.js +674 -63
- package/dist/utils/jsonlLoader.js.map +1 -1
- package/dist/utils/model-analyzer.d.ts.map +1 -1
- package/dist/utils/model-analyzer.js +67 -13
- package/dist/utils/model-analyzer.js.map +1 -1
- package/dist/utils/userManagement.d.ts +57 -0
- package/dist/utils/userManagement.d.ts.map +1 -0
- package/dist/utils/userManagement.js +288 -0
- package/dist/utils/userManagement.js.map +1 -0
- package/dist/utils/viewsGenerator.d.ts +15 -0
- package/dist/utils/viewsGenerator.d.ts.map +1 -0
- package/dist/utils/viewsGenerator.js +311 -0
- package/dist/utils/viewsGenerator.js.map +1 -0
- package/oclif.manifest.json +445 -20
- package/package.json +29 -27
- package/src/templates/.env.template +23 -0
- package/src/templates/.firebaserc.template +5 -0
- package/src/templates/.github/copilot-instructions.md.template +652 -17
- package/src/templates/backend/Dockerfile.template +30 -0
- package/src/templates/config/datasource.ts.template +12 -9
- package/src/templates/config/jest.config.ts +30 -30
- package/src/templates/config/jest.setup.ts +1 -1
- package/src/templates/config/tsconfig.json.template +50 -29
- package/src/templates/dataSources/mysql.ts.template +16 -13
- package/src/templates/dataSources/postgres.ts.template +15 -13
- package/src/templates/dataset-generator-script.ts.template +139 -139
- package/src/templates/datasets/mysql-default/.slingr-schema.json.template +5 -0
- package/src/templates/datasets/mysql-default/Address.jsonl.template +3 -3
- package/src/templates/datasets/mysql-default/App.jsonl.template +4 -4
- package/src/templates/datasets/mysql-default/Company.jsonl.template +3 -3
- package/src/templates/datasets/mysql-default/Person.jsonl.template +2 -2
- package/src/templates/datasets/mysql-default/User.jsonl.template +1 -0
- package/src/templates/datasets/mysql-default/instructions.md.template +1 -0
- package/src/templates/datasets/postgres-default/.slingr-schema.json.template +5 -0
- package/src/templates/datasets/postgres-default/Address.jsonl.template +3 -3
- package/src/templates/datasets/postgres-default/App.jsonl.template +4 -4
- package/src/templates/datasets/postgres-default/Company.jsonl.template +3 -3
- package/src/templates/datasets/postgres-default/Person.jsonl.template +2 -2
- package/src/templates/datasets/postgres-default/User.jsonl.template +1 -0
- package/src/templates/datasets/postgres-default/instructions.md.template +1 -0
- package/src/templates/docker-compose.prod-test.yml.template +32 -0
- package/src/templates/docker-compose.yml.template +24 -0
- package/src/templates/docs/app-description.md.template +33 -33
- package/src/templates/firebase.json.template +68 -0
- package/src/templates/frontend/.umirc.ts.template +23 -0
- package/src/templates/frontend/package.json.template +45 -0
- package/src/templates/frontend/public/config.json +6 -0
- package/src/templates/frontend/public/logo.svg +6 -0
- package/src/templates/frontend/src/app.tsx.template +44 -0
- package/src/templates/frontend/src/global.less.template +117 -0
- package/src/templates/frontend/src/layouts/MainLayout.tsx.template +75 -0
- package/src/templates/frontend/src/types/graphql-augmentation.d.ts.template +44 -0
- package/src/templates/frontend/src/views/customViews/user/UserCreateView.tsx.template +18 -0
- package/src/templates/frontend/src/views/customViews/user/UserEditView.tsx.template +29 -0
- package/src/templates/frontend/src/views/customViews/user/UserReadView.tsx.template +24 -0
- package/src/templates/frontend/src/views/customViews/user/UserTableView.tsx.template +38 -0
- package/src/templates/frontend/src/views/customViews/welcome.tsx.template +34 -0
- package/src/templates/frontend/tsconfig.json.template +50 -0
- package/src/templates/gql/codegen.yml.template +25 -25
- package/src/templates/gql/index.ts.template +17 -24
- package/src/templates/gql/operations.graphql.template +30 -30
- package/src/templates/ops/README.md.template +1045 -0
- package/src/templates/ops/cloudbuild.yaml.template +161 -0
- package/src/templates/ops/scripts/_utils.js.template +217 -0
- package/src/templates/ops/scripts/deploy.js.template +145 -0
- package/src/templates/ops/scripts/setup-gcp.js.template +330 -0
- package/src/templates/ops/scripts/setup-secrets.js.template +76 -0
- package/src/templates/ops/scripts/test-prod-local.js.template +49 -0
- package/src/templates/package.json.template +50 -38
- package/src/templates/pnpm-workspace.yaml.template +3 -0
- package/src/templates/prompt-analysis.md.template +110 -110
- package/src/templates/prompt-script-generation.md.template +258 -258
- package/src/templates/src/Address.ts.template +28 -31
- package/src/templates/src/App.ts.template +17 -61
- package/src/templates/src/Company.ts.template +41 -47
- package/src/templates/src/Models.test.ts.template +654 -654
- package/src/templates/src/Person.test.ts.template +289 -289
- package/src/templates/src/Person.ts.template +90 -105
- package/src/templates/src/actions/index.ts.template +11 -11
- package/src/templates/src/auth/permissions.ts.template +34 -0
- package/src/templates/src/data/App.ts.template +48 -0
- package/src/templates/src/data/User.ts.template +35 -0
- package/src/templates/src/types/gql.d.ts.template +17 -17
- package/src/templates/vscode/extensions.json +4 -3
- package/src/templates/vscode/settings.json +17 -11
- package/src/templates/workspace-package.json.template +21 -0
- package/dist/templates/src/index.ts +0 -66
- package/src/templates/src/index.ts +0 -66
|
@@ -1,105 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Address } from "./Address";
|
|
3
|
-
import { {{DATASOURCE_NAME}} } from "
|
|
4
|
-
|
|
5
|
-
@
|
|
6
|
-
docs: "Represents a person",
|
|
7
|
-
dataSource: {{DATASOURCE_NAME}}
|
|
8
|
-
})
|
|
9
|
-
export class Person extends
|
|
10
|
-
@
|
|
11
|
-
required: true,
|
|
12
|
-
primaryKey: true,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
additionalInfo!: string;
|
|
92
|
-
|
|
93
|
-
@Field({
|
|
94
|
-
required: false,
|
|
95
|
-
})
|
|
96
|
-
@Boolean()
|
|
97
|
-
isActive!: boolean;
|
|
98
|
-
|
|
99
|
-
@Field({
|
|
100
|
-
required: false
|
|
101
|
-
})
|
|
102
|
-
@SharedComposition({ elementType: () => Address })
|
|
103
|
-
address!: Address;
|
|
104
|
-
|
|
105
|
-
}
|
|
1
|
+
import { TextField, EmailField, HtmlField, BooleanField, DataModel, BaseDataModel, UuidField, IntegerField, SharedCompositionField } from "@slingr/framework-backend";
|
|
2
|
+
import { Address } from "./Address";
|
|
3
|
+
import { {{DATASOURCE_NAME}} } from "@/dataSources/{{DATASOURCE_FILE}}";
|
|
4
|
+
|
|
5
|
+
@DataModel({
|
|
6
|
+
docs: "Represents a person",
|
|
7
|
+
dataSource: {{DATASOURCE_NAME}}
|
|
8
|
+
})
|
|
9
|
+
export class Person extends BaseDataModel {
|
|
10
|
+
@UuidField({
|
|
11
|
+
required: true,
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
generated: true
|
|
14
|
+
})
|
|
15
|
+
id!: string;
|
|
16
|
+
|
|
17
|
+
@TextField({
|
|
18
|
+
required: true,
|
|
19
|
+
minLength: 2,
|
|
20
|
+
maxLength: 30,
|
|
21
|
+
regex: /^[a-zA-Z]+$/,
|
|
22
|
+
regexMessage: "firstName must contain only letters",
|
|
23
|
+
})
|
|
24
|
+
firstName!: string;
|
|
25
|
+
|
|
26
|
+
@TextField({
|
|
27
|
+
required: true,
|
|
28
|
+
minLength: 2,
|
|
29
|
+
maxLength: 30,
|
|
30
|
+
regex: /^[a-zA-Z]+$/,
|
|
31
|
+
regexMessage: "lastName must contain only letters",
|
|
32
|
+
})
|
|
33
|
+
lastName!: string;
|
|
34
|
+
|
|
35
|
+
@EmailField()
|
|
36
|
+
email!: string;
|
|
37
|
+
|
|
38
|
+
@IntegerField({
|
|
39
|
+
validation: (_: number, person: Person) => {
|
|
40
|
+
let errors = [];
|
|
41
|
+
if (person.age < 0 || person.age > 120) {
|
|
42
|
+
errors.push({
|
|
43
|
+
constraint: "invalidAge",
|
|
44
|
+
message: "Age must be between 0 and 120",
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return errors;
|
|
48
|
+
},
|
|
49
|
+
required: true,
|
|
50
|
+
})
|
|
51
|
+
age!: number;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@EmailField({
|
|
55
|
+
required: (person: Person) => {
|
|
56
|
+
return (person.age < 18);
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
parentEmail!: string;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@TextField({
|
|
63
|
+
available: false, // This field should be excluded from JSON operations
|
|
64
|
+
docs: "Internal identifier not exposed in JSON"
|
|
65
|
+
})
|
|
66
|
+
internalId!: string;
|
|
67
|
+
|
|
68
|
+
@TextField({
|
|
69
|
+
required: false,
|
|
70
|
+
available: (person: Person) => {
|
|
71
|
+
return person.age >= 18;
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
phoneNumber!: string;
|
|
75
|
+
|
|
76
|
+
@HtmlField()
|
|
77
|
+
additionalInfo!: string;
|
|
78
|
+
|
|
79
|
+
@BooleanField({
|
|
80
|
+
required: false,
|
|
81
|
+
})
|
|
82
|
+
isActive!: boolean;
|
|
83
|
+
|
|
84
|
+
@SharedCompositionField({
|
|
85
|
+
required: false,
|
|
86
|
+
type: () => Address
|
|
87
|
+
})
|
|
88
|
+
address!: Address;
|
|
89
|
+
|
|
90
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Actions index file for {{APP_NAME}}
|
|
3
|
-
* This file exports all actions that should be available in the GraphQL schema
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Import any custom actions here
|
|
7
|
-
// Example:
|
|
8
|
-
// export * from './userActions';
|
|
9
|
-
// export * from './companyActions';
|
|
10
|
-
|
|
11
|
-
// For now, we'll just export an empty object to make the file valid
|
|
1
|
+
/**
|
|
2
|
+
* Actions index file for {{APP_NAME}}
|
|
3
|
+
* This file exports all actions that should be available in the GraphQL schema
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Import any custom actions here
|
|
7
|
+
// Example:
|
|
8
|
+
// export * from './userActions';
|
|
9
|
+
// export * from './companyActions';
|
|
10
|
+
|
|
11
|
+
// For now, we'll just export an empty object to make the file valid
|
|
12
12
|
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { app } from '@slingr/framework-backend';
|
|
2
|
+
import { Role } from '../data/User';
|
|
3
|
+
|
|
4
|
+
// Guest permissions (non-authenticated users)
|
|
5
|
+
// Define what unauthenticated users can access
|
|
6
|
+
app.defineGuestPermissions(({ can, cannot }) => {
|
|
7
|
+
// Example: Allow guests to read public content
|
|
8
|
+
// can('read', 'PublicContent');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// Global permissions (all authenticated users)
|
|
12
|
+
// Define what all logged-in users can access
|
|
13
|
+
app.defineGlobalPermissions((user, { can, cannot }) => {
|
|
14
|
+
// Example: Allow all users to read their own profile
|
|
15
|
+
// can('read', 'User', { id: user.id });
|
|
16
|
+
// can('update', 'User', { id: user.id });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Role-based permissions
|
|
20
|
+
// System role can manage everything
|
|
21
|
+
app.definePermissionsForRole(Role.System, (user, { can, cannot }) => {
|
|
22
|
+
can('manage', 'all');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Add more role permissions as needed:
|
|
26
|
+
// app.definePermissionsForRole(Role.Admin, (user, { can, cannot }) => {
|
|
27
|
+
// can('manage', 'User');
|
|
28
|
+
// can('read', 'all');
|
|
29
|
+
// });
|
|
30
|
+
//
|
|
31
|
+
// app.definePermissionsForRole(Role.User, (user, { can, cannot }) => {
|
|
32
|
+
// can('read', 'User', { id: user.id });
|
|
33
|
+
// can('update', 'User', { id: user.id });
|
|
34
|
+
// });
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { TextField, DataModel, BaseDataModel, UuidField, ReferenceField } from "@slingr/framework-backend";
|
|
2
|
+
import { Company } from "./Company";
|
|
3
|
+
import { {{DATASOURCE_NAME}} } from "@/dataSources/{{DATASOURCE_FILE}}";
|
|
4
|
+
|
|
5
|
+
@DataModel({
|
|
6
|
+
docs: "Represents an application managed in the system",
|
|
7
|
+
dataSource: {{DATASOURCE_NAME}}
|
|
8
|
+
})
|
|
9
|
+
export class App extends BaseDataModel {
|
|
10
|
+
@UuidField({
|
|
11
|
+
required: true,
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
generated: true
|
|
14
|
+
})
|
|
15
|
+
id!: string;
|
|
16
|
+
|
|
17
|
+
@TextField({
|
|
18
|
+
docs: "The name of the application",
|
|
19
|
+
required: true,
|
|
20
|
+
minLength: 1,
|
|
21
|
+
maxLength: 100,
|
|
22
|
+
regex: /^[A-Za-z0-9][A-Za-z0-9._]*$/,
|
|
23
|
+
regexMessage: "App name must start with a letter or digit and contain only letters, digits, dots, and underscores"
|
|
24
|
+
})
|
|
25
|
+
name!: string;
|
|
26
|
+
|
|
27
|
+
@TextField({
|
|
28
|
+
docs: "The version of the application in format NN.NN.NN",
|
|
29
|
+
required: true,
|
|
30
|
+
regex: /^\d{2}\.\d{2}\.\d{2}$/,
|
|
31
|
+
regexMessage: "Version must follow the format NN.NN.NN (e.g. 01.00.01)"
|
|
32
|
+
})
|
|
33
|
+
version!: string;
|
|
34
|
+
|
|
35
|
+
@TextField({
|
|
36
|
+
docs: "A brief description of the application",
|
|
37
|
+
required: false,
|
|
38
|
+
maxLength: 500
|
|
39
|
+
})
|
|
40
|
+
description?: string;
|
|
41
|
+
|
|
42
|
+
@ReferenceField({
|
|
43
|
+
docs: "The company that owns this application",
|
|
44
|
+
required: true,
|
|
45
|
+
type: () => Company
|
|
46
|
+
})
|
|
47
|
+
ownerCompany!: Company;
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DataModel, Field, UuidField, DateTimeField, ChoiceField, AppUser } from '@slingr/framework-backend';
|
|
2
|
+
import { {{DATASOURCE_NAME}} } from '@/dataSources/{{DATASOURCE_FILE}}';
|
|
3
|
+
|
|
4
|
+
export enum Role {
|
|
5
|
+
System = 'system',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@DataModel({
|
|
9
|
+
dataSource: {{DATASOURCE_NAME}},
|
|
10
|
+
crud: {
|
|
11
|
+
generate: true,
|
|
12
|
+
api: 'gql',
|
|
13
|
+
actions: ['create', 'findById', 'findBy', 'update', 'deleteById']
|
|
14
|
+
},
|
|
15
|
+
ui: {
|
|
16
|
+
api: 'gql',
|
|
17
|
+
actions: ['crud', 'refresh']{{USER_UI_VIEW_REFS}}
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
export class User extends AppUser<Role> {
|
|
21
|
+
@UuidField({
|
|
22
|
+
primaryKey: true,
|
|
23
|
+
generated: true
|
|
24
|
+
})
|
|
25
|
+
id?: string;
|
|
26
|
+
|
|
27
|
+
@DateTimeField()
|
|
28
|
+
createdAt?: Date;
|
|
29
|
+
|
|
30
|
+
@DateTimeField()
|
|
31
|
+
updatedAt?: Date;
|
|
32
|
+
|
|
33
|
+
@ChoiceField({ type: () => Role })
|
|
34
|
+
roles!: Role[];
|
|
35
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Temporary type declaration for @gql module
|
|
3
|
-
* This file prevents TypeScript compilation errors when the GraphQL SDK hasn't been generated yet.
|
|
4
|
-
* It will be automatically replaced when you run: slingr gql generate-sdk
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
declare module '@gql' {
|
|
8
|
-
// Placeholder interface for when SDK is not generated yet
|
|
9
|
-
interface PlaceholderGQL {
|
|
10
|
-
TestQuery?: () => Promise<any>;
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const gql: PlaceholderGQL;
|
|
15
|
-
export default gql;
|
|
16
|
-
}
|
|
17
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Temporary type declaration for @gql module
|
|
3
|
+
* This file prevents TypeScript compilation errors when the GraphQL SDK hasn't been generated yet.
|
|
4
|
+
* It will be automatically replaced when you run: slingr gql generate-sdk
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare module '@gql' {
|
|
8
|
+
// Placeholder interface for when SDK is not generated yet
|
|
9
|
+
interface PlaceholderGQL {
|
|
10
|
+
TestQuery?: () => Promise<any>;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const gql: PlaceholderGQL;
|
|
15
|
+
export default gql;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
18
|
// This file can be safely deleted after running: slingr gql generate-sdk
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"recommendations": ["github.copilot", "slingr.slingr"]
|
|
3
|
-
|
|
1
|
+
{
|
|
2
|
+
"recommendations": ["github.copilot-chat", "slingr.slingr"],
|
|
3
|
+
"unwantedRecommendations": ["github.copilot"]
|
|
4
|
+
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
{
|
|
2
|
-
"editor.
|
|
3
|
-
"editor.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
{
|
|
2
|
+
"editor.tabSize": 4,
|
|
3
|
+
"editor.insertSpaces": true,
|
|
4
|
+
"editor.formatOnSave": true,
|
|
5
|
+
"editor.inlineSuggest.enabled": true,
|
|
6
|
+
"files.autoSave": "afterDelay",
|
|
7
|
+
"github.copilot.advanced": {},
|
|
8
|
+
"github.copilot.enable": {
|
|
9
|
+
"*": true,
|
|
10
|
+
"markdown": true,
|
|
11
|
+
"plaintext": true
|
|
12
|
+
},
|
|
13
|
+
"typescript.preferences.importModuleSpecifier": "non-relative",
|
|
14
|
+
"javascript.preferences.importModuleSpecifier": "non-relative",
|
|
15
|
+
"typescript.updateImportsOnFileMove.enabled": "always",
|
|
16
|
+
"javascript.updateImportsOnFileMove.enabled": "always"
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{APP_NAME}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "{{DESCRIPTION}}",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"install:all": "pnpm install",
|
|
8
|
+
"build": "pnpm -r build",
|
|
9
|
+
"build:backend": "pnpm --filter ./backend build",
|
|
10
|
+
"build:frontend": "pnpm --filter ./frontend build",
|
|
11
|
+
"dev": "pnpm --filter ./backend dev",
|
|
12
|
+
"dev:frontend": "pnpm --filter ./frontend dev",
|
|
13
|
+
"start": "pnpm --filter ./backend start",
|
|
14
|
+
"test": "pnpm --filter ./backend test"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"slingr"
|
|
18
|
+
],
|
|
19
|
+
"author": "",
|
|
20
|
+
"license": "MIT"
|
|
21
|
+
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { app } from 'slingr-framework';
|
|
2
|
-
|
|
3
|
-
async function main() {
|
|
4
|
-
// Configure the application
|
|
5
|
-
app.configure({
|
|
6
|
-
graphql: {
|
|
7
|
-
port: 4000,
|
|
8
|
-
host: 'localhost',
|
|
9
|
-
enableExplorer: true,
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// Start the application
|
|
14
|
-
await app.run();
|
|
15
|
-
|
|
16
|
-
console.log('');
|
|
17
|
-
console.log('â
Application is ready!');
|
|
18
|
-
console.log('đ GraphQL Playground: http://localhost:4000/graphql');
|
|
19
|
-
console.log('');
|
|
20
|
-
|
|
21
|
-
// Test a sample query (if SDK is available)
|
|
22
|
-
console.log('đ Testing GraphQL SDK...');
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
// Check if SDK exists before trying to import it
|
|
26
|
-
const fs = await import('fs');
|
|
27
|
-
const path = await import('path');
|
|
28
|
-
const sdkPath = path.resolve(__dirname, '../generated/gql/index.ts');
|
|
29
|
-
|
|
30
|
-
if (fs.existsSync(sdkPath)) {
|
|
31
|
-
// Use dynamic import with variable to avoid TypeScript compile-time resolution
|
|
32
|
-
const sdkModule = '../generated/gql/index';
|
|
33
|
-
const gql = await import(sdkModule);
|
|
34
|
-
|
|
35
|
-
if (gql.default && typeof gql.default.TestQuery === 'function') {
|
|
36
|
-
const result = await gql.default.TestQuery();
|
|
37
|
-
console.log('â
GraphQL SDK is working! Test query result:', JSON.stringify(result, null, 2));
|
|
38
|
-
console.log('đ Your GraphQL API is ready to use with type-safe queries!');
|
|
39
|
-
console.log('đĄ Import using: import gql from "@gql" (alias) or "../generated/gql"');
|
|
40
|
-
} else {
|
|
41
|
-
console.log('â
GraphQL SDK loaded successfully!');
|
|
42
|
-
console.log('âšī¸ No test query available, but the SDK is ready for your custom operations.');
|
|
43
|
-
console.log('đ Edit operations.graphql to add your GraphQL queries and mutations.');
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
console.log('âšī¸ GraphQL SDK not available yet.');
|
|
47
|
-
console.log('đĄ Run the complete setup to generate schema and SDK:');
|
|
48
|
-
console.log(' npx slingr setup');
|
|
49
|
-
}
|
|
50
|
-
} catch (error: any) {
|
|
51
|
-
console.log('âšī¸ GraphQL SDK may need to be regenerated after recent changes.');
|
|
52
|
-
console.log('đĄ Try regenerating the SDK:');
|
|
53
|
-
console.log(' npx slingr gql generate-schema');
|
|
54
|
-
console.log(' npx slingr gql generate-sdk');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
console.log('');
|
|
58
|
-
|
|
59
|
-
console.log('');
|
|
60
|
-
console.log('Press Ctrl+C to stop');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
main().catch(error => {
|
|
64
|
-
console.error('â Failed to start application:', error);
|
|
65
|
-
process.exit(1);
|
|
66
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { app } from 'slingr-framework';
|
|
2
|
-
|
|
3
|
-
async function main() {
|
|
4
|
-
// Configure the application
|
|
5
|
-
app.configure({
|
|
6
|
-
graphql: {
|
|
7
|
-
port: 4000,
|
|
8
|
-
host: 'localhost',
|
|
9
|
-
enableExplorer: true,
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// Start the application
|
|
14
|
-
await app.run();
|
|
15
|
-
|
|
16
|
-
console.log('');
|
|
17
|
-
console.log('â
Application is ready!');
|
|
18
|
-
console.log('đ GraphQL Playground: http://localhost:4000/graphql');
|
|
19
|
-
console.log('');
|
|
20
|
-
|
|
21
|
-
// Test a sample query (if SDK is available)
|
|
22
|
-
console.log('đ Testing GraphQL SDK...');
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
// Check if SDK exists before trying to import it
|
|
26
|
-
const fs = await import('fs');
|
|
27
|
-
const path = await import('path');
|
|
28
|
-
const sdkPath = path.resolve(__dirname, '../generated/gql/index.ts');
|
|
29
|
-
|
|
30
|
-
if (fs.existsSync(sdkPath)) {
|
|
31
|
-
// Use dynamic import with variable to avoid TypeScript compile-time resolution
|
|
32
|
-
const sdkModule = '../generated/gql/index';
|
|
33
|
-
const gql = await import(sdkModule);
|
|
34
|
-
|
|
35
|
-
if (gql.default && typeof gql.default.TestQuery === 'function') {
|
|
36
|
-
const result = await gql.default.TestQuery();
|
|
37
|
-
console.log('â
GraphQL SDK is working! Test query result:', JSON.stringify(result, null, 2));
|
|
38
|
-
console.log('đ Your GraphQL API is ready to use with type-safe queries!');
|
|
39
|
-
console.log('đĄ Import using: import gql from "@gql" (alias) or "../generated/gql"');
|
|
40
|
-
} else {
|
|
41
|
-
console.log('â
GraphQL SDK loaded successfully!');
|
|
42
|
-
console.log('âšī¸ No test query available, but the SDK is ready for your custom operations.');
|
|
43
|
-
console.log('đ Edit operations.graphql to add your GraphQL queries and mutations.');
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
console.log('âšī¸ GraphQL SDK not available yet.');
|
|
47
|
-
console.log('đĄ Run the complete setup to generate schema and SDK:');
|
|
48
|
-
console.log(' npx slingr setup');
|
|
49
|
-
}
|
|
50
|
-
} catch (error: any) {
|
|
51
|
-
console.log('âšī¸ GraphQL SDK may need to be regenerated after recent changes.');
|
|
52
|
-
console.log('đĄ Try regenerating the SDK:');
|
|
53
|
-
console.log(' npx slingr gql generate-schema');
|
|
54
|
-
console.log(' npx slingr gql generate-sdk');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
console.log('');
|
|
58
|
-
|
|
59
|
-
console.log('');
|
|
60
|
-
console.log('Press Ctrl+C to stop');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
main().catch(error => {
|
|
64
|
-
console.error('â Failed to start application:', error);
|
|
65
|
-
process.exit(1);
|
|
66
|
-
});
|