@bessemer/cornerstone 0.5.35 → 0.5.37

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/uri.d.ts CHANGED
@@ -42,6 +42,11 @@ export type UriBuilder = {
42
42
  } | string;
43
43
  };
44
44
  export declare const build: (builder: UriBuilder) => Uri;
45
- export declare const format: (uri: Uri) => UriString;
45
+ export declare enum UriComponentType {
46
+ Scheme = "Scheme",
47
+ Host = "Host",
48
+ Location = "Location"
49
+ }
50
+ export declare const format: (uri: Uri, format?: Array<UriComponentType>) => UriString;
46
51
  export declare const buildString: (builder: UriBuilder) => UriString;
47
52
  //# sourceMappingURL=uri.d.ts.map
package/dist/uri.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../src/uri.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAGzD,eAAO,MAAM,MAAM,GAAI,cAAc,YAAY,WAEhD,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,cAAc,YAAY,WAEhD,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AACxD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AAEjC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;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KAAG,GA8C3C,CAAA;AAED,oBAAY,gBAAgB;IAC1B,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,eAAO,MAAM,MAAM,GAAI,KAAK,GAAG,EAAE,SAAQ,KAAK,CAAC,gBAAgB,CAAmC,KAAG,SAgCpG,CAAA;AAoBD,eAAO,MAAM,WAAW,GAAI,SAAS,UAAU,KAAG,SAEjD,CAAA"}
package/dist/uri.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/uri.ts
2
- import { Objects, Strings } from "@bessemer/cornerstone";
2
+ import { Arrays, Objects, Strings } from "@bessemer/cornerstone";
3
3
  var encode = (uriComponent) => {
4
4
  return encodeURIComponent(uriComponent);
5
5
  };
@@ -159,12 +159,18 @@ var build = (builder) => {
159
159
  location
160
160
  };
161
161
  };
162
- var format = (uri) => {
162
+ var UriComponentType = /* @__PURE__ */ ((UriComponentType2) => {
163
+ UriComponentType2["Scheme"] = "Scheme";
164
+ UriComponentType2["Host"] = "Host";
165
+ UriComponentType2["Location"] = "Location";
166
+ return UriComponentType2;
167
+ })(UriComponentType || {});
168
+ var format = (uri, format2 = Object.values(UriComponentType)) => {
163
169
  let urlString = "";
164
- if (Objects.isPresent(uri.scheme)) {
170
+ if (Objects.isPresent(uri.scheme) && Arrays.contains(format2, "Scheme" /* Scheme */)) {
165
171
  urlString = urlString + uri.scheme;
166
172
  }
167
- if (Objects.isPresent(uri.host)) {
173
+ if (Objects.isPresent(uri.host) && Arrays.contains(format2, "Host" /* Host */)) {
168
174
  if (Objects.isPresent(uri.scheme)) {
169
175
  urlString = urlString + "://";
170
176
  }
@@ -180,10 +186,12 @@ var format = (uri) => {
180
186
  urlString = urlString + ":" + uri.host.port;
181
187
  }
182
188
  }
183
- urlString = urlString + formatLocation(uri.location);
189
+ if (Arrays.contains(format2, "Location" /* Location */)) {
190
+ urlString = urlString + formatLocation(uri.location, format2);
191
+ }
184
192
  return urlString;
185
193
  };
186
- var formatLocation = (location) => {
194
+ var formatLocation = (location, format2) => {
187
195
  let urlString = "";
188
196
  if (!Strings.isEmpty(location.path)) {
189
197
  urlString = urlString + location.path;
@@ -200,6 +208,7 @@ var buildString = (builder) => {
200
208
  return format(build(builder));
201
209
  };
202
210
  export {
211
+ UriComponentType,
203
212
  build,
204
213
  buildString,
205
214
  decode,
package/dist/uri.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/uri.ts"],"sourcesContent":["import { Objects, Strings } from '@bessemer/cornerstone'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { StringSplitResult } from '@bessemer/cornerstone/string'\n\nexport const encode = (uriComponent: UriComponent) => {\n return encodeURIComponent(uriComponent)\n}\n\nexport const decode = (uriComponent: UriComponent) => {\n return decodeURIComponent(uriComponent)\n}\n\nexport type UriString = NominalType<string, 'UriString'>\nexport type UriComponent = string\n\nexport type UriScheme = string\n\nexport type UriAuthentication = {\n principal: string\n password: string | null\n}\n\nexport type UriHost = {\n value: string\n port: number | null\n}\n\nexport interface UriLocation {\n path: string\n query: string | null\n fragment: string | null\n}\n\nexport interface Uri {\n scheme: UriScheme | null\n host: UriHost | null\n authentication: UriAuthentication | null\n location: UriLocation\n}\n\nconst parseSchemePart = (url: UriComponent): [UriScheme | null, UriComponent] => {\n // Search for the colon or double slash\n const schemeMatch = Strings.splitFirst(url, /(\\/\\/|:)/)\n\n // If we don't find either, or we hit the double slash before finding a colon, there is no scheme\n if (Objects.isNil(schemeMatch.selection) || schemeMatch.separator === '//') {\n return [null, url]\n }\n\n // This means the string started with :, so no protocol. We'll go ahead and remove the : from consideration\n if (Strings.isEmpty(schemeMatch.selection)) {\n return [null, schemeMatch.rest]\n } else {\n return [schemeMatch.selection, schemeMatch.rest]\n }\n}\n\nconst parseAuthenticationPart = (url: UriComponent): [UriAuthentication | null, UriComponent] => {\n let targetPart = url\n const queryMatch = Strings.splitFirst(targetPart, '?')\n const fragmentMatch = Strings.splitFirst(targetPart, '#')\n if (Objects.isPresent(queryMatch.selection)) {\n targetPart = queryMatch.selection\n } else if (Objects.isPresent(fragmentMatch.selection)) {\n targetPart = fragmentMatch.selection\n }\n\n const { selection: authentication } = Strings.splitFirst(targetPart, '@')\n\n // If there is no @, then we don't have an authentication\n if (Objects.isNil(authentication)) {\n return [null, url]\n }\n\n const { rest } = Strings.splitFirst(url, '@')\n\n return [parseAuthentication(Strings.removeStart(authentication, '//')), '//' + rest]\n}\n\nconst parseAuthentication = (authentication: UriComponent): UriAuthentication => {\n const { selection: principal, rest: authenticationRest } = Strings.splitFirst(authentication, ':')\n\n // If there isn't a colon, then there is no password but there is a username\n if (Objects.isNil(principal)) {\n return { principal: authenticationRest, password: null }\n }\n\n // The authentication section started with a :, don't know what to make of this... password but no username?\n if (Strings.isEmpty(principal)) {\n throw new Error(`Unable to parse Authentication: ${authentication}`)\n }\n\n // Otherwise, we have both, so return the complete authentication object and the rest\n return { principal, password: authenticationRest }\n}\n\nconst parseHostPart = (url: UriComponent): [UriHost | null, UriComponent] => {\n // Check if the host is starting with reserved characters, if so we should just bail on trying to parse\n if (Strings.startsWith(url, '?') || Strings.startsWith(url, '#')) {\n return [null, url]\n }\n\n let hostRequired = Strings.startsWith(url, '//')\n if (!hostRequired) {\n return [null, url]\n }\n\n url = Strings.removeStart(url, '//')\n\n // Lets grab everything to the left of the first / ? or #, this is the remainder of our authority (if any)\n const urlMatch = Strings.splitFirst(url, /[\\/?#]/)\n let host = urlMatch.rest\n let rest = ''\n\n if (Objects.isPresent(urlMatch.selection)) {\n host = urlMatch.selection\n rest = urlMatch.separator + urlMatch.rest\n }\n\n if (Strings.isEmpty(host)) {\n return [null, rest]\n }\n\n return [parseHost(host), rest]\n}\n\nconst parseHost = (host: UriComponent): UriHost => {\n // Try to see if we have an ipv6 address like the form [2001:db8::7] and handle it\n if (Strings.startsWith(host, '[')) {\n const ipMatch = Strings.splitFirst(host, ']')\n\n if (Objects.isPresent(ipMatch.selection)) {\n const portMatch = Strings.splitFirst(ipMatch.rest, ':')\n if (Objects.isPresent(portMatch.selection)) {\n if (Strings.isEmpty(portMatch.selection)) {\n return { value: ipMatch.selection + ']', port: Number(portMatch.rest) }\n }\n } else {\n return { value: ipMatch.selection + ']', port: null }\n }\n }\n }\n\n let hostMatch: StringSplitResult = Strings.splitFirst(host, ':')\n\n // We have no :, which means no port, so treat the rest as the hostname\n if (Objects.isNil(hostMatch.selection)) {\n return { value: hostMatch.rest, port: null }\n }\n\n // The host started with a :, this is odd\n if (Strings.isEmpty(hostMatch.selection)) {\n throw new Error(`Unable to parse Host: ${host}`)\n }\n\n const hostName = hostMatch.selection\n\n // Otherwise, we have both, so return the complete authentication object and the rest\n return { value: hostName, port: Number(hostMatch.rest) }\n}\n\nconst parseLocation = (url: UriComponent): UriLocation => {\n const location: UriLocation = { path: '', query: null, fragment: null }\n\n // Lets see if we have a fragment and parse it off the end\n const fragmentMatch = Strings.splitFirst(url, '#')\n if (Objects.isPresent(fragmentMatch.selection) && !Strings.isEmpty(fragmentMatch.rest)) {\n location.fragment = fragmentMatch.rest\n }\n\n // Lets see if we have a query string and parse it off the remainder\n const queryMatch = Strings.splitFirst(fragmentMatch.selection ?? fragmentMatch.rest, '?')\n if (Objects.isPresent(queryMatch.selection) && !Strings.isEmpty(queryMatch.rest)) {\n location.query = queryMatch.rest\n }\n\n location.path = queryMatch.selection ?? queryMatch.rest\n return location\n}\n\nexport const parse = (urlString: UriString): Uri => {\n const [scheme, rest1] = parseSchemePart(urlString)\n const [authentication, rest2] = parseAuthenticationPart(rest1)\n const [host, rest3] = parseHostPart(rest2)\n const location = parseLocation(rest3)\n const url: Uri = { scheme, host, authentication, location }\n return url\n}\n\nexport const emptyLocation = (): UriLocation => {\n return {\n path: '',\n query: null,\n fragment: null,\n }\n}\n\nexport type UriBuilder = {\n scheme?: string\n host?:\n | {\n value: string\n port?: number\n }\n | string\n authentication?:\n | {\n principal: string\n password?: string\n }\n | string\n location?:\n | {\n path: string\n query?: string\n fragment?: string\n }\n | string\n}\n\nexport const build = (builder: UriBuilder): Uri => {\n const scheme = builder.scheme ?? null\n\n let host: UriHost | null = null\n if (Objects.isPresent(builder.host)) {\n if (Strings.isString(builder.host)) {\n host = parseHost(builder.host)\n } else {\n host = {\n value: builder.host.value,\n port: builder.host.port ?? null,\n }\n }\n }\n\n let authentication: UriAuthentication | null = null\n if (Objects.isPresent(builder.authentication)) {\n if (Strings.isString(builder.authentication)) {\n authentication = parseAuthentication(builder.authentication)\n } else {\n authentication = {\n principal: builder.authentication.principal,\n password: builder.authentication.password ?? null,\n }\n }\n }\n\n let location: UriLocation = emptyLocation()\n if (Objects.isPresent(builder.location)) {\n if (Strings.isString(builder.location)) {\n location = parseLocation(builder.location)\n } else {\n location = {\n path: builder.location.path,\n query: builder.location.query ?? null,\n fragment: builder.location.fragment ?? null,\n }\n }\n }\n\n return {\n scheme,\n host,\n authentication,\n location,\n }\n}\n\nexport const format = (uri: Uri): UriString => {\n let urlString = ''\n if (Objects.isPresent(uri.scheme)) {\n urlString = urlString + uri.scheme\n }\n\n if (Objects.isPresent(uri.host)) {\n if (Objects.isPresent(uri.scheme)) {\n urlString = urlString + '://'\n }\n\n if (Objects.isPresent(uri.authentication)) {\n urlString = urlString + uri.authentication.principal\n\n if (Objects.isPresent(uri.authentication.password)) {\n urlString = urlString + ':' + uri.authentication.password\n }\n\n urlString = urlString + '@'\n }\n\n urlString = urlString + uri.host.value\n\n if (Objects.isPresent(uri.host.port)) {\n urlString = urlString + ':' + uri.host.port\n }\n }\n\n urlString = urlString + formatLocation(uri.location)\n return urlString\n}\n\nconst formatLocation = (location: UriLocation): string => {\n let urlString = ''\n\n if (!Strings.isEmpty(location.path)) {\n urlString = urlString + location.path\n }\n\n if (!Strings.isEmpty(location.query)) {\n urlString = urlString + '?' + location.query\n }\n\n if (!Strings.isEmpty(location.fragment)) {\n urlString = urlString + '#' + encode(location.fragment!)\n }\n\n return urlString\n}\n\nexport const buildString = (builder: UriBuilder): UriString => {\n return format(build(builder))\n}\n"],"mappings":";A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,QAAQ,UAAU,IAAI,IAAI,GAAG;AAC/B,QAAI,QAAQ,UAAU,IAAI,MAAM,GAAG;AACjC,kBAAY,YAAY;AAAA,IAC1B;AAEA,QAAI,QAAQ,UAAU,IAAI,cAAc,GAAG;AACzC,kBAAY,YAAY,IAAI,eAAe;AAE3C,UAAI,QAAQ,UAAU,IAAI,eAAe,QAAQ,GAAG;AAClD,oBAAY,YAAY,MAAM,IAAI,eAAe;AAAA,MACnD;AAEA,kBAAY,YAAY;AAAA,IAC1B;AAEA,gBAAY,YAAY,IAAI,KAAK;AAEjC,QAAI,QAAQ,UAAU,IAAI,KAAK,IAAI,GAAG;AACpC,kBAAY,YAAY,MAAM,IAAI,KAAK;AAAA,IACzC;AAAA,EACF;AAEA,cAAY,YAAY,eAAe,IAAI,QAAQ;AACnD,SAAO;AACT;AAEA,IAAM,iBAAiB,CAAC,aAAkC;AACxD,MAAI,YAAY;AAEhB,MAAI,CAAC,QAAQ,QAAQ,SAAS,IAAI,GAAG;AACnC,gBAAY,YAAY,SAAS;AAAA,EACnC;AAEA,MAAI,CAAC,QAAQ,QAAQ,SAAS,KAAK,GAAG;AACpC,gBAAY,YAAY,MAAM,SAAS;AAAA,EACzC;AAEA,MAAI,CAAC,QAAQ,QAAQ,SAAS,QAAQ,GAAG;AACvC,gBAAY,YAAY,MAAM,OAAO,SAAS,QAAS;AAAA,EACzD;AAEA,SAAO;AACT;AAEO,IAAM,cAAc,CAAC,YAAmC;AAC7D,SAAO,OAAO,MAAM,OAAO,CAAC;AAC9B;","names":[]}
1
+ {"version":3,"sources":["../src/uri.ts"],"sourcesContent":["import { Arrays, Objects, Strings } from '@bessemer/cornerstone'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { StringSplitResult } from '@bessemer/cornerstone/string'\n\nexport const encode = (uriComponent: UriComponent) => {\n return encodeURIComponent(uriComponent)\n}\n\nexport const decode = (uriComponent: UriComponent) => {\n return decodeURIComponent(uriComponent)\n}\n\nexport type UriString = NominalType<string, 'UriString'>\nexport type UriComponent = string\n\nexport type UriScheme = string\n\nexport type UriAuthentication = {\n principal: string\n password: string | null\n}\n\nexport type UriHost = {\n value: string\n port: number | null\n}\n\nexport interface UriLocation {\n path: string\n query: string | null\n fragment: string | null\n}\n\nexport interface Uri {\n scheme: UriScheme | null\n host: UriHost | null\n authentication: UriAuthentication | null\n location: UriLocation\n}\n\nconst parseSchemePart = (url: UriComponent): [UriScheme | null, UriComponent] => {\n // Search for the colon or double slash\n const schemeMatch = Strings.splitFirst(url, /(\\/\\/|:)/)\n\n // If we don't find either, or we hit the double slash before finding a colon, there is no scheme\n if (Objects.isNil(schemeMatch.selection) || schemeMatch.separator === '//') {\n return [null, url]\n }\n\n // This means the string started with :, so no protocol. We'll go ahead and remove the : from consideration\n if (Strings.isEmpty(schemeMatch.selection)) {\n return [null, schemeMatch.rest]\n } else {\n return [schemeMatch.selection, schemeMatch.rest]\n }\n}\n\nconst parseAuthenticationPart = (url: UriComponent): [UriAuthentication | null, UriComponent] => {\n let targetPart = url\n const queryMatch = Strings.splitFirst(targetPart, '?')\n const fragmentMatch = Strings.splitFirst(targetPart, '#')\n if (Objects.isPresent(queryMatch.selection)) {\n targetPart = queryMatch.selection\n } else if (Objects.isPresent(fragmentMatch.selection)) {\n targetPart = fragmentMatch.selection\n }\n\n const { selection: authentication } = Strings.splitFirst(targetPart, '@')\n\n // If there is no @, then we don't have an authentication\n if (Objects.isNil(authentication)) {\n return [null, url]\n }\n\n const { rest } = Strings.splitFirst(url, '@')\n\n return [parseAuthentication(Strings.removeStart(authentication, '//')), '//' + rest]\n}\n\nconst parseAuthentication = (authentication: UriComponent): UriAuthentication => {\n const { selection: principal, rest: authenticationRest } = Strings.splitFirst(authentication, ':')\n\n // If there isn't a colon, then there is no password but there is a username\n if (Objects.isNil(principal)) {\n return { principal: authenticationRest, password: null }\n }\n\n // The authentication section started with a :, don't know what to make of this... password but no username?\n if (Strings.isEmpty(principal)) {\n throw new Error(`Unable to parse Authentication: ${authentication}`)\n }\n\n // Otherwise, we have both, so return the complete authentication object and the rest\n return { principal, password: authenticationRest }\n}\n\nconst parseHostPart = (url: UriComponent): [UriHost | null, UriComponent] => {\n // Check if the host is starting with reserved characters, if so we should just bail on trying to parse\n if (Strings.startsWith(url, '?') || Strings.startsWith(url, '#')) {\n return [null, url]\n }\n\n let hostRequired = Strings.startsWith(url, '//')\n if (!hostRequired) {\n return [null, url]\n }\n\n url = Strings.removeStart(url, '//')\n\n // Lets grab everything to the left of the first / ? or #, this is the remainder of our authority (if any)\n const urlMatch = Strings.splitFirst(url, /[\\/?#]/)\n let host = urlMatch.rest\n let rest = ''\n\n if (Objects.isPresent(urlMatch.selection)) {\n host = urlMatch.selection\n rest = urlMatch.separator + urlMatch.rest\n }\n\n if (Strings.isEmpty(host)) {\n return [null, rest]\n }\n\n return [parseHost(host), rest]\n}\n\nconst parseHost = (host: UriComponent): UriHost => {\n // Try to see if we have an ipv6 address like the form [2001:db8::7] and handle it\n if (Strings.startsWith(host, '[')) {\n const ipMatch = Strings.splitFirst(host, ']')\n\n if (Objects.isPresent(ipMatch.selection)) {\n const portMatch = Strings.splitFirst(ipMatch.rest, ':')\n if (Objects.isPresent(portMatch.selection)) {\n if (Strings.isEmpty(portMatch.selection)) {\n return { value: ipMatch.selection + ']', port: Number(portMatch.rest) }\n }\n } else {\n return { value: ipMatch.selection + ']', port: null }\n }\n }\n }\n\n let hostMatch: StringSplitResult = Strings.splitFirst(host, ':')\n\n // We have no :, which means no port, so treat the rest as the hostname\n if (Objects.isNil(hostMatch.selection)) {\n return { value: hostMatch.rest, port: null }\n }\n\n // The host started with a :, this is odd\n if (Strings.isEmpty(hostMatch.selection)) {\n throw new Error(`Unable to parse Host: ${host}`)\n }\n\n const hostName = hostMatch.selection\n\n // Otherwise, we have both, so return the complete authentication object and the rest\n return { value: hostName, port: Number(hostMatch.rest) }\n}\n\nconst parseLocation = (url: UriComponent): UriLocation => {\n const location: UriLocation = { path: '', query: null, fragment: null }\n\n // Lets see if we have a fragment and parse it off the end\n const fragmentMatch = Strings.splitFirst(url, '#')\n if (Objects.isPresent(fragmentMatch.selection) && !Strings.isEmpty(fragmentMatch.rest)) {\n location.fragment = fragmentMatch.rest\n }\n\n // Lets see if we have a query string and parse it off the remainder\n const queryMatch = Strings.splitFirst(fragmentMatch.selection ?? fragmentMatch.rest, '?')\n if (Objects.isPresent(queryMatch.selection) && !Strings.isEmpty(queryMatch.rest)) {\n location.query = queryMatch.rest\n }\n\n location.path = queryMatch.selection ?? queryMatch.rest\n return location\n}\n\nexport const parse = (urlString: UriString): Uri => {\n const [scheme, rest1] = parseSchemePart(urlString)\n const [authentication, rest2] = parseAuthenticationPart(rest1)\n const [host, rest3] = parseHostPart(rest2)\n const location = parseLocation(rest3)\n const url: Uri = { scheme, host, authentication, location }\n return url\n}\n\nexport const emptyLocation = (): UriLocation => {\n return {\n path: '',\n query: null,\n fragment: null,\n }\n}\n\nexport type UriBuilder = {\n scheme?: string\n host?:\n | {\n value: string\n port?: number\n }\n | string\n authentication?:\n | {\n principal: string\n password?: string\n }\n | string\n location?:\n | {\n path: string\n query?: string\n fragment?: string\n }\n | string\n}\n\nexport const build = (builder: UriBuilder): Uri => {\n const scheme = builder.scheme ?? null\n\n let host: UriHost | null = null\n if (Objects.isPresent(builder.host)) {\n if (Strings.isString(builder.host)) {\n host = parseHost(builder.host)\n } else {\n host = {\n value: builder.host.value,\n port: builder.host.port ?? null,\n }\n }\n }\n\n let authentication: UriAuthentication | null = null\n if (Objects.isPresent(builder.authentication)) {\n if (Strings.isString(builder.authentication)) {\n authentication = parseAuthentication(builder.authentication)\n } else {\n authentication = {\n principal: builder.authentication.principal,\n password: builder.authentication.password ?? null,\n }\n }\n }\n\n let location: UriLocation = emptyLocation()\n if (Objects.isPresent(builder.location)) {\n if (Strings.isString(builder.location)) {\n location = parseLocation(builder.location)\n } else {\n location = {\n path: builder.location.path,\n query: builder.location.query ?? null,\n fragment: builder.location.fragment ?? null,\n }\n }\n }\n\n return {\n scheme,\n host,\n authentication,\n location,\n }\n}\n\nexport enum UriComponentType {\n Scheme = 'Scheme',\n Host = 'Host',\n Location = 'Location',\n}\n\nexport const format = (uri: Uri, format: Array<UriComponentType> = Object.values(UriComponentType)): UriString => {\n let urlString = ''\n if (Objects.isPresent(uri.scheme) && Arrays.contains(format, UriComponentType.Scheme)) {\n urlString = urlString + uri.scheme\n }\n\n if (Objects.isPresent(uri.host) && Arrays.contains(format, UriComponentType.Host)) {\n if (Objects.isPresent(uri.scheme)) {\n urlString = urlString + '://'\n }\n\n if (Objects.isPresent(uri.authentication)) {\n urlString = urlString + uri.authentication.principal\n\n if (Objects.isPresent(uri.authentication.password)) {\n urlString = urlString + ':' + uri.authentication.password\n }\n\n urlString = urlString + '@'\n }\n\n urlString = urlString + uri.host.value\n\n if (Objects.isPresent(uri.host.port)) {\n urlString = urlString + ':' + uri.host.port\n }\n }\n\n if (Arrays.contains(format, UriComponentType.Location)) {\n urlString = urlString + formatLocation(uri.location, format)\n }\n return urlString\n}\n\nconst formatLocation = (location: UriLocation, format: Array<UriComponentType>): string => {\n let urlString = ''\n\n if (!Strings.isEmpty(location.path)) {\n urlString = urlString + location.path\n }\n\n if (!Strings.isEmpty(location.query)) {\n urlString = urlString + '?' + location.query\n }\n\n if (!Strings.isEmpty(location.fragment)) {\n urlString = urlString + '#' + encode(location.fragment!)\n }\n\n return urlString\n}\n\nexport const buildString = (builder: UriBuilder): UriString => {\n return format(build(builder))\n}\n"],"mappings":";AAAA,SAAS,QAAQ,SAAS,eAAe;AAIlC,IAAM,SAAS,CAAC,iBAA+B;AACpD,SAAO,mBAAmB,YAAY;AACxC;AAEO,IAAM,SAAS,CAAC,iBAA+B;AACpD,SAAO,mBAAmB,YAAY;AACxC;AA8BA,IAAM,kBAAkB,CAAC,QAAwD;AAE/E,QAAM,cAAc,QAAQ,WAAW,KAAK,UAAU;AAGtD,MAAI,QAAQ,MAAM,YAAY,SAAS,KAAK,YAAY,cAAc,MAAM;AAC1E,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M,GAAG;AACjC,kBAAY,YAAY;AAAA,IAC1B;AAEA,QAAI,QAAQ,UAAU,IAAI,cAAc,GAAG;AACzC,kBAAY,YAAY,IAAI,eAAe;AAE3C,UAAI,QAAQ,UAAU,IAAI,eAAe,QAAQ,GAAG;AAClD,oBAAY,YAAY,MAAM,IAAI,eAAe;AAAA,MACnD;AAEA,kBAAY,YAAY;AAAA,IAC1B;AAEA,gBAAY,YAAY,IAAI,KAAK;AAEjC,QAAI,QAAQ,UAAU,IAAI,KAAK,IAAI,GAAG;AACpC,kBAAY,YAAY,MAAM,IAAI,KAAK;AAAA,IACzC;AAAA,EACF;AAEA,MAAI,OAAO,SAASA,SAAQ,yBAAyB,GAAG;AACtD,gBAAY,YAAY,eAAe,IAAI,UAAUA,OAAM;AAAA,EAC7D;AACA,SAAO;AACT;AAEA,IAAM,iBAAiB,CAAC,UAAuBA,YAA4C;AACzF,MAAI,YAAY;AAEhB,MAAI,CAAC,QAAQ,QAAQ,SAAS,IAAI,GAAG;AACnC,gBAAY,YAAY,SAAS;AAAA,EACnC;AAEA,MAAI,CAAC,QAAQ,QAAQ,SAAS,KAAK,GAAG;AACpC,gBAAY,YAAY,MAAM,SAAS;AAAA,EACzC;AAEA,MAAI,CAAC,QAAQ,QAAQ,SAAS,QAAQ,GAAG;AACvC,gBAAY,YAAY,MAAM,OAAO,SAAS,QAAS;AAAA,EACzD;AAEA,SAAO;AACT;AAEO,IAAM,cAAc,CAAC,YAAmC;AAC7D,SAAO,OAAO,MAAM,OAAO,CAAC;AAC9B;","names":["UriComponentType","format"]}
package/dist/url.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Uris } from '@bessemer/cornerstone';
1
2
  import { Dictionary } from '@bessemer/cornerstone/types';
2
3
  import { Uri, UriBuilder, UriComponent, UriLocation, UriString } from '@bessemer/cornerstone/uri';
3
4
  export declare const encode: (uriComponent: UriComponent) => string;
@@ -11,7 +12,7 @@ export interface Url extends Uri {
11
12
  }
12
13
  export type UrlLike = Url | UriString;
13
14
  export declare const parse: (urlString: UriString, normalize?: boolean) => Url;
14
- export declare const format: (uri: Uri) => UriString;
15
+ export declare const format: (uri: Uri, format?: Array<Uris.UriComponentType>) => UriString;
15
16
  export type UrlBuilder = UriBuilder & {
16
17
  location?: {
17
18
  parameters?: Dictionary<string | Array<string>>;
package/dist/url.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAEjG,eAAO,MAAM,MAAM,wCAAc,CAAA;AAEjC,eAAO,MAAM,MAAM,wCAAc,CAAA;AAEjC,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC3B,UAAU,EAAE,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;CAC/C;AAED,MAAM,WAAW,GAAI,SAAQ,GAAG;IAC9B,QAAQ,EAAE,WAAW,CAAA;CACtB;AAED,MAAM,MAAM,OAAO,GAAG,GAAG,GAAG,SAAS,CAAA;AA8CrC,eAAO,MAAM,KAAK,GAAI,WAAW,SAAS,EAAE,YAAW,OAAc,KAAG,GAkBvE,CAAA;AAED,eAAO,MAAM,MAAM,yBAAc,CAAA;AAuBjC,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,QAAQ,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;KAChD,CAAA;CACF,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,SAAS,UAAU,KAAG,GAY3C,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,SAAS,UAAU,KAAG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AAC,EAAE,MAAM,OAAO,KAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAEnF,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM,KAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAOvF,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM,KAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAEtF,CAAA"}
package/dist/zod.js CHANGED
@@ -33,7 +33,11 @@ var parseOrThrow = (type, data) => {
33
33
  return Results.getValueOrThrow(parse(type, data));
34
34
  };
35
35
  var parseJson = (type, data) => {
36
- return parse(type, Json.parse(data));
36
+ const result = Json.parse(data);
37
+ if (!result.isSuccess) {
38
+ return result;
39
+ }
40
+ return parse(type, result.value);
37
41
  };
38
42
  var parseJsonOrThrow = (type, data) => {
39
43
  return parseJson(type, data);
package/dist/zod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/zod.ts"],"sourcesContent":["import Zod, { ZodType } from 'zod'\nimport { ResourceKey } from '@bessemer/cornerstone/resource'\nimport { Entry } from '@bessemer/cornerstone/entry'\nimport { Json, Results } from '@bessemer/cornerstone'\nimport { Result } from '@bessemer/cornerstone/result'\n\nexport type infer<T extends ZodType<any, any, any>> = Zod.infer<T>\nexport const object = Zod.object\nexport const string = Zod.string\nexport const union = Zod.union\nexport const array = Zod.array\nexport const unknown = Zod.unknown\nexport const nullType = Zod.null\nexport const undefined = Zod.undefined\nexport const date = Zod.date\nexport const boolean = Zod.boolean\nexport const number = Zod.number\nexport const tuple = Zod.tuple\n\nexport const arrayable = <T>(type: ZodType<T>) => {\n return union([type, array(type)])\n}\n\nexport const key = (): ZodType<ResourceKey> => {\n return string()\n}\n\nexport const entry = <Value, Key = string>(value: ZodType<Value>, key?: ZodType<Key>): ZodType<Entry<Value, Key>> => {\n return tuple([key ?? string(), value]) as ZodType<Entry<Value, Key>>\n}\n\nexport const parse = <T extends ZodType>(type: T, data: unknown): Result<Zod.infer<T>> => {\n const result = type.safeParse(data)\n if (result.success) {\n return Results.success(result.data)\n } else {\n return Results.failure(result.error)\n }\n}\n\nexport const parseOrThrow = <T extends ZodType>(type: T, data: unknown): Zod.infer<T> => {\n return Results.getValueOrThrow(parse(type, data))\n}\n\nexport const parseJson = <T extends ZodType>(type: T, data: string): Result<Zod.infer<T>> => {\n return parse(type, Json.parse(data))\n}\n\nexport const parseJsonOrThrow = <T extends ZodType>(type: T, data: string): Zod.infer<T> => {\n return parseJson(type, data)\n}\n"],"mappings":";AAAA,OAAO,SAAsB;AAG7B,SAAS,MAAM,eAAe;AAIvB,IAAM,SAAS,IAAI;AACnB,IAAM,SAAS,IAAI;AACnB,IAAM,QAAQ,IAAI;AAClB,IAAM,QAAQ,IAAI;AAClB,IAAM,UAAU,IAAI;AACpB,IAAM,WAAW,IAAI;AACrB,IAAM,YAAY,IAAI;AACtB,IAAM,OAAO,IAAI;AACjB,IAAM,UAAU,IAAI;AACpB,IAAM,SAAS,IAAI;AACnB,IAAM,QAAQ,IAAI;AAElB,IAAM,YAAY,CAAI,SAAqB;AAChD,SAAO,MAAM,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC;AAClC;AAEO,IAAM,MAAM,MAA4B;AAC7C,SAAO,OAAO;AAChB;AAEO,IAAM,QAAQ,CAAsB,OAAuBA,SAAmD;AACnH,SAAO,MAAM,CAACA,QAAO,OAAO,GAAG,KAAK,CAAC;AACvC;AAEO,IAAM,QAAQ,CAAoB,MAAS,SAAwC;AACxF,QAAM,SAAS,KAAK,UAAU,IAAI;AAClC,MAAI,OAAO,SAAS;AAClB,WAAO,QAAQ,QAAQ,OAAO,IAAI;AAAA,EACpC,OAAO;AACL,WAAO,QAAQ,QAAQ,OAAO,KAAK;AAAA,EACrC;AACF;AAEO,IAAM,eAAe,CAAoB,MAAS,SAAgC;AACvF,SAAO,QAAQ,gBAAgB,MAAM,MAAM,IAAI,CAAC;AAClD;AAEO,IAAM,YAAY,CAAoB,MAAS,SAAuC;AAC3F,SAAO,MAAM,MAAM,KAAK,MAAM,IAAI,CAAC;AACrC;AAEO,IAAM,mBAAmB,CAAoB,MAAS,SAA+B;AAC1F,SAAO,UAAU,MAAM,IAAI;AAC7B;","names":["key"]}
1
+ {"version":3,"sources":["../src/zod.ts"],"sourcesContent":["import Zod, { ZodType } from 'zod'\nimport { ResourceKey } from '@bessemer/cornerstone/resource'\nimport { Entry } from '@bessemer/cornerstone/entry'\nimport { Json, Results } from '@bessemer/cornerstone'\nimport { Result } from '@bessemer/cornerstone/result'\n\nexport type infer<T extends ZodType<any, any, any>> = Zod.infer<T>\nexport const object = Zod.object\nexport const string = Zod.string\nexport const union = Zod.union\nexport const array = Zod.array\nexport const unknown = Zod.unknown\nexport const nullType = Zod.null\nexport const undefined = Zod.undefined\nexport const date = Zod.date\nexport const boolean = Zod.boolean\nexport const number = Zod.number\nexport const tuple = Zod.tuple\n\nexport const arrayable = <T>(type: ZodType<T>) => {\n return union([type, array(type)])\n}\n\nexport const key = (): ZodType<ResourceKey> => {\n return string()\n}\n\nexport const entry = <Value, Key = string>(value: ZodType<Value>, key?: ZodType<Key>): ZodType<Entry<Value, Key>> => {\n return tuple([key ?? string(), value]) as ZodType<Entry<Value, Key>>\n}\n\nexport const parse = <T extends ZodType>(type: T, data: unknown): Result<Zod.infer<T>> => {\n const result = type.safeParse(data)\n if (result.success) {\n return Results.success(result.data)\n } else {\n return Results.failure(result.error)\n }\n}\n\nexport const parseOrThrow = <T extends ZodType>(type: T, data: unknown): Zod.infer<T> => {\n return Results.getValueOrThrow(parse(type, data))\n}\n\nexport const parseJson = <T extends ZodType>(type: T, data: string): Result<Zod.infer<T>> => {\n const result = Json.parse(data)\n if (!result.isSuccess) {\n return result\n }\n\n return parse(type, result.value)\n}\n\nexport const parseJsonOrThrow = <T extends ZodType>(type: T, data: string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ornerstone",
3
3
  "type": "module",
4
- "version": "0.5.35",
4
+ "version": "0.5.37",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "sideEffects": false,