ocel 0.0.1-alpha.1 → 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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ Ocel
2
+ Copyright 2026 The Ocel Authors
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # ocel
2
+
3
+ Platform as a Framework. `ocel` is the **runtime SDK** your app imports and the types your
4
+ config is written against. Declaring a resource in app code — `postgres("main")` — *is* the
5
+ provisioning step.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install ocel
11
+ ```
12
+
13
+ It belongs in `dependencies`, not `devDependencies`: the SDK subpaths are imported by your
14
+ running app.
15
+
16
+ ## CLI
17
+
18
+ The `ocel` command is a separate install:
19
+
20
+ ```sh
21
+ npm install -g @ocel/cli
22
+ curl -fsSL https://ocel.dev/install.sh | sh
23
+ brew install --cask ocelhq/tap/ocel
24
+ ```
25
+
26
+ ## SDK
27
+
28
+ Every entry point is a subpath — there is no root export.
29
+
30
+ | Import | Contents |
31
+ | --- | --- |
32
+ | `ocel/config` | `defineConfig`, and the `OcelConfig` / `AppConfig` / `DomainConfig` / `ProviderDescriptor` types |
33
+ | `ocel/postgres` | `postgres(id, config?)` — declares a Postgres database and returns a connected client |
34
+ | `ocel/bucket` | `bucket(name, options?)` — declares a bucket and returns the handle its objects are read and written through, plus `uploader`, `createRouteHandler` and `resolveBucketContext`, framework-agnostic |
35
+ | `ocel/bucket/next` | `bucket`, `uploader`, `createRouteHandler` returning Next route handlers |
36
+ | `ocel/bucket/hono` | `bucket`, `uploader`, `createRouteHandler` returning a Hono handler |
37
+ | `ocel/bucket/express` | `bucket`, `uploader`, `createRouteHandler` returning Express middleware |
38
+ | `ocel/bucket/client` | `createUploadClient` — browser-side uploads against a bucket's uploaders |
39
+ | `ocel/task` | `task(name, options)` — declares a task and returns the handle its runs are triggered through, plus `runs` and `AbortTaskRunError` |
40
+ | `ocel/topic` | `topic(name, options?)` — declares a topic and returns the handle messages are sent through and consumers are declared on |
41
+ | `ocel/kv` | `kv(name, options?)` — declares a key-value store and returns its typed entries as members, beside its ioredis `client` and `connectionString`; `kv.text`, `kv.counter`, `kv.json`, `kv.list` and `kv.set` declare the entries |
42
+ | `ocel/worker` | `worker(name, options?)` — declares the worker tasks and consumers run on, plus `deliver`, which the generated worker entry calls |
43
+
44
+ `next`, `hono`, `express`, `pg` and `ioredis` are optional peer dependencies; install only the one
45
+ your app uses.
46
+
47
+ `ocel init` writes `ocel.json`, which needs none of this package. `ocel/config` is for a
48
+ project that would rather write the same document as a program — `ocel init --provider aws
49
+ --ts` writes one:
50
+
51
+ ```ts
52
+ // ocel.config.ts
53
+ import { defineConfig } from "ocel/config";
54
+ import awsProvider from "ocel/providers/aws";
55
+
56
+ export default defineConfig({
57
+ slug: "my-app",
58
+ provider: awsProvider(),
59
+ });
60
+ ```
61
+
62
+ Point any command at a different config with `--config <path>` (or `OCEL_CONFIG`).
63
+
64
+ ```ts
65
+ // ocel/index.ts
66
+ import { bucket, uploader } from "ocel/bucket/next";
67
+ import { postgres } from "ocel/postgres";
68
+
69
+ export const db = postgres("main");
70
+
71
+ export const uploads = bucket("uploads", {
72
+ uploaders: {
73
+ // The first argument authorizes the upload and returns the metadata the
74
+ // rest of the uploader — paths, limits, onUploadComplete — receives.
75
+ avatar: uploader(
76
+ { middleware: ({ req }) => ({ userId: req.headers.get("x-user-id") }) },
77
+ { accept: ["image/*"], limits: { maxFileCount: 1 } },
78
+ ),
79
+ },
80
+ });
81
+ ```
82
+
83
+ The handle `bucket()` returns is how the app reaches its objects: `put`, `get`, `head`,
84
+ `delete`, `copy`, `list`, `signedUrl` and `signedUpload`, plus `publicUrl` on a bucket
85
+ declared `public: true`. A `put` over 16 MB is uploaded in parts without being asked to.
86
+
87
+ ```ts
88
+ await uploads.put("reports/q3.pdf", bytes, { contentType: "application/pdf" });
89
+
90
+ const report = await uploads.get("reports/q3.pdf");
91
+ if (report) console.log(report.info.etag, await report.bytes());
92
+
93
+ for await (const object of uploads.list({ prefix: "reports/" })) console.log(object.key);
94
+ ```
95
+
96
+ Resource declarations resolve through `ocel dev`, so importing them outside a `dev`/`run`
97
+ session (or a deployed environment) throws unless the resource's environment variable is
98
+ set.
@@ -0,0 +1,22 @@
1
+ import { type Binding, BindingType } from "../gen/proto/common/bindings/v1/bindings_pb.js";
2
+ /** The binding types an app resolves; a custom record is read by transforms alone. */
3
+ export type BindingCase = Exclude<NonNullable<Binding["properties"]["case"]>, "custom">;
4
+ /** The properties a binding of the given type carries. */
5
+ export type BindingProperties<TCase extends BindingCase> = Extract<Binding["properties"], {
6
+ case: TCase;
7
+ }>["value"];
8
+ /** The type a binding's properties case declares; UNSPECIFIED when it has none. */
9
+ export declare function bindingTypeOf(binding: Binding): BindingType;
10
+ /** The env key a binding of the given type is delivered under. */
11
+ export declare function bindingKey(name: string, type: BindingType): string;
12
+ /**
13
+ * Reads the binding delivered for a resource and hands back its typed
14
+ * properties. Throws when nothing was delivered, when the payload is not a
15
+ * binding record, or when the record is of another type than the one asked for.
16
+ */
17
+ export declare function getConfig<TCase extends BindingCase>(name: string, kind: TCase): BindingProperties<TCase>;
18
+ /**
19
+ * The error for a resource whose binding of the given type was not delivered,
20
+ * is not a binding record, or is of another type; undefined when it was delivered.
21
+ */
22
+ export declare function refuseUnbound(name: string, kind: BindingCase): Error | undefined;
@@ -0,0 +1,60 @@
1
+ import { fromJson } from "@bufbuild/protobuf";
2
+ import { readLiveFile } from "../env/file.js";
3
+ import { readLive } from "../env/live.js";
4
+ import { BindingSchema, BindingType, } from "../gen/proto/common/bindings/v1/bindings_pb.js";
5
+ const typeOfCase = {
6
+ postgres: BindingType.POSTGRES,
7
+ bucket: BindingType.BUCKET,
8
+ custom: BindingType.CUSTOM,
9
+ topic: BindingType.TOPIC,
10
+ task: BindingType.TASK,
11
+ kv: BindingType.KV,
12
+ realtime: BindingType.REALTIME,
13
+ };
14
+ /** The type a binding's properties case declares; UNSPECIFIED when it has none. */
15
+ export function bindingTypeOf(binding) {
16
+ return binding.properties.case ? typeOfCase[binding.properties.case] : BindingType.UNSPECIFIED;
17
+ }
18
+ /** The env key a binding of the given type is delivered under. */
19
+ export function bindingKey(name, type) {
20
+ return `OCEL_RESOURCE_${BindingType[type]}_${name}`;
21
+ }
22
+ /**
23
+ * Reads the binding delivered for a resource and hands back its typed
24
+ * properties. Throws when nothing was delivered, when the payload is not a
25
+ * binding record, or when the record is of another type than the one asked for.
26
+ */
27
+ export function getConfig(name, kind) {
28
+ const found = findBinding(name, kind);
29
+ if (found instanceof Error) {
30
+ throw found;
31
+ }
32
+ return found.properties.value;
33
+ }
34
+ /**
35
+ * The error for a resource whose binding of the given type was not delivered,
36
+ * is not a binding record, or is of another type; undefined when it was delivered.
37
+ */
38
+ export function refuseUnbound(name, kind) {
39
+ const found = findBinding(name, kind);
40
+ return found instanceof Error ? found : undefined;
41
+ }
42
+ function findBinding(name, kind) {
43
+ const type = typeOfCase[kind];
44
+ const key = bindingKey(name, type);
45
+ const raw = readLive(key) ?? readLiveFile(key) ?? process.env[key];
46
+ if (!raw) {
47
+ return new Error(`Value for ${key} is not defined. Run \`ocel dev\` to resolve it locally, or \`ocel deploy\` to have it delivered from the resource this app binds.`);
48
+ }
49
+ let binding;
50
+ try {
51
+ binding = fromJson(BindingSchema, JSON.parse(raw));
52
+ }
53
+ catch (cause) {
54
+ return new Error(`${key} does not contain a binding record, so this app cannot read it as a ${BindingType[type]}`, { cause });
55
+ }
56
+ if (binding.properties.case !== kind) {
57
+ return new Error(`${key} contains a ${BindingType[bindingTypeOf(binding)]} binding, and this app reads it as a ${BindingType[type]}`);
58
+ }
59
+ return binding;
60
+ }
@@ -0,0 +1,17 @@
1
+ /** The phase in which app code runs before any resource is provisioned. */
2
+ export type UnprovisionedPhase = "discovery";
3
+ /**
4
+ * Thrown when app code reaches for a resource this run never provisioned, which
5
+ * is discovery: the pass that reads the declarations before anything is
6
+ * provisioned. Catch it to keep a boot path alive when the resource is optional there; anything else
7
+ * thrown from the same call means the resource exists and is genuinely broken.
8
+ */
9
+ export declare class UnprovisionedResourceError extends Error {
10
+ name: string;
11
+ }
12
+ /** The phase this process runs in when no resource has been provisioned yet; undefined once resources are. */
13
+ export declare function unprovisionedPhase(): UnprovisionedPhase | undefined;
14
+ /** The error app code gets for touching `access` on the resource `what` during discovery. */
15
+ export declare function unprovisioned(what: string, access: string): UnprovisionedResourceError;
16
+ /** A stand-in for the resource `what` that throws {@link UnprovisionedResourceError} on any property access. */
17
+ export declare function unprovisionedProxy<T extends object>(what: string): T;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Thrown when app code reaches for a resource this run never provisioned, which
3
+ * is discovery: the pass that reads the declarations before anything is
4
+ * provisioned. Catch it to keep a boot path alive when the resource is optional there; anything else
5
+ * thrown from the same call means the resource exists and is genuinely broken.
6
+ */
7
+ export class UnprovisionedResourceError extends Error {
8
+ name = "UnprovisionedResourceError";
9
+ }
10
+ /** The phase this process runs in when no resource has been provisioned yet; undefined once resources are. */
11
+ export function unprovisionedPhase() {
12
+ return process.env.OCEL_PHASE === "discovery" ? "discovery" : undefined;
13
+ }
14
+ /** The error app code gets for touching `access` on the resource `what` during discovery. */
15
+ export function unprovisioned(what, access) {
16
+ return new UnprovisionedResourceError(`'${what}' cannot be used during discovery: tried to access '${access}' before the resource was provisioned`);
17
+ }
18
+ /** A stand-in for the resource `what` that throws {@link UnprovisionedResourceError} on any property access. */
19
+ export function unprovisionedProxy(what) {
20
+ return new Proxy({}, {
21
+ get(_target, prop) {
22
+ throw unprovisioned(what, String(prop));
23
+ },
24
+ });
25
+ }
@@ -0,0 +1,4 @@
1
+ import { type Client, type Transport } from "@connectrpc/connect";
2
+ import { BucketService } from "../gen/proto/app/bucket/v1/bucket_pb.js";
3
+ export type BucketServiceClient = Client<typeof BucketService>;
4
+ export declare function createBucketClient(transport: Transport): BucketServiceClient;
@@ -0,0 +1,5 @@
1
+ import { createClient } from "@connectrpc/connect";
2
+ import { BucketService } from "../gen/proto/app/bucket/v1/bucket_pb.js";
3
+ export function createBucketClient(transport) {
4
+ return createClient(BucketService, transport);
5
+ }
@@ -0,0 +1,8 @@
1
+ import type { Bucket } from "./bucket.js";
2
+ import { type BucketServiceClient } from "./bucket-client.js";
3
+ export interface BucketContext {
4
+ client: BucketServiceClient;
5
+ bucket: string;
6
+ publicBaseUrl: string;
7
+ }
8
+ export declare function resolveBucketContext(bucket: Bucket): BucketContext;
@@ -0,0 +1,10 @@
1
+ import { createRuntimeTransport } from "../runtime/transport.js";
2
+ import { createBucketClient } from "./bucket-client.js";
3
+ export function resolveBucketContext(bucket) {
4
+ const { bucket: storeBucket, publicBaseUrl } = bucket.__config();
5
+ return {
6
+ client: createBucketClient(createRuntimeTransport()),
7
+ bucket: storeBucket,
8
+ publicBaseUrl,
9
+ };
10
+ }
@@ -0,0 +1,60 @@
1
+ import type { BucketProperties } from "../gen/proto/common/bindings/v1/bindings_pb.js";
2
+ import { type GetOptions, type ListOptions, type ObjectBody, type ObjectInfo, type ObjectListing, type PutBody, type PutOptions, type SignedUpload, type SignedUploadOptions, type SignedUrlOptions } from "./objects.js";
3
+ import type { AnyUploader } from "./types.js";
4
+ /** How a bucket is declared. */
5
+ export interface BucketOptions<TUploaders extends Record<string, AnyUploader>, TPublic extends boolean> {
6
+ /** Serves every object anonymously over HTTP. */
7
+ public?: TPublic;
8
+ /** Browser origins allowed to upload straight to the store. */
9
+ allowedOrigins?: string[];
10
+ /** The named browser-upload flows this bucket accepts. */
11
+ uploaders?: TUploaders;
12
+ }
13
+ /** The binding fields a bucket resolves at runtime. */
14
+ export type ResolvedBucketConfig = Pick<BucketProperties, "bucket" | "publicBaseUrl">;
15
+ /** A declared bucket, and the handle an app reads and writes its objects through. */
16
+ export declare class Bucket<TUploaders extends Record<string, AnyUploader> = Record<string, AnyUploader>, TPublic extends boolean = boolean> {
17
+ /** The name this bucket was declared under. */
18
+ name: string;
19
+ /** The browser-upload flows this bucket accepts. */
20
+ uploaders: TUploaders;
21
+ /** The browser origins allowed to upload straight to the store. */
22
+ allowedOrigins: string[];
23
+ /** Whether every object is served anonymously over HTTP. */
24
+ isPublic: boolean;
25
+ private type;
26
+ private context;
27
+ private objects;
28
+ constructor(
29
+ /** The name this bucket was declared under. */
30
+ name: string,
31
+ /** The browser-upload flows this bucket accepts. */
32
+ uploaders: TUploaders,
33
+ /** The browser origins allowed to upload straight to the store. */
34
+ allowedOrigins: string[],
35
+ /** Whether every object is served anonymously over HTTP. */
36
+ isPublic: boolean);
37
+ private runtime;
38
+ /** The binding delivered for this bucket. */
39
+ __config(): ResolvedBucketConfig;
40
+ /** Writes `body` under `key`, in one request or in parts, and returns the stored object. */
41
+ put(key: string, body: PutBody, options?: PutOptions): Promise<ObjectInfo>;
42
+ /** Reads the object under `key`, or `null` when the bucket has none. */
43
+ get(key: string, options?: GetOptions): Promise<ObjectBody | null>;
44
+ /** What the bucket knows about `key`, or `null` when it has none. */
45
+ head(key: string): Promise<ObjectInfo | null>;
46
+ /** Removes one key or many; a key that is not there is not an error. */
47
+ delete(key: string | string[]): Promise<void>;
48
+ /** The objects under a prefix, walked as an async iterable or one page at a time. */
49
+ list(options?: ListOptions): ObjectListing;
50
+ /** Copies `source` to `destination` within the bucket. */
51
+ copy(source: string, destination: string): Promise<ObjectInfo>;
52
+ /** A url that reads `key` without a credential, for as long as it is valid. */
53
+ signedUrl(key: string, options?: SignedUrlOptions): Promise<string>;
54
+ /** A target that writes `key` without a credential, for as long as it is valid. */
55
+ signedUpload(key: string, options?: SignedUploadOptions): Promise<SignedUpload>;
56
+ /** The object's address on a bucket declared `public: true`. */
57
+ publicUrl: TPublic extends true ? (key: string) => string : never;
58
+ }
59
+ /** Declares a bucket, and hands back the handle its objects are reached through. */
60
+ export declare function bucket<TUploaders extends Record<string, AnyUploader> = Record<string, never>, TPublic extends boolean = false>(name: string, options?: BucketOptions<TUploaders, TPublic>): Bucket<TUploaders, TPublic>;
@@ -0,0 +1,91 @@
1
+ import { getConfig } from "../binding/binding.js";
2
+ import { unprovisioned, unprovisionedPhase } from "../binding/unprovisioned.js";
3
+ import { declarationSite } from "../declaration/callsite.js";
4
+ import { defer } from "../declaration/defer.js";
5
+ import { ResourceType } from "../gen/proto/app/resources/v1/resources_pb.js";
6
+ import { rpc } from "../runtime/rpc.js";
7
+ import { resolveBucketContext } from "./bucket-context.js";
8
+ import { createObjects, } from "./objects.js";
9
+ /** A declared bucket, and the handle an app reads and writes its objects through. */
10
+ export class Bucket {
11
+ name;
12
+ uploaders;
13
+ allowedOrigins;
14
+ isPublic;
15
+ type = ResourceType.BUCKET;
16
+ context;
17
+ objects;
18
+ constructor(
19
+ /** The name this bucket was declared under. */
20
+ name,
21
+ /** The browser-upload flows this bucket accepts. */
22
+ uploaders,
23
+ /** The browser origins allowed to upload straight to the store. */
24
+ allowedOrigins,
25
+ /** Whether every object is served anonymously over HTTP. */
26
+ isPublic) {
27
+ this.name = name;
28
+ this.uploaders = uploaders;
29
+ this.allowedOrigins = allowedOrigins;
30
+ this.isPublic = isPublic;
31
+ this.objects = createObjects({ runtime: () => this.runtime() });
32
+ if (process.env.OCEL_PHASE === "discovery") {
33
+ defer(rpc.resource.declare({
34
+ resource: { name, type: this.type },
35
+ config: {
36
+ case: "bucket",
37
+ value: { allowedOrigins, public: isPublic },
38
+ },
39
+ source: declarationSite(),
40
+ }));
41
+ }
42
+ }
43
+ runtime() {
44
+ return (this.context ??= resolveBucketContext(this));
45
+ }
46
+ /** The binding delivered for this bucket. */
47
+ __config() {
48
+ if (unprovisionedPhase()) {
49
+ throw unprovisioned(`bucket("${this.name}")`, "__config");
50
+ }
51
+ return getConfig(this.name, "bucket");
52
+ }
53
+ /** Writes `body` under `key`, in one request or in parts, and returns the stored object. */
54
+ put(key, body, options) {
55
+ return this.objects.put(key, body, options);
56
+ }
57
+ /** Reads the object under `key`, or `null` when the bucket has none. */
58
+ get(key, options) {
59
+ return this.objects.get(key, options);
60
+ }
61
+ /** What the bucket knows about `key`, or `null` when it has none. */
62
+ head(key) {
63
+ return this.objects.head(key);
64
+ }
65
+ /** Removes one key or many; a key that is not there is not an error. */
66
+ delete(key) {
67
+ return this.objects.delete(key);
68
+ }
69
+ /** The objects under a prefix, walked as an async iterable or one page at a time. */
70
+ list(options) {
71
+ return this.objects.list(options);
72
+ }
73
+ /** Copies `source` to `destination` within the bucket. */
74
+ copy(source, destination) {
75
+ return this.objects.copy(source, destination);
76
+ }
77
+ /** A url that reads `key` without a credential, for as long as it is valid. */
78
+ signedUrl(key, options) {
79
+ return this.objects.signedUrl(key, options);
80
+ }
81
+ /** A target that writes `key` without a credential, for as long as it is valid. */
82
+ signedUpload(key, options) {
83
+ return this.objects.signedUpload(key, options);
84
+ }
85
+ /** The object's address on a bucket declared `public: true`. */
86
+ publicUrl = ((key) => this.objects.publicUrl(key));
87
+ }
88
+ /** Declares a bucket, and hands back the handle its objects are reached through. */
89
+ export function bucket(name, options = {}) {
90
+ return new Bucket(name, options.uploaders ?? {}, options.allowedOrigins ?? [], options.public ?? false);
91
+ }