@syncular/server 0.0.1-100
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/blobs/adapters/database.d.ts +83 -0
- package/dist/blobs/adapters/database.d.ts.map +1 -0
- package/dist/blobs/adapters/database.js +202 -0
- package/dist/blobs/adapters/database.js.map +1 -0
- package/dist/blobs/adapters/s3.d.ts +82 -0
- package/dist/blobs/adapters/s3.d.ts.map +1 -0
- package/dist/blobs/adapters/s3.js +170 -0
- package/dist/blobs/adapters/s3.js.map +1 -0
- package/dist/blobs/index.d.ts +9 -0
- package/dist/blobs/index.d.ts.map +1 -0
- package/dist/blobs/index.js +9 -0
- package/dist/blobs/index.js.map +1 -0
- package/dist/blobs/manager.d.ts +195 -0
- package/dist/blobs/manager.d.ts.map +1 -0
- package/dist/blobs/manager.js +440 -0
- package/dist/blobs/manager.js.map +1 -0
- package/dist/blobs/migrate.d.ts +27 -0
- package/dist/blobs/migrate.d.ts.map +1 -0
- package/dist/blobs/migrate.js +119 -0
- package/dist/blobs/migrate.js.map +1 -0
- package/dist/blobs/types.d.ts +54 -0
- package/dist/blobs/types.d.ts.map +1 -0
- package/dist/blobs/types.js +5 -0
- package/dist/blobs/types.js.map +1 -0
- package/dist/clients.d.ts +14 -0
- package/dist/clients.d.ts.map +1 -0
- package/dist/clients.js +7 -0
- package/dist/clients.js.map +1 -0
- package/dist/compaction.d.ts +27 -0
- package/dist/compaction.d.ts.map +1 -0
- package/dist/compaction.js +49 -0
- package/dist/compaction.js.map +1 -0
- package/dist/dialect/base.d.ts +83 -0
- package/dist/dialect/base.d.ts.map +1 -0
- package/dist/dialect/base.js +144 -0
- package/dist/dialect/base.js.map +1 -0
- package/dist/dialect/helpers.d.ts +10 -0
- package/dist/dialect/helpers.d.ts.map +1 -0
- package/dist/dialect/helpers.js +59 -0
- package/dist/dialect/helpers.js.map +1 -0
- package/dist/dialect/index.d.ts +7 -0
- package/dist/dialect/index.d.ts.map +1 -0
- package/dist/dialect/index.js +7 -0
- package/dist/dialect/index.js.map +1 -0
- package/dist/dialect/types.d.ts +149 -0
- package/dist/dialect/types.d.ts.map +1 -0
- package/dist/dialect/types.js +8 -0
- package/dist/dialect/types.js.map +1 -0
- package/dist/helpers/conflict.d.ts +52 -0
- package/dist/helpers/conflict.d.ts.map +1 -0
- package/dist/helpers/conflict.js +49 -0
- package/dist/helpers/conflict.js.map +1 -0
- package/dist/helpers/emitted-change.d.ts +56 -0
- package/dist/helpers/emitted-change.d.ts.map +1 -0
- package/dist/helpers/emitted-change.js +46 -0
- package/dist/helpers/emitted-change.js.map +1 -0
- package/dist/helpers/index.d.ts +10 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +10 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/paginate.d.ts +49 -0
- package/dist/helpers/paginate.d.ts.map +1 -0
- package/dist/helpers/paginate.js +54 -0
- package/dist/helpers/paginate.js.map +1 -0
- package/dist/helpers/scope-strings.d.ts +74 -0
- package/dist/helpers/scope-strings.d.ts.map +1 -0
- package/dist/helpers/scope-strings.js +82 -0
- package/dist/helpers/scope-strings.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/migrate.d.ts +14 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +13 -0
- package/dist/migrate.js.map +1 -0
- package/dist/proxy/handler.d.ts +42 -0
- package/dist/proxy/handler.d.ts.map +1 -0
- package/dist/proxy/handler.js +102 -0
- package/dist/proxy/handler.js.map +1 -0
- package/dist/proxy/index.d.ts +9 -0
- package/dist/proxy/index.d.ts.map +1 -0
- package/dist/proxy/index.js +14 -0
- package/dist/proxy/index.js.map +1 -0
- package/dist/proxy/mutation-detector.d.ts +35 -0
- package/dist/proxy/mutation-detector.d.ts.map +1 -0
- package/dist/proxy/mutation-detector.js +246 -0
- package/dist/proxy/mutation-detector.js.map +1 -0
- package/dist/proxy/oplog.d.ts +30 -0
- package/dist/proxy/oplog.d.ts.map +1 -0
- package/dist/proxy/oplog.js +110 -0
- package/dist/proxy/oplog.js.map +1 -0
- package/dist/proxy/registry.d.ts +35 -0
- package/dist/proxy/registry.d.ts.map +1 -0
- package/dist/proxy/registry.js +49 -0
- package/dist/proxy/registry.js.map +1 -0
- package/dist/proxy/types.d.ts +44 -0
- package/dist/proxy/types.d.ts.map +1 -0
- package/dist/proxy/types.js +7 -0
- package/dist/proxy/types.js.map +1 -0
- package/dist/prune.d.ts +37 -0
- package/dist/prune.d.ts.map +1 -0
- package/dist/prune.js +112 -0
- package/dist/prune.js.map +1 -0
- package/dist/pull.d.ts +31 -0
- package/dist/pull.d.ts.map +1 -0
- package/dist/pull.js +608 -0
- package/dist/pull.js.map +1 -0
- package/dist/push.d.ts +33 -0
- package/dist/push.d.ts.map +1 -0
- package/dist/push.js +412 -0
- package/dist/push.js.map +1 -0
- package/dist/realtime/in-memory.d.ts +13 -0
- package/dist/realtime/in-memory.d.ts.map +1 -0
- package/dist/realtime/in-memory.js +28 -0
- package/dist/realtime/in-memory.js.map +1 -0
- package/dist/realtime/index.d.ts +3 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +2 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/realtime/types.d.ts +50 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/dist/realtime/types.js +7 -0
- package/dist/realtime/types.js.map +1 -0
- package/dist/schema.d.ts +164 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +10 -0
- package/dist/schema.js.map +1 -0
- package/dist/shapes/create-handler.d.ts +119 -0
- package/dist/shapes/create-handler.d.ts.map +1 -0
- package/dist/shapes/create-handler.js +327 -0
- package/dist/shapes/create-handler.js.map +1 -0
- package/dist/shapes/index.d.ts +4 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/shapes/index.js +4 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/registry.d.ts +20 -0
- package/dist/shapes/registry.d.ts.map +1 -0
- package/dist/shapes/registry.js +88 -0
- package/dist/shapes/registry.js.map +1 -0
- package/dist/shapes/types.d.ts +204 -0
- package/dist/shapes/types.d.ts.map +1 -0
- package/dist/shapes/types.js +2 -0
- package/dist/shapes/types.js.map +1 -0
- package/dist/snapshot-chunks/adapters/s3.d.ts +74 -0
- package/dist/snapshot-chunks/adapters/s3.d.ts.map +1 -0
- package/dist/snapshot-chunks/adapters/s3.js +50 -0
- package/dist/snapshot-chunks/adapters/s3.js.map +1 -0
- package/dist/snapshot-chunks/db-metadata.d.ts +38 -0
- package/dist/snapshot-chunks/db-metadata.d.ts.map +1 -0
- package/dist/snapshot-chunks/db-metadata.js +324 -0
- package/dist/snapshot-chunks/db-metadata.js.map +1 -0
- package/dist/snapshot-chunks/index.d.ts +9 -0
- package/dist/snapshot-chunks/index.d.ts.map +1 -0
- package/dist/snapshot-chunks/index.js +9 -0
- package/dist/snapshot-chunks/index.js.map +1 -0
- package/dist/snapshot-chunks/types.d.ts +78 -0
- package/dist/snapshot-chunks/types.d.ts.map +1 -0
- package/dist/snapshot-chunks/types.js +8 -0
- package/dist/snapshot-chunks/types.js.map +1 -0
- package/dist/snapshot-chunks.d.ts +60 -0
- package/dist/snapshot-chunks.d.ts.map +1 -0
- package/dist/snapshot-chunks.js +223 -0
- package/dist/snapshot-chunks.js.map +1 -0
- package/dist/stats.d.ts +19 -0
- package/dist/stats.d.ts.map +1 -0
- package/dist/stats.js +57 -0
- package/dist/stats.js.map +1 -0
- package/dist/subscriptions/index.d.ts +2 -0
- package/dist/subscriptions/index.d.ts.map +1 -0
- package/dist/subscriptions/index.js +2 -0
- package/dist/subscriptions/index.js.map +1 -0
- package/dist/subscriptions/resolve.d.ts +35 -0
- package/dist/subscriptions/resolve.d.ts.map +1 -0
- package/dist/subscriptions/resolve.js +134 -0
- package/dist/subscriptions/resolve.js.map +1 -0
- package/package.json +80 -0
- package/src/blobs/adapters/database.test.ts +67 -0
- package/src/blobs/adapters/database.ts +315 -0
- package/src/blobs/adapters/s3.ts +271 -0
- package/src/blobs/index.ts +9 -0
- package/src/blobs/manager.ts +600 -0
- package/src/blobs/migrate.ts +150 -0
- package/src/blobs/types.ts +70 -0
- package/src/clients.ts +21 -0
- package/src/compaction.ts +77 -0
- package/src/dialect/base.ts +292 -0
- package/src/dialect/helpers.ts +61 -0
- package/src/dialect/index.ts +7 -0
- package/src/dialect/types.ts +197 -0
- package/src/helpers/conflict.ts +64 -0
- package/src/helpers/emitted-change.ts +69 -0
- package/src/helpers/index.ts +10 -0
- package/src/helpers/paginate.ts +82 -0
- package/src/helpers/scope-strings.ts +101 -0
- package/src/index.ts +28 -0
- package/src/migrate.ts +20 -0
- package/src/proxy/handler.test.ts +120 -0
- package/src/proxy/handler.ts +159 -0
- package/src/proxy/index.ts +18 -0
- package/src/proxy/mutation-detector.test.ts +71 -0
- package/src/proxy/mutation-detector.ts +281 -0
- package/src/proxy/oplog.ts +146 -0
- package/src/proxy/registry.ts +56 -0
- package/src/proxy/types.ts +46 -0
- package/src/prune.ts +200 -0
- package/src/pull.ts +858 -0
- package/src/push.ts +583 -0
- package/src/realtime/in-memory.ts +33 -0
- package/src/realtime/index.ts +5 -0
- package/src/realtime/types.ts +55 -0
- package/src/schema.ts +172 -0
- package/src/shapes/create-handler.ts +590 -0
- package/src/shapes/index.ts +3 -0
- package/src/shapes/registry.ts +109 -0
- package/src/shapes/types.ts +267 -0
- package/src/snapshot-chunks/adapters/s3.ts +68 -0
- package/src/snapshot-chunks/db-metadata.test.ts +100 -0
- package/src/snapshot-chunks/db-metadata.ts +466 -0
- package/src/snapshot-chunks/index.ts +9 -0
- package/src/snapshot-chunks/types.ts +103 -0
- package/src/snapshot-chunks.ts +329 -0
- package/src/stats.ts +104 -0
- package/src/subscriptions/index.ts +1 -0
- package/src/subscriptions/resolve.ts +185 -0
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - database schema types
|
|
3
|
+
*
|
|
4
|
+
* Commit-log based sync tables:
|
|
5
|
+
* - sync_commits: one row per committed push
|
|
6
|
+
* - sync_changes: one row per emitted change, stamped with scopes
|
|
7
|
+
* - sync_table_commits: commit routing index for fast pull
|
|
8
|
+
*/
|
|
9
|
+
import type { SyncOp } from '@syncular/core';
|
|
10
|
+
import type { Generated } from 'kysely';
|
|
11
|
+
/**
|
|
12
|
+
* Commit log.
|
|
13
|
+
*/
|
|
14
|
+
export interface SyncCommitsTable {
|
|
15
|
+
/** Monotonic commit sequence (server-assigned) */
|
|
16
|
+
commit_seq: Generated<number>;
|
|
17
|
+
/** Logical partition key (tenant / demo / workspace) */
|
|
18
|
+
partition_id: string;
|
|
19
|
+
/** Actor who produced the commit */
|
|
20
|
+
actor_id: string;
|
|
21
|
+
/** Client/device identifier */
|
|
22
|
+
client_id: string;
|
|
23
|
+
/** Client-provided commit idempotency key (unique per client) */
|
|
24
|
+
client_commit_id: string;
|
|
25
|
+
/** Creation timestamp */
|
|
26
|
+
created_at: Generated<string>;
|
|
27
|
+
/** Optional metadata */
|
|
28
|
+
meta: unknown | null;
|
|
29
|
+
/** Cached push response for idempotency */
|
|
30
|
+
result_json: unknown | null;
|
|
31
|
+
/** Number of emitted changes (denormalized for observability) */
|
|
32
|
+
change_count: Generated<number>;
|
|
33
|
+
/**
|
|
34
|
+
* Tables affected by this commit (for realtime notifications).
|
|
35
|
+
* Array of table names that had changes.
|
|
36
|
+
*/
|
|
37
|
+
affected_tables: Generated<string[]>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Change log entries (filtered by scopes on pull).
|
|
41
|
+
*/
|
|
42
|
+
export interface SyncChangesTable {
|
|
43
|
+
/** Monotonic change id */
|
|
44
|
+
change_id: Generated<number>;
|
|
45
|
+
/** Logical partition key (tenant / demo / workspace) */
|
|
46
|
+
partition_id: string;
|
|
47
|
+
/** Commit sequence this change belongs to */
|
|
48
|
+
commit_seq: number;
|
|
49
|
+
/** Table name being changed */
|
|
50
|
+
table: string;
|
|
51
|
+
/** Row primary key */
|
|
52
|
+
row_id: string;
|
|
53
|
+
/** Operation: 'upsert' or 'delete' */
|
|
54
|
+
op: SyncOp;
|
|
55
|
+
/** Row data as JSON (null for deletes) */
|
|
56
|
+
row_json: unknown | null;
|
|
57
|
+
/** Optional row version for optimistic concurrency */
|
|
58
|
+
row_version: number | null;
|
|
59
|
+
/**
|
|
60
|
+
* Scope values for routing/filtering (JSONB).
|
|
61
|
+
* Example: { "user_id": "U1", "project_id": "P1" }
|
|
62
|
+
*/
|
|
63
|
+
scopes: unknown;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Per-client cursor tracking (for pruning + observability).
|
|
67
|
+
*/
|
|
68
|
+
export interface SyncClientCursorsTable {
|
|
69
|
+
/** Logical partition key (tenant / demo / workspace) */
|
|
70
|
+
partition_id: string;
|
|
71
|
+
/** Client/device identifier */
|
|
72
|
+
client_id: string;
|
|
73
|
+
/** Actor currently associated with the client */
|
|
74
|
+
actor_id: string;
|
|
75
|
+
/** Last successfully pulled commit_seq */
|
|
76
|
+
cursor: number;
|
|
77
|
+
/**
|
|
78
|
+
* Effective scope values for the client's last pull (JSONB).
|
|
79
|
+
* This is the intersection of requested scopes and allowed scopes.
|
|
80
|
+
*/
|
|
81
|
+
effective_scopes: unknown;
|
|
82
|
+
/** Last update timestamp */
|
|
83
|
+
updated_at: Generated<string>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Cached bootstrap snapshot chunks (encoded, for large read-only bootstraps).
|
|
87
|
+
*/
|
|
88
|
+
export interface SyncSnapshotChunksTable {
|
|
89
|
+
/** Opaque chunk id */
|
|
90
|
+
chunk_id: string;
|
|
91
|
+
/** Logical partition key (tenant / demo / workspace) */
|
|
92
|
+
partition_id: string;
|
|
93
|
+
/** Effective scope key this chunk belongs to */
|
|
94
|
+
scope_key: string;
|
|
95
|
+
/** Scope identifier */
|
|
96
|
+
scope: string;
|
|
97
|
+
/** Snapshot as-of commit sequence */
|
|
98
|
+
as_of_commit_seq: number;
|
|
99
|
+
/** Snapshot row cursor key (empty string represents null) */
|
|
100
|
+
row_cursor: string;
|
|
101
|
+
/** Snapshot row limit used to produce this chunk */
|
|
102
|
+
row_limit: number;
|
|
103
|
+
/** Row encoding (e.g. 'json-row-frame-v1') */
|
|
104
|
+
encoding: string;
|
|
105
|
+
/** Compression algorithm (e.g. 'gzip') */
|
|
106
|
+
compression: string;
|
|
107
|
+
/** Hex-encoded sha256 of content */
|
|
108
|
+
sha256: string;
|
|
109
|
+
/** Byte length of content */
|
|
110
|
+
byte_length: number;
|
|
111
|
+
/** Reference to blob storage (new field for external storage) */
|
|
112
|
+
blob_hash: string;
|
|
113
|
+
/** Encoded chunk bytes (deprecated: use blob storage via blob_hash) */
|
|
114
|
+
body?: Uint8Array | null;
|
|
115
|
+
/** Created timestamp */
|
|
116
|
+
created_at: Generated<string>;
|
|
117
|
+
/** Expiration timestamp (server may delete after this) */
|
|
118
|
+
expires_at: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Index table: which commits affect which tables.
|
|
122
|
+
*
|
|
123
|
+
* Used to efficiently find commit_seq values for a table without scanning
|
|
124
|
+
* the (much larger) change log.
|
|
125
|
+
*/
|
|
126
|
+
export interface SyncTableCommitsTable {
|
|
127
|
+
/** Logical partition key (tenant / demo / workspace) */
|
|
128
|
+
partition_id: string;
|
|
129
|
+
table: string;
|
|
130
|
+
commit_seq: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Database interface for sync infrastructure tables
|
|
134
|
+
* Merge this with your app's database interface
|
|
135
|
+
*/
|
|
136
|
+
export interface SyncCoreDb {
|
|
137
|
+
sync_commits: SyncCommitsTable;
|
|
138
|
+
sync_changes: SyncChangesTable;
|
|
139
|
+
sync_client_cursors: SyncClientCursorsTable;
|
|
140
|
+
sync_table_commits: SyncTableCommitsTable;
|
|
141
|
+
sync_snapshot_chunks: SyncSnapshotChunksTable;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Commit metadata row for pull responses
|
|
145
|
+
*/
|
|
146
|
+
export interface SyncCommitRow {
|
|
147
|
+
commit_seq: number;
|
|
148
|
+
actor_id: string;
|
|
149
|
+
created_at: string;
|
|
150
|
+
result_json: unknown | null;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Change row for pull responses
|
|
154
|
+
*/
|
|
155
|
+
export interface SyncChangeRow {
|
|
156
|
+
commit_seq: number;
|
|
157
|
+
table: string;
|
|
158
|
+
row_id: string;
|
|
159
|
+
op: SyncOp;
|
|
160
|
+
row_json: unknown | null;
|
|
161
|
+
row_version: number | null;
|
|
162
|
+
scopes: unknown;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC9B,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,gBAAgB,EAAE,MAAM,CAAC;IACzB,yBAAyB;IACzB,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC9B,wBAAwB;IACxB,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACrB,2CAA2C;IAC3C,WAAW,EAAE,OAAO,GAAG,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AI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;CACjB"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - database schema types
|
|
3
|
+
*
|
|
4
|
+
* Commit-log based sync tables:
|
|
5
|
+
* - sync_commits: one row per committed push
|
|
6
|
+
* - sync_changes: one row per emitted change, stamped with scopes
|
|
7
|
+
* - sync_table_commits: commit routing index for fast pull
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Declarative server handler helper
|
|
3
|
+
*/
|
|
4
|
+
import type { ScopeValues, ScopeDefinition as SimpleScopeDefinition, StoredScopes, SyncOperation } from '@syncular/core';
|
|
5
|
+
import type { Selectable, Updateable } from 'kysely';
|
|
6
|
+
import type { SyncCoreDb } from '../schema';
|
|
7
|
+
import type { ServerApplyOperationContext, ServerContext, ServerTableHandler } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Authorization result from authorize callback.
|
|
10
|
+
*/
|
|
11
|
+
type AuthorizeResult = true | {
|
|
12
|
+
error: string;
|
|
13
|
+
code: string;
|
|
14
|
+
retriable?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Scope definition for a column - maps scope variable to column name.
|
|
18
|
+
*/
|
|
19
|
+
export type ScopeColumnMap = Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Options for creating a declarative server handler.
|
|
22
|
+
*/
|
|
23
|
+
export interface CreateServerHandlerOptions<ServerDB extends SyncCoreDb, ClientDB, TableName extends keyof ServerDB & keyof ClientDB & string> {
|
|
24
|
+
/** Table name in the database */
|
|
25
|
+
table: TableName;
|
|
26
|
+
/**
|
|
27
|
+
* Scope definitions for this table.
|
|
28
|
+
* Can be simple strings (column auto-derived) or objects with explicit mapping.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Simple: column auto-derived from placeholder
|
|
33
|
+
* scopes: ['user:{user_id}', 'org:{org_id}']
|
|
34
|
+
*
|
|
35
|
+
* // Explicit: when column differs from pattern variable
|
|
36
|
+
* scopes: [
|
|
37
|
+
* { pattern: 'user:{user_id}', column: 'owner_id' }
|
|
38
|
+
* ]
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
scopes: SimpleScopeDefinition[];
|
|
42
|
+
/** Primary key column name (default: 'id') */
|
|
43
|
+
primaryKey?: string;
|
|
44
|
+
/** Version column name (default: 'server_version') */
|
|
45
|
+
versionColumn?: string;
|
|
46
|
+
/** Tables this handler depends on (for bootstrap ordering) */
|
|
47
|
+
dependsOn?: string[];
|
|
48
|
+
/** TTL for cached snapshot chunks in ms */
|
|
49
|
+
snapshotChunkTtlMs?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve allowed scope values for the current actor.
|
|
52
|
+
* Called per request to determine what the actor can access.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* resolveScopes: async (ctx) => ({
|
|
56
|
+
* user_id: [ctx.actorId],
|
|
57
|
+
* project_id: await getProjectsForUser(ctx.db, ctx.actorId),
|
|
58
|
+
* })
|
|
59
|
+
*/
|
|
60
|
+
resolveScopes: (ctx: ServerContext<ServerDB>) => Promise<ScopeValues>;
|
|
61
|
+
/**
|
|
62
|
+
* Transform inbound row from client to server format.
|
|
63
|
+
* Use ctx.schemaVersion to handle older client versions.
|
|
64
|
+
*/
|
|
65
|
+
transformInbound?: (row: ClientDB[TableName], ctx: {
|
|
66
|
+
schemaVersion?: number;
|
|
67
|
+
}) => Updateable<ServerDB[TableName]>;
|
|
68
|
+
/**
|
|
69
|
+
* Transform outbound row from server to client format.
|
|
70
|
+
*/
|
|
71
|
+
transformOutbound?: (row: Selectable<ServerDB[TableName]>) => ClientDB[TableName];
|
|
72
|
+
/**
|
|
73
|
+
* Authorize an operation before applying.
|
|
74
|
+
* Return true to allow, or an error object to reject.
|
|
75
|
+
*/
|
|
76
|
+
authorize?: (ctx: ServerApplyOperationContext<ServerDB>, op: SyncOperation) => Promise<AuthorizeResult>;
|
|
77
|
+
/**
|
|
78
|
+
* Override: Build snapshot query.
|
|
79
|
+
*/
|
|
80
|
+
snapshot?: ServerTableHandler<ServerDB>['snapshot'];
|
|
81
|
+
/**
|
|
82
|
+
* Override: Apply operation.
|
|
83
|
+
*/
|
|
84
|
+
applyOperation?: ServerTableHandler<ServerDB>['applyOperation'];
|
|
85
|
+
/**
|
|
86
|
+
* Custom scope extraction from row (for complex scope logic).
|
|
87
|
+
*/
|
|
88
|
+
extractScopes?: (row: Record<string, unknown>) => StoredScopes;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create a declarative server table handler with sensible defaults.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* import { createServerHandler } from '@syncular/server';
|
|
96
|
+
* import type { ServerDb } from '../db';
|
|
97
|
+
* import type { ClientDb } from '../../shared/client-db.generated';
|
|
98
|
+
*
|
|
99
|
+
* export const tasksHandler = createServerHandler<ServerDb, ClientDb, 'tasks'>({
|
|
100
|
+
* table: 'tasks',
|
|
101
|
+
* scopes: ['user:{user_id}'], // column auto-derived from placeholder
|
|
102
|
+
* resolveScopes: async (ctx) => ({
|
|
103
|
+
* user_id: [ctx.actorId],
|
|
104
|
+
* }),
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* // With custom column mapping:
|
|
108
|
+
* export const tasksHandler = createServerHandler<ServerDb, ClientDb, 'tasks'>({
|
|
109
|
+
* table: 'tasks',
|
|
110
|
+
* scopes: [{ pattern: 'user:{user_id}', column: 'owner_id' }],
|
|
111
|
+
* resolveScopes: async (ctx) => ({
|
|
112
|
+
* user_id: [ctx.actorId],
|
|
113
|
+
* }),
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function createServerHandler<ServerDB extends SyncCoreDb, ClientDB, TableName extends keyof ServerDB & keyof ClientDB & string>(options: CreateServerHandlerOptions<ServerDB, ClientDB, TableName>): ServerTableHandler<ServerDB>;
|
|
118
|
+
export {};
|
|
119
|
+
//# sourceMappingURL=create-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-handler.d.ts","sourceRoot":"","sources":["../../src/shapes/create-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAEV,WAAW,EACX,eAAe,IAAI,qBAAqB,EACxC,YAAY,EACZ,aAAa,EACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAMV,UAAU,EAEV,UAAU,EAGX,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAGV,2BAA2B,EAC3B,aAAa,EAEb,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,KAAK,eAAe,GAChB,IAAI,GACJ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAoBzD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,0BAA0B,CACzC,QAAQ,SAAS,UAAU,EAC3B,QAAQ,EACR,SAAS,SAAS,MAAM,QAAQ,GAAG,MAAM,QAAQ,GAAG,MAAM;IAE1D,iCAAiC;IACjC,KAAK,EAAE,SAAS,CAAC;IAEjB;;;;;;;;;;;;;;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,SAAS,UAAU,EAC3B,QAAQ,EACR,SAAS,SAAS,MAAM,QAAQ,GAAG,MAAM,QAAQ,GAAG,MAAM,EAE1D,OAAO,EAAE,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,GACjE,kBAAkB,CAAC,QAAQ,CAAC,CA+Y9B"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Declarative server handler helper
|
|
3
|
+
*/
|
|
4
|
+
import { extractScopeVars, normalizeScopes } from '@syncular/core';
|
|
5
|
+
function classifyConstraintViolationCode(message) {
|
|
6
|
+
const normalized = message.toLowerCase();
|
|
7
|
+
if (normalized.includes('not null'))
|
|
8
|
+
return 'NOT_NULL_CONSTRAINT';
|
|
9
|
+
if (normalized.includes('unique'))
|
|
10
|
+
return 'UNIQUE_CONSTRAINT';
|
|
11
|
+
if (normalized.includes('foreign key'))
|
|
12
|
+
return 'FOREIGN_KEY_CONSTRAINT';
|
|
13
|
+
return 'CONSTRAINT_VIOLATION';
|
|
14
|
+
}
|
|
15
|
+
function isConstraintViolationError(message) {
|
|
16
|
+
const normalized = message.toLowerCase();
|
|
17
|
+
return (normalized.includes('constraint') ||
|
|
18
|
+
normalized.includes('not null') ||
|
|
19
|
+
normalized.includes('foreign key') ||
|
|
20
|
+
normalized.includes('unique'));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a declarative server table handler with sensible defaults.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { createServerHandler } from '@syncular/server';
|
|
28
|
+
* import type { ServerDb } from '../db';
|
|
29
|
+
* import type { ClientDb } from '../../shared/client-db.generated';
|
|
30
|
+
*
|
|
31
|
+
* export const tasksHandler = createServerHandler<ServerDb, ClientDb, 'tasks'>({
|
|
32
|
+
* table: 'tasks',
|
|
33
|
+
* scopes: ['user:{user_id}'], // column auto-derived from placeholder
|
|
34
|
+
* resolveScopes: async (ctx) => ({
|
|
35
|
+
* user_id: [ctx.actorId],
|
|
36
|
+
* }),
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // With custom column mapping:
|
|
40
|
+
* export const tasksHandler = createServerHandler<ServerDb, ClientDb, 'tasks'>({
|
|
41
|
+
* table: 'tasks',
|
|
42
|
+
* scopes: [{ pattern: 'user:{user_id}', column: 'owner_id' }],
|
|
43
|
+
* resolveScopes: async (ctx) => ({
|
|
44
|
+
* user_id: [ctx.actorId],
|
|
45
|
+
* }),
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function createServerHandler(options) {
|
|
50
|
+
const { table, scopes: scopeDefs, primaryKey = 'id', versionColumn = 'server_version', dependsOn, snapshotChunkTtlMs, resolveScopes, transformInbound, transformOutbound, authorize, extractScopes: customExtractScopes, } = options;
|
|
51
|
+
// Normalize scopes to pattern map and extract patterns/columns
|
|
52
|
+
const scopeColumnMap = normalizeScopes(scopeDefs);
|
|
53
|
+
const scopePatterns = Object.keys(scopeColumnMap);
|
|
54
|
+
const scopeColumns = {};
|
|
55
|
+
for (const [pattern, columnName] of Object.entries(scopeColumnMap)) {
|
|
56
|
+
const vars = extractScopeVars(pattern);
|
|
57
|
+
if (vars.length !== 1) {
|
|
58
|
+
throw new Error(`Scope pattern "${pattern}" must contain exactly one placeholder (got ${vars.length}).`);
|
|
59
|
+
}
|
|
60
|
+
const varName = vars[0];
|
|
61
|
+
const existing = scopeColumns[varName];
|
|
62
|
+
if (existing && existing !== columnName) {
|
|
63
|
+
throw new Error(`Scope variable "${varName}" is mapped to multiple columns: "${existing}" and "${columnName}".`);
|
|
64
|
+
}
|
|
65
|
+
scopeColumns[varName] = columnName;
|
|
66
|
+
}
|
|
67
|
+
// Default extractScopes from scope columns
|
|
68
|
+
const defaultExtractScopes = (row) => {
|
|
69
|
+
const scopes = {};
|
|
70
|
+
for (const [varName, columnName] of Object.entries(scopeColumns)) {
|
|
71
|
+
const raw = row[columnName];
|
|
72
|
+
if (raw === null || raw === undefined)
|
|
73
|
+
continue;
|
|
74
|
+
const value = String(raw);
|
|
75
|
+
if (value.length > 0) {
|
|
76
|
+
scopes[varName] = value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return scopes;
|
|
80
|
+
};
|
|
81
|
+
const extractScopesImpl = customExtractScopes ?? defaultExtractScopes;
|
|
82
|
+
// Default snapshot implementation
|
|
83
|
+
const defaultSnapshot = async (ctx, _params) => {
|
|
84
|
+
const trx = ctx.db;
|
|
85
|
+
const { ref } = trx.dynamic;
|
|
86
|
+
const scopeValues = ctx.scopeValues;
|
|
87
|
+
const pageSize = Math.max(1, Math.min(10_000, ctx.limit));
|
|
88
|
+
// Build dynamic WHERE conditions
|
|
89
|
+
const whereConditions = [];
|
|
90
|
+
for (const [varName, columnName] of Object.entries(scopeColumns)) {
|
|
91
|
+
const values = scopeValues[varName];
|
|
92
|
+
if (values === undefined)
|
|
93
|
+
continue;
|
|
94
|
+
const normalized = Array.isArray(values) ? values : [values];
|
|
95
|
+
if (normalized.length === 0)
|
|
96
|
+
continue;
|
|
97
|
+
whereConditions.push({ column: columnName, values: normalized });
|
|
98
|
+
}
|
|
99
|
+
let q = trx.selectFrom(table).selectAll();
|
|
100
|
+
for (const cond of whereConditions) {
|
|
101
|
+
if (cond.values.length === 1) {
|
|
102
|
+
q = q.where(ref(cond.column), '=', cond.values[0]);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
q = q.where(ref(cond.column), 'in', cond.values);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (ctx.cursor !== null) {
|
|
109
|
+
q = q.where(ref(primaryKey), '>', ctx.cursor);
|
|
110
|
+
}
|
|
111
|
+
const rows = await q
|
|
112
|
+
.orderBy(ref(primaryKey), 'asc')
|
|
113
|
+
.limit(pageSize + 1)
|
|
114
|
+
.execute();
|
|
115
|
+
const hasMore = rows.length > pageSize;
|
|
116
|
+
const pageRows = hasMore ? rows.slice(0, pageSize) : rows;
|
|
117
|
+
const lastRow = pageRows[pageRows.length - 1];
|
|
118
|
+
const nextCursor = hasMore
|
|
119
|
+
? lastRow?.[primaryKey]
|
|
120
|
+
: null;
|
|
121
|
+
// Transform outbound if provided
|
|
122
|
+
const outputRows = transformOutbound
|
|
123
|
+
? pageRows.map((r) => transformOutbound(r))
|
|
124
|
+
: pageRows;
|
|
125
|
+
return {
|
|
126
|
+
rows: outputRows,
|
|
127
|
+
nextCursor: typeof nextCursor === 'string' && nextCursor.length > 0
|
|
128
|
+
? nextCursor
|
|
129
|
+
: null,
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
// Default applyOperation implementation
|
|
133
|
+
const defaultApplyOperation = async (ctx, op, opIndex) => {
|
|
134
|
+
const trx = ctx.trx;
|
|
135
|
+
const { ref } = trx.dynamic;
|
|
136
|
+
if (op.table !== table) {
|
|
137
|
+
return {
|
|
138
|
+
result: {
|
|
139
|
+
opIndex,
|
|
140
|
+
status: 'error',
|
|
141
|
+
error: `UNKNOWN_TABLE:${op.table}`,
|
|
142
|
+
code: 'UNKNOWN_TABLE',
|
|
143
|
+
retriable: false,
|
|
144
|
+
},
|
|
145
|
+
emittedChanges: [],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
// Run authorization if provided
|
|
149
|
+
if (authorize) {
|
|
150
|
+
const authResult = await authorize(ctx, op);
|
|
151
|
+
if (authResult !== true) {
|
|
152
|
+
return {
|
|
153
|
+
result: {
|
|
154
|
+
opIndex,
|
|
155
|
+
status: 'error',
|
|
156
|
+
error: authResult.error,
|
|
157
|
+
code: authResult.code,
|
|
158
|
+
retriable: authResult.retriable ?? false,
|
|
159
|
+
},
|
|
160
|
+
emittedChanges: [],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Handle delete
|
|
165
|
+
if (op.op === 'delete') {
|
|
166
|
+
const existing = await trx.selectFrom(table).selectAll()
|
|
167
|
+
.where(ref(primaryKey), '=', op.row_id)
|
|
168
|
+
.executeTakeFirst();
|
|
169
|
+
if (!existing) {
|
|
170
|
+
return { result: { opIndex, status: 'applied' }, emittedChanges: [] };
|
|
171
|
+
}
|
|
172
|
+
// Extract scopes from existing row for the delete emission
|
|
173
|
+
const scopes = extractScopesImpl(existing);
|
|
174
|
+
await trx.deleteFrom(table)
|
|
175
|
+
.where(ref(primaryKey), '=', op.row_id)
|
|
176
|
+
.execute();
|
|
177
|
+
const emitted = {
|
|
178
|
+
table,
|
|
179
|
+
row_id: op.row_id,
|
|
180
|
+
op: 'delete',
|
|
181
|
+
row_json: null,
|
|
182
|
+
row_version: null,
|
|
183
|
+
scopes,
|
|
184
|
+
};
|
|
185
|
+
return {
|
|
186
|
+
result: { opIndex, status: 'applied' },
|
|
187
|
+
emittedChanges: [emitted],
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
// Handle upsert
|
|
191
|
+
const rawPayload = op.payload ?? {};
|
|
192
|
+
const payload = transformInbound
|
|
193
|
+
? transformInbound(rawPayload, {
|
|
194
|
+
schemaVersion: ctx.schemaVersion,
|
|
195
|
+
})
|
|
196
|
+
: rawPayload;
|
|
197
|
+
// Check for existing row
|
|
198
|
+
const existing = await trx.selectFrom(table).selectAll()
|
|
199
|
+
.where(ref(primaryKey), '=', op.row_id)
|
|
200
|
+
.executeTakeFirst();
|
|
201
|
+
const existingRow = existing;
|
|
202
|
+
const existingVersion = existingRow?.[versionColumn] ?? 0;
|
|
203
|
+
// Check version conflict
|
|
204
|
+
if (existing &&
|
|
205
|
+
op.base_version != null &&
|
|
206
|
+
existingVersion !== op.base_version) {
|
|
207
|
+
return {
|
|
208
|
+
result: {
|
|
209
|
+
opIndex,
|
|
210
|
+
status: 'conflict',
|
|
211
|
+
message: `Version conflict: server=${existingVersion}, base=${op.base_version}`,
|
|
212
|
+
server_version: existingVersion,
|
|
213
|
+
server_row: transformOutbound
|
|
214
|
+
? transformOutbound(existing)
|
|
215
|
+
: existing,
|
|
216
|
+
},
|
|
217
|
+
emittedChanges: [],
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
// If the client provided a base version, they expected this row to exist.
|
|
221
|
+
// A missing row usually indicates stale local state after a server reset.
|
|
222
|
+
if (!existing && op.base_version != null) {
|
|
223
|
+
return {
|
|
224
|
+
result: {
|
|
225
|
+
opIndex,
|
|
226
|
+
status: 'error',
|
|
227
|
+
error: 'ROW_NOT_FOUND_FOR_BASE_VERSION',
|
|
228
|
+
code: 'ROW_MISSING',
|
|
229
|
+
retriable: false,
|
|
230
|
+
},
|
|
231
|
+
emittedChanges: [],
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const nextVersion = existingVersion + 1;
|
|
235
|
+
let updated;
|
|
236
|
+
let constraintError = null;
|
|
237
|
+
try {
|
|
238
|
+
if (existing) {
|
|
239
|
+
// Update - merge payload with existing
|
|
240
|
+
const updateSet = {
|
|
241
|
+
...payload,
|
|
242
|
+
[versionColumn]: nextVersion,
|
|
243
|
+
};
|
|
244
|
+
// Don't update primary key or scope columns
|
|
245
|
+
delete updateSet[primaryKey];
|
|
246
|
+
for (const col of Object.values(scopeColumns)) {
|
|
247
|
+
delete updateSet[col];
|
|
248
|
+
}
|
|
249
|
+
await trx.updateTable(table)
|
|
250
|
+
.set(updateSet)
|
|
251
|
+
.where(ref(primaryKey), '=', op.row_id)
|
|
252
|
+
.execute();
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
// Insert
|
|
256
|
+
const insertValues = {
|
|
257
|
+
...payload,
|
|
258
|
+
[primaryKey]: op.row_id,
|
|
259
|
+
[versionColumn]: 1,
|
|
260
|
+
};
|
|
261
|
+
await trx.insertInto(table)
|
|
262
|
+
.values(insertValues)
|
|
263
|
+
.execute();
|
|
264
|
+
}
|
|
265
|
+
// Read back the updated row
|
|
266
|
+
updated = await trx.selectFrom(table).selectAll()
|
|
267
|
+
.where(ref(primaryKey), '=', op.row_id)
|
|
268
|
+
.executeTakeFirstOrThrow();
|
|
269
|
+
}
|
|
270
|
+
catch (err) {
|
|
271
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
272
|
+
if (!isConstraintViolationError(message)) {
|
|
273
|
+
throw err;
|
|
274
|
+
}
|
|
275
|
+
constraintError = {
|
|
276
|
+
message,
|
|
277
|
+
code: classifyConstraintViolationCode(message),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
if (constraintError) {
|
|
281
|
+
return {
|
|
282
|
+
result: {
|
|
283
|
+
opIndex,
|
|
284
|
+
status: 'error',
|
|
285
|
+
error: constraintError.message,
|
|
286
|
+
code: constraintError.code,
|
|
287
|
+
retriable: false,
|
|
288
|
+
},
|
|
289
|
+
emittedChanges: [],
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
if (!updated) {
|
|
293
|
+
throw new Error('Updated row is missing after applyOperation');
|
|
294
|
+
}
|
|
295
|
+
const updatedRow = updated;
|
|
296
|
+
const rowVersion = updatedRow[versionColumn] ?? 1;
|
|
297
|
+
// Extract scopes from updated row
|
|
298
|
+
const scopes = extractScopesImpl(updatedRow);
|
|
299
|
+
// Transform outbound for emitted change
|
|
300
|
+
const rowJson = transformOutbound
|
|
301
|
+
? transformOutbound(updated)
|
|
302
|
+
: updated;
|
|
303
|
+
const emitted = {
|
|
304
|
+
table,
|
|
305
|
+
row_id: op.row_id,
|
|
306
|
+
op: 'upsert',
|
|
307
|
+
row_json: rowJson,
|
|
308
|
+
row_version: rowVersion,
|
|
309
|
+
scopes,
|
|
310
|
+
};
|
|
311
|
+
return {
|
|
312
|
+
result: { opIndex, status: 'applied' },
|
|
313
|
+
emittedChanges: [emitted],
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
return {
|
|
317
|
+
table,
|
|
318
|
+
scopePatterns,
|
|
319
|
+
dependsOn,
|
|
320
|
+
snapshotChunkTtlMs,
|
|
321
|
+
resolveScopes,
|
|
322
|
+
extractScopes: extractScopesImpl,
|
|
323
|
+
snapshot: options.snapshot ?? defaultSnapshot,
|
|
324
|
+
applyOperation: options.applyOperation ?? defaultApplyOperation,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
//# sourceMappingURL=create-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-handler.js","sourceRoot":"","sources":["../../src/shapes/create-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA8BnE,SAAS,+BAA+B,CAAC,OAAe,EAAU;IAChE,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,qBAAqB,CAAC;IAClE,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,mBAAmB,CAAC;IAC9D,IAAI,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC;QAAE,OAAO,wBAAwB,CAAC;IACxE,OAAO,sBAAsB,CAAC;AAAA,CAC/B;AAED,SAAS,0BAA0B,CAAC,OAAe,EAAW;IAC5D,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,OAAO,CACL,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC;QACjC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC/B,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC;QAClC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAC9B,CAAC;AAAA,CACH;AAoGD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,mBAAmB,CAKjC,OAAkE,EACpC;IAY9B,MAAM,EACJ,KAAK,EACL,MAAM,EAAE,SAAS,EACjB,UAAU,GAAG,IAAI,EACjB,aAAa,GAAG,gBAAgB,EAChC,SAAS,EACT,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,SAAS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I,qBAAqB;KAChE,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shapes/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shapes/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|