@junobuild/functions 0.0.12 → 0.0.13

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.
@@ -1,12 +1,9 @@
1
1
  import * as z from 'zod';
2
+ import { type DelDoc, type Doc, type SetDoc } from '../../../schemas/db';
2
3
  /**
3
4
  * @see DocUpsert
4
5
  */
5
6
  export declare const DocUpsertSchema: z.ZodObject<{
6
- /**
7
- * The previous version of the document before the update.
8
- * Undefined if this is a new document.
9
- */
10
7
  before: z.ZodOptional<z.ZodObject<{
11
8
  owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
12
9
  data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
@@ -29,9 +26,6 @@ export declare const DocUpsertSchema: z.ZodObject<{
29
26
  description?: string | undefined;
30
27
  version?: bigint | undefined;
31
28
  }>>;
32
- /**
33
- * The new version of the document after the update.
34
- */
35
29
  after: z.ZodObject<{
36
30
  owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
37
31
  data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
@@ -94,45 +88,21 @@ export declare const DocUpsertSchema: z.ZodObject<{
94
88
  *
95
89
  * This is used in hooks where a document is either being created or updated.
96
90
  */
97
- export type DocUpsert = z.infer<typeof DocUpsertSchema>;
98
- /**
99
- * @see ProposedDoc
100
- */
101
- export declare const ProposedDocSchema: z.ZodObject<{
102
- /**
103
- * The raw data of the document.
104
- */
105
- data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
91
+ export interface DocUpsert {
106
92
  /**
107
- * An optional description of the document.
93
+ * The previous version of the document before the update.
94
+ * Undefined if this is a new document.
108
95
  */
109
- description: z.ZodOptional<z.ZodString>;
96
+ before?: Doc;
110
97
  /**
111
- * The expected version number to ensure consistency.
98
+ * The new version of the document after the update.
112
99
  */
113
- version: z.ZodOptional<z.ZodBigInt>;
114
- }, "strict", z.ZodTypeAny, {
115
- data: Uint8Array<ArrayBufferLike>;
116
- description?: string | undefined;
117
- version?: bigint | undefined;
118
- }, {
119
- data: Uint8Array<ArrayBufferLike>;
120
- description?: string | undefined;
121
- version?: bigint | undefined;
122
- }>;
123
- /**
124
- * Represents the proposed version of a document.
125
- * This can be validated before allowing the operation.
126
- */
127
- export type ProposedDoc = z.infer<typeof ProposedDocSchema>;
100
+ after: Doc;
101
+ }
128
102
  /**
129
103
  * @see DocAssertSet
130
104
  */
131
105
  export declare const DocAssertSetSchema: z.ZodObject<{
132
- /**
133
- * The current version of the document before the operation.
134
- * Undefined if this is a new document.
135
- */
136
106
  current: z.ZodOptional<z.ZodObject<{
137
107
  owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
138
108
  data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
@@ -155,22 +125,9 @@ export declare const DocAssertSetSchema: z.ZodObject<{
155
125
  description?: string | undefined;
156
126
  version?: bigint | undefined;
157
127
  }>>;
158
- /**
159
- * The proposed version of the document.
160
- * This can be validated before allowing the operation.
161
- */
162
128
  proposed: z.ZodObject<{
163
- /**
164
- * The raw data of the document.
165
- */
166
129
  data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
167
- /**
168
- * An optional description of the document.
169
- */
170
130
  description: z.ZodOptional<z.ZodString>;
171
- /**
172
- * The expected version number to ensure consistency.
173
- */
174
131
  version: z.ZodOptional<z.ZodBigInt>;
175
132
  }, "strict", z.ZodTypeAny, {
176
133
  data: Uint8Array<ArrayBufferLike>;
@@ -216,4 +173,91 @@ export declare const DocAssertSetSchema: z.ZodObject<{
216
173
  * The developer can compare the `current` and `proposed` versions and
217
174
  * throw an error if their validation fails.
218
175
  */
219
- export type DocAssertSet = z.infer<typeof DocAssertSetSchema>;
176
+ export interface DocAssertSet {
177
+ /**
178
+ * The current version of the document before the operation.
179
+ * Undefined if this is a new document.
180
+ */
181
+ current?: Doc;
182
+ /**
183
+ * The proposed version of the document.
184
+ * This can be validated before allowing the operation.
185
+ */
186
+ proposed: SetDoc;
187
+ }
188
+ /**
189
+ * @see DocAssertDelete
190
+ */
191
+ export declare const DocAssertDeleteSchema: z.ZodObject<{
192
+ current: z.ZodOptional<z.ZodObject<{
193
+ owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
194
+ data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
195
+ description: z.ZodOptional<z.ZodString>;
196
+ created_at: z.ZodBigInt;
197
+ updated_at: z.ZodBigInt;
198
+ version: z.ZodOptional<z.ZodBigInt>;
199
+ }, "strict", z.ZodTypeAny, {
200
+ owner: Uint8Array<ArrayBufferLike>;
201
+ data: Uint8Array<ArrayBufferLike>;
202
+ created_at: bigint;
203
+ updated_at: bigint;
204
+ description?: string | undefined;
205
+ version?: bigint | undefined;
206
+ }, {
207
+ owner: Uint8Array<ArrayBufferLike>;
208
+ data: Uint8Array<ArrayBufferLike>;
209
+ created_at: bigint;
210
+ updated_at: bigint;
211
+ description?: string | undefined;
212
+ version?: bigint | undefined;
213
+ }>>;
214
+ proposed: z.ZodObject<{
215
+ version: z.ZodOptional<z.ZodBigInt>;
216
+ }, "strict", z.ZodTypeAny, {
217
+ version?: bigint | undefined;
218
+ }, {
219
+ version?: bigint | undefined;
220
+ }>;
221
+ }, "strict", z.ZodTypeAny, {
222
+ proposed: {
223
+ version?: bigint | undefined;
224
+ };
225
+ current?: {
226
+ owner: Uint8Array<ArrayBufferLike>;
227
+ data: Uint8Array<ArrayBufferLike>;
228
+ created_at: bigint;
229
+ updated_at: bigint;
230
+ description?: string | undefined;
231
+ version?: bigint | undefined;
232
+ } | undefined;
233
+ }, {
234
+ proposed: {
235
+ version?: bigint | undefined;
236
+ };
237
+ current?: {
238
+ owner: Uint8Array<ArrayBufferLike>;
239
+ data: Uint8Array<ArrayBufferLike>;
240
+ created_at: bigint;
241
+ updated_at: bigint;
242
+ description?: string | undefined;
243
+ version?: bigint | undefined;
244
+ } | undefined;
245
+ }>;
246
+ /**
247
+ * Represents a validation check before deleting a document.
248
+ *
249
+ * The developer can compare the `current` and `proposed` versions and
250
+ * throw an error if their validation fails.
251
+ */
252
+ export interface DocAssertDelete {
253
+ /**
254
+ * The current version of the document before the operation.
255
+ * Undefined if the document does not exist.
256
+ */
257
+ current?: Doc;
258
+ /**
259
+ * The proposed version of the document.
260
+ * This can be validated before allowing the operation.
261
+ */
262
+ proposed: DelDoc;
263
+ }