@lssm/lib.files 0.0.0-canary-20251217083314 → 1.41.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 (138) hide show
  1. package/dist/contracts/index.js +1 -858
  2. package/dist/docs/files.docblock.js +2 -22
  3. package/dist/docs/index.js +1 -1
  4. package/dist/entities/index.js +1 -265
  5. package/dist/events.js +1 -343
  6. package/dist/files.feature.js +1 -124
  7. package/dist/index.js +1 -8
  8. package/dist/storage/index.js +1 -268
  9. package/package.json +13 -14
  10. package/dist/contracts/dist/capabilities/openbanking.js +0 -88
  11. package/dist/contracts/dist/client/index.js +0 -5
  12. package/dist/contracts/dist/client/react/feature-render.js +0 -2
  13. package/dist/contracts/dist/client/react/form-render.js +0 -4
  14. package/dist/contracts/dist/client/react/index.js +0 -4
  15. package/dist/contracts/dist/contract-registry/index.js +0 -1
  16. package/dist/contracts/dist/contract-registry/schemas.js +0 -60
  17. package/dist/contracts/dist/docs/PUBLISHING.docblock.js +0 -16
  18. package/dist/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +0 -16
  19. package/dist/contracts/dist/docs/index.js +0 -29
  20. package/dist/contracts/dist/docs/presentations.js +0 -71
  21. package/dist/contracts/dist/docs/registry.js +0 -44
  22. package/dist/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +0 -16
  23. package/dist/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +0 -16
  24. package/dist/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +0 -16
  25. package/dist/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +0 -16
  26. package/dist/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +0 -16
  27. package/dist/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +0 -80
  28. package/dist/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +0 -57
  29. package/dist/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +0 -16
  30. package/dist/contracts/dist/docs/tech/llm/llm-integration.docblock.js +0 -357
  31. package/dist/contracts/dist/docs/tech/mcp-endpoints.docblock.js +0 -37
  32. package/dist/contracts/dist/docs/tech/presentation-runtime.docblock.js +0 -16
  33. package/dist/contracts/dist/docs/tech/schema/README.docblock.js +0 -20
  34. package/dist/contracts/dist/docs/tech/studio/learning-events.docblock.js +0 -48
  35. package/dist/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +0 -79
  36. package/dist/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +0 -84
  37. package/dist/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +0 -45
  38. package/dist/contracts/dist/docs/tech/studio/project-routing.docblock.js +0 -67
  39. package/dist/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +0 -40
  40. package/dist/contracts/dist/docs/tech/studio/team-invitations.docblock.js +0 -69
  41. package/dist/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +0 -47
  42. package/dist/contracts/dist/docs/tech/studio/workspaces.docblock.js +0 -62
  43. package/dist/contracts/dist/docs/tech/telemetry-ingest.docblock.js +0 -155
  44. package/dist/contracts/dist/docs/tech/templates/runtime.docblock.js +0 -20
  45. package/dist/contracts/dist/docs/tech/vscode-extension.docblock.js +0 -101
  46. package/dist/contracts/dist/docs/tech/workflows/overview.docblock.js +0 -20
  47. package/dist/contracts/dist/events.js +0 -10
  48. package/dist/contracts/dist/experiments/evaluator.js +0 -1
  49. package/dist/contracts/dist/index.js +0 -71
  50. package/dist/contracts/dist/install.js +0 -2
  51. package/dist/contracts/dist/integrations/contracts.js +0 -377
  52. package/dist/contracts/dist/integrations/index.js +0 -18
  53. package/dist/contracts/dist/integrations/openbanking/contracts/accounts.js +0 -228
  54. package/dist/contracts/dist/integrations/openbanking/contracts/balances.js +0 -159
  55. package/dist/contracts/dist/integrations/openbanking/contracts/index.js +0 -3
  56. package/dist/contracts/dist/integrations/openbanking/contracts/transactions.js +0 -210
  57. package/dist/contracts/dist/integrations/openbanking/models.js +0 -242
  58. package/dist/contracts/dist/integrations/openbanking/telemetry.js +0 -13
  59. package/dist/contracts/dist/integrations/providers/elevenlabs.js +0 -52
  60. package/dist/contracts/dist/integrations/providers/gcs-storage.js +0 -75
  61. package/dist/contracts/dist/integrations/providers/gmail.js +0 -87
  62. package/dist/contracts/dist/integrations/providers/google-calendar.js +0 -66
  63. package/dist/contracts/dist/integrations/providers/index.js +0 -11
  64. package/dist/contracts/dist/integrations/providers/mistral.js +0 -68
  65. package/dist/contracts/dist/integrations/providers/postmark.js +0 -68
  66. package/dist/contracts/dist/integrations/providers/powens.js +0 -116
  67. package/dist/contracts/dist/integrations/providers/qdrant.js +0 -73
  68. package/dist/contracts/dist/integrations/providers/registry.js +0 -10
  69. package/dist/contracts/dist/integrations/providers/stripe.js +0 -83
  70. package/dist/contracts/dist/integrations/providers/twilio-sms.js +0 -61
  71. package/dist/contracts/dist/jsonschema.js +0 -1
  72. package/dist/contracts/dist/knowledge/contracts.js +0 -306
  73. package/dist/contracts/dist/knowledge/index.js +0 -7
  74. package/dist/contracts/dist/knowledge/spaces/email-threads.js +0 -34
  75. package/dist/contracts/dist/knowledge/spaces/financial-docs.js +0 -34
  76. package/dist/contracts/dist/knowledge/spaces/financial-overview.js +0 -38
  77. package/dist/contracts/dist/knowledge/spaces/index.js +0 -6
  78. package/dist/contracts/dist/knowledge/spaces/product-canon.js +0 -34
  79. package/dist/contracts/dist/knowledge/spaces/support-faq.js +0 -37
  80. package/dist/contracts/dist/knowledge/spaces/uploaded-docs.js +0 -34
  81. package/dist/contracts/dist/llm/exporters.js +0 -19
  82. package/dist/contracts/dist/llm/index.js +0 -2
  83. package/dist/contracts/dist/llm/prompts.js +0 -1
  84. package/dist/contracts/dist/onboarding-base.js +0 -196
  85. package/dist/contracts/dist/openapi.js +0 -1
  86. package/dist/contracts/dist/ownership.js +0 -21
  87. package/dist/contracts/dist/presentations.js +0 -1
  88. package/dist/contracts/dist/presentations.v2.js +0 -11
  89. package/dist/contracts/dist/prompt.js +0 -1
  90. package/dist/contracts/dist/promptRegistry.js +0 -1
  91. package/dist/contracts/dist/regenerator/index.js +0 -1
  92. package/dist/contracts/dist/regenerator/service.js +0 -6
  93. package/dist/contracts/dist/registry.js +0 -2
  94. package/dist/contracts/dist/resources.js +0 -1
  95. package/dist/contracts/dist/schema/dist/EnumType.js +0 -2
  96. package/dist/contracts/dist/schema/dist/FieldType.js +0 -49
  97. package/dist/contracts/dist/schema/dist/ScalarTypeEnum.js +0 -236
  98. package/dist/contracts/dist/schema/dist/SchemaModel.js +0 -34
  99. package/dist/contracts/dist/schema/dist/entity/defineEntity.js +0 -1
  100. package/dist/contracts/dist/schema/dist/entity/index.js +0 -2
  101. package/dist/contracts/dist/schema/dist/entity/types.js +0 -1
  102. package/dist/contracts/dist/schema/dist/index.js +0 -6
  103. package/dist/contracts/dist/server/graphql-pothos.js +0 -6
  104. package/dist/contracts/dist/server/index.js +0 -8
  105. package/dist/contracts/dist/server/mcp/createMcpServer.js +0 -4
  106. package/dist/contracts/dist/server/mcp/registerPresentations.js +0 -2
  107. package/dist/contracts/dist/server/mcp/registerPrompts.js +0 -1
  108. package/dist/contracts/dist/server/mcp/registerResources.js +0 -2
  109. package/dist/contracts/dist/server/mcp/registerTools.js +0 -1
  110. package/dist/contracts/dist/server/provider-mcp.js +0 -1
  111. package/dist/contracts/dist/server/rest-elysia.js +0 -1
  112. package/dist/contracts/dist/server/rest-express.js +0 -1
  113. package/dist/contracts/dist/server/rest-generic.js +0 -1
  114. package/dist/contracts/dist/server/rest-next-app.js +0 -1
  115. package/dist/contracts/dist/server/rest-next-pages.js +0 -1
  116. package/dist/contracts/dist/spec.js +0 -34
  117. package/dist/contracts/dist/telemetry/index.js +0 -1
  118. package/dist/contracts/dist/telemetry/tracker.js +0 -1
  119. package/dist/contracts/dist/tests/index.js +0 -1
  120. package/dist/contracts/dist/tests/runner.js +0 -2
  121. package/dist/contracts/dist/workflow/index.js +0 -1
  122. package/dist/contracts/dist/workflow/runner.js +0 -1
  123. package/dist/contracts/index.d.ts +0 -1139
  124. package/dist/docs/files.docblock.d.ts +0 -1
  125. package/dist/docs/index.d.ts +0 -1
  126. package/dist/entities/index.d.ts +0 -168
  127. package/dist/events.d.ts +0 -467
  128. package/dist/files.feature.d.ts +0 -11
  129. package/dist/index.d.ts +0 -6
  130. package/dist/schema/dist/EnumType.js +0 -2
  131. package/dist/schema/dist/FieldType.js +0 -49
  132. package/dist/schema/dist/ScalarTypeEnum.js +0 -236
  133. package/dist/schema/dist/SchemaModel.js +0 -39
  134. package/dist/schema/dist/entity/defineEntity.js +0 -236
  135. package/dist/schema/dist/entity/index.js +0 -2
  136. package/dist/schema/dist/entity/types.js +0 -1
  137. package/dist/schema/dist/index.js +0 -6
  138. package/dist/storage/index.d.ts +0 -200
@@ -1,124 +1 @@
1
- //#region src/files.feature.ts
2
- /**
3
- * Files feature module that bundles file upload, versioning,
4
- * and attachment management capabilities.
5
- */
6
- const FilesFeature = {
7
- meta: {
8
- key: "files",
9
- title: "File Management",
10
- description: "File upload, versioning, and attachment management with presigned URLs",
11
- domain: "platform",
12
- owners: ["@platform.files"],
13
- tags: [
14
- "files",
15
- "upload",
16
- "attachments",
17
- "storage"
18
- ],
19
- stability: "stable"
20
- },
21
- operations: [
22
- {
23
- name: "file.upload",
24
- version: 1
25
- },
26
- {
27
- name: "file.update",
28
- version: 1
29
- },
30
- {
31
- name: "file.delete",
32
- version: 1
33
- },
34
- {
35
- name: "file.get",
36
- version: 1
37
- },
38
- {
39
- name: "file.list",
40
- version: 1
41
- },
42
- {
43
- name: "file.downloadUrl",
44
- version: 1
45
- },
46
- {
47
- name: "file.presignedUrl.create",
48
- version: 1
49
- },
50
- {
51
- name: "file.version.create",
52
- version: 1
53
- },
54
- {
55
- name: "file.version.list",
56
- version: 1
57
- },
58
- {
59
- name: "attachment.attach",
60
- version: 1
61
- },
62
- {
63
- name: "attachment.detach",
64
- version: 1
65
- },
66
- {
67
- name: "attachment.list",
68
- version: 1
69
- }
70
- ],
71
- events: [
72
- {
73
- name: "file.uploaded",
74
- version: 1
75
- },
76
- {
77
- name: "file.updated",
78
- version: 1
79
- },
80
- {
81
- name: "file.deleted",
82
- version: 1
83
- },
84
- {
85
- name: "file.version_created",
86
- version: 1
87
- },
88
- {
89
- name: "attachment.attached",
90
- version: 1
91
- },
92
- {
93
- name: "attachment.detached",
94
- version: 1
95
- },
96
- {
97
- name: "upload.session_started",
98
- version: 1
99
- },
100
- {
101
- name: "upload.session_completed",
102
- version: 1
103
- }
104
- ],
105
- presentations: [],
106
- opToPresentation: [],
107
- presentationsTargets: [],
108
- capabilities: {
109
- provides: [{
110
- key: "files",
111
- version: 1
112
- }, {
113
- key: "attachments",
114
- version: 1
115
- }],
116
- requires: [{
117
- key: "identity",
118
- version: 1
119
- }]
120
- }
121
- };
122
-
123
- //#endregion
124
- export { FilesFeature };
1
+ const e={meta:{key:`files`,title:`File Management`,description:`File upload, versioning, and attachment management with presigned URLs`,domain:`platform`,owners:[`@platform.files`],tags:[`files`,`upload`,`attachments`,`storage`],stability:`stable`},operations:[{name:`file.upload`,version:1},{name:`file.update`,version:1},{name:`file.delete`,version:1},{name:`file.get`,version:1},{name:`file.list`,version:1},{name:`file.downloadUrl`,version:1},{name:`file.presignedUrl.create`,version:1},{name:`file.version.create`,version:1},{name:`file.version.list`,version:1},{name:`attachment.attach`,version:1},{name:`attachment.detach`,version:1},{name:`attachment.list`,version:1}],events:[{name:`file.uploaded`,version:1},{name:`file.updated`,version:1},{name:`file.deleted`,version:1},{name:`file.version_created`,version:1},{name:`attachment.attached`,version:1},{name:`attachment.detached`,version:1},{name:`upload.session_started`,version:1},{name:`upload.session_completed`,version:1}],presentations:[],opToPresentation:[],presentationsTargets:[],capabilities:{provides:[{key:`files`,version:1},{key:`attachments`,version:1}],requires:[{key:`identity`,version:1}]}};export{e as FilesFeature};
package/dist/index.js CHANGED
@@ -1,8 +1 @@
1
- import { AttachmentAttachedEvent, AttachmentDetachedEvent, FileDeletedEvent, FileEvents, FileUpdatedEvent, FileUploadedEvent, FileVersionCreatedEvent, UploadSessionCompletedEvent, UploadSessionStartedEvent } from "./events.js";
2
- import { FilesFeature } from "./files.feature.js";
3
- import { AttachmentEntity, FileEntity, FileStatusEnum, FileVersionEntity, StorageProviderEnum, UploadSessionEntity, fileEntities, filesSchemaContribution } from "./entities/index.js";
4
- import { AttachFileContract, AttachmentModel, CreatePresignedUrlContract, CreateVersionContract, DeleteFileContract, DetachFileContract, FileModel, FileVersionModel, GetDownloadUrlContract, GetFileContract, GetVersionsContract, ListAttachmentsContract, ListFilesContract, PresignedUrlModel, UpdateFileContract, UploadFileContract } from "./contracts/index.js";
5
- import { InMemoryStorageAdapter, LocalStorageAdapter, S3StorageAdapter, createStorageAdapter } from "./storage/index.js";
6
- import "./docs/index.js";
7
-
8
- export { AttachFileContract, AttachmentAttachedEvent, AttachmentDetachedEvent, AttachmentEntity, AttachmentModel, CreatePresignedUrlContract, CreateVersionContract, DeleteFileContract, DetachFileContract, FileDeletedEvent, FileEntity, FileEvents, FileModel, FileStatusEnum, FileUpdatedEvent, FileUploadedEvent, FileVersionCreatedEvent, FileVersionEntity, FileVersionModel, FilesFeature, GetDownloadUrlContract, GetFileContract, GetVersionsContract, InMemoryStorageAdapter, ListAttachmentsContract, ListFilesContract, LocalStorageAdapter, PresignedUrlModel, S3StorageAdapter, StorageProviderEnum, UpdateFileContract, UploadFileContract, UploadSessionCompletedEvent, UploadSessionEntity, UploadSessionStartedEvent, createStorageAdapter, fileEntities, filesSchemaContribution };
1
+ import{AttachmentAttachedEvent as e,AttachmentDetachedEvent as t,FileDeletedEvent as n,FileEvents as r,FileUpdatedEvent as i,FileUploadedEvent as a,FileVersionCreatedEvent as o,UploadSessionCompletedEvent as s,UploadSessionStartedEvent as c}from"./events.js";import{FilesFeature as l}from"./files.feature.js";import{AttachmentEntity as u,FileEntity as d,FileStatusEnum as f,FileVersionEntity as p,StorageProviderEnum as m,UploadSessionEntity as h,fileEntities as g,filesSchemaContribution as _}from"./entities/index.js";import{AttachFileContract as v,AttachmentModel as y,CreatePresignedUrlContract as b,CreateVersionContract as x,DeleteFileContract as S,DetachFileContract as C,FileModel as w,FileVersionModel as T,GetDownloadUrlContract as E,GetFileContract as D,GetVersionsContract as O,ListAttachmentsContract as k,ListFilesContract as A,PresignedUrlModel as j,UpdateFileContract as M,UploadFileContract as N}from"./contracts/index.js";import{InMemoryStorageAdapter as P,LocalStorageAdapter as F,S3StorageAdapter as I,createStorageAdapter as L}from"./storage/index.js";import"./docs/index.js";export{v as AttachFileContract,e as AttachmentAttachedEvent,t as AttachmentDetachedEvent,u as AttachmentEntity,y as AttachmentModel,b as CreatePresignedUrlContract,x as CreateVersionContract,S as DeleteFileContract,C as DetachFileContract,n as FileDeletedEvent,d as FileEntity,r as FileEvents,w as FileModel,f as FileStatusEnum,i as FileUpdatedEvent,a as FileUploadedEvent,o as FileVersionCreatedEvent,p as FileVersionEntity,T as FileVersionModel,l as FilesFeature,E as GetDownloadUrlContract,D as GetFileContract,O as GetVersionsContract,P as InMemoryStorageAdapter,k as ListAttachmentsContract,A as ListFilesContract,F as LocalStorageAdapter,j as PresignedUrlModel,I as S3StorageAdapter,m as StorageProviderEnum,M as UpdateFileContract,N as UploadFileContract,s as UploadSessionCompletedEvent,h as UploadSessionEntity,c as UploadSessionStartedEvent,L as createStorageAdapter,g as fileEntities,_ as filesSchemaContribution};
@@ -1,268 +1 @@
1
- import * as crypto from "node:crypto";
2
- import * as fs from "node:fs/promises";
3
- import * as path from "node:path";
4
-
5
- //#region src/storage/index.ts
6
- /**
7
- * Local filesystem storage adapter.
8
- * For development and testing purposes.
9
- */
10
- var LocalStorageAdapter = class {
11
- provider = "LOCAL";
12
- basePath;
13
- baseUrl;
14
- constructor(options) {
15
- this.basePath = options.basePath;
16
- this.baseUrl = options.baseUrl;
17
- }
18
- async upload(options) {
19
- const fullPath = path.join(this.basePath, options.path);
20
- const dir = path.dirname(fullPath);
21
- await fs.mkdir(dir, { recursive: true });
22
- const content = typeof options.content === "string" ? Buffer.from(options.content, "base64") : options.content;
23
- await fs.writeFile(fullPath, content);
24
- const checksum = crypto.createHash("sha256").update(content).digest("hex");
25
- return {
26
- path: options.path,
27
- size: content.length,
28
- mimeType: options.mimeType,
29
- checksum,
30
- metadata: options.metadata
31
- };
32
- }
33
- async download(filePath) {
34
- const fullPath = path.join(this.basePath, filePath);
35
- return fs.readFile(fullPath);
36
- }
37
- async delete(filePath) {
38
- const fullPath = path.join(this.basePath, filePath);
39
- await fs.unlink(fullPath);
40
- }
41
- async exists(filePath) {
42
- const fullPath = path.join(this.basePath, filePath);
43
- try {
44
- await fs.access(fullPath);
45
- return true;
46
- } catch {
47
- return false;
48
- }
49
- }
50
- async getMetadata(filePath) {
51
- const fullPath = path.join(this.basePath, filePath);
52
- try {
53
- return {
54
- path: filePath,
55
- size: (await fs.stat(fullPath)).size,
56
- mimeType: "application/octet-stream"
57
- };
58
- } catch {
59
- return null;
60
- }
61
- }
62
- async list(options) {
63
- const dir = options?.prefix ? path.join(this.basePath, options.prefix) : this.basePath;
64
- try {
65
- const entries = await fs.readdir(dir, { withFileTypes: true });
66
- const files = [];
67
- for (const entry of entries) if (entry.isFile()) {
68
- const filePath = options?.prefix ? path.join(options.prefix, entry.name) : entry.name;
69
- const stat = await fs.stat(path.join(dir, entry.name));
70
- files.push({
71
- path: filePath,
72
- size: stat.size,
73
- mimeType: "application/octet-stream"
74
- });
75
- }
76
- const limit = options?.limit || files.length;
77
- return {
78
- files: files.slice(0, limit),
79
- hasMore: files.length > limit
80
- };
81
- } catch {
82
- return {
83
- files: [],
84
- hasMore: false
85
- };
86
- }
87
- }
88
- async createPresignedUpload(options) {
89
- const expiresIn = options.expiresIn || 3600;
90
- const expiresAt = new Date(Date.now() + expiresIn * 1e3);
91
- return {
92
- url: this.baseUrl ? `${this.baseUrl}/upload?path=${encodeURIComponent(options.path)}` : `/upload?path=${encodeURIComponent(options.path)}`,
93
- fields: {
94
- path: options.path,
95
- mimeType: options.mimeType
96
- },
97
- expiresAt
98
- };
99
- }
100
- async createPresignedDownload(options) {
101
- const expiresIn = options.expiresIn || 3600;
102
- const expiresAt = new Date(Date.now() + expiresIn * 1e3);
103
- return {
104
- url: this.baseUrl ? `${this.baseUrl}/download/${options.path}` : `/download/${options.path}`,
105
- expiresAt
106
- };
107
- }
108
- getPublicUrl(filePath) {
109
- if (!this.baseUrl) return null;
110
- return `${this.baseUrl}/${filePath}`;
111
- }
112
- async copy(sourcePath, destinationPath) {
113
- const sourceFullPath = path.join(this.basePath, sourcePath);
114
- const destFullPath = path.join(this.basePath, destinationPath);
115
- const destDir = path.dirname(destFullPath);
116
- await fs.mkdir(destDir, { recursive: true });
117
- await fs.copyFile(sourceFullPath, destFullPath);
118
- return {
119
- path: destinationPath,
120
- size: (await fs.stat(destFullPath)).size,
121
- mimeType: "application/octet-stream"
122
- };
123
- }
124
- };
125
- /**
126
- * S3 storage adapter interface.
127
- * Implementation would use AWS SDK or compatible client.
128
- *
129
- * This is a placeholder that defines the interface.
130
- * Actual implementation would require @aws-sdk/client-s3 dependency.
131
- */
132
- var S3StorageAdapter = class {
133
- provider = "S3";
134
- config;
135
- constructor(options) {
136
- this.config = options;
137
- }
138
- async upload(options) {
139
- throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the upload method.");
140
- }
141
- async download(filePath) {
142
- throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the download method.");
143
- }
144
- async delete(filePath) {
145
- throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the delete method.");
146
- }
147
- async exists(filePath) {
148
- throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the exists method.");
149
- }
150
- async getMetadata(filePath) {
151
- throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the getMetadata method.");
152
- }
153
- async list(options) {
154
- throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the list method.");
155
- }
156
- async createPresignedUpload(options) {
157
- throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedUpload method.");
158
- }
159
- async createPresignedDownload(options) {
160
- throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedDownload method.");
161
- }
162
- getPublicUrl(filePath) {
163
- const { bucket, region, endpoint } = this.config;
164
- if (endpoint) return `${endpoint}/${bucket}/${filePath}`;
165
- return `https://${bucket}.s3.${region}.amazonaws.com/${filePath}`;
166
- }
167
- async copy(sourcePath, destinationPath) {
168
- throw new Error("S3 adapter requires @aws-sdk/client-s3. Install it and implement the copy method.");
169
- }
170
- };
171
- /**
172
- * In-memory storage adapter for testing.
173
- */
174
- var InMemoryStorageAdapter = class {
175
- provider = "LOCAL";
176
- files = /* @__PURE__ */ new Map();
177
- async upload(options) {
178
- const content = typeof options.content === "string" ? Buffer.from(options.content, "base64") : options.content;
179
- const checksum = crypto.createHash("sha256").update(content).digest("hex");
180
- const metadata = {
181
- path: options.path,
182
- size: content.length,
183
- mimeType: options.mimeType,
184
- checksum,
185
- metadata: options.metadata
186
- };
187
- this.files.set(options.path, {
188
- content,
189
- metadata
190
- });
191
- return metadata;
192
- }
193
- async download(filePath) {
194
- const file = this.files.get(filePath);
195
- if (!file) throw new Error(`File not found: ${filePath}`);
196
- return file.content;
197
- }
198
- async delete(filePath) {
199
- this.files.delete(filePath);
200
- }
201
- async exists(filePath) {
202
- return this.files.has(filePath);
203
- }
204
- async getMetadata(filePath) {
205
- return this.files.get(filePath)?.metadata || null;
206
- }
207
- async list(options) {
208
- const prefix = options?.prefix || "";
209
- const files = [];
210
- for (const [path$1, file] of this.files) if (path$1.startsWith(prefix)) files.push(file.metadata);
211
- const limit = options?.limit || files.length;
212
- return {
213
- files: files.slice(0, limit),
214
- hasMore: files.length > limit
215
- };
216
- }
217
- async createPresignedUpload(options) {
218
- const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1e3);
219
- return {
220
- url: `/upload?path=${encodeURIComponent(options.path)}`,
221
- fields: { path: options.path },
222
- expiresAt
223
- };
224
- }
225
- async createPresignedDownload(options) {
226
- const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1e3);
227
- return {
228
- url: `/download/${options.path}`,
229
- expiresAt
230
- };
231
- }
232
- getPublicUrl(filePath) {
233
- return `/files/${filePath}`;
234
- }
235
- async copy(sourcePath, destinationPath) {
236
- const source = this.files.get(sourcePath);
237
- if (!source) throw new Error(`Source file not found: ${sourcePath}`);
238
- const metadata = {
239
- ...source.metadata,
240
- path: destinationPath
241
- };
242
- this.files.set(destinationPath, {
243
- content: source.content,
244
- metadata
245
- });
246
- return metadata;
247
- }
248
- clear() {
249
- this.files.clear();
250
- }
251
- };
252
- /**
253
- * Create a storage adapter based on configuration.
254
- */
255
- function createStorageAdapter(config) {
256
- switch (config.provider) {
257
- case "LOCAL":
258
- if (!config.local) throw new Error("Local storage configuration required");
259
- return new LocalStorageAdapter(config.local);
260
- case "S3":
261
- if (!config.s3) throw new Error("S3 storage configuration required");
262
- return new S3StorageAdapter(config.s3);
263
- default: throw new Error(`Unsupported storage provider: ${config.provider}`);
264
- }
265
- }
266
-
267
- //#endregion
268
- export { InMemoryStorageAdapter, LocalStorageAdapter, S3StorageAdapter, createStorageAdapter };
1
+ import*as e from"node:fs/promises";import*as t from"node:path";import*as n from"node:crypto";var r=class{provider=`LOCAL`;basePath;baseUrl;constructor(e){this.basePath=e.basePath,this.baseUrl=e.baseUrl}async upload(r){let i=t.join(this.basePath,r.path),a=t.dirname(i);await e.mkdir(a,{recursive:!0});let o=typeof r.content==`string`?Buffer.from(r.content,`base64`):r.content;await e.writeFile(i,o);let s=n.createHash(`sha256`).update(o).digest(`hex`);return{path:r.path,size:o.length,mimeType:r.mimeType,checksum:s,metadata:r.metadata}}async download(n){let r=t.join(this.basePath,n);return e.readFile(r)}async delete(n){let r=t.join(this.basePath,n);await e.unlink(r)}async exists(n){let r=t.join(this.basePath,n);try{return await e.access(r),!0}catch{return!1}}async getMetadata(n){let r=t.join(this.basePath,n);try{return{path:n,size:(await e.stat(r)).size,mimeType:`application/octet-stream`}}catch{return null}}async list(n){let r=n?.prefix?t.join(this.basePath,n.prefix):this.basePath;try{let i=await e.readdir(r,{withFileTypes:!0}),a=[];for(let o of i)if(o.isFile()){let i=n?.prefix?t.join(n.prefix,o.name):o.name,s=await e.stat(t.join(r,o.name));a.push({path:i,size:s.size,mimeType:`application/octet-stream`})}let o=n?.limit||a.length;return{files:a.slice(0,o),hasMore:a.length>o}}catch{return{files:[],hasMore:!1}}}async createPresignedUpload(e){let t=e.expiresIn||3600,n=new Date(Date.now()+t*1e3);return{url:this.baseUrl?`${this.baseUrl}/upload?path=${encodeURIComponent(e.path)}`:`/upload?path=${encodeURIComponent(e.path)}`,fields:{path:e.path,mimeType:e.mimeType},expiresAt:n}}async createPresignedDownload(e){let t=e.expiresIn||3600,n=new Date(Date.now()+t*1e3);return{url:this.baseUrl?`${this.baseUrl}/download/${e.path}`:`/download/${e.path}`,expiresAt:n}}getPublicUrl(e){return this.baseUrl?`${this.baseUrl}/${e}`:null}async copy(n,r){let i=t.join(this.basePath,n),a=t.join(this.basePath,r),o=t.dirname(a);return await e.mkdir(o,{recursive:!0}),await e.copyFile(i,a),{path:r,size:(await e.stat(a)).size,mimeType:`application/octet-stream`}}},i=class{provider=`S3`;config;constructor(e){this.config=e}async upload(e){throw Error(`S3 adapter requires @aws-sdk/client-s3. Install it and implement the upload method.`)}async download(e){throw Error(`S3 adapter requires @aws-sdk/client-s3. Install it and implement the download method.`)}async delete(e){throw Error(`S3 adapter requires @aws-sdk/client-s3. Install it and implement the delete method.`)}async exists(e){throw Error(`S3 adapter requires @aws-sdk/client-s3. Install it and implement the exists method.`)}async getMetadata(e){throw Error(`S3 adapter requires @aws-sdk/client-s3. Install it and implement the getMetadata method.`)}async list(e){throw Error(`S3 adapter requires @aws-sdk/client-s3. Install it and implement the list method.`)}async createPresignedUpload(e){throw Error(`S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedUpload method.`)}async createPresignedDownload(e){throw Error(`S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedDownload method.`)}getPublicUrl(e){let{bucket:t,region:n,endpoint:r}=this.config;return r?`${r}/${t}/${e}`:`https://${t}.s3.${n}.amazonaws.com/${e}`}async copy(e,t){throw Error(`S3 adapter requires @aws-sdk/client-s3. Install it and implement the copy method.`)}},a=class{provider=`LOCAL`;files=new Map;async upload(e){let t=typeof e.content==`string`?Buffer.from(e.content,`base64`):e.content,r=n.createHash(`sha256`).update(t).digest(`hex`),i={path:e.path,size:t.length,mimeType:e.mimeType,checksum:r,metadata:e.metadata};return this.files.set(e.path,{content:t,metadata:i}),i}async download(e){let t=this.files.get(e);if(!t)throw Error(`File not found: ${e}`);return t.content}async delete(e){this.files.delete(e)}async exists(e){return this.files.has(e)}async getMetadata(e){return this.files.get(e)?.metadata||null}async list(e){let t=e?.prefix||``,n=[];for(let[e,r]of this.files)e.startsWith(t)&&n.push(r.metadata);let r=e?.limit||n.length;return{files:n.slice(0,r),hasMore:n.length>r}}async createPresignedUpload(e){let t=new Date(Date.now()+(e.expiresIn||3600)*1e3);return{url:`/upload?path=${encodeURIComponent(e.path)}`,fields:{path:e.path},expiresAt:t}}async createPresignedDownload(e){let t=new Date(Date.now()+(e.expiresIn||3600)*1e3);return{url:`/download/${e.path}`,expiresAt:t}}getPublicUrl(e){return`/files/${e}`}async copy(e,t){let n=this.files.get(e);if(!n)throw Error(`Source file not found: ${e}`);let r={...n.metadata,path:t};return this.files.set(t,{content:n.content,metadata:r}),r}clear(){this.files.clear()}};function o(e){switch(e.provider){case`LOCAL`:if(!e.local)throw Error(`Local storage configuration required`);return new r(e.local);case`S3`:if(!e.s3)throw Error(`S3 storage configuration required`);return new i(e.s3);default:throw Error(`Unsupported storage provider: ${e.provider}`)}}export{a as InMemoryStorageAdapter,r as LocalStorageAdapter,i as S3StorageAdapter,o as createStorageAdapter};
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@lssm/lib.files",
3
- "version": "0.0.0-canary-20251217083314",
3
+ "version": "1.41.0",
4
4
  "description": "Files, documents and attachments module for ContractSpec applications",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
10
- "publish:pkg:canary": "bun publish:pkg --tag canary",
11
10
  "build": "bun build:bundle && bun build:types",
12
11
  "build:bundle": "tsdown",
13
12
  "build:types": "tsc --noEmit",
@@ -18,24 +17,24 @@
18
17
  "lint:check": "eslint src"
19
18
  },
20
19
  "dependencies": {
21
- "@lssm/lib.schema": "0.0.0-canary-20251217083314",
22
- "@lssm/lib.contracts": "0.0.0-canary-20251217083314",
20
+ "@lssm/lib.schema": "workspace:*",
21
+ "@lssm/lib.contracts": "workspace:*",
23
22
  "zod": "^4.1.13"
24
23
  },
25
24
  "devDependencies": {
26
- "@lssm/tool.typescript": "0.0.0-canary-20251217083314",
27
- "@lssm/tool.tsdown": "0.0.0-canary-20251217083314",
25
+ "@lssm/tool.typescript": "workspace:*",
26
+ "@lssm/tool.tsdown": "workspace:*",
28
27
  "typescript": "^5.9.3"
29
28
  },
30
29
  "exports": {
31
- ".": "./dist/index.js",
32
- "./contracts": "./dist/contracts/index.js",
33
- "./docs": "./dist/docs/index.js",
34
- "./docs/files.docblock": "./dist/docs/files.docblock.js",
35
- "./entities": "./dist/entities/index.js",
36
- "./events": "./dist/events.js",
37
- "./files.feature": "./dist/files.feature.js",
38
- "./storage": "./dist/storage/index.js",
30
+ ".": "./src/index.ts",
31
+ "./contracts": "./src/contracts/index.ts",
32
+ "./docs": "./src/docs/index.ts",
33
+ "./docs/files.docblock": "./src/docs/files.docblock.ts",
34
+ "./entities": "./src/entities/index.ts",
35
+ "./events": "./src/events.ts",
36
+ "./files.feature": "./src/files.feature.ts",
37
+ "./storage": "./src/storage/index.ts",
39
38
  "./*": "./*"
40
39
  },
41
40
  "module": "./dist/index.js",
@@ -1,88 +0,0 @@
1
- import { StabilityEnum } from "../ownership.js";
2
-
3
- //#region ../contracts/dist/capabilities/openbanking.js
4
- const OWNERS = ["platform.finance"];
5
- const TAGS = ["open-banking", "finance"];
6
- const openBankingAccountsReadCapability = {
7
- meta: {
8
- key: "openbanking.accounts.read",
9
- version: 1,
10
- kind: "integration",
11
- title: "Open Banking Accounts (Read)",
12
- description: "Provides read-only access to linked bank accounts, including account summaries and metadata.",
13
- domain: "finance",
14
- owners: [...OWNERS],
15
- tags: [...TAGS],
16
- stability: StabilityEnum.Experimental
17
- },
18
- provides: [
19
- {
20
- surface: "operation",
21
- name: "openbanking.accounts.list",
22
- version: 1,
23
- description: "List bank accounts linked to a Powens open banking connection."
24
- },
25
- {
26
- surface: "operation",
27
- name: "openbanking.accounts.get",
28
- version: 1,
29
- description: "Retrieve the canonical bank account record for a specific account."
30
- },
31
- {
32
- surface: "operation",
33
- name: "openbanking.accounts.sync",
34
- version: 1,
35
- description: "Trigger a refresh of bank account metadata from the open banking provider."
36
- }
37
- ]
38
- };
39
- const openBankingTransactionsReadCapability = {
40
- meta: {
41
- key: "openbanking.transactions.read",
42
- version: 1,
43
- kind: "integration",
44
- title: "Open Banking Transactions (Read)",
45
- description: "Enables retrieval of transaction history for linked bank accounts via open banking providers.",
46
- domain: "finance",
47
- owners: [...OWNERS],
48
- tags: [...TAGS, "transactions"],
49
- stability: StabilityEnum.Experimental
50
- },
51
- provides: [{
52
- surface: "operation",
53
- name: "openbanking.transactions.list",
54
- version: 1,
55
- description: "List transactions for a given bank account with optional date filtering."
56
- }, {
57
- surface: "operation",
58
- name: "openbanking.transactions.sync",
59
- version: 1,
60
- description: "Synchronise transactions from the open banking provider into the canonical ledger."
61
- }]
62
- };
63
- const openBankingBalancesReadCapability = {
64
- meta: {
65
- key: "openbanking.balances.read",
66
- version: 1,
67
- kind: "integration",
68
- title: "Open Banking Balances (Read)",
69
- description: "Allows querying of current and available balances for linked bank accounts via open banking providers.",
70
- domain: "finance",
71
- owners: [...OWNERS],
72
- tags: [...TAGS, "balances"],
73
- stability: StabilityEnum.Experimental
74
- },
75
- provides: [{
76
- surface: "operation",
77
- name: "openbanking.balances.get",
78
- version: 1,
79
- description: "Retrieve the latest known balances for a specified bank account."
80
- }, {
81
- surface: "operation",
82
- name: "openbanking.balances.refresh",
83
- version: 1,
84
- description: "Force a balance refresh from the open banking provider."
85
- }]
86
- };
87
-
88
- //#endregion
@@ -1,5 +0,0 @@
1
- 'use client';
2
-
3
- import "./react/feature-render.js";
4
- import "./react/form-render.js";
5
- import "./react/index.js";
@@ -1,2 +0,0 @@
1
- import "../../presentations.v2.js";
2
- import "react";
@@ -1,4 +0,0 @@
1
- import "react";
2
- import "react-hook-form";
3
- import "@hookform/resolvers/zod";
4
- import "react/jsx-runtime";
@@ -1,4 +0,0 @@
1
- 'use client';
2
-
3
- import "./feature-render.js";
4
- import "./form-render.js";
@@ -1 +0,0 @@
1
- import { ContractRegistryFileSchema, ContractRegistryItemSchema, ContractRegistryItemTypeSchema } from "./schemas.js";
@@ -1,60 +0,0 @@
1
- import { StabilityEnum } from "../ownership.js";
2
- import z from "zod";
3
-
4
- //#region ../contracts/dist/contract-registry/schemas.js
5
- const ContractRegistryItemTypeSchema = z.enum([
6
- "contractspec:operation",
7
- "contractspec:event",
8
- "contractspec:presentation",
9
- "contractspec:form",
10
- "contractspec:feature",
11
- "contractspec:workflow",
12
- "contractspec:template",
13
- "contractspec:integration",
14
- "contractspec:data-view",
15
- "contractspec:migration",
16
- "contractspec:telemetry",
17
- "contractspec:experiment",
18
- "contractspec:app-config",
19
- "contractspec:knowledge"
20
- ]);
21
- const ContractRegistryFileSchema = z.object({
22
- path: z.string().min(1),
23
- type: z.string().min(1),
24
- content: z.string().optional()
25
- });
26
- const ContractRegistryItemSchema = z.object({
27
- name: z.string().min(1),
28
- type: ContractRegistryItemTypeSchema,
29
- version: z.number().int().nonnegative(),
30
- title: z.string().min(1),
31
- description: z.string().min(1),
32
- meta: z.object({
33
- stability: z.enum([
34
- StabilityEnum.Idea,
35
- StabilityEnum.InCreation,
36
- StabilityEnum.Experimental,
37
- StabilityEnum.Beta,
38
- StabilityEnum.Stable,
39
- StabilityEnum.Deprecated
40
- ]),
41
- owners: z.array(z.string().min(1)).default([]),
42
- tags: z.array(z.string().min(1)).default([])
43
- }),
44
- dependencies: z.array(z.string().min(1)).optional(),
45
- registryDependencies: z.array(z.string().min(1)).optional(),
46
- files: z.array(ContractRegistryFileSchema).min(1),
47
- schema: z.object({
48
- input: z.unknown().optional(),
49
- output: z.unknown().optional()
50
- }).optional()
51
- });
52
- const ContractRegistryManifestSchema = z.object({
53
- $schema: z.string().min(1).optional(),
54
- name: z.string().min(1),
55
- homepage: z.string().min(1).optional(),
56
- items: z.array(ContractRegistryItemSchema)
57
- });
58
-
59
- //#endregion
60
- export { ContractRegistryFileSchema, ContractRegistryItemSchema, ContractRegistryItemTypeSchema };
@@ -1,16 +0,0 @@
1
- import { registerDocBlocks } from "./registry.js";
2
-
3
- //#region ../contracts/dist/docs/PUBLISHING.docblock.js
4
- const PUBLISHING_DocBlocks = [{
5
- id: "docs.PUBLISHING",
6
- title: "Publishing ContractSpec Libraries",
7
- summary: "This guide describes how we release the ContractSpec libraries to npm. We use a dual-track release system: **Stable** (manual) and **Canary** (automatic).",
8
- kind: "reference",
9
- visibility: "public",
10
- route: "/docs/PUBLISHING",
11
- tags: ["PUBLISHING"],
12
- body: "# Publishing ContractSpec Libraries\n\nThis guide describes how we release the ContractSpec libraries to npm. We use a dual-track release system: **Stable** (manual) and **Canary** (automatic).\n\n## Release Tracks\n\n| Track | Branch | npm Tag | Frequency | Versioning | Use Case |\n|-------|--------|---------|-----------|------------|----------|\n| **Stable** | `release` | `latest` | Manual | SemVer (e.g., `1.7.4`) | Production, external users |\n| **Canary** | `main` | `canary` | Every Push | Snapshot (e.g., `1.7.4-canary...`) | Dev, internal testing |\n\n## Prerequisites\n\n- ✅ `NPM_TOKEN` secret is configured in GitHub (owner or automation token with _publish_ scope).\n- ✅ `GITHUB_TOKEN` (built-in) has permissions to create PRs (enabled by default in new repos).\n- ✅ For stable releases: `release` branch exists and is protected.\n\n## Canary Workflow (Automatic)\n\nEvery commit pushed to `main` triggers the `.github/workflows/publish-canary.yml` workflow.\n\n1. **Trigger**: Push to `main`.\n2. **Versioning**: Runs `changeset version --snapshot canary` to generate a temporary snapshot version.\n3. **Publish**: Packages are published to npm with the `canary` tag using `changeset publish --tag canary`.\n\n### Consuming Canary Builds\n\nTo install the latest bleeding-edge version:\n\n```bash\nnpm install @lssm/lib.contracts@canary\n# or\nbun add @lssm/lib.contracts@canary\n```\n\n## Stable Release Workflow (Manual)\n\nStable releases are managed via the `release` branch using the standard [Changesets Action](https://github.com/changesets/action).\n\n1. **Develop on `main`**: Create features and fixes.\n2. **Add Changesets**: Run `bun changeset` to document changes and impact (major/minor/patch).\n3. **Merge to `release`**: When ready to ship, open a PR from `main` to `release` or merge manually.\n4. **\"Version Packages\" PR**:\n - The GitHub Action detects new changesets and automatically creates a Pull Request titled **\"Version Packages\"**.\n - This PR contains the version bumps and updated `CHANGELOG.md` files.\n5. **Merge & Publish**:\n - Review and merge the \"Version Packages\" PR.\n - The Action runs again, detects the versions have been bumped, builds the libraries, and publishes them to npm with the `latest` tag.\n\n### Publishing Steps\n\n1. Ensure all changesets are present on `main`.\n2. Merge `main` into `release`:\n ```bash\n git checkout release\n git pull origin release\n git merge main\n git push origin release\n ```\n3. Go to GitHub Pull Requests. You will see a **\"Version Packages\"** PR created by the bot.\n4. Merge that PR.\n5. The release is now live on npm!\n\n## Manual Verification (Optional)\n\nBefore publishing a new version you can run:\n\n```bash\nbun run build:not-apps\nnpx npm-packlist --json packages/libs/contracts\n```\n\n## Rollback\n\nIf a publish fails mid-way, re-run the workflow once the issue is fixed. Already published packages are skipped automatically. Use `npm deprecate <package>@<version>` if we need to warn consumers about a broken release.\n"
13
- }];
14
- registerDocBlocks(PUBLISHING_DocBlocks);
15
-
16
- //#endregion