@atcute/lexicons 1.0.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.
Files changed (91) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +11 -0
  3. package/dist/ambient.d.ts +8 -0
  4. package/dist/ambient.js +2 -0
  5. package/dist/ambient.js.map +1 -0
  6. package/dist/index.d.ts +16 -0
  7. package/dist/index.js +3 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/interfaces/blob.d.ts +20 -0
  10. package/dist/interfaces/blob.js +20 -0
  11. package/dist/interfaces/blob.js.map +1 -0
  12. package/dist/interfaces/bytes.d.ts +23 -0
  13. package/dist/interfaces/bytes.js +21 -0
  14. package/dist/interfaces/bytes.js.map +1 -0
  15. package/dist/interfaces/cid-link.d.ts +24 -0
  16. package/dist/interfaces/cid-link.js +13 -0
  17. package/dist/interfaces/cid-link.js.map +1 -0
  18. package/dist/interfaces/index.d.ts +3 -0
  19. package/dist/interfaces/index.js +4 -0
  20. package/dist/interfaces/index.js.map +1 -0
  21. package/dist/syntax/at-identifier.d.ts +8 -0
  22. package/dist/syntax/at-identifier.js +7 -0
  23. package/dist/syntax/at-identifier.js.map +1 -0
  24. package/dist/syntax/at-uri.d.ts +46 -0
  25. package/dist/syntax/at-uri.js +64 -0
  26. package/dist/syntax/at-uri.js.map +1 -0
  27. package/dist/syntax/cid.d.ts +5 -0
  28. package/dist/syntax/cid.js +10 -0
  29. package/dist/syntax/cid.js.map +1 -0
  30. package/dist/syntax/datetime.d.ts +2 -0
  31. package/dist/syntax/datetime.js +6 -0
  32. package/dist/syntax/datetime.js.map +1 -0
  33. package/dist/syntax/did.d.ts +9 -0
  34. package/dist/syntax/did.js +6 -0
  35. package/dist/syntax/did.js.map +1 -0
  36. package/dist/syntax/handle.d.ts +6 -0
  37. package/dist/syntax/handle.js +6 -0
  38. package/dist/syntax/handle.js.map +1 -0
  39. package/dist/syntax/index.d.ts +11 -0
  40. package/dist/syntax/index.js +12 -0
  41. package/dist/syntax/index.js.map +1 -0
  42. package/dist/syntax/language.d.ts +2 -0
  43. package/dist/syntax/language.js +6 -0
  44. package/dist/syntax/language.js.map +1 -0
  45. package/dist/syntax/nsid.d.ts +5 -0
  46. package/dist/syntax/nsid.js +6 -0
  47. package/dist/syntax/nsid.js.map +1 -0
  48. package/dist/syntax/record-key.d.ts +5 -0
  49. package/dist/syntax/record-key.js +6 -0
  50. package/dist/syntax/record-key.js.map +1 -0
  51. package/dist/syntax/tid.d.ts +5 -0
  52. package/dist/syntax/tid.js +6 -0
  53. package/dist/syntax/tid.js.map +1 -0
  54. package/dist/syntax/uri.d.ts +5 -0
  55. package/dist/syntax/uri.js +6 -0
  56. package/dist/syntax/uri.js.map +1 -0
  57. package/dist/types/brand.d.ts +13 -0
  58. package/dist/types/brand.js +2 -0
  59. package/dist/types/brand.js.map +1 -0
  60. package/dist/utils.d.ts +11 -0
  61. package/dist/utils.js +12 -0
  62. package/dist/utils.js.map +1 -0
  63. package/dist/validations/index.d.ts +409 -0
  64. package/dist/validations/index.js +1003 -0
  65. package/dist/validations/index.js.map +1 -0
  66. package/dist/validations/utils.d.ts +8 -0
  67. package/dist/validations/utils.js +54 -0
  68. package/dist/validations/utils.js.map +1 -0
  69. package/lib/ambient.ts +7 -0
  70. package/lib/index.ts +38 -0
  71. package/lib/interfaces/blob.ts +47 -0
  72. package/lib/interfaces/bytes.ts +45 -0
  73. package/lib/interfaces/cid-link.ts +36 -0
  74. package/lib/interfaces/index.ts +3 -0
  75. package/lib/syntax/at-identifier.ts +13 -0
  76. package/lib/syntax/at-uri.ts +117 -0
  77. package/lib/syntax/cid.ts +16 -0
  78. package/lib/syntax/datetime.ts +9 -0
  79. package/lib/syntax/did.ts +16 -0
  80. package/lib/syntax/handle.ts +13 -0
  81. package/lib/syntax/index.ts +11 -0
  82. package/lib/syntax/language.ts +9 -0
  83. package/lib/syntax/nsid.ts +12 -0
  84. package/lib/syntax/record-key.ts +11 -0
  85. package/lib/syntax/tid.ts +11 -0
  86. package/lib/syntax/uri.ts +11 -0
  87. package/lib/types/brand.ts +11 -0
  88. package/lib/utils.ts +15 -0
  89. package/lib/validations/index.ts +1749 -0
  90. package/lib/validations/utils.ts +62 -0
  91. package/package.json +35 -0
package/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2
+ of this software and associated documentation files (the "Software"), to deal
3
+ in the Software without restriction, including without limitation the rights
4
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ copies of the Software, and to permit persons to whom the Software is
6
+ furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all
9
+ copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @atcute/lexicons
2
+
3
+ AT Protocol core lexicon types, interfaces, and schema validations
4
+
5
+ ```ts
6
+ import { isHandle, isDid } from '@atcute/lexicons/syntax';
7
+
8
+ isHandle('example.com');
9
+
10
+ isDid('did:web:example.com');
11
+ ```
@@ -0,0 +1,8 @@
1
+ export interface XRPCQueries {
2
+ }
3
+ export interface XRPCProcedures {
4
+ }
5
+ export interface XRPCSubscriptions {
6
+ }
7
+ export interface Records {
8
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ambient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ambient.js","sourceRoot":"","sources":["../lib/ambient.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ export type { ActorIdentifier } from './syntax/at-identifier.js';
2
+ export { isCanonicalResourceUri, isResourceUri, parseCanonicalResourceUri, parseResourceUri, type CanonicalResourceUri, type ParsedCanonicalResourceUri, type ParsedResourceUri, type ResourceUri, } from './syntax/at-uri.js';
3
+ export type { Cid } from './syntax/cid.js';
4
+ export type { Datetime } from './syntax/datetime.js';
5
+ export type { Did } from './syntax/did.js';
6
+ export type { Handle } from './syntax/handle.js';
7
+ export type { LanguageCode } from './syntax/language.js';
8
+ export type { Nsid } from './syntax/nsid.js';
9
+ export type { RecordKey } from './syntax/record-key.js';
10
+ export type { Tid } from './syntax/tid.js';
11
+ export type { GenericUri } from './syntax/uri.js';
12
+ export type { Blob, LegacyBlob } from './interfaces/blob.js';
13
+ export type { Bytes } from './interfaces/bytes.js';
14
+ export type { CidLink } from './interfaces/cid-link.js';
15
+ export type { $type } from './types/brand.js';
16
+ export { is, parse, safeParse, ValidationError, type InferInput, type InferOutput, type InferXRPCBodyInput, type InferXRPCBodyOutput, type ValidationResult, } from './validations/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { isCanonicalResourceUri, isResourceUri, parseCanonicalResourceUri, parseResourceUri, } from './syntax/at-uri.js';
2
+ export { is, parse, safeParse, ValidationError, } from './validations/index.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,sBAAsB,EACtB,aAAa,EACb,yBAAyB,EACzB,gBAAgB,GAKhB,MAAM,oBAAoB,CAAC;AAiB5B,OAAO,EACN,EAAE,EACF,KAAK,EACL,SAAS,EACT,eAAe,GAMf,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Cid } from '../syntax/cid.js';
2
+ import { type CidLink } from './cid-link.js';
3
+ /**
4
+ * represents a reference to a data blob
5
+ */
6
+ export interface Blob<TMime extends string = string> {
7
+ $type: 'blob';
8
+ mimeType: TMime;
9
+ ref: CidLink;
10
+ size: number;
11
+ }
12
+ export declare const isBlob: (input: unknown) => input is Blob;
13
+ /**
14
+ * deprecated interface representing an interface to a data blob
15
+ */
16
+ export interface LegacyBlob<TMime extends string = string> {
17
+ cid: Cid;
18
+ mimeType: TMime;
19
+ }
20
+ export declare const isLegacyBlob: (input: unknown) => input is LegacyBlob;
@@ -0,0 +1,20 @@
1
+ import { isCidLink } from './cid-link.js';
2
+ export const isBlob = (input) => {
3
+ const v = input;
4
+ return (typeof v === 'object' &&
5
+ v !== null &&
6
+ v.$type === 'blob' &&
7
+ typeof v.mimeType === 'string' &&
8
+ Number.isSafeInteger(v.size) &&
9
+ isCidLink(v.ref) &&
10
+ Object.keys(v).length === 4);
11
+ };
12
+ export const isLegacyBlob = (input) => {
13
+ const v = input;
14
+ return (typeof v === 'object' &&
15
+ v !== null &&
16
+ typeof v.cid === 'string' &&
17
+ typeof v.mimeType === 'string' &&
18
+ Object.keys(v).length === 2);
19
+ };
20
+ //# sourceMappingURL=blob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob.js","sourceRoot":"","sources":["../../lib/interfaces/blob.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAgB,MAAM,eAAe,CAAC;AAYxD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE;IACvD,MAAM,CAAC,GAAG,KAAY,CAAC;IAEvB,OAAO,CACN,OAAO,CAAC,KAAK,QAAQ;QACrB,CAAC,KAAK,IAAI;QACV,CAAC,CAAC,KAAK,KAAK,MAAM;QAClB,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;QAC9B,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5B,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAC3B,CAAC;AACH,CAAC,CAAC;AAUF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuB,EAAE;IACnE,MAAM,CAAC,GAAG,KAAY,CAAC;IAEvB,OAAO,CACN,OAAO,CAAC,KAAK,QAAQ;QACrB,CAAC,KAAK,IAAI;QACV,OAAO,CAAC,CAAC,GAAG,KAAK,QAAQ;QACzB,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;QAC9B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAC3B,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * represents an object containing raw binary data encoded as a base64 string
3
+ */
4
+ export interface Bytes {
5
+ $bytes: string;
6
+ }
7
+ declare const BYTES_SYMBOL: unique symbol;
8
+ /**
9
+ * this should match with {@link file://./../../../../utilities/cbor/lib/bytes.ts}
10
+ * @internal
11
+ */
12
+ export interface _BytesWrapper {
13
+ readonly [BYTES_SYMBOL]: true;
14
+ readonly buf: Uint8Array;
15
+ readonly $bytes: string;
16
+ toJSON(): Bytes;
17
+ }
18
+ /**
19
+ * @internal
20
+ */
21
+ export declare const _isBytesWrapper: (input: unknown) => input is _BytesWrapper;
22
+ export declare const isBytes: (input: unknown) => input is Bytes;
23
+ export {};
@@ -0,0 +1,21 @@
1
+ const BYTES_SYMBOL = Symbol.for('@atcute/bytes-wrapper');
2
+ /**
3
+ * @internal
4
+ */
5
+ // #__NO_SIDE_EFFECTS__
6
+ export const _isBytesWrapper = (input) => {
7
+ return typeof input === 'object' && input !== null && BYTES_SYMBOL in input;
8
+ };
9
+ const BASE64_RE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}(?:==)?|[A-Za-z0-9+/]{3}=?)?$/;
10
+ const isBase64 = (input) => {
11
+ if (typeof input !== 'string') {
12
+ return false;
13
+ }
14
+ return BASE64_RE.test(input);
15
+ };
16
+ // #__NO_SIDE_EFFECTS__
17
+ export const isBytes = (input) => {
18
+ const v = input;
19
+ return typeof v === 'object' && v !== null && (BYTES_SYMBOL in v || isBase64(v.$bytes));
20
+ };
21
+ //# sourceMappingURL=bytes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../lib/interfaces/bytes.ts"],"names":[],"mappings":"AAOA,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAezD;;GAEG;AACH,uBAAuB;AACvB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAc,EAA0B,EAAE;IACzE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,YAAY,IAAI,KAAK,CAAC;AAC7E,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,wEAAwE,CAAC;AAC3F,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF,uBAAuB;AACvB,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAc,EAAkB,EAAE;IACzD,MAAM,CAAC,GAAG,KAAY,CAAC;IAEvB,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACzF,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { type Cid } from '../syntax/cid.js';
2
+ /**
3
+ * represents a content identifier (CID) reference
4
+ */
5
+ export interface CidLink {
6
+ $link: Cid;
7
+ }
8
+ declare const CID_LINK_SYMBOL: unique symbol;
9
+ /**
10
+ * this should match with {@link file://./../../../../utilities/cid/lib/cid-link.ts}
11
+ * @internal
12
+ */
13
+ export interface _CidLinkWrapper {
14
+ readonly [CID_LINK_SYMBOL]: true;
15
+ readonly bytes: Uint8Array;
16
+ readonly $link: string;
17
+ toJSON(): CidLink;
18
+ }
19
+ /**
20
+ * @internal
21
+ */
22
+ export declare const _isCidLinkWrapper: (input: unknown) => input is _CidLinkWrapper;
23
+ export declare const isCidLink: (input: unknown) => input is CidLink;
24
+ export {};
@@ -0,0 +1,13 @@
1
+ import { isCid } from '../syntax/cid.js';
2
+ const CID_LINK_SYMBOL = Symbol.for('@atcute/cid-link-wrapper');
3
+ /**
4
+ * @internal
5
+ */
6
+ export const _isCidLinkWrapper = (input) => {
7
+ return typeof input === 'object' && input !== null && CID_LINK_SYMBOL in input;
8
+ };
9
+ export const isCidLink = (input) => {
10
+ const v = input;
11
+ return typeof v === 'object' && v !== null && (CID_LINK_SYMBOL in v || isCid(v.$link));
12
+ };
13
+ //# sourceMappingURL=cid-link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cid-link.js","sourceRoot":"","sources":["../../lib/interfaces/cid-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAY,MAAM,kBAAkB,CAAC;AASnD,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAe/D;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAA4B,EAAE;IAC7E,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,eAAe,IAAI,KAAK,CAAC;AAChF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAoB,EAAE;IAC7D,MAAM,CAAC,GAAG,KAAY,CAAC;IAEvB,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { isBlob, isLegacyBlob, type Blob, type LegacyBlob } from './blob.js';
2
+ export { isBytes, type Bytes } from './bytes.js';
3
+ export { isCidLink, type CidLink } from './cid-link.js';
@@ -0,0 +1,4 @@
1
+ export { isBlob, isLegacyBlob } from './blob.js';
2
+ export { isBytes } from './bytes.js';
3
+ export { isCidLink } from './cid-link.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAA8B,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAc,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,SAAS,EAAgB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type Did } from './did.js';
2
+ import { type Handle } from './handle.js';
3
+ /**
4
+ * represents an account's identifier, either a {@link Did} or a
5
+ * {@link Handle}
6
+ */
7
+ export type ActorIdentifier = Did | Handle;
8
+ export declare const isActorIdentifier: (input: unknown) => input is ActorIdentifier;
@@ -0,0 +1,7 @@
1
+ import { isDid } from './did.js';
2
+ import { isHandle } from './handle.js';
3
+ // #__NO_SIDE_EFFECTS__
4
+ export const isActorIdentifier = (input) => {
5
+ return isDid(input) || isHandle(input);
6
+ };
7
+ //# sourceMappingURL=at-identifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"at-identifier.js","sourceRoot":"","sources":["../../lib/syntax/at-identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAY,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAe,MAAM,aAAa,CAAC;AAQpD,uBAAuB;AACvB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAA4B,EAAE;IAC7E,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { type ActorIdentifier } from './at-identifier.js';
2
+ import { type Did } from './did.js';
3
+ import { type Nsid } from './nsid.js';
4
+ import { type RecordKey } from './record-key.js';
5
+ import { type Result } from '../utils.js';
6
+ /**
7
+ * represents a general AT Protocol URI, representing either an entire
8
+ * repository, a specific collection within a repository, or a record.
9
+ *
10
+ * it allows using handles over DIDs, but this means that it won't be stable.
11
+ */
12
+ export type ResourceUri = `at://${ActorIdentifier}` | `at://${ActorIdentifier}/${Nsid}` | `at://${ActorIdentifier}/${Nsid}/${RecordKey}`;
13
+ export type ParsedResourceUri = {
14
+ repo: ActorIdentifier;
15
+ collection: undefined;
16
+ rkey: undefined;
17
+ fragment: string | undefined;
18
+ } | {
19
+ repo: ActorIdentifier;
20
+ collection: Nsid;
21
+ rkey: undefined;
22
+ fragment: string | undefined;
23
+ } | {
24
+ repo: ActorIdentifier;
25
+ collection: Nsid;
26
+ rkey: RecordKey;
27
+ fragment: string | undefined;
28
+ };
29
+ export declare const isResourceUri: (input: unknown) => input is ResourceUri;
30
+ export declare const parseResourceUri: (input: string) => Result<ParsedResourceUri, string>;
31
+ /**
32
+ * represents a canonical AT Protocol URI for a specific record.
33
+ *
34
+ * this URI format uses the account's DID as the authority, ensuring that
35
+ * the URI remains valid even as the account changes handles, uniquely
36
+ * identifying a specific piece of record within AT Protocol.
37
+ */
38
+ export type CanonicalResourceUri = `at://${Did}/${Nsid}/${RecordKey}`;
39
+ export type ParsedCanonicalResourceUri = {
40
+ repo: Did;
41
+ collection: Nsid;
42
+ rkey: RecordKey;
43
+ fragment: string | undefined;
44
+ };
45
+ export declare const isCanonicalResourceUri: (input: string) => input is CanonicalResourceUri;
46
+ export declare const parseCanonicalResourceUri: (input: string) => Result<ParsedCanonicalResourceUri, string>;
@@ -0,0 +1,64 @@
1
+ import { isActorIdentifier } from './at-identifier.js';
2
+ import { isDid } from './did.js';
3
+ import { isNsid } from './nsid.js';
4
+ import { isRecordKey } from './record-key.js';
5
+ import {} from '../utils.js';
6
+ const ATURI_RE = /^at:\/\/([a-zA-Z0-9._:%-]+)(?:\/([a-zA-Z0-9-.]+)(?:\/([a-zA-Z0-9._~:@!$&%')(*+,;=-]+))?)?(?:#(\/[a-zA-Z0-9._~:@!$&%')(*+,;=\-[\]/\\]*))?$/;
7
+ // #__NO_SIDE_EFFECTS__
8
+ export const isResourceUri = (input) => {
9
+ if (typeof input !== 'string') {
10
+ return false;
11
+ }
12
+ const match = ATURI_RE.exec(input);
13
+ if (match === null) {
14
+ return false;
15
+ }
16
+ const [, r, c, k] = match;
17
+ return isActorIdentifier(r) && (c === undefined || isNsid(c)) && (k === undefined || isRecordKey(k));
18
+ };
19
+ // #__NO_SIDE_EFFECTS__
20
+ export const parseResourceUri = (input) => {
21
+ const match = ATURI_RE.exec(input);
22
+ if (match === null) {
23
+ return { ok: false, error: `invalid at-uri: ${input}` };
24
+ }
25
+ const [, r, c, k, f] = match;
26
+ if (!isActorIdentifier(r)) {
27
+ return { ok: false, error: `invalid repo in at-uri: ${r}` };
28
+ }
29
+ if (c !== undefined && !isNsid(c)) {
30
+ return { ok: false, error: `invalid collection in at-uri: ${c}` };
31
+ }
32
+ if (k !== undefined && !isRecordKey(k)) {
33
+ return { ok: false, error: `invalid rkey in at-uri: ${k}` };
34
+ }
35
+ return { ok: true, value: { repo: r, collection: c, rkey: k, fragment: f } };
36
+ };
37
+ // #__NO_SIDE_EFFECTS__
38
+ export const isCanonicalResourceUri = (input) => {
39
+ const match = ATURI_RE.exec(input);
40
+ if (match === null) {
41
+ return false;
42
+ }
43
+ const [, r, c, k] = match;
44
+ return isDid(r) && isNsid(c) && isRecordKey(k);
45
+ };
46
+ // #__NO_SIDE_EFFECTS__
47
+ export const parseCanonicalResourceUri = (input) => {
48
+ const match = ATURI_RE.exec(input);
49
+ if (match === null) {
50
+ return { ok: false, error: `invalid canonical-at-uri: ${input}` };
51
+ }
52
+ const [, r, c, k, f] = match;
53
+ if (!isDid(r)) {
54
+ return { ok: false, error: `invalid repo in canonical-at-uri: ${r}` };
55
+ }
56
+ if (!isNsid(c)) {
57
+ return { ok: false, error: `invalid collection in canonical-at-uri: ${c}` };
58
+ }
59
+ if (!isRecordKey(k)) {
60
+ return { ok: false, error: `invalid rkey in canonical-at-uri: ${k}` };
61
+ }
62
+ return { ok: true, value: { repo: r, collection: c, rkey: k, fragment: f } };
63
+ };
64
+ //# sourceMappingURL=at-uri.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"at-uri.js","sourceRoot":"","sources":["../../lib/syntax/at-uri.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * represents a content identifier (CID)
3
+ */
4
+ export type Cid = string;
5
+ export declare const isCid: (input: unknown) => input is Cid;
@@ -0,0 +1,10 @@
1
+ const DASL_CID_RE = /^baf[ky]re(?:aa|i[a-z2-7]{52})$/;
2
+ // #__NO_SIDE_EFFECTS__
3
+ export const isCid = (input) => {
4
+ if (typeof input !== 'string') {
5
+ return false;
6
+ }
7
+ const length = input.length;
8
+ return (length === 8 || length === 59) && DASL_CID_RE.test(input);
9
+ };
10
+ //# sourceMappingURL=cid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cid.js","sourceRoot":"","sources":["../../lib/syntax/cid.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,GAAG,iCAAiC,CAAC;AAEtD,uBAAuB;AACvB,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAc,EAAgB,EAAE;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,EAAE,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type Datetime = string;
2
+ export declare const isDatetime: (input: unknown) => input is Datetime;
@@ -0,0 +1,6 @@
1
+ const DATE_TIME_RE = /^((?!0{3})\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))T((?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d))(\.\d+)?(Z|(?!-00:00)[+-](?:[01]\d|2[0-3]):(?:[0-5]\d))$/;
2
+ // #__NO_SIDE_EFFECTS__
3
+ export const isDatetime = (input) => {
4
+ return typeof input === 'string' && input.length >= 20 && input.length <= 64 && DATE_TIME_RE.test(input);
5
+ };
6
+ //# sourceMappingURL=datetime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datetime.js","sourceRoot":"","sources":["../../lib/syntax/datetime.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GACjB,gKAAgK,CAAC;AAElK,uBAAuB;AACvB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAqB,EAAE;IAC/D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1G,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * represents a decentralized identifier (DID).
3
+ */
4
+ export type Did<Method extends string = string> = `did:${Method}:${string}`;
5
+ /**
6
+ * represents a decentralized identifier with methods supported in atproto
7
+ */
8
+ export type AtprotoDid = Did<'plc' | 'web'>;
9
+ export declare const isDid: (input: unknown) => input is Did;
@@ -0,0 +1,6 @@
1
+ const DID_RE = /^did:([a-z]+):([a-zA-Z0-9._:%\-]*[a-zA-Z0-9._\-])$/;
2
+ // #__NO_SIDE_EFFECTS__
3
+ export const isDid = (input) => {
4
+ return typeof input === 'string' && input.length >= 7 && input.length <= 2048 && DID_RE.test(input);
5
+ };
6
+ //# sourceMappingURL=did.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did.js","sourceRoot":"","sources":["../../lib/syntax/did.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,GAAG,oDAAoD,CAAC;AAEpE,uBAAuB;AACvB,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAc,EAAgB,EAAE;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrG,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * represents an account's handle, using domains as a human-friendly
3
+ * identifier.
4
+ */
5
+ export type Handle = `${string}.${string}`;
6
+ export declare const isHandle: (input: unknown) => input is Handle;
@@ -0,0 +1,6 @@
1
+ const HANDLE_RE = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+([a-zA-Z][a-zA-Z0-9-]{0,61}[a-zA-Z])$/;
2
+ // #__NO_SIDE_EFFECTS__
3
+ export const isHandle = (input) => {
4
+ return typeof input === 'string' && input.length >= 3 && input.length <= 253 && HANDLE_RE.test(input);
5
+ };
6
+ //# sourceMappingURL=handle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle.js","sourceRoot":"","sources":["../../lib/syntax/handle.ts"],"names":[],"mappings":"AAMA,MAAM,SAAS,GACd,4FAA4F,CAAC;AAE9F,uBAAuB;AACvB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE;IAC3D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvG,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export * from './at-identifier.js';
2
+ export * from './at-uri.js';
3
+ export * from './cid.js';
4
+ export * from './datetime.js';
5
+ export * from './did.js';
6
+ export * from './handle.js';
7
+ export * from './language.js';
8
+ export * from './nsid.js';
9
+ export * from './record-key.js';
10
+ export * from './tid.js';
11
+ export * from './uri.js';
@@ -0,0 +1,12 @@
1
+ export * from './at-identifier.js';
2
+ export * from './at-uri.js';
3
+ export * from './cid.js';
4
+ export * from './datetime.js';
5
+ export * from './did.js';
6
+ export * from './handle.js';
7
+ export * from './language.js';
8
+ export * from './nsid.js';
9
+ export * from './record-key.js';
10
+ export * from './tid.js';
11
+ export * from './uri.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/syntax/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type LanguageCode = string;
2
+ export declare const isLanguageCode: (input: unknown) => input is LanguageCode;
@@ -0,0 +1,6 @@
1
+ const LANGUAGE_CODE_RE = /^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUseA>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUseB>x(-[A-Za-z0-9]{1,8})+))$/;
2
+ // #__NO_SIDE_EFFECTS__
3
+ export const isLanguageCode = (input) => {
4
+ return typeof input === 'string' && input.length >= 2 && LANGUAGE_CODE_RE.test(input);
5
+ };
6
+ //# sourceMappingURL=language.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.js","sourceRoot":"","sources":["../../lib/syntax/language.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GACrB,mlBAAmlB,CAAC;AAErlB,uBAAuB;AACvB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE;IACvE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * represents a namespace identifier (NSID)
3
+ */
4
+ export type Nsid = `${string}.${string}.${string}`;
5
+ export declare const isNsid: (input: unknown) => input is Nsid;
@@ -0,0 +1,6 @@
1
+ const NSID_RE = /^[a-zA-Z](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+\.[a-zA-Z][a-zA-Z0-9]{0,62}?$/;
2
+ // #__NO_SIDE_EFFECTS__
3
+ export const isNsid = (input) => {
4
+ return typeof input === 'string' && input.length >= 5 && input.length <= 317 && NSID_RE.test(input);
5
+ };
6
+ //# sourceMappingURL=nsid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nsid.js","sourceRoot":"","sources":["../../lib/syntax/nsid.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,GACZ,8HAA8H,CAAC;AAEhI,uBAAuB;AACvB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE;IACvD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrG,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * represents a record key
3
+ */
4
+ export type RecordKey = string;
5
+ export declare const isRecordKey: (input: unknown) => input is RecordKey;
@@ -0,0 +1,6 @@
1
+ const RECORD_KEY_RE = /^(?!\.{1,2}$)[a-zA-Z0-9_~.:-]{1,512}$/;
2
+ // #__NO_SIDE_EFFECTS__
3
+ export const isRecordKey = (input) => {
4
+ return typeof input === 'string' && input.length >= 1 && input.length <= 512 && RECORD_KEY_RE.test(input);
5
+ };
6
+ //# sourceMappingURL=record-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-key.js","sourceRoot":"","sources":["../../lib/syntax/record-key.ts"],"names":[],"mappings":"AAKA,MAAM,aAAa,GAAG,uCAAuC,CAAC;AAE9D,uBAAuB;AACvB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAsB,EAAE;IACjE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3G,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * represents a timestamp identifier (TID)
3
+ */
4
+ export type Tid = string;
5
+ export declare const isTid: (input: unknown) => input is Tid;
@@ -0,0 +1,6 @@
1
+ const TID_RE = /^[234567abcdefghij][234567abcdefghijklmnopqrstuvwxyz]{12}$/;
2
+ // #__NO_SIDE_EFFECTS__
3
+ export const isTid = (input) => {
4
+ return typeof input === 'string' && input.length === 13 && TID_RE.test(input);
5
+ };
6
+ //# sourceMappingURL=tid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tid.js","sourceRoot":"","sources":["../../lib/syntax/tid.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,GAAG,4DAA4D,CAAC;AAE5E,uBAAuB;AACvB,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAc,EAAgB,EAAE;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/E,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * represents a generic URI
3
+ */
4
+ export type GenericUri = `${string}:${string}`;
5
+ export declare const isGenericUri: (input: unknown) => input is GenericUri;
@@ -0,0 +1,6 @@
1
+ const URI_RE = /^\w+:(?:\/\/)?[^\s/][^\s]*$/;
2
+ // #__NO_SIDE_EFFECTS__
3
+ export const isGenericUri = (input) => {
4
+ return typeof input === 'string' && input.length >= 3 && URI_RE.test(input);
5
+ };
6
+ //# sourceMappingURL=uri.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uri.js","sourceRoot":"","sources":["../../lib/syntax/uri.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,GAAG,6BAA6B,CAAC;AAE7C,uBAAuB;AACvB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuB,EAAE;IACnE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare namespace $type {
2
+ type get<TObject extends {
3
+ $type?: string;
4
+ }> = NonNullable<TObject['$type']>;
5
+ type enforce<TObject extends {
6
+ $type?: string;
7
+ }> = TObject extends any ? undefined extends TObject['$type'] ? TObject & {
8
+ $type: NonNullable<TObject['$type']>;
9
+ } : TObject : never;
10
+ type omit<TObject extends {
11
+ $type?: string;
12
+ }> = Omit<TObject, '$type'>;
13
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=brand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand.js","sourceRoot":"","sources":["../../lib/types/brand.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export type Result<T, E> = {
2
+ ok: true;
3
+ value: T;
4
+ } | {
5
+ ok: false;
6
+ error: E;
7
+ };
8
+ export declare const assert: {
9
+ (condition: any, message?: string): asserts condition;
10
+ };
11
+ export declare const assertNever: (_: never, message?: string) => never;