@igstack/app-catalog-backend-core 0.0.1

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +1934 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +2539 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +84 -0
  7. package/prisma/migrations/20250526183023_init/migration.sql +71 -0
  8. package/prisma/migrations/migration_lock.toml +3 -0
  9. package/prisma/schema.prisma +149 -0
  10. package/src/__tests__/dummy.test.ts +7 -0
  11. package/src/db/client.ts +42 -0
  12. package/src/db/index.ts +21 -0
  13. package/src/db/syncAppCatalog.ts +312 -0
  14. package/src/db/tableSyncMagazine.ts +32 -0
  15. package/src/db/tableSyncPrismaAdapter.ts +203 -0
  16. package/src/index.ts +126 -0
  17. package/src/middleware/backendResolver.ts +42 -0
  18. package/src/middleware/createEhMiddleware.ts +171 -0
  19. package/src/middleware/database.ts +62 -0
  20. package/src/middleware/featureRegistry.ts +173 -0
  21. package/src/middleware/index.ts +43 -0
  22. package/src/middleware/types.ts +202 -0
  23. package/src/modules/admin/chat/createAdminChatHandler.ts +152 -0
  24. package/src/modules/admin/chat/createDatabaseTools.ts +261 -0
  25. package/src/modules/appCatalog/service.ts +130 -0
  26. package/src/modules/appCatalogAdmin/appCatalogAdminRouter.ts +187 -0
  27. package/src/modules/appCatalogAdmin/catalogBackupController.ts +213 -0
  28. package/src/modules/approvalMethod/approvalMethodRouter.ts +169 -0
  29. package/src/modules/approvalMethod/slugUtils.ts +17 -0
  30. package/src/modules/approvalMethod/syncApprovalMethods.ts +38 -0
  31. package/src/modules/assets/assetRestController.ts +271 -0
  32. package/src/modules/assets/assetUtils.ts +114 -0
  33. package/src/modules/assets/screenshotRestController.ts +195 -0
  34. package/src/modules/assets/screenshotRouter.ts +112 -0
  35. package/src/modules/assets/syncAssets.ts +277 -0
  36. package/src/modules/assets/upsertAsset.ts +46 -0
  37. package/src/modules/auth/auth.ts +51 -0
  38. package/src/modules/auth/authProviders.ts +40 -0
  39. package/src/modules/auth/authRouter.ts +75 -0
  40. package/src/modules/auth/authorizationUtils.ts +132 -0
  41. package/src/modules/auth/devMockUserUtils.ts +49 -0
  42. package/src/modules/auth/registerAuthRoutes.ts +33 -0
  43. package/src/modules/icons/iconRestController.ts +171 -0
  44. package/src/modules/icons/iconRouter.ts +180 -0
  45. package/src/modules/icons/iconService.ts +73 -0
  46. package/src/modules/icons/iconUtils.ts +46 -0
  47. package/src/prisma-json-types.d.ts +34 -0
  48. package/src/server/controller.ts +47 -0
  49. package/src/server/ehStaticControllerContract.ts +19 -0
  50. package/src/server/ehTrpcContext.ts +26 -0
  51. package/src/server/trpcSetup.ts +89 -0
  52. package/src/types/backend/api.ts +73 -0
  53. package/src/types/backend/common.ts +10 -0
  54. package/src/types/backend/companySpecificBackend.ts +5 -0
  55. package/src/types/backend/dataSources.ts +25 -0
  56. package/src/types/backend/deployments.ts +40 -0
  57. package/src/types/common/app/appTypes.ts +13 -0
  58. package/src/types/common/app/ui/appUiTypes.ts +12 -0
  59. package/src/types/common/appCatalogTypes.ts +65 -0
  60. package/src/types/common/approvalMethodTypes.ts +149 -0
  61. package/src/types/common/env/envTypes.ts +7 -0
  62. package/src/types/common/resourceTypes.ts +8 -0
  63. package/src/types/common/sharedTypes.ts +5 -0
  64. package/src/types/index.ts +21 -0
@@ -0,0 +1,12 @@
1
+ import type { Tag } from '../../sharedTypes'
2
+
3
+ export interface EhAppPageIndexed {
4
+ slug: string
5
+ displayName: string
6
+ url: string
7
+ tags?: Array<Tag>
8
+ }
9
+
10
+ export interface EhAppUiIndexed {
11
+ pages: Array<EhAppPageIndexed>
12
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * App Catalog Types - Universal Software Access Request Catalog
3
+ *
4
+ * These types define a standardized catalog of software applications and their
5
+ * access methods. The typing system is designed to be universal across companies,
6
+ * abstracting away specific tools (Jira, Slack, etc.) into generic categories.
7
+ */
8
+
9
+ import type { AppAccessRequest, ApprovalMethod } from './approvalMethodTypes'
10
+
11
+ // ============================================================================
12
+ // APP CATALOG TYPES
13
+ // ============================================================================
14
+
15
+ /**
16
+ * Application entry in the catalog
17
+ */
18
+ export interface AppForCatalog {
19
+ id: string
20
+ slug: string
21
+ displayName: string
22
+ description?: string
23
+ teams?: Array<string>
24
+ accessRequest?: AppAccessRequest
25
+ notes?: string
26
+ tags?: Array<string>
27
+ appUrl?: string
28
+ links?: Array<{ url: string; title?: string }>
29
+ iconName?: string // Optional icon identifier for display
30
+ screenshotIds?: Array<string>
31
+ }
32
+
33
+ // Derived catalog data returned by backend
34
+ export interface AppCategory {
35
+ id: string
36
+ name: string
37
+ }
38
+
39
+ export interface GroupingTagDefinition {
40
+ prefix: string
41
+ displayName: string
42
+ description: string
43
+ values: Array<GroupingTagValue>
44
+ }
45
+
46
+ type DistributiveOmit<T, TKey extends keyof any> = T extends any
47
+ ? Omit<T, TKey>
48
+ : never
49
+
50
+ export type AppApprovalMethod = DistributiveOmit<
51
+ ApprovalMethod,
52
+ 'createdAt' | 'updatedAt'
53
+ >
54
+
55
+ export interface GroupingTagValue {
56
+ value: string
57
+ displayName: string
58
+ description: string
59
+ }
60
+
61
+ export interface AppCatalogData {
62
+ apps: Array<AppForCatalog>
63
+ tagsDefinitions: Array<GroupingTagDefinition>
64
+ approvalMethods: Array<AppApprovalMethod>
65
+ }
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Approval Method Types
3
+ *
4
+ * Global approval method templates that apps can link to.
5
+ * Each method has a type (service, personTeam, custom) with type-specific config.
6
+ */
7
+
8
+ // ============================================================================
9
+ // APPROVAL METHOD TYPES (Global Templates)
10
+ // ============================================================================
11
+
12
+ export type ApprovalMethodType = 'service' | 'personTeam' | 'custom'
13
+
14
+ /**
15
+ * Contact for reaching out (not necessarily the approver)
16
+ */
17
+ export interface ReachOutContact {
18
+ displayName: string
19
+ contact: string // email, slack handle, etc.
20
+ }
21
+
22
+ /**
23
+ * Service type config - for bots, ticketing systems, self-service portals
24
+ */
25
+ export interface ServiceConfig {
26
+ url?: string // Service URL (clickable in UI)
27
+ icon?: string // Icon identifier
28
+ }
29
+
30
+ /**
31
+ * Person/Team type config - for human approvers
32
+ */
33
+ export interface PersonTeamConfig {
34
+ reachOutContacts?: Array<ReachOutContact>
35
+ }
36
+
37
+ /**
38
+ * Custom type config - generic, no additional fields
39
+ */
40
+ export interface CustomConfig {
41
+ // No additional fields
42
+ }
43
+
44
+ /**
45
+ * Union of all config types
46
+ */
47
+ export type ApprovalMethodConfig =
48
+ | ServiceConfig
49
+ | PersonTeamConfig
50
+ | CustomConfig
51
+
52
+ /**
53
+ * Approval Method - stored in DbApprovalMethod
54
+ */
55
+ // export interface ApprovalMethod {
56
+ // slug: string
57
+ // type: ApprovalMethodType
58
+ // displayName: string
59
+ // config?: ApprovalMethodConfig
60
+ // createdAt?: Date
61
+ // updatedAt?: Date
62
+ // }
63
+
64
+ export type ApprovalMethod = {
65
+ slug: string
66
+ displayName: string
67
+ createdAt?: Date
68
+ updatedAt?: Date
69
+ } & (
70
+ | {
71
+ type: 'service'
72
+ config: ServiceConfig
73
+ }
74
+ | {
75
+ type: 'personTeam'
76
+ config: PersonTeamConfig
77
+ }
78
+ | {
79
+ type: 'custom'
80
+ config: CustomConfig
81
+ }
82
+ )
83
+
84
+ // ============================================================================
85
+ // PER-APP APPROVAL DETAILS
86
+ // ============================================================================
87
+
88
+ /**
89
+ * Role that can be requested for an app
90
+ */
91
+ export interface AppRole {
92
+ displayName: string
93
+ description?: string
94
+ adminNotes?: string
95
+ }
96
+
97
+ /**
98
+ * Approver contact (person who approves, may differ from reach-out contact)
99
+ */
100
+ export interface ApproverContact {
101
+ displayName: string
102
+ contact?: string
103
+ }
104
+
105
+ /**
106
+ * URL link with optional label
107
+ */
108
+ export interface ApprovalUrl {
109
+ label?: string
110
+ url: string
111
+ }
112
+
113
+ /**
114
+ * Per-app approval details - stored as JSON in DbAppForCatalog
115
+ * All comment/text-like strings are markdown
116
+ */
117
+ export interface AppAccessRequest {
118
+ approvalMethodId: string // FK to DbApprovalMethod
119
+
120
+ // Common fields (all types) - markdown text
121
+ comments?: string
122
+ requestPrompt?: string
123
+ postApprovalInstructions?: string
124
+
125
+ // Lists
126
+ roles?: Array<AppRole>
127
+ approvers?: Array<ApproverContact>
128
+ urls?: Array<ApprovalUrl>
129
+
130
+ // Type-specific (Person/Team only)
131
+ whoToReachOut?: string // markdown
132
+ }
133
+
134
+ // ============================================================================
135
+ // INPUT TYPES FOR API
136
+ // ============================================================================
137
+
138
+ export interface CreateApprovalMethodInput {
139
+ type: ApprovalMethodType
140
+ displayName: string
141
+ config?: ApprovalMethodConfig
142
+ }
143
+
144
+ export interface UpdateApprovalMethodInput {
145
+ id: string
146
+ type?: ApprovalMethodType
147
+ displayName?: string
148
+ config?: ApprovalMethodConfig
149
+ }
@@ -0,0 +1,7 @@
1
+ import type { EhMetaDictionary } from '../sharedTypes'
2
+
3
+ export interface EhEnvIndexed {
4
+ slug: string
5
+ displayName: string
6
+ meta?: EhMetaDictionary
7
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Resources like kafka topics, database tables, etc.
3
+ */
4
+ export interface EhResourceIndexed {
5
+ slug: string
6
+ displayName: string
7
+ defaultFixedValues?: Array<string>
8
+ }
@@ -0,0 +1,5 @@
1
+ export interface EhMetaDictionary {
2
+ [key: string]: string | null | Record<string, string | null>
3
+ }
4
+
5
+ export type Tag = string
@@ -0,0 +1,21 @@
1
+ // Export all common types
2
+ export * from './common/sharedTypes.js'
3
+ export * from './common/resourceTypes.js'
4
+ export * from './common/appCatalogTypes.js'
5
+ export * from './common/approvalMethodTypes.js'
6
+ export * from './common/env/envTypes.js'
7
+ export * from './common/app/appTypes.js'
8
+ export * from './common/app/ui/appUiTypes.js'
9
+
10
+ // Main API interfaces
11
+ export * from './backend/api.js'
12
+
13
+ // Common types
14
+ export * from './backend/common.js'
15
+ // Data source types
16
+ export * from './backend/dataSources.js'
17
+ // Company specific backend types
18
+ export * from './backend/companySpecificBackend.js'
19
+
20
+ // Deployment and version types
21
+ export * from './backend/deployments.js'