@atcute/lex-cli 2.3.3 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -4
- package/dist/cli.js +13 -162
- package/dist/cli.js.map +1 -1
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +76 -78
- package/dist/codegen.js.map +1 -1
- package/dist/commands/export.d.ts +13 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +76 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/generate.d.ts +13 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +136 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/pull.d.ts +13 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +163 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/config.d.ts +99 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +82 -25
- package/dist/config.js.map +1 -1
- package/dist/git.d.ts +27 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +73 -0
- package/dist/git.js.map +1 -0
- package/dist/lexicon-loader.d.ts +17 -0
- package/dist/lexicon-loader.d.ts.map +1 -0
- package/dist/lexicon-loader.js +167 -0
- package/dist/lexicon-loader.js.map +1 -0
- package/dist/pull-sources/atproto.d.ts +9 -0
- package/dist/pull-sources/atproto.d.ts.map +1 -0
- package/dist/pull-sources/atproto.js +192 -0
- package/dist/pull-sources/atproto.js.map +1 -0
- package/dist/pull-sources/git.d.ts +11 -0
- package/dist/pull-sources/git.d.ts.map +1 -0
- package/dist/pull-sources/git.js +80 -0
- package/dist/pull-sources/git.js.map +1 -0
- package/dist/pull-sources/types.d.ts +16 -0
- package/dist/pull-sources/types.d.ts.map +1 -0
- package/dist/pull-sources/types.js +2 -0
- package/dist/pull-sources/types.js.map +1 -0
- package/dist/shared-options.d.ts +6 -0
- package/dist/shared-options.d.ts.map +1 -0
- package/dist/shared-options.js +11 -0
- package/dist/shared-options.js.map +1 -0
- package/package.json +10 -7
- package/src/cli.ts +11 -198
- package/src/codegen.ts +90 -88
- package/src/commands/export.ts +106 -0
- package/src/commands/generate.ts +170 -0
- package/src/commands/pull.ts +231 -0
- package/src/config.ts +102 -30
- package/src/git.ts +104 -0
- package/src/lexicon-loader.ts +199 -0
- package/src/pull-sources/atproto.ts +243 -0
- package/src/pull-sources/git.ts +103 -0
- package/src/pull-sources/types.ts +18 -0
- package/src/shared-options.ts +13 -0
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,78 @@
|
|
|
1
1
|
import * as v from '@badrap/valita';
|
|
2
2
|
import type { ImportMapping } from './codegen.js';
|
|
3
|
+
declare const gitSourceConfigSchema: v.ObjectType<{
|
|
4
|
+
type: v.Type<"git">;
|
|
5
|
+
remote: v.Type<string>;
|
|
6
|
+
ref: v.Optional<string>;
|
|
7
|
+
pattern: v.Type<string[]>;
|
|
8
|
+
}, undefined>;
|
|
9
|
+
declare const atprotoNsidsSourceConfigSchema: v.ObjectType<{
|
|
10
|
+
type: v.Type<"atproto">;
|
|
11
|
+
mode: v.Type<"nsids">;
|
|
12
|
+
nsids: v.Type<`${string}.${string}.${string}`[]>;
|
|
13
|
+
}, undefined>;
|
|
14
|
+
declare const atprotoAuthoritySourceConfigSchema: v.ObjectType<{
|
|
15
|
+
type: v.Type<"atproto">;
|
|
16
|
+
mode: v.Type<"authority">;
|
|
17
|
+
authority: v.Type<`${string}.${string}` | `did:plc:${string}` | `did:web:${string}`>;
|
|
18
|
+
pattern: v.Optional<string[]>;
|
|
19
|
+
}, undefined>;
|
|
20
|
+
declare const atprotoSourceConfigSchema: v.UnionType<[v.ObjectType<{
|
|
21
|
+
type: v.Type<"atproto">;
|
|
22
|
+
mode: v.Type<"nsids">;
|
|
23
|
+
nsids: v.Type<`${string}.${string}.${string}`[]>;
|
|
24
|
+
}, undefined>, v.ObjectType<{
|
|
25
|
+
type: v.Type<"atproto">;
|
|
26
|
+
mode: v.Type<"authority">;
|
|
27
|
+
authority: v.Type<`${string}.${string}` | `did:plc:${string}` | `did:web:${string}`>;
|
|
28
|
+
pattern: v.Optional<string[]>;
|
|
29
|
+
}, undefined>]>;
|
|
30
|
+
declare const sourceConfigSchema: v.UnionType<[v.ObjectType<{
|
|
31
|
+
type: v.Type<"git">;
|
|
32
|
+
remote: v.Type<string>;
|
|
33
|
+
ref: v.Optional<string>;
|
|
34
|
+
pattern: v.Type<string[]>;
|
|
35
|
+
}, undefined>, v.UnionType<[v.ObjectType<{
|
|
36
|
+
type: v.Type<"atproto">;
|
|
37
|
+
mode: v.Type<"nsids">;
|
|
38
|
+
nsids: v.Type<`${string}.${string}.${string}`[]>;
|
|
39
|
+
}, undefined>, v.ObjectType<{
|
|
40
|
+
type: v.Type<"atproto">;
|
|
41
|
+
mode: v.Type<"authority">;
|
|
42
|
+
authority: v.Type<`${string}.${string}` | `did:plc:${string}` | `did:web:${string}`>;
|
|
43
|
+
pattern: v.Optional<string[]>;
|
|
44
|
+
}, undefined>]>]>;
|
|
45
|
+
declare const pullConfigSchema: v.ObjectType<{
|
|
46
|
+
outdir: v.Type<string>;
|
|
47
|
+
clean: v.Optional<boolean>;
|
|
48
|
+
sources: v.Type<({
|
|
49
|
+
type: "atproto";
|
|
50
|
+
mode: "nsids";
|
|
51
|
+
nsids: `${string}.${string}.${string}`[];
|
|
52
|
+
} | {
|
|
53
|
+
type: "atproto";
|
|
54
|
+
mode: "authority";
|
|
55
|
+
authority: `${string}.${string}` | `did:plc:${string}` | `did:web:${string}`;
|
|
56
|
+
pattern?: string[] | undefined;
|
|
57
|
+
} | {
|
|
58
|
+
type: "git";
|
|
59
|
+
remote: string;
|
|
60
|
+
ref?: string | undefined;
|
|
61
|
+
pattern: string[];
|
|
62
|
+
})[]>;
|
|
63
|
+
}, undefined>;
|
|
64
|
+
declare const exportConfigSchema: v.ObjectType<{
|
|
65
|
+
outdir: v.Type<string>;
|
|
66
|
+
files: v.Optional<string[]>;
|
|
67
|
+
clean: v.Optional<boolean>;
|
|
68
|
+
}, undefined>;
|
|
69
|
+
export type GitSourceConfig = v.Infer<typeof gitSourceConfigSchema>;
|
|
70
|
+
export type AtprotoNsidsSourceConfig = v.Infer<typeof atprotoNsidsSourceConfigSchema>;
|
|
71
|
+
export type AtprotoAuthoritySourceConfig = v.Infer<typeof atprotoAuthoritySourceConfigSchema>;
|
|
72
|
+
export type AtprotoSourceConfig = v.Infer<typeof atprotoSourceConfigSchema>;
|
|
73
|
+
export type SourceConfig = v.Infer<typeof sourceConfigSchema>;
|
|
74
|
+
export type PullConfig = v.Infer<typeof pullConfigSchema>;
|
|
75
|
+
export type ExportConfig = v.Infer<typeof exportConfigSchema>;
|
|
3
76
|
export declare const lexiconConfigSchema: v.ObjectType<{
|
|
4
77
|
outdir: v.Type<string>;
|
|
5
78
|
files: v.Type<string[]>;
|
|
@@ -8,10 +81,35 @@ export declare const lexiconConfigSchema: v.ObjectType<{
|
|
|
8
81
|
modules: v.Optional<{
|
|
9
82
|
importSuffix?: string | undefined;
|
|
10
83
|
}>;
|
|
84
|
+
pull: v.Optional<{
|
|
85
|
+
outdir: string;
|
|
86
|
+
clean?: boolean | undefined;
|
|
87
|
+
sources: ({
|
|
88
|
+
type: "atproto";
|
|
89
|
+
mode: "nsids";
|
|
90
|
+
nsids: `${string}.${string}.${string}`[];
|
|
91
|
+
} | {
|
|
92
|
+
type: "atproto";
|
|
93
|
+
mode: "authority";
|
|
94
|
+
authority: `${string}.${string}` | `did:plc:${string}` | `did:web:${string}`;
|
|
95
|
+
pattern?: string[] | undefined;
|
|
96
|
+
} | {
|
|
97
|
+
type: "git";
|
|
98
|
+
remote: string;
|
|
99
|
+
ref?: string | undefined;
|
|
100
|
+
pattern: string[];
|
|
101
|
+
})[];
|
|
102
|
+
}>;
|
|
103
|
+
export: v.Optional<{
|
|
104
|
+
outdir: string;
|
|
105
|
+
files?: string[] | undefined;
|
|
106
|
+
clean?: boolean | undefined;
|
|
107
|
+
}>;
|
|
11
108
|
}, undefined>;
|
|
12
109
|
export type LexiconConfig = v.Infer<typeof lexiconConfigSchema>;
|
|
13
110
|
export interface NormalizedConfig extends LexiconConfig {
|
|
14
111
|
root: string;
|
|
15
112
|
}
|
|
16
|
-
export declare const loadConfig: (configPath
|
|
113
|
+
export declare const loadConfig: (configPath?: string) => Promise<NormalizedConfig>;
|
|
114
|
+
export {};
|
|
17
115
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAMpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,QAAA,MAAM,qBAAqB;;;;;aAUzB,CAAC;AAEH,QAAA,MAAM,8BAA8B;;;;aAMlC,CAAC;AAEH,QAAA,MAAM,kCAAkC;;;;;aAatC,CAAC;AAEH,QAAA,MAAM,yBAAyB;;;;;;;;;eAA8E,CAAC;AAE9G,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;iBAA4D,CAAC;AAErF,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;aAMpB,CAAC;AAEH,QAAA,MAAM,kBAAkB;;;;aAItB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAC9F,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAyC9D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAkB9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD,IAAI,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,UAAU,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC,gBAAgB,CAsD9E,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,8 +1,54 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
1
2
|
import * as path from 'node:path';
|
|
2
3
|
import * as url from 'node:url';
|
|
3
4
|
import * as v from '@badrap/valita';
|
|
4
5
|
import pc from 'picocolors';
|
|
5
|
-
import {
|
|
6
|
+
import { isAtprotoDid } from '@atcute/identity';
|
|
7
|
+
import { isHandle, isNsid } from '@atcute/lexicons/syntax';
|
|
8
|
+
const gitSourceConfigSchema = v.object({
|
|
9
|
+
type: v.literal('git'),
|
|
10
|
+
remote: v.string().assert((value) => value.length > 0, `must not be empty`),
|
|
11
|
+
ref: v
|
|
12
|
+
.string()
|
|
13
|
+
.assert((value) => value.length > 0, `must not be empty`)
|
|
14
|
+
.optional(),
|
|
15
|
+
pattern: v
|
|
16
|
+
.array(v.string().assert((value) => value.length > 0, `must not be empty`))
|
|
17
|
+
.assert((value) => value.length > 0, `must include at least one glob pattern`),
|
|
18
|
+
});
|
|
19
|
+
const atprotoNsidsSourceConfigSchema = v.object({
|
|
20
|
+
type: v.literal('atproto'),
|
|
21
|
+
mode: v.literal('nsids'),
|
|
22
|
+
nsids: v
|
|
23
|
+
.array(v.string().assert((value) => isNsid(value), `must be valid nsid`))
|
|
24
|
+
.assert((value) => value.length > 0, `must include at least one nsid`),
|
|
25
|
+
});
|
|
26
|
+
const atprotoAuthoritySourceConfigSchema = v.object({
|
|
27
|
+
type: v.literal('atproto'),
|
|
28
|
+
mode: v.literal('authority'),
|
|
29
|
+
authority: v
|
|
30
|
+
.string()
|
|
31
|
+
.assert((value) => isHandle(value) || isAtprotoDid(value), `must a valid at-identifier`),
|
|
32
|
+
pattern: v
|
|
33
|
+
.array(v
|
|
34
|
+
.string()
|
|
35
|
+
.assert((value) => isValidLexiconPattern(value), `must be valid nsid or pattern ending with .*`))
|
|
36
|
+
.optional(),
|
|
37
|
+
});
|
|
38
|
+
const atprotoSourceConfigSchema = v.union(atprotoNsidsSourceConfigSchema, atprotoAuthoritySourceConfigSchema);
|
|
39
|
+
const sourceConfigSchema = v.union(gitSourceConfigSchema, atprotoSourceConfigSchema);
|
|
40
|
+
const pullConfigSchema = v.object({
|
|
41
|
+
outdir: v.string().assert((value) => value.length > 0, `must not be empty`),
|
|
42
|
+
clean: v.boolean().optional(),
|
|
43
|
+
sources: v
|
|
44
|
+
.array(sourceConfigSchema)
|
|
45
|
+
.assert((value) => value.length > 0, `must include at least one source`),
|
|
46
|
+
});
|
|
47
|
+
const exportConfigSchema = v.object({
|
|
48
|
+
outdir: v.string().assert((value) => value.length > 0, `must not be empty`),
|
|
49
|
+
files: v.array(v.string().assert((value) => value.length > 0, `must not be empty`)).optional(),
|
|
50
|
+
clean: v.boolean().optional(),
|
|
51
|
+
});
|
|
6
52
|
const isValidLexiconPattern = (pattern) => {
|
|
7
53
|
if (pattern.endsWith('.*')) {
|
|
8
54
|
return isNsid(`${pattern.slice(0, -2)}.x`);
|
|
@@ -12,59 +58,70 @@ const isValidLexiconPattern = (pattern) => {
|
|
|
12
58
|
const mappingImports = v.unknown().chain((value) => {
|
|
13
59
|
if (typeof value === 'string') {
|
|
14
60
|
if (value.length === 0) {
|
|
15
|
-
return v.err(
|
|
61
|
+
return v.err('imports must not be empty');
|
|
16
62
|
}
|
|
17
63
|
return v.ok(value);
|
|
18
64
|
}
|
|
19
65
|
if (typeof value === 'function') {
|
|
20
66
|
return v.ok(value);
|
|
21
67
|
}
|
|
22
|
-
return v.err(
|
|
68
|
+
return v.err('imports must be a string or function');
|
|
23
69
|
});
|
|
24
70
|
const importMappingSchema = v.object({
|
|
25
71
|
nsid: v
|
|
26
72
|
.array(v.string().chain((value) => {
|
|
27
73
|
if (!isValidLexiconPattern(value)) {
|
|
28
|
-
return v.err(
|
|
29
|
-
message: 'invalid NSID pattern (must be valid NSID or end with .*)',
|
|
30
|
-
});
|
|
74
|
+
return v.err(`invalid NSID pattern (must be valid NSID or end with .*)`);
|
|
31
75
|
}
|
|
32
76
|
return v.ok(value);
|
|
33
77
|
}))
|
|
34
|
-
.assert((patterns) => patterns.length > 0,
|
|
35
|
-
message: 'nsid requires at least one pattern',
|
|
36
|
-
}),
|
|
78
|
+
.assert((patterns) => patterns.length > 0, `nsid requires at least one pattern`),
|
|
37
79
|
imports: mappingImports,
|
|
38
80
|
});
|
|
39
81
|
export const lexiconConfigSchema = v.object({
|
|
40
|
-
outdir: v.string().assert((value) => value.length > 0,
|
|
41
|
-
message: 'outdir must not be empty',
|
|
42
|
-
}),
|
|
82
|
+
outdir: v.string().assert((value) => value.length > 0, `must not be empty`),
|
|
43
83
|
files: v
|
|
44
|
-
.array(v.string().assert((value) => value.length > 0,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.assert((value) => value.length > 0, {
|
|
48
|
-
message: 'files must include at least one pattern',
|
|
49
|
-
}),
|
|
50
|
-
imports: v
|
|
51
|
-
.array(v.string().assert((value) => value.length > 0, {
|
|
52
|
-
message: 'imports entries must not be empty',
|
|
53
|
-
}))
|
|
54
|
-
.optional(),
|
|
84
|
+
.array(v.string().assert((value) => value.length > 0, `must not be empty`))
|
|
85
|
+
.assert((value) => value.length > 0, `must include at least one glob pattern`),
|
|
86
|
+
imports: v.array(v.string().assert((value) => value.length > 0, `must not be empty`)).optional(),
|
|
55
87
|
mappings: v.array(importMappingSchema).optional(),
|
|
56
88
|
modules: v
|
|
57
89
|
.object({
|
|
58
90
|
importSuffix: v
|
|
59
91
|
.string()
|
|
60
|
-
.assert((value) => value.length > 0,
|
|
92
|
+
.assert((value) => value.length > 0, `must not be empty`)
|
|
61
93
|
.optional(),
|
|
62
94
|
})
|
|
63
95
|
.partial()
|
|
64
96
|
.optional(),
|
|
97
|
+
pull: pullConfigSchema.optional(),
|
|
98
|
+
export: exportConfigSchema.optional(),
|
|
65
99
|
});
|
|
66
100
|
export const loadConfig = async (configPath) => {
|
|
67
|
-
|
|
101
|
+
let configFilename;
|
|
102
|
+
if (configPath) {
|
|
103
|
+
configFilename = path.resolve(configPath);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// try to find lex.config.js or lex.config.ts in the current directory
|
|
107
|
+
const candidates = ['lex.config.js', 'lex.config.ts'];
|
|
108
|
+
for (const candidate of candidates) {
|
|
109
|
+
const candidatePath = path.resolve(candidate);
|
|
110
|
+
try {
|
|
111
|
+
await fs.access(candidatePath);
|
|
112
|
+
configFilename = candidatePath;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// file doesn't exist, try next candidate
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (!configFilename) {
|
|
120
|
+
console.error(pc.bold(pc.red(`config file not found`)));
|
|
121
|
+
console.error(`looked for: ${candidates.join(', ')}`);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
68
125
|
const configDirname = path.dirname(configFilename);
|
|
69
126
|
let rawConfig;
|
|
70
127
|
try {
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAI3D,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACtB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,mBAAmB,CAAC;IAC3E,GAAG,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,mBAAmB,CAAC;SACxD,QAAQ,EAAE;IACZ,OAAO,EAAE,CAAC;SACR,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,mBAAmB,CAAC,CAA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EAAE,EAAE,CAAC;QACtB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAClD,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEpC,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;YACzC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,EAAE,GAAG,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AACvD,CAAC,CAAC"}
|
package/dist/git.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface GitCommandOptions {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
env?: NodeJS.ProcessEnv;
|
|
4
|
+
stdin?: string;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface GitResult {
|
|
8
|
+
stdout: string;
|
|
9
|
+
stderr: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class GitError extends Error {
|
|
12
|
+
readonly args: readonly string[];
|
|
13
|
+
readonly code: number | null;
|
|
14
|
+
readonly signal: NodeJS.Signals | null;
|
|
15
|
+
readonly stdout: string;
|
|
16
|
+
readonly stderr: string;
|
|
17
|
+
constructor(args: readonly string[], stdout: string, stderr: string, code: number | null, signal: NodeJS.Signals | null);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* runs git with the provided arguments and throws when the command fails.
|
|
21
|
+
* @param args positional arguments for git
|
|
22
|
+
* @param options execution options
|
|
23
|
+
* @returns stdout and stderr from git
|
|
24
|
+
* @throws GitError when git exits with a non-zero status or is terminated
|
|
25
|
+
*/
|
|
26
|
+
export declare const runGit: (args: readonly string[], options?: GitCommandOptions) => Promise<GitResult>;
|
|
27
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,QAAS,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGvB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI;CAY9B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAI,MAAM,SAAS,MAAM,EAAE,EAAE,UAAS,iBAAsB,KAAG,OAAO,CAAC,SAAS,CAwDlG,CAAC"}
|
package/dist/git.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export class GitError extends Error {
|
|
3
|
+
args;
|
|
4
|
+
code;
|
|
5
|
+
signal;
|
|
6
|
+
stdout;
|
|
7
|
+
stderr;
|
|
8
|
+
constructor(args, stdout, stderr, code, signal) {
|
|
9
|
+
const reason = code !== null ? `code ${code}` : `signal ${signal ?? 'unknown'}`;
|
|
10
|
+
super(`git ${args.join(' ')} failed with ${reason}`);
|
|
11
|
+
this.name = 'GitError';
|
|
12
|
+
this.args = args;
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.signal = signal;
|
|
15
|
+
this.stdout = stdout;
|
|
16
|
+
this.stderr = stderr;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* runs git with the provided arguments and throws when the command fails.
|
|
21
|
+
* @param args positional arguments for git
|
|
22
|
+
* @param options execution options
|
|
23
|
+
* @returns stdout and stderr from git
|
|
24
|
+
* @throws GitError when git exits with a non-zero status or is terminated
|
|
25
|
+
*/
|
|
26
|
+
export const runGit = (args, options = {}) => {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const child = spawn('git', args, {
|
|
29
|
+
cwd: options.cwd,
|
|
30
|
+
env: options.env,
|
|
31
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
32
|
+
});
|
|
33
|
+
let stdout = '';
|
|
34
|
+
let stderr = '';
|
|
35
|
+
child.stdout?.setEncoding('utf8');
|
|
36
|
+
child.stderr?.setEncoding('utf8');
|
|
37
|
+
child.stdout?.on('data', (chunk) => {
|
|
38
|
+
stdout += chunk;
|
|
39
|
+
});
|
|
40
|
+
child.stderr?.on('data', (chunk) => {
|
|
41
|
+
stderr += chunk;
|
|
42
|
+
});
|
|
43
|
+
let timer;
|
|
44
|
+
if (options.timeoutMs !== undefined) {
|
|
45
|
+
timer = setTimeout(() => {
|
|
46
|
+
child.kill('SIGKILL');
|
|
47
|
+
}, options.timeoutMs);
|
|
48
|
+
}
|
|
49
|
+
child.on('error', (err) => {
|
|
50
|
+
if (timer) {
|
|
51
|
+
clearTimeout(timer);
|
|
52
|
+
}
|
|
53
|
+
reject(err);
|
|
54
|
+
});
|
|
55
|
+
child.on('close', (code, signal) => {
|
|
56
|
+
if (timer) {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
}
|
|
59
|
+
if (code === 0) {
|
|
60
|
+
resolve({ stdout, stderr });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
reject(new GitError(args, stdout, stderr, code, signal));
|
|
64
|
+
});
|
|
65
|
+
if (options.stdin !== undefined) {
|
|
66
|
+
child.stdin?.end(options.stdin);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
child.stdin?.end();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAc3C,MAAM,OAAO,QAAS,SAAQ,KAAK;IACzB,IAAI,CAAoB;IACxB,IAAI,CAAgB;IACpB,MAAM,CAAwB;IAC9B,MAAM,CAAS;IACf,MAAM,CAAS;IAExB,YACC,IAAuB,EACvB,MAAc,EACd,MAAc,EACd,IAAmB,EACnB,MAA6B;QAE7B,MAAM,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,MAAM,IAAI,SAAS,EAAE,CAAC;QAChF,KAAK,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,MAAM,EAAE,CAAC,CAAC;QAErD,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;Q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AC,KAAK,CAAC,CAAC;YACrB,CAAC;YAED,MAAM,CAAC,GAAG,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YAClC,IAAI,KAAK,EAAE,CAAC;gBACX,YAAY,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;YAED,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBAChB,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC5B,OAAO;YACR,CAAC;YAED,MAAM,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACjC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACP,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;QACpB,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type LexiconDoc } from '@atcute/lexicon-doc';
|
|
2
|
+
/**
|
|
3
|
+
* represents a loaded lexicon document with its source file
|
|
4
|
+
*/
|
|
5
|
+
export interface LoadedLexicon {
|
|
6
|
+
nsid: string;
|
|
7
|
+
doc: LexiconDoc;
|
|
8
|
+
filename: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* loads lexicon documents from glob patterns
|
|
12
|
+
* @param patterns glob patterns to match files
|
|
13
|
+
* @param root root directory for resolving paths
|
|
14
|
+
* @returns array of loaded lexicon documents
|
|
15
|
+
*/
|
|
16
|
+
export declare const loadLexicons: (patterns: string[], root: string) => Promise<LoadedLexicon[]>;
|
|
17
|
+
//# sourceMappingURL=lexicon-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexicon-loader.d.ts","sourceRoot":"","sources":["../src/lexicon-loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAQpF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACjB;AA0GD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,UAAU,MAAM,EAAE,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,aAAa,EAAE,CAmE5F,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import * as url from 'node:url';
|
|
4
|
+
import { lexiconDoc, refineLexiconDoc } from '@atcute/lexicon-doc';
|
|
5
|
+
import { build } from '@atcute/lexicon-doc/builder';
|
|
6
|
+
import pc from 'picocolors';
|
|
7
|
+
/** file extensions recognized as module files */
|
|
8
|
+
const MODULE_EXTENSIONS = new Set(['.js', '.cjs', '.mjs', '.ts', '.cts', '.mts']);
|
|
9
|
+
/**
|
|
10
|
+
* checks if a filename is a module file based on extension
|
|
11
|
+
* @param filename the filename to check
|
|
12
|
+
* @returns true if it's a module file
|
|
13
|
+
*/
|
|
14
|
+
const isModuleFile = (filename) => {
|
|
15
|
+
const ext = path.extname(filename);
|
|
16
|
+
return MODULE_EXTENSIONS.has(ext);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* basic validation that a value looks like a LexDocumentBuilder
|
|
20
|
+
* @param value the value to check
|
|
21
|
+
* @returns true if it appears to be a LexDocumentBuilder
|
|
22
|
+
*/
|
|
23
|
+
const isLexDocumentBuilder = (value) => {
|
|
24
|
+
return (typeof value === 'object' &&
|
|
25
|
+
value !== null &&
|
|
26
|
+
'id' in value &&
|
|
27
|
+
typeof value.id === 'string' &&
|
|
28
|
+
'defs' in value &&
|
|
29
|
+
typeof value.defs === 'object');
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* loads and validates a lexicon document from a JSON file
|
|
33
|
+
* @param absolutePath absolute path to the JSON file
|
|
34
|
+
* @param relativePath relative path for error messages
|
|
35
|
+
* @returns parsed and validated lexicon document
|
|
36
|
+
*/
|
|
37
|
+
const loadJsonFile = async (absolutePath, relativePath) => {
|
|
38
|
+
let source;
|
|
39
|
+
try {
|
|
40
|
+
source = await fs.readFile(absolutePath, 'utf8');
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error(pc.bold(pc.red(`file read error with "${relativePath}"`)));
|
|
44
|
+
console.error(err);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
let json;
|
|
48
|
+
try {
|
|
49
|
+
json = JSON.parse(source);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
console.error(pc.bold(pc.red(`json parse error in "${relativePath}"`)));
|
|
53
|
+
console.error(err);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
const result = lexiconDoc.try(json, { mode: 'strip' });
|
|
57
|
+
if (!result.ok) {
|
|
58
|
+
console.error(pc.bold(pc.red(`schema validation failed for "${relativePath}"`)));
|
|
59
|
+
console.error(result.message);
|
|
60
|
+
for (const issue of result.issues) {
|
|
61
|
+
console.log(`- ${issue.code} at .${issue.path.join('.')}`);
|
|
62
|
+
}
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
const issues = refineLexiconDoc(result.value, true);
|
|
66
|
+
if (issues.length > 0) {
|
|
67
|
+
console.error(pc.bold(pc.red(`lint validation failed for "${relativePath}"`)));
|
|
68
|
+
for (const issue of issues) {
|
|
69
|
+
console.log(`- ${issue.message} at .${issue.path.join('.')}`);
|
|
70
|
+
}
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
return result.value;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* loads a LexDocumentBuilder from a module file
|
|
77
|
+
* @param absolutePath absolute path to the module file
|
|
78
|
+
* @param relativePath relative path for error messages
|
|
79
|
+
* @returns the LexDocumentBuilder from the module's default export
|
|
80
|
+
*/
|
|
81
|
+
const loadModuleBuilder = async (absolutePath, relativePath) => {
|
|
82
|
+
let mod;
|
|
83
|
+
try {
|
|
84
|
+
const fileUrl = url.pathToFileURL(absolutePath);
|
|
85
|
+
mod = await import(fileUrl.href);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
console.error(pc.bold(pc.red(`failed to import module "${relativePath}"`)));
|
|
89
|
+
console.error(err);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
const defaultExport = mod?.default;
|
|
93
|
+
if (!isLexDocumentBuilder(defaultExport)) {
|
|
94
|
+
console.error(pc.bold(pc.red(`module "${relativePath}" default export is not a valid LexDocumentBuilder`)));
|
|
95
|
+
console.error(`expected default export to be a LexDocumentBuilder (object with 'id' and 'defs')`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
return defaultExport;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* loads lexicon documents from glob patterns
|
|
102
|
+
* @param patterns glob patterns to match files
|
|
103
|
+
* @param root root directory for resolving paths
|
|
104
|
+
* @returns array of loaded lexicon documents
|
|
105
|
+
*/
|
|
106
|
+
export const loadLexicons = async (patterns, root) => {
|
|
107
|
+
const results = [];
|
|
108
|
+
const seen = new Map();
|
|
109
|
+
// collect JSON docs and module builders separately
|
|
110
|
+
const jsonDocs = [];
|
|
111
|
+
const moduleBuilders = [];
|
|
112
|
+
for await (const filename of fs.glob(patterns, { cwd: root })) {
|
|
113
|
+
const absolutePath = path.join(root, filename);
|
|
114
|
+
if (isModuleFile(filename)) {
|
|
115
|
+
const builder = await loadModuleBuilder(absolutePath, filename);
|
|
116
|
+
moduleBuilders.push({ builder, filename });
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
// assume JSON for anything else (including .json)
|
|
120
|
+
const doc = await loadJsonFile(absolutePath, filename);
|
|
121
|
+
jsonDocs.push({ doc, filename });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// add JSON docs directly (already built)
|
|
125
|
+
for (const { doc, filename } of jsonDocs) {
|
|
126
|
+
const existing = seen.get(doc.id);
|
|
127
|
+
if (existing) {
|
|
128
|
+
console.error(pc.bold(pc.red(`duplicate lexicon "${doc.id}"`)));
|
|
129
|
+
console.error(`- found in ${filename}`);
|
|
130
|
+
console.error(`- already found in ${existing}`);
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
seen.set(doc.id, filename);
|
|
134
|
+
results.push({ nsid: doc.id, doc, filename });
|
|
135
|
+
}
|
|
136
|
+
// build all module builders together (for cross-references)
|
|
137
|
+
if (moduleBuilders.length > 0) {
|
|
138
|
+
// check for duplicates in builders
|
|
139
|
+
const buildersByNsid = new Map();
|
|
140
|
+
for (const { builder, filename } of moduleBuilders) {
|
|
141
|
+
const existing = buildersByNsid.get(builder.id) ?? seen.get(builder.id);
|
|
142
|
+
if (existing) {
|
|
143
|
+
console.error(pc.bold(pc.red(`duplicate lexicon "${builder.id}"`)));
|
|
144
|
+
console.error(`- found in ${filename}`);
|
|
145
|
+
console.error(`- already found in ${existing}`);
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
buildersByNsid.set(builder.id, filename);
|
|
149
|
+
}
|
|
150
|
+
let built;
|
|
151
|
+
try {
|
|
152
|
+
built = build({ documents: moduleBuilders.map((m) => m.builder) });
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
console.error(pc.bold(pc.red(`build failed for module lexicons`)));
|
|
156
|
+
console.error(err);
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
for (const { builder, filename } of moduleBuilders) {
|
|
160
|
+
const doc = built[builder.id];
|
|
161
|
+
seen.set(builder.id, filename);
|
|
162
|
+
results.push({ nsid: builder.id, doc, filename });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return results;
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=lexicon-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexicon-loader.js","sourceRoot":"","sources":["../src/lexicon-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAmB,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,KAAK,EAA2B,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,iDAAiD;AACjD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAWlF;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAW,EAAE;IAClD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,OAAO,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,KAAc,EAA+B,EAAE;IAC5E,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,IAAI,IAAI,KAAK;QACb,OAAQ,KAAa,CAAC,EAAE,KAAK,QAAQ;QACrC,MAAM,IAAI,KAAK;QACf,OAAQ,KAAa,CAAC,IAAI,KAAK,QAAQ,CACvC,CA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AC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AtprotoSourceConfig } from '../config.js';
|
|
2
|
+
import type { PullResult } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* pulls lexicon documents from AT Protocol network resolution
|
|
5
|
+
* @param source atproto source configuration
|
|
6
|
+
* @returns pulled lexicons and ISO timestamp
|
|
7
|
+
*/
|
|
8
|
+
export declare const pullAtprotoSource: (source: AtprotoSourceConfig) => Promise<PullResult>;
|
|
9
|
+
//# sourceMappingURL=atproto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atproto.d.ts","sourceRoot":"","sources":["../../src/pull-sources/atproto.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AAoE7D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAU,QAAQ,mBAAmB,KAAG,OAAO,CAAC,UAAU,CAmJvF,CAAC"}
|