@meetploy/types 1.13.0 → 1.14.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.
package/dist/db.d.ts CHANGED
@@ -2,12 +2,23 @@ export interface DBResultMeta {
2
2
  duration: number;
3
3
  rows_read: number;
4
4
  rows_written: number;
5
+ changes?: number;
6
+ last_row_id?: number | bigint;
7
+ changed_db?: boolean;
8
+ size_after?: number;
9
+ served_by?: string;
5
10
  }
6
11
  export interface DBResult<T = unknown> {
7
12
  results: T[];
8
13
  success: boolean;
9
14
  meta: DBResultMeta;
10
15
  }
16
+ export interface D1ExecResult {
17
+ count: number;
18
+ duration: number;
19
+ }
20
+ export type D1SessionConstraint = "first-primary" | "first-unconstrained";
21
+ export type D1SessionBookmark = string;
11
22
  export interface DBPreparedStatement {
12
23
  bind: (...values: unknown[]) => DBPreparedStatement;
13
24
  run: <T = unknown>() => Promise<DBResult<T>>;
@@ -16,10 +27,23 @@ export interface DBPreparedStatement {
16
27
  raw: <T = unknown>(options?: {
17
28
  columnNames?: boolean;
18
29
  }) => Promise<T[][]>;
30
+ __db_data?: {
31
+ query: string;
32
+ params: unknown[];
33
+ };
19
34
  }
20
35
  export interface Database {
21
36
  prepare: (query: string) => DBPreparedStatement;
22
37
  dump: () => Promise<ArrayBuffer>;
23
- exec: (query: string) => Promise<DBResult>;
38
+ exec: (query: string) => Promise<D1ExecResult>;
39
+ batch: <T = unknown>(statements: DBPreparedStatement[]) => Promise<DBResult<T>[]>;
40
+ withSession: (constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint) => D1DatabaseSession;
41
+ }
42
+ export interface D1DatabaseSession {
43
+ prepare: (query: string) => DBPreparedStatement;
24
44
  batch: <T = unknown>(statements: DBPreparedStatement[]) => Promise<DBResult<T>[]>;
45
+ getBookmark: () => D1SessionBookmark | null;
25
46
  }
47
+ export type D1Database = Database;
48
+ export type D1PreparedStatement = DBPreparedStatement;
49
+ export type D1Result<T = unknown> = DBResult<T>;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- export type { Database, DBPreparedStatement, DBResult, DBResultMeta, } from "./db.js";
1
+ export type { Database, D1Database, D1DatabaseSession, D1ExecResult, D1PreparedStatement, D1Result, D1SessionBookmark, D1SessionConstraint, DBPreparedStatement, DBResult, DBResultMeta, } from "./db.js";
2
2
  export type { QueueBinding, QueueBatchMessage, QueueMessageEvent, QueueSendOptions, QueueSendResult, QueueSendBatchResult, } from "./queue.js";
3
3
  export type { WorkflowBinding, WorkflowContext, WorkflowExecution, WorkflowExecutionStatus, WorkflowHandler, WorkflowHandlerConfig, WorkflowStep, WorkflowStepOptions, WorkflowTriggerResult, } from "./workflow.js";
4
4
  export type { TimerHandler, ExecutionContext, FetchHandler, MessageHandler, Ploy, PloyHandler, WorkflowHandlers, } from "./ploy.js";
5
5
  export type { TimerBinding, TimerEvent, TimerOptions } from "./timer.js";
6
- export type { CacheBinding } from "./cache.js";
7
- export type { StateBinding, StateUpdateDoc } from "./state.js";
6
+ export type { KVNamespace, KVNamespaceGetOptions, KVNamespaceGetMethodOptions, KVNamespaceGetWithMetadataResult, KVNamespaceListKey, KVNamespaceListOptions, KVNamespaceListResult, KVNamespacePutOptions, StateBinding, StateUpdateDoc, } from "./state.js";
8
7
  export type { FileStorageBinding, FileStorageObject, FileStorageKey, FileStorageListResult, FileStoragePutOptions, FileStorageListOptions, } from "./fs.js";
9
8
  export type { ScheduledEvent, ScheduledHandler } from "./scheduled.js";
10
9
  export type { PloyAuth, PloyUser } from "./auth.js";
package/dist/state.d.ts CHANGED
@@ -5,9 +5,61 @@ export interface StateUpdateDoc {
5
5
  $push?: Record<string, unknown>;
6
6
  $pop?: Record<string, 1 | -1>;
7
7
  }
8
- export interface StateBinding {
9
- get: (key: string) => Promise<string | null>;
10
- set: (key: string, value: string) => Promise<void>;
8
+ export type KVNamespaceGetOptions = "text" | "json" | "arrayBuffer" | "stream";
9
+ export interface KVNamespaceGetMethodOptions {
10
+ type?: KVNamespaceGetOptions;
11
+ cacheTtl?: number;
12
+ }
13
+ export interface KVNamespacePutOptions<Metadata = unknown> {
14
+ expiration?: number;
15
+ expirationTtl?: number;
16
+ metadata?: Metadata | null;
17
+ }
18
+ export interface KVNamespaceListOptions {
19
+ prefix?: string;
20
+ limit?: number;
21
+ cursor?: string;
22
+ }
23
+ export interface KVNamespaceListKey<Metadata = unknown> {
24
+ name: string;
25
+ expiration?: number;
26
+ metadata?: Metadata | null;
27
+ }
28
+ export interface KVNamespaceListResult<Metadata = unknown> {
29
+ keys: KVNamespaceListKey<Metadata>[];
30
+ list_complete: boolean;
31
+ cursor?: string;
32
+ }
33
+ export interface KVNamespaceGetWithMetadataResult<Value = unknown, Metadata = unknown> {
34
+ value: Value | null;
35
+ metadata: Metadata | null;
36
+ }
37
+ export interface KVNamespace<Metadata = unknown> {
38
+ get: ((key: string, type?: "text" | KVNamespaceGetMethodOptions) => Promise<string | null>) & (<T>(key: string, type: "json" | (KVNamespaceGetMethodOptions & {
39
+ type: "json";
40
+ })) => Promise<T | null>) & ((key: string, type: "arrayBuffer" | (KVNamespaceGetMethodOptions & {
41
+ type: "arrayBuffer";
42
+ })) => Promise<ArrayBuffer | null>) & ((key: string, type: "stream" | (KVNamespaceGetMethodOptions & {
43
+ type: "stream";
44
+ })) => Promise<ReadableStream | null>) & ((keys: string[], type?: "text" | KVNamespaceGetMethodOptions) => Promise<Map<string, string | null>>) & (<T>(keys: string[], type: "json" | (KVNamespaceGetMethodOptions & {
45
+ type: "json";
46
+ })) => Promise<Map<string, T | null>>) & ((keys: string[], type: "arrayBuffer" | (KVNamespaceGetMethodOptions & {
47
+ type: "arrayBuffer";
48
+ })) => Promise<Map<string, ArrayBuffer | null>>) & ((keys: string[], type: "stream" | (KVNamespaceGetMethodOptions & {
49
+ type: "stream";
50
+ })) => Promise<Map<string, ReadableStream | null>>);
51
+ getWithMetadata: ((key: string, type?: "text" | KVNamespaceGetMethodOptions) => Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>) & (<T>(key: string, type: "json" | (KVNamespaceGetMethodOptions & {
52
+ type: "json";
53
+ })) => Promise<KVNamespaceGetWithMetadataResult<T, Metadata>>) & ((key: string, type: "arrayBuffer" | (KVNamespaceGetMethodOptions & {
54
+ type: "arrayBuffer";
55
+ })) => Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>) & ((key: string, type: "stream" | (KVNamespaceGetMethodOptions & {
56
+ type: "stream";
57
+ })) => Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>);
58
+ put: (key: string, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions<Metadata>) => Promise<void>;
11
59
  delete: (key: string) => Promise<void>;
60
+ list: (options?: KVNamespaceListOptions) => Promise<KVNamespaceListResult<Metadata>>;
61
+ }
62
+ export interface StateBinding<Metadata = unknown> extends KVNamespace<Metadata> {
63
+ set: (key: string, value: string) => Promise<void>;
12
64
  update: (key: string, update: StateUpdateDoc) => Promise<void>;
13
65
  }
package/globals.d.ts CHANGED
@@ -19,10 +19,16 @@ declare global {
19
19
 
20
20
  // --- Binding types ---
21
21
  type Database = import("@meetploy/types").Database;
22
+ type D1Database = import("@meetploy/types").D1Database;
23
+ type D1DatabaseSession = import("@meetploy/types").D1DatabaseSession;
24
+ type D1ExecResult = import("@meetploy/types").D1ExecResult;
22
25
  type DBPreparedStatement = import("@meetploy/types").DBPreparedStatement;
26
+ type D1PreparedStatement = import("@meetploy/types").D1PreparedStatement;
23
27
  type DBResult<T = unknown> = import("@meetploy/types").DBResult<T>;
28
+ type D1Result<T = unknown> = import("@meetploy/types").D1Result<T>;
24
29
  type DBResultMeta = import("@meetploy/types").DBResultMeta;
25
- type CacheBinding = import("@meetploy/types").CacheBinding;
30
+ type KVNamespace<Metadata = unknown> =
31
+ import("@meetploy/types").KVNamespace<Metadata>;
26
32
  type QueueBinding = import("@meetploy/types").QueueBinding;
27
33
  type StateBinding = import("@meetploy/types").StateBinding;
28
34
  type WorkflowBinding = import("@meetploy/types").WorkflowBinding;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetploy/types",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
package/dist/cache.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export interface CacheBinding {
2
- get: (key: string) => Promise<string | null>;
3
- set: (key: string, value: string, opts: {
4
- ttl: number;
5
- }) => Promise<void>;
6
- delete: (key: string) => Promise<void>;
7
- }
package/dist/cache.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cache.js.map
package/dist/cache.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":""}