@burdenoff/be-sdk 2026.1021.4 → 2026.1021.6

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 (47) hide show
  1. package/README.md +92 -0
  2. package/dist/cache/index.js +2 -2
  3. package/dist/chunk-4KK6YJ46.js +41 -0
  4. package/dist/chunk-4KK6YJ46.js.map +1 -0
  5. package/dist/chunk-AE4PRE4N.js +731 -0
  6. package/dist/chunk-AE4PRE4N.js.map +1 -0
  7. package/dist/{chunk-YCSIHUYP.js → chunk-HDUS6UBO.js} +3 -3
  8. package/dist/{chunk-YCSIHUYP.js.map → chunk-HDUS6UBO.js.map} +1 -1
  9. package/dist/{chunk-HIO3DNKK.js → chunk-KCGJCY5U.js} +2 -2
  10. package/dist/{chunk-HIO3DNKK.js.map → chunk-KCGJCY5U.js.map} +1 -1
  11. package/dist/{chunk-AT52BRVL.js → chunk-OXGIVASV.js} +3 -3
  12. package/dist/{chunk-AT52BRVL.js.map → chunk-OXGIVASV.js.map} +1 -1
  13. package/dist/{chunk-GSIJ2DBJ.js → chunk-PPFJTSHA.js} +3 -3
  14. package/dist/{chunk-GSIJ2DBJ.js.map → chunk-PPFJTSHA.js.map} +1 -1
  15. package/dist/chunk-QZG27OR7.js +22 -0
  16. package/dist/chunk-QZG27OR7.js.map +1 -0
  17. package/dist/{chunk-2TTE5KSS.js → chunk-UCNTCCV6.js} +5 -54
  18. package/dist/chunk-UCNTCCV6.js.map +1 -0
  19. package/dist/chunk-X3MNBBOL.js +941 -0
  20. package/dist/chunk-X3MNBBOL.js.map +1 -0
  21. package/dist/{chunk-TNYNRKLQ.js → chunk-XJKVW34Q.js} +3 -3
  22. package/dist/{chunk-TNYNRKLQ.js.map → chunk-XJKVW34Q.js.map} +1 -1
  23. package/dist/client-WSFUJHLI.js +11 -0
  24. package/dist/client-WSFUJHLI.js.map +1 -0
  25. package/dist/export/index.js +5 -3
  26. package/dist/files/index.d.ts +3 -0
  27. package/dist/files/index.js +5 -0
  28. package/dist/files/index.js.map +1 -0
  29. package/dist/gateway/index.d.ts +2 -1
  30. package/dist/gateway/index.js +4 -2
  31. package/dist/gateway/security/index.js +1 -1
  32. package/dist/index-BWhuZl8f.d.ts +59 -0
  33. package/dist/index-BjtgcJxt.d.ts +208 -0
  34. package/dist/index-C_t30VyQ.d.ts +284 -0
  35. package/dist/index.d.ts +4 -1
  36. package/dist/index.js +21 -18
  37. package/dist/index.js.map +1 -1
  38. package/dist/init/index.js +5 -3
  39. package/dist/server/index.js +1 -1
  40. package/dist/tags/index.d.ts +3 -0
  41. package/dist/tags/index.js +5 -0
  42. package/dist/tags/index.js.map +1 -0
  43. package/dist/tracker/index.js +2 -2
  44. package/dist/types-B376RbyK.d.ts +108 -0
  45. package/package.json +3 -3
  46. package/dist/chunk-2TTE5KSS.js.map +0 -1
  47. package/dist/index-Dy6neH2G.d.ts +0 -166
package/README.md CHANGED
@@ -136,6 +136,8 @@ await sdk.translation.upsertProductTranslations({
136
136
  - **bootstrap**: Server initialization
137
137
  - **platform**: Scale primitives (see below)
138
138
  - **validation**: User-field validators and the `@rbac` coverage guard (see below)
139
+ - **tags**: Shared entity tagging over wspace-tags-svc (see below)
140
+ - **files**: Shared client for workspace blobs owned by wspace-files-svc (see below)
139
141
 
140
142
  ### RBAC coverage guard (`@burdenoff/be-sdk/validation`)
141
143
 
@@ -161,6 +163,96 @@ it('gates every root field with a well-formed @rbac', () => {
161
163
 
162
164
  `analyzeRbacCoverage` returns the same report without throwing.
163
165
 
166
+ ### Entity tags (`@burdenoff/be-sdk/tags`)
167
+
168
+ One implementation of "let users tag my entities" for every svc, replacing the per-svc
169
+ `EntityTagAdapter` copies. Everything goes to **wspace-tags-svc** through the internal
170
+ workspace gateway with the caller's `x-actor-*` / `x-workspace-id` forwarded.
171
+
172
+ - `TagsGatewayAdapter` takes the svc's entity types, its default vocabulary and default
173
+ source, and provides get / tag / untag / replace, search / list / create tags (inline
174
+ create resolves or creates the default vocabulary), and `findEntityIdsByTags` for
175
+ server-side filter-by-tag. Inputs are validated (`EntityTagsError` with a stable `code`).
176
+ - `buildEntityTagsSdl({ prefix, rbac, extendTypes })` emits the whole surface under a
177
+ per-svc prefix, because two subgraphs declaring the same non-shareable tag types break
178
+ composition. Every root field carries a static `@rbac`. `typeNames` / `externalTypes`
179
+ keep already-published names (VibeControls ships `EntityTagAssignment`, `AvailableTag`).
180
+ - `createEntityTagResolvers({ prefix, adapter, entities })` returns the matching
181
+ `Query` / `Mutation` / per-type `tagAssignments` resolvers (fail-soft reads), with
182
+ `authorizeEntity` (ownership check: throw NOT_FOUND), `onMutation` (audit) and
183
+ `mapError` (svc i18n errors) hooks.
184
+
185
+ ```typescript
186
+ import { TagsGatewayAdapter, buildEntityTagsSdl, createEntityTagResolvers } from '@burdenoff/be-sdk/tags';
187
+
188
+ const adapter = new TagsGatewayAdapter({
189
+ serviceName: 'wspace-workflow-svc',
190
+ entityTypes: ['FLUIDGRIDS_WORKFLOW', 'FLUIDGRIDS_RUN', 'FLUIDGRIDS_DATATABLE'],
191
+ vocabulary: { key: 'fluidgrids-tags', name: 'FluidGrids Tags' },
192
+ });
193
+
194
+ export const typeDefs = buildEntityTagsSdl({
195
+ prefix: 'Fluidgrids', // fluidgridsEntityTags, tagFluidgridsEntity, FluidgridsTagAssignment, ...
196
+ productLabel: 'FluidGrids',
197
+ rbac: { resource: 'workflow' },
198
+ extendTypes: ['WorkflowDefinition', 'WorkflowRun', 'DataTable'],
199
+ includeEntitiesByTags: true,
200
+ });
201
+
202
+ export const { Query, Mutation, types } = createEntityTagResolvers({
203
+ prefix: 'Fluidgrids',
204
+ adapter,
205
+ includeEntitiesByTags: true,
206
+ entities: {
207
+ // Versioned rows: tag the logical key so every version shares one tag set.
208
+ WorkflowDefinition: { entityType: 'FLUIDGRIDS_WORKFLOW', entityId: (p) => String(p.workflowKey ?? '') },
209
+ WorkflowRun: { entityType: 'FLUIDGRIDS_RUN' },
210
+ DataTable: { entityType: 'FLUIDGRIDS_DATATABLE' },
211
+ },
212
+ });
213
+ ```
214
+
215
+ ### Files client (`@burdenoff/be-sdk/files`)
216
+
217
+ wspace-files-svc owns every workspace blob. Services must not presign object storage
218
+ themselves or hold storage credentials: hand the bytes to `FilesClient` and persist only
219
+ the opaque `fileId`. Every call goes through the internal workspace gateway with the
220
+ CALLER's `x-actor-*` / `x-workspace-id`, so the File row is owned by the user who asked
221
+ for it and files-svc applies quota, folder access and read permission to that user. The
222
+ service must still authorize the action itself (its own `@rbac` plus a scoped row lookup).
223
+
224
+ - `uploadFile` runs the files-svc protocol: `initiateUpload` → presigned PUT (DIRECT) or
225
+ per-part PUTs + `registerUploadedPart` (MULTIPART, which files-svc picks above 5 MiB) →
226
+ `completeUpload` with the same `fileSize` string (required). The SHA-256 is declared at
227
+ both ends; a failed upload aborts its session.
228
+ - `requireFile` proves a caller-supplied `fileId` is an ACTIVE, actor-readable File in the
229
+ actor's workspace (throws `NOT_FOUND`, never a permission error) before you store it.
230
+ - `getDownloadUrl` mints a short-lived URL on demand (clamped to 60 s – 7 days, the S3
231
+ presign cap); never persist it. `downloadFile` / `downloadFileAsBase64` fetch the bytes
232
+ for server-side processing with a size cap. `deleteFile` trashes (or `permanent`).
233
+ - `FileReference` (`toFileReference`, `isFileReference`) is the JSON-safe pointer that node
234
+ outputs, attachments and evidence rows carry instead of inline base64.
235
+ - Only scalar `File` fields are read through the ROOT `getFile` field: files-svc's `File`
236
+ entity has no `__resolveReference`, so never select federated `file { name }` elsewhere.
237
+ - Errors are `FilesClientError` with a stable `code` (`NOT_FOUND`, `QUOTA_EXCEEDED`,
238
+ `TOO_LARGE`, `STORAGE_ERROR`, …) and `graphqlCode`.
239
+
240
+ ```typescript
241
+ import { FilesClient, toFileReference } from '@burdenoff/be-sdk/files';
242
+
243
+ const files = new FilesClient({ serviceName: 'wspace-vibecontrols-svc' });
244
+ const actor = { actorId: ctx.actorId, workspaceId: ctx.workspaceId };
245
+
246
+ const stored = await files.uploadFile(
247
+ { fileName: 'access-review.pdf', data: pdfBytes, mimeType: 'application/pdf', description: 'SOC 2 evidence' },
248
+ actor
249
+ );
250
+ await db.securityEvidence.update({ where: { id }, data: { fileId: stored.fileId } });
251
+
252
+ const url = await files.getDownloadUrl(evidence.fileId, actor, { expiresInSeconds: 300 });
253
+ const output = { attachment: toFileReference(stored) }; // workflow node output, no base64
254
+ ```
255
+
164
256
  ### Platform Primitives (`@burdenoff/be-sdk/platform`)
165
257
 
166
258
  Reusable building blocks consumed fleet-wide as part of the scale refactor:
@@ -1,6 +1,6 @@
1
- export { CacheFactory, CacheProviderType, MemoryCacheProvider, ValkeyGlideProvider, assertCacheEndpointConfigured, closeAllCaches, createCache, getCache, getValkeyClient, warnOnLayerDefaultEndpoint } from '../chunk-AT52BRVL.js';
2
- import '../chunk-KO2ZXZ7W.js';
1
+ export { CacheFactory, CacheProviderType, MemoryCacheProvider, ValkeyGlideProvider, assertCacheEndpointConfigured, closeAllCaches, createCache, getCache, getValkeyClient, warnOnLayerDefaultEndpoint } from '../chunk-OXGIVASV.js';
3
2
  import '../chunk-A5F6Z5UE.js';
3
+ import '../chunk-KO2ZXZ7W.js';
4
4
  import '../chunk-YFOHAHZE.js';
5
5
  import '../chunk-RU266375.js';
6
6
  import '../chunk-XE4OXN2W.js';
@@ -0,0 +1,41 @@
1
+ import { __name } from './chunk-XE4OXN2W.js';
2
+
3
+ // src/gateway/types.ts
4
+ var CircuitState = /* @__PURE__ */ (function(CircuitState2) {
5
+ CircuitState2["CLOSED"] = "CLOSED";
6
+ CircuitState2["OPEN"] = "OPEN";
7
+ CircuitState2["HALF_OPEN"] = "HALF_OPEN";
8
+ return CircuitState2;
9
+ })({});
10
+ var GatewayErrorType = /* @__PURE__ */ (function(GatewayErrorType2) {
11
+ GatewayErrorType2["NETWORK_ERROR"] = "NETWORK_ERROR";
12
+ GatewayErrorType2["TIMEOUT_ERROR"] = "TIMEOUT_ERROR";
13
+ GatewayErrorType2["CIRCUIT_OPEN"] = "CIRCUIT_OPEN";
14
+ GatewayErrorType2["GRAPHQL_ERROR"] = "GRAPHQL_ERROR";
15
+ GatewayErrorType2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
16
+ return GatewayErrorType2;
17
+ })({});
18
+ var GatewayError = class _GatewayError extends Error {
19
+ static {
20
+ __name(this, "GatewayError");
21
+ }
22
+ type;
23
+ gatewayUrl;
24
+ statusCode;
25
+ graphqlErrors;
26
+ cause;
27
+ constructor(message, type, gatewayUrl, options) {
28
+ super(message);
29
+ this.name = "GatewayError";
30
+ this.type = type;
31
+ this.gatewayUrl = gatewayUrl;
32
+ this.statusCode = options?.statusCode;
33
+ this.graphqlErrors = options?.graphqlErrors;
34
+ this.cause = options?.cause;
35
+ Object.setPrototypeOf(this, _GatewayError.prototype);
36
+ }
37
+ };
38
+
39
+ export { CircuitState, GatewayError, GatewayErrorType };
40
+ //# sourceMappingURL=chunk-4KK6YJ46.js.map
41
+ //# sourceMappingURL=chunk-4KK6YJ46.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/gateway/types.ts"],"names":["CircuitState","GatewayErrorType","GatewayError","Error","type","gatewayUrl","statusCode","graphqlErrors","cause","message","options","name","Object","setPrototypeOf","prototype"],"mappings":";;;AA2EO,IAAKA,YAAAA,6BAAAA,aAAAA,EAAAA;;;;AAAAA,EAAAA,OAAAA,aAAAA;;AA8ML,IAAKC,gBAAAA,6BAAAA,iBAAAA,EAAAA;;;;;;AAAAA,EAAAA,OAAAA,iBAAAA;;AAWL,IAAMC,YAAAA,GAAN,MAAMA,aAAAA,SAAqBC,KAAAA,CAAAA;EApSlC;;;AAqSEC,EAAAA,IAAAA;AACAC,EAAAA,UAAAA;AACAC,EAAAA,UAAAA;AACAC,EAAAA,aAAAA;AACSC,EAAAA,KAAAA;EAET,WAAA,CACEC,OAAAA,EACAL,IAAAA,EACAC,UAAAA,EACAK,OAAAA,EAKA;AACA,IAAA,KAAA,CAAMD,OAAAA,CAAAA;AACN,IAAA,IAAA,CAAKE,IAAAA,GAAO,cAAA;AACZ,IAAA,IAAA,CAAKP,IAAAA,GAAOA,IAAAA;AACZ,IAAA,IAAA,CAAKC,UAAAA,GAAaA,UAAAA;AAClB,IAAA,IAAA,CAAKC,aAAaI,OAAAA,EAASJ,UAAAA;AAC3B,IAAA,IAAA,CAAKC,gBAAgBG,OAAAA,EAASH,aAAAA;AAC9B,IAAA,IAAA,CAAKC,QAAQE,OAAAA,EAASF,KAAAA;AACtBI,IAAAA,MAAAA,CAAOC,cAAAA,CAAe,IAAA,EAAMX,aAAAA,CAAaY,SAAS,CAAA;AACpD,EAAA;AACF","file":"chunk-4KK6YJ46.js","sourcesContent":["/**\n * Gateway Client Types\n *\n * Type definitions for the unified gateway client with\n * circuit breaker and retry logic.\n *\n * @module gateway/types\n * @category Gateway\n */\n\nimport type { ServiceLayer, CircuitBreakerConfig, GatewayRetryConfig, GatewayRequestHeaders } from '../types/layer.js';\n\n/**\n * Gateway client configuration\n */\nexport interface GatewayClientConfig {\n /**\n * Layer this client belongs to\n */\n layer: ServiceLayer;\n\n /**\n * Service name (for logging and headers)\n */\n serviceName: string;\n\n /**\n * Service identity for bypass headers\n * @default serviceName\n */\n serviceIdentity?: string;\n\n /**\n * Internal gateway URL (same layer M2M)\n * @default Resolved from layer defaults or environment\n */\n internalGatewayUrl?: string;\n\n /**\n * Cross-layer gateway URL (cross layer via public gateway)\n * @default Resolved from layer defaults or environment\n */\n crossLayerGatewayUrl?: string;\n\n /**\n * Request timeout in milliseconds\n * @default 30000 (30 seconds)\n */\n timeout?: number;\n\n /**\n * Circuit breaker configuration\n */\n circuitBreaker?: Partial<CircuitBreakerConfig>;\n\n /**\n * Retry configuration\n */\n retry?: Partial<GatewayRetryConfig>;\n\n /**\n * Enable request logging\n * @default true\n */\n enableLogging?: boolean;\n\n /**\n * Default headers to include in all requests\n */\n defaultHeaders?: GatewayRequestHeaders;\n}\n\n/**\n * Circuit breaker states\n */\nexport enum CircuitState {\n CLOSED = 'CLOSED',\n OPEN = 'OPEN',\n HALF_OPEN = 'HALF_OPEN',\n}\n\n/**\n * Circuit breaker instance interface\n */\nexport interface ICircuitBreaker {\n /**\n * Get current circuit state\n */\n getState(): CircuitState;\n\n /**\n * Record a successful call\n */\n recordSuccess(): void;\n\n /**\n * Record a failed call\n */\n recordFailure(): void;\n\n /**\n * Check if circuit allows calls\n */\n allowRequest(): boolean;\n\n /**\n * Force open the circuit\n */\n forceOpen(): void;\n\n /**\n * Force close the circuit\n */\n forceClose(): void;\n\n /**\n * Get circuit statistics\n */\n getStats(): CircuitBreakerStats;\n}\n\n/**\n * Circuit breaker statistics\n */\nexport interface CircuitBreakerStats {\n state: CircuitState;\n failures: number;\n successes: number;\n consecutiveFailures: number;\n lastFailureTime: number | null;\n lastSuccessTime: number | null;\n openedAt: number | null;\n}\n\n/**\n * GraphQL request options\n */\nexport interface GraphQLRequestOptions {\n /**\n * GraphQL query or mutation string\n */\n query: string;\n\n /**\n * GraphQL variables\n */\n variables?: Record<string, unknown>;\n\n /**\n * Operation name (for multi-operation documents)\n */\n operationName?: string;\n\n /**\n * Additional headers for this request\n */\n headers?: GatewayRequestHeaders;\n\n /**\n * Override timeout for this request\n */\n timeout?: number;\n\n /**\n * Skip circuit breaker for this request\n * @default false\n */\n skipCircuitBreaker?: boolean;\n\n /**\n * Skip retry logic for this request\n * @default false\n */\n skipRetry?: boolean;\n}\n\n/**\n * GraphQL response\n */\nexport interface GraphQLResponse<T = unknown> {\n /**\n * Response data\n */\n data?: T;\n\n /**\n * GraphQL errors\n */\n errors?: GraphQLError[];\n}\n\n/**\n * GraphQL error structure\n */\nexport interface GraphQLError {\n message: string;\n locations?: Array<{ line: number; column: number }>;\n path?: Array<string | number>;\n extensions?: Record<string, unknown>;\n}\n\n/**\n * Gateway client interface\n */\nexport interface IGatewayClient {\n /**\n * Execute internal (same layer) GraphQL query/mutation\n *\n * Uses internal gateway with bypass headers for M2M communication.\n *\n * @param options - Request options\n * @returns GraphQL response\n */\n internalQuery<T = unknown>(options: GraphQLRequestOptions): Promise<GraphQLResponse<T>>;\n\n /**\n * Execute cross-layer GraphQL query/mutation\n *\n * Uses public gateway for cross-layer communication.\n *\n * @param options - Request options\n * @returns GraphQL response\n */\n crossLayerQuery<T = unknown>(options: GraphQLRequestOptions): Promise<GraphQLResponse<T>>;\n\n /**\n * Execute GraphQL query/mutation with explicit gateway URL\n *\n * @param gatewayUrl - Gateway URL to use\n * @param options - Request options\n * @returns GraphQL response\n */\n query<T = unknown>(gatewayUrl: string, options: GraphQLRequestOptions): Promise<GraphQLResponse<T>>;\n\n /**\n * Get internal gateway circuit breaker\n */\n getInternalCircuitBreaker(): ICircuitBreaker;\n\n /**\n * Get cross-layer gateway circuit breaker\n */\n getCrossLayerCircuitBreaker(): ICircuitBreaker;\n\n /**\n * Get client health status\n */\n getHealthStatus(): GatewayClientHealth;\n\n /**\n * Update default headers\n */\n updateDefaultHeaders(headers: Partial<GatewayRequestHeaders>): void;\n}\n\n/**\n * Gateway client health status\n */\nexport interface GatewayClientHealth {\n /**\n * Internal gateway status\n */\n internal: {\n url: string;\n circuitState: CircuitState;\n stats: CircuitBreakerStats;\n };\n\n /**\n * Cross-layer gateway status\n */\n crossLayer: {\n url: string;\n circuitState: CircuitState;\n stats: CircuitBreakerStats;\n };\n}\n\n/**\n * Gateway error types\n */\nexport enum GatewayErrorType {\n NETWORK_ERROR = 'NETWORK_ERROR',\n TIMEOUT_ERROR = 'TIMEOUT_ERROR',\n CIRCUIT_OPEN = 'CIRCUIT_OPEN',\n GRAPHQL_ERROR = 'GRAPHQL_ERROR',\n UNKNOWN_ERROR = 'UNKNOWN_ERROR',\n}\n\n/**\n * Gateway error class\n */\nexport class GatewayError extends Error {\n type: GatewayErrorType;\n gatewayUrl: string;\n statusCode?: number;\n graphqlErrors?: GraphQLError[];\n override cause?: Error;\n\n constructor(\n message: string,\n type: GatewayErrorType,\n gatewayUrl: string,\n options?: {\n statusCode?: number;\n graphqlErrors?: GraphQLError[];\n cause?: Error;\n }\n ) {\n super(message);\n this.name = 'GatewayError';\n this.type = type;\n this.gatewayUrl = gatewayUrl;\n this.statusCode = options?.statusCode;\n this.graphqlErrors = options?.graphqlErrors;\n this.cause = options?.cause;\n Object.setPrototypeOf(this, GatewayError.prototype);\n }\n}\n\n/**\n * Request context for logging and tracing\n */\nexport interface RequestContext {\n /**\n * Request ID for tracing\n */\n requestId: string;\n\n /**\n * Actor ID making the request\n */\n actorId?: string;\n\n /**\n * Workspace ID context\n */\n workspaceId?: string;\n\n /**\n * Timestamp when request started\n */\n startTime: number;\n\n /**\n * Call type\n */\n callType: 'internal' | 'cross-layer' | 'direct';\n}\n"]}