@dxos/util 0.6.12-main.78ddbdf → 0.6.12-main.89e9959
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/lib/browser/index.mjs +0 -51
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +0 -51
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +0 -51
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +6 -8
- package/src/index.ts +0 -1
- package/dist/types/src/params.d.ts +0 -22
- package/dist/types/src/params.d.ts.map +0 -1
- package/dist/types/src/params.test.d.ts +0 -2
- package/dist/types/src/params.test.d.ts.map +0 -1
- package/src/params.test.ts +0 -37
- package/src/params.ts +0 -70
|
@@ -1168,55 +1168,6 @@ var inferRecordOrder = (objectMap, order = []) => {
|
|
|
1168
1168
|
}, {}), objectMap);
|
|
1169
1169
|
};
|
|
1170
1170
|
|
|
1171
|
-
// packages/common/util/src/params.ts
|
|
1172
|
-
import { AST } from "@effect/schema";
|
|
1173
|
-
import { decamelize } from "xcase";
|
|
1174
|
-
var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKeyAnnotation");
|
|
1175
|
-
var ParamKeyAnnotation = (value) => (self) => self.annotations({
|
|
1176
|
-
[ParamKeyAnnotationId]: value
|
|
1177
|
-
});
|
|
1178
|
-
var Params = class {
|
|
1179
|
-
constructor(_schema) {
|
|
1180
|
-
this._schema = _schema;
|
|
1181
|
-
}
|
|
1182
|
-
/**
|
|
1183
|
-
* Parse URL params.
|
|
1184
|
-
* @param url
|
|
1185
|
-
*/
|
|
1186
|
-
parse(url) {
|
|
1187
|
-
return Object.entries(this._schema.fields).reduce((acc, [key, type]) => {
|
|
1188
|
-
let v = url.searchParams.get(decamelize(key));
|
|
1189
|
-
if (v == null) {
|
|
1190
|
-
v = url.searchParams.get(key);
|
|
1191
|
-
}
|
|
1192
|
-
if (v != null) {
|
|
1193
|
-
if (AST.isNumberKeyword(type.ast)) {
|
|
1194
|
-
acc[key] = parseInt(v);
|
|
1195
|
-
} else if (AST.isBooleanKeyword(type.ast)) {
|
|
1196
|
-
acc[key] = v === "true" || v === "1";
|
|
1197
|
-
} else {
|
|
1198
|
-
acc[key] = v;
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
return acc;
|
|
1202
|
-
}, {});
|
|
1203
|
-
}
|
|
1204
|
-
/**
|
|
1205
|
-
* Update URL with params.
|
|
1206
|
-
*/
|
|
1207
|
-
params(url, values) {
|
|
1208
|
-
Object.entries(values).forEach(([key, value]) => {
|
|
1209
|
-
const type = this._schema.fields[key];
|
|
1210
|
-
if (type && value != null) {
|
|
1211
|
-
const { value: alt } = AST.getAnnotation(ParamKeyAnnotationId)(type.ast);
|
|
1212
|
-
const k = alt ?? decamelize(key);
|
|
1213
|
-
url.searchParams.set(k, String(value));
|
|
1214
|
-
}
|
|
1215
|
-
});
|
|
1216
|
-
return url;
|
|
1217
|
-
}
|
|
1218
|
-
};
|
|
1219
|
-
|
|
1220
1171
|
// packages/common/util/src/pick.ts
|
|
1221
1172
|
var pick = (object, keys) => keys.reduce((obj, key) => {
|
|
1222
1173
|
if (object && key in object) {
|
|
@@ -1891,8 +1842,6 @@ export {
|
|
|
1891
1842
|
ComplexSet,
|
|
1892
1843
|
HumanHasher,
|
|
1893
1844
|
MapEntry,
|
|
1894
|
-
ParamKeyAnnotation,
|
|
1895
|
-
Params,
|
|
1896
1845
|
SlidingWindowSummary,
|
|
1897
1846
|
Tracer,
|
|
1898
1847
|
WeakDictionary,
|