@boltstore/utils 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +61 -0
  2. package/dist/auth-types.d.ts +138 -0
  3. package/dist/auth-types.d.ts.map +1 -0
  4. package/dist/auth-types.js +4 -0
  5. package/dist/auth-types.js.map +1 -0
  6. package/dist/constants.d.ts +123 -0
  7. package/dist/constants.d.ts.map +1 -0
  8. package/dist/constants.js +144 -0
  9. package/dist/constants.js.map +1 -0
  10. package/dist/filter/compiler.d.ts +14 -0
  11. package/dist/filter/compiler.d.ts.map +1 -0
  12. package/dist/filter/compiler.js +93 -0
  13. package/dist/filter/compiler.js.map +1 -0
  14. package/dist/filter/parser.d.ts +15 -0
  15. package/dist/filter/parser.d.ts.map +1 -0
  16. package/dist/filter/parser.js +134 -0
  17. package/dist/filter/parser.js.map +1 -0
  18. package/dist/filter/query.d.ts +13 -0
  19. package/dist/filter/query.d.ts.map +1 -0
  20. package/dist/filter/query.js +20 -0
  21. package/dist/filter/query.js.map +1 -0
  22. package/dist/filter/tokenizer.d.ts +17 -0
  23. package/dist/filter/tokenizer.d.ts.map +1 -0
  24. package/dist/filter/tokenizer.js +133 -0
  25. package/dist/filter/tokenizer.js.map +1 -0
  26. package/dist/filter/types.d.ts +24 -0
  27. package/dist/filter/types.d.ts.map +1 -0
  28. package/dist/filter/types.js +3 -0
  29. package/dist/filter/types.js.map +1 -0
  30. package/dist/filter.d.ts +7 -0
  31. package/dist/filter.d.ts.map +1 -0
  32. package/dist/filter.js +12 -0
  33. package/dist/filter.js.map +1 -0
  34. package/dist/index.d.ts +13 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +16 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/realtime-types.d.ts +90 -0
  39. package/dist/realtime-types.d.ts.map +1 -0
  40. package/dist/realtime-types.js +4 -0
  41. package/dist/realtime-types.js.map +1 -0
  42. package/dist/schema.d.ts +612 -0
  43. package/dist/schema.d.ts.map +1 -0
  44. package/dist/schema.js +209 -0
  45. package/dist/schema.js.map +1 -0
  46. package/dist/storage-types.d.ts +117 -0
  47. package/dist/storage-types.d.ts.map +1 -0
  48. package/dist/storage-types.js +4 -0
  49. package/dist/storage-types.js.map +1 -0
  50. package/dist/sync-types.d.ts +136 -0
  51. package/dist/sync-types.d.ts.map +1 -0
  52. package/dist/sync-types.js +4 -0
  53. package/dist/sync-types.js.map +1 -0
  54. package/dist/types.d.ts +164 -0
  55. package/dist/types.d.ts.map +1 -0
  56. package/dist/types.js +3 -0
  57. package/dist/types.js.map +1 -0
  58. package/dist/validation.d.ts +30 -0
  59. package/dist/validation.d.ts.map +1 -0
  60. package/dist/validation.js +259 -0
  61. package/dist/validation.js.map +1 -0
  62. package/package.json +74 -0
package/dist/schema.js ADDED
@@ -0,0 +1,209 @@
1
+ // ── JSON Schema Exports ──
2
+ // Standard JSON Schema representations of all Boltstore types.
3
+ // Enables code generation for any language with JSON Schema tooling.
4
+ export const RecordSchema = {
5
+ $id: "https://boltstore.dev/schemas/record.json",
6
+ $schema: "https://json-schema.org/draft/2020-12/schema",
7
+ title: "Record",
8
+ type: "object",
9
+ properties: {
10
+ id: { type: "string", description: "Unique record ID" },
11
+ collectionId: { type: "string", description: "Parent collection ID" },
12
+ collectionName: { type: "string", description: "Parent collection name" },
13
+ created: { type: "string", format: "date-time" },
14
+ updated: { type: "string", format: "date-time" },
15
+ },
16
+ required: ["id", "collectionId", "collectionName", "created", "updated"],
17
+ additionalProperties: true,
18
+ };
19
+ export const CollectionSchema = {
20
+ $id: "https://boltstore.dev/schemas/collection.json",
21
+ $schema: "https://json-schema.org/draft/2020-12/schema",
22
+ title: "Collection",
23
+ type: "object",
24
+ properties: {
25
+ id: { type: "string" },
26
+ name: { type: "string", minLength: 1, maxLength: 64 },
27
+ fields: {
28
+ type: "array",
29
+ items: { $ref: "#/$defs/FieldSchema" },
30
+ },
31
+ rls: { $ref: "#/$defs/RlsPolicy" },
32
+ sync: { $ref: "#/$defs/SyncConfig" },
33
+ system: { type: "boolean" },
34
+ created: { type: "string", format: "date-time" },
35
+ updated: { type: "string", format: "date-time" },
36
+ },
37
+ required: ["id", "name", "fields", "created", "updated"],
38
+ $defs: {
39
+ FieldSchema: {
40
+ type: "object",
41
+ properties: {
42
+ name: { type: "string" },
43
+ type: {
44
+ type: "string",
45
+ enum: ["text", "number", "bool", "date", "json", "file", "relation", "email", "url", "select"],
46
+ },
47
+ required: { type: "boolean" },
48
+ unique: { type: "boolean" },
49
+ default: {},
50
+ values: { type: "array", items: { type: "string" } },
51
+ maxLength: { type: "integer" },
52
+ min: { type: "number" },
53
+ max: { type: "number" },
54
+ pattern: { type: "string" },
55
+ relationCollection: { type: "string" },
56
+ cascadeDelete: { type: "boolean" },
57
+ maxSize: { type: "integer" },
58
+ mimeTypes: { type: "array", items: { type: "string" } },
59
+ index: { type: "boolean" },
60
+ },
61
+ required: ["name", "type"],
62
+ },
63
+ RlsPolicy: {
64
+ type: "object",
65
+ properties: {
66
+ select: { type: "string" },
67
+ insert: { type: "string" },
68
+ update: { type: "string" },
69
+ delete: { type: "string" },
70
+ },
71
+ },
72
+ SyncConfig: {
73
+ type: "object",
74
+ properties: {
75
+ strategy: {
76
+ type: "string",
77
+ enum: ["server-wins", "last-write-wins", "client-wins", "custom"],
78
+ },
79
+ fields: {
80
+ type: "object",
81
+ additionalProperties: {
82
+ type: "string",
83
+ enum: ["server-wins", "last-write-wins", "client-wins", "custom"],
84
+ },
85
+ },
86
+ },
87
+ required: ["strategy"],
88
+ },
89
+ },
90
+ };
91
+ export const UserSchema = {
92
+ $id: "https://boltstore.dev/schemas/user.json",
93
+ $schema: "https://json-schema.org/draft/2020-12/schema",
94
+ title: "User",
95
+ type: "object",
96
+ properties: {
97
+ id: { type: "string" },
98
+ email: { type: "string", format: "email" },
99
+ emailVerified: { type: "boolean" },
100
+ role: { type: "string", enum: ["admin", "editor", "viewer"] },
101
+ avatar: { type: "string", format: "uri" },
102
+ created: { type: "string", format: "date-time" },
103
+ updated: { type: "string", format: "date-time" },
104
+ },
105
+ required: ["id", "email", "emailVerified", "role", "created", "updated"],
106
+ };
107
+ export const JwtPayloadSchema = {
108
+ $id: "https://boltstore.dev/schemas/jwt-payload.json",
109
+ $schema: "https://json-schema.org/draft/2020-12/schema",
110
+ title: "JWT Payload",
111
+ type: "object",
112
+ properties: {
113
+ sub: { type: "string" },
114
+ iss: { type: "string", const: "boltstore" },
115
+ aud: { type: "string" },
116
+ iat: { type: "integer" },
117
+ exp: { type: "integer" },
118
+ role: { type: "string", enum: ["admin", "editor", "viewer"] },
119
+ email: { type: "string", format: "email" },
120
+ application: { type: "string" },
121
+ type: { type: "string", enum: ["access", "refresh"] },
122
+ jti: { type: "string" },
123
+ },
124
+ required: ["sub", "iss", "aud", "iat", "exp", "role", "application", "type", "jti"],
125
+ };
126
+ export const ApiResponseSchema = {
127
+ $id: "https://boltstore.dev/schemas/api-response.json",
128
+ $schema: "https://json-schema.org/draft/2020-12/schema",
129
+ title: "API Response",
130
+ type: "object",
131
+ properties: {
132
+ success: { type: "boolean" },
133
+ data: {},
134
+ error: {
135
+ type: "object",
136
+ properties: {
137
+ code: { type: "string" },
138
+ message: { type: "string" },
139
+ details: { type: "object" },
140
+ },
141
+ required: ["code", "message"],
142
+ },
143
+ meta: {
144
+ type: "object",
145
+ properties: {
146
+ page: { type: "integer" },
147
+ perPage: { type: "integer" },
148
+ totalItems: { type: "integer" },
149
+ totalPages: { type: "integer" },
150
+ },
151
+ },
152
+ },
153
+ required: ["success"],
154
+ };
155
+ export const ErrorCodesSchema = {
156
+ $id: "https://boltstore.dev/schemas/error-codes.json",
157
+ $schema: "https://json-schema.org/draft/2020-12/schema",
158
+ title: "Error Codes",
159
+ type: "object",
160
+ properties: {
161
+ code: {
162
+ type: "string",
163
+ enum: [
164
+ "unauthorized",
165
+ "forbidden",
166
+ "token_expired",
167
+ "invalid_token",
168
+ "invalid_credentials",
169
+ "email_not_verified",
170
+ "email_already_exists",
171
+ "collection_not_found",
172
+ "record_not_found",
173
+ "validation_error",
174
+ "duplicate_entry",
175
+ "rls_forbidden",
176
+ "rls_no_policy",
177
+ "file_too_large",
178
+ "invalid_file_type",
179
+ "file_not_found",
180
+ "storage_error",
181
+ "rate_limited",
182
+ "internal_error",
183
+ "not_implemented",
184
+ "service_unavailable",
185
+ "sync_conflict",
186
+ "sync_rejected",
187
+ "sync_clock_skew",
188
+ "application_not_found",
189
+ "application_limit_reached",
190
+ "backup_failed",
191
+ "backup_not_found",
192
+ "restore_failed",
193
+ ],
194
+ },
195
+ message: { type: "string" },
196
+ details: { type: "object" },
197
+ },
198
+ required: ["code", "message"],
199
+ };
200
+ // ── All schemas registry ──
201
+ export const allSchemas = {
202
+ record: RecordSchema,
203
+ collection: CollectionSchema,
204
+ user: UserSchema,
205
+ jwtPayload: JwtPayloadSchema,
206
+ apiResponse: ApiResponseSchema,
207
+ errorCodes: ErrorCodesSchema,
208
+ };
209
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,+DAA+D;AAC/D,qEAAqE;AAErE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,EAAE,2CAA2C;IAChD,OAAO,EAAE,8CAA8C;IACvD,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE;QACvD,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;QACrE,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wBAAwB,EAAE;QACzE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE;QACh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,CAAC;CAC9B,CAAC;AAEF,6BAA6B;AAE7B,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,MAAM,EAAE,YAAY;IACpB,UAAU,EAAE,gBAAgB;IAC5B,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,gBAAgB;IAC5B,WAAW,EAAE,iBAAiB;IAC9B,UAAU,EAAE,gBAAgB;CACpB,CAAC"}
@@ -0,0 +1,117 @@
1
+ export interface FileInfo {
2
+ /** Storage key / path */
3
+ key: string;
4
+ /** Original filename */
5
+ filename: string;
6
+ /** File size in bytes */
7
+ size: number;
8
+ /** MIME type */
9
+ mimeType: string;
10
+ /** Application ID */
11
+ applicationId: string;
12
+ /** Collection name */
13
+ collection: string;
14
+ /** Record ID */
15
+ recordId: string;
16
+ /** ISO 8601 upload timestamp */
17
+ uploadedAt: string;
18
+ /** Uploader user ID */
19
+ uploadedBy?: string;
20
+ /** Uploader type (admin, user, api) */
21
+ uploaderType?: string;
22
+ /** Uploader display name */
23
+ uploaderName?: string;
24
+ /** Folder path / ID */
25
+ folder?: string;
26
+ /** Visibility (public, private, shared) */
27
+ visibility?: string;
28
+ /** Content hash (SHA-256) for deduplication */
29
+ checksum?: string;
30
+ /** Custom metadata */
31
+ metadata?: Record<string, string>;
32
+ }
33
+ export interface PutOptions {
34
+ /** Override MIME type detection */
35
+ contentType?: string;
36
+ /** Custom metadata */
37
+ metadata?: Record<string, string>;
38
+ /** Override filename (default: original) */
39
+ filename?: string;
40
+ }
41
+ export interface SignedUrlOptions {
42
+ /** Expiry in seconds (default: 3600 = 1 hour) */
43
+ expiry?: number;
44
+ /** Override content-disposition for download */
45
+ download?: boolean;
46
+ /** Force a specific filename in Content-Disposition */
47
+ filename?: string;
48
+ }
49
+ export interface MultipartUploadInit {
50
+ uploadId: string;
51
+ key: string;
52
+ /** Part size in bytes */
53
+ partSize: number;
54
+ /** Total number of parts */
55
+ totalParts: number;
56
+ }
57
+ export interface MultipartUploadPart {
58
+ partNumber: number;
59
+ /** ETag from the upload response */
60
+ etag: string;
61
+ }
62
+ export interface MultipartUploadComplete {
63
+ uploadId: string;
64
+ key: string;
65
+ parts: MultipartUploadPart[];
66
+ }
67
+ export type StorageProvider = "local" | "s3";
68
+ export interface StorageConfig {
69
+ /** Which provider to use */
70
+ provider: StorageProvider;
71
+ /** Base path for local storage (default: data/uploads/) */
72
+ localBasePath?: string;
73
+ /** S3 configuration */
74
+ s3?: S3Config;
75
+ }
76
+ export interface S3Config {
77
+ /** S3 bucket name */
78
+ bucket: string;
79
+ /** AWS region */
80
+ region: string;
81
+ /** Access key ID */
82
+ accessKeyId: string;
83
+ /** Secret access key */
84
+ secretAccessKey: string;
85
+ /** Custom endpoint for S3-compatible services */
86
+ endpoint?: string;
87
+ /** Force path-style URLs (required for many S3-compatible providers) */
88
+ forcePathStyle?: boolean;
89
+ /** Upload in parts above this size (bytes, default: 5MB) */
90
+ multipartThreshold?: number;
91
+ }
92
+ export interface UploadRequest {
93
+ /** File data (for server-side uploads) */
94
+ file?: File | Blob;
95
+ /** URL to fetch the file from (for URL-based uploads) */
96
+ url?: string;
97
+ /** Target application */
98
+ applicationId: string;
99
+ /** Target collection */
100
+ collection: string;
101
+ /** Target record */
102
+ recordId: string;
103
+ /** Field name on the record */
104
+ field: string;
105
+ options?: PutOptions;
106
+ }
107
+ export interface UploadResponse {
108
+ /** Storage key for retrieval */
109
+ key: string;
110
+ /** Public or signed URL to access the file */
111
+ url: string;
112
+ /** Signed URL for direct access (e.g. S3 presigned) */
113
+ signedUrl?: string;
114
+ /** File metadata */
115
+ file: FileInfo;
116
+ }
117
+ //# sourceMappingURL=storage-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-types.d.ts","sourceRoot":"","sources":["../src/storage-types.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAy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AAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,IAAI,EAAE,QAAQ,CAAC;CAChB"}
@@ -0,0 +1,4 @@
1
+ // ── File Storage Types ──
2
+ // Shared between server storage engine and client SDK.
3
+ export {};
4
+ //# sourceMappingURL=storage-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-types.js","sourceRoot":"","sources":["../src/storage-types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,uDAAuD"}
@@ -0,0 +1,136 @@
1
+ import type { SyncStrategy } from "./types";
2
+ /**
3
+ * A Lamport logical clock — monotonically increasing counter.
4
+ * Each node (client or server) increments its clock on every event.
5
+ * Higher clock = "happened after" in causal ordering.
6
+ */
7
+ export interface LamportClock {
8
+ /** Current clock value */
9
+ counter: number;
10
+ /** Node identifier */
11
+ nodeId: string;
12
+ }
13
+ /**
14
+ * A version vector tracks the latest clock value seen from each node.
15
+ * Used to determine which changes are new when syncing.
16
+ *
17
+ * @example
18
+ * { "server": 10, "client-A": 5, "client-B": 3 }
19
+ */
20
+ export type VersionVector = Record<string, number>;
21
+ export interface ChangeLogEntry {
22
+ /** Unique change ID */
23
+ id: string;
24
+ /** The record that changed */
25
+ rowId: string;
26
+ /** Collection/table name */
27
+ collection: string;
28
+ /** Field that changed (null for row-level operations like delete) */
29
+ field?: string;
30
+ /** Previous value */
31
+ oldValue?: unknown;
32
+ /** New value */
33
+ newValue?: unknown;
34
+ /** Lamport clock value when change was made */
35
+ clock: number;
36
+ /** Node that made the change */
37
+ clientId: string;
38
+ /** ISO 8601 timestamp */
39
+ timestamp: string;
40
+ /** Operation type */
41
+ operation: "insert" | "update" | "delete";
42
+ }
43
+ export interface FieldChange {
44
+ /** Field name */
45
+ field: string;
46
+ /** The new value */
47
+ value: unknown;
48
+ /** Lamport clock for this field change */
49
+ clock: number;
50
+ /** Node that last changed this field */
51
+ clientId: string;
52
+ }
53
+ export interface MergeInput {
54
+ /** The current server-side row */
55
+ serverRow: Record<string, FieldChange>;
56
+ /** The incoming client-side changes */
57
+ clientChanges: Record<string, FieldChange>;
58
+ /** Collection-level sync strategy */
59
+ strategy: SyncStrategy;
60
+ /** Per-field strategy overrides */
61
+ fieldStrategies?: Record<string, SyncStrategy>;
62
+ }
63
+ export interface MergeResult {
64
+ /** The merged row (winning values) */
65
+ merged: Record<string, unknown>;
66
+ /** Fields accepted from client changes */
67
+ accepted: string[];
68
+ /** Fields rejected (server values kept) */
69
+ rejected: string[];
70
+ /** Per-field rejection reasons */
71
+ rejectReasons?: Record<string, string>;
72
+ }
73
+ export type SyncMessageType = "sync_start" | "sync_pull" | "sync_push" | "sync_ack" | "sync_error" | "catchup";
74
+ export interface SyncStartMessage {
75
+ type: "sync_start";
76
+ /** Client's last known version vector */
77
+ lastSeen: VersionVector;
78
+ /** Client's current Lamport clock */
79
+ clock: number;
80
+ }
81
+ export interface SyncPullResponse {
82
+ type: "sync_pull";
83
+ /** Changes since client's lastSeen */
84
+ changes: ChangeLogEntry[];
85
+ /** Current server clock */
86
+ serverClock: number;
87
+ /** Has more changes to send? */
88
+ hasMore: boolean;
89
+ }
90
+ export interface SyncPushRequest {
91
+ type: "sync_push";
92
+ /** Pending local changes to push */
93
+ changes: Array<{
94
+ rowId: string;
95
+ collection: string;
96
+ operation: "insert" | "update" | "delete";
97
+ fields: Record<string, FieldChange>;
98
+ }>;
99
+ }
100
+ export interface SyncPushResponse {
101
+ type: "sync_ack";
102
+ /** Accepted change IDs */
103
+ accepted: string[];
104
+ /** Rejected changes with reasons */
105
+ rejected: Array<{
106
+ rowId: string;
107
+ reason: string;
108
+ code: string;
109
+ }>;
110
+ }
111
+ export interface SyncErrorMessage {
112
+ type: "sync_error";
113
+ code: string;
114
+ message: string;
115
+ }
116
+ export interface CatchupMessage {
117
+ type: "catchup";
118
+ /** Replay changes since this timestamp */
119
+ since: string;
120
+ }
121
+ export interface ClientSyncState {
122
+ /** Local Lamport clock */
123
+ clock: LamportClock;
124
+ /** Known version vector */
125
+ versionVector: VersionVector;
126
+ /** Pending changes not yet pushed */
127
+ pendingChanges: ChangeLogEntry[];
128
+ /** Is a sync in progress? */
129
+ syncing: boolean;
130
+ /** Last successful sync timestamp */
131
+ lastSyncAt?: string;
132
+ /** Number of consecutive sync failures */
133
+ consecutiveFailures: number;
134
+ }
135
+ export type SyncConnectionState = "disconnected" | "connecting" | "connected" | "syncing" | "error";
136
+ //# sourceMappingURL=sync-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-types.d.ts","sourceRoot":"","sources":["../src/sync-types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAInD,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,SAAS,EAAE,QAAQ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WAAW,GAAG,SAAS,GAAG,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ // ── Offline Sync Types ──
2
+ // Shared between server sync engine and client SDK.
3
+ export {};
4
+ //# sourceMappingURL=sync-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-types.js","sourceRoot":"","sources":["../src/sync-types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,oDAAoD"}
@@ -0,0 +1,164 @@
1
+ export type FieldType = "text" | "number" | "bool" | "date" | "json" | "file" | "relation" | "email" | "url" | "select";
2
+ export interface FieldSchema {
3
+ name: string;
4
+ type: FieldType;
5
+ required?: boolean;
6
+ unique?: boolean;
7
+ default?: unknown;
8
+ /** Options for 'select' fields */
9
+ values?: string[];
10
+ /** Max length for 'text' fields */
11
+ maxLength?: number;
12
+ /** Min value for 'number' fields, min length for 'text' fields */
13
+ min?: number;
14
+ /** Max value for 'number' fields */
15
+ max?: number;
16
+ /** Regex pattern for 'text' fields */
17
+ pattern?: string;
18
+ /** For 'relation' fields: target collection name */
19
+ relationCollection?: string;
20
+ /** For 'relation' fields: cascade delete? */
21
+ cascadeDelete?: boolean;
22
+ /** For 'file' fields: max file size in bytes */
23
+ maxSize?: number;
24
+ /** For 'file' fields: allowed MIME types */
25
+ mimeTypes?: string[];
26
+ /** Index this field? */
27
+ index?: boolean;
28
+ /** Foreign key constraint: referenced table and column */
29
+ foreignKey?: {
30
+ table: string;
31
+ column: string;
32
+ onDelete?: "CASCADE" | "SET NULL" | "RESTRICT" | "NO ACTION";
33
+ };
34
+ }
35
+ export interface RlsPolicy {
36
+ /** SQL-like condition appended to SELECT WHERE clause */
37
+ select?: string;
38
+ /** SQL-like condition checked before INSERT */
39
+ insert?: string;
40
+ /** SQL-like condition appended to UPDATE WHERE clause */
41
+ update?: string;
42
+ /** SQL-like condition appended to DELETE WHERE clause */
43
+ delete?: string;
44
+ }
45
+ export interface CollectionSchema {
46
+ id: string;
47
+ name: string;
48
+ fields: FieldSchema[];
49
+ rls?: RlsPolicy;
50
+ sync?: SyncConfig;
51
+ /** System fields added automatically */
52
+ system?: boolean;
53
+ created: string;
54
+ updated: string;
55
+ }
56
+ export type SyncStrategy = "server-wins" | "last-write-wins" | "client-wins" | "custom";
57
+ export interface SyncConfig {
58
+ /** Default strategy for this collection */
59
+ strategy: SyncStrategy;
60
+ /** Per-field strategy overrides */
61
+ fields?: Record<string, SyncStrategy>;
62
+ }
63
+ export interface RecordData {
64
+ id: string;
65
+ collectionId: string;
66
+ collectionName: string;
67
+ /** Dynamic field data */
68
+ [key: string]: unknown;
69
+ created: string;
70
+ updated: string;
71
+ }
72
+ export type UserRole = string;
73
+ export interface BoltstoreUser {
74
+ id: string;
75
+ email: string;
76
+ emailVerified: boolean;
77
+ role: UserRole;
78
+ avatar?: string;
79
+ created: string;
80
+ updated: string;
81
+ }
82
+ export interface BoltstoreApplication {
83
+ id: string;
84
+ name: string;
85
+ description?: string;
86
+ /** Per-application database file path */
87
+ dbFile: string;
88
+ created: string;
89
+ updated: string;
90
+ }
91
+ export type ApiKeyScope = "read-only" | "read-write" | "admin";
92
+ export interface ApiKeyRecord {
93
+ id: string;
94
+ name: string;
95
+ /** SHA-256 hash of the key */
96
+ keyHash: string;
97
+ /** The key prefix for identification (bs_xxxx...) */
98
+ prefix: string;
99
+ scope: ApiKeyScope;
100
+ applicationId: string;
101
+ created: string;
102
+ expiresAt?: string;
103
+ lastUsedAt?: string;
104
+ }
105
+ export interface PaginationParams {
106
+ page?: number;
107
+ perPage?: number;
108
+ sort?: string;
109
+ filter?: string;
110
+ expand?: string;
111
+ search?: string;
112
+ }
113
+ export interface PaginatedResponse<T> {
114
+ page: number;
115
+ perPage: number;
116
+ totalItems: number;
117
+ totalPages: number;
118
+ items: T[];
119
+ }
120
+ export type BatchOperation = {
121
+ method: "POST";
122
+ collection: string;
123
+ data: Record<string, unknown>;
124
+ } | {
125
+ method: "PATCH";
126
+ collection: string;
127
+ id: string;
128
+ data: Record<string, unknown>;
129
+ } | {
130
+ method: "DELETE";
131
+ collection: string;
132
+ id: string;
133
+ };
134
+ export interface BatchRequest {
135
+ operations: BatchOperation[];
136
+ /** Execute in a single transaction? */
137
+ transactional?: boolean;
138
+ }
139
+ export interface BatchResult {
140
+ success: boolean;
141
+ results: Array<{
142
+ operation: BatchOperation;
143
+ status: number;
144
+ data?: RecordData;
145
+ error?: string;
146
+ }>;
147
+ }
148
+ export interface ApiError {
149
+ code: string;
150
+ message: string;
151
+ details?: Record<string, unknown>;
152
+ }
153
+ export interface ApiResponse<T = unknown> {
154
+ success: boolean;
155
+ data?: T;
156
+ error?: ApiError;
157
+ meta?: {
158
+ page?: number;
159
+ perPage?: number;
160
+ totalItems?: number;
161
+ totalPages?: number;
162
+ };
163
+ }
164
+ //# sourceMappingURL=types.d.ts.map