@dxos/effect 0.6.12-main.89e9959 → 0.6.12-main.ac23639

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.
@@ -13,7 +13,38 @@ import { AST as AST2, JSONSchema, Schema as S } from "@effect/schema";
13
13
  // packages/common/effect/src/url.ts
14
14
  import { AST } from "@effect/schema";
15
15
  import { Option, pipe } from "effect";
16
- import { decamelize } from "xcase";
16
+
17
+ // packages/common/effect/src/decamelize.ts
18
+ var LOW_DASH = "_".codePointAt(0);
19
+ var SMALL_A = "a".codePointAt(0);
20
+ var CAPITAL_A = "A".codePointAt(0);
21
+ var SMALL_Z = "z".codePointAt(0);
22
+ var CAPITAL_Z = "Z".codePointAt(0);
23
+ var isLower = (char) => char >= SMALL_A && char <= SMALL_Z;
24
+ var isUpper = (char) => char >= CAPITAL_A && char <= CAPITAL_Z;
25
+ var toLower = (char) => char + 32;
26
+ var decamelize = (str) => {
27
+ const firstChar = str.charCodeAt(0);
28
+ if (!isLower(firstChar)) {
29
+ return str;
30
+ }
31
+ const length = str.length;
32
+ let changed = false;
33
+ const out = [];
34
+ for (let i = 0; i < length; ++i) {
35
+ const c = str.charCodeAt(i);
36
+ if (isUpper(c)) {
37
+ out.push(LOW_DASH);
38
+ out.push(toLower(c));
39
+ changed = true;
40
+ } else {
41
+ out.push(c);
42
+ }
43
+ }
44
+ return changed ? String.fromCharCode.apply(void 0, out) : str;
45
+ };
46
+
47
+ // packages/common/effect/src/url.ts
17
48
  var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
18
49
  var getParamKeyAnnotation = AST.getAnnotation(ParamKeyAnnotationId);
19
50
  var ParamKeyAnnotation = (value) => (self) => self.annotations({
@@ -69,6 +100,7 @@ export {
69
100
  JSONSchema,
70
101
  ParamKeyAnnotation,
71
102
  S,
72
- UrlParser
103
+ UrlParser,
104
+ getParamKeyAnnotation
73
105
  };
74
106
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/index.ts", "../../../src/url.ts"],
4
- "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { AST, JSONSchema, Schema as S } from '@effect/schema';\n\nexport { AST, JSONSchema, S };\n\nexport * from './url';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, type Schema as S } from '@effect/schema';\nimport { Option, pipe } from 'effect';\nimport { decamelize } from 'xcase';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nconst getParamKeyAnnotation: (annotated: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n AST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends S.Annotable.All>(self: S): S.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: S.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (AST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (AST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),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AKf,KAAAA,MAAM;AAC1C,UAAIA,UAAU0B,QAAW;AACvB,cAAMC,QAAQ,KAAKtB,QAAQO,OAAOG,GAAAA;AAClC,YAAIY,OAAO;AACT,gBAAM,EAAEZ,KAAKa,cAAa,IAAKC,KAC7BjC,sBAAsB+B,MAAMN,GAAG,GAC/BS,OAAOC,UAAU,OAAO;YACtBhB,KAAKI,WAAWJ,GAAAA;UAClB,EAAA,CAAA;AAGFP,cAAIS,aAAae,IAAIJ,eAAeK,OAAOjC,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOQ;EACT;AACF;",
6
- "names": ["AST", "JSONSchema", "Schema", "S", "AST", "Option", "pipe", "decamelize", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "AST", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "Option", "getOrElse", "set", "String"]
3
+ "sources": ["../../../src/index.ts", "../../../src/url.ts", "../../../src/decamelize.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { AST, JSONSchema, Schema as S } from '@effect/schema';\nimport type * as Types from 'effect/Types';\n\nexport { AST, JSONSchema, S, Types };\n\nexport * from './url';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, type Schema as S } from '@effect/schema';\nimport { Option, pipe } from 'effect';\n\nimport { decamelize } from './decamelize';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n AST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends S.Annotable.All>(self: S): S.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: S.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (AST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (AST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nconst LOW_DASH = '_'.codePointAt(0)!;\nconst SMALL_A = 'a'.codePointAt(0)!;\nconst CAPITAL_A = 'A'.codePointAt(0)!;\nconst SMALL_Z = 'z'.codePointAt(0)!;\nconst CAPITAL_Z = 'Z'.codePointAt(0)!;\n\nconst isLower = (char: number) => char >= SMALL_A && char <= SMALL_Z;\n\nconst isUpper = (char: number) => char >= CAPITAL_A && char <= CAPITAL_Z;\n\nconst toLower = (char: number) => char + 0x20;\n\nexport const decamelize = (str: string) => {\n const firstChar = str.charCodeAt(0);\n if (!isLower(firstChar)) {\n return str;\n }\n const length = str.length;\n let changed = false;\n const out: number[] = [];\n for (let i = 0; i < length; ++i) {\n const c = str.charCodeAt(i);\n if (isUpper(c)) {\n out.push(LOW_DASH);\n out.push(toLower(c));\n changed = true;\n } else {\n out.push(c);\n }\n }\n return changed ? String.fromCharCode.apply(undefined, out) : str;\n};\n"],
5
+ "mappings": ";;;;;;;;;;AAIA,SAASA,OAAAA,MAAKC,YAAYC,UAAUC,SAAS;;;ACA7C,SAASC,WAA6B;AACtC,SAASC,QAAQC,YAAY;;;ACD7B,IAAMC,WAAW,IAAIC,YAAY,CAAA;AACjC,IAAMC,UAAU,IAAID,YAAY,CAAA;AAChC,IAAME,YAAY,IAAIF,YAAY,CAAA;AAClC,IAAMG,UAAU,IAAIH,YAAY,CAAA;AAChC,IAAMI,YAAY,IAAIJ,YAAY,CAAA;AAElC,IAAMK,UAAU,CAACC,SAAiBA,QAAQL,WAAWK,QAAQH;AAE7D,IAAMI,UAAU,CAACD,SAAiBA,QAAQJ,aAAaI,QAAQF;AAE/D,IAAMI,UAAU,CAACF,SAAiBA,OAAO;AAElC,IAAMG,aAAa,CAACC,QAAAA;AACzB,QAAMC,YAAYD,IAAIE,WAAW,CAAA;AACjC,MAAI,CAACP,QAAQM,SAAAA,GAAY;AACvB,WAAOD;EACT;AACA,QAAMG,SAASH,IAAIG;AACnB,MAAIC,UAAU;AACd,QAAMC,MAAgB,CAAA;AACtB,WAASC,IAAI,GAAGA,IAAIH,QAAQ,EAAEG,GAAG;AAC/B,UAAMC,IAAIP,IAAIE,WAAWI,CAAAA;AACzB,QAAIT,QAAQU,CAAAA,GAAI;AACdF,UAAIG,KAAKnB,QAAAA;AACTgB,UAAIG,KAAKV,QAAQS,CAAAA,CAAAA;AACjBH,gBAAU;IACZ,OAAO;AACLC,UAAIG,KAAKD,CAAAA;IACX;EACF;AACA,SAAOH,UAAUK,OAAOC,aAAaC,MAAMC,QAAWP,GAAAA,IAAOL;AAC/D;;;AD1BA,IAAMa,uBAAuBC,OAAOC,IAAI,kCAAA;AAIjC,IAAMC,wBACXC,IAAIC,cAAuCL,oBAAAA;AAEtC,I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K,OAAOjC,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOQ;EACT;AACF;",
6
+ "names": ["AST", "JSONSchema", "Schema", "S", "AST", "Option", "pipe", "LOW_DASH", "codePointAt", "SMALL_A", "CAPITAL_A", "SMALL_Z", "CAPITAL_Z", "isLower", "char", "isUpper", "toLower", "decamelize", "str", "firstChar", "charCodeAt", "length", "changed", "out", "i", "c", "push", "String", "fromCharCode", "apply", "undefined", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "AST", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "Option", "getOrElse", "set", "String"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"inject-globals:@inject-globals":{"bytes":324,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/url.ts":{"bytes":7663,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"xcase","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/index.ts":{"bytes":887,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"packages/common/effect/src/url.ts","kind":"import-statement","original":"./url"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/common/effect/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4330},"packages/common/effect/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"xcase","kind":"import-statement","external":true}],"exports":["AST","JSONSchema","ParamKeyAnnotation","S","UrlParser"],"entryPoint":"packages/common/effect/src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/common/effect/src/index.ts":{"bytesInOutput":71},"packages/common/effect/src/url.ts":{"bytesInOutput":1586}},"bytes":1997}}}
1
+ {"inputs":{"inject-globals:@inject-globals":{"bytes":324,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/decamelize.ts":{"bytes":3867,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/url.ts":{"bytes":7713,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"packages/common/effect/src/decamelize.ts","kind":"import-statement","original":"./decamelize"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/index.ts":{"bytes":959,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"packages/common/effect/src/url.ts","kind":"import-statement","original":"./url"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/common/effect/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":6370},"packages/common/effect/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["AST","JSONSchema","ParamKeyAnnotation","S","UrlParser","getParamKeyAnnotation"],"entryPoint":"packages/common/effect/src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/common/effect/src/index.ts":{"bytesInOutput":71},"packages/common/effect/src/url.ts":{"bytesInOutput":1550},"packages/common/effect/src/decamelize.ts":{"bytesInOutput":798}},"bytes":2867}}}
@@ -22,13 +22,41 @@ __export(node_exports, {
22
22
  JSONSchema: () => import_schema.JSONSchema,
23
23
  ParamKeyAnnotation: () => ParamKeyAnnotation,
24
24
  S: () => import_schema.Schema,
25
- UrlParser: () => UrlParser
25
+ UrlParser: () => UrlParser,
26
+ getParamKeyAnnotation: () => getParamKeyAnnotation
26
27
  });
27
28
  module.exports = __toCommonJS(node_exports);
28
29
  var import_schema = require("@effect/schema");
29
30
  var import_schema2 = require("@effect/schema");
30
31
  var import_effect = require("effect");
31
- var import_xcase = require("xcase");
32
+ var LOW_DASH = "_".codePointAt(0);
33
+ var SMALL_A = "a".codePointAt(0);
34
+ var CAPITAL_A = "A".codePointAt(0);
35
+ var SMALL_Z = "z".codePointAt(0);
36
+ var CAPITAL_Z = "Z".codePointAt(0);
37
+ var isLower = (char) => char >= SMALL_A && char <= SMALL_Z;
38
+ var isUpper = (char) => char >= CAPITAL_A && char <= CAPITAL_Z;
39
+ var toLower = (char) => char + 32;
40
+ var decamelize = (str) => {
41
+ const firstChar = str.charCodeAt(0);
42
+ if (!isLower(firstChar)) {
43
+ return str;
44
+ }
45
+ const length = str.length;
46
+ let changed = false;
47
+ const out = [];
48
+ for (let i = 0; i < length; ++i) {
49
+ const c = str.charCodeAt(i);
50
+ if (isUpper(c)) {
51
+ out.push(LOW_DASH);
52
+ out.push(toLower(c));
53
+ changed = true;
54
+ } else {
55
+ out.push(c);
56
+ }
57
+ }
58
+ return changed ? String.fromCharCode.apply(void 0, out) : str;
59
+ };
32
60
  var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
33
61
  var getParamKeyAnnotation = import_schema2.AST.getAnnotation(ParamKeyAnnotationId);
34
62
  var ParamKeyAnnotation = (value) => (self) => self.annotations({
@@ -44,7 +72,7 @@ var UrlParser = class {
44
72
  parse(_url) {
45
73
  const url = new URL(_url);
46
74
  return Object.entries(this._schema.fields).reduce((params, [key, type]) => {
47
- let value = url.searchParams.get((0, import_xcase.decamelize)(key));
75
+ let value = url.searchParams.get(decamelize(key));
48
76
  if (value == null) {
49
77
  value = url.searchParams.get(key);
50
78
  }
@@ -70,7 +98,7 @@ var UrlParser = class {
70
98
  const field = this._schema.fields[key];
71
99
  if (field) {
72
100
  const { key: serializedKey } = (0, import_effect.pipe)(getParamKeyAnnotation(field.ast), import_effect.Option.getOrElse(() => ({
73
- key: (0, import_xcase.decamelize)(key)
101
+ key: decamelize(key)
74
102
  })));
75
103
  url.searchParams.set(serializedKey, String(value));
76
104
  }
@@ -85,6 +113,7 @@ var UrlParser = class {
85
113
  JSONSchema,
86
114
  ParamKeyAnnotation,
87
115
  S,
88
- UrlParser
116
+ UrlParser,
117
+ getParamKeyAnnotation
89
118
  });
90
119
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/index.ts", "../../../src/url.ts"],
4
- "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { AST, JSONSchema, Schema as S } from '@effect/schema';\n\nexport { AST, JSONSchema, S };\n\nexport * from './url';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, type Schema as S } from '@effect/schema';\nimport { Option, pipe } from 'effect';\nimport { decamelize } from 'xcase';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nconst getParamKeyAnnotation: (annotated: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n AST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends S.Annotable.All>(self: S): S.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: S.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (AST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (AST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAA6C;ACA7C,IAAAA,iBAAsC;AACtC,oBAA6B;AAC7B,mBAA2B;AAE3B,IAAMC,uBAAuBC,OAAOC,IAAI,kCAAA;AAIxC,IAAMC,wBACJC,mBAAIC,cAAuCL,oBAAAA;AAEtC,IAAMM,qBACX,CAACC,UACD,CAA4BC,SAC1BA,KAAKC,YAAY;EAAE,CAACT,oBAAAA,GAAuBO;AAAM,CAAA;AAM9C,IAAMG,YAAN,MAAMA;EACXC,YAA6BC,SAAsB;SAAtBA,UAAAA;EAAuB;;;;EAKpDC,MAAMC,MAAiB;AACrB,UAAMC,MAAM,IAAIC,IAAIF,IAAAA;AACpB,WAAOG,OAAOC,QAAQ,KAAKN,QAAQO,MAAM,EAAEC,OAA4B,CAACC,QAAQ,CAACC,KAAKC,IAAAA,MAAK;AACzF,UAAIhB,QAAQQ,IAAIS,aAAaC,QAAIC,yBAAWJ,GAAAA,CAAAA;AAC5C,UAAIf,SAAS,MAAM;AACjBA,gBAAQQ,IAAIS,aAAaC,IAAIH,GAAAA;MAC/B;AAEA,UAAIf,SAAS,MAAM;AACjB,YAAIH,mBAAIuB,gBAAgBJ,KAAKK,GAAG,GAAG;AACjCP,iBAAOC,GAAAA,IAAOO,SAAStB,KAAAA;QACzB,WAAWH,mBAAI0B,iBAAiBP,KAAKK,GAAG,GAAG;AACzCP,iBAAOC,GAAAA,IAAOf,UAAU,UAAUA,UAAU;QAC9C,OAAO;AACLc,iBAAOC,GAAAA,IAAOf;QAChB;MACF;AAEA,aAAOc;IACT,GAAG,CAAC,CAAA;EACN;;;;EAKAU,OAAOjB,MAAcO,QAAgB;AACnC,UAAMN,MAAM,IAAIC,IAAIF,IAAAA;AACpBG,WAAOC,QAAQG,MAAAA,EAAQW,QAAQ,CAAC,CAACV,KAAKf,KAAAA,MAAM;AAC1C,UAAIA,UAAU0B,QAAW;AACvB,cAAMC,QAAQ,KAAKtB,QAAQO,OAAOG,GAAAA;AAClC,YAAIY,OAAO;AACT,gBAAM,EAAEZ,KAAKa,cAAa,QAAKC,oBAC7BjC,sBAAsB+B,MAAMN,GAAG,GAC/BS,qBAAOC,UAAU,OAAO;YACtBhB,SAAKI,yBAAWJ,GAAAA;UAClB,EAAA,CAAA;AAGFP,cAAIS,aAAae,IAAIJ,eAAeK,OAAOjC,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOQ;EACT;AACF;",
6
- "names": ["import_schema", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "AST", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "Option", "getOrElse", "set", "String"]
3
+ "sources": ["../../../src/index.ts", "../../../src/url.ts", "../../../src/decamelize.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { AST, JSONSchema, Schema as S } from '@effect/schema';\nimport type * as Types from 'effect/Types';\n\nexport { AST, JSONSchema, S, Types };\n\nexport * from './url';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, type Schema as S } from '@effect/schema';\nimport { Option, pipe } from 'effect';\n\nimport { decamelize } from './decamelize';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n AST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends S.Annotable.All>(self: S): S.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: S.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (AST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (AST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nconst LOW_DASH = '_'.codePointAt(0)!;\nconst SMALL_A = 'a'.codePointAt(0)!;\nconst CAPITAL_A = 'A'.codePointAt(0)!;\nconst SMALL_Z = 'z'.codePointAt(0)!;\nconst CAPITAL_Z = 'Z'.codePointAt(0)!;\n\nconst isLower = (char: number) => char >= SMALL_A && char <= SMALL_Z;\n\nconst isUpper = (char: number) => char >= CAPITAL_A && char <= CAPITAL_Z;\n\nconst toLower = (char: number) => char + 0x20;\n\nexport const decamelize = (str: string) => {\n const firstChar = str.charCodeAt(0);\n if (!isLower(firstChar)) {\n return str;\n }\n const length = str.length;\n let changed = false;\n const out: number[] = [];\n for (let i = 0; i < length; ++i) {\n const c = str.charCodeAt(i);\n if (isUpper(c)) {\n out.push(LOW_DASH);\n out.push(toLower(c));\n changed = true;\n } else {\n out.push(c);\n }\n }\n return changed ? String.fromCharCode.apply(undefined, out) : str;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAA6C;ACA7C,IAAAA,iBAAsC;AACtC,oBAA6B;ACD7B,IAAMC,WAAW,IAAIC,YAAY,CAAA;AACjC,IAAMC,UAAU,IAAID,YAAY,CAAA;AAChC,IAAME,YAAY,IAAIF,YAAY,CAAA;AAClC,IAAMG,UAAU,IAAIH,YAAY,CAAA;AAChC,IAAMI,YAAY,IAAIJ,YAAY,CAAA;AAElC,IAAMK,UAAU,CAACC,SAAiBA,QAAQL,WAAWK,QAAQH;AAE7D,IAAMI,UAAU,CAACD,SAAiBA,QAAQJ,aAAaI,QAAQF;AAE/D,IAAMI,UAAU,CAACF,SAAiBA,OAAO;AAElC,IAAMG,aAAa,CAACC,QAAAA;AACzB,QAAMC,YAAYD,IAAIE,WAAW,CAAA;AACjC,MAAI,CAACP,QAAQM,SAAAA,GAAY;AACvB,WAAOD;EACT;AACA,QAAMG,SAASH,IAAIG;AACnB,MAAIC,UAAU;AACd,QAAMC,MAAgB,CAAA;AACtB,WAASC,IAAI,GAAGA,IAAIH,QAAQ,EAAEG,GAAG;AAC/B,UAAMC,IAAIP,IAAIE,WAAWI,C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C,QAAQG,MAAAA,EAAQU,QAAQ,CAAC,CAACT,KAAKf,KAAAA,MAAM;AAC1C,UAAIA,UAAUR,QAAW;AACvB,cAAMiC,QAAQ,KAAKpB,QAAQO,OAAOG,GAAAA;AAClC,YAAIU,OAAO;AACT,gBAAM,EAAEV,KAAKW,cAAa,QAAKC,oBAC7B/B,sBAAsB6B,MAAML,GAAG,GAC/BQ,qBAAOC,UAAU,OAAO;YACtBd,KAAKpC,WAAWoC,GAAAA;UAClB,EAAA,CAAA;AAGFP,cAAIS,aAAaa,IAAIJ,eAAerC,OAAOW,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOQ;EACT;AACF;",
6
+ "names": ["import_schema", "LOW_DASH", "codePointAt", "SMALL_A", "CAPITAL_A", "SMALL_Z", "CAPITAL_Z", "isLower", "char", "isUpper", "toLower", "decamelize", "str", "firstChar", "charCodeAt", "length", "changed", "out", "i", "c", "push", "String", "fromCharCode", "apply", "undefined", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "AST", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "field", "serializedKey", "pipe", "Option", "getOrElse", "set"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/common/effect/src/url.ts":{"bytes":7663,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"xcase","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/index.ts":{"bytes":887,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"packages/common/effect/src/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"}},"outputs":{"packages/common/effect/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4321},"packages/common/effect/dist/lib/node/index.cjs":{"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"xcase","kind":"import-statement","external":true}],"exports":["AST","JSONSchema","ParamKeyAnnotation","S","UrlParser"],"entryPoint":"packages/common/effect/src/index.ts","inputs":{"packages/common/effect/src/index.ts":{"bytesInOutput":71},"packages/common/effect/src/url.ts":{"bytesInOutput":1586}},"bytes":1849}}}
1
+ {"inputs":{"packages/common/effect/src/decamelize.ts":{"bytes":3867,"imports":[],"format":"esm"},"packages/common/effect/src/url.ts":{"bytes":7713,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"packages/common/effect/src/decamelize.ts","kind":"import-statement","original":"./decamelize"}],"format":"esm"},"packages/common/effect/src/index.ts":{"bytes":959,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"packages/common/effect/src/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"}},"outputs":{"packages/common/effect/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":6361},"packages/common/effect/dist/lib/node/index.cjs":{"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["AST","JSONSchema","ParamKeyAnnotation","S","UrlParser","getParamKeyAnnotation"],"entryPoint":"packages/common/effect/src/index.ts","inputs":{"packages/common/effect/src/index.ts":{"bytesInOutput":71},"packages/common/effect/src/url.ts":{"bytesInOutput":1550},"packages/common/effect/src/decamelize.ts":{"bytesInOutput":798}},"bytes":2719}}}
@@ -6,7 +6,38 @@ import { AST as AST2, JSONSchema, Schema as S } from "@effect/schema";
6
6
  // packages/common/effect/src/url.ts
7
7
  import { AST } from "@effect/schema";
8
8
  import { Option, pipe } from "effect";
9
- import { decamelize } from "xcase";
9
+
10
+ // packages/common/effect/src/decamelize.ts
11
+ var LOW_DASH = "_".codePointAt(0);
12
+ var SMALL_A = "a".codePointAt(0);
13
+ var CAPITAL_A = "A".codePointAt(0);
14
+ var SMALL_Z = "z".codePointAt(0);
15
+ var CAPITAL_Z = "Z".codePointAt(0);
16
+ var isLower = (char) => char >= SMALL_A && char <= SMALL_Z;
17
+ var isUpper = (char) => char >= CAPITAL_A && char <= CAPITAL_Z;
18
+ var toLower = (char) => char + 32;
19
+ var decamelize = (str) => {
20
+ const firstChar = str.charCodeAt(0);
21
+ if (!isLower(firstChar)) {
22
+ return str;
23
+ }
24
+ const length = str.length;
25
+ let changed = false;
26
+ const out = [];
27
+ for (let i = 0; i < length; ++i) {
28
+ const c = str.charCodeAt(i);
29
+ if (isUpper(c)) {
30
+ out.push(LOW_DASH);
31
+ out.push(toLower(c));
32
+ changed = true;
33
+ } else {
34
+ out.push(c);
35
+ }
36
+ }
37
+ return changed ? String.fromCharCode.apply(void 0, out) : str;
38
+ };
39
+
40
+ // packages/common/effect/src/url.ts
10
41
  var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
11
42
  var getParamKeyAnnotation = AST.getAnnotation(ParamKeyAnnotationId);
12
43
  var ParamKeyAnnotation = (value) => (self) => self.annotations({
@@ -62,6 +93,7 @@ export {
62
93
  JSONSchema,
63
94
  ParamKeyAnnotation,
64
95
  S,
65
- UrlParser
96
+ UrlParser,
97
+ getParamKeyAnnotation
66
98
  };
67
99
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/index.ts", "../../../src/url.ts"],
4
- "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { AST, JSONSchema, Schema as S } from '@effect/schema';\n\nexport { AST, JSONSchema, S };\n\nexport * from './url';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, type Schema as S } from '@effect/schema';\nimport { Option, pipe } from 'effect';\nimport { decamelize } from 'xcase';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nconst getParamKeyAnnotation: (annotated: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n AST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends S.Annotable.All>(self: S): S.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: S.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (AST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (AST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n"],
5
- "mappings": ";;;AAIA,SAASA,OAAAA,MAAKC,YAAYC,UAAUC,SAAS;;;ACA7C,SAASC,WAA6B;AACtC,SAASC,QAAQC,YAAY;AAC7B,SAASC,kBAAkB;AAE3B,IAAMC,uBAAuBC,OAAOC,IAAI,kCAAA;AAIxC,IAAMC,wBACJC,IAAIC,cAAuCL,oBAAAA;AAEtC,IAAMM,qBACX,CAACC,UACD,CAA4BC,SAC1BA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ACF,CAAA;AAEA,WAAOQ;EACT;AACF;",
6
- "names": ["AST", "JSONSchema", "Schema", "S", "AST", "Option", "pipe", "decamelize", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "AST", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "Option", "getOrElse", "set", "String"]
3
+ "sources": ["../../../src/index.ts", "../../../src/url.ts", "../../../src/decamelize.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { AST, JSONSchema, Schema as S } from '@effect/schema';\nimport type * as Types from 'effect/Types';\n\nexport { AST, JSONSchema, S, Types };\n\nexport * from './url';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, type Schema as S } from '@effect/schema';\nimport { Option, pipe } from 'effect';\n\nimport { decamelize } from './decamelize';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n AST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends S.Annotable.All>(self: S): S.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: S.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (AST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (AST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nconst LOW_DASH = '_'.codePointAt(0)!;\nconst SMALL_A = 'a'.codePointAt(0)!;\nconst CAPITAL_A = 'A'.codePointAt(0)!;\nconst SMALL_Z = 'z'.codePointAt(0)!;\nconst CAPITAL_Z = 'Z'.codePointAt(0)!;\n\nconst isLower = (char: number) => char >= SMALL_A && char <= SMALL_Z;\n\nconst isUpper = (char: number) => char >= CAPITAL_A && char <= CAPITAL_Z;\n\nconst toLower = (char: number) => char + 0x20;\n\nexport const decamelize = (str: string) => {\n const firstChar = str.charCodeAt(0);\n if (!isLower(firstChar)) {\n return str;\n }\n const length = str.length;\n let changed = false;\n const out: number[] = [];\n for (let i = 0; i < length; ++i) {\n const c = str.charCodeAt(i);\n if (isUpper(c)) {\n out.push(LOW_DASH);\n out.push(toLower(c));\n changed = true;\n } else {\n out.push(c);\n }\n }\n return changed ? String.fromCharCode.apply(undefined, out) : str;\n};\n"],
5
+ "mappings": ";;;AAIA,SAASA,OAAAA,MAAKC,YAAYC,UAAUC,SAAS;;;ACA7C,SAASC,WAA6B;AACtC,SAASC,QAAQC,YAAY;;;ACD7B,IAAMC,WAAW,IAAIC,YAAY,CAAA;AACjC,IAAMC,UAAU,IAAID,YAAY,CAAA;AAChC,IAAME,YAAY,IAA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,QAAQQ,IAAIS,aAAaC,IAAIC,WAAWJ,GAAAA,CAAAA;AAC5C,UAAIf,SAAS,MAAM;AACjBA,gBAAQQ,IAAIS,aAAaC,IAAIH,GAAAA;MAC/B;AAEA,UAAIf,SAAS,MAAM;AACjB,YAAIH,IAAIuB,gBAAgBJ,KAAKK,GAAG,GAAG;AACjCP,iBAAOC,GAAAA,IAAOO,SAAStB,KAAAA;QACzB,WAAWH,IAAI0B,iBAAiBP,KAAKK,GAAG,GAAG;AACzCP,iBAAOC,GAAAA,IAAOf,UAAU,UAAUA,UAAU;QAC9C,OAAO;AACLc,iBAAOC,GAAAA,IAAOf;QAChB;MACF;AAEA,aAAOc;IACT,GAAG,CAAC,CAAA;EACN;;;;EAKAU,OAAOjB,MAAcO,QAAgB;AACnC,UAAMN,MAAM,IAAIC,IAAIF,IAAAA;AACpBG,WAAOC,QAAQG,MAAAA,EAAQW,QAAQ,CAAC,CAACV,KAAKf,KAAAA,MAAM;AAC1C,UAAIA,UAAU0B,QAAW;AACvB,cAAMC,QAAQ,KAAKtB,QAAQO,OAAOG,GAAAA;AAClC,YAAIY,OAAO;AACT,gBAAM,EAAEZ,KAAKa,cAAa,IAAKC,KAC7BjC,sBAAsB+B,MAAMN,GAAG,GAC/BS,OAAOC,UAAU,OAAO;YACtBhB,KAAKI,WAAWJ,GAAAA;UAClB,EAAA,CAAA;AAGFP,cAAIS,aAAae,IAAIJ,eAAeK,OAAOjC,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOQ;EACT;AACF;",
6
+ "names": ["AST", "JSONSchema", "Schema", "S", "AST", "Option", "pipe", "LOW_DASH", "codePointAt", "SMALL_A", "CAPITAL_A", "SMALL_Z", "CAPITAL_Z", "isLower", "char", "isUpper", "toLower", "decamelize", "str", "firstChar", "charCodeAt", "length", "changed", "out", "i", "c", "push", "String", "fromCharCode", "apply", "undefined", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "AST", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "Option", "getOrElse", "set", "String"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/common/effect/src/url.ts":{"bytes":7663,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"xcase","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/index.ts":{"bytes":887,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"packages/common/effect/src/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"}},"outputs":{"packages/common/effect/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4323},"packages/common/effect/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"xcase","kind":"import-statement","external":true}],"exports":["AST","JSONSchema","ParamKeyAnnotation","S","UrlParser"],"entryPoint":"packages/common/effect/src/index.ts","inputs":{"packages/common/effect/src/index.ts":{"bytesInOutput":71},"packages/common/effect/src/url.ts":{"bytesInOutput":1586}},"bytes":1942}}}
1
+ {"inputs":{"packages/common/effect/src/decamelize.ts":{"bytes":3867,"imports":[],"format":"esm"},"packages/common/effect/src/url.ts":{"bytes":7713,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"packages/common/effect/src/decamelize.ts","kind":"import-statement","original":"./decamelize"}],"format":"esm"},"packages/common/effect/src/index.ts":{"bytes":959,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"packages/common/effect/src/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"}},"outputs":{"packages/common/effect/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":6363},"packages/common/effect/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["AST","JSONSchema","ParamKeyAnnotation","S","UrlParser","getParamKeyAnnotation"],"entryPoint":"packages/common/effect/src/index.ts","inputs":{"packages/common/effect/src/index.ts":{"bytesInOutput":71},"packages/common/effect/src/url.ts":{"bytesInOutput":1550},"packages/common/effect/src/decamelize.ts":{"bytesInOutput":798}},"bytes":2812}}}
@@ -0,0 +1,2 @@
1
+ export declare const decamelize: (str: string) => string;
2
+ //# sourceMappingURL=decamelize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decamelize.d.ts","sourceRoot":"","sources":["../../../src/decamelize.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,UAAU,QAAS,MAAM,WAmBrC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { AST, JSONSchema, Schema as S } from '@effect/schema';
2
- export { AST, JSONSchema, S };
2
+ import type * as Types from 'effect/Types';
3
+ export { AST, JSONSchema, S, Types };
3
4
  export * from './url';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;AAE9B,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;AAErC,cAAc,OAAO,CAAC"}
@@ -1,7 +1,9 @@
1
- import { type Schema as S } from '@effect/schema';
1
+ import { AST, type Schema as S } from '@effect/schema';
2
+ import { Option } from 'effect';
2
3
  type ParamKeyAnnotationValue = {
3
4
  key: string;
4
5
  };
6
+ export declare const getParamKeyAnnotation: (annotated: AST.Annotated) => Option.Option<ParamKeyAnnotationValue>;
5
7
  export declare const ParamKeyAnnotation: (value: ParamKeyAnnotationValue) => <S extends S.Annotable.All>(self: S) => S.Annotable.Self<S>;
6
8
  /**
7
9
  * HTTP params parser.
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/url.ts"],"names":[],"mappings":"AAIA,OAAO,EAAO,KAAK,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAMvD,KAAK,uBAAuB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAK/C,eAAO,MAAM,kBAAkB,UACrB,uBAAuB,MAC9B,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CACH,CAAC;AAExD;;;GAGG;AACH,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC;IAsBtB;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,GAAG;CAoBrC"}
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/url.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,KAAK,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAMtC,KAAK,uBAAuB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/C,eAAO,MAAM,qBAAqB,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC,uBAAuB,CACrC,CAAC;AAEnE,eAAO,MAAM,kBAAkB,UACrB,uBAAuB,MAC9B,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CACH,CAAC;AAExD;;;GAGG;AACH,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC;IAsBtB;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,GAAG;CAoBrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/effect",
3
- "version": "0.6.12-main.89e9959",
3
+ "version": "0.6.12-main.ac23639",
4
4
  "description": "Effect utils.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -25,16 +25,15 @@
25
25
  "src"
26
26
  ],
27
27
  "dependencies": {
28
- "xcase": "^2.0.1",
29
- "@dxos/node-std": "0.6.12-main.89e9959"
28
+ "@dxos/node-std": "0.6.12-main.ac23639"
30
29
  },
31
30
  "devDependencies": {
32
- "@effect/schema": "^0.67.16",
33
- "effect": "^3.2.7"
31
+ "@effect/schema": "^0.75.1",
32
+ "effect": "^3.9.1"
34
33
  },
35
34
  "peerDependencies": {
36
35
  "@effect/schema": "^0.67.16",
37
- "effect": "^3.2.7"
36
+ "effect": "^3.9.1"
38
37
  },
39
38
  "publishConfig": {
40
39
  "access": "public"
@@ -0,0 +1,36 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ const LOW_DASH = '_'.codePointAt(0)!;
6
+ const SMALL_A = 'a'.codePointAt(0)!;
7
+ const CAPITAL_A = 'A'.codePointAt(0)!;
8
+ const SMALL_Z = 'z'.codePointAt(0)!;
9
+ const CAPITAL_Z = 'Z'.codePointAt(0)!;
10
+
11
+ const isLower = (char: number) => char >= SMALL_A && char <= SMALL_Z;
12
+
13
+ const isUpper = (char: number) => char >= CAPITAL_A && char <= CAPITAL_Z;
14
+
15
+ const toLower = (char: number) => char + 0x20;
16
+
17
+ export const decamelize = (str: string) => {
18
+ const firstChar = str.charCodeAt(0);
19
+ if (!isLower(firstChar)) {
20
+ return str;
21
+ }
22
+ const length = str.length;
23
+ let changed = false;
24
+ const out: number[] = [];
25
+ for (let i = 0; i < length; ++i) {
26
+ const c = str.charCodeAt(i);
27
+ if (isUpper(c)) {
28
+ out.push(LOW_DASH);
29
+ out.push(toLower(c));
30
+ changed = true;
31
+ } else {
32
+ out.push(c);
33
+ }
34
+ }
35
+ return changed ? String.fromCharCode.apply(undefined, out) : str;
36
+ };
package/src/index.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  //
4
4
 
5
5
  import { AST, JSONSchema, Schema as S } from '@effect/schema';
6
+ import type * as Types from 'effect/Types';
6
7
 
7
- export { AST, JSONSchema, S };
8
+ export { AST, JSONSchema, S, Types };
8
9
 
9
10
  export * from './url';
package/src/url.ts CHANGED
@@ -4,13 +4,14 @@
4
4
 
5
5
  import { AST, type Schema as S } from '@effect/schema';
6
6
  import { Option, pipe } from 'effect';
7
- import { decamelize } from 'xcase';
7
+
8
+ import { decamelize } from './decamelize';
8
9
 
9
10
  const ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');
10
11
 
11
12
  type ParamKeyAnnotationValue = { key: string };
12
13
 
13
- const getParamKeyAnnotation: (annotated: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =
14
+ export const getParamKeyAnnotation: (annotated: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =
14
15
  AST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);
15
16
 
16
17
  export const ParamKeyAnnotation =