ocel 0.0.1-alpha.0 → 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 (271) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +2 -0
  3. package/README.md +98 -0
  4. package/dist/binding/binding.d.ts +22 -0
  5. package/dist/binding/binding.js +60 -0
  6. package/dist/binding/unprovisioned.d.ts +17 -0
  7. package/dist/binding/unprovisioned.js +25 -0
  8. package/dist/bucket/bucket-client.d.ts +4 -0
  9. package/dist/bucket/bucket-client.js +5 -0
  10. package/dist/bucket/bucket-context.d.ts +8 -0
  11. package/dist/bucket/bucket-context.js +10 -0
  12. package/dist/bucket/bucket.d.ts +60 -0
  13. package/dist/bucket/bucket.js +91 -0
  14. package/dist/bucket/client.d.ts +49 -0
  15. package/dist/bucket/client.js +95 -0
  16. package/dist/bucket/errors.d.ts +12 -0
  17. package/dist/bucket/errors.js +20 -0
  18. package/dist/bucket/express.d.ts +10 -0
  19. package/dist/bucket/express.js +24 -0
  20. package/dist/bucket/hono.d.ts +18 -0
  21. package/dist/bucket/hono.js +13 -0
  22. package/dist/bucket/index.d.ts +8 -0
  23. package/dist/bucket/index.js +6 -0
  24. package/dist/bucket/keys.d.ts +5 -0
  25. package/dist/bucket/keys.js +24 -0
  26. package/dist/bucket/metadata.d.ts +6 -0
  27. package/dist/bucket/metadata.js +6 -0
  28. package/dist/bucket/next.d.ts +15 -0
  29. package/dist/bucket/next.js +11 -0
  30. package/dist/bucket/objects.d.ts +130 -0
  31. package/dist/bucket/objects.js +350 -0
  32. package/dist/bucket/route.d.ts +13 -0
  33. package/dist/bucket/route.js +247 -0
  34. package/dist/bucket/server-only.js +5 -0
  35. package/dist/bucket/types.d.ts +63 -0
  36. package/dist/bucket/uploader.d.ts +3 -0
  37. package/dist/bucket/uploader.js +6 -0
  38. package/dist/build-env.d.ts +17 -0
  39. package/dist/build-env.js +41 -0
  40. package/dist/config.d.ts +30 -0
  41. package/dist/config.js +9 -0
  42. package/dist/declaration/callsite.d.ts +15 -0
  43. package/dist/declaration/callsite.js +43 -0
  44. package/dist/declaration/component.d.ts +4 -0
  45. package/dist/declaration/component.js +1 -0
  46. package/dist/declaration/defer.d.ts +5 -0
  47. package/dist/declaration/defer.js +9 -0
  48. package/dist/delivery/duration.d.ts +13 -0
  49. package/dist/delivery/duration.js +36 -0
  50. package/dist/delivery/lane.d.ts +4 -0
  51. package/dist/delivery/lane.js +15 -0
  52. package/dist/delivery/payload.d.ts +6 -0
  53. package/dist/delivery/payload.js +14 -0
  54. package/dist/delivery/retry.d.ts +16 -0
  55. package/dist/delivery/retry.js +10 -0
  56. package/dist/delivery/schema.d.ts +10 -0
  57. package/dist/delivery/schema.js +20 -0
  58. package/dist/dns.d.ts +11 -0
  59. package/dist/dns.js +4 -0
  60. package/dist/edge.d.ts +4 -0
  61. package/dist/edge.js +4 -0
  62. package/dist/env/access.d.ts +22 -0
  63. package/dist/env/access.js +49 -0
  64. package/dist/env/client.d.ts +5 -0
  65. package/dist/env/client.js +10 -0
  66. package/dist/env/declare.d.ts +2 -0
  67. package/dist/env/declare.js +83 -0
  68. package/dist/env/definition.d.ts +46 -0
  69. package/dist/env/definition.js +164 -0
  70. package/dist/env/deployment.d.ts +23 -0
  71. package/dist/env/deployment.js +13 -0
  72. package/dist/env/edge.d.ts +10 -0
  73. package/dist/env/edge.js +30 -0
  74. package/dist/env/errors.d.ts +9 -0
  75. package/dist/env/errors.js +9 -0
  76. package/dist/env/file.d.ts +1 -0
  77. package/dist/env/file.js +27 -0
  78. package/dist/env/index.d.ts +10 -0
  79. package/dist/env/index.js +63 -0
  80. package/dist/env/live.d.ts +3 -0
  81. package/dist/env/live.js +12 -0
  82. package/dist/env/schema.d.ts +27 -0
  83. package/dist/env/schema.js +43 -0
  84. package/dist/env/scope.d.ts +7 -0
  85. package/dist/env/scope.js +45 -0
  86. package/dist/env/standard.d.ts +10 -0
  87. package/dist/env/standard.js +21 -0
  88. package/dist/env/value.d.ts +5 -0
  89. package/dist/env/value.js +26 -0
  90. package/dist/env-source.d.ts +17 -0
  91. package/dist/env-source.js +16 -0
  92. package/dist/gen/proto/app/bucket/v1/bucket_pb.d.ts +911 -0
  93. package/dist/gen/proto/app/bucket/v1/bucket_pb.js +253 -0
  94. package/dist/gen/proto/app/realtime/v1/realtime_pb.d.ts +50 -0
  95. package/dist/gen/proto/app/realtime/v1/realtime_pb.js +23 -0
  96. package/dist/gen/proto/app/resources/v1/resources_pb.d.ts +554 -0
  97. package/dist/gen/proto/app/resources/v1/resources_pb.js +214 -0
  98. package/dist/gen/proto/app/resources/v1/variables_pb.d.ts +231 -0
  99. package/dist/gen/proto/app/resources/v1/variables_pb.js +101 -0
  100. package/dist/gen/proto/app/task/v1/task_pb.d.ts +498 -0
  101. package/dist/gen/proto/app/task/v1/task_pb.js +151 -0
  102. package/dist/gen/proto/app/topic/v1/topic_pb.d.ts +456 -0
  103. package/dist/gen/proto/app/topic/v1/topic_pb.js +125 -0
  104. package/dist/gen/proto/buf/validate/validate_pb.d.ts +4833 -0
  105. package/dist/gen/proto/buf/validate/validate_pb.js +356 -0
  106. package/dist/gen/proto/common/bindings/v1/bindings_pb.d.ts +378 -0
  107. package/dist/gen/proto/common/bindings/v1/bindings_pb.js +140 -0
  108. package/dist/generated/config.d.ts +428 -0
  109. package/dist/generated/config.js +2 -0
  110. package/dist/kv/entries.d.ts +193 -0
  111. package/dist/kv/entries.js +325 -0
  112. package/dist/kv/errors.d.ts +12 -0
  113. package/dist/kv/errors.js +14 -0
  114. package/dist/kv/index.d.ts +6 -0
  115. package/dist/kv/index.js +3 -0
  116. package/dist/kv/ioredis.d.ts +2 -0
  117. package/dist/kv/ioredis.js +20 -0
  118. package/dist/kv/kv.d.ts +84 -0
  119. package/dist/kv/kv.js +177 -0
  120. package/dist/kv/pattern.d.ts +27 -0
  121. package/dist/kv/pattern.js +73 -0
  122. package/dist/kv/ttl.d.ts +22 -0
  123. package/dist/kv/ttl.js +21 -0
  124. package/dist/postgres/index.d.ts +21 -2
  125. package/dist/postgres/index.js +73 -2
  126. package/dist/postgres/pg.d.ts +5 -4
  127. package/dist/postgres/pg.js +16 -12
  128. package/dist/providers/aws/dns.d.ts +11 -0
  129. package/dist/providers/aws/dns.js +4 -0
  130. package/dist/providers/aws/edge.d.ts +6 -0
  131. package/dist/providers/aws/edge.js +8 -0
  132. package/dist/providers/aws/index.d.ts +4 -0
  133. package/dist/providers/aws/index.js +4 -0
  134. package/dist/providers/gcp/edge.d.ts +14 -0
  135. package/dist/providers/gcp/edge.js +14 -0
  136. package/dist/providers/gcp/index.d.ts +9 -0
  137. package/dist/providers/gcp/index.js +9 -0
  138. package/dist/providers/vps/index.d.ts +4 -0
  139. package/dist/providers/vps/index.js +4 -0
  140. package/dist/realtime/client-error.d.ts +30 -0
  141. package/dist/realtime/client-error.js +17 -0
  142. package/dist/realtime/client-event-socket.d.ts +8 -0
  143. package/dist/realtime/client-event-socket.js +169 -0
  144. package/dist/realtime/client-transport.d.ts +29 -0
  145. package/dist/realtime/client-transport.js +13 -0
  146. package/dist/realtime/client.d.ts +150 -0
  147. package/dist/realtime/client.js +345 -0
  148. package/dist/realtime/express.d.ts +18 -0
  149. package/dist/realtime/express.js +83 -0
  150. package/dist/realtime/handler.d.ts +56 -0
  151. package/dist/realtime/handler.js +287 -0
  152. package/dist/realtime/hono.d.ts +19 -0
  153. package/dist/realtime/hono.js +24 -0
  154. package/dist/realtime/index.d.ts +2 -0
  155. package/dist/realtime/index.js +2 -0
  156. package/dist/realtime/next.d.ts +26 -0
  157. package/dist/realtime/next.js +16 -0
  158. package/dist/realtime/realtime.d.ts +181 -0
  159. package/dist/realtime/realtime.js +205 -0
  160. package/dist/realtime/token.d.ts +20 -0
  161. package/dist/realtime/token.js +45 -0
  162. package/dist/realtime/transport.d.ts +11 -0
  163. package/dist/realtime/transport.js +15 -0
  164. package/dist/realtime/wire.d.ts +30 -0
  165. package/dist/realtime/wire.js +104 -0
  166. package/dist/runtime/dev-server.d.ts +8 -0
  167. package/dist/runtime/dev-server.js +8 -0
  168. package/dist/runtime/rpc.d.ts +23 -0
  169. package/dist/runtime/rpc.js +24 -0
  170. package/dist/runtime/transport.d.ts +11 -0
  171. package/dist/runtime/transport.js +35 -0
  172. package/dist/task/errors.d.ts +7 -0
  173. package/dist/task/errors.js +7 -0
  174. package/dist/task/hooks.d.ts +57 -0
  175. package/dist/task/hooks.js +1 -0
  176. package/dist/task/index.d.ts +9 -0
  177. package/dist/task/index.js +4 -0
  178. package/dist/task/runs.d.ts +74 -0
  179. package/dist/task/runs.js +82 -0
  180. package/dist/task/task.d.ts +117 -0
  181. package/dist/task/task.js +109 -0
  182. package/dist/topic/dead-letters.d.ts +53 -0
  183. package/dist/topic/dead-letters.js +62 -0
  184. package/dist/topic/index.d.ts +8 -0
  185. package/dist/topic/index.js +4 -0
  186. package/dist/topic/topic.d.ts +85 -0
  187. package/dist/topic/topic.js +117 -0
  188. package/dist/version.d.ts +2 -0
  189. package/dist/version.js +2 -0
  190. package/dist/worker/context.d.ts +36 -0
  191. package/dist/worker/context.js +1 -0
  192. package/dist/worker/deliver.d.ts +13 -0
  193. package/dist/worker/deliver.js +258 -0
  194. package/dist/worker/index.d.ts +4 -0
  195. package/dist/worker/index.js +2 -0
  196. package/dist/worker/registry.d.ts +28 -0
  197. package/dist/worker/registry.js +22 -0
  198. package/dist/worker/semaphore.d.ts +7 -0
  199. package/dist/worker/semaphore.js +36 -0
  200. package/dist/worker/worker.d.ts +21 -0
  201. package/dist/worker/worker.js +32 -0
  202. package/package.json +158 -57
  203. package/bin/run.js +0 -39
  204. package/dist/blob/bucket.d.ts +0 -55
  205. package/dist/blob/bucket.js +0 -65
  206. package/dist/blob/index.d.ts +0 -8
  207. package/dist/blob/index.js +0 -13
  208. package/dist/blob/integrations/client.d.ts +0 -25
  209. package/dist/blob/integrations/client.js +0 -71
  210. package/dist/blob/integrations/hono.d.ts +0 -31
  211. package/dist/blob/integrations/hono.js +0 -11
  212. package/dist/blob/mime-types.d.ts +0 -1
  213. package/dist/blob/parse.d.ts +0 -16
  214. package/dist/blob/parse.js +0 -69
  215. package/dist/blob/s3-listener.d.ts +0 -7
  216. package/dist/blob/s3-listener.js +0 -35
  217. package/dist/blob/types.d.ts +0 -128
  218. package/dist/blob/types.js +0 -1
  219. package/dist/blob/upload-error.d.ts +0 -35
  220. package/dist/blob/upload-error.js +0 -54
  221. package/dist/blob/uploader.d.ts +0 -67
  222. package/dist/blob/uploader.js +0 -323
  223. package/dist/internal/db/index.d.ts +0 -68
  224. package/dist/internal/db/index.js +0 -73
  225. package/dist/lambda/index.d.ts +0 -2
  226. package/dist/lambda/index.js +0 -4
  227. package/dist/lambda/integrations/express.d.ts +0 -3
  228. package/dist/lambda/integrations/express.js +0 -13
  229. package/dist/lambda/integrations/hono.d.ts +0 -3
  230. package/dist/lambda/integrations/hono.js +0 -13
  231. package/dist/lambda/lambda.d.ts +0 -43
  232. package/dist/lambda/lambda.js +0 -30
  233. package/dist/utils/component.d.ts +0 -3
  234. package/dist/utils/constants.d.ts +0 -2
  235. package/dist/utils/constants.js +0 -2
  236. package/dist/utils/nanoid.d.ts +0 -1
  237. package/dist/utils/nanoid.js +0 -6
  238. package/dist/utils/rpc.d.ts +0 -11
  239. package/dist/utils/rpc.js +0 -17
  240. package/dist/utils/stack.d.ts +0 -4
  241. package/dist/utils/stack.js +0 -23
  242. package/dist/workflow/index.d.ts +0 -3
  243. package/dist/workflow/index.js +0 -4
  244. package/dist/workflow/workflow.d.ts +0 -34
  245. package/dist/workflow/workflow.js +0 -146
  246. package/src/blob/bucket.ts +0 -92
  247. package/src/blob/index.ts +0 -34
  248. package/src/blob/integrations/client.ts +0 -127
  249. package/src/blob/integrations/hono.ts +0 -16
  250. package/src/blob/mime-types.ts +0 -68
  251. package/src/blob/parse.ts +0 -93
  252. package/src/blob/s3-listener.ts +0 -48
  253. package/src/blob/types.ts +0 -142
  254. package/src/blob/upload-error.ts +0 -67
  255. package/src/blob/uploader.ts +0 -426
  256. package/src/internal/db/index.ts +0 -78
  257. package/src/lambda/index.ts +0 -8
  258. package/src/lambda/integrations/express.ts +0 -25
  259. package/src/lambda/integrations/hono.ts +0 -25
  260. package/src/lambda/lambda.ts +0 -94
  261. package/src/postgres/index.ts +0 -5
  262. package/src/postgres/pg.ts +0 -33
  263. package/src/utils/component.ts +0 -3
  264. package/src/utils/constants.ts +0 -2
  265. package/src/utils/nanoid.ts +0 -9
  266. package/src/utils/rpc.ts +0 -28
  267. package/src/utils/stack.ts +0 -26
  268. package/src/workflow/index.ts +0 -9
  269. package/src/workflow/workflow.ts +0 -235
  270. /package/dist/{blob/mime-types.js → bucket/server-only.d.ts} +0 -0
  271. /package/dist/{utils/component.js → bucket/types.js} +0 -0
package/package.json CHANGED
@@ -1,84 +1,171 @@
1
1
  {
2
2
  "name": "ocel",
3
- "version": "0.0.1-alpha.0",
3
+ "version": "0.0.1",
4
4
  "type": "module",
5
- "description": "The power of AWS with the DX of Vercel",
6
- "bin": {
7
- "ocel": "./bin/run.js"
8
- },
5
+ "description": "ocel runtime sdk — turns cloud infrastructure into function calls",
9
6
  "files": [
10
- "bin/",
11
7
  "dist/",
12
- "src/",
13
- "README.md"
8
+ "README.md",
9
+ "LICENSE",
10
+ "NOTICE"
14
11
  ],
15
12
  "exports": {
16
- "./blob": {
17
- "import": "./dist/blob/index.js",
18
- "types": "./dist/blob/index.d.ts"
13
+ "./config": {
14
+ "types": "./dist/config.d.ts",
15
+ "import": "./dist/config.js"
16
+ },
17
+ "./edge": {
18
+ "types": "./dist/edge.d.ts",
19
+ "import": "./dist/edge.js"
20
+ },
21
+ "./dns": {
22
+ "types": "./dist/dns.d.ts",
23
+ "import": "./dist/dns.js"
24
+ },
25
+ "./env-source": {
26
+ "types": "./dist/env-source.d.ts",
27
+ "import": "./dist/env-source.js"
28
+ },
29
+ "./providers/aws": {
30
+ "types": "./dist/providers/aws/index.d.ts",
31
+ "import": "./dist/providers/aws/index.js"
19
32
  },
20
- "./blob/client": {
21
- "import": "./dist/blob/integrations/client.js",
22
- "types": "./dist/blob/integrations/client.d.ts"
33
+ "./providers/aws/edge": {
34
+ "types": "./dist/providers/aws/edge.d.ts",
35
+ "import": "./dist/providers/aws/edge.js"
23
36
  },
24
- "./blob/*": {
25
- "import": "./dist/blob/integrations/*.js",
26
- "types": "./dist/blob/integrations/*.d.ts"
37
+ "./providers/aws/dns": {
38
+ "types": "./dist/providers/aws/dns.d.ts",
39
+ "import": "./dist/providers/aws/dns.js"
27
40
  },
28
- "./lambda": {
29
- "import": "./dist/lambda/index.js",
30
- "types": "./dist/lambda/index.d.ts"
41
+ "./providers/gcp": {
42
+ "types": "./dist/providers/gcp/index.d.ts",
43
+ "import": "./dist/providers/gcp/index.js"
31
44
  },
32
- "./lambda/*": {
33
- "import": "./dist/lambda/integrations/*.js",
34
- "types": "./dist/lambda/integrations/*.d.ts"
45
+ "./providers/gcp/edge": {
46
+ "types": "./dist/providers/gcp/edge.d.ts",
47
+ "import": "./dist/providers/gcp/edge.js"
35
48
  },
36
- "./workflow": {
37
- "import": "./dist/workflow/index.js",
38
- "types": "./dist/workflow/index.d.ts"
49
+ "./providers/vps": {
50
+ "types": "./dist/providers/vps/index.d.ts",
51
+ "import": "./dist/providers/vps/index.js"
52
+ },
53
+ "./env": {
54
+ "types": "./dist/env/index.d.ts",
55
+ "edge-light": "./dist/env/edge.js",
56
+ "workerd": "./dist/env/edge.js",
57
+ "worker": "./dist/env/edge.js",
58
+ "import": "./dist/env/index.js"
59
+ },
60
+ "./env/client": {
61
+ "types": "./dist/env/client.d.ts",
62
+ "import": "./dist/env/client.js"
63
+ },
64
+ "./env/schema": {
65
+ "types": "./dist/env/schema.d.ts",
66
+ "import": "./dist/env/schema.js"
39
67
  },
40
68
  "./postgres": {
41
- "import": "./dist/postgres/index.js",
42
- "types": "./dist/postgres/index.d.ts"
43
- }
69
+ "types": "./dist/postgres/index.d.ts",
70
+ "import": "./dist/postgres/index.js"
71
+ },
72
+ "./bucket": {
73
+ "types": "./dist/bucket/index.d.ts",
74
+ "import": "./dist/bucket/index.js"
75
+ },
76
+ "./bucket/next": {
77
+ "types": "./dist/bucket/next.d.ts",
78
+ "import": "./dist/bucket/next.js"
79
+ },
80
+ "./bucket/hono": {
81
+ "types": "./dist/bucket/hono.d.ts",
82
+ "import": "./dist/bucket/hono.js"
83
+ },
84
+ "./bucket/express": {
85
+ "types": "./dist/bucket/express.d.ts",
86
+ "import": "./dist/bucket/express.js"
87
+ },
88
+ "./bucket/client": {
89
+ "types": "./dist/bucket/client.d.ts",
90
+ "import": "./dist/bucket/client.js"
91
+ },
92
+ "./task": {
93
+ "types": "./dist/task/index.d.ts",
94
+ "import": "./dist/task/index.js"
95
+ },
96
+ "./topic": {
97
+ "types": "./dist/topic/index.d.ts",
98
+ "import": "./dist/topic/index.js"
99
+ },
100
+ "./worker": {
101
+ "types": "./dist/worker/index.d.ts",
102
+ "import": "./dist/worker/index.js"
103
+ },
104
+ "./kv": {
105
+ "types": "./dist/kv/index.d.ts",
106
+ "import": "./dist/kv/index.js"
107
+ },
108
+ "./realtime": {
109
+ "types": "./dist/realtime/index.d.ts",
110
+ "import": "./dist/realtime/index.js"
111
+ },
112
+ "./realtime/next": {
113
+ "types": "./dist/realtime/next.d.ts",
114
+ "import": "./dist/realtime/next.js"
115
+ },
116
+ "./realtime/express": {
117
+ "types": "./dist/realtime/express.d.ts",
118
+ "import": "./dist/realtime/express.js"
119
+ },
120
+ "./realtime/hono": {
121
+ "types": "./dist/realtime/hono.d.ts",
122
+ "import": "./dist/realtime/hono.js"
123
+ },
124
+ "./realtime/client": {
125
+ "types": "./dist/realtime/client.d.ts",
126
+ "import": "./dist/realtime/client.js"
127
+ },
128
+ "./package.json": "./package.json"
44
129
  },
45
- "scripts": {
46
- "build": "tsc",
47
- "build:listener": "bun build src/blob/s3-listener.ts --outfile=dist/blob-listener/index.js --target=node --format=cjs --minify"
130
+ "license": "Apache-2.0",
131
+ "repository": {
132
+ "type": "git",
133
+ "url": "git+https://github.com/ocelhq/ocel.git",
134
+ "directory": "packages/ocel"
48
135
  },
49
- "license": "MIT",
50
- "packageManager": "pnpm@10.18.3",
51
- "optionalDependencies": {
52
- "@ocel/linux-x64": "^0.0.1-alpha.0",
53
- "@ocel/win32-x64": "^0.0.1-alpha.0",
54
- "@ocel/darwin-arm64": "^0.0.1-alpha.0",
55
- "@ocel/darwin-x64": "^0.0.1-alpha.0"
136
+ "dependencies": {
137
+ "@bufbuild/protobuf": "^2.12.1",
138
+ "@connectrpc/connect": "^2.1.2",
139
+ "@connectrpc/connect-node": "^2.1.2",
140
+ "@standard-schema/spec": "^1.1.0",
141
+ "zod": "^4.4.3"
56
142
  },
57
143
  "devDependencies": {
58
144
  "@types/aws-lambda": "^8.10.160",
59
145
  "@types/express": "~5.0.0",
146
+ "@types/ioredis-mock": "^8.2.8",
147
+ "@types/pg": "^8.20.0",
148
+ "@types/ws": "^8.18.2",
60
149
  "express": "~5.0.0",
61
150
  "hono": "~4.11.1",
62
- "typescript": "^5.9.3"
63
- },
64
- "dependencies": {
65
- "@aws-sdk/client-dynamodb": "^3.958.0",
66
- "@aws-sdk/client-lambda": "^3.958.0",
67
- "@aws-sdk/client-s3": "^3.958.0",
68
- "@aws-sdk/client-xray": "^3.958.0",
69
- "@aws-sdk/s3-request-presigner": "^3.958.0",
70
- "@aws/durable-execution-sdk-js": "^1.0.1",
71
- "@opentelemetry/api": "^1.9.0",
72
- "@sindresorhus/slugify": "^3.0.0",
73
- "electrodb": "^3.5.0",
74
- "nanoid": "^5.1.6",
75
- "serverless-http": "^4.0.0",
76
- "zod": "^4.2.1"
151
+ "ioredis": "^5.11.1",
152
+ "ioredis-mock": "^8.13.1",
153
+ "next": "16.2.10",
154
+ "pg": "^8.22.0",
155
+ "react": "19.2.8",
156
+ "react-dom": "19.2.8",
157
+ "typescript": "^5.9.3",
158
+ "vite": "^8.1.3",
159
+ "vitest": "^4.1.9",
160
+ "ws": "^8.21.0"
77
161
  },
78
162
  "peerDependencies": {
79
- "hono": ">=4.11.1",
80
163
  "@types/express": ">=5.0.0",
81
- "express": ">=5.0.0"
164
+ "express": ">=5.0.0",
165
+ "hono": ">=4.11.1",
166
+ "ioredis": ">=5",
167
+ "next": ">=14",
168
+ "pg": "^8.22.0"
82
169
  },
83
170
  "peerDependenciesMeta": {
84
171
  "hono": {
@@ -89,10 +176,24 @@
89
176
  },
90
177
  "express": {
91
178
  "optional": true
179
+ },
180
+ "next": {
181
+ "optional": true
182
+ },
183
+ "pg": {
184
+ "optional": true
185
+ },
186
+ "ioredis": {
187
+ "optional": true
92
188
  }
93
189
  },
94
190
  "publishConfig": {
95
191
  "access": "public",
96
192
  "registry": "https://registry.npmjs.org/"
193
+ },
194
+ "scripts": {
195
+ "build": "tsc",
196
+ "test": "vitest run",
197
+ "typecheck": "tsc --noEmit -p tsconfig.typecheck.json && tsc --noEmit -p tsconfig.typetests-config.json"
97
198
  }
98
- }
199
+ }
package/bin/run.js DELETED
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { join } from "path";
4
- import { createRequire } from "node:module";
5
-
6
- const { platform, arch } = process;
7
- const require = createRequire(import.meta.url);
8
-
9
- let packageName = "";
10
-
11
- switch (platform) {
12
- case "win32":
13
- packageName = `win32-${arch}`;
14
- break;
15
- case "darwin":
16
- packageName = `darwin-${arch}`;
17
- break;
18
- case "linux":
19
- packageName = `linux-${arch}`;
20
- break;
21
- default:
22
- throw new Error(`Unsupported platform: ${platform}`);
23
- }
24
-
25
- const binaryPkg = `@ocel/${packageName}`;
26
-
27
- try {
28
- const binary = process.platform === "win32" ? "ocel.exe" : "ocel";
29
- const binaryPath = require.resolve(join(binaryPkg, "bin", binary));
30
-
31
- const { spawnSync } = require("child_process");
32
- const result = spawnSync(binaryPath, process.argv.slice(2), {
33
- stdio: "inherit",
34
- });
35
- process.exit(result.status);
36
- } catch (e) {
37
- console.error(`Failed to locate binary for ${binaryPkg}.`);
38
- process.exit(1);
39
- }
@@ -1,55 +0,0 @@
1
- import type { IncomingMessage } from "node:http";
2
- import type { HandleUploadBody, TBucketConfig, TUploaderConfig } from "./types";
3
- import type { Component } from "../utils/component";
4
- export declare class Bucket<TUploaderShape extends Record<string, TUploaderConfig<any, any>>> implements Component {
5
- readonly name: string;
6
- readonly _shape: TUploaderShape;
7
- private uploaders;
8
- constructor(name: string, args: TBucketConfig<TUploaderShape>);
9
- __id(): string;
10
- __name(): string;
11
- upload: () => Promise<void>;
12
- uploadExternal: () => Promise<void>;
13
- handleUpload: ({ body, request, }: {
14
- request: Request | IncomingMessage;
15
- body: HandleUploadBody;
16
- }) => Promise<{
17
- files: {
18
- url: string;
19
- key: string;
20
- name: string;
21
- }[];
22
- sessionId: string;
23
- } | {
24
- files: {
25
- fileKey: string;
26
- status: "PENDING" | "SUCCESS" | "FAILED";
27
- file: {
28
- path: string;
29
- contentDisposition: string;
30
- contentType: string;
31
- } | undefined;
32
- metadata: any;
33
- }[];
34
- completed: boolean;
35
- type?: undefined;
36
- response?: undefined;
37
- error?: undefined;
38
- } | {
39
- type: "UPLOAD_COMPLETED";
40
- response: "ok";
41
- files?: undefined;
42
- completed?: undefined;
43
- error?: undefined;
44
- } | {
45
- error: {
46
- message: string;
47
- code: string;
48
- status: number;
49
- };
50
- files?: undefined;
51
- completed?: undefined;
52
- type?: undefined;
53
- response?: undefined;
54
- }>;
55
- }
@@ -1,65 +0,0 @@
1
- import z from "zod";
2
- import { getCallerFile } from "../utils/stack";
3
- import { rpc } from "../utils/rpc";
4
- import { Uploader } from "./uploader";
5
- import { parseReq } from "./parse";
6
- export class Bucket {
7
- name;
8
- _shape = {};
9
- uploaders = {};
10
- constructor(name, args) {
11
- this.name = name;
12
- if (process.env.OCEL_PHASE === "discovery") {
13
- rpc.register({
14
- id: name,
15
- type: "bucket",
16
- source: getCallerFile() || "unknown",
17
- // TODO:
18
- config: {},
19
- });
20
- }
21
- this._shape = args.uploaders;
22
- Object.entries(args.uploaders).forEach(([key, config]) => {
23
- this.uploaders[key] = new Uploader(this, key, config);
24
- });
25
- }
26
- __id() {
27
- return this.name;
28
- }
29
- __name() {
30
- const id = process.env[`RESOURCE_${this.name}_BUCKET_NAME`];
31
- if (!id) {
32
- throw new Error(`Bucket ID for bucket "${this.name}" is not defined. Make sure the bucket is properly configured in your Ocel project.`);
33
- }
34
- return id;
35
- }
36
- upload = async () => { };
37
- uploadExternal = async () => { };
38
- handleUpload = async ({ body, request, }) => {
39
- const parsedReq = parseReq(request);
40
- const hasUploaders = Object.keys(this._shape).length > 0;
41
- if (!hasUploaders) {
42
- throw new Error("No uploaders configured for this bucket");
43
- }
44
- const querySchema = z.object({
45
- action: z.enum(["presign", "callback", "poll"]),
46
- uploader: z.enum(Object.keys(this._shape)),
47
- sessionId: z.string().optional(),
48
- });
49
- const queryRes = querySchema.safeParse(Object.fromEntries(parsedReq.query));
50
- if (!queryRes.success) {
51
- throw new Error(`Invalid query parameters: ${queryRes.error.message}`);
52
- }
53
- const query = queryRes.data;
54
- const uploader = this.uploaders[query.uploader];
55
- if (!uploader) {
56
- throw new Error(`Uploader not found: ${query.uploader}`);
57
- }
58
- return uploader.handleUpload({
59
- body,
60
- request,
61
- action: query.action,
62
- sessionId: query.sessionId,
63
- });
64
- };
65
- }
@@ -1,8 +0,0 @@
1
- import { type ZodType } from "zod";
2
- import type { TBucketConfig, TUploaderConfig } from "./types";
3
- import { Bucket } from "./bucket";
4
- export declare function bucket<TUploaderShape extends Record<string, TUploaderConfig<any, any>>>(name: string, args: TBucketConfig<TUploaderShape>): Bucket<TUploaderShape>;
5
- export declare function uploader<TInput extends ZodType = never, TMeta = never, TReturn = void>({ middleware, input, }: {
6
- input?: TInput;
7
- middleware: TUploaderConfig<TInput, TMeta, TReturn>["onBeforeUpload"];
8
- }, config: Omit<TUploaderConfig<TInput, TMeta, TReturn>, "onBeforeUpload" | "_def" | "input">): TUploaderConfig<TInput, TMeta, TReturn>;
@@ -1,13 +0,0 @@
1
- import {} from "zod";
2
- import { Bucket } from "./bucket";
3
- export function bucket(name, args) {
4
- return new Bucket(name, args);
5
- }
6
- export function uploader({ middleware, input, }, config) {
7
- return {
8
- ...config,
9
- input,
10
- onBeforeUpload: middleware,
11
- _def: {},
12
- };
13
- }
@@ -1,25 +0,0 @@
1
- import type z from "zod";
2
- import type { Bucket } from "../bucket";
3
- type InferReturn<TRouter, K extends keyof TRouter> = TRouter[K] extends {
4
- _def: {
5
- output: infer R;
6
- };
7
- } ? R : never;
8
- type InferInput<TRouter, K extends keyof TRouter> = TRouter[K] extends {
9
- _def: {
10
- input: infer R;
11
- };
12
- } ? R : never;
13
- export declare function createUploadClient<TBucket extends Bucket<any>>(opts: {
14
- url: string;
15
- }): {
16
- upload: <K extends keyof TBucket["_shape"]>(uploader: K, args: InferInput<TBucket["_shape"], K> extends never ? {
17
- files: File[];
18
- onClientUploadComplete?: (res: InferReturn<TBucket["_shape"], K>) => void;
19
- } : {
20
- files: File[];
21
- input: z.infer<InferInput<TBucket["_shape"], K>>;
22
- onClientUploadComplete?: (res: InferReturn<TBucket["_shape"], K>) => void;
23
- }) => Promise<void>;
24
- };
25
- export {};
@@ -1,71 +0,0 @@
1
- export function createUploadClient(opts) {
2
- return {
3
- upload: async (uploader, args) => {
4
- const url = opts.url;
5
- const searchParams = new URLSearchParams();
6
- searchParams.append("action", "presign");
7
- searchParams.append("uploader", String(uploader));
8
- // get presign urls
9
- const result = (await fetch(`${url}?${searchParams.toString()}`, {
10
- method: "POST",
11
- headers: {
12
- "Content-Type": "application/json",
13
- },
14
- body: JSON.stringify({
15
- files: args.files.map((f) => {
16
- return {
17
- name: f.name,
18
- size: f.size,
19
- type: f.type,
20
- lastModified: f.lastModified,
21
- mimeType: f.type,
22
- };
23
- }),
24
- ...("input" in args ? { input: args.input } : {}),
25
- }),
26
- }).then((r) => r.json()));
27
- // upload files to presign urls (sessionId required for S3 listener to update DynamoDB)
28
- await Promise.all(args.files.map((file, index) => {
29
- if (!result.files[index]?.url) {
30
- throw new Error(`No presign URL returned for file index ${index}`);
31
- }
32
- return fetch(result.files[index].url, {
33
- method: "PUT",
34
- headers: {
35
- "Content-Type": file.type,
36
- "Content-Disposition": "inline",
37
- },
38
- body: file,
39
- });
40
- }));
41
- // poll for completion (S3 listener Lambda updates DynamoDB when upload lands)
42
- const pollParams = new URLSearchParams();
43
- pollParams.append("action", "poll");
44
- pollParams.append("uploader", String(uploader));
45
- pollParams.append("sessionId", result.sessionId);
46
- const pollUntilComplete = async () => {
47
- const res = await fetch(`${url}?${pollParams.toString()}`, {
48
- method: "POST",
49
- headers: { "Content-Type": "application/json" },
50
- body: JSON.stringify({}),
51
- });
52
- const data = (await res.json());
53
- if (data.completed)
54
- return data;
55
- await new Promise((r) => setTimeout(r, 1000));
56
- return pollUntilComplete();
57
- };
58
- const pollResult = await pollUntilComplete();
59
- if (args.onClientUploadComplete && pollResult.files) {
60
- const completedFiles = pollResult.files.filter((f) => f.status === "SUCCESS" && f.file);
61
- const results = completedFiles.map((f) => ({
62
- file: f.file,
63
- metadata: f.metadata ?? {},
64
- }));
65
- if (results.length > 0) {
66
- args.onClientUploadComplete(results.length === 1 ? results[0] : results);
67
- }
68
- }
69
- },
70
- };
71
- }
@@ -1,31 +0,0 @@
1
- import type { Context } from "hono";
2
- import type { Bucket } from "../bucket";
3
- export declare function createRouteHandler(bucket: Bucket<any>): (c: Context) => Promise<Response & import("hono").TypedResponse<{
4
- files: {
5
- url: string;
6
- key: string;
7
- name: string;
8
- }[];
9
- sessionId: string;
10
- } | {
11
- files: {
12
- fileKey: string;
13
- status: "PENDING" | "SUCCESS" | "FAILED";
14
- file: {
15
- path: string;
16
- contentDisposition: string;
17
- contentType: string;
18
- } | undefined;
19
- metadata: any;
20
- }[];
21
- completed: boolean;
22
- } | {
23
- type: "UPLOAD_COMPLETED";
24
- response: "ok";
25
- } | {
26
- error: {
27
- message: string;
28
- code: string;
29
- status: number;
30
- };
31
- }, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
@@ -1,11 +0,0 @@
1
- export function createRouteHandler(bucket) {
2
- return async (c) => {
3
- const req = c.req.raw;
4
- const body = (await req.json());
5
- const result = await bucket.handleUpload({
6
- body,
7
- request: req,
8
- });
9
- return c.json(result);
10
- };
11
- }
@@ -1 +0,0 @@
1
- export type KnownMimeType = "application/json" | "application/xml" | "application/octet-stream" | "application/zip" | "application/gzip" | "application/x-tar" | "application/wasm" | "application/x-7z-compressed" | "application/x-sh" | "application/*" | "text/plain" | "text/csv" | "text/html" | "text/css" | "text/javascript" | "application/javascript" | "application/typescript" | "application/pdf" | "application/rtf" | "text/*" | "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/svg+xml" | "image/bmp" | "image/tiff" | "image/avif" | "image/vnd.microsoft.icon" | "image/*" | "audio/mpeg" | "audio/wav" | "audio/ogg" | "audio/aac" | "audio/flac" | "audio/*" | "video/mp4" | "video/webm" | "video/ogg" | "video/quicktime" | "video/x-msvideo" | "video/*" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.oasis.opendocument.text" | "application/vnd.oasis.opendocument.spreadsheet" | "font/otf" | "font/ttf" | "font/woff" | "font/woff2";
@@ -1,16 +0,0 @@
1
- import type { IncomingMessage } from "node:http";
2
- import type { FileSize } from "./types";
3
- export declare function parseReq(req: Request | IncomingMessage): {
4
- headers: Record<string, string>;
5
- method: string;
6
- url: string;
7
- path: string;
8
- query: URLSearchParams;
9
- };
10
- /**
11
- * Converts a human-readable file size string (e.g., "10MB", "2.5GB") into bytes.
12
- * Throws an error for invalid input formats.
13
- * * @param size The file size represented as a number (bytes) or a string with units (KB, MB, GB, B).
14
- * @returns The size in bytes (number).
15
- */
16
- export declare function parseFileSize(size: FileSize): number;