@smart-data-engines/sde 0.1.0-dev.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/LICENSE +201 -0
- package/NOTICE +13 -0
- package/README.md +153 -0
- package/bin/weather.mjs +32 -0
- package/dist/_usage.d.ts +30 -0
- package/dist/_usage.js +194 -0
- package/dist/_usage.js.map +1 -0
- package/dist/bulk.d.ts +9 -0
- package/dist/bulk.js +83 -0
- package/dist/bulk.js.map +1 -0
- package/dist/canonical.d.ts +46 -0
- package/dist/canonical.js +150 -0
- package/dist/canonical.js.map +1 -0
- package/dist/capabilities.d.ts +48 -0
- package/dist/capabilities.js +62 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/cutover.d.ts +36 -0
- package/dist/cutover.js +219 -0
- package/dist/cutover.js.map +1 -0
- package/dist/demo/model.d.ts +28 -0
- package/dist/demo/model.js +40 -0
- package/dist/demo/model.js.map +1 -0
- package/dist/demo/project.d.ts +19 -0
- package/dist/demo/project.js +128 -0
- package/dist/demo/project.js.map +1 -0
- package/dist/demo/weather.d.ts +73 -0
- package/dist/demo/weather.js +334 -0
- package/dist/demo/weather.js.map +1 -0
- package/dist/engines/_clickhouse-connection.d.ts +17 -0
- package/dist/engines/_clickhouse-connection.js +182 -0
- package/dist/engines/_clickhouse-connection.js.map +1 -0
- package/dist/engines/_tls-peer-identity.d.ts +2 -0
- package/dist/engines/_tls-peer-identity.js +23 -0
- package/dist/engines/_tls-peer-identity.js.map +1 -0
- package/dist/engines/_write-fences.d.ts +51 -0
- package/dist/engines/_write-fences.js +189 -0
- package/dist/engines/_write-fences.js.map +1 -0
- package/dist/engines/clickhouse.d.ts +193 -0
- package/dist/engines/clickhouse.js +899 -0
- package/dist/engines/clickhouse.js.map +1 -0
- package/dist/engines/postgres.d.ts +293 -0
- package/dist/engines/postgres.js +981 -0
- package/dist/engines/postgres.js.map +1 -0
- package/dist/errors.d.ts +89 -0
- package/dist/errors.js +90 -0
- package/dist/errors.js.map +1 -0
- package/dist/frozen-verification.d.ts +26 -0
- package/dist/frozen-verification.js +67 -0
- package/dist/frozen-verification.js.map +1 -0
- package/dist/generation.d.ts +34 -0
- package/dist/generation.js +81 -0
- package/dist/generation.js.map +1 -0
- package/dist/groups.d.ts +17 -0
- package/dist/groups.js +66 -0
- package/dist/groups.js.map +1 -0
- package/dist/hashing.d.ts +68 -0
- package/dist/hashing.js +146 -0
- package/dist/hashing.js.map +1 -0
- package/dist/in-place-index.d.ts +43 -0
- package/dist/in-place-index.js +272 -0
- package/dist/in-place-index.js.map +1 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/inspection.d.ts +19 -0
- package/dist/inspection.js +31 -0
- package/dist/inspection.js.map +1 -0
- package/dist/internal.d.ts +42 -0
- package/dist/internal.js +56 -0
- package/dist/internal.js.map +1 -0
- package/dist/layout.d.ts +36 -0
- package/dist/layout.js +62 -0
- package/dist/layout.js.map +1 -0
- package/dist/migration.d.ts +197 -0
- package/dist/migration.js +592 -0
- package/dist/migration.js.map +1 -0
- package/dist/model.d.ts +93 -0
- package/dist/model.js +313 -0
- package/dist/model.js.map +1 -0
- package/dist/physical.d.ts +128 -0
- package/dist/physical.js +421 -0
- package/dist/physical.js.map +1 -0
- package/dist/placement.d.ts +157 -0
- package/dist/placement.js +651 -0
- package/dist/placement.js.map +1 -0
- package/dist/provisioning.d.ts +6 -0
- package/dist/provisioning.js +45 -0
- package/dist/provisioning.js.map +1 -0
- package/dist/query.d.ts +68 -0
- package/dist/query.js +340 -0
- package/dist/query.js.map +1 -0
- package/dist/routing.d.ts +25 -0
- package/dist/routing.js +35 -0
- package/dist/routing.js.map +1 -0
- package/dist/schema.d.ts +110 -0
- package/dist/schema.js +337 -0
- package/dist/schema.js.map +1 -0
- package/dist/session.d.ts +195 -0
- package/dist/session.js +870 -0
- package/dist/session.js.map +1 -0
- package/dist/shapes.d.ts +30 -0
- package/dist/shapes.js +112 -0
- package/dist/shapes.js.map +1 -0
- package/dist/staging.d.ts +29 -0
- package/dist/staging.js +214 -0
- package/dist/staging.js.map +1 -0
- package/dist/telemetry.d.ts +468 -0
- package/dist/telemetry.js +872 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/testing/loader.d.ts +38 -0
- package/dist/testing/loader.js +86 -0
- package/dist/testing/loader.js.map +1 -0
- package/dist/testing/memory.d.ts +131 -0
- package/dist/testing/memory.js +311 -0
- package/dist/testing/memory.js.map +1 -0
- package/dist/timestamp.d.ts +20 -0
- package/dist/timestamp.js +89 -0
- package/dist/timestamp.js.map +1 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.js +100 -0
- package/dist/types.js.map +1 -0
- package/dist/verification.d.ts +41 -0
- package/dist/verification.js +169 -0
- package/dist/verification.js.map +1 -0
- package/dist/watermark.d.ts +103 -0
- package/dist/watermark.js +170 -0
- package/dist/watermark.js.map +1 -0
- package/dist/write-fence.d.ts +58 -0
- package/dist/write-fence.js +225 -0
- package/dist/write-fence.js.map +1 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Smart Data Engine client libraries
|
|
2
|
+
Copyright 2026 Smart Data Engines
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Smart Data Engines
|
|
5
|
+
(https://smartdataengines.com).
|
|
6
|
+
|
|
7
|
+
The libraries in this repository are the client side of Smart Data Engine: they
|
|
8
|
+
declare a data model, cache a placement map, route operations and manage schema.
|
|
9
|
+
They connect to database engines directly and they work without an account.
|
|
10
|
+
|
|
11
|
+
The control plane - the placement planner, the scoring model and the migration
|
|
12
|
+
orchestrator - is a separate, private program and is not covered by this notice
|
|
13
|
+
or by this licence.
|
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# @smart-data-engines/sde — TypeScript client library
|
|
2
|
+
|
|
3
|
+
Declare your data model. We decide which database engine each part of it lives in, how it is laid out
|
|
4
|
+
there, and when it should move.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { entity, ref, buildModel, T } from '@smart-data-engines/sde'
|
|
8
|
+
|
|
9
|
+
const User = entity('User', {
|
|
10
|
+
fields: { id: T.uuid, email: T.string },
|
|
11
|
+
pii: ['email'],
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const Order = entity('Order', {
|
|
15
|
+
fields: { id: T.uuid, total: T.decimal(12, 2), placedAt: T.timestamptz },
|
|
16
|
+
relations: { user: ref('User') },
|
|
17
|
+
residency: 'EU',
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const Event = entity('Event', {
|
|
21
|
+
fields: { id: T.uuid, name: T.string, at: T.timestamptz },
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const model = buildModel([User, Order, Event])
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`User` and `Order` are related, so they are placed together. `Event` is joined to nothing, so it is
|
|
28
|
+
free to go somewhere built for it. That split is the decision most applications get wrong once, at the
|
|
29
|
+
start, and never revisit.
|
|
30
|
+
|
|
31
|
+
## Status: Tier 2 for PostgreSQL and ClickHouse, plus hashed identifiers
|
|
32
|
+
|
|
33
|
+
| Tier | What it covers | Here? |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| 0 | model, canonical IR and version, groups, shapes and ids, map parsing and refusals, routing | **yes** |
|
|
36
|
+
| 1 | telemetry: measurement, window aggregation, local buffering | **yes** |
|
|
37
|
+
| 2 | schema creation and migration participation | **yes**, for `postgres` and `clickhouse` |
|
|
38
|
+
| 3 | framework integrations, pooling | not yet |
|
|
39
|
+
| — | hashed identifiers (§2a), a mode rather than a tier | **yes** |
|
|
40
|
+
|
|
41
|
+
The shared vectors for Tier 1 and Tier 2 were written **before** this library claimed those tiers,
|
|
42
|
+
which is what §10 of the format contract says has to happen and is worth knowing about the claim:
|
|
43
|
+
`telemetry/`, `schema/` and `migration/` exist because of it. Closing that gap found five defects in
|
|
44
|
+
the reference implementation, which had been claiming those tiers with nothing shared to check them.
|
|
45
|
+
|
|
46
|
+
### Where the two libraries differ, and why
|
|
47
|
+
|
|
48
|
+
Two differences, both deliberate.
|
|
49
|
+
|
|
50
|
+
**Tier 2 here is asynchronous.** Node's I/O is asynchronous, so a synchronous wrapper around a driver
|
|
51
|
+
means blocking the event loop - a worse thing to do to your process than a `Promise` in a signature.
|
|
52
|
+
The split follows the tiers exactly: everything up to and including telemetry touches no socket and
|
|
53
|
+
stays synchronous, and a `Session` is *opened* rather than constructed, because the forward-only map
|
|
54
|
+
check reads a table and a constructor cannot await. You therefore cannot hold a session whose check
|
|
55
|
+
has not run.
|
|
56
|
+
|
|
57
|
+
**The ClickHouse adapter has no driver dependency.** There is an official Node client and it requires
|
|
58
|
+
Node 20 or newer; this package supports Node 18 to 26 and its CI runs all five majors. Dropping Node 18
|
|
59
|
+
would narrow a published claim to gain a dependency, and pinning a superseded version of the client
|
|
60
|
+
is the conflict the zero-dependency rule exists to avoid - so neither. ClickHouse's HTTP interface
|
|
61
|
+
needs no client, and this adapter therefore owns both of its timeouts instead of inheriting a
|
|
62
|
+
driver's defaults, which is how the reference implementation discovered that its ClickHouse connect
|
|
63
|
+
timeout never fired.
|
|
64
|
+
|
|
65
|
+
`pg` is an **optional peer dependency**: install it if you place a group in PostgreSQL, and keep the
|
|
66
|
+
version you already chose. Importing this library resolves neither driver, and a test over the import
|
|
67
|
+
closure of `src/index.ts` pins that - which is what makes the no-account mode free and
|
|
68
|
+
`docs/observability.md` true.
|
|
69
|
+
|
|
70
|
+
`hashIdentifiers` is listed separately because hashing is orthogonal to the tiers - a complete Tier 0
|
|
71
|
+
library may omit it. What is not optional is agreement: run two services in two languages against one
|
|
72
|
+
model, and if they derive different digests they compute different `model_version` values and each
|
|
73
|
+
refuses the other's placement map. This library passes `conformance/vectors/hashing/`, which is the
|
|
74
|
+
only claim worth making about it.
|
|
75
|
+
|
|
76
|
+
## Why the model is declared rather than inferred
|
|
77
|
+
|
|
78
|
+
TypeScript's types are erased before the code runs, so a library cannot read them the way the Python
|
|
79
|
+
one reads annotations. The model is stated as values instead.
|
|
80
|
+
|
|
81
|
+
That is not a workaround, and it is the reason this was a good second implementation to write. Anything
|
|
82
|
+
the format contract had left implicit - anything that was really "whatever Python's introspection
|
|
83
|
+
produces" - had nowhere to hide here, because nothing is introspected.
|
|
84
|
+
|
|
85
|
+
It found one immediately, and it was not small. JavaScript compares strings by UTF-16 code unit; the
|
|
86
|
+
contract requires code point order. For anything in the Basic Multilingual Plane the two agree, so no
|
|
87
|
+
test written with Latin or CJK identifiers can see the difference. Above U+FFFF they diverge: an astral
|
|
88
|
+
character is a surrogate pair starting at 0xD800, so `Array.prototype.sort` places every emoji *before*
|
|
89
|
+
U+E000 while code point order places it after. One such field name would have hashed differently in
|
|
90
|
+
Python and TypeScript, the control plane would have seen two models where there was one, and nothing
|
|
91
|
+
would have failed until half a fleet was writing to the wrong tables.
|
|
92
|
+
|
|
93
|
+
Hence `compareCodePoints` in `src/canonical.ts`, and two vectors that make sure nobody replaces it
|
|
94
|
+
with `.sort()`.
|
|
95
|
+
|
|
96
|
+
## Conformance
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm install
|
|
100
|
+
npx vitest run
|
|
101
|
+
|
|
102
|
+
# with both engines, which is what the Tier 2 slices need
|
|
103
|
+
export SDE_POSTGRES_DSN=postgresql://postgres:sde@127.0.0.1:55432/sde
|
|
104
|
+
export SDE_CLICKHOUSE_DSN=clickhouse://default:sde@127.0.0.1:58123/sde
|
|
105
|
+
npx vitest run
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The vectors live in `../conformance` and are shared with every other language. A divergence is a red
|
|
109
|
+
test for whoever caused it, rather than an operation written to the wrong engine in production.
|
|
110
|
+
|
|
111
|
+
If you are porting this to another language, read `../docs/format-contract.md` first. It is meant to be
|
|
112
|
+
sufficient on its own; if it is not, that is a bug in the document and worth reporting as one.
|
|
113
|
+
|
|
114
|
+
## Licence
|
|
115
|
+
|
|
116
|
+
Apache-2.0.
|
|
117
|
+
|
|
118
|
+
## Timestamp values
|
|
119
|
+
|
|
120
|
+
Both adapters return `Timestamp`, an immutable value with microsecond precision, for `timestamp`
|
|
121
|
+
and `timestamptz`. `Date` is still accepted on writes. Use `Timestamp.from(isoText)` for six-digit
|
|
122
|
+
inputs, `.toISOString()` for text and `.epochMicroseconds` for exact comparison; `.toDate()` refuses
|
|
123
|
+
if converting would lose digits. See [exact timestamps](../docs/timestamps.md) for examples and
|
|
124
|
+
migration from the previous `Date` return type.
|
|
125
|
+
|
|
126
|
+
## Bound migration verification
|
|
127
|
+
|
|
128
|
+
Configure `Session.open(..., { projectId })` from your local enrollment manifest. Load the
|
|
129
|
+
controller's request with `VerificationRequest.fromRecord` and call `verify(session, group,
|
|
130
|
+
{ request })`; send `verifyRecord(report)` back. The complete request is checked before comparison,
|
|
131
|
+
and row-level differences remain local. See [the request protocol](../docs/format-contract.md#7b-verification-requests-and-bound-reports).
|
|
132
|
+
Loaded placement maps are immutable snapshots. Load a new document rather than modifying a layout
|
|
133
|
+
or copying an object with its old fingerprint.
|
|
134
|
+
|
|
135
|
+
Batch operations: [logical bulk writes](../docs/bulk-writes.md) document `save_many` / `saveMany`,
|
|
136
|
+
bounds, source/copy ordering and uncertain outcomes.
|
|
137
|
+
|
|
138
|
+
[Logical reads and exact summaries](../docs/logical-reads.md) cover scan, count and summarize,
|
|
139
|
+
including portable keyset pages, typed values and explicit failure semantics.
|
|
140
|
+
|
|
141
|
+
## Local Weather starter
|
|
142
|
+
|
|
143
|
+
The unreleased [Weather starter](https://github.com/Smart-Data-Engines/smart-data-engine-sdk/blob/main/docs/weather-starter.md)
|
|
144
|
+
installs from reviewed artifacts and exercises logical operations with restricted runtime credentials.
|
|
145
|
+
It includes local setup, telemetry, operator handoffs and an ownership-checked reset.
|
|
146
|
+
|
|
147
|
+
## Test-tool dependencies
|
|
148
|
+
|
|
149
|
+
The Node 18/20/22/24/26 matrix uses the tool versions and supported invocation described in
|
|
150
|
+
[the test-toolchain record](../docs/test-toolchain.md). That record distinguishes the SDK runtime
|
|
151
|
+
from development dependencies and documents the remaining development-server advisory.
|
|
152
|
+
|
|
153
|
+
Engine credentials and verified TLS configuration: [connection guide](../docs/engine-connections.md).
|
package/bin/weather.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Runtime entry point; bootstrap and the local operator use the Python sde-weather command. */
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
|
+
import { parseArgs } from 'node:util'
|
|
5
|
+
import { DemoRefused } from '../dist/demo/project.js'
|
|
6
|
+
import { runWeather, workloads } from '../dist/demo/weather.js'
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
const { values, positionals } = parseArgs({ allowPositionals: true, options: {
|
|
10
|
+
directory: { type: 'string' }, iterations: { type: 'string', default: '10' },
|
|
11
|
+
'batch-size': { type: 'string', default: '10' }, 'interval-ms': { type: 'string', default: '100' },
|
|
12
|
+
'recovery-ms': { type: 'string', default: '10000' }, workload: { type: 'string', default: 'mixed' },
|
|
13
|
+
help: { type: 'boolean' },
|
|
14
|
+
} })
|
|
15
|
+
if (values.help) {
|
|
16
|
+
console.log(`sde-weather-ts --directory DIR run [--iterations 10] [--batch-size 10] [--interval-ms 100] [--recovery-ms 10000] [--workload ${workloads.join('|')}]`)
|
|
17
|
+
} else {
|
|
18
|
+
const workload = workloads.find(item => item === (values.workload ?? 'mixed'))
|
|
19
|
+
if (positionals.length !== 1 || positionals[0] !== 'run' || !values.directory ||
|
|
20
|
+
workload === undefined) throw new DemoRefused('Use --help for the local runtime command.')
|
|
21
|
+
const result = await runWeather(resolve(values.directory), {
|
|
22
|
+
iterations: Number(values.iterations), batchSize: Number(values['batch-size']),
|
|
23
|
+
intervalMs: Number(values['interval-ms']), recoveryMs: Number(values['recovery-ms']),
|
|
24
|
+
workload,
|
|
25
|
+
})
|
|
26
|
+
console.log(JSON.stringify(result))
|
|
27
|
+
}
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error(JSON.stringify({ error: error instanceof Error ? error.name : 'UnknownError', message:
|
|
30
|
+
error instanceof DemoRefused ? error.message : 'The local operation did not complete. Inspect the run report before retrying.' }))
|
|
31
|
+
process.exitCode = error instanceof DemoRefused ? 2 : 3
|
|
32
|
+
}
|
package/dist/_usage.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare function checkScope(): void;
|
|
2
|
+
export declare function withSession<T>(owner: object, body: () => T): T;
|
|
3
|
+
export declare class UsageGate {
|
|
4
|
+
private operationOwner;
|
|
5
|
+
private operationDepth;
|
|
6
|
+
private transactionOwner;
|
|
7
|
+
private checkTransaction;
|
|
8
|
+
operation<T>(body: () => Promise<T>): Promise<T>;
|
|
9
|
+
transaction<T>(body: () => Promise<T>): Promise<T>;
|
|
10
|
+
seal(): void;
|
|
11
|
+
idle(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare class SessionUsage {
|
|
14
|
+
private readonly owner;
|
|
15
|
+
private closed;
|
|
16
|
+
private busy;
|
|
17
|
+
private transactionScope;
|
|
18
|
+
constructor(owner: object);
|
|
19
|
+
isOwner(owner: object): boolean;
|
|
20
|
+
check(): void;
|
|
21
|
+
group(name: string): void;
|
|
22
|
+
operation<T>(body: () => Promise<T>): Promise<T>;
|
|
23
|
+
transaction<T>(group: string, body: () => Promise<T>): Promise<T>;
|
|
24
|
+
idle(): void;
|
|
25
|
+
maintenance<T>(body: () => Promise<T>): Promise<T>;
|
|
26
|
+
seal(): void;
|
|
27
|
+
close(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare function registerSession(owner: object, usage: SessionUsage): void;
|
|
30
|
+
export declare function withReader<T>(reader: object, body: () => Promise<T>): Promise<T>;
|
package/dist/_usage.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/** Local operation/transaction ownership across async execution chains. */
|
|
2
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
+
import { ModelPlanningError, ResourceBusy, ResourceClosed } from './errors.js';
|
|
4
|
+
const sessionOwner = new AsyncLocalStorage();
|
|
5
|
+
const operation = new AsyncLocalStorage();
|
|
6
|
+
const transaction = new AsyncLocalStorage();
|
|
7
|
+
export function checkScope() {
|
|
8
|
+
let scope = transaction.getStore();
|
|
9
|
+
while (scope !== undefined) {
|
|
10
|
+
if (!scope.active)
|
|
11
|
+
throw new ResourceClosed('the inherited transaction scope has already ended');
|
|
12
|
+
scope = scope.parent;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function withSession(owner, body) {
|
|
16
|
+
checkScope();
|
|
17
|
+
const logical = sessionScope.getStore();
|
|
18
|
+
if (logical !== undefined && logical.active && !logical.usage.isOwner(owner)) {
|
|
19
|
+
throw new ResourceBusy('another session owns the current transaction scope');
|
|
20
|
+
}
|
|
21
|
+
const scope = transaction.getStore();
|
|
22
|
+
if (scope !== undefined && scope.session !== owner) {
|
|
23
|
+
throw new ResourceBusy('another session owns the current transaction scope');
|
|
24
|
+
}
|
|
25
|
+
return sessionOwner.run(owner, body);
|
|
26
|
+
}
|
|
27
|
+
export class UsageGate {
|
|
28
|
+
operationOwner;
|
|
29
|
+
operationDepth = 0;
|
|
30
|
+
transactionOwner;
|
|
31
|
+
checkTransaction() {
|
|
32
|
+
checkScope();
|
|
33
|
+
if (this.transactionOwner === undefined)
|
|
34
|
+
return;
|
|
35
|
+
let scope = transaction.getStore();
|
|
36
|
+
while (scope !== undefined && scope.gate !== this)
|
|
37
|
+
scope = scope.parent;
|
|
38
|
+
if (scope !== this.transactionOwner || scope.session !== sessionOwner.getStore()) {
|
|
39
|
+
throw new ResourceBusy('the connection is owned by another active transaction scope');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async operation(body) {
|
|
43
|
+
this.checkTransaction();
|
|
44
|
+
const owner = operation.getStore() ?? {};
|
|
45
|
+
if (this.operationOwner !== undefined && this.operationOwner !== owner) {
|
|
46
|
+
throw new ResourceBusy('the connection already has an operation in progress');
|
|
47
|
+
}
|
|
48
|
+
this.operationOwner = owner;
|
|
49
|
+
this.operationDepth++;
|
|
50
|
+
return operation.run(owner, async () => {
|
|
51
|
+
let failed = false;
|
|
52
|
+
try {
|
|
53
|
+
return await body();
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
failed = true;
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
this.operationDepth--;
|
|
61
|
+
if (this.operationDepth === 0)
|
|
62
|
+
this.operationOwner = undefined;
|
|
63
|
+
if (!failed)
|
|
64
|
+
checkScope();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async transaction(body) {
|
|
69
|
+
this.checkTransaction();
|
|
70
|
+
if (this.operationOwner !== undefined) {
|
|
71
|
+
throw new ResourceBusy('a transaction cannot begin while an operation is in progress');
|
|
72
|
+
}
|
|
73
|
+
const previous = this.transactionOwner;
|
|
74
|
+
const scope = {
|
|
75
|
+
gate: this, parent: transaction.getStore(), session: sessionOwner.getStore(), active: true,
|
|
76
|
+
};
|
|
77
|
+
this.transactionOwner = scope;
|
|
78
|
+
return transaction.run(scope, async () => {
|
|
79
|
+
try {
|
|
80
|
+
return await body();
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
scope.active = false;
|
|
84
|
+
this.transactionOwner = previous;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
seal() { if (this.transactionOwner !== undefined)
|
|
89
|
+
this.transactionOwner.active = false; }
|
|
90
|
+
idle() {
|
|
91
|
+
if (this.operationOwner !== undefined) {
|
|
92
|
+
if (this.transactionOwner !== undefined)
|
|
93
|
+
this.transactionOwner.active = false;
|
|
94
|
+
throw new ResourceBusy('finish all operations before leaving the transaction');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const sessionScope = new AsyncLocalStorage();
|
|
99
|
+
export class SessionUsage {
|
|
100
|
+
owner;
|
|
101
|
+
closed = false;
|
|
102
|
+
busy = false;
|
|
103
|
+
transactionScope;
|
|
104
|
+
constructor(owner) {
|
|
105
|
+
this.owner = owner;
|
|
106
|
+
}
|
|
107
|
+
isOwner(owner) { return this.owner === owner; }
|
|
108
|
+
check() {
|
|
109
|
+
checkScope();
|
|
110
|
+
const scope = sessionScope.getStore();
|
|
111
|
+
if (this.closed || (scope !== undefined && !scope.active)) {
|
|
112
|
+
throw new ResourceClosed('the session or inherited transaction scope has ended');
|
|
113
|
+
}
|
|
114
|
+
if (this.transactionScope !== undefined && scope !== this.transactionScope) {
|
|
115
|
+
throw new ResourceBusy('the session belongs to another active transaction context');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
group(name) {
|
|
119
|
+
this.check();
|
|
120
|
+
if (this.transactionScope !== undefined && this.transactionScope.group !== name) {
|
|
121
|
+
throw new ModelPlanningError("the operation is outside the active transaction's colocation group");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async operation(body) {
|
|
125
|
+
this.check();
|
|
126
|
+
if (this.busy)
|
|
127
|
+
throw new ResourceBusy('the session already has an operation in progress');
|
|
128
|
+
this.busy = true;
|
|
129
|
+
let failed = false;
|
|
130
|
+
try {
|
|
131
|
+
return await withSession(this.owner, async () => {
|
|
132
|
+
try {
|
|
133
|
+
return await body();
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
failed = true;
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
if (!failed)
|
|
141
|
+
this.check();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
this.busy = false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async transaction(group, body) {
|
|
150
|
+
this.group(group);
|
|
151
|
+
if (this.busy)
|
|
152
|
+
throw new ResourceBusy('finish the session operation before beginning a transaction');
|
|
153
|
+
const previous = this.transactionScope;
|
|
154
|
+
const scope = { usage: this, group, active: true };
|
|
155
|
+
this.transactionScope = scope;
|
|
156
|
+
try {
|
|
157
|
+
return await sessionScope.run(scope, () => withSession(this.owner, body));
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
scope.active = false;
|
|
161
|
+
this.transactionScope = previous;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
idle() {
|
|
165
|
+
if (this.busy) {
|
|
166
|
+
if (this.transactionScope !== undefined)
|
|
167
|
+
this.transactionScope.active = false;
|
|
168
|
+
throw new ResourceBusy('finish all session operations before leaving the transaction');
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async maintenance(body) {
|
|
172
|
+
this.check();
|
|
173
|
+
if (this.transactionScope !== undefined)
|
|
174
|
+
throw new ResourceBusy('run migration helpers outside application transactions');
|
|
175
|
+
return this.operation(body);
|
|
176
|
+
}
|
|
177
|
+
seal() { if (this.transactionScope !== undefined)
|
|
178
|
+
this.transactionScope.active = false; }
|
|
179
|
+
close() {
|
|
180
|
+
if (this.busy || this.transactionScope !== undefined) {
|
|
181
|
+
throw new ResourceBusy('cannot close a session while its operation or transaction is active');
|
|
182
|
+
}
|
|
183
|
+
this.closed = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const sessions = new WeakMap();
|
|
187
|
+
export function registerSession(owner, usage) { sessions.set(owner, usage); }
|
|
188
|
+
export async function withReader(reader, body) {
|
|
189
|
+
const usage = sessions.get(reader);
|
|
190
|
+
if (usage === undefined)
|
|
191
|
+
return body();
|
|
192
|
+
return usage.maintenance(body);
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=_usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_usage.js","sourceRoot":"","sources":["../src/_usage.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAQ9E,MAAM,YAAY,GAAG,IAAI,iBAAiB,EAAU,CAAA;AACpD,MAAM,SAAS,GAAG,IAAI,iBAAiB,EAAU,CAAA;AACjD,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAoB,CAAA;AAE7D,MAAM,UAAU,UAAU;IACxB,IAAI,KAAK,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAA;IAClC,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,MAAM,IAAI,cAAc,CAAC,mDAAmD,CAAC,CAAA;QAChG,KAAK,GAAG,KAAK,CAAC,MAAM,CAAA;IACtB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAI,KAAa,EAAE,IAAa;IACzD,UAAU,EAAE,CAAA;IACZ,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAA;IACvC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7E,MAAM,IAAI,YAAY,CAAC,oDAAoD,CAAC,CAAA;IAC9E,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAA;IACpC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QACnD,MAAM,I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AA;IACtC,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;AAChC,CAAC"}
|
package/dist/bulk.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Row } from './session.js';
|
|
2
|
+
export declare const MAX_BATCH_ROWS = 1000;
|
|
3
|
+
export declare const MAX_BATCH_VALUES = 60000;
|
|
4
|
+
export interface BulkWritable {
|
|
5
|
+
insertMany(table: string, rows: readonly Readonly<Row>[]): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare function bulkWriter(engine: object): BulkWritable;
|
|
8
|
+
export declare function batchColumns(rows: readonly Readonly<Row>[], extraColumns?: number): string[];
|
|
9
|
+
export declare function snapshotRows(rows: readonly Readonly<Row>[]): Row[];
|