@pipeline-builder/api-core 3.1.0

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 (122) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +51 -0
  3. package/lib/constants/ai-providers.d.ts +41 -0
  4. package/lib/constants/ai-providers.js +88 -0
  5. package/lib/constants/http-status.d.ts +24 -0
  6. package/lib/constants/http-status.js +29 -0
  7. package/lib/constants/index.d.ts +3 -0
  8. package/lib/constants/index.js +22 -0
  9. package/lib/constants/time.d.ts +10 -0
  10. package/lib/constants/time.js +16 -0
  11. package/lib/errors/app-errors.d.ts +30 -0
  12. package/lib/errors/app-errors.js +62 -0
  13. package/lib/errors/index.d.ts +1 -0
  14. package/lib/errors/index.js +20 -0
  15. package/lib/helpers/access-helpers.d.ts +40 -0
  16. package/lib/helpers/access-helpers.js +56 -0
  17. package/lib/helpers/crud-helpers.d.ts +16 -0
  18. package/lib/helpers/crud-helpers.js +34 -0
  19. package/lib/helpers/index.d.ts +4 -0
  20. package/lib/helpers/index.js +23 -0
  21. package/lib/helpers/mask-helpers.d.ts +33 -0
  22. package/lib/helpers/mask-helpers.js +54 -0
  23. package/lib/helpers/sse-helpers.d.ts +13 -0
  24. package/lib/helpers/sse-helpers.js +40 -0
  25. package/lib/index.d.ts +57 -0
  26. package/lib/index.js +86 -0
  27. package/lib/middleware/auth.d.ts +50 -0
  28. package/lib/middleware/auth.js +171 -0
  29. package/lib/middleware/index.d.ts +1 -0
  30. package/lib/middleware/index.js +20 -0
  31. package/lib/openapi/extend-zod.d.ts +1 -0
  32. package/lib/openapi/extend-zod.js +8 -0
  33. package/lib/openapi/index.d.ts +2 -0
  34. package/lib/openapi/index.js +10 -0
  35. package/lib/openapi/registry.d.ts +17 -0
  36. package/lib/openapi/registry.js +42 -0
  37. package/lib/openapi/routes/billing-routes.d.ts +1 -0
  38. package/lib/openapi/routes/billing-routes.js +69 -0
  39. package/lib/openapi/routes/index.d.ts +5 -0
  40. package/lib/openapi/routes/index.js +22 -0
  41. package/lib/openapi/routes/message-routes.d.ts +1 -0
  42. package/lib/openapi/routes/message-routes.js +108 -0
  43. package/lib/openapi/routes/pipeline-routes.d.ts +1 -0
  44. package/lib/openapi/routes/pipeline-routes.js +90 -0
  45. package/lib/openapi/routes/plugin-routes.d.ts +1 -0
  46. package/lib/openapi/routes/plugin-routes.js +99 -0
  47. package/lib/openapi/routes/quota-routes.d.ts +1 -0
  48. package/lib/openapi/routes/quota-routes.js +65 -0
  49. package/lib/openapi/schema-registry.d.ts +25 -0
  50. package/lib/openapi/schema-registry.js +95 -0
  51. package/lib/routes/health.d.ts +47 -0
  52. package/lib/routes/health.js +81 -0
  53. package/lib/routes/index.d.ts +1 -0
  54. package/lib/routes/index.js +20 -0
  55. package/lib/services/admin-audit.d.ts +13 -0
  56. package/lib/services/admin-audit.js +31 -0
  57. package/lib/services/cache-service.d.ts +108 -0
  58. package/lib/services/cache-service.js +212 -0
  59. package/lib/services/compliance-client.d.ts +46 -0
  60. package/lib/services/compliance-client.js +102 -0
  61. package/lib/services/compliance-event-subscriber.d.ts +11 -0
  62. package/lib/services/compliance-event-subscriber.js +60 -0
  63. package/lib/services/compliance-queue.d.ts +11 -0
  64. package/lib/services/compliance-queue.js +38 -0
  65. package/lib/services/entity-events.d.ts +44 -0
  66. package/lib/services/entity-events.js +63 -0
  67. package/lib/services/http-client.d.ts +108 -0
  68. package/lib/services/http-client.js +285 -0
  69. package/lib/services/index.d.ts +10 -0
  70. package/lib/services/index.js +40 -0
  71. package/lib/services/quota.d.ts +59 -0
  72. package/lib/services/quota.js +137 -0
  73. package/lib/services/retry-strategy.d.ts +74 -0
  74. package/lib/services/retry-strategy.js +127 -0
  75. package/lib/types/billing.d.ts +47 -0
  76. package/lib/types/billing.js +5 -0
  77. package/lib/types/common.d.ts +161 -0
  78. package/lib/types/common.js +53 -0
  79. package/lib/types/error-codes.d.ts +38 -0
  80. package/lib/types/error-codes.js +77 -0
  81. package/lib/types/feature-flags.d.ts +38 -0
  82. package/lib/types/feature-flags.js +107 -0
  83. package/lib/types/http.d.ts +37 -0
  84. package/lib/types/http.js +5 -0
  85. package/lib/types/index.d.ts +7 -0
  86. package/lib/types/index.js +26 -0
  87. package/lib/types/pipeline.d.ts +70 -0
  88. package/lib/types/pipeline.js +44 -0
  89. package/lib/types/quota-tiers.d.ts +23 -0
  90. package/lib/types/quota-tiers.js +26 -0
  91. package/lib/utils/alias-resolver.d.ts +16 -0
  92. package/lib/utils/alias-resolver.js +49 -0
  93. package/lib/utils/headers.d.ts +18 -0
  94. package/lib/utils/headers.js +24 -0
  95. package/lib/utils/identity.d.ts +61 -0
  96. package/lib/utils/identity.js +75 -0
  97. package/lib/utils/index.d.ts +7 -0
  98. package/lib/utils/index.js +26 -0
  99. package/lib/utils/logger.d.ts +28 -0
  100. package/lib/utils/logger.js +77 -0
  101. package/lib/utils/object.d.ts +13 -0
  102. package/lib/utils/object.js +21 -0
  103. package/lib/utils/params.d.ts +89 -0
  104. package/lib/utils/params.js +148 -0
  105. package/lib/utils/response.d.ts +142 -0
  106. package/lib/utils/response.js +237 -0
  107. package/lib/validation/ai-schemas.d.ts +61 -0
  108. package/lib/validation/ai-schemas.js +81 -0
  109. package/lib/validation/common-schemas.d.ts +72 -0
  110. package/lib/validation/common-schemas.js +58 -0
  111. package/lib/validation/index.d.ts +6 -0
  112. package/lib/validation/index.js +25 -0
  113. package/lib/validation/message-schemas.d.ts +79 -0
  114. package/lib/validation/message-schemas.js +42 -0
  115. package/lib/validation/middleware.d.ts +60 -0
  116. package/lib/validation/middleware.js +77 -0
  117. package/lib/validation/pipeline-schemas.d.ts +135 -0
  118. package/lib/validation/pipeline-schemas.js +85 -0
  119. package/lib/validation/plugin-schemas.d.ts +127 -0
  120. package/lib/validation/plugin-schemas.js +84 -0
  121. package/openapi.yaml +292 -0
  122. package/package.json +127 -0
package/openapi.yaml ADDED
@@ -0,0 +1,292 @@
1
+ openapi: 3.0.3
2
+ info:
3
+ title: Pipeline API Common Types
4
+ description: Shared type definitions and schemas for Pipeline API microservices
5
+ version: 0.1.0
6
+ license:
7
+ name: Apache 2.0
8
+ url: https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ components:
11
+ securitySchemes:
12
+ bearerAuth:
13
+ type: http
14
+ scheme: bearer
15
+ bearerFormat: JWT
16
+ description: JWT access token
17
+
18
+ schemas:
19
+ # Standard Response Types
20
+ SuccessResponse:
21
+ type: object
22
+ required:
23
+ - success
24
+ - statusCode
25
+ properties:
26
+ success:
27
+ type: boolean
28
+ enum: [true]
29
+ statusCode:
30
+ type: integer
31
+ example: 200
32
+ data:
33
+ type: object
34
+ message:
35
+ type: string
36
+
37
+ ErrorResponse:
38
+ type: object
39
+ required:
40
+ - success
41
+ - statusCode
42
+ - message
43
+ properties:
44
+ success:
45
+ type: boolean
46
+ enum: [false]
47
+ statusCode:
48
+ type: integer
49
+ example: 400
50
+ message:
51
+ type: string
52
+ code:
53
+ $ref: '#/components/schemas/ErrorCode'
54
+ details:
55
+ type: object
56
+
57
+ # Error Codes
58
+ ErrorCode:
59
+ type: string
60
+ enum:
61
+ - UNAUTHORIZED
62
+ - TOKEN_EXPIRED
63
+ - TOKEN_INVALID
64
+ - TOKEN_MISSING
65
+ - FORBIDDEN
66
+ - INSUFFICIENT_PERMISSIONS
67
+ - ORG_MISMATCH
68
+ - NOT_FOUND
69
+ - RESOURCE_NOT_FOUND
70
+ - ORG_NOT_FOUND
71
+ - VALIDATION_ERROR
72
+ - INVALID_INPUT
73
+ - MISSING_REQUIRED_FIELD
74
+ - INVALID_FORMAT
75
+ - QUOTA_EXCEEDED
76
+ - RATE_LIMIT_EXCEEDED
77
+ - PLUGINS_QUOTA_EXCEEDED
78
+ - PIPELINES_QUOTA_EXCEEDED
79
+ - API_CALLS_QUOTA_EXCEEDED
80
+ - CONFLICT
81
+ - ALREADY_EXISTS
82
+ - DUPLICATE_ENTRY
83
+ - INTERNAL_ERROR
84
+ - DATABASE_ERROR
85
+ - SERVICE_UNAVAILABLE
86
+ - EXTERNAL_SERVICE_ERROR
87
+
88
+ # Quota Types
89
+ QuotaType:
90
+ type: string
91
+ enum:
92
+ - plugins
93
+ - pipelines
94
+ - apiCalls
95
+
96
+ QuotaInfo:
97
+ type: object
98
+ required:
99
+ - type
100
+ - limit
101
+ - used
102
+ - remaining
103
+ properties:
104
+ type:
105
+ $ref: '#/components/schemas/QuotaType'
106
+ limit:
107
+ type: integer
108
+ description: Maximum quota limit (-1 for unlimited)
109
+ example: 100
110
+ used:
111
+ type: integer
112
+ description: Current usage count
113
+ example: 42
114
+ remaining:
115
+ type: integer
116
+ description: Remaining quota (-1 for unlimited)
117
+ example: 58
118
+
119
+ QuotaExceededResponse:
120
+ allOf:
121
+ - $ref: '#/components/schemas/ErrorResponse'
122
+ - type: object
123
+ properties:
124
+ quota:
125
+ $ref: '#/components/schemas/QuotaInfo'
126
+
127
+ # Health Check
128
+ HealthCheckResponse:
129
+ type: object
130
+ required:
131
+ - status
132
+ - service
133
+ - timestamp
134
+ - uptime
135
+ properties:
136
+ status:
137
+ type: string
138
+ enum: [healthy, unhealthy]
139
+ service:
140
+ type: string
141
+ example: get-plugin
142
+ timestamp:
143
+ type: string
144
+ format: date-time
145
+ uptime:
146
+ type: integer
147
+ description: Uptime in seconds
148
+ version:
149
+ type: string
150
+ dependencies:
151
+ type: object
152
+ additionalProperties:
153
+ type: string
154
+ enum: [connected, disconnected, unknown]
155
+
156
+ # JWT Payload
157
+ JwtPayload:
158
+ type: object
159
+ required:
160
+ - sub
161
+ - username
162
+ - email
163
+ - role
164
+ - type
165
+ properties:
166
+ sub:
167
+ type: string
168
+ description: User ID (subject)
169
+ username:
170
+ type: string
171
+ email:
172
+ type: string
173
+ format: email
174
+ role:
175
+ type: string
176
+ enum: [user, admin]
177
+ organizationId:
178
+ type: string
179
+ organizationName:
180
+ type: string
181
+ type:
182
+ type: string
183
+ enum: [access, refresh]
184
+ iat:
185
+ type: integer
186
+ description: Issued at timestamp
187
+ exp:
188
+ type: integer
189
+ description: Expiration timestamp
190
+
191
+ headers:
192
+ X-Quota-Limit:
193
+ description: Maximum quota limit
194
+ schema:
195
+ type: integer
196
+ X-Quota-Used:
197
+ description: Current usage count
198
+ schema:
199
+ type: integer
200
+ X-Quota-Remaining:
201
+ description: Remaining quota
202
+ schema:
203
+ type: integer
204
+ X-Quota-Reset:
205
+ description: ISO timestamp when quota resets
206
+ schema:
207
+ type: string
208
+ format: date-time
209
+ Retry-After:
210
+ description: Seconds until quota resets
211
+ schema:
212
+ type: integer
213
+
214
+ responses:
215
+ Unauthorized:
216
+ description: Authentication required
217
+ content:
218
+ application/json:
219
+ schema:
220
+ $ref: '#/components/schemas/ErrorResponse'
221
+ example:
222
+ success: false
223
+ statusCode: 401
224
+ message: Authorization header required
225
+ code: TOKEN_MISSING
226
+
227
+ Forbidden:
228
+ description: Insufficient permissions
229
+ content:
230
+ application/json:
231
+ schema:
232
+ $ref: '#/components/schemas/ErrorResponse'
233
+ example:
234
+ success: false
235
+ statusCode: 403
236
+ message: Admin access required
237
+ code: INSUFFICIENT_PERMISSIONS
238
+
239
+ NotFound:
240
+ description: Resource not found
241
+ content:
242
+ application/json:
243
+ schema:
244
+ $ref: '#/components/schemas/ErrorResponse'
245
+ example:
246
+ success: false
247
+ statusCode: 404
248
+ message: Resource not found
249
+ code: NOT_FOUND
250
+
251
+ QuotaExceeded:
252
+ description: Quota exceeded
253
+ headers:
254
+ Retry-After:
255
+ $ref: '#/components/headers/Retry-After'
256
+ X-Quota-Limit:
257
+ $ref: '#/components/headers/X-Quota-Limit'
258
+ X-Quota-Used:
259
+ $ref: '#/components/headers/X-Quota-Used'
260
+ X-Quota-Remaining:
261
+ $ref: '#/components/headers/X-Quota-Remaining'
262
+ X-Quota-Reset:
263
+ $ref: '#/components/headers/X-Quota-Reset'
264
+ content:
265
+ application/json:
266
+ schema:
267
+ $ref: '#/components/schemas/QuotaExceededResponse'
268
+ example:
269
+ success: false
270
+ statusCode: 429
271
+ message: API call quota exceeded (10000/10000). Please try again later.
272
+ code: QUOTA_EXCEEDED
273
+ quota:
274
+ type: apiCalls
275
+ limit: 10000
276
+ used: 10000
277
+ remaining: 0
278
+
279
+ InternalError:
280
+ description: Internal server error
281
+ content:
282
+ application/json:
283
+ schema:
284
+ $ref: '#/components/schemas/ErrorResponse'
285
+ example:
286
+ success: false
287
+ statusCode: 500
288
+ message: An unexpected error occurred
289
+ code: INTERNAL_ERROR
290
+
291
+ security:
292
+ - bearerAuth: []
package/package.json ADDED
@@ -0,0 +1,127 @@
1
+ {
2
+ "name": "@pipeline-builder/api-core",
3
+ "description": "Core server-side utilities (auth middleware, response helpers, error codes, quota service, HTTP client, logging, AI provider catalog) shared by every Pipeline Builder backend service.",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/mwashburn160/pipeline-builder.git"
7
+ },
8
+ "devDependencies": {
9
+ "@stylistic/eslint-plugin": "^2",
10
+ "@types/express": "5.0.6",
11
+ "@types/jest": "^30.0.0",
12
+ "@types/jsonwebtoken": "9.0.10",
13
+ "@types/node": "25.3.0",
14
+ "@typescript-eslint/eslint-plugin": "^8",
15
+ "@typescript-eslint/parser": "^8",
16
+ "eslint": "^9",
17
+ "eslint-import-resolver-typescript": "^4.4.4",
18
+ "eslint-plugin-import": "^2.32.0",
19
+ "jest": "^30.2.0",
20
+ "jest-junit": "^16",
21
+ "ts-jest": "^29.4.6",
22
+ "typescript": "5.9.3"
23
+ },
24
+ "dependencies": {
25
+ "@asteasolutions/zod-to-openapi": "8.4.0",
26
+ "express": "5.2.1",
27
+ "jsonwebtoken": "9.0.3",
28
+ "winston": "3.19.0",
29
+ "zod": "4.3.6"
30
+ },
31
+ "keywords": [
32
+ "aws",
33
+ "codepipeline",
34
+ "codebuild",
35
+ "cicd",
36
+ "ci-cd",
37
+ "devops",
38
+ "cdk",
39
+ "aws-cdk",
40
+ "cloudformation",
41
+ "pipeline",
42
+ "pipeline-as-code",
43
+ "containerized",
44
+ "docker",
45
+ "kubernetes",
46
+ "plugins",
47
+ "typescript",
48
+ "self-service",
49
+ "multi-tenant",
50
+ "compliance",
51
+ "automation",
52
+ "infrastructure-as-code",
53
+ "iac",
54
+ "cli"
55
+ ],
56
+ "engines": {
57
+ "node": ">= 24.14.0"
58
+ },
59
+ "main": "lib/index.js",
60
+ "license": "Apache-2.0",
61
+ "homepage": "https://mwashburn160.github.io/pipeline-builder/",
62
+ "version": "3.1.0",
63
+ "bugs": {
64
+ "url": "https://github.com/mwashburn160/pipeline-builder/issues"
65
+ },
66
+ "jest": {
67
+ "coverageProvider": "v8",
68
+ "testMatch": [
69
+ "<rootDir>/@(src|test)/**/*(*.)@(spec|test).ts?(x)",
70
+ "<rootDir>/@(src|test)/**/__tests__/**/*.ts?(x)"
71
+ ],
72
+ "clearMocks": true,
73
+ "collectCoverage": true,
74
+ "coverageReporters": [
75
+ "json",
76
+ "lcov",
77
+ "clover",
78
+ "cobertura",
79
+ "text"
80
+ ],
81
+ "coverageDirectory": "coverage",
82
+ "coveragePathIgnorePatterns": [
83
+ "/node_modules/"
84
+ ],
85
+ "testPathIgnorePatterns": [
86
+ "/node_modules/"
87
+ ],
88
+ "watchPathIgnorePatterns": [
89
+ "/node_modules/"
90
+ ],
91
+ "reporters": [
92
+ "default",
93
+ [
94
+ "jest-junit",
95
+ {
96
+ "outputDirectory": "test-reports"
97
+ }
98
+ ]
99
+ ],
100
+ "transform": {
101
+ "^.+\\.[t]sx?$": [
102
+ "ts-jest",
103
+ {
104
+ "tsconfig": "tsconfig.dev.json"
105
+ }
106
+ ]
107
+ },
108
+ "moduleNameMapper": {
109
+ "^uuid$": "<rootDir>/../../jest-uuid-stub.js"
110
+ }
111
+ },
112
+ "types": "lib/index.d.ts",
113
+ "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm dlx projen\".",
114
+ "scripts": {
115
+ "build": "pnpm dlx projen build",
116
+ "compile": "pnpm dlx projen compile",
117
+ "default": "pnpm dlx projen default",
118
+ "eslint": "pnpm dlx projen eslint",
119
+ "package": "pnpm dlx projen package",
120
+ "post-compile": "pnpm dlx projen post-compile",
121
+ "pre-compile": "pnpm dlx projen pre-compile",
122
+ "test": "pnpm dlx projen test",
123
+ "test:watch": "pnpm dlx projen test:watch",
124
+ "watch": "pnpm dlx projen watch",
125
+ "projen": "pnpm dlx projen"
126
+ }
127
+ }