@slingr/cli 0.0.3 → 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.
Files changed (251) hide show
  1. package/LICENSE.txt +202 -0
  2. package/README.md +490 -319
  3. package/bin/dev.cmd +2 -2
  4. package/bin/dev.js +5 -5
  5. package/bin/run.cmd +2 -2
  6. package/bin/run.js +4 -4
  7. package/bin/slingr +1 -0
  8. package/dist/commands/build.d.ts +20 -0
  9. package/dist/commands/build.d.ts.map +1 -0
  10. package/dist/commands/build.js +206 -0
  11. package/dist/commands/build.js.map +1 -0
  12. package/dist/commands/create-app.d.ts +0 -1
  13. package/dist/commands/create-app.d.ts.map +1 -1
  14. package/dist/commands/create-app.js +38 -57
  15. package/dist/commands/create-app.js.map +1 -1
  16. package/dist/commands/debug.d.ts +28 -0
  17. package/dist/commands/debug.d.ts.map +1 -0
  18. package/dist/commands/debug.js +474 -0
  19. package/dist/commands/debug.js.map +1 -0
  20. package/dist/commands/ds.d.ts +14 -1
  21. package/dist/commands/ds.d.ts.map +1 -1
  22. package/dist/commands/ds.js +450 -121
  23. package/dist/commands/ds.js.map +1 -1
  24. package/dist/commands/gql.d.ts +1 -1
  25. package/dist/commands/gql.d.ts.map +1 -1
  26. package/dist/commands/gql.js +190 -184
  27. package/dist/commands/gql.js.map +1 -1
  28. package/dist/commands/infra/down.d.ts.map +1 -1
  29. package/dist/commands/infra/down.js +8 -7
  30. package/dist/commands/infra/down.js.map +1 -1
  31. package/dist/commands/infra/up.d.ts.map +1 -1
  32. package/dist/commands/infra/up.js +8 -7
  33. package/dist/commands/infra/up.js.map +1 -1
  34. package/dist/commands/infra/update.d.ts +1 -0
  35. package/dist/commands/infra/update.d.ts.map +1 -1
  36. package/dist/commands/infra/update.js +33 -69
  37. package/dist/commands/infra/update.js.map +1 -1
  38. package/dist/commands/run.d.ts +29 -2
  39. package/dist/commands/run.d.ts.map +1 -1
  40. package/dist/commands/run.js +628 -130
  41. package/dist/commands/run.js.map +1 -1
  42. package/dist/commands/setup.d.ts +1 -1
  43. package/dist/commands/setup.d.ts.map +1 -1
  44. package/dist/commands/setup.js +34 -71
  45. package/dist/commands/setup.js.map +1 -1
  46. package/dist/commands/sync-metadata.d.ts +15 -0
  47. package/dist/commands/sync-metadata.d.ts.map +1 -0
  48. package/dist/commands/sync-metadata.js +225 -0
  49. package/dist/commands/sync-metadata.js.map +1 -0
  50. package/dist/commands/users.d.ts +30 -0
  51. package/dist/commands/users.d.ts.map +1 -0
  52. package/dist/commands/users.js +472 -0
  53. package/dist/commands/users.js.map +1 -0
  54. package/dist/commands/views.d.ts +11 -0
  55. package/dist/commands/views.d.ts.map +1 -0
  56. package/dist/commands/views.js +73 -0
  57. package/dist/commands/views.js.map +1 -0
  58. package/dist/projectStructure.d.ts +2 -2
  59. package/dist/projectStructure.d.ts.map +1 -1
  60. package/dist/projectStructure.js +281 -69
  61. package/dist/projectStructure.js.map +1 -1
  62. package/dist/scripts/generate-metadata.d.ts +13 -0
  63. package/dist/scripts/generate-metadata.d.ts.map +1 -0
  64. package/dist/scripts/generate-metadata.js +412 -0
  65. package/dist/scripts/generate-metadata.js.map +1 -0
  66. package/dist/scripts/generate-metadata.ts +498 -0
  67. package/dist/scripts/generate-schema.d.ts +1 -1
  68. package/dist/scripts/generate-schema.js +168 -74
  69. package/dist/scripts/generate-schema.js.map +1 -1
  70. package/dist/scripts/generate-schema.ts +258 -143
  71. package/dist/templates/.env.template +23 -0
  72. package/dist/templates/.firebaserc.template +5 -0
  73. package/dist/templates/.github/copilot-instructions.md.template +652 -17
  74. package/dist/templates/backend/Dockerfile.template +30 -0
  75. package/dist/templates/config/datasource.ts.template +12 -9
  76. package/dist/templates/config/jest.config.ts +30 -30
  77. package/dist/templates/config/jest.setup.ts +1 -1
  78. package/dist/templates/config/tsconfig.json.template +50 -29
  79. package/dist/templates/dataSources/mysql.ts.template +16 -13
  80. package/dist/templates/dataSources/postgres.ts.template +15 -13
  81. package/dist/templates/dataset-generator-script.ts.template +139 -139
  82. package/dist/templates/datasets/mysql-default/.slingr-schema.json.template +5 -0
  83. package/dist/templates/datasets/mysql-default/Address.jsonl.template +3 -3
  84. package/dist/templates/datasets/mysql-default/App.jsonl.template +4 -4
  85. package/dist/templates/datasets/mysql-default/Company.jsonl.template +3 -3
  86. package/dist/templates/datasets/mysql-default/Person.jsonl.template +2 -2
  87. package/dist/templates/datasets/mysql-default/User.jsonl.template +1 -0
  88. package/dist/templates/datasets/mysql-default/instructions.md.template +1 -0
  89. package/dist/templates/datasets/postgres-default/.slingr-schema.json.template +5 -0
  90. package/dist/templates/datasets/postgres-default/Address.jsonl.template +3 -3
  91. package/dist/templates/datasets/postgres-default/App.jsonl.template +4 -4
  92. package/dist/templates/datasets/postgres-default/Company.jsonl.template +3 -3
  93. package/dist/templates/datasets/postgres-default/Person.jsonl.template +2 -2
  94. package/dist/templates/datasets/postgres-default/User.jsonl.template +1 -0
  95. package/dist/templates/datasets/postgres-default/instructions.md.template +1 -0
  96. package/dist/templates/docker-compose.prod-test.yml.template +32 -0
  97. package/dist/templates/docker-compose.yml.template +24 -0
  98. package/dist/templates/docs/app-description.md.template +33 -33
  99. package/dist/templates/firebase.json.template +68 -0
  100. package/dist/templates/frontend/.umirc.ts.template +23 -0
  101. package/dist/templates/frontend/package.json.template +45 -0
  102. package/dist/templates/frontend/public/config.json +6 -0
  103. package/dist/templates/frontend/public/logo.svg +6 -0
  104. package/dist/templates/frontend/src/app.tsx.template +44 -0
  105. package/dist/templates/frontend/src/global.less.template +117 -0
  106. package/dist/templates/frontend/src/layouts/MainLayout.tsx.template +75 -0
  107. package/dist/templates/frontend/src/types/graphql-augmentation.d.ts.template +44 -0
  108. package/dist/templates/frontend/src/views/customViews/user/UserCreateView.tsx.template +18 -0
  109. package/dist/templates/frontend/src/views/customViews/user/UserEditView.tsx.template +29 -0
  110. package/dist/templates/frontend/src/views/customViews/user/UserReadView.tsx.template +24 -0
  111. package/dist/templates/frontend/src/views/customViews/user/UserTableView.tsx.template +38 -0
  112. package/dist/templates/frontend/src/views/customViews/welcome.tsx.template +34 -0
  113. package/dist/templates/frontend/tsconfig.json.template +50 -0
  114. package/dist/templates/gql/codegen.yml.template +25 -25
  115. package/dist/templates/gql/index.ts.template +17 -24
  116. package/dist/templates/gql/operations.graphql.template +30 -30
  117. package/dist/templates/ops/README.md.template +1045 -0
  118. package/dist/templates/ops/cloudbuild.yaml.template +161 -0
  119. package/dist/templates/ops/scripts/_utils.js.template +217 -0
  120. package/dist/templates/ops/scripts/deploy.js.template +145 -0
  121. package/dist/templates/ops/scripts/setup-gcp.js.template +330 -0
  122. package/dist/templates/ops/scripts/setup-secrets.js.template +76 -0
  123. package/dist/templates/ops/scripts/test-prod-local.js.template +49 -0
  124. package/dist/templates/package.json.template +50 -38
  125. package/dist/templates/pnpm-workspace.yaml.template +3 -0
  126. package/dist/templates/prompt-analysis.md.template +110 -110
  127. package/dist/templates/prompt-script-generation.md.template +258 -258
  128. package/dist/templates/src/Address.ts.template +28 -31
  129. package/dist/templates/src/App.ts.template +17 -61
  130. package/dist/templates/src/Company.ts.template +41 -47
  131. package/dist/templates/src/Models.test.ts.template +654 -654
  132. package/dist/templates/src/Person.test.ts.template +289 -289
  133. package/dist/templates/src/Person.ts.template +90 -105
  134. package/dist/templates/src/actions/index.ts.template +11 -11
  135. package/dist/templates/src/auth/permissions.ts.template +34 -0
  136. package/dist/templates/src/data/App.ts.template +48 -0
  137. package/dist/templates/src/data/User.ts.template +35 -0
  138. package/dist/templates/src/types/gql.d.ts.template +17 -17
  139. package/dist/templates/vscode/extensions.json +4 -3
  140. package/dist/templates/vscode/settings.json +17 -11
  141. package/dist/templates/workspace-package.json.template +21 -0
  142. package/dist/utils/buildCache.d.ts +12 -0
  143. package/dist/utils/buildCache.d.ts.map +1 -0
  144. package/dist/utils/buildCache.js +102 -0
  145. package/dist/utils/buildCache.js.map +1 -0
  146. package/dist/utils/checkFramework.d.ts +27 -0
  147. package/dist/utils/checkFramework.d.ts.map +1 -0
  148. package/dist/utils/checkFramework.js +104 -0
  149. package/dist/utils/checkFramework.js.map +1 -0
  150. package/dist/utils/datasourceParser.d.ts +11 -0
  151. package/dist/utils/datasourceParser.d.ts.map +1 -1
  152. package/dist/utils/datasourceParser.js +154 -56
  153. package/dist/utils/datasourceParser.js.map +1 -1
  154. package/dist/utils/dockerManager.d.ts +25 -0
  155. package/dist/utils/dockerManager.d.ts.map +1 -0
  156. package/dist/utils/dockerManager.js +281 -0
  157. package/dist/utils/dockerManager.js.map +1 -0
  158. package/dist/utils/infraFileParser.d.ts +26 -0
  159. package/dist/utils/infraFileParser.d.ts.map +1 -0
  160. package/dist/utils/infraFileParser.js +75 -0
  161. package/dist/utils/infraFileParser.js.map +1 -0
  162. package/dist/utils/jsonlLoader.d.ts +91 -12
  163. package/dist/utils/jsonlLoader.d.ts.map +1 -1
  164. package/dist/utils/jsonlLoader.js +674 -63
  165. package/dist/utils/jsonlLoader.js.map +1 -1
  166. package/dist/utils/model-analyzer.d.ts.map +1 -1
  167. package/dist/utils/model-analyzer.js +67 -13
  168. package/dist/utils/model-analyzer.js.map +1 -1
  169. package/dist/utils/userManagement.d.ts +57 -0
  170. package/dist/utils/userManagement.d.ts.map +1 -0
  171. package/dist/utils/userManagement.js +288 -0
  172. package/dist/utils/userManagement.js.map +1 -0
  173. package/dist/utils/viewsGenerator.d.ts +15 -0
  174. package/dist/utils/viewsGenerator.d.ts.map +1 -0
  175. package/dist/utils/viewsGenerator.js +311 -0
  176. package/dist/utils/viewsGenerator.js.map +1 -0
  177. package/oclif.manifest.json +445 -20
  178. package/package.json +29 -26
  179. package/src/templates/.env.template +23 -0
  180. package/src/templates/.firebaserc.template +5 -0
  181. package/src/templates/.github/copilot-instructions.md.template +652 -17
  182. package/src/templates/backend/Dockerfile.template +30 -0
  183. package/src/templates/config/datasource.ts.template +12 -9
  184. package/src/templates/config/jest.config.ts +30 -30
  185. package/src/templates/config/jest.setup.ts +1 -1
  186. package/src/templates/config/tsconfig.json.template +50 -29
  187. package/src/templates/dataSources/mysql.ts.template +16 -13
  188. package/src/templates/dataSources/postgres.ts.template +15 -13
  189. package/src/templates/dataset-generator-script.ts.template +139 -139
  190. package/src/templates/datasets/mysql-default/.slingr-schema.json.template +5 -0
  191. package/src/templates/datasets/mysql-default/Address.jsonl.template +3 -3
  192. package/src/templates/datasets/mysql-default/App.jsonl.template +4 -4
  193. package/src/templates/datasets/mysql-default/Company.jsonl.template +3 -3
  194. package/src/templates/datasets/mysql-default/Person.jsonl.template +2 -2
  195. package/src/templates/datasets/mysql-default/User.jsonl.template +1 -0
  196. package/src/templates/datasets/mysql-default/instructions.md.template +1 -0
  197. package/src/templates/datasets/postgres-default/.slingr-schema.json.template +5 -0
  198. package/src/templates/datasets/postgres-default/Address.jsonl.template +3 -3
  199. package/src/templates/datasets/postgres-default/App.jsonl.template +4 -4
  200. package/src/templates/datasets/postgres-default/Company.jsonl.template +3 -3
  201. package/src/templates/datasets/postgres-default/Person.jsonl.template +2 -2
  202. package/src/templates/datasets/postgres-default/User.jsonl.template +1 -0
  203. package/src/templates/datasets/postgres-default/instructions.md.template +1 -0
  204. package/src/templates/docker-compose.prod-test.yml.template +32 -0
  205. package/src/templates/docker-compose.yml.template +24 -0
  206. package/src/templates/docs/app-description.md.template +33 -33
  207. package/src/templates/firebase.json.template +68 -0
  208. package/src/templates/frontend/.umirc.ts.template +23 -0
  209. package/src/templates/frontend/package.json.template +45 -0
  210. package/src/templates/frontend/public/config.json +6 -0
  211. package/src/templates/frontend/public/logo.svg +6 -0
  212. package/src/templates/frontend/src/app.tsx.template +44 -0
  213. package/src/templates/frontend/src/global.less.template +117 -0
  214. package/src/templates/frontend/src/layouts/MainLayout.tsx.template +75 -0
  215. package/src/templates/frontend/src/types/graphql-augmentation.d.ts.template +44 -0
  216. package/src/templates/frontend/src/views/customViews/user/UserCreateView.tsx.template +18 -0
  217. package/src/templates/frontend/src/views/customViews/user/UserEditView.tsx.template +29 -0
  218. package/src/templates/frontend/src/views/customViews/user/UserReadView.tsx.template +24 -0
  219. package/src/templates/frontend/src/views/customViews/user/UserTableView.tsx.template +38 -0
  220. package/src/templates/frontend/src/views/customViews/welcome.tsx.template +34 -0
  221. package/src/templates/frontend/tsconfig.json.template +50 -0
  222. package/src/templates/gql/codegen.yml.template +25 -25
  223. package/src/templates/gql/index.ts.template +17 -24
  224. package/src/templates/gql/operations.graphql.template +30 -30
  225. package/src/templates/ops/README.md.template +1045 -0
  226. package/src/templates/ops/cloudbuild.yaml.template +161 -0
  227. package/src/templates/ops/scripts/_utils.js.template +217 -0
  228. package/src/templates/ops/scripts/deploy.js.template +145 -0
  229. package/src/templates/ops/scripts/setup-gcp.js.template +330 -0
  230. package/src/templates/ops/scripts/setup-secrets.js.template +76 -0
  231. package/src/templates/ops/scripts/test-prod-local.js.template +49 -0
  232. package/src/templates/package.json.template +50 -38
  233. package/src/templates/pnpm-workspace.yaml.template +3 -0
  234. package/src/templates/prompt-analysis.md.template +110 -110
  235. package/src/templates/prompt-script-generation.md.template +258 -258
  236. package/src/templates/src/Address.ts.template +28 -31
  237. package/src/templates/src/App.ts.template +17 -61
  238. package/src/templates/src/Company.ts.template +41 -47
  239. package/src/templates/src/Models.test.ts.template +654 -654
  240. package/src/templates/src/Person.test.ts.template +289 -289
  241. package/src/templates/src/Person.ts.template +90 -105
  242. package/src/templates/src/actions/index.ts.template +11 -11
  243. package/src/templates/src/auth/permissions.ts.template +34 -0
  244. package/src/templates/src/data/App.ts.template +48 -0
  245. package/src/templates/src/data/User.ts.template +35 -0
  246. package/src/templates/src/types/gql.d.ts.template +17 -17
  247. package/src/templates/vscode/extensions.json +4 -3
  248. package/src/templates/vscode/settings.json +17 -11
  249. package/src/templates/workspace-package.json.template +21 -0
  250. package/dist/templates/src/index.ts +0 -66
  251. package/src/templates/src/index.ts +0 -66
@@ -1,105 +1,90 @@
1
- import { Field, Text, Email, Html, Boolean, Model, BaseModel, Uuid, Integer, SharedComposition } from "slingr-framework";
2
- import { Address } from "./Address";
3
- import { {{DATASOURCE_NAME}} } from "../dataSources/{{DATASOURCE_FILE}}";
4
-
5
- @Model({
6
- docs: "Represents a person",
7
- dataSource: {{DATASOURCE_NAME}}
8
- })
9
- export class Person extends BaseModel {
10
- @Field({
11
- required: true,
12
- primaryKey: true,
13
- })
14
- @Uuid(
15
- {
16
- generated: true
17
- }
18
- )
19
- id!: string;
20
-
21
- @Field({
22
- required: true,
23
- })
24
- @Text({
25
- minLength: 2,
26
- maxLength: 30,
27
- regex: /^[a-zA-Z]+$/,
28
- regexMessage: "firstName must contain only letters",
29
- })
30
- firstName!: string;
31
-
32
- @Field({
33
- required: true,
34
- })
35
- @Text({
36
- minLength: 2,
37
- maxLength: 30,
38
- regex: /^[a-zA-Z]+$/,
39
- regexMessage: "lastName must contain only letters",
40
- })
41
- lastName!: string;
42
-
43
- @Field()
44
- @Email()
45
- email!: string;
46
-
47
- @Field({
48
- validation: (_: number, person: Person) => {
49
- let errors = [];
50
- if (person.age < 0 || person.age > 120) {
51
- errors.push({
52
- constraint: "invalidAge",
53
- message: "Age must be between 0 and 120",
54
- });
55
- }
56
- return errors;
57
- },
58
- required: true,
59
- })
60
- @Integer()
61
- age!: number;
62
-
63
-
64
- @Field({
65
- required: (person: Person) => {
66
- return (person.age < 18);
67
- },
68
- })
69
- @Email()
70
- parentEmail!: string;
71
-
72
-
73
- @Field({
74
- available: false, // This field should be excluded from JSON operations
75
- docs: "Internal identifier not exposed in JSON"
76
- })
77
- @Text()
78
- internalId!: string;
79
-
80
- @Field({
81
- required: false,
82
- available: (person: Person) => {
83
- return person.age >= 18;
84
- },
85
- })
86
- @Text()
87
- phoneNumber!: string;
88
-
89
- @Field()
90
- @Html()
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.formatOnSave": true,
3
- "editor.inlineSuggest.enabled": true,
4
- "github.copilot.advanced": {},
5
- "github.copilot.enable": {
6
- "*": true,
7
- "markdown": true,
8
- "plaintext": true
9
- },
10
- "typescript.preferences.importModuleSpecifier": "relative"
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
- });